at572d940hf.c 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  1. /*
  2. * arch/arm/mach-at91/at572d940hf.c
  3. *
  4. * Antonio R. Costa <costa.antonior@gmail.com>
  5. * Copyright (C) 2008 Atmel
  6. *
  7. * Copyright (C) 2005 SAN People
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  22. *
  23. */
  24. #include <linux/module.h>
  25. #include <asm/mach/irq.h>
  26. #include <asm/mach/arch.h>
  27. #include <asm/mach/map.h>
  28. #include <mach/at572d940hf.h>
  29. #include <mach/at91_pmc.h>
  30. #include <mach/at91_rstc.h>
  31. #include "generic.h"
  32. #include "clock.h"
  33. static struct map_desc at572d940hf_io_desc[] __initdata = {
  34. {
  35. .virtual = AT91_VA_BASE_SYS,
  36. .pfn = __phys_to_pfn(AT91_BASE_SYS),
  37. .length = SZ_16K,
  38. .type = MT_DEVICE,
  39. }, {
  40. .virtual = AT91_IO_VIRT_BASE - AT572D940HF_SRAM_SIZE,
  41. .pfn = __phys_to_pfn(AT572D940HF_SRAM_BASE),
  42. .length = AT572D940HF_SRAM_SIZE,
  43. .type = MT_DEVICE,
  44. },
  45. };
  46. /* --------------------------------------------------------------------
  47. * Clocks
  48. * -------------------------------------------------------------------- */
  49. /*
  50. * The peripheral clocks.
  51. */
  52. static struct clk pioA_clk = {
  53. .name = "pioA_clk",
  54. .pmc_mask = 1 << AT572D940HF_ID_PIOA,
  55. .type = CLK_TYPE_PERIPHERAL,
  56. };
  57. static struct clk pioB_clk = {
  58. .name = "pioB_clk",
  59. .pmc_mask = 1 << AT572D940HF_ID_PIOB,
  60. .type = CLK_TYPE_PERIPHERAL,
  61. };
  62. static struct clk pioC_clk = {
  63. .name = "pioC_clk",
  64. .pmc_mask = 1 << AT572D940HF_ID_PIOC,
  65. .type = CLK_TYPE_PERIPHERAL,
  66. };
  67. static struct clk macb_clk = {
  68. .name = "macb_clk",
  69. .pmc_mask = 1 << AT572D940HF_ID_EMAC,
  70. .type = CLK_TYPE_PERIPHERAL,
  71. };
  72. static struct clk usart0_clk = {
  73. .name = "usart0_clk",
  74. .pmc_mask = 1 << AT572D940HF_ID_US0,
  75. .type = CLK_TYPE_PERIPHERAL,
  76. };
  77. static struct clk usart1_clk = {
  78. .name = "usart1_clk",
  79. .pmc_mask = 1 << AT572D940HF_ID_US1,
  80. .type = CLK_TYPE_PERIPHERAL,
  81. };
  82. static struct clk usart2_clk = {
  83. .name = "usart2_clk",
  84. .pmc_mask = 1 << AT572D940HF_ID_US2,
  85. .type = CLK_TYPE_PERIPHERAL,
  86. };
  87. static struct clk mmc_clk = {
  88. .name = "mci_clk",
  89. .pmc_mask = 1 << AT572D940HF_ID_MCI,
  90. .type = CLK_TYPE_PERIPHERAL,
  91. };
  92. static struct clk udc_clk = {
  93. .name = "udc_clk",
  94. .pmc_mask = 1 << AT572D940HF_ID_UDP,
  95. .type = CLK_TYPE_PERIPHERAL,
  96. };
  97. static struct clk twi0_clk = {
  98. .name = "twi0_clk",
  99. .pmc_mask = 1 << AT572D940HF_ID_TWI0,
  100. .type = CLK_TYPE_PERIPHERAL,
  101. };
  102. static struct clk spi0_clk = {
  103. .name = "spi0_clk",
  104. .pmc_mask = 1 << AT572D940HF_ID_SPI0,
  105. .type = CLK_TYPE_PERIPHERAL,
  106. };
  107. static struct clk spi1_clk = {
  108. .name = "spi1_clk",
  109. .pmc_mask = 1 << AT572D940HF_ID_SPI1,
  110. .type = CLK_TYPE_PERIPHERAL,
  111. };
  112. static struct clk ssc0_clk = {
  113. .name = "ssc0_clk",
  114. .pmc_mask = 1 << AT572D940HF_ID_SSC0,
  115. .type = CLK_TYPE_PERIPHERAL,
  116. };
  117. static struct clk ssc1_clk = {
  118. .name = "ssc1_clk",
  119. .pmc_mask = 1 << AT572D940HF_ID_SSC1,
  120. .type = CLK_TYPE_PERIPHERAL,
  121. };
  122. static struct clk ssc2_clk = {
  123. .name = "ssc2_clk",
  124. .pmc_mask = 1 << AT572D940HF_ID_SSC2,
  125. .type = CLK_TYPE_PERIPHERAL,
  126. };
  127. static struct clk tc0_clk = {
  128. .name = "tc0_clk",
  129. .pmc_mask = 1 << AT572D940HF_ID_TC0,
  130. .type = CLK_TYPE_PERIPHERAL,
  131. };
  132. static struct clk tc1_clk = {
  133. .name = "tc1_clk",
  134. .pmc_mask = 1 << AT572D940HF_ID_TC1,
  135. .type = CLK_TYPE_PERIPHERAL,
  136. };
  137. static struct clk tc2_clk = {
  138. .name = "tc2_clk",
  139. .pmc_mask = 1 << AT572D940HF_ID_TC2,
  140. .type = CLK_TYPE_PERIPHERAL,
  141. };
  142. static struct clk ohci_clk = {
  143. .name = "ohci_clk",
  144. .pmc_mask = 1 << AT572D940HF_ID_UHP,
  145. .type = CLK_TYPE_PERIPHERAL,
  146. };
  147. static struct clk ssc3_clk = {
  148. .name = "ssc3_clk",
  149. .pmc_mask = 1 << AT572D940HF_ID_SSC3,
  150. .type = CLK_TYPE_PERIPHERAL,
  151. };
  152. static struct clk twi1_clk = {
  153. .name = "twi1_clk",
  154. .pmc_mask = 1 << AT572D940HF_ID_TWI1,
  155. .type = CLK_TYPE_PERIPHERAL,
  156. };
  157. static struct clk can0_clk = {
  158. .name = "can0_clk",
  159. .pmc_mask = 1 << AT572D940HF_ID_CAN0,
  160. .type = CLK_TYPE_PERIPHERAL,
  161. };
  162. static struct clk can1_clk = {
  163. .name = "can1_clk",
  164. .pmc_mask = 1 << AT572D940HF_ID_CAN1,
  165. .type = CLK_TYPE_PERIPHERAL,
  166. };
  167. static struct clk mAgicV_clk = {
  168. .name = "mAgicV_clk",
  169. .pmc_mask = 1 << AT572D940HF_ID_MSIRQ0,
  170. .type = CLK_TYPE_PERIPHERAL,
  171. };
  172. static struct clk *periph_clocks[] __initdata = {
  173. &pioA_clk,
  174. &pioB_clk,
  175. &pioC_clk,
  176. &macb_clk,
  177. &usart0_clk,
  178. &usart1_clk,
  179. &usart2_clk,
  180. &mmc_clk,
  181. &udc_clk,
  182. &twi0_clk,
  183. &spi0_clk,
  184. &spi1_clk,
  185. &ssc0_clk,
  186. &ssc1_clk,
  187. &ssc2_clk,
  188. &tc0_clk,
  189. &tc1_clk,
  190. &tc2_clk,
  191. &ohci_clk,
  192. &ssc3_clk,
  193. &twi1_clk,
  194. &can0_clk,
  195. &can1_clk,
  196. &mAgicV_clk,
  197. /* irq0 .. irq2 */
  198. };
  199. /*
  200. * The five programmable clocks.
  201. * You must configure pin multiplexing to bring these signals out.
  202. */
  203. static struct clk pck0 = {
  204. .name = "pck0",
  205. .pmc_mask = AT91_PMC_PCK0,
  206. .type = CLK_TYPE_PROGRAMMABLE,
  207. .id = 0,
  208. };
  209. static struct clk pck1 = {
  210. .name = "pck1",
  211. .pmc_mask = AT91_PMC_PCK1,
  212. .type = CLK_TYPE_PROGRAMMABLE,
  213. .id = 1,
  214. };
  215. static struct clk pck2 = {
  216. .name = "pck2",
  217. .pmc_mask = AT91_PMC_PCK2,
  218. .type = CLK_TYPE_PROGRAMMABLE,
  219. .id = 2,
  220. };
  221. static struct clk pck3 = {
  222. .name = "pck3",
  223. .pmc_mask = AT91_PMC_PCK3,
  224. .type = CLK_TYPE_PROGRAMMABLE,
  225. .id = 3,
  226. };
  227. static struct clk mAgicV_mem_clk = {
  228. .name = "mAgicV_mem_clk",
  229. .pmc_mask = AT91_PMC_PCK4,
  230. .type = CLK_TYPE_PROGRAMMABLE,
  231. .id = 4,
  232. };
  233. /* HClocks */
  234. static struct clk hck0 = {
  235. .name = "hck0",
  236. .pmc_mask = AT91_PMC_HCK0,
  237. .type = CLK_TYPE_SYSTEM,
  238. .id = 0,
  239. };
  240. static struct clk hck1 = {
  241. .name = "hck1",
  242. .pmc_mask = AT91_PMC_HCK1,
  243. .type = CLK_TYPE_SYSTEM,
  244. .id = 1,
  245. };
  246. static void __init at572d940hf_register_clocks(void)
  247. {
  248. int i;
  249. for (i = 0; i < ARRAY_SIZE(periph_clocks); i++)
  250. clk_register(periph_clocks[i]);
  251. clk_register(&pck0);
  252. clk_register(&pck1);
  253. clk_register(&pck2);
  254. clk_register(&pck3);
  255. clk_register(&mAgicV_mem_clk);
  256. clk_register(&hck0);
  257. clk_register(&hck1);
  258. }
  259. /* --------------------------------------------------------------------
  260. * GPIO
  261. * -------------------------------------------------------------------- */
  262. static struct at91_gpio_bank at572d940hf_gpio[] = {
  263. {
  264. .id = AT572D940HF_ID_PIOA,
  265. .offset = AT91_PIOA,
  266. .clock = &pioA_clk,
  267. }, {
  268. .id = AT572D940HF_ID_PIOB,
  269. .offset = AT91_PIOB,
  270. .clock = &pioB_clk,
  271. }, {
  272. .id = AT572D940HF_ID_PIOC,
  273. .offset = AT91_PIOC,
  274. .clock = &pioC_clk,
  275. }
  276. };
  277. static void at572d940hf_reset(void)
  278. {
  279. at91_sys_write(AT91_RSTC_CR, AT91_RSTC_KEY | AT91_RSTC_PROCRST | AT91_RSTC_PERRST);
  280. }
  281. /* --------------------------------------------------------------------
  282. * AT572D940HF processor initialization
  283. * -------------------------------------------------------------------- */
  284. void __init at572d940hf_initialize(unsigned long main_clock)
  285. {
  286. /* Map peripherals */
  287. iotable_init(at572d940hf_io_desc, ARRAY_SIZE(at572d940hf_io_desc));
  288. at91_arch_reset = at572d940hf_reset;
  289. at91_extern_irq = (1 << AT572D940HF_ID_IRQ0) | (1 << AT572D940HF_ID_IRQ1)
  290. | (1 << AT572D940HF_ID_IRQ2);
  291. /* Init clock subsystem */
  292. at91_clock_init(main_clock);
  293. /* Register the processor-specific clocks */
  294. at572d940hf_register_clocks();
  295. /* Register GPIO subsystem */
  296. at91_gpio_init(at572d940hf_gpio, 3);
  297. }
  298. /* --------------------------------------------------------------------
  299. * Interrupt initialization
  300. * -------------------------------------------------------------------- */
  301. /*
  302. * The default interrupt priority levels (0 = lowest, 7 = highest).
  303. */
  304. static unsigned int at572d940hf_default_irq_priority[NR_AIC_IRQS] __initdata = {
  305. 7, /* Advanced Interrupt Controller */
  306. 7, /* System Peripherals */
  307. 0, /* Parallel IO Controller A */
  308. 0, /* Parallel IO Controller B */
  309. 0, /* Parallel IO Controller C */
  310. 3, /* Ethernet */
  311. 6, /* USART 0 */
  312. 6, /* USART 1 */
  313. 6, /* USART 2 */
  314. 0, /* Multimedia Card Interface */
  315. 4, /* USB Device Port */
  316. 0, /* Two-Wire Interface 0 */
  317. 6, /* Serial Peripheral Interface 0 */
  318. 6, /* Serial Peripheral Interface 1 */
  319. 5, /* Serial Synchronous Controller 0 */
  320. 5, /* Serial Synchronous Controller 1 */
  321. 5, /* Serial Synchronous Controller 2 */
  322. 0, /* Timer Counter 0 */
  323. 0, /* Timer Counter 1 */
  324. 0, /* Timer Counter 2 */
  325. 3, /* USB Host port */
  326. 3, /* Serial Synchronous Controller 3 */
  327. 0, /* Two-Wire Interface 1 */
  328. 0, /* CAN Controller 0 */
  329. 0, /* CAN Controller 1 */
  330. 0, /* mAgicV HALT line */
  331. 0, /* mAgicV SIRQ0 line */
  332. 0, /* mAgicV exception line */
  333. 0, /* mAgicV end of DMA line */
  334. 0, /* Advanced Interrupt Controller */
  335. 0, /* Advanced Interrupt Controller */
  336. 0, /* Advanced Interrupt Controller */
  337. };
  338. void __init at572d940hf_init_interrupts(unsigned int priority[NR_AIC_IRQS])
  339. {
  340. if (!priority)
  341. priority = at572d940hf_default_irq_priority;
  342. /* Initialize the AIC interrupt controller */
  343. at91_aic_init(priority);
  344. /* Enable GPIO interrupts */
  345. at91_gpio_irq_setup();
  346. }