mach-vr1000.c 9.9 KB

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