mach-osiris.c 9.7 KB

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