mach-bast.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  1. /* linux/arch/arm/mach-s3c2410/mach-bast.c
  2. *
  3. * Copyright (c) 2003-2005 Simtec Electronics
  4. * Ben Dooks <ben@simtec.co.uk>
  5. *
  6. * http://www.simtec.co.uk/products/EB2410ITX/
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. *
  12. * Modifications:
  13. * 14-Sep-2004 BJD USB power control
  14. * 20-Aug-2004 BJD Added s3c2410_board struct
  15. * 18-Aug-2004 BJD Added platform devices from default set
  16. * 16-May-2003 BJD Created initial version
  17. * 16-Aug-2003 BJD Fixed header files and copyright, added URL
  18. * 05-Sep-2003 BJD Moved to v2.6 kernel
  19. * 06-Jan-2003 BJD Updates for <arch/map.h>
  20. * 18-Jan-2003 BJD Added serial port configuration
  21. * 05-Oct-2004 BJD Power management code
  22. * 04-Nov-2004 BJD Updated serial port clocks
  23. * 04-Jan-2005 BJD New uart init call
  24. * 10-Jan-2005 BJD Removed include of s3c2410.h
  25. * 14-Jan-2005 BJD Add support for muitlple NAND devices
  26. * 03-Mar-2005 BJD Ensured that bast-cpld.h is included
  27. * 10-Mar-2005 LCVR Changed S3C2410_VA to S3C24XX_VA
  28. * 14-Mar-2005 BJD Updated for __iomem changes
  29. * 22-Jun-2005 BJD Added DM9000 platform information
  30. * 28-Jun-2005 BJD Moved pm functionality out to common code
  31. * 17-Jul-2005 BJD Changed to platform device for SuperIO 16550s
  32. * 25-Jul-2005 BJD Removed ASIX static mappings
  33. * 27-Jul-2005 BJD Ensure maximum frequency of i2c bus
  34. * 20-Sep-2005 BJD Added static to non-exported items
  35. */
  36. #include <linux/kernel.h>
  37. #include <linux/types.h>
  38. #include <linux/interrupt.h>
  39. #include <linux/list.h>
  40. #include <linux/timer.h>
  41. #include <linux/init.h>
  42. #include <linux/device.h>
  43. #include <linux/dm9000.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/bast-irq.h>
  49. #include <asm/arch/bast-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/debug-ll.h>
  55. #include <asm/arch/regs-serial.h>
  56. #include <asm/arch/regs-gpio.h>
  57. #include <asm/arch/regs-mem.h>
  58. #include <asm/arch/regs-lcd.h>
  59. #include <asm/arch/nand.h>
  60. #include <asm/arch/iic.h>
  61. #include <linux/mtd/mtd.h>
  62. #include <linux/mtd/nand.h>
  63. #include <linux/mtd/nand_ecc.h>
  64. #include <linux/mtd/partitions.h>
  65. #include <linux/serial_8250.h>
  66. #include "clock.h"
  67. #include "devs.h"
  68. #include "cpu.h"
  69. #include "usb-simtec.h"
  70. #define COPYRIGHT ", (c) 2004-2005 Simtec Electronics"
  71. /* macros for virtual address mods for the io space entries */
  72. #define VA_C5(item) ((unsigned long)(item) + BAST_VAM_CS5)
  73. #define VA_C4(item) ((unsigned long)(item) + BAST_VAM_CS4)
  74. #define VA_C3(item) ((unsigned long)(item) + BAST_VAM_CS3)
  75. #define VA_C2(item) ((unsigned long)(item) + BAST_VAM_CS2)
  76. /* macros to modify the physical addresses for io space */
  77. #define PA_CS2(item) ((item) + S3C2410_CS2)
  78. #define PA_CS3(item) ((item) + S3C2410_CS3)
  79. #define PA_CS4(item) ((item) + S3C2410_CS4)
  80. #define PA_CS5(item) ((item) + S3C2410_CS5)
  81. static struct map_desc bast_iodesc[] __initdata = {
  82. /* ISA IO areas */
  83. { (u32)S3C24XX_VA_ISA_BYTE, PA_CS2(BAST_PA_ISAIO), SZ_16M, MT_DEVICE },
  84. { (u32)S3C24XX_VA_ISA_WORD, PA_CS3(BAST_PA_ISAIO), SZ_16M, MT_DEVICE },
  85. /* we could possibly compress the next set down into a set of smaller tables
  86. * pagetables, but that would mean using an L2 section, and it still means
  87. * we cannot actually feed the same register to an LDR due to 16K spacing
  88. */
  89. /* bast CPLD control registers, and external interrupt controls */
  90. { (u32)BAST_VA_CTRL1, BAST_PA_CTRL1, SZ_1M, MT_DEVICE },
  91. { (u32)BAST_VA_CTRL2, BAST_PA_CTRL2, SZ_1M, MT_DEVICE },
  92. { (u32)BAST_VA_CTRL3, BAST_PA_CTRL3, SZ_1M, MT_DEVICE },
  93. { (u32)BAST_VA_CTRL4, BAST_PA_CTRL4, SZ_1M, MT_DEVICE },
  94. /* PC104 IRQ mux */
  95. { (u32)BAST_VA_PC104_IRQREQ, BAST_PA_PC104_IRQREQ, SZ_1M, MT_DEVICE },
  96. { (u32)BAST_VA_PC104_IRQRAW, BAST_PA_PC104_IRQRAW, SZ_1M, MT_DEVICE },
  97. { (u32)BAST_VA_PC104_IRQMASK, BAST_PA_PC104_IRQMASK, SZ_1M, MT_DEVICE },
  98. /* peripheral space... one for each of fast/slow/byte/16bit */
  99. /* note, ide is only decoded in word space, even though some registers
  100. * are only 8bit */
  101. /* slow, byte */
  102. { VA_C2(BAST_VA_ISAIO), PA_CS2(BAST_PA_ISAIO), SZ_16M, MT_DEVICE },
  103. { VA_C2(BAST_VA_ISAMEM), PA_CS2(BAST_PA_ISAMEM), SZ_16M, MT_DEVICE },
  104. { VA_C2(BAST_VA_SUPERIO), PA_CS2(BAST_PA_SUPERIO), SZ_1M, MT_DEVICE },
  105. { VA_C2(BAST_VA_IDEPRI), PA_CS3(BAST_PA_IDEPRI), SZ_1M, MT_DEVICE },
  106. { VA_C2(BAST_VA_IDESEC), PA_CS3(BAST_PA_IDESEC), SZ_1M, MT_DEVICE },
  107. { VA_C2(BAST_VA_IDEPRIAUX), PA_CS3(BAST_PA_IDEPRIAUX), SZ_1M, MT_DEVICE },
  108. { VA_C2(BAST_VA_IDESECAUX), PA_CS3(BAST_PA_IDESECAUX), SZ_1M, MT_DEVICE },
  109. /* slow, word */
  110. { VA_C3(BAST_VA_ISAIO), PA_CS3(BAST_PA_ISAIO), SZ_16M, MT_DEVICE },
  111. { VA_C3(BAST_VA_ISAMEM), PA_CS3(BAST_PA_ISAMEM), SZ_16M, MT_DEVICE },
  112. { VA_C3(BAST_VA_SUPERIO), PA_CS3(BAST_PA_SUPERIO), SZ_1M, MT_DEVICE },
  113. { VA_C3(BAST_VA_IDEPRI), PA_CS3(BAST_PA_IDEPRI), SZ_1M, MT_DEVICE },
  114. { VA_C3(BAST_VA_IDESEC), PA_CS3(BAST_PA_IDESEC), SZ_1M, MT_DEVICE },
  115. { VA_C3(BAST_VA_IDEPRIAUX), PA_CS3(BAST_PA_IDEPRIAUX), SZ_1M, MT_DEVICE },
  116. { VA_C3(BAST_VA_IDESECAUX), PA_CS3(BAST_PA_IDESECAUX), SZ_1M, MT_DEVICE },
  117. /* fast, byte */
  118. { VA_C4(BAST_VA_ISAIO), PA_CS4(BAST_PA_ISAIO), SZ_16M, MT_DEVICE },
  119. { VA_C4(BAST_VA_ISAMEM), PA_CS4(BAST_PA_ISAMEM), SZ_16M, MT_DEVICE },
  120. { VA_C4(BAST_VA_SUPERIO), PA_CS4(BAST_PA_SUPERIO), SZ_1M, MT_DEVICE },
  121. { VA_C4(BAST_VA_IDEPRI), PA_CS5(BAST_PA_IDEPRI), SZ_1M, MT_DEVICE },
  122. { VA_C4(BAST_VA_IDESEC), PA_CS5(BAST_PA_IDESEC), SZ_1M, MT_DEVICE },
  123. { VA_C4(BAST_VA_IDEPRIAUX), PA_CS5(BAST_PA_IDEPRIAUX), SZ_1M, MT_DEVICE },
  124. { VA_C4(BAST_VA_IDESECAUX), PA_CS5(BAST_PA_IDESECAUX), SZ_1M, MT_DEVICE },
  125. /* fast, word */
  126. { VA_C5(BAST_VA_ISAIO), PA_CS5(BAST_PA_ISAIO), SZ_16M, MT_DEVICE },
  127. { VA_C5(BAST_VA_ISAMEM), PA_CS5(BAST_PA_ISAMEM), SZ_16M, MT_DEVICE },
  128. { VA_C5(BAST_VA_SUPERIO), PA_CS5(BAST_PA_SUPERIO), SZ_1M, MT_DEVICE },
  129. { VA_C5(BAST_VA_IDEPRI), PA_CS5(BAST_PA_IDEPRI), SZ_1M, MT_DEVICE },
  130. { VA_C5(BAST_VA_IDESEC), PA_CS5(BAST_PA_IDESEC), SZ_1M, MT_DEVICE },
  131. { VA_C5(BAST_VA_IDEPRIAUX), PA_CS5(BAST_PA_IDEPRIAUX), SZ_1M, MT_DEVICE },
  132. { VA_C5(BAST_VA_IDESECAUX), PA_CS5(BAST_PA_IDESECAUX), SZ_1M, MT_DEVICE },
  133. };
  134. #define UCON S3C2410_UCON_DEFAULT | S3C2410_UCON_UCLK
  135. #define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB
  136. #define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
  137. static struct s3c24xx_uart_clksrc bast_serial_clocks[] = {
  138. [0] = {
  139. .name = "uclk",
  140. .divisor = 1,
  141. .min_baud = 0,
  142. .max_baud = 0,
  143. },
  144. [1] = {
  145. .name = "pclk",
  146. .divisor = 1,
  147. .min_baud = 0,
  148. .max_baud = 0.
  149. }
  150. };
  151. static struct s3c2410_uartcfg bast_uartcfgs[] = {
  152. [0] = {
  153. .hwport = 0,
  154. .flags = 0,
  155. .ucon = UCON,
  156. .ulcon = ULCON,
  157. .ufcon = UFCON,
  158. .clocks = bast_serial_clocks,
  159. .clocks_size = ARRAY_SIZE(bast_serial_clocks)
  160. },
  161. [1] = {
  162. .hwport = 1,
  163. .flags = 0,
  164. .ucon = UCON,
  165. .ulcon = ULCON,
  166. .ufcon = UFCON,
  167. .clocks = bast_serial_clocks,
  168. .clocks_size = ARRAY_SIZE(bast_serial_clocks)
  169. },
  170. /* port 2 is not actually used */
  171. [2] = {
  172. .hwport = 2,
  173. .flags = 0,
  174. .ucon = UCON,
  175. .ulcon = ULCON,
  176. .ufcon = UFCON,
  177. .clocks = bast_serial_clocks,
  178. .clocks_size = ARRAY_SIZE(bast_serial_clocks)
  179. }
  180. };
  181. /* NOR Flash on BAST board */
  182. static struct resource bast_nor_resource[] = {
  183. [0] = {
  184. .start = S3C2410_CS1 + 0x4000000,
  185. .end = S3C2410_CS1 + 0x4000000 + (32*1024*1024) - 1,
  186. .flags = IORESOURCE_MEM,
  187. }
  188. };
  189. static struct platform_device bast_device_nor = {
  190. .name = "bast-nor",
  191. .id = -1,
  192. .num_resources = ARRAY_SIZE(bast_nor_resource),
  193. .resource = bast_nor_resource,
  194. };
  195. /* NAND Flash on BAST board */
  196. static int smartmedia_map[] = { 0 };
  197. static int chip0_map[] = { 1 };
  198. static int chip1_map[] = { 2 };
  199. static int chip2_map[] = { 3 };
  200. static struct mtd_partition bast_default_nand_part[] = {
  201. [0] = {
  202. .name = "Boot Agent",
  203. .size = SZ_16K,
  204. .offset = 0
  205. },
  206. [1] = {
  207. .name = "/boot",
  208. .size = SZ_4M - SZ_16K,
  209. .offset = SZ_16K,
  210. },
  211. [2] = {
  212. .name = "user",
  213. .offset = SZ_4M,
  214. .size = MTDPART_SIZ_FULL,
  215. }
  216. };
  217. /* the bast has 4 selectable slots for nand-flash, the three
  218. * on-board chip areas, as well as the external SmartMedia
  219. * slot.
  220. *
  221. * Note, there is no current hot-plug support for the SmartMedia
  222. * socket.
  223. */
  224. static struct s3c2410_nand_set bast_nand_sets[] = {
  225. [0] = {
  226. .name = "SmartMedia",
  227. .nr_chips = 1,
  228. .nr_map = smartmedia_map,
  229. .nr_partitions = ARRAY_SIZE(bast_default_nand_part),
  230. .partitions = bast_default_nand_part
  231. },
  232. [1] = {
  233. .name = "chip0",
  234. .nr_chips = 1,
  235. .nr_map = chip0_map,
  236. .nr_partitions = ARRAY_SIZE(bast_default_nand_part),
  237. .partitions = bast_default_nand_part
  238. },
  239. [2] = {
  240. .name = "chip1",
  241. .nr_chips = 1,
  242. .nr_map = chip1_map,
  243. .nr_partitions = ARRAY_SIZE(bast_default_nand_part),
  244. .partitions = bast_default_nand_part
  245. },
  246. [3] = {
  247. .name = "chip2",
  248. .nr_chips = 1,
  249. .nr_map = chip2_map,
  250. .nr_partitions = ARRAY_SIZE(bast_default_nand_part),
  251. .partitions = bast_default_nand_part
  252. }
  253. };
  254. static void bast_nand_select(struct s3c2410_nand_set *set, int slot)
  255. {
  256. unsigned int tmp;
  257. slot = set->nr_map[slot] & 3;
  258. pr_debug("bast_nand: selecting slot %d (set %p,%p)\n",
  259. slot, set, set->nr_map);
  260. tmp = __raw_readb(BAST_VA_CTRL2);
  261. tmp &= BAST_CPLD_CTLR2_IDERST;
  262. tmp |= slot;
  263. tmp |= BAST_CPLD_CTRL2_WNAND;
  264. pr_debug("bast_nand: ctrl2 now %02x\n", tmp);
  265. __raw_writeb(tmp, BAST_VA_CTRL2);
  266. }
  267. static struct s3c2410_platform_nand bast_nand_info = {
  268. .tacls = 30,
  269. .twrph0 = 60,
  270. .twrph1 = 60,
  271. .nr_sets = ARRAY_SIZE(bast_nand_sets),
  272. .sets = bast_nand_sets,
  273. .select_chip = bast_nand_select,
  274. };
  275. /* DM9000 */
  276. static struct resource bast_dm9k_resource[] = {
  277. [0] = {
  278. .start = S3C2410_CS5 + BAST_PA_DM9000,
  279. .end = S3C2410_CS5 + BAST_PA_DM9000 + 3,
  280. .flags = IORESOURCE_MEM
  281. },
  282. [1] = {
  283. .start = S3C2410_CS5 + BAST_PA_DM9000 + 0x40,
  284. .end = S3C2410_CS5 + BAST_PA_DM9000 + 0x40 + 0x3f,
  285. .flags = IORESOURCE_MEM
  286. },
  287. [2] = {
  288. .start = IRQ_DM9000,
  289. .end = IRQ_DM9000,
  290. .flags = IORESOURCE_IRQ
  291. }
  292. };
  293. /* for the moment we limit ourselves to 16bit IO until some
  294. * better IO routines can be written and tested
  295. */
  296. static struct dm9000_plat_data bast_dm9k_platdata = {
  297. .flags = DM9000_PLATF_16BITONLY
  298. };
  299. static struct platform_device bast_device_dm9k = {
  300. .name = "dm9000",
  301. .id = 0,
  302. .num_resources = ARRAY_SIZE(bast_dm9k_resource),
  303. .resource = bast_dm9k_resource,
  304. .dev = {
  305. .platform_data = &bast_dm9k_platdata,
  306. }
  307. };
  308. /* serial devices */
  309. #define SERIAL_BASE (S3C2410_CS2 + BAST_PA_SUPERIO)
  310. #define SERIAL_FLAGS (UPF_BOOT_AUTOCONF | UPF_IOREMAP | UPF_SHARE_IRQ)
  311. #define SERIAL_CLK (1843200)
  312. static struct plat_serial8250_port bast_sio_data[] = {
  313. [0] = {
  314. .mapbase = SERIAL_BASE + 0x2f8,
  315. .irq = IRQ_PCSERIAL1,
  316. .flags = SERIAL_FLAGS,
  317. .iotype = UPIO_MEM,
  318. .regshift = 0,
  319. .uartclk = SERIAL_CLK,
  320. },
  321. [1] = {
  322. .mapbase = SERIAL_BASE + 0x3f8,
  323. .irq = IRQ_PCSERIAL2,
  324. .flags = SERIAL_FLAGS,
  325. .iotype = UPIO_MEM,
  326. .regshift = 0,
  327. .uartclk = SERIAL_CLK,
  328. },
  329. { }
  330. };
  331. static struct platform_device bast_sio = {
  332. .name = "serial8250",
  333. .id = PLAT8250_DEV_PLATFORM,
  334. .dev = {
  335. .platform_data = &bast_sio_data,
  336. },
  337. };
  338. /* we have devices on the bus which cannot work much over the
  339. * standard 100KHz i2c bus frequency
  340. */
  341. static struct s3c2410_platform_i2c bast_i2c_info = {
  342. .flags = 0,
  343. .slave_addr = 0x10,
  344. .bus_freq = 100*1000,
  345. .max_freq = 130*1000,
  346. };
  347. /* Standard BAST devices */
  348. static struct platform_device *bast_devices[] __initdata = {
  349. &s3c_device_usb,
  350. &s3c_device_lcd,
  351. &s3c_device_wdt,
  352. &s3c_device_i2c,
  353. &s3c_device_iis,
  354. &s3c_device_rtc,
  355. &s3c_device_nand,
  356. &bast_device_nor,
  357. &bast_device_dm9k,
  358. &bast_sio,
  359. };
  360. static struct clk *bast_clocks[] = {
  361. &s3c24xx_dclk0,
  362. &s3c24xx_dclk1,
  363. &s3c24xx_clkout0,
  364. &s3c24xx_clkout1,
  365. &s3c24xx_uclk,
  366. };
  367. static struct s3c24xx_board bast_board __initdata = {
  368. .devices = bast_devices,
  369. .devices_count = ARRAY_SIZE(bast_devices),
  370. .clocks = bast_clocks,
  371. .clocks_count = ARRAY_SIZE(bast_clocks)
  372. };
  373. static void __init bast_map_io(void)
  374. {
  375. /* initialise the clocks */
  376. s3c24xx_dclk0.parent = NULL;
  377. s3c24xx_dclk0.rate = 12*1000*1000;
  378. s3c24xx_dclk1.parent = NULL;
  379. s3c24xx_dclk1.rate = 24*1000*1000;
  380. s3c24xx_clkout0.parent = &s3c24xx_dclk0;
  381. s3c24xx_clkout1.parent = &s3c24xx_dclk1;
  382. s3c24xx_uclk.parent = &s3c24xx_clkout1;
  383. s3c_device_nand.dev.platform_data = &bast_nand_info;
  384. s3c_device_i2c.dev.platform_data = &bast_i2c_info;
  385. s3c24xx_init_io(bast_iodesc, ARRAY_SIZE(bast_iodesc));
  386. s3c24xx_init_clocks(0);
  387. s3c24xx_init_uarts(bast_uartcfgs, ARRAY_SIZE(bast_uartcfgs));
  388. s3c24xx_set_board(&bast_board);
  389. usb_simtec_init();
  390. }
  391. MACHINE_START(BAST, "Simtec-BAST")
  392. /* Maintainer: Ben Dooks <ben@simtec.co.uk> */
  393. .phys_ram = S3C2410_SDRAM_PA,
  394. .phys_io = S3C2410_PA_UART,
  395. .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
  396. .boot_params = S3C2410_SDRAM_PA + 0x100,
  397. .map_io = bast_map_io,
  398. .init_irq = s3c24xx_init_irq,
  399. .timer = &s3c24xx_timer,
  400. MACHINE_END