mach-bast.c 13 KB

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