at91rm9200.c 7.6 KB

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