mach-osiris.c 9.6 KB

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