mach-osiris.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464
  1. /* linux/arch/arm/mach-s3c2440/mach-osiris.c
  2. *
  3. * Copyright (c) 2005-2008 Simtec Electronics
  4. * http://armlinux.simtec.co.uk/
  5. * Ben Dooks <ben@simtec.co.uk>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. */
  11. #include <linux/kernel.h>
  12. #include <linux/types.h>
  13. #include <linux/interrupt.h>
  14. #include <linux/list.h>
  15. #include <linux/timer.h>
  16. #include <linux/init.h>
  17. #include <linux/gpio.h>
  18. #include <linux/device.h>
  19. #include <linux/sysdev.h>
  20. #include <linux/serial_core.h>
  21. #include <linux/clk.h>
  22. #include <linux/i2c.h>
  23. #include <linux/io.h>
  24. #include <linux/i2c/tps65010.h>
  25. #include <asm/mach/arch.h>
  26. #include <asm/mach/map.h>
  27. #include <asm/mach/irq.h>
  28. #include <mach/osiris-map.h>
  29. #include <mach/osiris-cpld.h>
  30. #include <mach/hardware.h>
  31. #include <asm/irq.h>
  32. #include <asm/mach-types.h>
  33. #include <plat/cpu-freq.h>
  34. #include <plat/regs-serial.h>
  35. #include <mach/regs-gpio.h>
  36. #include <mach/regs-mem.h>
  37. #include <mach/regs-lcd.h>
  38. #include <plat/nand.h>
  39. #include <plat/iic.h>
  40. #include <linux/mtd/mtd.h>
  41. #include <linux/mtd/nand.h>
  42. #include <linux/mtd/nand_ecc.h>
  43. #include <linux/mtd/partitions.h>
  44. #include <plat/clock.h>
  45. #include <plat/devs.h>
  46. #include <plat/cpu.h>
  47. /* onboard perihperal map */
  48. static struct map_desc osiris_iodesc[] __initdata = {
  49. /* ISA IO areas (may be over-written later) */
  50. {
  51. .virtual = (u32)S3C24XX_VA_ISA_BYTE,
  52. .pfn = __phys_to_pfn(S3C2410_CS5),
  53. .length = SZ_16M,
  54. .type = MT_DEVICE,
  55. }, {
  56. .virtual = (u32)S3C24XX_VA_ISA_WORD,
  57. .pfn = __phys_to_pfn(S3C2410_CS5),
  58. .length = SZ_16M,
  59. .type = MT_DEVICE,
  60. },
  61. /* CPLD control registers */
  62. {
  63. .virtual = (u32)OSIRIS_VA_CTRL0,
  64. .pfn = __phys_to_pfn(OSIRIS_PA_CTRL0),
  65. .length = SZ_16K,
  66. .type = MT_DEVICE,
  67. }, {
  68. .virtual = (u32)OSIRIS_VA_CTRL1,
  69. .pfn = __phys_to_pfn(OSIRIS_PA_CTRL1),
  70. .length = SZ_16K,
  71. .type = MT_DEVICE,
  72. }, {
  73. .virtual = (u32)OSIRIS_VA_CTRL2,
  74. .pfn = __phys_to_pfn(OSIRIS_PA_CTRL2),
  75. .length = SZ_16K,
  76. .type = MT_DEVICE,
  77. }, {
  78. .virtual = (u32)OSIRIS_VA_IDREG,
  79. .pfn = __phys_to_pfn(OSIRIS_PA_IDREG),
  80. .length = SZ_16K,
  81. .type = MT_DEVICE,
  82. },
  83. };
  84. #define UCON S3C2410_UCON_DEFAULT | S3C2410_UCON_UCLK
  85. #define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB
  86. #define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
  87. static struct s3c24xx_uart_clksrc osiris_serial_clocks[] = {
  88. [0] = {
  89. .name = "uclk",
  90. .divisor = 1,
  91. .min_baud = 0,
  92. .max_baud = 0,
  93. },
  94. [1] = {
  95. .name = "pclk",
  96. .divisor = 1,
  97. .min_baud = 0,
  98. .max_baud = 0,
  99. }
  100. };
  101. static struct s3c2410_uartcfg osiris_uartcfgs[] __initdata = {
  102. [0] = {
  103. .hwport = 0,
  104. .flags = 0,
  105. .ucon = UCON,
  106. .ulcon = ULCON,
  107. .ufcon = UFCON,
  108. .clocks = osiris_serial_clocks,
  109. .clocks_size = ARRAY_SIZE(osiris_serial_clocks),
  110. },
  111. [1] = {
  112. .hwport = 1,
  113. .flags = 0,
  114. .ucon = UCON,
  115. .ulcon = ULCON,
  116. .ufcon = UFCON,
  117. .clocks = osiris_serial_clocks,
  118. .clocks_size = ARRAY_SIZE(osiris_serial_clocks),
  119. },
  120. [2] = {
  121. .hwport = 2,
  122. .flags = 0,
  123. .ucon = UCON,
  124. .ulcon = ULCON,
  125. .ufcon = UFCON,
  126. .clocks = osiris_serial_clocks,
  127. .clocks_size = ARRAY_SIZE(osiris_serial_clocks),
  128. }
  129. };
  130. /* NAND Flash on Osiris board */
  131. static int external_map[] = { 2 };
  132. static int chip0_map[] = { 0 };
  133. static int chip1_map[] = { 1 };
  134. static struct mtd_partition __initdata osiris_default_nand_part[] = {
  135. [0] = {
  136. .name = "Boot Agent",
  137. .size = SZ_16K,
  138. .offset = 0,
  139. },
  140. [1] = {
  141. .name = "/boot",
  142. .size = SZ_4M - SZ_16K,
  143. .offset = SZ_16K,
  144. },
  145. [2] = {
  146. .name = "user1",
  147. .offset = SZ_4M,
  148. .size = SZ_32M - SZ_4M,
  149. },
  150. [3] = {
  151. .name = "user2",
  152. .offset = SZ_32M,
  153. .size = MTDPART_SIZ_FULL,
  154. }
  155. };
  156. static struct mtd_partition __initdata osiris_default_nand_part_large[] = {
  157. [0] = {
  158. .name = "Boot Agent",
  159. .size = SZ_128K,
  160. .offset = 0,
  161. },
  162. [1] = {
  163. .name = "/boot",
  164. .size = SZ_4M - SZ_128K,
  165. .offset = SZ_128K,
  166. },
  167. [2] = {
  168. .name = "user1",
  169. .offset = SZ_4M,
  170. .size = SZ_32M - SZ_4M,
  171. },
  172. [3] = {
  173. .name = "user2",
  174. .offset = SZ_32M,
  175. .size = MTDPART_SIZ_FULL,
  176. }
  177. };
  178. /* the Osiris has 3 selectable slots for nand-flash, the two
  179. * on-board chip areas, as well as the external slot.
  180. *
  181. * Note, there is no current hot-plug support for the External
  182. * socket.
  183. */
  184. static struct s3c2410_nand_set __initdata osiris_nand_sets[] = {
  185. [1] = {
  186. .name = "External",
  187. .nr_chips = 1,
  188. .nr_map = external_map,
  189. .options = NAND_SCAN_SILENT_NODEV,
  190. .nr_partitions = ARRAY_SIZE(osiris_default_nand_part),
  191. .partitions = osiris_default_nand_part,
  192. },
  193. [0] = {
  194. .name = "chip0",
  195. .nr_chips = 1,
  196. .nr_map = chip0_map,
  197. .nr_partitions = ARRAY_SIZE(osiris_default_nand_part),
  198. .partitions = osiris_default_nand_part,
  199. },
  200. [2] = {
  201. .name = "chip1",
  202. .nr_chips = 1,
  203. .nr_map = chip1_map,
  204. .options = NAND_SCAN_SILENT_NODEV,
  205. .nr_partitions = ARRAY_SIZE(osiris_default_nand_part),
  206. .partitions = osiris_default_nand_part,
  207. },
  208. };
  209. static void osiris_nand_select(struct s3c2410_nand_set *set, int slot)
  210. {
  211. unsigned int tmp;
  212. slot = set->nr_map[slot] & 3;
  213. pr_debug("osiris_nand: selecting slot %d (set %p,%p)\n",
  214. slot, set, set->nr_map);
  215. tmp = __raw_readb(OSIRIS_VA_CTRL0);
  216. tmp &= ~OSIRIS_CTRL0_NANDSEL;
  217. tmp |= slot;
  218. pr_debug("osiris_nand: ctrl0 now %02x\n", tmp);
  219. __raw_writeb(tmp, OSIRIS_VA_CTRL0);
  220. }
  221. static struct s3c2410_platform_nand __initdata osiris_nand_info = {
  222. .tacls = 25,
  223. .twrph0 = 60,
  224. .twrph1 = 60,
  225. .nr_sets = ARRAY_SIZE(osiris_nand_sets),
  226. .sets = osiris_nand_sets,
  227. .select_chip = osiris_nand_select,
  228. };
  229. /* PCMCIA control and configuration */
  230. static struct resource osiris_pcmcia_resource[] = {
  231. [0] = {
  232. .start = 0x0f000000,
  233. .end = 0x0f100000,
  234. .flags = IORESOURCE_MEM,
  235. },
  236. [1] = {
  237. .start = 0x0c000000,
  238. .end = 0x0c100000,
  239. .flags = IORESOURCE_MEM,
  240. }
  241. };
  242. static struct platform_device osiris_pcmcia = {
  243. .name = "osiris-pcmcia",
  244. .id = -1,
  245. .num_resources = ARRAY_SIZE(osiris_pcmcia_resource),
  246. .resource = osiris_pcmcia_resource,
  247. };
  248. /* Osiris power management device */
  249. #ifdef CONFIG_PM
  250. static unsigned char pm_osiris_ctrl0;
  251. static int osiris_pm_suspend(struct sys_device *sd, pm_message_t state)
  252. {
  253. unsigned int tmp;
  254. pm_osiris_ctrl0 = __raw_readb(OSIRIS_VA_CTRL0);
  255. tmp = pm_osiris_ctrl0 & ~OSIRIS_CTRL0_NANDSEL;
  256. /* ensure correct NAND slot is selected on resume */
  257. if ((pm_osiris_ctrl0 & OSIRIS_CTRL0_BOOT_INT) == 0)
  258. tmp |= 2;
  259. __raw_writeb(tmp, OSIRIS_VA_CTRL0);
  260. /* ensure that an nRESET is not generated on resume. */
  261. s3c2410_gpio_setpin(S3C2410_GPA(21), 1);
  262. s3c2410_gpio_cfgpin(S3C2410_GPA(21), S3C2410_GPIO_OUTPUT);
  263. return 0;
  264. }
  265. static int osiris_pm_resume(struct sys_device *sd)
  266. {
  267. if (pm_osiris_ctrl0 & OSIRIS_CTRL0_FIX8)
  268. __raw_writeb(OSIRIS_CTRL1_FIX8, OSIRIS_VA_CTRL1);
  269. __raw_writeb(pm_osiris_ctrl0, OSIRIS_VA_CTRL0);
  270. s3c2410_gpio_cfgpin(S3C2410_GPA(21), S3C2410_GPA21_nRSTOUT);
  271. return 0;
  272. }
  273. #else
  274. #define osiris_pm_suspend NULL
  275. #define osiris_pm_resume NULL
  276. #endif
  277. static struct sysdev_class osiris_pm_sysclass = {
  278. .name = "mach-osiris",
  279. .suspend = osiris_pm_suspend,
  280. .resume = osiris_pm_resume,
  281. };
  282. static struct sys_device osiris_pm_sysdev = {
  283. .cls = &osiris_pm_sysclass,
  284. };
  285. /* Link for DVS driver to TPS65011 */
  286. static void osiris_tps_release(struct device *dev)
  287. {
  288. /* static device, do not need to release anything */
  289. }
  290. static struct platform_device osiris_tps_device = {
  291. .name = "osiris-dvs",
  292. .id = -1,
  293. .dev.release = osiris_tps_release,
  294. };
  295. static int osiris_tps_setup(struct i2c_client *client, void *context)
  296. {
  297. osiris_tps_device.dev.parent = &client->dev;
  298. return platform_device_register(&osiris_tps_device);
  299. }
  300. static int osiris_tps_remove(struct i2c_client *client, void *context)
  301. {
  302. platform_device_unregister(&osiris_tps_device);
  303. return 0;
  304. }
  305. static struct tps65010_board osiris_tps_board = {
  306. .base = -1, /* GPIO can go anywhere at the moment */
  307. .setup = osiris_tps_setup,
  308. .teardown = osiris_tps_remove,
  309. };
  310. /* I2C devices fitted. */
  311. static struct i2c_board_info osiris_i2c_devs[] __initdata = {
  312. {
  313. I2C_BOARD_INFO("tps65011", 0x48),
  314. .irq = IRQ_EINT20,
  315. .platform_data = &osiris_tps_board,
  316. },
  317. };
  318. /* Standard Osiris devices */
  319. static struct platform_device *osiris_devices[] __initdata = {
  320. &s3c_device_i2c0,
  321. &s3c_device_wdt,
  322. &s3c_device_nand,
  323. &osiris_pcmcia,
  324. };
  325. static struct clk *osiris_clocks[] __initdata = {
  326. &s3c24xx_dclk0,
  327. &s3c24xx_dclk1,
  328. &s3c24xx_clkout0,
  329. &s3c24xx_clkout1,
  330. &s3c24xx_uclk,
  331. };
  332. static struct s3c_cpufreq_board __initdata osiris_cpufreq = {
  333. .refresh = 7800, /* refresh period is 7.8usec */
  334. .auto_io = 1,
  335. .need_io = 1,
  336. };
  337. static void __init osiris_map_io(void)
  338. {
  339. unsigned long flags;
  340. /* initialise the clocks */
  341. s3c24xx_dclk0.parent = &clk_upll;
  342. s3c24xx_dclk0.rate = 12*1000*1000;
  343. s3c24xx_dclk1.parent = &clk_upll;
  344. s3c24xx_dclk1.rate = 24*1000*1000;
  345. s3c24xx_clkout0.parent = &s3c24xx_dclk0;
  346. s3c24xx_clkout1.parent = &s3c24xx_dclk1;
  347. s3c24xx_uclk.parent = &s3c24xx_clkout1;
  348. s3c24xx_register_clocks(osiris_clocks, ARRAY_SIZE(osiris_clocks));
  349. s3c24xx_init_io(osiris_iodesc, ARRAY_SIZE(osiris_iodesc));
  350. s3c24xx_init_clocks(0);
  351. s3c24xx_init_uarts(osiris_uartcfgs, ARRAY_SIZE(osiris_uartcfgs));
  352. /* check for the newer revision boards with large page nand */
  353. if ((__raw_readb(OSIRIS_VA_IDREG) & OSIRIS_ID_REVMASK) >= 4) {
  354. printk(KERN_INFO "OSIRIS-B detected (revision %d)\n",
  355. __raw_readb(OSIRIS_VA_IDREG) & OSIRIS_ID_REVMASK);
  356. osiris_nand_sets[0].partitions = osiris_default_nand_part_large;
  357. osiris_nand_sets[0].nr_partitions = ARRAY_SIZE(osiris_default_nand_part_large);
  358. } else {
  359. /* write-protect line to the NAND */
  360. s3c2410_gpio_setpin(S3C2410_GPA(0), 1);
  361. }
  362. /* fix bus configuration (nBE settings wrong on ABLE pre v2.20) */
  363. local_irq_save(flags);
  364. __raw_writel(__raw_readl(S3C2410_BWSCON) | S3C2410_BWSCON_ST1 | S3C2410_BWSCON_ST2 | S3C2410_BWSCON_ST3 | S3C2410_BWSCON_ST4 | S3C2410_BWSCON_ST5, S3C2410_BWSCON);
  365. local_irq_restore(flags);
  366. }
  367. static void __init osiris_init(void)
  368. {
  369. sysdev_class_register(&osiris_pm_sysclass);
  370. sysdev_register(&osiris_pm_sysdev);
  371. s3c_i2c0_set_platdata(NULL);
  372. s3c_nand_set_platdata(&osiris_nand_info);
  373. s3c_cpufreq_setboard(&osiris_cpufreq);
  374. i2c_register_board_info(0, osiris_i2c_devs,
  375. ARRAY_SIZE(osiris_i2c_devs));
  376. platform_add_devices(osiris_devices, ARRAY_SIZE(osiris_devices));
  377. };
  378. MACHINE_START(OSIRIS, "Simtec-OSIRIS")
  379. /* Maintainer: Ben Dooks <ben@simtec.co.uk> */
  380. .phys_io = S3C2410_PA_UART,
  381. .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
  382. .boot_params = S3C2410_SDRAM_PA + 0x100,
  383. .map_io = osiris_map_io,
  384. .init_irq = s3c24xx_init_irq,
  385. .init_machine = osiris_init,
  386. .timer = &s3c24xx_timer,
  387. MACHINE_END