mach-osiris.c 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  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/serial_s3c.h>
  21. #include <linux/clk.h>
  22. #include <linux/i2c.h>
  23. #include <linux/io.h>
  24. #include <linux/platform_device.h>
  25. #include <linux/i2c/tps65010.h>
  26. #include <asm/mach-types.h>
  27. #include <asm/mach/arch.h>
  28. #include <asm/mach/map.h>
  29. #include <asm/mach/irq.h>
  30. #include <asm/irq.h>
  31. #include <linux/platform_data/mtd-nand-s3c2410.h>
  32. #include <linux/platform_data/i2c-s3c2410.h>
  33. #include <linux/mtd/mtd.h>
  34. #include <linux/mtd/rawnand.h>
  35. #include <linux/mtd/nand_ecc.h>
  36. #include <linux/mtd/partitions.h>
  37. #include <plat/cpu.h>
  38. #include <plat/cpu-freq.h>
  39. #include <plat/devs.h>
  40. #include <plat/gpio-cfg.h>
  41. #include <plat/samsung-time.h>
  42. #include <mach/hardware.h>
  43. #include <mach/regs-gpio.h>
  44. #include <mach/regs-lcd.h>
  45. #include <mach/gpio-samsung.h>
  46. #include "common.h"
  47. #include "osiris.h"
  48. #include "regs-mem.h"
  49. /* onboard perihperal map */
  50. static struct map_desc osiris_iodesc[] __initdata = {
  51. /* ISA IO areas (may be over-written later) */
  52. {
  53. .virtual = (u32)S3C24XX_VA_ISA_BYTE,
  54. .pfn = __phys_to_pfn(S3C2410_CS5),
  55. .length = SZ_16M,
  56. .type = MT_DEVICE,
  57. }, {
  58. .virtual = (u32)S3C24XX_VA_ISA_WORD,
  59. .pfn = __phys_to_pfn(S3C2410_CS5),
  60. .length = SZ_16M,
  61. .type = MT_DEVICE,
  62. },
  63. /* CPLD control registers */
  64. {
  65. .virtual = (u32)OSIRIS_VA_CTRL0,
  66. .pfn = __phys_to_pfn(OSIRIS_PA_CTRL0),
  67. .length = SZ_16K,
  68. .type = MT_DEVICE,
  69. }, {
  70. .virtual = (u32)OSIRIS_VA_CTRL1,
  71. .pfn = __phys_to_pfn(OSIRIS_PA_CTRL1),
  72. .length = SZ_16K,
  73. .type = MT_DEVICE,
  74. }, {
  75. .virtual = (u32)OSIRIS_VA_CTRL2,
  76. .pfn = __phys_to_pfn(OSIRIS_PA_CTRL2),
  77. .length = SZ_16K,
  78. .type = MT_DEVICE,
  79. }, {
  80. .virtual = (u32)OSIRIS_VA_IDREG,
  81. .pfn = __phys_to_pfn(OSIRIS_PA_IDREG),
  82. .length = SZ_16K,
  83. .type = MT_DEVICE,
  84. },
  85. };
  86. #define UCON S3C2410_UCON_DEFAULT | S3C2410_UCON_UCLK
  87. #define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB
  88. #define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
  89. static struct s3c2410_uartcfg osiris_uartcfgs[] __initdata = {
  90. [0] = {
  91. .hwport = 0,
  92. .flags = 0,
  93. .ucon = UCON,
  94. .ulcon = ULCON,
  95. .ufcon = UFCON,
  96. .clk_sel = S3C2410_UCON_CLKSEL1 | S3C2410_UCON_CLKSEL2,
  97. },
  98. [1] = {
  99. .hwport = 1,
  100. .flags = 0,
  101. .ucon = UCON,
  102. .ulcon = ULCON,
  103. .ufcon = UFCON,
  104. .clk_sel = S3C2410_UCON_CLKSEL1 | S3C2410_UCON_CLKSEL2,
  105. },
  106. [2] = {
  107. .hwport = 2,
  108. .flags = 0,
  109. .ucon = UCON,
  110. .ulcon = ULCON,
  111. .ufcon = UFCON,
  112. .clk_sel = S3C2410_UCON_CLKSEL1 | S3C2410_UCON_CLKSEL2,
  113. }
  114. };
  115. /* NAND Flash on Osiris board */
  116. static int external_map[] = { 2 };
  117. static int chip0_map[] = { 0 };
  118. static int chip1_map[] = { 1 };
  119. static struct mtd_partition __initdata osiris_default_nand_part[] = {
  120. [0] = {
  121. .name = "Boot Agent",
  122. .size = SZ_16K,
  123. .offset = 0,
  124. },
  125. [1] = {
  126. .name = "/boot",
  127. .size = SZ_4M - SZ_16K,
  128. .offset = SZ_16K,
  129. },
  130. [2] = {
  131. .name = "user1",
  132. .offset = SZ_4M,
  133. .size = SZ_32M - SZ_4M,
  134. },
  135. [3] = {
  136. .name = "user2",
  137. .offset = SZ_32M,
  138. .size = MTDPART_SIZ_FULL,
  139. }
  140. };
  141. static struct mtd_partition __initdata osiris_default_nand_part_large[] = {
  142. [0] = {
  143. .name = "Boot Agent",
  144. .size = SZ_128K,
  145. .offset = 0,
  146. },
  147. [1] = {
  148. .name = "/boot",
  149. .size = SZ_4M - SZ_128K,
  150. .offset = SZ_128K,
  151. },
  152. [2] = {
  153. .name = "user1",
  154. .offset = SZ_4M,
  155. .size = SZ_32M - SZ_4M,
  156. },
  157. [3] = {
  158. .name = "user2",
  159. .offset = SZ_32M,
  160. .size = MTDPART_SIZ_FULL,
  161. }
  162. };
  163. /* the Osiris has 3 selectable slots for nand-flash, the two
  164. * on-board chip areas, as well as the external slot.
  165. *
  166. * Note, there is no current hot-plug support for the External
  167. * socket.
  168. */
  169. static struct s3c2410_nand_set __initdata osiris_nand_sets[] = {
  170. [1] = {
  171. .name = "External",
  172. .nr_chips = 1,
  173. .nr_map = external_map,
  174. .options = NAND_SCAN_SILENT_NODEV,
  175. .nr_partitions = ARRAY_SIZE(osiris_default_nand_part),
  176. .partitions = osiris_default_nand_part,
  177. },
  178. [0] = {
  179. .name = "chip0",
  180. .nr_chips = 1,
  181. .nr_map = chip0_map,
  182. .nr_partitions = ARRAY_SIZE(osiris_default_nand_part),
  183. .partitions = osiris_default_nand_part,
  184. },
  185. [2] = {
  186. .name = "chip1",
  187. .nr_chips = 1,
  188. .nr_map = chip1_map,
  189. .options = NAND_SCAN_SILENT_NODEV,
  190. .nr_partitions = ARRAY_SIZE(osiris_default_nand_part),
  191. .partitions = osiris_default_nand_part,
  192. },
  193. };
  194. static void osiris_nand_select(struct s3c2410_nand_set *set, int slot)
  195. {
  196. unsigned int tmp;
  197. slot = set->nr_map[slot] & 3;
  198. pr_debug("osiris_nand: selecting slot %d (set %p,%p)\n",
  199. slot, set, set->nr_map);
  200. tmp = __raw_readb(OSIRIS_VA_CTRL0);
  201. tmp &= ~OSIRIS_CTRL0_NANDSEL;
  202. tmp |= slot;
  203. pr_debug("osiris_nand: ctrl0 now %02x\n", tmp);
  204. __raw_writeb(tmp, OSIRIS_VA_CTRL0);
  205. }
  206. static struct s3c2410_platform_nand __initdata osiris_nand_info = {
  207. .tacls = 25,
  208. .twrph0 = 60,
  209. .twrph1 = 60,
  210. .nr_sets = ARRAY_SIZE(osiris_nand_sets),
  211. .sets = osiris_nand_sets,
  212. .select_chip = osiris_nand_select,
  213. .ecc_mode = NAND_ECC_SOFT,
  214. };
  215. /* PCMCIA control and configuration */
  216. static struct resource osiris_pcmcia_resource[] = {
  217. [0] = DEFINE_RES_MEM(0x0f000000, SZ_1M),
  218. [1] = DEFINE_RES_MEM(0x0c000000, SZ_1M),
  219. };
  220. static struct platform_device osiris_pcmcia = {
  221. .name = "osiris-pcmcia",
  222. .id = -1,
  223. .num_resources = ARRAY_SIZE(osiris_pcmcia_resource),
  224. .resource = osiris_pcmcia_resource,
  225. };
  226. /* Osiris power management device */
  227. #ifdef CONFIG_PM
  228. static unsigned char pm_osiris_ctrl0;
  229. static int osiris_pm_suspend(void)
  230. {
  231. unsigned int tmp;
  232. pm_osiris_ctrl0 = __raw_readb(OSIRIS_VA_CTRL0);
  233. tmp = pm_osiris_ctrl0 & ~OSIRIS_CTRL0_NANDSEL;
  234. /* ensure correct NAND slot is selected on resume */
  235. if ((pm_osiris_ctrl0 & OSIRIS_CTRL0_BOOT_INT) == 0)
  236. tmp |= 2;
  237. __raw_writeb(tmp, OSIRIS_VA_CTRL0);
  238. /* ensure that an nRESET is not generated on resume. */
  239. gpio_request_one(S3C2410_GPA(21), GPIOF_OUT_INIT_HIGH, NULL);
  240. gpio_free(S3C2410_GPA(21));
  241. return 0;
  242. }
  243. static void osiris_pm_resume(void)
  244. {
  245. if (pm_osiris_ctrl0 & OSIRIS_CTRL0_FIX8)
  246. __raw_writeb(OSIRIS_CTRL1_FIX8, OSIRIS_VA_CTRL1);
  247. __raw_writeb(pm_osiris_ctrl0, OSIRIS_VA_CTRL0);
  248. s3c_gpio_cfgpin(S3C2410_GPA(21), S3C2410_GPA21_nRSTOUT);
  249. }
  250. #else
  251. #define osiris_pm_suspend NULL
  252. #define osiris_pm_resume NULL
  253. #endif
  254. static struct syscore_ops osiris_pm_syscore_ops = {
  255. .suspend = osiris_pm_suspend,
  256. .resume = osiris_pm_resume,
  257. };
  258. /* Link for DVS driver to TPS65011 */
  259. static void osiris_tps_release(struct device *dev)
  260. {
  261. /* static device, do not need to release anything */
  262. }
  263. static struct platform_device osiris_tps_device = {
  264. .name = "osiris-dvs",
  265. .id = -1,
  266. .dev.release = osiris_tps_release,
  267. };
  268. static int osiris_tps_setup(struct i2c_client *client, void *context)
  269. {
  270. osiris_tps_device.dev.parent = &client->dev;
  271. return platform_device_register(&osiris_tps_device);
  272. }
  273. static int osiris_tps_remove(struct i2c_client *client, void *context)
  274. {
  275. platform_device_unregister(&osiris_tps_device);
  276. return 0;
  277. }
  278. static struct tps65010_board osiris_tps_board = {
  279. .base = -1, /* GPIO can go anywhere at the moment */
  280. .setup = osiris_tps_setup,
  281. .teardown = osiris_tps_remove,
  282. };
  283. /* I2C devices fitted. */
  284. static struct i2c_board_info osiris_i2c_devs[] __initdata = {
  285. {
  286. I2C_BOARD_INFO("tps65011", 0x48),
  287. .irq = IRQ_EINT20,
  288. .platform_data = &osiris_tps_board,
  289. },
  290. };
  291. /* Standard Osiris devices */
  292. static struct platform_device *osiris_devices[] __initdata = {
  293. &s3c2410_device_dclk,
  294. &s3c_device_i2c0,
  295. &s3c_device_wdt,
  296. &s3c_device_nand,
  297. &osiris_pcmcia,
  298. };
  299. static struct s3c_cpufreq_board __initdata osiris_cpufreq = {
  300. .refresh = 7800, /* refresh period is 7.8usec */
  301. .auto_io = 1,
  302. .need_io = 1,
  303. };
  304. static void __init osiris_map_io(void)
  305. {
  306. unsigned long flags;
  307. s3c24xx_init_io(osiris_iodesc, ARRAY_SIZE(osiris_iodesc));
  308. s3c24xx_init_uarts(osiris_uartcfgs, ARRAY_SIZE(osiris_uartcfgs));
  309. samsung_set_timer_source(SAMSUNG_PWM3, SAMSUNG_PWM4);
  310. /* check for the newer revision boards with large page nand */
  311. if ((__raw_readb(OSIRIS_VA_IDREG) & OSIRIS_ID_REVMASK) >= 4) {
  312. printk(KERN_INFO "OSIRIS-B detected (revision %d)\n",
  313. __raw_readb(OSIRIS_VA_IDREG) & OSIRIS_ID_REVMASK);
  314. osiris_nand_sets[0].partitions = osiris_default_nand_part_large;
  315. osiris_nand_sets[0].nr_partitions = ARRAY_SIZE(osiris_default_nand_part_large);
  316. } else {
  317. /* write-protect line to the NAND */
  318. gpio_request_one(S3C2410_GPA(0), GPIOF_OUT_INIT_HIGH, NULL);
  319. gpio_free(S3C2410_GPA(0));
  320. }
  321. /* fix bus configuration (nBE settings wrong on ABLE pre v2.20) */
  322. local_irq_save(flags);
  323. __raw_writel(__raw_readl(S3C2410_BWSCON) | S3C2410_BWSCON_ST1 | S3C2410_BWSCON_ST2 | S3C2410_BWSCON_ST3 | S3C2410_BWSCON_ST4 | S3C2410_BWSCON_ST5, S3C2410_BWSCON);
  324. local_irq_restore(flags);
  325. }
  326. static void __init osiris_init_time(void)
  327. {
  328. s3c2440_init_clocks(12000000);
  329. samsung_timer_init();
  330. }
  331. static void __init osiris_init(void)
  332. {
  333. register_syscore_ops(&osiris_pm_syscore_ops);
  334. s3c_i2c0_set_platdata(NULL);
  335. s3c_nand_set_platdata(&osiris_nand_info);
  336. s3c_cpufreq_setboard(&osiris_cpufreq);
  337. i2c_register_board_info(0, osiris_i2c_devs,
  338. ARRAY_SIZE(osiris_i2c_devs));
  339. platform_add_devices(osiris_devices, ARRAY_SIZE(osiris_devices));
  340. };
  341. MACHINE_START(OSIRIS, "Simtec-OSIRIS")
  342. /* Maintainer: Ben Dooks <ben@simtec.co.uk> */
  343. .atag_offset = 0x100,
  344. .map_io = osiris_map_io,
  345. .init_irq = s3c2440_init_irq,
  346. .init_machine = osiris_init,
  347. .init_time = osiris_init_time,
  348. MACHINE_END