at91sam9n12.c 5.9 KB

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