mach-vr1000.c 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  1. /* linux/arch/arm/mach-s3c2410/mach-vr1000.c
  2. *
  3. * Copyright (c) 2003-2008 Simtec Electronics
  4. * Ben Dooks <ben@simtec.co.uk>
  5. *
  6. * Machine support for Thorcom VR1000 board. Designed for Thorcom by
  7. * Simtec Electronics, http://www.simtec.co.uk/
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. *
  13. */
  14. #include <linux/kernel.h>
  15. #include <linux/types.h>
  16. #include <linux/interrupt.h>
  17. #include <linux/list.h>
  18. #include <linux/timer.h>
  19. #include <linux/init.h>
  20. #include <linux/gpio.h>
  21. #include <linux/dm9000.h>
  22. #include <linux/i2c.h>
  23. #include <linux/serial.h>
  24. #include <linux/tty.h>
  25. #include <linux/serial_8250.h>
  26. #include <linux/serial_reg.h>
  27. #include <linux/io.h>
  28. #include <asm/mach/arch.h>
  29. #include <asm/mach/map.h>
  30. #include <asm/mach/irq.h>
  31. #include <mach/bast-map.h>
  32. #include <mach/vr1000-map.h>
  33. #include <mach/vr1000-irq.h>
  34. #include <mach/vr1000-cpld.h>
  35. #include <mach/hardware.h>
  36. #include <asm/irq.h>
  37. #include <asm/mach-types.h>
  38. #include <plat/regs-serial.h>
  39. #include <mach/regs-gpio.h>
  40. #include <mach/leds-gpio.h>
  41. #include <plat/clock.h>
  42. #include <plat/devs.h>
  43. #include <plat/cpu.h>
  44. #include <plat/iic.h>
  45. #include <plat/audio-simtec.h>
  46. #include "usb-simtec.h"
  47. #include "nor-simtec.h"
  48. #include "common.h"
  49. /* macros for virtual address mods for the io space entries */
  50. #define VA_C5(item) ((unsigned long)(item) + BAST_VAM_CS5)
  51. #define VA_C4(item) ((unsigned long)(item) + BAST_VAM_CS4)
  52. #define VA_C3(item) ((unsigned long)(item) + BAST_VAM_CS3)
  53. #define VA_C2(item) ((unsigned long)(item) + BAST_VAM_CS2)
  54. /* macros to modify the physical addresses for io space */
  55. #define PA_CS2(item) (__phys_to_pfn((item) + S3C2410_CS2))
  56. #define PA_CS3(item) (__phys_to_pfn((item) + S3C2410_CS3))
  57. #define PA_CS4(item) (__phys_to_pfn((item) + S3C2410_CS4))
  58. #define PA_CS5(item) (__phys_to_pfn((item) + S3C2410_CS5))
  59. static struct map_desc vr1000_iodesc[] __initdata = {
  60. /* ISA IO areas */
  61. {
  62. .virtual = (u32)S3C24XX_VA_ISA_BYTE,
  63. .pfn = PA_CS2(BAST_PA_ISAIO),
  64. .length = SZ_16M,
  65. .type = MT_DEVICE,
  66. }, {
  67. .virtual = (u32)S3C24XX_VA_ISA_WORD,
  68. .pfn = PA_CS3(BAST_PA_ISAIO),
  69. .length = SZ_16M,
  70. .type = MT_DEVICE,
  71. },
  72. /* CPLD control registers, and external interrupt controls */
  73. {
  74. .virtual = (u32)VR1000_VA_CTRL1,
  75. .pfn = __phys_to_pfn(VR1000_PA_CTRL1),
  76. .length = SZ_1M,
  77. .type = MT_DEVICE,
  78. }, {
  79. .virtual = (u32)VR1000_VA_CTRL2,
  80. .pfn = __phys_to_pfn(VR1000_PA_CTRL2),
  81. .length = SZ_1M,
  82. .type = MT_DEVICE,
  83. }, {
  84. .virtual = (u32)VR1000_VA_CTRL3,
  85. .pfn = __phys_to_pfn(VR1000_PA_CTRL3),
  86. .length = SZ_1M,
  87. .type = MT_DEVICE,
  88. }, {
  89. .virtual = (u32)VR1000_VA_CTRL4,
  90. .pfn = __phys_to_pfn(VR1000_PA_CTRL4),
  91. .length = SZ_1M,
  92. .type = MT_DEVICE,
  93. },
  94. };
  95. #define UCON S3C2410_UCON_DEFAULT | S3C2410_UCON_UCLK
  96. #define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB
  97. #define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
  98. static struct s3c2410_uartcfg vr1000_uartcfgs[] __initdata = {
  99. [0] = {
  100. .hwport = 0,
  101. .flags = 0,
  102. .ucon = UCON,
  103. .ulcon = ULCON,
  104. .ufcon = UFCON,
  105. },
  106. [1] = {
  107. .hwport = 1,
  108. .flags = 0,
  109. .ucon = UCON,
  110. .ulcon = ULCON,
  111. .ufcon = UFCON,
  112. },
  113. /* port 2 is not actually used */
  114. [2] = {
  115. .hwport = 2,
  116. .flags = 0,
  117. .ucon = UCON,
  118. .ulcon = ULCON,
  119. .ufcon = UFCON,
  120. }
  121. };
  122. /* definitions for the vr1000 extra 16550 serial ports */
  123. #define VR1000_BAUDBASE (3692307)
  124. #define VR1000_SERIAL_MAPBASE(x) (VR1000_PA_SERIAL + 0x80 + ((x) << 5))
  125. static struct plat_serial8250_port serial_platform_data[] = {
  126. [0] = {
  127. .mapbase = VR1000_SERIAL_MAPBASE(0),
  128. .irq = IRQ_VR1000_SERIAL + 0,
  129. .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
  130. .iotype = UPIO_MEM,
  131. .regshift = 0,
  132. .uartclk = VR1000_BAUDBASE,
  133. },
  134. [1] = {
  135. .mapbase = VR1000_SERIAL_MAPBASE(1),
  136. .irq = IRQ_VR1000_SERIAL + 1,
  137. .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
  138. .iotype = UPIO_MEM,
  139. .regshift = 0,
  140. .uartclk = VR1000_BAUDBASE,
  141. },
  142. [2] = {
  143. .mapbase = VR1000_SERIAL_MAPBASE(2),
  144. .irq = IRQ_VR1000_SERIAL + 2,
  145. .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
  146. .iotype = UPIO_MEM,
  147. .regshift = 0,
  148. .uartclk = VR1000_BAUDBASE,
  149. },
  150. [3] = {
  151. .mapbase = VR1000_SERIAL_MAPBASE(3),
  152. .irq = IRQ_VR1000_SERIAL + 3,
  153. .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
  154. .iotype = UPIO_MEM,
  155. .regshift = 0,
  156. .uartclk = VR1000_BAUDBASE,
  157. },
  158. { },
  159. };
  160. static struct platform_device serial_device = {
  161. .name = "serial8250",
  162. .id = PLAT8250_DEV_PLATFORM,
  163. .dev = {
  164. .platform_data = serial_platform_data,
  165. },
  166. };
  167. /* DM9000 ethernet devices */
  168. static struct resource vr1000_dm9k0_resource[] = {
  169. [0] = {
  170. .start = S3C2410_CS5 + VR1000_PA_DM9000,
  171. .end = S3C2410_CS5 + VR1000_PA_DM9000 + 3,
  172. .flags = IORESOURCE_MEM
  173. },
  174. [1] = {
  175. .start = S3C2410_CS5 + VR1000_PA_DM9000 + 0x40,
  176. .end = S3C2410_CS5 + VR1000_PA_DM9000 + 0x7f,
  177. .flags = IORESOURCE_MEM
  178. },
  179. [2] = {
  180. .start = IRQ_VR1000_DM9000A,
  181. .end = IRQ_VR1000_DM9000A,
  182. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  183. }
  184. };
  185. static struct resource vr1000_dm9k1_resource[] = {
  186. [0] = {
  187. .start = S3C2410_CS5 + VR1000_PA_DM9000 + 0x80,
  188. .end = S3C2410_CS5 + VR1000_PA_DM9000 + 0x83,
  189. .flags = IORESOURCE_MEM
  190. },
  191. [1] = {
  192. .start = S3C2410_CS5 + VR1000_PA_DM9000 + 0xC0,
  193. .end = S3C2410_CS5 + VR1000_PA_DM9000 + 0xFF,
  194. .flags = IORESOURCE_MEM
  195. },
  196. [2] = {
  197. .start = IRQ_VR1000_DM9000N,
  198. .end = IRQ_VR1000_DM9000N,
  199. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  200. }
  201. };
  202. /* for the moment we limit ourselves to 16bit IO until some
  203. * better IO routines can be written and tested
  204. */
  205. static struct dm9000_plat_data vr1000_dm9k_platdata = {
  206. .flags = DM9000_PLATF_16BITONLY,
  207. };
  208. static struct platform_device vr1000_dm9k0 = {
  209. .name = "dm9000",
  210. .id = 0,
  211. .num_resources = ARRAY_SIZE(vr1000_dm9k0_resource),
  212. .resource = vr1000_dm9k0_resource,
  213. .dev = {
  214. .platform_data = &vr1000_dm9k_platdata,
  215. }
  216. };
  217. static struct platform_device vr1000_dm9k1 = {
  218. .name = "dm9000",
  219. .id = 1,
  220. .num_resources = ARRAY_SIZE(vr1000_dm9k1_resource),
  221. .resource = vr1000_dm9k1_resource,
  222. .dev = {
  223. .platform_data = &vr1000_dm9k_platdata,
  224. }
  225. };
  226. /* LEDS */
  227. static struct s3c24xx_led_platdata vr1000_led1_pdata = {
  228. .name = "led1",
  229. .gpio = S3C2410_GPB(0),
  230. .def_trigger = "",
  231. };
  232. static struct s3c24xx_led_platdata vr1000_led2_pdata = {
  233. .name = "led2",
  234. .gpio = S3C2410_GPB(1),
  235. .def_trigger = "",
  236. };
  237. static struct s3c24xx_led_platdata vr1000_led3_pdata = {
  238. .name = "led3",
  239. .gpio = S3C2410_GPB(2),
  240. .def_trigger = "",
  241. };
  242. static struct platform_device vr1000_led1 = {
  243. .name = "s3c24xx_led",
  244. .id = 1,
  245. .dev = {
  246. .platform_data = &vr1000_led1_pdata,
  247. },
  248. };
  249. static struct platform_device vr1000_led2 = {
  250. .name = "s3c24xx_led",
  251. .id = 2,
  252. .dev = {
  253. .platform_data = &vr1000_led2_pdata,
  254. },
  255. };
  256. static struct platform_device vr1000_led3 = {
  257. .name = "s3c24xx_led",
  258. .id = 3,
  259. .dev = {
  260. .platform_data = &vr1000_led3_pdata,
  261. },
  262. };
  263. /* I2C devices. */
  264. static struct i2c_board_info vr1000_i2c_devs[] __initdata = {
  265. {
  266. I2C_BOARD_INFO("tlv320aic23", 0x1a),
  267. }, {
  268. I2C_BOARD_INFO("tmp101", 0x48),
  269. }, {
  270. I2C_BOARD_INFO("m41st87", 0x68),
  271. },
  272. };
  273. /* devices for this board */
  274. static struct platform_device *vr1000_devices[] __initdata = {
  275. &s3c_device_ohci,
  276. &s3c_device_lcd,
  277. &s3c_device_wdt,
  278. &s3c_device_i2c0,
  279. &s3c_device_adc,
  280. &serial_device,
  281. &vr1000_dm9k0,
  282. &vr1000_dm9k1,
  283. &vr1000_led1,
  284. &vr1000_led2,
  285. &vr1000_led3,
  286. };
  287. static struct clk *vr1000_clocks[] __initdata = {
  288. &s3c24xx_dclk0,
  289. &s3c24xx_dclk1,
  290. &s3c24xx_clkout0,
  291. &s3c24xx_clkout1,
  292. &s3c24xx_uclk,
  293. };
  294. static void vr1000_power_off(void)
  295. {
  296. gpio_direction_output(S3C2410_GPB(9), 1);
  297. }
  298. static void __init vr1000_map_io(void)
  299. {
  300. /* initialise clock sources */
  301. s3c24xx_dclk0.parent = &clk_upll;
  302. s3c24xx_dclk0.rate = 12*1000*1000;
  303. s3c24xx_dclk1.parent = NULL;
  304. s3c24xx_dclk1.rate = 3692307;
  305. s3c24xx_clkout0.parent = &s3c24xx_dclk0;
  306. s3c24xx_clkout1.parent = &s3c24xx_dclk1;
  307. s3c24xx_uclk.parent = &s3c24xx_clkout1;
  308. s3c24xx_register_clocks(vr1000_clocks, ARRAY_SIZE(vr1000_clocks));
  309. pm_power_off = vr1000_power_off;
  310. s3c24xx_init_io(vr1000_iodesc, ARRAY_SIZE(vr1000_iodesc));
  311. s3c24xx_init_clocks(0);
  312. s3c24xx_init_uarts(vr1000_uartcfgs, ARRAY_SIZE(vr1000_uartcfgs));
  313. }
  314. static void __init vr1000_init(void)
  315. {
  316. s3c_i2c0_set_platdata(NULL);
  317. platform_add_devices(vr1000_devices, ARRAY_SIZE(vr1000_devices));
  318. i2c_register_board_info(0, vr1000_i2c_devs,
  319. ARRAY_SIZE(vr1000_i2c_devs));
  320. nor_simtec_init();
  321. simtec_audio_add(NULL, true, NULL);
  322. WARN_ON(gpio_request(S3C2410_GPB(9), "power off"));
  323. }
  324. MACHINE_START(VR1000, "Thorcom-VR1000")
  325. /* Maintainer: Ben Dooks <ben@simtec.co.uk> */
  326. .atag_offset = 0x100,
  327. .map_io = vr1000_map_io,
  328. .init_machine = vr1000_init,
  329. .init_irq = s3c24xx_init_irq,
  330. .timer = &s3c24xx_timer,
  331. .restart = s3c2410_restart,
  332. MACHINE_END