at91sam9261.c 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. /*
  2. * arch/arm/mach-at91rm9200/at91sam9261.c
  3. *
  4. * Copyright (C) 2005 SAN People
  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 as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. */
  12. #include <linux/module.h>
  13. #include <asm/mach/arch.h>
  14. #include <asm/mach/map.h>
  15. #include <asm/arch/at91sam9261.h>
  16. #include <asm/arch/at91_pmc.h>
  17. #include "generic.h"
  18. #include "clock.h"
  19. static struct map_desc at91sam9261_io_desc[] __initdata = {
  20. {
  21. .virtual = AT91_VA_BASE_SYS,
  22. .pfn = __phys_to_pfn(AT91_BASE_SYS),
  23. .length = SZ_16K,
  24. .type = MT_DEVICE,
  25. }, {
  26. .virtual = AT91_IO_VIRT_BASE - AT91SAM9261_SRAM_SIZE,
  27. .pfn = __phys_to_pfn(AT91SAM9261_SRAM_BASE),
  28. .length = AT91SAM9261_SRAM_SIZE,
  29. .type = MT_DEVICE,
  30. },
  31. };
  32. /* --------------------------------------------------------------------
  33. * Clocks
  34. * -------------------------------------------------------------------- */
  35. /*
  36. * The peripheral clocks.
  37. */
  38. static struct clk pioA_clk = {
  39. .name = "pioA_clk",
  40. .pmc_mask = 1 << AT91SAM9261_ID_PIOA,
  41. .type = CLK_TYPE_PERIPHERAL,
  42. };
  43. static struct clk pioB_clk = {
  44. .name = "pioB_clk",
  45. .pmc_mask = 1 << AT91SAM9261_ID_PIOB,
  46. .type = CLK_TYPE_PERIPHERAL,
  47. };
  48. static struct clk pioC_clk = {
  49. .name = "pioC_clk",
  50. .pmc_mask = 1 << AT91SAM9261_ID_PIOC,
  51. .type = CLK_TYPE_PERIPHERAL,
  52. };
  53. static struct clk usart0_clk = {
  54. .name = "usart0_clk",
  55. .pmc_mask = 1 << AT91SAM9261_ID_US0,
  56. .type = CLK_TYPE_PERIPHERAL,
  57. };
  58. static struct clk usart1_clk = {
  59. .name = "usart1_clk",
  60. .pmc_mask = 1 << AT91SAM9261_ID_US1,
  61. .type = CLK_TYPE_PERIPHERAL,
  62. };
  63. static struct clk usart2_clk = {
  64. .name = "usart2_clk",
  65. .pmc_mask = 1 << AT91SAM9261_ID_US2,
  66. .type = CLK_TYPE_PERIPHERAL,
  67. };
  68. static struct clk mmc_clk = {
  69. .name = "mci_clk",
  70. .pmc_mask = 1 << AT91SAM9261_ID_MCI,
  71. .type = CLK_TYPE_PERIPHERAL,
  72. };
  73. static struct clk udc_clk = {
  74. .name = "udc_clk",
  75. .pmc_mask = 1 << AT91SAM9261_ID_UDP,
  76. .type = CLK_TYPE_PERIPHERAL,
  77. };
  78. static struct clk twi_clk = {
  79. .name = "twi_clk",
  80. .pmc_mask = 1 << AT91SAM9261_ID_TWI,
  81. .type = CLK_TYPE_PERIPHERAL,
  82. };
  83. static struct clk spi0_clk = {
  84. .name = "spi0_clk",
  85. .pmc_mask = 1 << AT91SAM9261_ID_SPI0,
  86. .type = CLK_TYPE_PERIPHERAL,
  87. };
  88. static struct clk spi1_clk = {
  89. .name = "spi1_clk",
  90. .pmc_mask = 1 << AT91SAM9261_ID_SPI1,
  91. .type = CLK_TYPE_PERIPHERAL,
  92. };
  93. static struct clk ohci_clk = {
  94. .name = "ohci_clk",
  95. .pmc_mask = 1 << AT91SAM9261_ID_UHP,
  96. .type = CLK_TYPE_PERIPHERAL,
  97. };
  98. static struct clk lcdc_clk = {
  99. .name = "lcdc_clk",
  100. .pmc_mask = 1 << AT91SAM9261_ID_LCDC,
  101. .type = CLK_TYPE_PERIPHERAL,
  102. };
  103. static struct clk *periph_clocks[] __initdata = {
  104. &pioA_clk,
  105. &pioB_clk,
  106. &pioC_clk,
  107. &usart0_clk,
  108. &usart1_clk,
  109. &usart2_clk,
  110. &mmc_clk,
  111. &udc_clk,
  112. &twi_clk,
  113. &spi0_clk,
  114. &spi1_clk,
  115. // ssc 0 .. ssc2
  116. // tc0 .. tc2
  117. &ohci_clk,
  118. &lcdc_clk,
  119. // irq0 .. irq2
  120. };
  121. /*
  122. * The four programmable clocks.
  123. * You must configure pin multiplexing to bring these signals out.
  124. */
  125. static struct clk pck0 = {
  126. .name = "pck0",
  127. .pmc_mask = AT91_PMC_PCK0,
  128. .type = CLK_TYPE_PROGRAMMABLE,
  129. .id = 0,
  130. };
  131. static struct clk pck1 = {
  132. .name = "pck1",
  133. .pmc_mask = AT91_PMC_PCK1,
  134. .type = CLK_TYPE_PROGRAMMABLE,
  135. .id = 1,
  136. };
  137. static struct clk pck2 = {
  138. .name = "pck2",
  139. .pmc_mask = AT91_PMC_PCK2,
  140. .type = CLK_TYPE_PROGRAMMABLE,
  141. .id = 2,
  142. };
  143. static struct clk pck3 = {
  144. .name = "pck3",
  145. .pmc_mask = AT91_PMC_PCK3,
  146. .type = CLK_TYPE_PROGRAMMABLE,
  147. .id = 3,
  148. };
  149. /* HClocks */
  150. static struct clk hck0 = {
  151. .name = "hck0",
  152. .pmc_mask = AT91_PMC_HCK0,
  153. .type = CLK_TYPE_SYSTEM,
  154. .id = 0,
  155. };
  156. static struct clk hck1 = {
  157. .name = "hck1",
  158. .pmc_mask = AT91_PMC_HCK1,
  159. .type = CLK_TYPE_SYSTEM,
  160. .id = 1,
  161. };
  162. static void __init at91sam9261_register_clocks(void)
  163. {
  164. int i;
  165. for (i = 0; i < ARRAY_SIZE(periph_clocks); i++)
  166. clk_register(periph_clocks[i]);
  167. clk_register(&pck0);
  168. clk_register(&pck1);
  169. clk_register(&pck2);
  170. clk_register(&pck3);
  171. clk_register(&hck0);
  172. clk_register(&hck1);
  173. }
  174. /* --------------------------------------------------------------------
  175. * GPIO
  176. * -------------------------------------------------------------------- */
  177. static struct at91_gpio_bank at91sam9261_gpio[] = {
  178. {
  179. .id = AT91SAM9261_ID_PIOA,
  180. .offset = AT91_PIOA,
  181. .clock = &pioA_clk,
  182. }, {
  183. .id = AT91SAM9261_ID_PIOB,
  184. .offset = AT91_PIOB,
  185. .clock = &pioB_clk,
  186. }, {
  187. .id = AT91SAM9261_ID_PIOC,
  188. .offset = AT91_PIOC,
  189. .clock = &pioC_clk,
  190. }
  191. };
  192. static void at91sam9261_reset(void)
  193. {
  194. #warning "Implement CPU reset"
  195. }
  196. /* --------------------------------------------------------------------
  197. * AT91SAM9261 processor initialization
  198. * -------------------------------------------------------------------- */
  199. void __init at91sam9261_initialize(unsigned long main_clock)
  200. {
  201. /* Map peripherals */
  202. iotable_init(at91sam9261_io_desc, ARRAY_SIZE(at91sam9261_io_desc));
  203. at91_arch_reset = at91sam9261_reset;
  204. at91_extern_irq = (1 << AT91SAM9261_ID_IRQ0) | (1 << AT91SAM9261_ID_IRQ1)
  205. | (1 << AT91SAM9261_ID_IRQ2);
  206. /* Init clock subsystem */
  207. at91_clock_init(main_clock);
  208. /* Register the processor-specific clocks */
  209. at91sam9261_register_clocks();
  210. /* Register GPIO subsystem */
  211. at91_gpio_init(at91sam9261_gpio, 3);
  212. }
  213. /* --------------------------------------------------------------------
  214. * Interrupt initialization
  215. * -------------------------------------------------------------------- */
  216. /*
  217. * The default interrupt priority levels (0 = lowest, 7 = highest).
  218. */
  219. static unsigned int at91sam9261_default_irq_priority[NR_AIC_IRQS] __initdata = {
  220. 7, /* Advanced Interrupt Controller */
  221. 7, /* System Peripherals */
  222. 0, /* Parallel IO Controller A */
  223. 0, /* Parallel IO Controller B */
  224. 0, /* Parallel IO Controller C */
  225. 0,
  226. 6, /* USART 0 */
  227. 6, /* USART 1 */
  228. 6, /* USART 2 */
  229. 0, /* Multimedia Card Interface */
  230. 4, /* USB Device Port */
  231. 0, /* Two-Wire Interface */
  232. 6, /* Serial Peripheral Interface 0 */
  233. 6, /* Serial Peripheral Interface 1 */
  234. 5, /* Serial Synchronous Controller 0 */
  235. 5, /* Serial Synchronous Controller 1 */
  236. 5, /* Serial Synchronous Controller 2 */
  237. 0, /* Timer Counter 0 */
  238. 0, /* Timer Counter 1 */
  239. 0, /* Timer Counter 2 */
  240. 3, /* USB Host port */
  241. 3, /* LCD Controller */
  242. 0,
  243. 0,
  244. 0,
  245. 0,
  246. 0,
  247. 0,
  248. 0,
  249. 0, /* Advanced Interrupt Controller */
  250. 0, /* Advanced Interrupt Controller */
  251. 0, /* Advanced Interrupt Controller */
  252. };
  253. void __init at91sam9261_init_interrupts(unsigned int priority[NR_AIC_IRQS])
  254. {
  255. if (!priority)
  256. priority = at91sam9261_default_irq_priority;
  257. /* Initialize the AIC interrupt controller */
  258. at91_aic_init(priority);
  259. /* Enable GPIO interrupts */
  260. at91_gpio_irq_setup();
  261. }