PageRenderTime 22ms CodeModel.GetById 33ms RepoModel.GetById 0ms app.codeStats 0ms

/arch/arm/mach-s3c2440/mach-osiris.c

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