mach-jive.c 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. /* linux/arch/arm/mach-s3c2410/mach-jive.c
  2. *
  3. * Copyright 2007 Simtec Electronics
  4. * Ben Dooks <ben@simtec.co.uk>
  5. *
  6. * http://armlinux.simtec.co.uk/
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. */
  12. #include <linux/kernel.h>
  13. #include <linux/types.h>
  14. #include <linux/interrupt.h>
  15. #include <linux/list.h>
  16. #include <linux/timer.h>
  17. #include <linux/init.h>
  18. #include <linux/sysdev.h>
  19. #include <linux/serial_core.h>
  20. #include <linux/platform_device.h>
  21. #include <linux/mtd/mtd.h>
  22. #include <linux/mtd/partitions.h>
  23. #include <asm/mach/arch.h>
  24. #include <asm/mach/map.h>
  25. #include <asm/mach/irq.h>
  26. #include <asm/plat-s3c/regs-serial.h>
  27. #include <asm/plat-s3c/nand.h>
  28. #include <asm/arch/regs-power.h>
  29. #include <asm/arch/regs-gpio.h>
  30. #include <asm/arch/regs-mem.h>
  31. #include <asm/arch/regs-lcd.h>
  32. #include <asm/mach-types.h>
  33. #include <linux/mtd/mtd.h>
  34. #include <linux/mtd/nand.h>
  35. #include <linux/mtd/nand_ecc.h>
  36. #include <linux/mtd/partitions.h>
  37. #include <asm/plat-s3c24xx/clock.h>
  38. #include <asm/plat-s3c24xx/devs.h>
  39. #include <asm/plat-s3c24xx/cpu.h>
  40. #include <asm/plat-s3c24xx/pm.h>
  41. #include <asm/plat-s3c24xx/udc.h>
  42. static struct map_desc jive_iodesc[] __initdata = {
  43. };
  44. #define UCON S3C2410_UCON_DEFAULT
  45. #define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE
  46. #define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
  47. static struct s3c2410_uartcfg jive_uartcfgs[] = {
  48. [0] = {
  49. .hwport = 0,
  50. .flags = 0,
  51. .ucon = UCON,
  52. .ulcon = ULCON,
  53. .ufcon = UFCON,
  54. },
  55. [1] = {
  56. .hwport = 1,
  57. .flags = 0,
  58. .ucon = UCON,
  59. .ulcon = ULCON,
  60. .ufcon = UFCON,
  61. },
  62. [2] = {
  63. .hwport = 2,
  64. .flags = 0,
  65. .ucon = UCON,
  66. .ulcon = ULCON,
  67. .ufcon = UFCON,
  68. }
  69. };
  70. /* Jive flash assignment
  71. *
  72. * 0x00000000-0x00028000 : uboot
  73. * 0x00028000-0x0002c000 : uboot env
  74. * 0x0002c000-0x00030000 : spare
  75. * 0x00030000-0x00200000 : zimage A
  76. * 0x00200000-0x01600000 : cramfs A
  77. * 0x01600000-0x017d0000 : zimage B
  78. * 0x017d0000-0x02bd0000 : cramfs B
  79. * 0x02bd0000-0x03fd0000 : yaffs
  80. */
  81. static struct mtd_partition jive_imageA_nand_part[] = {
  82. #ifdef CONFIG_MACH_JIVE_SHOW_BOOTLOADER
  83. /* Don't allow access to the bootloader from linux */
  84. {
  85. .name = "uboot",
  86. .offset = 0,
  87. .size = (160 * SZ_1K),
  88. .mask_flags = MTD_WRITEABLE, /* force read-only */
  89. },
  90. /* spare */
  91. {
  92. .name = "spare",
  93. .offset = (176 * SZ_1K),
  94. .size = (16 * SZ_1K),
  95. },
  96. #endif
  97. /* booted images */
  98. {
  99. .name = "kernel (ro)",
  100. .offset = (192 * SZ_1K),
  101. .size = (SZ_2M) - (192 * SZ_1K),
  102. .mask_flags = MTD_WRITEABLE, /* force read-only */
  103. }, {
  104. .name = "root (ro)",
  105. .offset = (SZ_2M),
  106. .size = (20 * SZ_1M),
  107. .mask_flags = MTD_WRITEABLE, /* force read-only */
  108. },
  109. /* yaffs */
  110. {
  111. .name = "yaffs",
  112. .offset = (44 * SZ_1M),
  113. .size = (20 * SZ_1M),
  114. },
  115. /* bootloader environment */
  116. {
  117. .name = "env",
  118. .offset = (160 * SZ_1K),
  119. .size = (16 * SZ_1K),
  120. },
  121. /* upgrade images */
  122. {
  123. .name = "zimage",
  124. .offset = (22 * SZ_1M),
  125. .size = (2 * SZ_1M) - (192 * SZ_1K),
  126. }, {
  127. .name = "cramfs",
  128. .offset = (24 * SZ_1M) - (192*SZ_1K),
  129. .size = (20 * SZ_1M),
  130. },
  131. };
  132. static struct mtd_partition jive_imageB_nand_part[] = {
  133. #ifdef CONFIG_MACH_JIVE_SHOW_BOOTLOADER
  134. /* Don't allow access to the bootloader from linux */
  135. {
  136. .name = "uboot",
  137. .offset = 0,
  138. .size = (160 * SZ_1K),
  139. .mask_flags = MTD_WRITEABLE, /* force read-only */
  140. },
  141. /* spare */
  142. {
  143. .name = "spare",
  144. .offset = (176 * SZ_1K),
  145. .size = (16 * SZ_1K),
  146. },
  147. #endif
  148. /* booted images */
  149. {
  150. .name = "kernel (ro)",
  151. .offset = (22 * SZ_1M),
  152. .size = (2 * SZ_1M) - (192 * SZ_1K),
  153. .mask_flags = MTD_WRITEABLE, /* force read-only */
  154. },
  155. {
  156. .name = "root (ro)",
  157. .offset = (24 * SZ_1M) - (192 * SZ_1K),
  158. .size = (20 * SZ_1M),
  159. .mask_flags = MTD_WRITEABLE, /* force read-only */
  160. },
  161. /* yaffs */
  162. {
  163. .name = "yaffs",
  164. .offset = (44 * SZ_1M),
  165. .size = (20 * SZ_1M),
  166. },
  167. /* bootloader environment */
  168. {
  169. .name = "env",
  170. .offset = (160 * SZ_1K),
  171. .size = (16 * SZ_1K),
  172. },
  173. /* upgrade images */
  174. {
  175. .name = "zimage",
  176. .offset = (192 * SZ_1K),
  177. .size = (2 * SZ_1M) - (192 * SZ_1K),
  178. }, {
  179. .name = "cramfs",
  180. .offset = (2 * SZ_1M),
  181. .size = (20 * SZ_1M),
  182. },
  183. };
  184. static struct s3c2410_nand_set jive_nand_sets[] = {
  185. [0] = {
  186. .name = "flash",
  187. .nr_chips = 1,
  188. .nr_partitions = ARRAY_SIZE(jive_imageA_nand_part),
  189. .partitions = jive_imageA_nand_part,
  190. },
  191. };
  192. static struct s3c2410_platform_nand jive_nand_info = {
  193. /* set taken from osiris nand timings, possibly still conservative */
  194. .tacls = 30,
  195. .twrph0 = 55,
  196. .twrph1 = 40,
  197. .sets = jive_nand_sets,
  198. .nr_sets = ARRAY_SIZE(jive_nand_sets),
  199. };
  200. static int __init jive_mtdset(char *options)
  201. {
  202. struct s3c2410_nand_set *nand = &jive_nand_sets[0];
  203. unsigned long set;
  204. if (options == NULL || options[0] == '\0')
  205. return 0;
  206. if (strict_strtoul(options, 10, &set)) {
  207. printk(KERN_ERR "failed to parse mtdset=%s\n", options);
  208. return 0;
  209. }
  210. switch (set) {
  211. case 1:
  212. nand->nr_partitions = ARRAY_SIZE(jive_imageB_nand_part);
  213. nand->partitions = jive_imageB_nand_part;
  214. case 0:
  215. /* this is already setup in the nand info */
  216. break;
  217. default:
  218. printk(KERN_ERR "Unknown mtd set %ld specified,"
  219. "using default.", set);
  220. }
  221. return 0;
  222. }
  223. /* parse the mtdset= option given to the kernel command line */
  224. __setup("mtdset=", jive_mtdset);
  225. static struct platform_device *jive_devices[] __initdata = {
  226. &s3c_device_usb,
  227. &s3c_device_rtc,
  228. &s3c_device_wdt,
  229. &s3c_device_i2c,
  230. &s3c_device_nand,
  231. &s3c_device_usbgadget,
  232. };
  233. static struct s3c2410_udc_mach_info jive_udc_cfg __initdata = {
  234. .vbus_pin = S3C2410_GPG1, /* detect is on GPG1 */
  235. };
  236. /* Jive power management device */
  237. #ifdef CONFIG_PM
  238. static int jive_pm_suspend(struct sys_device *sd, pm_message_t state)
  239. {
  240. /* Write the magic value u-boot uses to check for resume into
  241. * the INFORM0 register, and ensure INFORM1 is set to the
  242. * correct address to resume from. */
  243. __raw_writel(0x2BED, S3C2412_INFORM0);
  244. __raw_writel(virt_to_phys(s3c2410_cpu_resume), S3C2412_INFORM1);
  245. return 0;
  246. }
  247. static int jive_pm_resume(struct sys_device *sd)
  248. {
  249. __raw_writel(0x0, S3C2412_INFORM0);
  250. return 0;
  251. }
  252. #else
  253. #define jive_pm_suspend NULL
  254. #define jive_pm_resume NULL
  255. #endif
  256. static struct sysdev_class jive_pm_sysclass = {
  257. .name = "jive-pm",
  258. .suspend = jive_pm_suspend,
  259. .resume = jive_pm_resume,
  260. };
  261. static struct sys_device jive_pm_sysdev = {
  262. .cls = &jive_pm_sysclass,
  263. };
  264. static void __init jive_map_io(void)
  265. {
  266. s3c24xx_init_io(jive_iodesc, ARRAY_SIZE(jive_iodesc));
  267. s3c24xx_init_clocks(12000000);
  268. s3c24xx_init_uarts(jive_uartcfgs, ARRAY_SIZE(jive_uartcfgs));
  269. }
  270. static void __init jive_machine_init(void)
  271. {
  272. /* register system devices for managing low level suspend */
  273. sysdev_class_register(&jive_pm_sysclass);
  274. sysdev_register(&jive_pm_sysdev);
  275. s3c2410_pm_init();
  276. s3c_device_nand.dev.platform_data = &jive_nand_info;
  277. /* Turn off suspend on both USB ports, and switch the
  278. * selectable USB port to USB device mode. */
  279. s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST |
  280. S3C2410_MISCCR_USBSUSPND0 |
  281. S3C2410_MISCCR_USBSUSPND1, 0x0);
  282. s3c24xx_udc_set_platdata(&jive_udc_cfg);
  283. platform_add_devices(jive_devices, ARRAY_SIZE(jive_devices));
  284. }
  285. MACHINE_START(JIVE, "JIVE")
  286. /* Maintainer: Ben Dooks <ben@fluff.org> */
  287. .phys_io = S3C2410_PA_UART,
  288. .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
  289. .boot_params = S3C2410_SDRAM_PA + 0x100,
  290. .init_irq = s3c24xx_init_irq,
  291. .map_io = jive_map_io,
  292. .init_machine = jive_machine_init,
  293. .timer = &s3c24xx_timer,
  294. MACHINE_END