spear6xx.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. /*
  2. * arch/arm/mach-spear6xx/spear6xx.c
  3. *
  4. * SPEAr6XX machines common source file
  5. *
  6. * Copyright (C) 2009 ST Microelectronics
  7. * Rajeev Kumar<rajeev-dlh.kumar@st.com>
  8. *
  9. * This file is licensed under the terms of the GNU General Public
  10. * License version 2. This program is licensed "as is" without any
  11. * warranty of any kind, whether express or implied.
  12. */
  13. #include <linux/types.h>
  14. #include <linux/amba/pl061.h>
  15. #include <linux/ptrace.h>
  16. #include <linux/io.h>
  17. #include <asm/hardware/vic.h>
  18. #include <asm/irq.h>
  19. #include <asm/mach/arch.h>
  20. #include <mach/generic.h>
  21. #include <mach/hardware.h>
  22. #include <mach/irqs.h>
  23. /* Add spear6xx machines common devices here */
  24. /* uart device registration */
  25. struct amba_device uart_device[] = {
  26. {
  27. .dev = {
  28. .init_name = "uart0",
  29. },
  30. .res = {
  31. .start = SPEAR6XX_ICM1_UART0_BASE,
  32. .end = SPEAR6XX_ICM1_UART0_BASE + SZ_4K - 1,
  33. .flags = IORESOURCE_MEM,
  34. },
  35. .irq = {IRQ_UART_0, NO_IRQ},
  36. }, {
  37. .dev = {
  38. .init_name = "uart1",
  39. },
  40. .res = {
  41. .start = SPEAR6XX_ICM1_UART1_BASE,
  42. .end = SPEAR6XX_ICM1_UART1_BASE + SZ_4K - 1,
  43. .flags = IORESOURCE_MEM,
  44. },
  45. .irq = {IRQ_UART_1, NO_IRQ},
  46. }
  47. };
  48. /* gpio device registration */
  49. static struct pl061_platform_data gpio_plat_data[] = {
  50. {
  51. .gpio_base = 0,
  52. .irq_base = SPEAR_GPIO0_INT_BASE,
  53. }, {
  54. .gpio_base = 8,
  55. .irq_base = SPEAR_GPIO1_INT_BASE,
  56. }, {
  57. .gpio_base = 16,
  58. .irq_base = SPEAR_GPIO2_INT_BASE,
  59. },
  60. };
  61. struct amba_device gpio_device[] = {
  62. {
  63. .dev = {
  64. .init_name = "gpio0",
  65. .platform_data = &gpio_plat_data[0],
  66. },
  67. .res = {
  68. .start = SPEAR6XX_CPU_GPIO_BASE,
  69. .end = SPEAR6XX_CPU_GPIO_BASE + SZ_4K - 1,
  70. .flags = IORESOURCE_MEM,
  71. },
  72. .irq = {IRQ_LOCAL_GPIO, NO_IRQ},
  73. }, {
  74. .dev = {
  75. .init_name = "gpio1",
  76. .platform_data = &gpio_plat_data[1],
  77. },
  78. .res = {
  79. .start = SPEAR6XX_ICM3_GPIO_BASE,
  80. .end = SPEAR6XX_ICM3_GPIO_BASE + SZ_4K - 1,
  81. .flags = IORESOURCE_MEM,
  82. },
  83. .irq = {IRQ_BASIC_GPIO, NO_IRQ},
  84. }, {
  85. .dev = {
  86. .init_name = "gpio2",
  87. .platform_data = &gpio_plat_data[2],
  88. },
  89. .res = {
  90. .start = SPEAR6XX_ICM2_GPIO_BASE,
  91. .end = SPEAR6XX_ICM2_GPIO_BASE + SZ_4K - 1,
  92. .flags = IORESOURCE_MEM,
  93. },
  94. .irq = {IRQ_APPL_GPIO, NO_IRQ},
  95. }
  96. };
  97. /* This will add devices, and do machine specific tasks */
  98. void __init spear6xx_init(void)
  99. {
  100. /* nothing to do for now */
  101. }
  102. /* This will initialize vic */
  103. void __init spear6xx_init_irq(void)
  104. {
  105. vic_init((void __iomem *)VA_SPEAR6XX_CPU_VIC_PRI_BASE, 0, ~0, 0);
  106. vic_init((void __iomem *)VA_SPEAR6XX_CPU_VIC_SEC_BASE, 32, ~0, 0);
  107. }
  108. /* Following will create static virtual/physical mappings */
  109. static struct map_desc spear6xx_io_desc[] __initdata = {
  110. {
  111. .virtual = VA_SPEAR6XX_ICM1_UART0_BASE,
  112. .pfn = __phys_to_pfn(SPEAR6XX_ICM1_UART0_BASE),
  113. .length = SZ_4K,
  114. .type = MT_DEVICE
  115. }, {
  116. .virtual = VA_SPEAR6XX_CPU_VIC_PRI_BASE,
  117. .pfn = __phys_to_pfn(SPEAR6XX_CPU_VIC_PRI_BASE),
  118. .length = SZ_4K,
  119. .type = MT_DEVICE
  120. }, {
  121. .virtual = VA_SPEAR6XX_CPU_VIC_SEC_BASE,
  122. .pfn = __phys_to_pfn(SPEAR6XX_CPU_VIC_SEC_BASE),
  123. .length = SZ_4K,
  124. .type = MT_DEVICE
  125. }, {
  126. .virtual = VA_SPEAR6XX_ICM3_SYS_CTRL_BASE,
  127. .pfn = __phys_to_pfn(SPEAR6XX_ICM3_SYS_CTRL_BASE),
  128. .length = SZ_4K,
  129. .type = MT_DEVICE
  130. }, {
  131. .virtual = VA_SPEAR6XX_ICM3_MISC_REG_BASE,
  132. .pfn = __phys_to_pfn(SPEAR6XX_ICM3_MISC_REG_BASE),
  133. .length = SZ_4K,
  134. .type = MT_DEVICE
  135. },
  136. };
  137. /* This will create static memory mapping for selected devices */
  138. void __init spear6xx_map_io(void)
  139. {
  140. iotable_init(spear6xx_io_desc, ARRAY_SIZE(spear6xx_io_desc));
  141. /* This will initialize clock framework */
  142. clk_init();
  143. }
  144. static void __init spear6xx_timer_init(void)
  145. {
  146. char pclk_name[] = "pll3_48m_clk";
  147. struct clk *gpt_clk, *pclk;
  148. /* get the system timer clock */
  149. gpt_clk = clk_get_sys("gpt0", NULL);
  150. if (IS_ERR(gpt_clk)) {
  151. pr_err("%s:couldn't get clk for gpt\n", __func__);
  152. BUG();
  153. }
  154. /* get the suitable parent clock for timer*/
  155. pclk = clk_get(NULL, pclk_name);
  156. if (IS_ERR(pclk)) {
  157. pr_err("%s:couldn't get %s as parent for gpt\n",
  158. __func__, pclk_name);
  159. BUG();
  160. }
  161. clk_set_parent(gpt_clk, pclk);
  162. clk_put(gpt_clk);
  163. clk_put(pclk);
  164. spear_setup_timer();
  165. }
  166. struct sys_timer spear6xx_timer = {
  167. .init = spear6xx_timer_init,
  168. };