s3c2412.c 4.2 KB

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