cpu.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. /* linux/arch/arm/mach-s5pv310/cpu.c
  2. *
  3. * Copyright (c) 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/sched.h>
  11. #include <linux/sysdev.h>
  12. #include <asm/mach/map.h>
  13. #include <asm/mach/irq.h>
  14. #include <asm/proc-fns.h>
  15. #include <asm/hardware/cache-l2x0.h>
  16. #include <plat/cpu.h>
  17. #include <plat/clock.h>
  18. #include <plat/s5pv310.h>
  19. #include <plat/sdhci.h>
  20. #include <mach/regs-irq.h>
  21. void __iomem *gic_cpu_base_addr;
  22. extern int combiner_init(unsigned int combiner_nr, void __iomem *base,
  23. unsigned int irq_start);
  24. extern void combiner_cascade_irq(unsigned int combiner_nr, unsigned int irq);
  25. /* Initial IO mappings */
  26. static struct map_desc s5pv310_iodesc[] __initdata = {
  27. {
  28. .virtual = (unsigned long)S5P_VA_SYSRAM,
  29. .pfn = __phys_to_pfn(S5PV310_PA_SYSRAM),
  30. .length = SZ_4K,
  31. .type = MT_DEVICE,
  32. }, {
  33. .virtual = (unsigned long)S5P_VA_CMU,
  34. .pfn = __phys_to_pfn(S5PV310_PA_CMU),
  35. .length = SZ_128K,
  36. .type = MT_DEVICE,
  37. }, {
  38. .virtual = (unsigned long)S5P_VA_COMBINER_BASE,
  39. .pfn = __phys_to_pfn(S5PV310_PA_COMBINER),
  40. .length = SZ_4K,
  41. .type = MT_DEVICE,
  42. }, {
  43. .virtual = (unsigned long)S5P_VA_COREPERI_BASE,
  44. .pfn = __phys_to_pfn(S5PV310_PA_COREPERI),
  45. .length = SZ_8K,
  46. .type = MT_DEVICE,
  47. }, {
  48. .virtual = (unsigned long)S5P_VA_L2CC,
  49. .pfn = __phys_to_pfn(S5PV310_PA_L2CC),
  50. .length = SZ_4K,
  51. .type = MT_DEVICE,
  52. }, {
  53. .virtual = (unsigned long)S5P_VA_GPIO1,
  54. .pfn = __phys_to_pfn(S5PV310_PA_GPIO1),
  55. .length = SZ_4K,
  56. .type = MT_DEVICE,
  57. }, {
  58. .virtual = (unsigned long)S5P_VA_GPIO2,
  59. .pfn = __phys_to_pfn(S5PV310_PA_GPIO2),
  60. .length = SZ_4K,
  61. .type = MT_DEVICE,
  62. }, {
  63. .virtual = (unsigned long)S5P_VA_GPIO3,
  64. .pfn = __phys_to_pfn(S5PV310_PA_GPIO3),
  65. .length = SZ_256,
  66. .type = MT_DEVICE,
  67. }, {
  68. .virtual = (unsigned long)S3C_VA_UART,
  69. .pfn = __phys_to_pfn(S3C_PA_UART),
  70. .length = SZ_512K,
  71. .type = MT_DEVICE,
  72. }, {
  73. .virtual = (unsigned long)S5P_VA_SROMC,
  74. .pfn = __phys_to_pfn(S5PV310_PA_SROMC),
  75. .length = SZ_4K,
  76. .type = MT_DEVICE,
  77. },
  78. };
  79. static void s5pv310_idle(void)
  80. {
  81. if (!need_resched())
  82. cpu_do_idle();
  83. local_irq_enable();
  84. }
  85. /* s5pv310_map_io
  86. *
  87. * register the standard cpu IO areas
  88. */
  89. void __init s5pv310_map_io(void)
  90. {
  91. iotable_init(s5pv310_iodesc, ARRAY_SIZE(s5pv310_iodesc));
  92. /* initialize device information early */
  93. s5pv310_default_sdhci0();
  94. s5pv310_default_sdhci1();
  95. s5pv310_default_sdhci2();
  96. s5pv310_default_sdhci3();
  97. }
  98. void __init s5pv310_init_clocks(int xtal)
  99. {
  100. printk(KERN_DEBUG "%s: initializing clocks\n", __func__);
  101. s3c24xx_register_baseclocks(xtal);
  102. s5p_register_clocks(xtal);
  103. s5pv310_register_clocks();
  104. s5pv310_setup_clocks();
  105. }
  106. void __init s5pv310_init_irq(void)
  107. {
  108. int irq;
  109. gic_cpu_base_addr = S5P_VA_GIC_CPU;
  110. gic_dist_init(0, S5P_VA_GIC_DIST, IRQ_LOCALTIMER);
  111. gic_cpu_init(0, S5P_VA_GIC_CPU);
  112. for (irq = 0; irq < MAX_COMBINER_NR; irq++) {
  113. combiner_init(irq, (void __iomem *)S5P_VA_COMBINER(irq),
  114. COMBINER_IRQ(irq, 0));
  115. combiner_cascade_irq(irq, IRQ_SPI(irq));
  116. }
  117. /* The parameters of s5p_init_irq() are for VIC init.
  118. * Theses parameters should be NULL and 0 because S5PV310
  119. * uses GIC instead of VIC.
  120. */
  121. s5p_init_irq(NULL, 0);
  122. }
  123. struct sysdev_class s5pv310_sysclass = {
  124. .name = "s5pv310-core",
  125. };
  126. static struct sys_device s5pv310_sysdev = {
  127. .cls = &s5pv310_sysclass,
  128. };
  129. static int __init s5pv310_core_init(void)
  130. {
  131. return sysdev_class_register(&s5pv310_sysclass);
  132. }
  133. core_initcall(s5pv310_core_init);
  134. #ifdef CONFIG_CACHE_L2X0
  135. static int __init s5pv310_l2x0_cache_init(void)
  136. {
  137. /* TAG, Data Latency Control: 2cycle */
  138. __raw_writel(0x110, S5P_VA_L2CC + L2X0_TAG_LATENCY_CTRL);
  139. __raw_writel(0x110, S5P_VA_L2CC + L2X0_DATA_LATENCY_CTRL);
  140. /* L2X0 Prefetch Control */
  141. __raw_writel(0x30000007, S5P_VA_L2CC + L2X0_PREFETCH_CTRL);
  142. /* L2X0 Power Control */
  143. __raw_writel(L2X0_DYNAMIC_CLK_GATING_EN | L2X0_STNDBY_MODE_EN,
  144. S5P_VA_L2CC + L2X0_POWER_CTRL);
  145. l2x0_init(S5P_VA_L2CC, 0x7C070001, 0xC200ffff);
  146. return 0;
  147. }
  148. early_initcall(s5pv310_l2x0_cache_init);
  149. #endif
  150. int __init s5pv310_init(void)
  151. {
  152. printk(KERN_INFO "S5PV310: Initializing architecture\n");
  153. /* set idle function */
  154. pm_idle = s5pv310_idle;
  155. return sysdev_register(&s5pv310_sysdev);
  156. }