at91sam9260.c 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. /*
  2. * arch/arm/mach-at91rm9200/at91sam9260.c
  3. *
  4. * Copyright (C) 2006 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/at91sam9260.h>
  16. #include <asm/arch/at91_pmc.h>
  17. #include <asm/arch/at91_rstc.h>
  18. #include "generic.h"
  19. #include "clock.h"
  20. static struct map_desc at91sam9260_io_desc[] __initdata = {
  21. {
  22. .virtual = AT91_VA_BASE_SYS,
  23. .pfn = __phys_to_pfn(AT91_BASE_SYS),
  24. .length = SZ_16K,
  25. .type = MT_DEVICE,
  26. }, {
  27. .virtual = AT91_IO_VIRT_BASE - AT91SAM9260_SRAM0_SIZE,
  28. .pfn = __phys_to_pfn(AT91SAM9260_SRAM0_BASE),
  29. .length = AT91SAM9260_SRAM0_SIZE,
  30. .type = MT_DEVICE,
  31. }, {
  32. .virtual = AT91_IO_VIRT_BASE - AT91SAM9260_SRAM0_SIZE - AT91SAM9260_SRAM1_SIZE,
  33. .pfn = __phys_to_pfn(AT91SAM9260_SRAM1_BASE),
  34. .length = AT91SAM9260_SRAM1_SIZE,
  35. .type = MT_DEVICE,
  36. },
  37. };
  38. /* --------------------------------------------------------------------
  39. * Clocks
  40. * -------------------------------------------------------------------- */
  41. /*
  42. * The peripheral clocks.
  43. */
  44. static struct clk pioA_clk = {
  45. .name = "pioA_clk",
  46. .pmc_mask = 1 << AT91SAM9260_ID_PIOA,
  47. .type = CLK_TYPE_PERIPHERAL,
  48. };
  49. static struct clk pioB_clk = {
  50. .name = "pioB_clk",
  51. .pmc_mask = 1 << AT91SAM9260_ID_PIOB,
  52. .type = CLK_TYPE_PERIPHERAL,
  53. };
  54. static struct clk pioC_clk = {
  55. .name = "pioC_clk",
  56. .pmc_mask = 1 << AT91SAM9260_ID_PIOC,
  57. .type = CLK_TYPE_PERIPHERAL,
  58. };
  59. static struct clk adc_clk = {
  60. .name = "adc_clk",
  61. .pmc_mask = 1 << AT91SAM9260_ID_ADC,
  62. .type = CLK_TYPE_PERIPHERAL,
  63. };
  64. static struct clk usart0_clk = {
  65. .name = "usart0_clk",
  66. .pmc_mask = 1 << AT91SAM9260_ID_US0,
  67. .type = CLK_TYPE_PERIPHERAL,
  68. };
  69. static struct clk usart1_clk = {
  70. .name = "usart1_clk",
  71. .pmc_mask = 1 << AT91SAM9260_ID_US1,
  72. .type = CLK_TYPE_PERIPHERAL,
  73. };
  74. static struct clk usart2_clk = {
  75. .name = "usart2_clk",
  76. .pmc_mask = 1 << AT91SAM9260_ID_US2,
  77. .type = CLK_TYPE_PERIPHERAL,
  78. };
  79. static struct clk mmc_clk = {
  80. .name = "mci_clk",
  81. .pmc_mask = 1 << AT91SAM9260_ID_MCI,
  82. .type = CLK_TYPE_PERIPHERAL,
  83. };
  84. static struct clk udc_clk = {
  85. .name = "udc_clk",
  86. .pmc_mask = 1 << AT91SAM9260_ID_UDP,
  87. .type = CLK_TYPE_PERIPHERAL,
  88. };
  89. static struct clk twi_clk = {
  90. .name = "twi_clk",
  91. .pmc_mask = 1 << AT91SAM9260_ID_TWI,
  92. .type = CLK_TYPE_PERIPHERAL,
  93. };
  94. static struct clk spi0_clk = {
  95. .name = "spi0_clk",
  96. .pmc_mask = 1 << AT91SAM9260_ID_SPI0,
  97. .type = CLK_TYPE_PERIPHERAL,
  98. };
  99. static struct clk spi1_clk = {
  100. .name = "spi1_clk",
  101. .pmc_mask = 1 << AT91SAM9260_ID_SPI1,
  102. .type = CLK_TYPE_PERIPHERAL,
  103. };
  104. static struct clk ohci_clk = {
  105. .name = "ohci_clk",
  106. .pmc_mask = 1 << AT91SAM9260_ID_UHP,
  107. .type = CLK_TYPE_PERIPHERAL,
  108. };
  109. static struct clk ether_clk = {
  110. .name = "ether_clk",
  111. .pmc_mask = 1 << AT91SAM9260_ID_EMAC,
  112. .type = CLK_TYPE_PERIPHERAL,
  113. };
  114. static struct clk isi_clk = {
  115. .name = "isi_clk",
  116. .pmc_mask = 1 << AT91SAM9260_ID_ISI,
  117. .type = CLK_TYPE_PERIPHERAL,
  118. };
  119. static struct clk usart3_clk = {
  120. .name = "usart3_clk",
  121. .pmc_mask = 1 << AT91SAM9260_ID_US3,
  122. .type = CLK_TYPE_PERIPHERAL,
  123. };
  124. static struct clk usart4_clk = {
  125. .name = "usart4_clk",
  126. .pmc_mask = 1 << AT91SAM9260_ID_US4,
  127. .type = CLK_TYPE_PERIPHERAL,
  128. };
  129. static struct clk usart5_clk = {
  130. .name = "usart5_clk",
  131. .pmc_mask = 1 << AT91SAM9260_ID_US5,
  132. .type = CLK_TYPE_PERIPHERAL,
  133. };
  134. static struct clk *periph_clocks[] __initdata = {
  135. &pioA_clk,
  136. &pioB_clk,
  137. &pioC_clk,
  138. &adc_clk,
  139. &usart0_clk,
  140. &usart1_clk,
  141. &usart2_clk,
  142. &mmc_clk,
  143. &udc_clk,
  144. &twi_clk,
  145. &spi0_clk,
  146. &spi1_clk,
  147. // ssc
  148. // tc0 .. tc2
  149. &ohci_clk,
  150. &ether_clk,
  151. &isi_clk,
  152. &usart3_clk,
  153. &usart4_clk,
  154. &usart5_clk,
  155. // tc3 .. tc5
  156. // irq0 .. irq2
  157. };
  158. /*
  159. * The two programmable clocks.
  160. * You must configure pin multiplexing to bring these signals out.
  161. */
  162. static struct clk pck0 = {
  163. .name = "pck0",
  164. .pmc_mask = AT91_PMC_PCK0,
  165. .type = CLK_TYPE_PROGRAMMABLE,
  166. .id = 0,
  167. };
  168. static struct clk pck1 = {
  169. .name = "pck1",
  170. .pmc_mask = AT91_PMC_PCK1,
  171. .type = CLK_TYPE_PROGRAMMABLE,
  172. .id = 1,
  173. };
  174. static void __init at91sam9260_register_clocks(void)
  175. {
  176. int i;
  177. for (i = 0; i < ARRAY_SIZE(periph_clocks); i++)
  178. clk_register(periph_clocks[i]);
  179. clk_register(&pck0);
  180. clk_register(&pck1);
  181. }
  182. /* --------------------------------------------------------------------
  183. * GPIO
  184. * -------------------------------------------------------------------- */
  185. static struct at91_gpio_bank at91sam9260_gpio[] = {
  186. {
  187. .id = AT91SAM9260_ID_PIOA,
  188. .offset = AT91_PIOA,
  189. .clock = &pioA_clk,
  190. }, {
  191. .id = AT91SAM9260_ID_PIOB,
  192. .offset = AT91_PIOB,
  193. .clock = &pioB_clk,
  194. }, {
  195. .id = AT91SAM9260_ID_PIOC,
  196. .offset = AT91_PIOC,
  197. .clock = &pioC_clk,
  198. }
  199. };
  200. static void at91sam9260_reset(void)
  201. {
  202. at91_sys_write(AT91_RSTC_CR, (0xA5 << 24) | AT91_RSTC_PROCRST | AT91_RSTC_PERRST);
  203. }
  204. /* --------------------------------------------------------------------
  205. * AT91SAM9260 processor initialization
  206. * -------------------------------------------------------------------- */
  207. void __init at91sam9260_initialize(unsigned long main_clock)
  208. {
  209. /* Map peripherals */
  210. iotable_init(at91sam9260_io_desc, ARRAY_SIZE(at91sam9260_io_desc));
  211. at91_arch_reset = at91sam9260_reset;
  212. at91_extern_irq = (1 << AT91SAM9260_ID_IRQ0) | (1 << AT91SAM9260_ID_IRQ1)
  213. | (1 << AT91SAM9260_ID_IRQ2);
  214. /* Init clock subsystem */
  215. at91_clock_init(main_clock);
  216. /* Register the processor-specific clocks */
  217. at91sam9260_register_clocks();
  218. /* Register GPIO subsystem */
  219. at91_gpio_init(at91sam9260_gpio, 3);
  220. }
  221. /* --------------------------------------------------------------------
  222. * Interrupt initialization
  223. * -------------------------------------------------------------------- */
  224. /*
  225. * The default interrupt priority levels (0 = lowest, 7 = highest).
  226. */
  227. static unsigned int at91sam9260_default_irq_priority[NR_AIC_IRQS] __initdata = {
  228. 7, /* Advanced Interrupt Controller */
  229. 7, /* System Peripherals */
  230. 0, /* Parallel IO Controller A */
  231. 0, /* Parallel IO Controller B */
  232. 0, /* Parallel IO Controller C */
  233. 0, /* Analog-to-Digital Converter */
  234. 6, /* USART 0 */
  235. 6, /* USART 1 */
  236. 6, /* USART 2 */
  237. 0, /* Multimedia Card Interface */
  238. 4, /* USB Device Port */
  239. 0, /* Two-Wire Interface */
  240. 6, /* Serial Peripheral Interface 0 */
  241. 6, /* Serial Peripheral Interface 1 */
  242. 5, /* Serial Synchronous Controller */
  243. 0,
  244. 0,
  245. 0, /* Timer Counter 0 */
  246. 0, /* Timer Counter 1 */
  247. 0, /* Timer Counter 2 */
  248. 3, /* USB Host port */
  249. 3, /* Ethernet */
  250. 0, /* Image Sensor Interface */
  251. 6, /* USART 3 */
  252. 6, /* USART 4 */
  253. 6, /* USART 5 */
  254. 0, /* Timer Counter 3 */
  255. 0, /* Timer Counter 4 */
  256. 0, /* Timer Counter 5 */
  257. 0, /* Advanced Interrupt Controller */
  258. 0, /* Advanced Interrupt Controller */
  259. 0, /* Advanced Interrupt Controller */
  260. };
  261. void __init at91sam9260_init_interrupts(unsigned int priority[NR_AIC_IRQS])
  262. {
  263. if (!priority)
  264. priority = at91sam9260_default_irq_priority;
  265. /* Initialize the AIC interrupt controller */
  266. at91_aic_init(priority);
  267. /* Enable GPIO interrupts */
  268. at91_gpio_irq_setup();
  269. }