2 * arch/arm/mach-at91/at91cap9.c
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.
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.
15 #include <linux/module.h>
18 #include <asm/mach/arch.h>
19 #include <asm/mach/map.h>
22 #include <mach/at91cap9.h>
23 #include <mach/at91_pmc.h>
24 #include <mach/at91_rstc.h>
25 #include <mach/at91_shdwc.h>
30 static struct map_desc at91cap9_io_desc[] __initdata = {
32 .virtual = AT91_VA_BASE_SYS,
33 .pfn = __phys_to_pfn(AT91_BASE_SYS),
37 .virtual = AT91_IO_VIRT_BASE - AT91CAP9_SRAM_SIZE,
38 .pfn = __phys_to_pfn(AT91CAP9_SRAM_BASE),
39 .length = AT91CAP9_SRAM_SIZE,
44 /* --------------------------------------------------------------------
46 * -------------------------------------------------------------------- */
49 * The peripheral clocks.
51 static struct clk pioABCD_clk = {
52 .name = "pioABCD_clk",
53 .pmc_mask = 1 << AT91CAP9_ID_PIOABCD,
54 .type = CLK_TYPE_PERIPHERAL,
56 static struct clk mpb0_clk = {
58 .pmc_mask = 1 << AT91CAP9_ID_MPB0,
59 .type = CLK_TYPE_PERIPHERAL,
61 static struct clk mpb1_clk = {
63 .pmc_mask = 1 << AT91CAP9_ID_MPB1,
64 .type = CLK_TYPE_PERIPHERAL,
66 static struct clk mpb2_clk = {
68 .pmc_mask = 1 << AT91CAP9_ID_MPB2,
69 .type = CLK_TYPE_PERIPHERAL,
71 static struct clk mpb3_clk = {
73 .pmc_mask = 1 << AT91CAP9_ID_MPB3,
74 .type = CLK_TYPE_PERIPHERAL,
76 static struct clk mpb4_clk = {
78 .pmc_mask = 1 << AT91CAP9_ID_MPB4,
79 .type = CLK_TYPE_PERIPHERAL,
81 static struct clk usart0_clk = {
83 .pmc_mask = 1 << AT91CAP9_ID_US0,
84 .type = CLK_TYPE_PERIPHERAL,
86 static struct clk usart1_clk = {
88 .pmc_mask = 1 << AT91CAP9_ID_US1,
89 .type = CLK_TYPE_PERIPHERAL,
91 static struct clk usart2_clk = {
93 .pmc_mask = 1 << AT91CAP9_ID_US2,
94 .type = CLK_TYPE_PERIPHERAL,
96 static struct clk mmc0_clk = {
98 .pmc_mask = 1 << AT91CAP9_ID_MCI0,
99 .type = CLK_TYPE_PERIPHERAL,
101 static struct clk mmc1_clk = {
103 .pmc_mask = 1 << AT91CAP9_ID_MCI1,
104 .type = CLK_TYPE_PERIPHERAL,
106 static struct clk can_clk = {
108 .pmc_mask = 1 << AT91CAP9_ID_CAN,
109 .type = CLK_TYPE_PERIPHERAL,
111 static struct clk twi_clk = {
113 .pmc_mask = 1 << AT91CAP9_ID_TWI,
114 .type = CLK_TYPE_PERIPHERAL,
116 static struct clk spi0_clk = {
118 .pmc_mask = 1 << AT91CAP9_ID_SPI0,
119 .type = CLK_TYPE_PERIPHERAL,
121 static struct clk spi1_clk = {
123 .pmc_mask = 1 << AT91CAP9_ID_SPI1,
124 .type = CLK_TYPE_PERIPHERAL,
126 static struct clk ssc0_clk = {
128 .pmc_mask = 1 << AT91CAP9_ID_SSC0,
129 .type = CLK_TYPE_PERIPHERAL,
131 static struct clk ssc1_clk = {
133 .pmc_mask = 1 << AT91CAP9_ID_SSC1,
134 .type = CLK_TYPE_PERIPHERAL,
136 static struct clk ac97_clk = {
138 .pmc_mask = 1 << AT91CAP9_ID_AC97C,
139 .type = CLK_TYPE_PERIPHERAL,
141 static struct clk tcb_clk = {
143 .pmc_mask = 1 << AT91CAP9_ID_TCB,
144 .type = CLK_TYPE_PERIPHERAL,
146 static struct clk pwm_clk = {
148 .pmc_mask = 1 << AT91CAP9_ID_PWMC,
149 .type = CLK_TYPE_PERIPHERAL,
151 static struct clk macb_clk = {
153 .pmc_mask = 1 << AT91CAP9_ID_EMAC,
154 .type = CLK_TYPE_PERIPHERAL,
156 static struct clk aestdes_clk = {
157 .name = "aestdes_clk",
158 .pmc_mask = 1 << AT91CAP9_ID_AESTDES,
159 .type = CLK_TYPE_PERIPHERAL,
161 static struct clk adc_clk = {
163 .pmc_mask = 1 << AT91CAP9_ID_ADC,
164 .type = CLK_TYPE_PERIPHERAL,
166 static struct clk isi_clk = {
168 .pmc_mask = 1 << AT91CAP9_ID_ISI,
169 .type = CLK_TYPE_PERIPHERAL,
171 static struct clk lcdc_clk = {
173 .pmc_mask = 1 << AT91CAP9_ID_LCDC,
174 .type = CLK_TYPE_PERIPHERAL,
176 static struct clk dma_clk = {
178 .pmc_mask = 1 << AT91CAP9_ID_DMA,
179 .type = CLK_TYPE_PERIPHERAL,
181 static struct clk udphs_clk = {
183 .pmc_mask = 1 << AT91CAP9_ID_UDPHS,
184 .type = CLK_TYPE_PERIPHERAL,
186 static struct clk ohci_clk = {
188 .pmc_mask = 1 << AT91CAP9_ID_UHP,
189 .type = CLK_TYPE_PERIPHERAL,
192 static struct clk *periph_clocks[] __initdata = {
225 * The four programmable clocks.
226 * You must configure pin multiplexing to bring these signals out.
228 static struct clk pck0 = {
230 .pmc_mask = AT91_PMC_PCK0,
231 .type = CLK_TYPE_PROGRAMMABLE,
234 static struct clk pck1 = {
236 .pmc_mask = AT91_PMC_PCK1,
237 .type = CLK_TYPE_PROGRAMMABLE,
240 static struct clk pck2 = {
242 .pmc_mask = AT91_PMC_PCK2,
243 .type = CLK_TYPE_PROGRAMMABLE,
246 static struct clk pck3 = {
248 .pmc_mask = AT91_PMC_PCK3,
249 .type = CLK_TYPE_PROGRAMMABLE,
253 static void __init at91cap9_register_clocks(void)
257 for (i = 0; i < ARRAY_SIZE(periph_clocks); i++)
258 clk_register(periph_clocks[i]);
266 /* --------------------------------------------------------------------
268 * -------------------------------------------------------------------- */
270 static struct at91_gpio_bank at91cap9_gpio[] = {
272 .id = AT91CAP9_ID_PIOABCD,
274 .clock = &pioABCD_clk,
276 .id = AT91CAP9_ID_PIOABCD,
278 .clock = &pioABCD_clk,
280 .id = AT91CAP9_ID_PIOABCD,
282 .clock = &pioABCD_clk,
284 .id = AT91CAP9_ID_PIOABCD,
286 .clock = &pioABCD_clk,
290 static void at91cap9_reset(void)
292 at91_sys_write(AT91_RSTC_CR, AT91_RSTC_KEY | AT91_RSTC_PROCRST | AT91_RSTC_PERRST);
295 static void at91cap9_poweroff(void)
297 at91_sys_write(AT91_SHDW_CR, AT91_SHDW_KEY | AT91_SHDW_SHDW);
301 /* --------------------------------------------------------------------
302 * AT91CAP9 processor initialization
303 * -------------------------------------------------------------------- */
305 void __init at91cap9_initialize(unsigned long main_clock)
307 /* Map peripherals */
308 iotable_init(at91cap9_io_desc, ARRAY_SIZE(at91cap9_io_desc));
310 at91_arch_reset = at91cap9_reset;
311 pm_power_off = at91cap9_poweroff;
312 at91_extern_irq = (1 << AT91CAP9_ID_IRQ0) | (1 << AT91CAP9_ID_IRQ1);
314 /* Init clock subsystem */
315 at91_clock_init(main_clock);
317 /* Register the processor-specific clocks */
318 at91cap9_register_clocks();
320 /* Register GPIO subsystem */
321 at91_gpio_init(at91cap9_gpio, 4);
323 /* Remember the silicon revision */
324 if (cpu_is_at91cap9_revB())
326 else if (cpu_is_at91cap9_revC())
330 /* --------------------------------------------------------------------
331 * Interrupt initialization
332 * -------------------------------------------------------------------- */
335 * The default interrupt priority levels (0 = lowest, 7 = highest).
337 static unsigned int at91cap9_default_irq_priority[NR_AIC_IRQS] __initdata = {
338 7, /* Advanced Interrupt Controller (FIQ) */
339 7, /* System Peripherals */
340 1, /* Parallel IO Controller A, B, C and D */
341 0, /* MP Block Peripheral 0 */
342 0, /* MP Block Peripheral 1 */
343 0, /* MP Block Peripheral 2 */
344 0, /* MP Block Peripheral 3 */
345 0, /* MP Block Peripheral 4 */
349 0, /* Multimedia Card Interface 0 */
350 0, /* Multimedia Card Interface 1 */
352 6, /* Two-Wire Interface */
353 5, /* Serial Peripheral Interface 0 */
354 5, /* Serial Peripheral Interface 1 */
355 4, /* Serial Synchronous Controller 0 */
356 4, /* Serial Synchronous Controller 1 */
357 5, /* AC97 Controller */
358 0, /* Timer Counter 0, 1 and 2 */
359 0, /* Pulse Width Modulation Controller */
361 0, /* Advanced Encryption Standard, Triple DES*/
362 0, /* Analog-to-Digital Converter */
363 0, /* Image Sensor Interface */
364 3, /* LCD Controller */
365 0, /* DMA Controller */
366 2, /* USB Device Port */
367 2, /* USB Host port */
368 0, /* Advanced Interrupt Controller (IRQ0) */
369 0, /* Advanced Interrupt Controller (IRQ1) */
372 void __init at91cap9_init_interrupts(unsigned int priority[NR_AIC_IRQS])
375 priority = at91cap9_default_irq_priority;
377 /* Initialize the AIC interrupt controller */
378 at91_aic_init(priority);
380 /* Enable GPIO interrupts */
381 at91_gpio_irq_setup();