s3c2412.c 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  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/device.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 <asm/system_misc.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-dsc.h>
  38. #include <plat/regs-spi.h>
  39. #include <mach/regs-s3c2412.h>
  40. #include <plat/s3c2412.h>
  41. #include <plat/cpu.h>
  42. #include <plat/devs.h>
  43. #include <plat/clock.h>
  44. #include <plat/pm.h>
  45. #include <plat/pll.h>
  46. #include <plat/nand-core.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. .virtual = (unsigned long)S3C2412_VA_SSMC,
  63. .pfn = __phys_to_pfn(S3C2412_PA_SSMC),
  64. .length = SZ_1M,
  65. .type = MT_DEVICE,
  66. },
  67. {
  68. .virtual = (unsigned long)S3C2412_VA_EBI,
  69. .pfn = __phys_to_pfn(S3C2412_PA_EBI),
  70. .length = SZ_1M,
  71. .type = MT_DEVICE,
  72. },
  73. };
  74. /* uart registration process */
  75. void __init s3c2412_init_uarts(struct s3c2410_uartcfg *cfg, int no)
  76. {
  77. s3c24xx_init_uartdevs("s3c2412-uart", s3c2410_uart_resources, cfg, no);
  78. /* rename devices that are s3c2412/s3c2413 specific */
  79. s3c_device_sdi.name = "s3c2412-sdi";
  80. s3c_device_lcd.name = "s3c2412-lcd";
  81. s3c_nand_setname("s3c2412-nand");
  82. /* alter IRQ of SDI controller */
  83. s3c_device_sdi.resource[1].start = IRQ_S3C2412_SDI;
  84. s3c_device_sdi.resource[1].end = IRQ_S3C2412_SDI;
  85. /* spi channel related changes, s3c2412/13 specific */
  86. s3c_device_spi0.name = "s3c2412-spi";
  87. s3c_device_spi0.resource[0].end = S3C24XX_PA_SPI + 0x24;
  88. s3c_device_spi1.name = "s3c2412-spi";
  89. s3c_device_spi1.resource[0].start = S3C24XX_PA_SPI + S3C2412_SPI1;
  90. s3c_device_spi1.resource[0].end = S3C24XX_PA_SPI + S3C2412_SPI1 + 0x24;
  91. }
  92. /* s3c2412_idle
  93. *
  94. * use the standard idle call by ensuring the idle mode
  95. * in power config, then issuing the idle co-processor
  96. * instruction
  97. */
  98. static void s3c2412_idle(void)
  99. {
  100. unsigned long tmp;
  101. /* ensure our idle mode is to go to idle */
  102. tmp = __raw_readl(S3C2412_PWRCFG);
  103. tmp &= ~S3C2412_PWRCFG_STANDBYWFI_MASK;
  104. tmp |= S3C2412_PWRCFG_STANDBYWFI_IDLE;
  105. __raw_writel(tmp, S3C2412_PWRCFG);
  106. cpu_do_idle();
  107. }
  108. void s3c2412_restart(char mode, const char *cmd)
  109. {
  110. if (mode == 's')
  111. soft_restart(0);
  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. arm_pm_idle = s3c2412_idle;
  135. /* register our io-tables */
  136. iotable_init(s3c2412_iodesc, ARRAY_SIZE(s3c2412_iodesc));
  137. }
  138. void __init_or_cpufreq s3c2412_setup_clocks(void)
  139. {
  140. struct clk *xtal_clk;
  141. unsigned long tmp;
  142. unsigned long xtal;
  143. unsigned long fclk;
  144. unsigned long hclk;
  145. unsigned long pclk;
  146. xtal_clk = clk_get(NULL, "xtal");
  147. xtal = clk_get_rate(xtal_clk);
  148. clk_put(xtal_clk);
  149. /* now we've got our machine bits initialised, work out what
  150. * clocks we've got */
  151. fclk = s3c24xx_get_pll(__raw_readl(S3C2410_MPLLCON), xtal * 2);
  152. clk_mpll.rate = fclk;
  153. tmp = __raw_readl(S3C2410_CLKDIVN);
  154. /* work out clock scalings */
  155. hclk = fclk / ((tmp & S3C2412_CLKDIVN_HDIVN_MASK) + 1);
  156. hclk /= ((tmp & S3C2412_CLKDIVN_ARMDIVN) ? 2 : 1);
  157. pclk = hclk / ((tmp & S3C2412_CLKDIVN_PDIVN) ? 2 : 1);
  158. /* print brieft summary of clocks, etc */
  159. printk("S3C2412: core %ld.%03ld MHz, memory %ld.%03ld MHz, peripheral %ld.%03ld MHz\n",
  160. print_mhz(fclk), print_mhz(hclk), print_mhz(pclk));
  161. s3c24xx_setup_clocks(fclk, hclk, pclk);
  162. }
  163. void __init s3c2412_init_clocks(int xtal)
  164. {
  165. /* initialise the clocks here, to allow other things like the
  166. * console to use them
  167. */
  168. s3c24xx_register_baseclocks(xtal);
  169. s3c2412_setup_clocks();
  170. s3c2412_baseclk_add();
  171. }
  172. /* need to register the subsystem before we actually register the device, and
  173. * we also need to ensure that it has been initialised before any of the
  174. * drivers even try to use it (even if not on an s3c2412 based system)
  175. * as a driver which may support both 2410 and 2440 may try and use it.
  176. */
  177. struct bus_type s3c2412_subsys = {
  178. .name = "s3c2412-core",
  179. .dev_name = "s3c2412-core",
  180. };
  181. static int __init s3c2412_core_init(void)
  182. {
  183. return subsys_system_register(&s3c2412_subsys, NULL);
  184. }
  185. core_initcall(s3c2412_core_init);
  186. static struct device s3c2412_dev = {
  187. .bus = &s3c2412_subsys,
  188. };
  189. int __init s3c2412_init(void)
  190. {
  191. printk("S3C2412: Initialising architecture\n");
  192. #ifdef CONFIG_PM
  193. register_syscore_ops(&s3c2412_pm_syscore_ops);
  194. #endif
  195. register_syscore_ops(&s3c24xx_irq_syscore_ops);
  196. return device_register(&s3c2412_dev);
  197. }