s3c244x.c 4.4 KB

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