s3c2412.c 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. /* linux/arch/arm/mach-s3c2410/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. * Modifications:
  13. * 16-May-2003 BJD Created initial version
  14. * 16-Aug-2003 BJD Fixed header files and copyright, added URL
  15. * 05-Sep-2003 BJD Moved to kernel v2.6
  16. * 18-Jan-2004 BJD Added serial port configuration
  17. * 21-Aug-2004 BJD Added new struct s3c2410_board handler
  18. * 28-Sep-2004 BJD Updates for new serial port bits
  19. * 04-Nov-2004 BJD Updated UART configuration process
  20. * 10-Jan-2005 BJD Removed s3c2410_clock_tick_rate
  21. * 13-Aug-2005 DA Removed UART from initial I/O mappings
  22. */
  23. #include <linux/kernel.h>
  24. #include <linux/types.h>
  25. #include <linux/interrupt.h>
  26. #include <linux/list.h>
  27. #include <linux/timer.h>
  28. #include <linux/init.h>
  29. #include <linux/sysdev.h>
  30. #include <linux/platform_device.h>
  31. #include <asm/mach/arch.h>
  32. #include <asm/mach/map.h>
  33. #include <asm/mach/irq.h>
  34. #include <asm/hardware.h>
  35. #include <asm/proc-fns.h>
  36. #include <asm/io.h>
  37. #include <asm/irq.h>
  38. #include <asm/arch/idle.h>
  39. #include <asm/arch/regs-clock.h>
  40. #include <asm/arch/regs-serial.h>
  41. #include <asm/arch/regs-power.h>
  42. #include <asm/arch/regs-gpio.h>
  43. #include <asm/arch/regs-gpioj.h>
  44. #include <asm/arch/regs-dsc.h>
  45. #include "s3c2412.h"
  46. #include "cpu.h"
  47. #include "devs.h"
  48. #include "clock.h"
  49. #include "pm.h"
  50. #ifndef CONFIG_CPU_S3C2412_ONLY
  51. void __iomem *s3c24xx_va_gpio2 = S3C24XX_VA_GPIO;
  52. static inline void s3c2412_init_gpio2(void)
  53. {
  54. s3c24xx_va_gpio2 = S3C24XX_VA_GPIO + 0x10;
  55. }
  56. #else
  57. #define s3c2412_init_gpio2() do { } while(0)
  58. #endif
  59. /* Initial IO mappings */
  60. static struct map_desc s3c2412_iodesc[] __initdata = {
  61. IODESC_ENT(CLKPWR),
  62. IODESC_ENT(LCD),
  63. IODESC_ENT(TIMER),
  64. IODESC_ENT(ADC),
  65. IODESC_ENT(WATCHDOG),
  66. };
  67. /* uart registration process */
  68. void __init s3c2412_init_uarts(struct s3c2410_uartcfg *cfg, int no)
  69. {
  70. s3c24xx_init_uartdevs("s3c2412-uart", s3c2410_uart_resources, cfg, no);
  71. /* rename devices that are s3c2412/s3c2413 specific */
  72. s3c_device_sdi.name = "s3c2412-sdi";
  73. s3c_device_nand.name = "s3c2412-nand";
  74. }
  75. /* s3c2412_idle
  76. *
  77. * use the standard idle call by ensuring the idle mode
  78. * in power config, then issuing the idle co-processor
  79. * instruction
  80. */
  81. static void s3c2412_idle(void)
  82. {
  83. unsigned long tmp;
  84. /* ensure our idle mode is to go to idle */
  85. tmp = __raw_readl(S3C2412_PWRCFG);
  86. tmp &= ~S3C2412_PWRCFG_STANDBYWFI_MASK;
  87. tmp |= S3C2412_PWRCFG_STANDBYWFI_IDLE;
  88. __raw_writel(tmp, S3C2412_PWRCFG);
  89. cpu_do_idle();
  90. }
  91. /* s3c2412_map_io
  92. *
  93. * register the standard cpu IO areas, and any passed in from the
  94. * machine specific initialisation.
  95. */
  96. void __init s3c2412_map_io(struct map_desc *mach_desc, int mach_size)
  97. {
  98. /* move base of IO */
  99. s3c2412_init_gpio2();
  100. /* set our idle function */
  101. s3c24xx_idle = s3c2412_idle;
  102. /* register our io-tables */
  103. iotable_init(s3c2412_iodesc, ARRAY_SIZE(s3c2412_iodesc));
  104. iotable_init(mach_desc, mach_size);
  105. }
  106. void __init s3c2412_init_clocks(int xtal)
  107. {
  108. unsigned long tmp;
  109. unsigned long fclk;
  110. unsigned long hclk;
  111. unsigned long pclk;
  112. /* now we've got our machine bits initialised, work out what
  113. * clocks we've got */
  114. fclk = s3c2410_get_pll(__raw_readl(S3C2410_MPLLCON), xtal*2);
  115. tmp = __raw_readl(S3C2410_CLKDIVN);
  116. /* work out clock scalings */
  117. hclk = fclk / ((tmp & S3C2412_CLKDIVN_HDIVN_MASK) + 1);
  118. hclk /= ((tmp & S3C2421_CLKDIVN_ARMDIVN) ? 2 : 1);
  119. pclk = hclk / ((tmp & S3C2412_CLKDIVN_PDIVN) ? 2 : 1);
  120. /* print brieft summary of clocks, etc */
  121. printk("S3C2412: core %ld.%03ld MHz, memory %ld.%03ld MHz, peripheral %ld.%03ld MHz\n",
  122. print_mhz(fclk), print_mhz(hclk), print_mhz(pclk));
  123. /* initialise the clocks here, to allow other things like the
  124. * console to use them
  125. */
  126. s3c24xx_setup_clocks(xtal, fclk, hclk, pclk);
  127. s3c2412_baseclk_add();
  128. }
  129. /* need to register class before we actually register the device, and
  130. * we also need to ensure that it has been initialised before any of the
  131. * drivers even try to use it (even if not on an s3c2412 based system)
  132. * as a driver which may support both 2410 and 2440 may try and use it.
  133. */
  134. #ifdef CONFIG_PM
  135. static struct sleep_save s3c2412_sleep[] = {
  136. SAVE_ITEM(S3C2412_DSC0),
  137. SAVE_ITEM(S3C2412_DSC1),
  138. SAVE_ITEM(S3C2413_GPJDAT),
  139. SAVE_ITEM(S3C2413_GPJCON),
  140. SAVE_ITEM(S3C2413_GPJUP),
  141. /* save the sleep configuration anyway, just in case these
  142. * get damaged during wakeup */
  143. SAVE_ITEM(S3C2412_GPBSLPCON),
  144. SAVE_ITEM(S3C2412_GPCSLPCON),
  145. SAVE_ITEM(S3C2412_GPDSLPCON),
  146. SAVE_ITEM(S3C2412_GPESLPCON),
  147. SAVE_ITEM(S3C2412_GPFSLPCON),
  148. SAVE_ITEM(S3C2412_GPGSLPCON),
  149. SAVE_ITEM(S3C2412_GPHSLPCON),
  150. SAVE_ITEM(S3C2413_GPJSLPCON),
  151. };
  152. static int s3c2412_suspend(struct sys_device *dev, pm_message_t state)
  153. {
  154. s3c2410_pm_do_save(s3c2412_sleep, ARRAY_SIZE(s3c2412_sleep));
  155. return 0;
  156. }
  157. static int s3c2412_resume(struct sys_device *dev)
  158. {
  159. s3c2410_pm_do_restore(s3c2412_sleep, ARRAY_SIZE(s3c2412_sleep));
  160. return 0;
  161. }
  162. #else
  163. #define s3c2412_suspend NULL
  164. #define s3c2412_resume NULL
  165. #endif
  166. struct sysdev_class s3c2412_sysclass = {
  167. set_kset_name("s3c2412-core"),
  168. .suspend = s3c2412_suspend,
  169. .resume = s3c2412_resume
  170. };
  171. static int __init s3c2412_core_init(void)
  172. {
  173. return sysdev_class_register(&s3c2412_sysclass);
  174. }
  175. core_initcall(s3c2412_core_init);
  176. static struct sys_device s3c2412_sysdev = {
  177. .cls = &s3c2412_sysclass,
  178. };
  179. int __init s3c2412_init(void)
  180. {
  181. printk("S3C2412: Initialising architecture\n");
  182. return sysdev_register(&s3c2412_sysdev);
  183. }