at91sam9263.c 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. /*
  2. * arch/arm/mach-at91/at91sam9263.c
  3. *
  4. * Copyright (C) 2007 Atmel Corporation.
  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/at91sam9263.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 at91sam9263_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 - AT91SAM9263_SRAM0_SIZE,
  28. .pfn = __phys_to_pfn(AT91SAM9263_SRAM0_BASE),
  29. .length = AT91SAM9263_SRAM0_SIZE,
  30. .type = MT_DEVICE,
  31. }, {
  32. .virtual = AT91_IO_VIRT_BASE - AT91SAM9263_SRAM0_SIZE - AT91SAM9263_SRAM1_SIZE,
  33. .pfn = __phys_to_pfn(AT91SAM9263_SRAM1_BASE),
  34. .length = AT91SAM9263_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 << AT91SAM9263_ID_PIOA,
  47. .type = CLK_TYPE_PERIPHERAL,
  48. };
  49. static struct clk pioB_clk = {
  50. .name = "pioB_clk",
  51. .pmc_mask = 1 << AT91SAM9263_ID_PIOB,
  52. .type = CLK_TYPE_PERIPHERAL,
  53. };
  54. static struct clk pioCDE_clk = {
  55. .name = "pioCDE_clk",
  56. .pmc_mask = 1 << AT91SAM9263_ID_PIOCDE,
  57. .type = CLK_TYPE_PERIPHERAL,
  58. };
  59. static struct clk usart0_clk = {
  60. .name = "usart0_clk",
  61. .pmc_mask = 1 << AT91SAM9263_ID_US0,
  62. .type = CLK_TYPE_PERIPHERAL,
  63. };
  64. static struct clk usart1_clk = {
  65. .name = "usart1_clk",
  66. .pmc_mask = 1 << AT91SAM9263_ID_US1,
  67. .type = CLK_TYPE_PERIPHERAL,
  68. };
  69. static struct clk usart2_clk = {
  70. .name = "usart2_clk",
  71. .pmc_mask = 1 << AT91SAM9263_ID_US2,
  72. .type = CLK_TYPE_PERIPHERAL,
  73. };
  74. static struct clk mmc0_clk = {
  75. .name = "mci0_clk",
  76. .pmc_mask = 1 << AT91SAM9263_ID_MCI0,
  77. .type = CLK_TYPE_PERIPHERAL,
  78. };
  79. static struct clk mmc1_clk = {
  80. .name = "mci1_clk",
  81. .pmc_mask = 1 << AT91SAM9263_ID_MCI1,
  82. .type = CLK_TYPE_PERIPHERAL,
  83. };
  84. static struct clk twi_clk = {
  85. .name = "twi_clk",
  86. .pmc_mask = 1 << AT91SAM9263_ID_TWI,
  87. .type = CLK_TYPE_PERIPHERAL,
  88. };
  89. static struct clk spi0_clk = {
  90. .name = "spi0_clk",
  91. .pmc_mask = 1 << AT91SAM9263_ID_SPI0,
  92. .type = CLK_TYPE_PERIPHERAL,
  93. };
  94. static struct clk spi1_clk = {
  95. .name = "spi1_clk",
  96. .pmc_mask = 1 << AT91SAM9263_ID_SPI1,
  97. .type = CLK_TYPE_PERIPHERAL,
  98. };
  99. static struct clk tcb_clk = {
  100. .name = "tcb_clk",
  101. .pmc_mask = 1 << AT91SAM9263_ID_TCB,
  102. .type = CLK_TYPE_PERIPHERAL,
  103. };
  104. static struct clk macb_clk = {
  105. .name = "macb_clk",
  106. .pmc_mask = 1 << AT91SAM9263_ID_EMAC,
  107. .type = CLK_TYPE_PERIPHERAL,
  108. };
  109. static struct clk udc_clk = {
  110. .name = "udc_clk",
  111. .pmc_mask = 1 << AT91SAM9263_ID_UDP,
  112. .type = CLK_TYPE_PERIPHERAL,
  113. };
  114. static struct clk isi_clk = {
  115. .name = "isi_clk",
  116. .pmc_mask = 1 << AT91SAM9263_ID_ISI,
  117. .type = CLK_TYPE_PERIPHERAL,
  118. };
  119. static struct clk lcdc_clk = {
  120. .name = "lcdc_clk",
  121. .pmc_mask = 1 << AT91SAM9263_ID_LCDC,
  122. .type = CLK_TYPE_PERIPHERAL,
  123. };
  124. static struct clk ohci_clk = {
  125. .name = "ohci_clk",
  126. .pmc_mask = 1 << AT91SAM9263_ID_UHP,
  127. .type = CLK_TYPE_PERIPHERAL,
  128. };
  129. static struct clk *periph_clocks[] __initdata = {
  130. &pioA_clk,
  131. &pioB_clk,
  132. &pioCDE_clk,
  133. &usart0_clk,
  134. &usart1_clk,
  135. &usart2_clk,
  136. &mmc0_clk,
  137. &mmc1_clk,
  138. // can
  139. &twi_clk,
  140. &spi0_clk,
  141. &spi1_clk,
  142. // ssc0 .. ssc1
  143. // ac97
  144. &tcb_clk,
  145. // pwmc
  146. &macb_clk,
  147. // 2dge
  148. &udc_clk,
  149. &isi_clk,
  150. &lcdc_clk,
  151. // dma
  152. &ohci_clk,
  153. // irq0 .. irq1
  154. };
  155. /*
  156. * The four programmable clocks.
  157. * You must configure pin multiplexing to bring these signals out.
  158. */
  159. static struct clk pck0 = {
  160. .name = "pck0",
  161. .pmc_mask = AT91_PMC_PCK0,
  162. .type = CLK_TYPE_PROGRAMMABLE,
  163. .id = 0,
  164. };
  165. static struct clk pck1 = {
  166. .name = "pck1",
  167. .pmc_mask = AT91_PMC_PCK1,
  168. .type = CLK_TYPE_PROGRAMMABLE,
  169. .id = 1,
  170. };
  171. static struct clk pck2 = {
  172. .name = "pck2",
  173. .pmc_mask = AT91_PMC_PCK2,
  174. .type = CLK_TYPE_PROGRAMMABLE,
  175. .id = 2,
  176. };
  177. static struct clk pck3 = {
  178. .name = "pck3",
  179. .pmc_mask = AT91_PMC_PCK3,
  180. .type = CLK_TYPE_PROGRAMMABLE,
  181. .id = 3,
  182. };
  183. static void __init at91sam9263_register_clocks(void)
  184. {
  185. int i;
  186. for (i = 0; i < ARRAY_SIZE(periph_clocks); i++)
  187. clk_register(periph_clocks[i]);
  188. clk_register(&pck0);
  189. clk_register(&pck1);
  190. clk_register(&pck2);
  191. clk_register(&pck3);
  192. }
  193. /* --------------------------------------------------------------------
  194. * GPIO
  195. * -------------------------------------------------------------------- */
  196. static struct at91_gpio_bank at91sam9263_gpio[] = {
  197. {
  198. .id = AT91SAM9263_ID_PIOA,
  199. .offset = AT91_PIOA,
  200. .clock = &pioA_clk,
  201. }, {
  202. .id = AT91SAM9263_ID_PIOB,
  203. .offset = AT91_PIOB,
  204. .clock = &pioB_clk,
  205. }, {
  206. .id = AT91SAM9263_ID_PIOCDE,
  207. .offset = AT91_PIOC,
  208. .clock = &pioCDE_clk,
  209. }, {
  210. .id = AT91SAM9263_ID_PIOCDE,
  211. .offset = AT91_PIOD,
  212. .clock = &pioCDE_clk,
  213. }, {
  214. .id = AT91SAM9263_ID_PIOCDE,
  215. .offset = AT91_PIOE,
  216. .clock = &pioCDE_clk,
  217. }
  218. };
  219. static void at91sam9263_reset(void)
  220. {
  221. at91_sys_write(AT91_RSTC_CR, AT91_RSTC_KEY | AT91_RSTC_PROCRST | AT91_RSTC_PERRST);
  222. }
  223. /* --------------------------------------------------------------------
  224. * AT91SAM9263 processor initialization
  225. * -------------------------------------------------------------------- */
  226. void __init at91sam9263_initialize(unsigned long main_clock)
  227. {
  228. /* Map peripherals */
  229. iotable_init(at91sam9263_io_desc, ARRAY_SIZE(at91sam9263_io_desc));
  230. at91_arch_reset = at91sam9263_reset;
  231. at91_extern_irq = (1 << AT91SAM9263_ID_IRQ0) | (1 << AT91SAM9263_ID_IRQ1);
  232. /* Init clock subsystem */
  233. at91_clock_init(main_clock);
  234. /* Register the processor-specific clocks */
  235. at91sam9263_register_clocks();
  236. /* Register GPIO subsystem */
  237. at91_gpio_init(at91sam9263_gpio, 5);
  238. }
  239. /* --------------------------------------------------------------------
  240. * Interrupt initialization
  241. * -------------------------------------------------------------------- */
  242. /*
  243. * The default interrupt priority levels (0 = lowest, 7 = highest).
  244. */
  245. static unsigned int at91sam9263_default_irq_priority[NR_AIC_IRQS] __initdata = {
  246. 7, /* Advanced Interrupt Controller (FIQ) */
  247. 7, /* System Peripherals */
  248. 0, /* Parallel IO Controller A */
  249. 0, /* Parallel IO Controller B */
  250. 0, /* Parallel IO Controller C, D and E */
  251. 0,
  252. 0,
  253. 6, /* USART 0 */
  254. 6, /* USART 1 */
  255. 6, /* USART 2 */
  256. 0, /* Multimedia Card Interface 0 */
  257. 0, /* Multimedia Card Interface 1 */
  258. 4, /* CAN */
  259. 0, /* Two-Wire Interface */
  260. 6, /* Serial Peripheral Interface 0 */
  261. 6, /* Serial Peripheral Interface 1 */
  262. 5, /* Serial Synchronous Controller 0 */
  263. 5, /* Serial Synchronous Controller 1 */
  264. 6, /* AC97 Controller */
  265. 0, /* Timer Counter 0, 1 and 2 */
  266. 0, /* Pulse Width Modulation Controller */
  267. 3, /* Ethernet */
  268. 0,
  269. 0, /* 2D Graphic Engine */
  270. 3, /* USB Device Port */
  271. 0, /* Image Sensor Interface */
  272. 3, /* LDC Controller */
  273. 0, /* DMA Controller */
  274. 0,
  275. 3, /* USB Host port */
  276. 0, /* Advanced Interrupt Controller (IRQ0) */
  277. 0, /* Advanced Interrupt Controller (IRQ1) */
  278. };
  279. void __init at91sam9263_init_interrupts(unsigned int priority[NR_AIC_IRQS])
  280. {
  281. if (!priority)
  282. priority = at91sam9263_default_irq_priority;
  283. /* Initialize the AIC interrupt controller */
  284. at91_aic_init(priority);
  285. /* Enable GPIO interrupts */
  286. at91_gpio_irq_setup();
  287. }