s3c2412.c 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. /* linux/arch/arm/mach-s3c2412/s3c2412.c
  2. *
  3. * Copyright (c) 2006 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/clk.h>
  19. #include <linux/delay.h>
  20. #include <linux/sysdev.h>
  21. #include <linux/syscore_ops.h>
  22. #include <linux/serial_core.h>
  23. #include <linux/platform_device.h>
  24. #include <linux/io.h>
  25. #include <asm/mach/arch.h>
  26. #include <asm/mach/map.h>
  27. #include <asm/mach/irq.h>
  28. #include <mach/hardware.h>
  29. #include <asm/proc-fns.h>
  30. #include <asm/irq.h>
  31. #include <mach/reset.h>
  32. #include <mach/idle.h>
  33. #include <plat/cpu-freq.h>
  34. #include <mach/regs-clock.h>
  35. #include <plat/regs-serial.h>
  36. #include <mach/regs-power.h>
  37. #include <mach/regs-gpio.h>
  38. #include <mach/regs-gpioj.h>
  39. #include <mach/regs-dsc.h>
  40. #include <plat/regs-spi.h>
  41. #include <mach/regs-s3c2412.h>
  42. #include <plat/s3c2412.h>
  43. #include <plat/cpu.h>
  44. #include <plat/devs.h>
  45. #include <plat/clock.h>
  46. #include <plat/pm.h>
  47. #include <plat/pll.h>
  48. #include <plat/nand-core.h>
  49. #ifndef CONFIG_CPU_S3C2412_ONLY
  50. void __iomem *s3c24xx_va_gpio2 = S3C24XX_VA_GPIO;
  51. static inline void s3c2412_init_gpio2(void)
  52. {
  53. s3c24xx_va_gpio2 = S3C24XX_VA_GPIO + 0x10;
  54. }
  55. #else
  56. #define s3c2412_init_gpio2() do { } while(0)
  57. #endif
  58. /* Initial IO mappings */
  59. static struct map_desc s3c2412_iodesc[] __initdata = {
  60. IODESC_ENT(CLKPWR),
  61. IODESC_ENT(TIMER),
  62. IODESC_ENT(WATCHDOG),
  63. {
  64. .virtual = (unsigned long)S3C2412_VA_SSMC,
  65. .pfn = __phys_to_pfn(S3C2412_PA_SSMC),
  66. .length = SZ_1M,
  67. .type = MT_DEVICE,
  68. },
  69. {
  70. .virtual = (unsigned long)S3C2412_VA_EBI,
  71. .pfn = __phys_to_pfn(S3C2412_PA_EBI),
  72. .length = SZ_1M,
  73. .type = MT_DEVICE,
  74. },
  75. };
  76. /* uart registration process */
  77. void __init s3c2412_init_uarts(struct s3c2410_uartcfg *cfg, int no)
  78. {
  79. s3c24xx_init_uartdevs("s3c2412-uart", s3c2410_uart_resources, cfg, no);
  80. /* rename devices that are s3c2412/s3c2413 specific */
  81. s3c_device_sdi.name = "s3c2412-sdi";
  82. s3c_device_lcd.name = "s3c2412-lcd";
  83. s3c_nand_setname("s3c2412-nand");
  84. /* alter IRQ of SDI controller */
  85. s3c_device_sdi.resource[1].start = IRQ_S3C2412_SDI;
  86. s3c_device_sdi.resource[1].end = IRQ_S3C2412_SDI;
  87. /* spi channel related changes, s3c2412/13 specific */
  88. s3c_device_spi0.name = "s3c2412-spi";
  89. s3c_device_spi0.resource[0].end = S3C24XX_PA_SPI + 0x24;
  90. s3c_device_spi1.name = "s3c2412-spi";
  91. s3c_device_spi1.resource[0].start = S3C24XX_PA_SPI + S3C2412_SPI1;
  92. s3c_device_spi1.resource[0].end = S3C24XX_PA_SPI + S3C2412_SPI1 + 0x24;
  93. }
  94. /* s3c2412_idle
  95. *
  96. * use the standard idle call by ensuring the idle mode
  97. * in power config, then issuing the idle co-processor
  98. * instruction
  99. */
  100. static void s3c2412_idle(void)
  101. {
  102. unsigned long tmp;
  103. /* ensure our idle mode is to go to idle */
  104. tmp = __raw_readl(S3C2412_PWRCFG);
  105. tmp &= ~S3C2412_PWRCFG_STANDBYWFI_MASK;
  106. tmp |= S3C2412_PWRCFG_STANDBYWFI_IDLE;
  107. __raw_writel(tmp, S3C2412_PWRCFG);
  108. cpu_do_idle();
  109. }
  110. static void s3c2412_hard_reset(void)
  111. {
  112. /* errata "Watch-dog/Software Reset Problem" specifies that
  113. * this reset must be done with the SYSCLK sourced from
  114. * EXTCLK instead of FOUT to avoid a glitch in the reset
  115. * mechanism.
  116. *
  117. * See the watchdog section of the S3C2412 manual for more
  118. * information on this fix.
  119. */
  120. __raw_writel(0x00, S3C2412_CLKSRC);
  121. __raw_writel(S3C2412_SWRST_RESET, S3C2412_SWRST);
  122. mdelay(1);
  123. }
  124. /* s3c2412_map_io
  125. *
  126. * register the standard cpu IO areas, and any passed in from the
  127. * machine specific initialisation.
  128. */
  129. void __init s3c2412_map_io(void)
  130. {
  131. /* move base of IO */
  132. s3c2412_init_gpio2();
  133. /* set our idle function */
  134. s3c24xx_idle = s3c2412_idle;
  135. /* set custom reset hook */
  136. s3c24xx_reset_hook = s3c2412_hard_reset;
  137. /* register our io-tables */
  138. iotable_init(s3c2412_iodesc, ARRAY_SIZE(s3c2412_iodesc));
  139. }
  140. void __init_or_cpufreq s3c2412_setup_clocks(void)
  141. {
  142. struct clk *xtal_clk;
  143. unsigned long tmp;
  144. unsigned long xtal;
  145. unsigned long fclk;
  146. unsigned long hclk;
  147. unsigned long pclk;
  148. xtal_clk = clk_get(NULL, "xtal");
  149. xtal = clk_get_rate(xtal_clk);
  150. clk_put(xtal_clk);
  151. /* now we've got our machine bits initialised, work out what
  152. * clocks we've got */
  153. fclk = s3c24xx_get_pll(__raw_readl(S3C2410_MPLLCON), xtal * 2);
  154. clk_mpll.rate = fclk;
  155. tmp = __raw_readl(S3C2410_CLKDIVN);
  156. /* work out clock scalings */
  157. hclk = fclk / ((tmp & S3C2412_CLKDIVN_HDIVN_MASK) + 1);
  158. hclk /= ((tmp & S3C2412_CLKDIVN_ARMDIVN) ? 2 : 1);
  159. pclk = hclk / ((tmp & S3C2412_CLKDIVN_PDIVN) ? 2 : 1);
  160. /* print brieft summary of clocks, etc */
  161. printk("S3C2412: core %ld.%03ld MHz, memory %ld.%03ld MHz, peripheral %ld.%03ld MHz\n",
  162. print_mhz(fclk), print_mhz(hclk), print_mhz(pclk));
  163. s3c24xx_setup_clocks(fclk, hclk, pclk);
  164. }
  165. void __init s3c2412_init_clocks(int xtal)
  166. {
  167. /* initialise the clocks here, to allow other things like the
  168. * console to use them
  169. */
  170. s3c24xx_register_baseclocks(xtal);
  171. s3c2412_setup_clocks();
  172. s3c2412_baseclk_add();
  173. }
  174. /* need to register class before we actually register the device, and
  175. * we also need to ensure that it has been initialised before any of the
  176. * drivers even try to use it (even if not on an s3c2412 based system)
  177. * as a driver which may support both 2410 and 2440 may try and use it.
  178. */
  179. struct sysdev_class s3c2412_sysclass = {
  180. .name = "s3c2412-core",
  181. };
  182. static int __init s3c2412_core_init(void)
  183. {
  184. return sysdev_class_register(&s3c2412_sysclass);
  185. }
  186. core_initcall(s3c2412_core_init);
  187. static struct sys_device s3c2412_sysdev = {
  188. .cls = &s3c2412_sysclass,
  189. };
  190. int __init s3c2412_init(void)
  191. {
  192. printk("S3C2412: Initialising architecture\n");
  193. #ifdef CONFIG_PM
  194. register_syscore_ops(&s3c2412_pm_syscore_ops);
  195. #endif
  196. register_syscore_ops(&s3c24xx_irq_syscore_ops);
  197. return sysdev_register(&s3c2412_sysdev);
  198. }