at91rm9200.c 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. /*
  2. * arch/arm/mach-at91rm9200/at91rm9200.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/hardware.h>
  16. #include "generic.h"
  17. #include "clock.h"
  18. static struct map_desc at91rm9200_io_desc[] __initdata = {
  19. {
  20. .virtual = AT91_VA_BASE_SYS,
  21. .pfn = __phys_to_pfn(AT91_BASE_SYS),
  22. .length = SZ_4K,
  23. .type = MT_DEVICE,
  24. }, {
  25. .virtual = AT91_VA_BASE_SPI,
  26. .pfn = __phys_to_pfn(AT91RM9200_BASE_SPI),
  27. .length = SZ_16K,
  28. .type = MT_DEVICE,
  29. }, {
  30. .virtual = AT91_VA_BASE_EMAC,
  31. .pfn = __phys_to_pfn(AT91RM9200_BASE_EMAC),
  32. .length = SZ_16K,
  33. .type = MT_DEVICE,
  34. }, {
  35. .virtual = AT91_VA_BASE_TWI,
  36. .pfn = __phys_to_pfn(AT91RM9200_BASE_TWI),
  37. .length = SZ_16K,
  38. .type = MT_DEVICE,
  39. }, {
  40. .virtual = AT91_VA_BASE_MCI,
  41. .pfn = __phys_to_pfn(AT91RM9200_BASE_MCI),
  42. .length = SZ_16K,
  43. .type = MT_DEVICE,
  44. }, {
  45. .virtual = AT91_VA_BASE_UDP,
  46. .pfn = __phys_to_pfn(AT91RM9200_BASE_UDP),
  47. .length = SZ_16K,
  48. .type = MT_DEVICE,
  49. }, {
  50. .virtual = AT91_SRAM_VIRT_BASE,
  51. .pfn = __phys_to_pfn(AT91RM9200_SRAM_BASE),
  52. .length = AT91RM9200_SRAM_SIZE,
  53. .type = MT_DEVICE,
  54. },
  55. };
  56. /* --------------------------------------------------------------------
  57. * Clocks
  58. * -------------------------------------------------------------------- */
  59. /*
  60. * The peripheral clocks.
  61. */
  62. static struct clk udc_clk = {
  63. .name = "udc_clk",
  64. .pmc_mask = 1 << AT91RM9200_ID_UDP,
  65. .type = CLK_TYPE_PERIPHERAL,
  66. };
  67. static struct clk ohci_clk = {
  68. .name = "ohci_clk",
  69. .pmc_mask = 1 << AT91RM9200_ID_UHP,
  70. .type = CLK_TYPE_PERIPHERAL,
  71. };
  72. static struct clk ether_clk = {
  73. .name = "ether_clk",
  74. .pmc_mask = 1 << AT91RM9200_ID_EMAC,
  75. .type = CLK_TYPE_PERIPHERAL,
  76. };
  77. static struct clk mmc_clk = {
  78. .name = "mci_clk",
  79. .pmc_mask = 1 << AT91RM9200_ID_MCI,
  80. .type = CLK_TYPE_PERIPHERAL,
  81. };
  82. static struct clk twi_clk = {
  83. .name = "twi_clk",
  84. .pmc_mask = 1 << AT91RM9200_ID_TWI,
  85. .type = CLK_TYPE_PERIPHERAL,
  86. };
  87. static struct clk usart0_clk = {
  88. .name = "usart0_clk",
  89. .pmc_mask = 1 << AT91RM9200_ID_US0,
  90. .type = CLK_TYPE_PERIPHERAL,
  91. };
  92. static struct clk usart1_clk = {
  93. .name = "usart1_clk",
  94. .pmc_mask = 1 << AT91RM9200_ID_US1,
  95. .type = CLK_TYPE_PERIPHERAL,
  96. };
  97. static struct clk usart2_clk = {
  98. .name = "usart2_clk",
  99. .pmc_mask = 1 << AT91RM9200_ID_US2,
  100. .type = CLK_TYPE_PERIPHERAL,
  101. };
  102. static struct clk usart3_clk = {
  103. .name = "usart3_clk",
  104. .pmc_mask = 1 << AT91RM9200_ID_US3,
  105. .type = CLK_TYPE_PERIPHERAL,
  106. };
  107. static struct clk spi_clk = {
  108. .name = "spi_clk",
  109. .pmc_mask = 1 << AT91RM9200_ID_SPI,
  110. .type = CLK_TYPE_PERIPHERAL,
  111. };
  112. static struct clk pioA_clk = {
  113. .name = "pioA_clk",
  114. .pmc_mask = 1 << AT91RM9200_ID_PIOA,
  115. .type = CLK_TYPE_PERIPHERAL,
  116. };
  117. static struct clk pioB_clk = {
  118. .name = "pioB_clk",
  119. .pmc_mask = 1 << AT91RM9200_ID_PIOB,
  120. .type = CLK_TYPE_PERIPHERAL,
  121. };
  122. static struct clk pioC_clk = {
  123. .name = "pioC_clk",
  124. .pmc_mask = 1 << AT91RM9200_ID_PIOC,
  125. .type = CLK_TYPE_PERIPHERAL,
  126. };
  127. static struct clk pioD_clk = {
  128. .name = "pioD_clk",
  129. .pmc_mask = 1 << AT91RM9200_ID_PIOD,
  130. .type = CLK_TYPE_PERIPHERAL,
  131. };
  132. static struct clk *periph_clocks[] __initdata = {
  133. &pioA_clk,
  134. &pioB_clk,
  135. &pioC_clk,
  136. &pioD_clk,
  137. &usart0_clk,
  138. &usart1_clk,
  139. &usart2_clk,
  140. &usart3_clk,
  141. &mmc_clk,
  142. &udc_clk,
  143. &twi_clk,
  144. &spi_clk,
  145. // ssc 0 .. ssc2
  146. // tc0 .. tc5
  147. &ohci_clk,
  148. &ether_clk,
  149. // irq0 .. irq6
  150. };
  151. /*
  152. * The four programmable clocks.
  153. * You must configure pin multiplexing to bring these signals out.
  154. */
  155. static struct clk pck0 = {
  156. .name = "pck0",
  157. .pmc_mask = AT91_PMC_PCK0,
  158. .type = CLK_TYPE_PROGRAMMABLE,
  159. .id = 0,
  160. };
  161. static struct clk pck1 = {
  162. .name = "pck1",
  163. .pmc_mask = AT91_PMC_PCK1,
  164. .type = CLK_TYPE_PROGRAMMABLE,
  165. .id = 1,
  166. };
  167. static struct clk pck2 = {
  168. .name = "pck2",
  169. .pmc_mask = AT91_PMC_PCK2,
  170. .type = CLK_TYPE_PROGRAMMABLE,
  171. .id = 2,
  172. };
  173. static struct clk pck3 = {
  174. .name = "pck3",
  175. .pmc_mask = AT91_PMC_PCK3,
  176. .type = CLK_TYPE_PROGRAMMABLE,
  177. .id = 3,
  178. };
  179. static void __init at91rm9200_register_clocks(void)
  180. {
  181. int i;
  182. for (i = 0; i < ARRAY_SIZE(periph_clocks); i++)
  183. clk_register(periph_clocks[i]);
  184. clk_register(&pck0);
  185. clk_register(&pck1);
  186. clk_register(&pck2);
  187. clk_register(&pck3);
  188. }
  189. /* --------------------------------------------------------------------
  190. * GPIO
  191. * -------------------------------------------------------------------- */
  192. static struct at91_gpio_bank at91rm9200_gpio[] = {
  193. {
  194. .id = AT91RM9200_ID_PIOA,
  195. .offset = AT91_PIOA,
  196. .clock = &pioA_clk,
  197. }, {
  198. .id = AT91RM9200_ID_PIOB,
  199. .offset = AT91_PIOB,
  200. .clock = &pioB_clk,
  201. }, {
  202. .id = AT91RM9200_ID_PIOC,
  203. .offset = AT91_PIOC,
  204. .clock = &pioC_clk,
  205. }, {
  206. .id = AT91RM9200_ID_PIOD,
  207. .offset = AT91_PIOD,
  208. .clock = &pioD_clk,
  209. }
  210. };
  211. /* --------------------------------------------------------------------
  212. * AT91RM9200 processor initialization
  213. * -------------------------------------------------------------------- */
  214. void __init at91rm9200_initialize(unsigned long main_clock, unsigned short banks)
  215. {
  216. /* Map peripherals */
  217. iotable_init(at91rm9200_io_desc, ARRAY_SIZE(at91rm9200_io_desc));
  218. /* Init clock subsystem */
  219. at91_clock_init(main_clock);
  220. /* Register the processor-specific clocks */
  221. at91rm9200_register_clocks();
  222. /* Initialize GPIO subsystem */
  223. at91_gpio_init(at91rm9200_gpio, banks);
  224. }
  225. /* --------------------------------------------------------------------
  226. * Interrupt initialization
  227. * -------------------------------------------------------------------- */
  228. /*
  229. * The default interrupt priority levels (0 = lowest, 7 = highest).
  230. */
  231. static unsigned int at91rm9200_default_irq_priority[NR_AIC_IRQS] __initdata = {
  232. 7, /* Advanced Interrupt Controller (FIQ) */
  233. 7, /* System Peripherals */
  234. 0, /* Parallel IO Controller A */
  235. 0, /* Parallel IO Controller B */
  236. 0, /* Parallel IO Controller C */
  237. 0, /* Parallel IO Controller D */
  238. 6, /* USART 0 */
  239. 6, /* USART 1 */
  240. 6, /* USART 2 */
  241. 6, /* USART 3 */
  242. 0, /* Multimedia Card Interface */
  243. 4, /* USB Device Port */
  244. 0, /* Two-Wire Interface */
  245. 6, /* Serial Peripheral Interface */
  246. 5, /* Serial Synchronous Controller 0 */
  247. 5, /* Serial Synchronous Controller 1 */
  248. 5, /* Serial Synchronous Controller 2 */
  249. 0, /* Timer Counter 0 */
  250. 0, /* Timer Counter 1 */
  251. 0, /* Timer Counter 2 */
  252. 0, /* Timer Counter 3 */
  253. 0, /* Timer Counter 4 */
  254. 0, /* Timer Counter 5 */
  255. 3, /* USB Host port */
  256. 3, /* Ethernet MAC */
  257. 0, /* Advanced Interrupt Controller (IRQ0) */
  258. 0, /* Advanced Interrupt Controller (IRQ1) */
  259. 0, /* Advanced Interrupt Controller (IRQ2) */
  260. 0, /* Advanced Interrupt Controller (IRQ3) */
  261. 0, /* Advanced Interrupt Controller (IRQ4) */
  262. 0, /* Advanced Interrupt Controller (IRQ5) */
  263. 0 /* Advanced Interrupt Controller (IRQ6) */
  264. };
  265. void __init at91rm9200_init_interrupts(unsigned int priority[NR_AIC_IRQS])
  266. {
  267. if (!priority)
  268. priority = at91rm9200_default_irq_priority;
  269. /* Initialize the AIC interrupt controller */
  270. at91_aic_init(priority);
  271. /* Enable GPIO interrupts */
  272. at91_gpio_irq_setup();
  273. }