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