at91sam9n12.c 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. /*
  2. * SoC specific setup code for the AT91SAM9N12
  3. *
  4. * Copyright (C) 2012 Atmel Corporation.
  5. *
  6. * Licensed under GPLv2 or later.
  7. */
  8. #include <linux/module.h>
  9. #include <linux/dma-mapping.h>
  10. #include <linux/clk/at91_pmc.h>
  11. #include <asm/irq.h>
  12. #include <asm/mach/arch.h>
  13. #include <asm/mach/map.h>
  14. #include <mach/at91sam9n12.h>
  15. #include <mach/cpu.h>
  16. #include "board.h"
  17. #include "soc.h"
  18. #include "generic.h"
  19. #include "sam9_smc.h"
  20. #if defined(CONFIG_OLD_CLK_AT91)
  21. #include "clock.h"
  22. /* --------------------------------------------------------------------
  23. * Clocks
  24. * -------------------------------------------------------------------- */
  25. /*
  26. * The peripheral clocks.
  27. */
  28. static struct clk pioAB_clk = {
  29. .name = "pioAB_clk",
  30. .pmc_mask = 1 << AT91SAM9N12_ID_PIOAB,
  31. .type = CLK_TYPE_PERIPHERAL,
  32. };
  33. static struct clk pioCD_clk = {
  34. .name = "pioCD_clk",
  35. .pmc_mask = 1 << AT91SAM9N12_ID_PIOCD,
  36. .type = CLK_TYPE_PERIPHERAL,
  37. };
  38. static struct clk usart0_clk = {
  39. .name = "usart0_clk",
  40. .pmc_mask = 1 << AT91SAM9N12_ID_USART0,
  41. .type = CLK_TYPE_PERIPHERAL,
  42. };
  43. static struct clk usart1_clk = {
  44. .name = "usart1_clk",
  45. .pmc_mask = 1 << AT91SAM9N12_ID_USART1,
  46. .type = CLK_TYPE_PERIPHERAL,
  47. };
  48. static struct clk usart2_clk = {
  49. .name = "usart2_clk",
  50. .pmc_mask = 1 << AT91SAM9N12_ID_USART2,
  51. .type = CLK_TYPE_PERIPHERAL,
  52. };
  53. static struct clk usart3_clk = {
  54. .name = "usart3_clk",
  55. .pmc_mask = 1 << AT91SAM9N12_ID_USART3,
  56. .type = CLK_TYPE_PERIPHERAL,
  57. };
  58. static struct clk twi0_clk = {
  59. .name = "twi0_clk",
  60. .pmc_mask = 1 << AT91SAM9N12_ID_TWI0,
  61. .type = CLK_TYPE_PERIPHERAL,
  62. };
  63. static struct clk twi1_clk = {
  64. .name = "twi1_clk",
  65. .pmc_mask = 1 << AT91SAM9N12_ID_TWI1,
  66. .type = CLK_TYPE_PERIPHERAL,
  67. };
  68. static struct clk mmc_clk = {
  69. .name = "mci_clk",
  70. .pmc_mask = 1 << AT91SAM9N12_ID_MCI,
  71. .type = CLK_TYPE_PERIPHERAL,
  72. };
  73. static struct clk spi0_clk = {
  74. .name = "spi0_clk",
  75. .pmc_mask = 1 << AT91SAM9N12_ID_SPI0,
  76. .type = CLK_TYPE_PERIPHERAL,
  77. };
  78. static struct clk spi1_clk = {
  79. .name = "spi1_clk",
  80. .pmc_mask = 1 << AT91SAM9N12_ID_SPI1,
  81. .type = CLK_TYPE_PERIPHERAL,
  82. };
  83. static struct clk uart0_clk = {
  84. .name = "uart0_clk",
  85. .pmc_mask = 1 << AT91SAM9N12_ID_UART0,
  86. .type = CLK_TYPE_PERIPHERAL,
  87. };
  88. static struct clk uart1_clk = {
  89. .name = "uart1_clk",
  90. .pmc_mask = 1 << AT91SAM9N12_ID_UART1,
  91. .type = CLK_TYPE_PERIPHERAL,
  92. };
  93. static struct clk tcb_clk = {
  94. .name = "tcb_clk",
  95. .pmc_mask = 1 << AT91SAM9N12_ID_TCB,
  96. .type = CLK_TYPE_PERIPHERAL,
  97. };
  98. static struct clk pwm_clk = {
  99. .name = "pwm_clk",
  100. .pmc_mask = 1 << AT91SAM9N12_ID_PWM,
  101. .type = CLK_TYPE_PERIPHERAL,
  102. };
  103. static struct clk adc_clk = {
  104. .name = "adc_clk",
  105. .pmc_mask = 1 << AT91SAM9N12_ID_ADC,
  106. .type = CLK_TYPE_PERIPHERAL,
  107. };
  108. static struct clk dma_clk = {
  109. .name = "dma_clk",
  110. .pmc_mask = 1 << AT91SAM9N12_ID_DMA,
  111. .type = CLK_TYPE_PERIPHERAL,
  112. };
  113. static struct clk uhp_clk = {
  114. .name = "uhp",
  115. .pmc_mask = 1 << AT91SAM9N12_ID_UHP,
  116. .type = CLK_TYPE_PERIPHERAL,
  117. };
  118. static struct clk udp_clk = {
  119. .name = "udp_clk",
  120. .pmc_mask = 1 << AT91SAM9N12_ID_UDP,
  121. .type = CLK_TYPE_PERIPHERAL,
  122. };
  123. static struct clk lcdc_clk = {
  124. .name = "lcdc_clk",
  125. .pmc_mask = 1 << AT91SAM9N12_ID_LCDC,
  126. .type = CLK_TYPE_PERIPHERAL,
  127. };
  128. static struct clk ssc_clk = {
  129. .name = "ssc_clk",
  130. .pmc_mask = 1 << AT91SAM9N12_ID_SSC,
  131. .type = CLK_TYPE_PERIPHERAL,
  132. };
  133. static struct clk *periph_clocks[] __initdata = {
  134. &pioAB_clk,
  135. &pioCD_clk,
  136. &usart0_clk,
  137. &usart1_clk,
  138. &usart2_clk,
  139. &usart3_clk,
  140. &twi0_clk,
  141. &twi1_clk,
  142. &mmc_clk,
  143. &spi0_clk,
  144. &spi1_clk,
  145. &lcdc_clk,
  146. &uart0_clk,
  147. &uart1_clk,
  148. &tcb_clk,
  149. &pwm_clk,
  150. &adc_clk,
  151. &dma_clk,
  152. &uhp_clk,
  153. &udp_clk,
  154. &ssc_clk,
  155. };
  156. static struct clk_lookup periph_clocks_lookups[] = {
  157. /* lookup table for DT entries */
  158. CLKDEV_CON_DEV_ID("usart", "fffff200.serial", &mck),
  159. CLKDEV_CON_DEV_ID("usart", "f801c000.serial", &usart0_clk),
  160. CLKDEV_CON_DEV_ID("usart", "f8020000.serial", &usart1_clk),
  161. CLKDEV_CON_DEV_ID("usart", "f8024000.serial", &usart2_clk),
  162. CLKDEV_CON_DEV_ID("usart", "f8028000.serial", &usart3_clk),
  163. CLKDEV_CON_DEV_ID("t0_clk", "f8008000.timer", &tcb_clk),
  164. CLKDEV_CON_DEV_ID("t0_clk", "f800c000.timer", &tcb_clk),
  165. CLKDEV_CON_DEV_ID("mci_clk", "f0008000.mmc", &mmc_clk),
  166. CLKDEV_CON_DEV_ID(NULL, "f0010000.ssc", &ssc_clk),
  167. CLKDEV_CON_DEV_ID("dma_clk", "ffffec00.dma-controller", &dma_clk),
  168. CLKDEV_CON_DEV_ID(NULL, "f8010000.i2c", &twi0_clk),
  169. CLKDEV_CON_DEV_ID(NULL, "f8014000.i2c", &twi1_clk),
  170. CLKDEV_CON_DEV_ID("spi_clk", "f0000000.spi", &spi0_clk),
  171. CLKDEV_CON_DEV_ID("spi_clk", "f0004000.spi", &spi1_clk),
  172. CLKDEV_CON_DEV_ID(NULL, "fffff400.gpio", &pioAB_clk),
  173. CLKDEV_CON_DEV_ID(NULL, "fffff600.gpio", &pioAB_clk),
  174. CLKDEV_CON_DEV_ID(NULL, "fffff800.gpio", &pioCD_clk),
  175. CLKDEV_CON_DEV_ID(NULL, "fffffa00.gpio", &pioCD_clk),
  176. /* additional fake clock for macb_hclk */
  177. CLKDEV_CON_DEV_ID("hclk", "500000.ohci", &uhp_clk),
  178. CLKDEV_CON_DEV_ID("ohci_clk", "500000.ohci", &uhp_clk),
  179. CLKDEV_CON_DEV_ID(NULL, "f8034000.pwm", &pwm_clk),
  180. };
  181. /*
  182. * The two programmable clocks.
  183. * You must configure pin multiplexing to bring these signals out.
  184. */
  185. static struct clk pck0 = {
  186. .name = "pck0",
  187. .pmc_mask = AT91_PMC_PCK0,
  188. .type = CLK_TYPE_PROGRAMMABLE,
  189. .id = 0,
  190. };
  191. static struct clk pck1 = {
  192. .name = "pck1",
  193. .pmc_mask = AT91_PMC_PCK1,
  194. .type = CLK_TYPE_PROGRAMMABLE,
  195. .id = 1,
  196. };
  197. static void __init at91sam9n12_register_clocks(void)
  198. {
  199. int i;
  200. for (i = 0; i < ARRAY_SIZE(periph_clocks); i++)
  201. clk_register(periph_clocks[i]);
  202. clk_register(&pck0);
  203. clk_register(&pck1);
  204. clkdev_add_table(periph_clocks_lookups,
  205. ARRAY_SIZE(periph_clocks_lookups));
  206. }
  207. #else
  208. #define at91sam9n12_register_clocks NULL
  209. #endif
  210. /* --------------------------------------------------------------------
  211. * AT91SAM9N12 processor initialization
  212. * -------------------------------------------------------------------- */
  213. static void __init at91sam9n12_map_io(void)
  214. {
  215. at91_init_sram(0, AT91SAM9N12_SRAM_BASE, AT91SAM9N12_SRAM_SIZE);
  216. }
  217. static void __init at91sam9n12_initialize(void)
  218. {
  219. at91_sysirq_mask_rtc(AT91SAM9N12_BASE_RTC);
  220. }
  221. AT91_SOC_START(at91sam9n12)
  222. .map_io = at91sam9n12_map_io,
  223. .register_clocks = at91sam9n12_register_clocks,
  224. .init = at91sam9n12_initialize,
  225. AT91_SOC_END