mach-vr1000.c 9.0 KB

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