cpu.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. /* linux/arch/arm/mach-s5p64x0/cpu.c
  2. *
  3. * Copyright (c) 2009-2010 Samsung Electronics Co., Ltd.
  4. * http://www.samsung.com
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #include <linux/kernel.h>
  11. #include <linux/types.h>
  12. #include <linux/interrupt.h>
  13. #include <linux/list.h>
  14. #include <linux/timer.h>
  15. #include <linux/init.h>
  16. #include <linux/clk.h>
  17. #include <linux/io.h>
  18. #include <linux/sysdev.h>
  19. #include <linux/serial_core.h>
  20. #include <linux/platform_device.h>
  21. #include <linux/sched.h>
  22. #include <linux/dma-mapping.h>
  23. #include <asm/mach/arch.h>
  24. #include <asm/mach/map.h>
  25. #include <asm/mach/irq.h>
  26. #include <asm/proc-fns.h>
  27. #include <asm/irq.h>
  28. #include <mach/hardware.h>
  29. #include <mach/map.h>
  30. #include <mach/regs-clock.h>
  31. #include <plat/regs-serial.h>
  32. #include <plat/cpu.h>
  33. #include <plat/devs.h>
  34. #include <plat/clock.h>
  35. #include <plat/s5p6440.h>
  36. #include <plat/s5p6450.h>
  37. #include <plat/adc-core.h>
  38. #include <plat/fb-core.h>
  39. /* Initial IO mappings */
  40. static struct map_desc s5p64x0_iodesc[] __initdata = {
  41. {
  42. .virtual = (unsigned long)S5P_VA_GPIO,
  43. .pfn = __phys_to_pfn(S5P64X0_PA_GPIO),
  44. .length = SZ_4K,
  45. .type = MT_DEVICE,
  46. }, {
  47. .virtual = (unsigned long)VA_VIC0,
  48. .pfn = __phys_to_pfn(S5P64X0_PA_VIC0),
  49. .length = SZ_16K,
  50. .type = MT_DEVICE,
  51. }, {
  52. .virtual = (unsigned long)VA_VIC1,
  53. .pfn = __phys_to_pfn(S5P64X0_PA_VIC1),
  54. .length = SZ_16K,
  55. .type = MT_DEVICE,
  56. },
  57. };
  58. static struct map_desc s5p6440_iodesc[] __initdata = {
  59. {
  60. .virtual = (unsigned long)S3C_VA_UART,
  61. .pfn = __phys_to_pfn(S5P6440_PA_UART(0)),
  62. .length = SZ_4K,
  63. .type = MT_DEVICE,
  64. },
  65. };
  66. static struct map_desc s5p6450_iodesc[] __initdata = {
  67. {
  68. .virtual = (unsigned long)S3C_VA_UART,
  69. .pfn = __phys_to_pfn(S5P6450_PA_UART(0)),
  70. .length = SZ_512K,
  71. .type = MT_DEVICE,
  72. }, {
  73. .virtual = (unsigned long)S3C_VA_UART + SZ_512K,
  74. .pfn = __phys_to_pfn(S5P6450_PA_UART(5)),
  75. .length = SZ_4K,
  76. .type = MT_DEVICE,
  77. },
  78. };
  79. static void s5p64x0_idle(void)
  80. {
  81. unsigned long val;
  82. if (!need_resched()) {
  83. val = __raw_readl(S5P64X0_PWR_CFG);
  84. val &= ~(0x3 << 5);
  85. val |= (0x1 << 5);
  86. __raw_writel(val, S5P64X0_PWR_CFG);
  87. cpu_do_idle();
  88. }
  89. local_irq_enable();
  90. }
  91. /*
  92. * s5p64x0_map_io
  93. *
  94. * register the standard CPU IO areas
  95. */
  96. void __init s5p6440_map_io(void)
  97. {
  98. /* initialize any device information early */
  99. s3c_adc_setname("s3c64xx-adc");
  100. s3c_fb_setname("s5p64x0-fb");
  101. iotable_init(s5p64x0_iodesc, ARRAY_SIZE(s5p64x0_iodesc));
  102. iotable_init(s5p6440_iodesc, ARRAY_SIZE(s5p6440_iodesc));
  103. init_consistent_dma_size(SZ_8M);
  104. }
  105. void __init s5p6450_map_io(void)
  106. {
  107. /* initialize any device information early */
  108. s3c_adc_setname("s3c64xx-adc");
  109. s3c_fb_setname("s5p64x0-fb");
  110. iotable_init(s5p64x0_iodesc, ARRAY_SIZE(s5p64x0_iodesc));
  111. iotable_init(s5p6450_iodesc, ARRAY_SIZE(s5p6450_iodesc));
  112. init_consistent_dma_size(SZ_8M);
  113. }
  114. /*
  115. * s5p64x0_init_clocks
  116. *
  117. * register and setup the CPU clocks
  118. */
  119. void __init s5p6440_init_clocks(int xtal)
  120. {
  121. printk(KERN_DEBUG "%s: initializing clocks\n", __func__);
  122. s3c24xx_register_baseclocks(xtal);
  123. s5p_register_clocks(xtal);
  124. s5p6440_register_clocks();
  125. s5p6440_setup_clocks();
  126. }
  127. void __init s5p6450_init_clocks(int xtal)
  128. {
  129. printk(KERN_DEBUG "%s: initializing clocks\n", __func__);
  130. s3c24xx_register_baseclocks(xtal);
  131. s5p_register_clocks(xtal);
  132. s5p6450_register_clocks();
  133. s5p6450_setup_clocks();
  134. }
  135. /*
  136. * s5p64x0_init_irq
  137. *
  138. * register the CPU interrupts
  139. */
  140. void __init s5p6440_init_irq(void)
  141. {
  142. /* S5P6440 supports 2 VIC */
  143. u32 vic[2];
  144. /*
  145. * VIC0 is missing IRQ_VIC0[3, 4, 8, 10, (12-22)]
  146. * VIC1 is missing IRQ VIC1[1, 3, 4, 10, 11, 12, 14, 15, 22]
  147. */
  148. vic[0] = 0xff800ae7;
  149. vic[1] = 0xffbf23e5;
  150. s5p_init_irq(vic, ARRAY_SIZE(vic));
  151. }
  152. void __init s5p6450_init_irq(void)
  153. {
  154. /* S5P6450 supports only 2 VIC */
  155. u32 vic[2];
  156. /*
  157. * VIC0 is missing IRQ_VIC0[(13-15), (21-22)]
  158. * VIC1 is missing IRQ VIC1[12, 14, 23]
  159. */
  160. vic[0] = 0xff9f1fff;
  161. vic[1] = 0xff7fafff;
  162. s5p_init_irq(vic, ARRAY_SIZE(vic));
  163. }
  164. struct sysdev_class s5p64x0_sysclass = {
  165. .name = "s5p64x0-core",
  166. };
  167. static struct sys_device s5p64x0_sysdev = {
  168. .cls = &s5p64x0_sysclass,
  169. };
  170. static int __init s5p64x0_core_init(void)
  171. {
  172. return sysdev_class_register(&s5p64x0_sysclass);
  173. }
  174. core_initcall(s5p64x0_core_init);
  175. int __init s5p64x0_init(void)
  176. {
  177. printk(KERN_INFO "S5P64X0(S5P6440/S5P6450): Initializing architecture\n");
  178. /* set idle function */
  179. pm_idle = s5p64x0_idle;
  180. return sysdev_register(&s5p64x0_sysdev);
  181. }