mach-vr1000.c 11 KB

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