s3c2412.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. // SPDX-License-Identifier: GPL-2.0
  2. //
  3. // Copyright (c) 2006 Simtec Electronics
  4. // Ben Dooks <ben@simtec.co.uk>
  5. //
  6. // http://armlinux.simtec.co.uk/.
  7. #include <linux/kernel.h>
  8. #include <linux/types.h>
  9. #include <linux/interrupt.h>
  10. #include <linux/list.h>
  11. #include <linux/timer.h>
  12. #include <linux/init.h>
  13. #include <linux/clk.h>
  14. #include <linux/delay.h>
  15. #include <linux/device.h>
  16. #include <linux/syscore_ops.h>
  17. #include <linux/serial_core.h>
  18. #include <linux/serial_s3c.h>
  19. #include <linux/platform_device.h>
  20. #include <linux/io.h>
  21. #include <linux/reboot.h>
  22. #include <asm/mach/arch.h>
  23. #include <asm/mach/map.h>
  24. #include <asm/mach/irq.h>
  25. #include <asm/proc-fns.h>
  26. #include <asm/irq.h>
  27. #include <asm/system_misc.h>
  28. #include <mach/hardware.h>
  29. #include <mach/regs-clock.h>
  30. #include <mach/regs-gpio.h>
  31. #include <plat/cpu.h>
  32. #include <plat/cpu-freq.h>
  33. #include <plat/devs.h>
  34. #include <plat/pm.h>
  35. #include <plat/regs-spi.h>
  36. #include "common.h"
  37. #include "nand-core.h"
  38. #include "regs-dsc.h"
  39. #include "s3c2412-power.h"
  40. #ifndef CONFIG_CPU_S3C2412_ONLY
  41. void __iomem *s3c24xx_va_gpio2 = S3C24XX_VA_GPIO;
  42. static inline void s3c2412_init_gpio2(void)
  43. {
  44. s3c24xx_va_gpio2 = S3C24XX_VA_GPIO + 0x10;
  45. }
  46. #else
  47. #define s3c2412_init_gpio2() do { } while(0)
  48. #endif
  49. /* Initial IO mappings */
  50. static struct map_desc s3c2412_iodesc[] __initdata = {
  51. IODESC_ENT(CLKPWR),
  52. IODESC_ENT(TIMER),
  53. IODESC_ENT(WATCHDOG),
  54. {
  55. .virtual = (unsigned long)S3C2412_VA_SSMC,
  56. .pfn = __phys_to_pfn(S3C2412_PA_SSMC),
  57. .length = SZ_1M,
  58. .type = MT_DEVICE,
  59. },
  60. {
  61. .virtual = (unsigned long)S3C2412_VA_EBI,
  62. .pfn = __phys_to_pfn(S3C2412_PA_EBI),
  63. .length = SZ_1M,
  64. .type = MT_DEVICE,
  65. },
  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_lcd.name = "s3c2412-lcd";
  74. s3c_nand_setname("s3c2412-nand");
  75. /* alter IRQ of SDI controller */
  76. s3c_device_sdi.resource[1].start = IRQ_S3C2412_SDI;
  77. s3c_device_sdi.resource[1].end = IRQ_S3C2412_SDI;
  78. /* spi channel related changes, s3c2412/13 specific */
  79. s3c_device_spi0.name = "s3c2412-spi";
  80. s3c_device_spi0.resource[0].end = S3C24XX_PA_SPI + 0x24;
  81. s3c_device_spi1.name = "s3c2412-spi";
  82. s3c_device_spi1.resource[0].start = S3C24XX_PA_SPI + S3C2412_SPI1;
  83. s3c_device_spi1.resource[0].end = S3C24XX_PA_SPI + S3C2412_SPI1 + 0x24;
  84. }
  85. /* s3c2412_idle
  86. *
  87. * use the standard idle call by ensuring the idle mode
  88. * in power config, then issuing the idle co-processor
  89. * instruction
  90. */
  91. static void s3c2412_idle(void)
  92. {
  93. unsigned long tmp;
  94. /* ensure our idle mode is to go to idle */
  95. tmp = __raw_readl(S3C2412_PWRCFG);
  96. tmp &= ~S3C2412_PWRCFG_STANDBYWFI_MASK;
  97. tmp |= S3C2412_PWRCFG_STANDBYWFI_IDLE;
  98. __raw_writel(tmp, S3C2412_PWRCFG);
  99. cpu_do_idle();
  100. }
  101. /* s3c2412_map_io
  102. *
  103. * register the standard cpu IO areas, and any passed in from the
  104. * machine specific initialisation.
  105. */
  106. void __init s3c2412_map_io(void)
  107. {
  108. /* move base of IO */
  109. s3c2412_init_gpio2();
  110. /* set our idle function */
  111. arm_pm_idle = s3c2412_idle;
  112. /* register our io-tables */
  113. iotable_init(s3c2412_iodesc, ARRAY_SIZE(s3c2412_iodesc));
  114. }
  115. /* need to register the subsystem before we actually register the device, and
  116. * we also need to ensure that it has been initialised before any of the
  117. * drivers even try to use it (even if not on an s3c2412 based system)
  118. * as a driver which may support both 2410 and 2440 may try and use it.
  119. */
  120. struct bus_type s3c2412_subsys = {
  121. .name = "s3c2412-core",
  122. .dev_name = "s3c2412-core",
  123. };
  124. static int __init s3c2412_core_init(void)
  125. {
  126. return subsys_system_register(&s3c2412_subsys, NULL);
  127. }
  128. core_initcall(s3c2412_core_init);
  129. static struct device s3c2412_dev = {
  130. .bus = &s3c2412_subsys,
  131. };
  132. int __init s3c2412_init(void)
  133. {
  134. printk("S3C2412: Initialising architecture\n");
  135. #ifdef CONFIG_PM_SLEEP
  136. register_syscore_ops(&s3c2412_pm_syscore_ops);
  137. register_syscore_ops(&s3c24xx_irq_syscore_ops);
  138. #endif
  139. return device_register(&s3c2412_dev);
  140. }