s3c2412.c 5.9 KB

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