mach-vr1000.c 11 KB

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