mach-osiris.c 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430
  1. /*
  2. * Copyright (c) 2005-2008 Simtec Electronics
  3. * http://armlinux.simtec.co.uk/
  4. * Ben Dooks <ben@simtec.co.uk>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #include <linux/kernel.h>
  11. #include <linux/types.h>
  12. #include <linux/interrupt.h>
  13. #include <linux/list.h>
  14. #include <linux/timer.h>
  15. #include <linux/init.h>
  16. #include <linux/gpio.h>
  17. #include <linux/device.h>
  18. #include <linux/syscore_ops.h>
  19. #include <linux/serial_core.h>
  20. #include <linux/clk.h>
  21. #include <linux/i2c.h>
  22. #include <linux/io.h>
  23. #include <linux/i2c/tps65010.h>
  24. #include <asm/mach-types.h>
  25. #include <asm/mach/arch.h>
  26. #include <asm/mach/map.h>
  27. #include <asm/mach/irq.h>
  28. #include <asm/irq.h>
  29. #include <linux/platform_data/mtd-nand-s3c2410.h>
  30. #include <linux/platform_data/i2c-s3c2410.h>
  31. #include <linux/mtd/mtd.h>
  32. #include <linux/mtd/nand.h>
  33. #include <linux/mtd/nand_ecc.h>
  34. #include <linux/mtd/partitions.h>
  35. #include <plat/clock.h>
  36. #include <plat/cpu.h>
  37. #include <plat/cpu-freq.h>
  38. #include <plat/devs.h>
  39. #include <plat/gpio-cfg.h>
  40. #include <plat/regs-serial.h>
  41. #include <mach/hardware.h>
  42. #include <mach/regs-gpio.h>
  43. #include <mach/regs-mem.h>
  44. #include <mach/regs-lcd.h>
  45. #include "common.h"
  46. #include "osiris.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 s3c2410_uartcfg osiris_uartcfgs[] __initdata = {
  88. [0] = {
  89. .hwport = 0,
  90. .flags = 0,
  91. .ucon = UCON,
  92. .ulcon = ULCON,
  93. .ufcon = UFCON,
  94. .clk_sel = S3C2410_UCON_CLKSEL1 | S3C2410_UCON_CLKSEL2,
  95. },
  96. [1] = {
  97. .hwport = 1,
  98. .flags = 0,
  99. .ucon = UCON,
  100. .ulcon = ULCON,
  101. .ufcon = UFCON,
  102. .clk_sel = S3C2410_UCON_CLKSEL1 | S3C2410_UCON_CLKSEL2,
  103. },
  104. [2] = {
  105. .hwport = 2,
  106. .flags = 0,
  107. .ucon = UCON,
  108. .ulcon = ULCON,
  109. .ufcon = UFCON,
  110. .clk_sel = S3C2410_UCON_CLKSEL1 | S3C2410_UCON_CLKSEL2,
  111. }
  112. };
  113. /* NAND Flash on Osiris board */
  114. static int external_map[] = { 2 };
  115. static int chip0_map[] = { 0 };
  116. static int chip1_map[] = { 1 };
  117. static struct mtd_partition __initdata osiris_default_nand_part[] = {
  118. [0] = {
  119. .name = "Boot Agent",
  120. .size = SZ_16K,
  121. .offset = 0,
  122. },
  123. [1] = {
  124. .name = "/boot",
  125. .size = SZ_4M - SZ_16K,
  126. .offset = SZ_16K,
  127. },
  128. [2] = {
  129. .name = "user1",
  130. .offset = SZ_4M,
  131. .size = SZ_32M - SZ_4M,
  132. },
  133. [3] = {
  134. .name = "user2",
  135. .offset = SZ_32M,
  136. .size = MTDPART_SIZ_FULL,
  137. }
  138. };
  139. static struct mtd_partition __initdata osiris_default_nand_part_large[] = {
  140. [0] = {
  141. .name = "Boot Agent",
  142. .size = SZ_128K,
  143. .offset = 0,
  144. },
  145. [1] = {
  146. .name = "/boot",
  147. .size = SZ_4M - SZ_128K,
  148. .offset = SZ_128K,
  149. },
  150. [2] = {
  151. .name = "user1",
  152. .offset = SZ_4M,
  153. .size = SZ_32M - SZ_4M,
  154. },
  155. [3] = {
  156. .name = "user2",
  157. .offset = SZ_32M,
  158. .size = MTDPART_SIZ_FULL,
  159. }
  160. };
  161. /* the Osiris has 3 selectable slots for nand-flash, the two
  162. * on-board chip areas, as well as the external slot.
  163. *
  164. * Note, there is no current hot-plug support for the External
  165. * socket.
  166. */
  167. static struct s3c2410_nand_set __initdata osiris_nand_sets[] = {
  168. [1] = {
  169. .name = "External",
  170. .nr_chips = 1,
  171. .nr_map = external_map,
  172. .options = NAND_SCAN_SILENT_NODEV,
  173. .nr_partitions = ARRAY_SIZE(osiris_default_nand_part),
  174. .partitions = osiris_default_nand_part,
  175. },
  176. [0] = {
  177. .name = "chip0",
  178. .nr_chips = 1,
  179. .nr_map = chip0_map,
  180. .nr_partitions = ARRAY_SIZE(osiris_default_nand_part),
  181. .partitions = osiris_default_nand_part,
  182. },
  183. [2] = {
  184. .name = "chip1",
  185. .nr_chips = 1,
  186. .nr_map = chip1_map,
  187. .options = NAND_SCAN_SILENT_NODEV,
  188. .nr_partitions = ARRAY_SIZE(osiris_default_nand_part),
  189. .partitions = osiris_default_nand_part,
  190. },
  191. };
  192. static void osiris_nand_select(struct s3c2410_nand_set *set, int slot)
  193. {
  194. unsigned int tmp;
  195. slot = set->nr_map[slot] & 3;
  196. pr_debug("osiris_nand: selecting slot %d (set %p,%p)\n",
  197. slot, set, set->nr_map);
  198. tmp = __raw_readb(OSIRIS_VA_CTRL0);
  199. tmp &= ~OSIRIS_CTRL0_NANDSEL;
  200. tmp |= slot;
  201. pr_debug("osiris_nand: ctrl0 now %02x\n", tmp);
  202. __raw_writeb(tmp, OSIRIS_VA_CTRL0);
  203. }
  204. static struct s3c2410_platform_nand __initdata osiris_nand_info = {
  205. .tacls = 25,
  206. .twrph0 = 60,
  207. .twrph1 = 60,
  208. .nr_sets = ARRAY_SIZE(osiris_nand_sets),
  209. .sets = osiris_nand_sets,
  210. .select_chip = osiris_nand_select,
  211. };
  212. /* PCMCIA control and configuration */
  213. static struct resource osiris_pcmcia_resource[] = {
  214. [0] = DEFINE_RES_MEM(0x0f000000, SZ_1M),
  215. [1] = DEFINE_RES_MEM(0x0c000000, SZ_1M),
  216. };
  217. static struct platform_device osiris_pcmcia = {
  218. .name = "osiris-pcmcia",
  219. .id = -1,
  220. .num_resources = ARRAY_SIZE(osiris_pcmcia_resource),
  221. .resource = osiris_pcmcia_resource,
  222. };
  223. /* Osiris power management device */
  224. #ifdef CONFIG_PM
  225. static unsigned char pm_osiris_ctrl0;
  226. static int osiris_pm_suspend(void)
  227. {
  228. unsigned int tmp;
  229. pm_osiris_ctrl0 = __raw_readb(OSIRIS_VA_CTRL0);
  230. tmp = pm_osiris_ctrl0 & ~OSIRIS_CTRL0_NANDSEL;
  231. /* ensure correct NAND slot is selected on resume */
  232. if ((pm_osiris_ctrl0 & OSIRIS_CTRL0_BOOT_INT) == 0)
  233. tmp |= 2;
  234. __raw_writeb(tmp, OSIRIS_VA_CTRL0);
  235. /* ensure that an nRESET is not generated on resume. */
  236. gpio_request_one(S3C2410_GPA(21), GPIOF_OUT_INIT_HIGH, NULL);
  237. gpio_free(S3C2410_GPA(21));
  238. return 0;
  239. }
  240. static void osiris_pm_resume(void)
  241. {
  242. if (pm_osiris_ctrl0 & OSIRIS_CTRL0_FIX8)
  243. __raw_writeb(OSIRIS_CTRL1_FIX8, OSIRIS_VA_CTRL1);
  244. __raw_writeb(pm_osiris_ctrl0, OSIRIS_VA_CTRL0);
  245. s3c_gpio_cfgpin(S3C2410_GPA(21), S3C2410_GPA21_nRSTOUT);
  246. }
  247. #else
  248. #define osiris_pm_suspend NULL
  249. #define osiris_pm_resume NULL
  250. #endif
  251. static struct syscore_ops osiris_pm_syscore_ops = {
  252. .suspend = osiris_pm_suspend,
  253. .resume = osiris_pm_resume,
  254. };
  255. /* Link for DVS driver to TPS65011 */
  256. static void osiris_tps_release(struct device *dev)
  257. {
  258. /* static device, do not need to release anything */
  259. }
  260. static struct platform_device osiris_tps_device = {
  261. .name = "osiris-dvs",
  262. .id = -1,
  263. .dev.release = osiris_tps_release,
  264. };
  265. static int osiris_tps_setup(struct i2c_client *client, void *context)
  266. {
  267. osiris_tps_device.dev.parent = &client->dev;
  268. return platform_device_register(&osiris_tps_device);
  269. }
  270. static int osiris_tps_remove(struct i2c_client *client, void *context)
  271. {
  272. platform_device_unregister(&osiris_tps_device);
  273. return 0;
  274. }
  275. static struct tps65010_board osiris_tps_board = {
  276. .base = -1, /* GPIO can go anywhere at the moment */
  277. .setup = osiris_tps_setup,
  278. .teardown = osiris_tps_remove,
  279. };
  280. /* I2C devices fitted. */
  281. static struct i2c_board_info osiris_i2c_devs[] __initdata = {
  282. {
  283. I2C_BOARD_INFO("tps65011", 0x48),
  284. .irq = IRQ_EINT20,
  285. .platform_data = &osiris_tps_board,
  286. },
  287. };
  288. /* Standard Osiris devices */
  289. static struct platform_device *osiris_devices[] __initdata = {
  290. &s3c_device_i2c0,
  291. &s3c_device_wdt,
  292. &s3c_device_nand,
  293. &osiris_pcmcia,
  294. };
  295. static struct clk *osiris_clocks[] __initdata = {
  296. &s3c24xx_dclk0,
  297. &s3c24xx_dclk1,
  298. &s3c24xx_clkout0,
  299. &s3c24xx_clkout1,
  300. &s3c24xx_uclk,
  301. };
  302. static struct s3c_cpufreq_board __initdata osiris_cpufreq = {
  303. .refresh = 7800, /* refresh period is 7.8usec */
  304. .auto_io = 1,
  305. .need_io = 1,
  306. };
  307. static void __init osiris_map_io(void)
  308. {
  309. unsigned long flags;
  310. /* initialise the clocks */
  311. s3c24xx_dclk0.parent = &clk_upll;
  312. s3c24xx_dclk0.rate = 12*1000*1000;
  313. s3c24xx_dclk1.parent = &clk_upll;
  314. s3c24xx_dclk1.rate = 24*1000*1000;
  315. s3c24xx_clkout0.parent = &s3c24xx_dclk0;
  316. s3c24xx_clkout1.parent = &s3c24xx_dclk1;
  317. s3c24xx_uclk.parent = &s3c24xx_clkout1;
  318. s3c24xx_register_clocks(osiris_clocks, ARRAY_SIZE(osiris_clocks));
  319. s3c24xx_init_io(osiris_iodesc, ARRAY_SIZE(osiris_iodesc));
  320. s3c24xx_init_clocks(0);
  321. s3c24xx_init_uarts(osiris_uartcfgs, ARRAY_SIZE(osiris_uartcfgs));
  322. /* check for the newer revision boards with large page nand */
  323. if ((__raw_readb(OSIRIS_VA_IDREG) & OSIRIS_ID_REVMASK) >= 4) {
  324. printk(KERN_INFO "OSIRIS-B detected (revision %d)\n",
  325. __raw_readb(OSIRIS_VA_IDREG) & OSIRIS_ID_REVMASK);
  326. osiris_nand_sets[0].partitions = osiris_default_nand_part_large;
  327. osiris_nand_sets[0].nr_partitions = ARRAY_SIZE(osiris_default_nand_part_large);
  328. } else {
  329. /* write-protect line to the NAND */
  330. gpio_request_one(S3C2410_GPA(0), GPIOF_OUT_INIT_HIGH, NULL);
  331. gpio_free(S3C2410_GPA(0));
  332. }
  333. /* fix bus configuration (nBE settings wrong on ABLE pre v2.20) */
  334. local_irq_save(flags);
  335. __raw_writel(__raw_readl(S3C2410_BWSCON) | S3C2410_BWSCON_ST1 | S3C2410_BWSCON_ST2 | S3C2410_BWSCON_ST3 | S3C2410_BWSCON_ST4 | S3C2410_BWSCON_ST5, S3C2410_BWSCON);
  336. local_irq_restore(flags);
  337. }
  338. static void __init osiris_init(void)
  339. {
  340. register_syscore_ops(&osiris_pm_syscore_ops);
  341. s3c_i2c0_set_platdata(NULL);
  342. s3c_nand_set_platdata(&osiris_nand_info);
  343. s3c_cpufreq_setboard(&osiris_cpufreq);
  344. i2c_register_board_info(0, osiris_i2c_devs,
  345. ARRAY_SIZE(osiris_i2c_devs));
  346. platform_add_devices(osiris_devices, ARRAY_SIZE(osiris_devices));
  347. };
  348. MACHINE_START(OSIRIS, "Simtec-OSIRIS")
  349. /* Maintainer: Ben Dooks <ben@simtec.co.uk> */
  350. .atag_offset = 0x100,
  351. .map_io = osiris_map_io,
  352. .init_irq = s3c24xx_init_irq,
  353. .init_machine = osiris_init,
  354. .init_time = s3c24xx_timer_init,
  355. .restart = s3c244x_restart,
  356. MACHINE_END