s3c2412.c 5.5 KB

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