mach-osiris.c 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  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 <asm/mach/arch.h>
  25. #include <asm/mach/map.h>
  26. #include <asm/mach/irq.h>
  27. #include <mach/osiris-map.h>
  28. #include <mach/osiris-cpld.h>
  29. #include <mach/hardware.h>
  30. #include <asm/irq.h>
  31. #include <asm/mach-types.h>
  32. #include <plat/regs-serial.h>
  33. #include <mach/regs-gpio.h>
  34. #include <mach/regs-mem.h>
  35. #include <mach/regs-lcd.h>
  36. #include <plat/nand.h>
  37. #include <plat/iic.h>
  38. #include <linux/mtd/mtd.h>
  39. #include <linux/mtd/nand.h>
  40. #include <linux/mtd/nand_ecc.h>
  41. #include <linux/mtd/partitions.h>
  42. #include <plat/clock.h>
  43. #include <plat/devs.h>
  44. #include <plat/cpu.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 s3c24xx_uart_clksrc osiris_serial_clocks[] = {
  86. [0] = {
  87. .name = "uclk",
  88. .divisor = 1,
  89. .min_baud = 0,
  90. .max_baud = 0,
  91. },
  92. [1] = {
  93. .name = "pclk",
  94. .divisor = 1,
  95. .min_baud = 0,
  96. .max_baud = 0,
  97. }
  98. };
  99. static struct s3c2410_uartcfg osiris_uartcfgs[] __initdata = {
  100. [0] = {
  101. .hwport = 0,
  102. .flags = 0,
  103. .ucon = UCON,
  104. .ulcon = ULCON,
  105. .ufcon = UFCON,
  106. .clocks = osiris_serial_clocks,
  107. .clocks_size = ARRAY_SIZE(osiris_serial_clocks),
  108. },
  109. [1] = {
  110. .hwport = 1,
  111. .flags = 0,
  112. .ucon = UCON,
  113. .ulcon = ULCON,
  114. .ufcon = UFCON,
  115. .clocks = osiris_serial_clocks,
  116. .clocks_size = ARRAY_SIZE(osiris_serial_clocks),
  117. },
  118. [2] = {
  119. .hwport = 2,
  120. .flags = 0,
  121. .ucon = UCON,
  122. .ulcon = ULCON,
  123. .ufcon = UFCON,
  124. .clocks = osiris_serial_clocks,
  125. .clocks_size = ARRAY_SIZE(osiris_serial_clocks),
  126. }
  127. };
  128. /* NAND Flash on Osiris board */
  129. static int external_map[] = { 2 };
  130. static int chip0_map[] = { 0 };
  131. static int chip1_map[] = { 1 };
  132. static struct mtd_partition osiris_default_nand_part[] = {
  133. [0] = {
  134. .name = "Boot Agent",
  135. .size = SZ_16K,
  136. .offset = 0,
  137. },
  138. [1] = {
  139. .name = "/boot",
  140. .size = SZ_4M - SZ_16K,
  141. .offset = SZ_16K,
  142. },
  143. [2] = {
  144. .name = "user1",
  145. .offset = SZ_4M,
  146. .size = SZ_32M - SZ_4M,
  147. },
  148. [3] = {
  149. .name = "user2",
  150. .offset = SZ_32M,
  151. .size = MTDPART_SIZ_FULL,
  152. }
  153. };
  154. static struct mtd_partition osiris_default_nand_part_large[] = {
  155. [0] = {
  156. .name = "Boot Agent",
  157. .size = SZ_128K,
  158. .offset = 0,
  159. },
  160. [1] = {
  161. .name = "/boot",
  162. .size = SZ_4M - SZ_128K,
  163. .offset = SZ_128K,
  164. },
  165. [2] = {
  166. .name = "user1",
  167. .offset = SZ_4M,
  168. .size = SZ_32M - SZ_4M,
  169. },
  170. [3] = {
  171. .name = "user2",
  172. .offset = SZ_32M,
  173. .size = MTDPART_SIZ_FULL,
  174. }
  175. };
  176. /* the Osiris has 3 selectable slots for nand-flash, the two
  177. * on-board chip areas, as well as the external slot.
  178. *
  179. * Note, there is no current hot-plug support for the External
  180. * socket.
  181. */
  182. static struct s3c2410_nand_set osiris_nand_sets[] = {
  183. [1] = {
  184. .name = "External",
  185. .nr_chips = 1,
  186. .nr_map = external_map,
  187. .nr_partitions = ARRAY_SIZE(osiris_default_nand_part),
  188. .partitions = osiris_default_nand_part,
  189. },
  190. [0] = {
  191. .name = "chip0",
  192. .nr_chips = 1,
  193. .nr_map = chip0_map,
  194. .nr_partitions = ARRAY_SIZE(osiris_default_nand_part),
  195. .partitions = osiris_default_nand_part,
  196. },
  197. [2] = {
  198. .name = "chip1",
  199. .nr_chips = 1,
  200. .nr_map = chip1_map,
  201. .nr_partitions = ARRAY_SIZE(osiris_default_nand_part),
  202. .partitions = osiris_default_nand_part,
  203. },
  204. };
  205. static void osiris_nand_select(struct s3c2410_nand_set *set, int slot)
  206. {
  207. unsigned int tmp;
  208. slot = set->nr_map[slot] & 3;
  209. pr_debug("osiris_nand: selecting slot %d (set %p,%p)\n",
  210. slot, set, set->nr_map);
  211. tmp = __raw_readb(OSIRIS_VA_CTRL0);
  212. tmp &= ~OSIRIS_CTRL0_NANDSEL;
  213. tmp |= slot;
  214. pr_debug("osiris_nand: ctrl0 now %02x\n", tmp);
  215. __raw_writeb(tmp, OSIRIS_VA_CTRL0);
  216. }
  217. static struct s3c2410_platform_nand osiris_nand_info = {
  218. .tacls = 25,
  219. .twrph0 = 60,
  220. .twrph1 = 60,
  221. .nr_sets = ARRAY_SIZE(osiris_nand_sets),
  222. .sets = osiris_nand_sets,
  223. .select_chip = osiris_nand_select,
  224. };
  225. /* PCMCIA control and configuration */
  226. static struct resource osiris_pcmcia_resource[] = {
  227. [0] = {
  228. .start = 0x0f000000,
  229. .end = 0x0f100000,
  230. .flags = IORESOURCE_MEM,
  231. },
  232. [1] = {
  233. .start = 0x0c000000,
  234. .end = 0x0c100000,
  235. .flags = IORESOURCE_MEM,
  236. }
  237. };
  238. static struct platform_device osiris_pcmcia = {
  239. .name = "osiris-pcmcia",
  240. .id = -1,
  241. .num_resources = ARRAY_SIZE(osiris_pcmcia_resource),
  242. .resource = osiris_pcmcia_resource,
  243. };
  244. /* Osiris power management device */
  245. #ifdef CONFIG_PM
  246. static unsigned char pm_osiris_ctrl0;
  247. static int osiris_pm_suspend(struct sys_device *sd, pm_message_t state)
  248. {
  249. unsigned int tmp;
  250. pm_osiris_ctrl0 = __raw_readb(OSIRIS_VA_CTRL0);
  251. tmp = pm_osiris_ctrl0 & ~OSIRIS_CTRL0_NANDSEL;
  252. /* ensure correct NAND slot is selected on resume */
  253. if ((pm_osiris_ctrl0 & OSIRIS_CTRL0_BOOT_INT) == 0)
  254. tmp |= 2;
  255. __raw_writeb(tmp, OSIRIS_VA_CTRL0);
  256. /* ensure that an nRESET is not generated on resume. */
  257. s3c2410_gpio_setpin(S3C2410_GPA(21), 1);
  258. s3c2410_gpio_cfgpin(S3C2410_GPA(21), S3C2410_GPIO_OUTPUT);
  259. return 0;
  260. }
  261. static int osiris_pm_resume(struct sys_device *sd)
  262. {
  263. if (pm_osiris_ctrl0 & OSIRIS_CTRL0_FIX8)
  264. __raw_writeb(OSIRIS_CTRL1_FIX8, OSIRIS_VA_CTRL1);
  265. __raw_writeb(pm_osiris_ctrl0, OSIRIS_VA_CTRL0);
  266. s3c2410_gpio_cfgpin(S3C2410_GPA(21), S3C2410_GPA21_nRSTOUT);
  267. return 0;
  268. }
  269. #else
  270. #define osiris_pm_suspend NULL
  271. #define osiris_pm_resume NULL
  272. #endif
  273. static struct sysdev_class osiris_pm_sysclass = {
  274. .name = "mach-osiris",
  275. .suspend = osiris_pm_suspend,
  276. .resume = osiris_pm_resume,
  277. };
  278. static struct sys_device osiris_pm_sysdev = {
  279. .cls = &osiris_pm_sysclass,
  280. };
  281. /* I2C devices fitted. */
  282. static struct i2c_board_info osiris_i2c_devs[] __initdata = {
  283. {
  284. I2C_BOARD_INFO("tps65011", 0x48),
  285. .irq = IRQ_EINT20,
  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 void __init osiris_map_io(void)
  303. {
  304. unsigned long flags;
  305. /* initialise the clocks */
  306. s3c24xx_dclk0.parent = &clk_upll;
  307. s3c24xx_dclk0.rate = 12*1000*1000;
  308. s3c24xx_dclk1.parent = &clk_upll;
  309. s3c24xx_dclk1.rate = 24*1000*1000;
  310. s3c24xx_clkout0.parent = &s3c24xx_dclk0;
  311. s3c24xx_clkout1.parent = &s3c24xx_dclk1;
  312. s3c24xx_uclk.parent = &s3c24xx_clkout1;
  313. s3c24xx_register_clocks(osiris_clocks, ARRAY_SIZE(osiris_clocks));
  314. s3c_device_nand.dev.platform_data = &osiris_nand_info;
  315. s3c24xx_init_io(osiris_iodesc, ARRAY_SIZE(osiris_iodesc));
  316. s3c24xx_init_clocks(0);
  317. s3c24xx_init_uarts(osiris_uartcfgs, ARRAY_SIZE(osiris_uartcfgs));
  318. /* check for the newer revision boards with large page nand */
  319. if ((__raw_readb(OSIRIS_VA_IDREG) & OSIRIS_ID_REVMASK) >= 4) {
  320. printk(KERN_INFO "OSIRIS-B detected (revision %d)\n",
  321. __raw_readb(OSIRIS_VA_IDREG) & OSIRIS_ID_REVMASK);
  322. osiris_nand_sets[0].partitions = osiris_default_nand_part_large;
  323. osiris_nand_sets[0].nr_partitions = ARRAY_SIZE(osiris_default_nand_part_large);
  324. } else {
  325. /* write-protect line to the NAND */
  326. s3c2410_gpio_setpin(S3C2410_GPA(0), 1);
  327. }
  328. /* fix bus configuration (nBE settings wrong on ABLE pre v2.20) */
  329. local_irq_save(flags);
  330. __raw_writel(__raw_readl(S3C2410_BWSCON) | S3C2410_BWSCON_ST1 | S3C2410_BWSCON_ST2 | S3C2410_BWSCON_ST3 | S3C2410_BWSCON_ST4 | S3C2410_BWSCON_ST5, S3C2410_BWSCON);
  331. local_irq_restore(flags);
  332. }
  333. static void __init osiris_init(void)
  334. {
  335. sysdev_class_register(&osiris_pm_sysclass);
  336. sysdev_register(&osiris_pm_sysdev);
  337. s3c_i2c0_set_platdata(NULL);
  338. i2c_register_board_info(0, osiris_i2c_devs,
  339. ARRAY_SIZE(osiris_i2c_devs));
  340. platform_add_devices(osiris_devices, ARRAY_SIZE(osiris_devices));
  341. };
  342. MACHINE_START(OSIRIS, "Simtec-OSIRIS")
  343. /* Maintainer: Ben Dooks <ben@simtec.co.uk> */
  344. .phys_io = S3C2410_PA_UART,
  345. .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
  346. .boot_params = S3C2410_SDRAM_PA + 0x100,
  347. .map_io = osiris_map_io,
  348. .init_irq = s3c24xx_init_irq,
  349. .init_machine = osiris_init,
  350. .timer = &s3c24xx_timer,
  351. MACHINE_END