mach-osiris.c 9.3 KB

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