at91cap9.c 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. /*
  2. * arch/arm/mach-at91/at91cap9.c
  3. *
  4. * Copyright (C) 2007 Stelian Pop <stelian.pop@leadtechdesign.com>
  5. * Copyright (C) 2007 Lead Tech Design <www.leadtechdesign.com>
  6. * Copyright (C) 2007 Atmel Corporation.
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. */
  14. #include <linux/module.h>
  15. #include <asm/mach/arch.h>
  16. #include <asm/mach/map.h>
  17. #include <asm/arch/at91cap9.h>
  18. #include <asm/arch/at91_pmc.h>
  19. #include <asm/arch/at91_rstc.h>
  20. #include "generic.h"
  21. #include "clock.h"
  22. static struct map_desc at91cap9_io_desc[] __initdata = {
  23. {
  24. .virtual = AT91_VA_BASE_SYS,
  25. .pfn = __phys_to_pfn(AT91_BASE_SYS),
  26. .length = SZ_16K,
  27. .type = MT_DEVICE,
  28. }, {
  29. .virtual = AT91_IO_VIRT_BASE - AT91CAP9_SRAM_SIZE,
  30. .pfn = __phys_to_pfn(AT91CAP9_SRAM_BASE),
  31. .length = AT91CAP9_SRAM_SIZE,
  32. .type = MT_DEVICE,
  33. },
  34. };
  35. /* --------------------------------------------------------------------
  36. * Clocks
  37. * -------------------------------------------------------------------- */
  38. /*
  39. * The peripheral clocks.
  40. */
  41. static struct clk pioABCD_clk = {
  42. .name = "pioABCD_clk",
  43. .pmc_mask = 1 << AT91CAP9_ID_PIOABCD,
  44. .type = CLK_TYPE_PERIPHERAL,
  45. };
  46. static struct clk mpb0_clk = {
  47. .name = "mpb0_clk",
  48. .pmc_mask = 1 << AT91CAP9_ID_MPB0,
  49. .type = CLK_TYPE_PERIPHERAL,
  50. };
  51. static struct clk mpb1_clk = {
  52. .name = "mpb1_clk",
  53. .pmc_mask = 1 << AT91CAP9_ID_MPB1,
  54. .type = CLK_TYPE_PERIPHERAL,
  55. };
  56. static struct clk mpb2_clk = {
  57. .name = "mpb2_clk",
  58. .pmc_mask = 1 << AT91CAP9_ID_MPB2,
  59. .type = CLK_TYPE_PERIPHERAL,
  60. };
  61. static struct clk mpb3_clk = {
  62. .name = "mpb3_clk",
  63. .pmc_mask = 1 << AT91CAP9_ID_MPB3,
  64. .type = CLK_TYPE_PERIPHERAL,
  65. };
  66. static struct clk mpb4_clk = {
  67. .name = "mpb4_clk",
  68. .pmc_mask = 1 << AT91CAP9_ID_MPB4,
  69. .type = CLK_TYPE_PERIPHERAL,
  70. };
  71. static struct clk usart0_clk = {
  72. .name = "usart0_clk",
  73. .pmc_mask = 1 << AT91CAP9_ID_US0,
  74. .type = CLK_TYPE_PERIPHERAL,
  75. };
  76. static struct clk usart1_clk = {
  77. .name = "usart1_clk",
  78. .pmc_mask = 1 << AT91CAP9_ID_US1,
  79. .type = CLK_TYPE_PERIPHERAL,
  80. };
  81. static struct clk usart2_clk = {
  82. .name = "usart2_clk",
  83. .pmc_mask = 1 << AT91CAP9_ID_US2,
  84. .type = CLK_TYPE_PERIPHERAL,
  85. };
  86. static struct clk mmc0_clk = {
  87. .name = "mci0_clk",
  88. .pmc_mask = 1 << AT91CAP9_ID_MCI0,
  89. .type = CLK_TYPE_PERIPHERAL,
  90. };
  91. static struct clk mmc1_clk = {
  92. .name = "mci1_clk",
  93. .pmc_mask = 1 << AT91CAP9_ID_MCI1,
  94. .type = CLK_TYPE_PERIPHERAL,
  95. };
  96. static struct clk can_clk = {
  97. .name = "can_clk",
  98. .pmc_mask = 1 << AT91CAP9_ID_CAN,
  99. .type = CLK_TYPE_PERIPHERAL,
  100. };
  101. static struct clk twi_clk = {
  102. .name = "twi_clk",
  103. .pmc_mask = 1 << AT91CAP9_ID_TWI,
  104. .type = CLK_TYPE_PERIPHERAL,
  105. };
  106. static struct clk spi0_clk = {
  107. .name = "spi0_clk",
  108. .pmc_mask = 1 << AT91CAP9_ID_SPI0,
  109. .type = CLK_TYPE_PERIPHERAL,
  110. };
  111. static struct clk spi1_clk = {
  112. .name = "spi1_clk",
  113. .pmc_mask = 1 << AT91CAP9_ID_SPI1,
  114. .type = CLK_TYPE_PERIPHERAL,
  115. };
  116. static struct clk ssc0_clk = {
  117. .name = "ssc0_clk",
  118. .pmc_mask = 1 << AT91CAP9_ID_SSC0,
  119. .type = CLK_TYPE_PERIPHERAL,
  120. };
  121. static struct clk ssc1_clk = {
  122. .name = "ssc1_clk",
  123. .pmc_mask = 1 << AT91CAP9_ID_SSC1,
  124. .type = CLK_TYPE_PERIPHERAL,
  125. };
  126. static struct clk ac97_clk = {
  127. .name = "ac97_clk",
  128. .pmc_mask = 1 << AT91CAP9_ID_AC97C,
  129. .type = CLK_TYPE_PERIPHERAL,
  130. };
  131. static struct clk tcb_clk = {
  132. .name = "tcb_clk",
  133. .pmc_mask = 1 << AT91CAP9_ID_TCB,
  134. .type = CLK_TYPE_PERIPHERAL,
  135. };
  136. static struct clk pwmc_clk = {
  137. .name = "pwmc_clk",
  138. .pmc_mask = 1 << AT91CAP9_ID_PWMC,
  139. .type = CLK_TYPE_PERIPHERAL,
  140. };
  141. static struct clk macb_clk = {
  142. .name = "macb_clk",
  143. .pmc_mask = 1 << AT91CAP9_ID_EMAC,
  144. .type = CLK_TYPE_PERIPHERAL,
  145. };
  146. static struct clk aestdes_clk = {
  147. .name = "aestdes_clk",
  148. .pmc_mask = 1 << AT91CAP9_ID_AESTDES,
  149. .type = CLK_TYPE_PERIPHERAL,
  150. };
  151. static struct clk adc_clk = {
  152. .name = "adc_clk",
  153. .pmc_mask = 1 << AT91CAP9_ID_ADC,
  154. .type = CLK_TYPE_PERIPHERAL,
  155. };
  156. static struct clk isi_clk = {
  157. .name = "isi_clk",
  158. .pmc_mask = 1 << AT91CAP9_ID_ISI,
  159. .type = CLK_TYPE_PERIPHERAL,
  160. };
  161. static struct clk lcdc_clk = {
  162. .name = "lcdc_clk",
  163. .pmc_mask = 1 << AT91CAP9_ID_LCDC,
  164. .type = CLK_TYPE_PERIPHERAL,
  165. };
  166. static struct clk dma_clk = {
  167. .name = "dma_clk",
  168. .pmc_mask = 1 << AT91CAP9_ID_DMA,
  169. .type = CLK_TYPE_PERIPHERAL,
  170. };
  171. static struct clk udphs_clk = {
  172. .name = "udphs_clk",
  173. .pmc_mask = 1 << AT91CAP9_ID_UDPHS,
  174. .type = CLK_TYPE_PERIPHERAL,
  175. };
  176. static struct clk ohci_clk = {
  177. .name = "ohci_clk",
  178. .pmc_mask = 1 << AT91CAP9_ID_UHP,
  179. .type = CLK_TYPE_PERIPHERAL,
  180. };
  181. static struct clk *periph_clocks[] __initdata = {
  182. &pioABCD_clk,
  183. &mpb0_clk,
  184. &mpb1_clk,
  185. &mpb2_clk,
  186. &mpb3_clk,
  187. &mpb4_clk,
  188. &usart0_clk,
  189. &usart1_clk,
  190. &usart2_clk,
  191. &mmc0_clk,
  192. &mmc1_clk,
  193. &can_clk,
  194. &twi_clk,
  195. &spi0_clk,
  196. &spi1_clk,
  197. &ssc0_clk,
  198. &ssc1_clk,
  199. &ac97_clk,
  200. &tcb_clk,
  201. &pwmc_clk,
  202. &macb_clk,
  203. &aestdes_clk,
  204. &adc_clk,
  205. &isi_clk,
  206. &lcdc_clk,
  207. &dma_clk,
  208. &udphs_clk,
  209. &ohci_clk,
  210. // irq0 .. irq1
  211. };
  212. /*
  213. * The four programmable clocks.
  214. * You must configure pin multiplexing to bring these signals out.
  215. */
  216. static struct clk pck0 = {
  217. .name = "pck0",
  218. .pmc_mask = AT91_PMC_PCK0,
  219. .type = CLK_TYPE_PROGRAMMABLE,
  220. .id = 0,
  221. };
  222. static struct clk pck1 = {
  223. .name = "pck1",
  224. .pmc_mask = AT91_PMC_PCK1,
  225. .type = CLK_TYPE_PROGRAMMABLE,
  226. .id = 1,
  227. };
  228. static struct clk pck2 = {
  229. .name = "pck2",
  230. .pmc_mask = AT91_PMC_PCK2,
  231. .type = CLK_TYPE_PROGRAMMABLE,
  232. .id = 2,
  233. };
  234. static struct clk pck3 = {
  235. .name = "pck3",
  236. .pmc_mask = AT91_PMC_PCK3,
  237. .type = CLK_TYPE_PROGRAMMABLE,
  238. .id = 3,
  239. };
  240. static void __init at91cap9_register_clocks(void)
  241. {
  242. int i;
  243. for (i = 0; i < ARRAY_SIZE(periph_clocks); i++)
  244. clk_register(periph_clocks[i]);
  245. clk_register(&pck0);
  246. clk_register(&pck1);
  247. clk_register(&pck2);
  248. clk_register(&pck3);
  249. }
  250. /* --------------------------------------------------------------------
  251. * GPIO
  252. * -------------------------------------------------------------------- */
  253. static struct at91_gpio_bank at91cap9_gpio[] = {
  254. {
  255. .id = AT91CAP9_ID_PIOABCD,
  256. .offset = AT91_PIOA,
  257. .clock = &pioABCD_clk,
  258. }, {
  259. .id = AT91CAP9_ID_PIOABCD,
  260. .offset = AT91_PIOB,
  261. .clock = &pioABCD_clk,
  262. }, {
  263. .id = AT91CAP9_ID_PIOABCD,
  264. .offset = AT91_PIOC,
  265. .clock = &pioABCD_clk,
  266. }, {
  267. .id = AT91CAP9_ID_PIOABCD,
  268. .offset = AT91_PIOD,
  269. .clock = &pioABCD_clk,
  270. }
  271. };
  272. static void at91cap9_reset(void)
  273. {
  274. at91_sys_write(AT91_RSTC_CR, AT91_RSTC_KEY | AT91_RSTC_PROCRST | AT91_RSTC_PERRST);
  275. }
  276. /* --------------------------------------------------------------------
  277. * AT91CAP9 processor initialization
  278. * -------------------------------------------------------------------- */
  279. void __init at91cap9_initialize(unsigned long main_clock)
  280. {
  281. /* Map peripherals */
  282. iotable_init(at91cap9_io_desc, ARRAY_SIZE(at91cap9_io_desc));
  283. at91_arch_reset = at91cap9_reset;
  284. at91_extern_irq = (1 << AT91CAP9_ID_IRQ0) | (1 << AT91CAP9_ID_IRQ1);
  285. /* Init clock subsystem */
  286. at91_clock_init(main_clock);
  287. /* Register the processor-specific clocks */
  288. at91cap9_register_clocks();
  289. /* Register GPIO subsystem */
  290. at91_gpio_init(at91cap9_gpio, 4);
  291. }
  292. /* --------------------------------------------------------------------
  293. * Interrupt initialization
  294. * -------------------------------------------------------------------- */
  295. /*
  296. * The default interrupt priority levels (0 = lowest, 7 = highest).
  297. */
  298. static unsigned int at91cap9_default_irq_priority[NR_AIC_IRQS] __initdata = {
  299. 7, /* Advanced Interrupt Controller (FIQ) */
  300. 7, /* System Peripherals */
  301. 1, /* Parallel IO Controller A, B, C and D */
  302. 0, /* MP Block Peripheral 0 */
  303. 0, /* MP Block Peripheral 1 */
  304. 0, /* MP Block Peripheral 2 */
  305. 0, /* MP Block Peripheral 3 */
  306. 0, /* MP Block Peripheral 4 */
  307. 5, /* USART 0 */
  308. 5, /* USART 1 */
  309. 5, /* USART 2 */
  310. 0, /* Multimedia Card Interface 0 */
  311. 0, /* Multimedia Card Interface 1 */
  312. 3, /* CAN */
  313. 6, /* Two-Wire Interface */
  314. 5, /* Serial Peripheral Interface 0 */
  315. 5, /* Serial Peripheral Interface 1 */
  316. 4, /* Serial Synchronous Controller 0 */
  317. 4, /* Serial Synchronous Controller 1 */
  318. 5, /* AC97 Controller */
  319. 0, /* Timer Counter 0, 1 and 2 */
  320. 0, /* Pulse Width Modulation Controller */
  321. 3, /* Ethernet */
  322. 0, /* Advanced Encryption Standard, Triple DES*/
  323. 0, /* Analog-to-Digital Converter */
  324. 0, /* Image Sensor Interface */
  325. 3, /* LCD Controller */
  326. 0, /* DMA Controller */
  327. 2, /* USB Device Port */
  328. 2, /* USB Host port */
  329. 0, /* Advanced Interrupt Controller (IRQ0) */
  330. 0, /* Advanced Interrupt Controller (IRQ1) */
  331. };
  332. void __init at91cap9_init_interrupts(unsigned int priority[NR_AIC_IRQS])
  333. {
  334. if (!priority)
  335. priority = at91cap9_default_irq_priority;
  336. /* Initialize the AIC interrupt controller */
  337. at91_aic_init(priority);
  338. /* Enable GPIO interrupts */
  339. at91_gpio_irq_setup();
  340. }