2 * arch/arm/mach-at91/at91sam9261.c
4 * Copyright (C) 2005 SAN People
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.
13 #include <linux/module.h>
16 #include <asm/mach/arch.h>
17 #include <asm/mach/map.h>
18 #include <asm/arch/at91sam9261.h>
19 #include <asm/arch/at91_pmc.h>
20 #include <asm/arch/at91_rstc.h>
21 #include <asm/arch/at91_shdwc.h>
26 static struct map_desc at91sam9261_io_desc[] __initdata = {
28 .virtual = AT91_VA_BASE_SYS,
29 .pfn = __phys_to_pfn(AT91_BASE_SYS),
33 .virtual = AT91_IO_VIRT_BASE - AT91SAM9261_SRAM_SIZE,
34 .pfn = __phys_to_pfn(AT91SAM9261_SRAM_BASE),
35 .length = AT91SAM9261_SRAM_SIZE,
40 /* --------------------------------------------------------------------
42 * -------------------------------------------------------------------- */
45 * The peripheral clocks.
47 static struct clk pioA_clk = {
49 .pmc_mask = 1 << AT91SAM9261_ID_PIOA,
50 .type = CLK_TYPE_PERIPHERAL,
52 static struct clk pioB_clk = {
54 .pmc_mask = 1 << AT91SAM9261_ID_PIOB,
55 .type = CLK_TYPE_PERIPHERAL,
57 static struct clk pioC_clk = {
59 .pmc_mask = 1 << AT91SAM9261_ID_PIOC,
60 .type = CLK_TYPE_PERIPHERAL,
62 static struct clk usart0_clk = {
64 .pmc_mask = 1 << AT91SAM9261_ID_US0,
65 .type = CLK_TYPE_PERIPHERAL,
67 static struct clk usart1_clk = {
69 .pmc_mask = 1 << AT91SAM9261_ID_US1,
70 .type = CLK_TYPE_PERIPHERAL,
72 static struct clk usart2_clk = {
74 .pmc_mask = 1 << AT91SAM9261_ID_US2,
75 .type = CLK_TYPE_PERIPHERAL,
77 static struct clk mmc_clk = {
79 .pmc_mask = 1 << AT91SAM9261_ID_MCI,
80 .type = CLK_TYPE_PERIPHERAL,
82 static struct clk udc_clk = {
84 .pmc_mask = 1 << AT91SAM9261_ID_UDP,
85 .type = CLK_TYPE_PERIPHERAL,
87 static struct clk twi_clk = {
89 .pmc_mask = 1 << AT91SAM9261_ID_TWI,
90 .type = CLK_TYPE_PERIPHERAL,
92 static struct clk spi0_clk = {
94 .pmc_mask = 1 << AT91SAM9261_ID_SPI0,
95 .type = CLK_TYPE_PERIPHERAL,
97 static struct clk spi1_clk = {
99 .pmc_mask = 1 << AT91SAM9261_ID_SPI1,
100 .type = CLK_TYPE_PERIPHERAL,
102 static struct clk ssc0_clk = {
104 .pmc_mask = 1 << AT91SAM9261_ID_SSC0,
105 .type = CLK_TYPE_PERIPHERAL,
107 static struct clk ssc1_clk = {
109 .pmc_mask = 1 << AT91SAM9261_ID_SSC1,
110 .type = CLK_TYPE_PERIPHERAL,
112 static struct clk ssc2_clk = {
114 .pmc_mask = 1 << AT91SAM9261_ID_SSC2,
115 .type = CLK_TYPE_PERIPHERAL,
117 static struct clk tc0_clk = {
119 .pmc_mask = 1 << AT91SAM9261_ID_TC0,
120 .type = CLK_TYPE_PERIPHERAL,
122 static struct clk tc1_clk = {
124 .pmc_mask = 1 << AT91SAM9261_ID_TC1,
125 .type = CLK_TYPE_PERIPHERAL,
127 static struct clk tc2_clk = {
129 .pmc_mask = 1 << AT91SAM9261_ID_TC2,
130 .type = CLK_TYPE_PERIPHERAL,
132 static struct clk ohci_clk = {
134 .pmc_mask = 1 << AT91SAM9261_ID_UHP,
135 .type = CLK_TYPE_PERIPHERAL,
137 static struct clk lcdc_clk = {
139 .pmc_mask = 1 << AT91SAM9261_ID_LCDC,
140 .type = CLK_TYPE_PERIPHERAL,
143 static struct clk *periph_clocks[] __initdata = {
167 * The four programmable clocks.
168 * You must configure pin multiplexing to bring these signals out.
170 static struct clk pck0 = {
172 .pmc_mask = AT91_PMC_PCK0,
173 .type = CLK_TYPE_PROGRAMMABLE,
176 static struct clk pck1 = {
178 .pmc_mask = AT91_PMC_PCK1,
179 .type = CLK_TYPE_PROGRAMMABLE,
182 static struct clk pck2 = {
184 .pmc_mask = AT91_PMC_PCK2,
185 .type = CLK_TYPE_PROGRAMMABLE,
188 static struct clk pck3 = {
190 .pmc_mask = AT91_PMC_PCK3,
191 .type = CLK_TYPE_PROGRAMMABLE,
196 static struct clk hck0 = {
198 .pmc_mask = AT91_PMC_HCK0,
199 .type = CLK_TYPE_SYSTEM,
202 static struct clk hck1 = {
204 .pmc_mask = AT91_PMC_HCK1,
205 .type = CLK_TYPE_SYSTEM,
209 static void __init at91sam9261_register_clocks(void)
213 for (i = 0; i < ARRAY_SIZE(periph_clocks); i++)
214 clk_register(periph_clocks[i]);
225 /* --------------------------------------------------------------------
227 * -------------------------------------------------------------------- */
229 static struct at91_gpio_bank at91sam9261_gpio[] = {
231 .id = AT91SAM9261_ID_PIOA,
235 .id = AT91SAM9261_ID_PIOB,
239 .id = AT91SAM9261_ID_PIOC,
245 static void at91sam9261_reset(void)
247 at91_sys_write(AT91_RSTC_CR, AT91_RSTC_KEY | AT91_RSTC_PROCRST | AT91_RSTC_PERRST);
250 static void at91sam9261_poweroff(void)
252 at91_sys_write(AT91_SHDW_CR, AT91_SHDW_KEY | AT91_SHDW_SHDW);
256 /* --------------------------------------------------------------------
257 * AT91SAM9261 processor initialization
258 * -------------------------------------------------------------------- */
260 void __init at91sam9261_initialize(unsigned long main_clock)
262 /* Map peripherals */
263 iotable_init(at91sam9261_io_desc, ARRAY_SIZE(at91sam9261_io_desc));
265 at91_arch_reset = at91sam9261_reset;
266 pm_power_off = at91sam9261_poweroff;
267 at91_extern_irq = (1 << AT91SAM9261_ID_IRQ0) | (1 << AT91SAM9261_ID_IRQ1)
268 | (1 << AT91SAM9261_ID_IRQ2);
270 /* Init clock subsystem */
271 at91_clock_init(main_clock);
273 /* Register the processor-specific clocks */
274 at91sam9261_register_clocks();
276 /* Register GPIO subsystem */
277 at91_gpio_init(at91sam9261_gpio, 3);
280 /* --------------------------------------------------------------------
281 * Interrupt initialization
282 * -------------------------------------------------------------------- */
285 * The default interrupt priority levels (0 = lowest, 7 = highest).
287 static unsigned int at91sam9261_default_irq_priority[NR_AIC_IRQS] __initdata = {
288 7, /* Advanced Interrupt Controller */
289 7, /* System Peripherals */
290 1, /* Parallel IO Controller A */
291 1, /* Parallel IO Controller B */
292 1, /* Parallel IO Controller C */
297 0, /* Multimedia Card Interface */
298 2, /* USB Device Port */
299 6, /* Two-Wire Interface */
300 5, /* Serial Peripheral Interface 0 */
301 5, /* Serial Peripheral Interface 1 */
302 4, /* Serial Synchronous Controller 0 */
303 4, /* Serial Synchronous Controller 1 */
304 4, /* Serial Synchronous Controller 2 */
305 0, /* Timer Counter 0 */
306 0, /* Timer Counter 1 */
307 0, /* Timer Counter 2 */
308 2, /* USB Host port */
309 3, /* LCD Controller */
317 0, /* Advanced Interrupt Controller */
318 0, /* Advanced Interrupt Controller */
319 0, /* Advanced Interrupt Controller */
322 void __init at91sam9261_init_interrupts(unsigned int priority[NR_AIC_IRQS])
325 priority = at91sam9261_default_irq_priority;
327 /* Initialize the AIC interrupt controller */
328 at91_aic_init(priority);
330 /* Enable GPIO interrupts */
331 at91_gpio_irq_setup();