s3c244x.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. /* linux/arch/arm/plat-s3c24xx/s3c244x.c
  2. *
  3. * Copyright (c) 2004-2006 Simtec Electronics
  4. * Ben Dooks <ben@simtec.co.uk>
  5. *
  6. * Samsung S3C2440 and S3C2442 Mobile CPU support (not S3C2443)
  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/serial_core.h>
  19. #include <linux/platform_device.h>
  20. #include <linux/sysdev.h>
  21. #include <linux/clk.h>
  22. #include <asm/mach/arch.h>
  23. #include <asm/mach/map.h>
  24. #include <asm/mach/irq.h>
  25. #include <asm/hardware.h>
  26. #include <asm/io.h>
  27. #include <asm/irq.h>
  28. #include <asm/arch/regs-clock.h>
  29. #include <asm/plat-s3c/regs-serial.h>
  30. #include <asm/arch/regs-gpio.h>
  31. #include <asm/arch/regs-gpioj.h>
  32. #include <asm/arch/regs-dsc.h>
  33. #include <asm/plat-s3c24xx/s3c2410.h>
  34. #include <asm/plat-s3c24xx/s3c2440.h>
  35. #include "s3c244x.h"
  36. #include <asm/plat-s3c24xx/clock.h>
  37. #include <asm/plat-s3c24xx/devs.h>
  38. #include <asm/plat-s3c24xx/cpu.h>
  39. #include <asm/plat-s3c24xx/pm.h>
  40. static struct map_desc s3c244x_iodesc[] __initdata = {
  41. IODESC_ENT(CLKPWR),
  42. IODESC_ENT(TIMER),
  43. IODESC_ENT(WATCHDOG),
  44. };
  45. /* uart initialisation */
  46. void __init s3c244x_init_uarts(struct s3c2410_uartcfg *cfg, int no)
  47. {
  48. s3c24xx_init_uartdevs("s3c2440-uart", s3c2410_uart_resources, cfg, no);
  49. }
  50. void __init s3c244x_map_io(struct map_desc *mach_desc, int size)
  51. {
  52. /* register our io-tables */
  53. iotable_init(s3c244x_iodesc, ARRAY_SIZE(s3c244x_iodesc));
  54. iotable_init(mach_desc, size);
  55. /* rename any peripherals used differing from the s3c2410 */
  56. s3c_device_i2c.name = "s3c2440-i2c";
  57. s3c_device_nand.name = "s3c2440-nand";
  58. s3c_device_usbgadget.name = "s3c2440-usbgadget";
  59. }
  60. void __init s3c244x_init_clocks(int xtal)
  61. {
  62. unsigned long clkdiv;
  63. unsigned long camdiv;
  64. unsigned long hclk, fclk, pclk;
  65. int hdiv = 1;
  66. /* now we've got our machine bits initialised, work out what
  67. * clocks we've got */
  68. fclk = s3c2410_get_pll(__raw_readl(S3C2410_MPLLCON), xtal) * 2;
  69. clkdiv = __raw_readl(S3C2410_CLKDIVN);
  70. camdiv = __raw_readl(S3C2440_CAMDIVN);
  71. /* work out clock scalings */
  72. switch (clkdiv & S3C2440_CLKDIVN_HDIVN_MASK) {
  73. case S3C2440_CLKDIVN_HDIVN_1:
  74. hdiv = 1;
  75. break;
  76. case S3C2440_CLKDIVN_HDIVN_2:
  77. hdiv = 2;
  78. break;
  79. case S3C2440_CLKDIVN_HDIVN_4_8:
  80. hdiv = (camdiv & S3C2440_CAMDIVN_HCLK4_HALF) ? 8 : 4;
  81. break;
  82. case S3C2440_CLKDIVN_HDIVN_3_6:
  83. hdiv = (camdiv & S3C2440_CAMDIVN_HCLK3_HALF) ? 6 : 3;
  84. break;
  85. }
  86. hclk = fclk / hdiv;
  87. pclk = hclk / ((clkdiv & S3C2440_CLKDIVN_PDIVN)? 2:1);
  88. /* print brief summary of clocks, etc */
  89. printk("S3C244X: core %ld.%03ld MHz, memory %ld.%03ld MHz, peripheral %ld.%03ld MHz\n",
  90. print_mhz(fclk), print_mhz(hclk), print_mhz(pclk));
  91. /* initialise the clocks here, to allow other things like the
  92. * console to use them, and to add new ones after the initialisation
  93. */
  94. s3c24xx_setup_clocks(xtal, fclk, hclk, pclk);
  95. s3c2410_baseclk_add();
  96. }
  97. #ifdef CONFIG_PM
  98. static struct sleep_save s3c244x_sleep[] = {
  99. SAVE_ITEM(S3C2440_DSC0),
  100. SAVE_ITEM(S3C2440_DSC1),
  101. SAVE_ITEM(S3C2440_GPJDAT),
  102. SAVE_ITEM(S3C2440_GPJCON),
  103. SAVE_ITEM(S3C2440_GPJUP)
  104. };
  105. static int s3c244x_suspend(struct sys_device *dev, pm_message_t state)
  106. {
  107. s3c2410_pm_do_save(s3c244x_sleep, ARRAY_SIZE(s3c244x_sleep));
  108. return 0;
  109. }
  110. static int s3c244x_resume(struct sys_device *dev)
  111. {
  112. s3c2410_pm_do_restore(s3c244x_sleep, ARRAY_SIZE(s3c244x_sleep));
  113. return 0;
  114. }
  115. #else
  116. #define s3c244x_suspend NULL
  117. #define s3c244x_resume NULL
  118. #endif
  119. /* Since the S3C2442 and S3C2440 share items, put both sysclasses here */
  120. struct sysdev_class s3c2440_sysclass = {
  121. .name = "s3c2440-core",
  122. .suspend = s3c244x_suspend,
  123. .resume = s3c244x_resume
  124. };
  125. struct sysdev_class s3c2442_sysclass = {
  126. .name = "s3c2442-core",
  127. .suspend = s3c244x_suspend,
  128. .resume = s3c244x_resume
  129. };
  130. /* need to register class before we actually register the device, and
  131. * we also need to ensure that it has been initialised before any of the
  132. * drivers even try to use it (even if not on an s3c2440 based system)
  133. * as a driver which may support both 2410 and 2440 may try and use it.
  134. */
  135. static int __init s3c2440_core_init(void)
  136. {
  137. return sysdev_class_register(&s3c2440_sysclass);
  138. }
  139. core_initcall(s3c2440_core_init);
  140. static int __init s3c2442_core_init(void)
  141. {
  142. return sysdev_class_register(&s3c2442_sysclass);
  143. }
  144. core_initcall(s3c2442_core_init);