2 * arch/arm/mach-at91/at91sam9rl.c
4 * Copyright (C) 2005 SAN People
5 * Copyright (C) 2007 Atmel Corporation
7 * This file is subject to the terms and conditions of the GNU General Public
8 * License. See the file COPYING in the main directory of this archive for
12 #include <linux/module.h>
15 #include <asm/mach/arch.h>
16 #include <asm/mach/map.h>
18 #include <mach/at91sam9rl.h>
19 #include <mach/at91_pmc.h>
20 #include <mach/at91_rstc.h>
21 #include <mach/at91_shdwc.h>
26 static struct map_desc at91sam9rl_io_desc[] __initdata = {
28 .virtual = AT91_VA_BASE_SYS,
29 .pfn = __phys_to_pfn(AT91_BASE_SYS),
35 static struct map_desc at91sam9rl_sram_desc[] __initdata = {
37 .pfn = __phys_to_pfn(AT91SAM9RL_SRAM_BASE),
42 /* --------------------------------------------------------------------
44 * -------------------------------------------------------------------- */
47 * The peripheral clocks.
49 static struct clk pioA_clk = {
51 .pmc_mask = 1 << AT91SAM9RL_ID_PIOA,
52 .type = CLK_TYPE_PERIPHERAL,
54 static struct clk pioB_clk = {
56 .pmc_mask = 1 << AT91SAM9RL_ID_PIOB,
57 .type = CLK_TYPE_PERIPHERAL,
59 static struct clk pioC_clk = {
61 .pmc_mask = 1 << AT91SAM9RL_ID_PIOC,
62 .type = CLK_TYPE_PERIPHERAL,
64 static struct clk pioD_clk = {
66 .pmc_mask = 1 << AT91SAM9RL_ID_PIOD,
67 .type = CLK_TYPE_PERIPHERAL,
69 static struct clk usart0_clk = {
71 .pmc_mask = 1 << AT91SAM9RL_ID_US0,
72 .type = CLK_TYPE_PERIPHERAL,
74 static struct clk usart1_clk = {
76 .pmc_mask = 1 << AT91SAM9RL_ID_US1,
77 .type = CLK_TYPE_PERIPHERAL,
79 static struct clk usart2_clk = {
81 .pmc_mask = 1 << AT91SAM9RL_ID_US2,
82 .type = CLK_TYPE_PERIPHERAL,
84 static struct clk usart3_clk = {
86 .pmc_mask = 1 << AT91SAM9RL_ID_US3,
87 .type = CLK_TYPE_PERIPHERAL,
89 static struct clk mmc_clk = {
91 .pmc_mask = 1 << AT91SAM9RL_ID_MCI,
92 .type = CLK_TYPE_PERIPHERAL,
94 static struct clk twi0_clk = {
96 .pmc_mask = 1 << AT91SAM9RL_ID_TWI0,
97 .type = CLK_TYPE_PERIPHERAL,
99 static struct clk twi1_clk = {
101 .pmc_mask = 1 << AT91SAM9RL_ID_TWI1,
102 .type = CLK_TYPE_PERIPHERAL,
104 static struct clk spi_clk = {
106 .pmc_mask = 1 << AT91SAM9RL_ID_SPI,
107 .type = CLK_TYPE_PERIPHERAL,
109 static struct clk ssc0_clk = {
111 .pmc_mask = 1 << AT91SAM9RL_ID_SSC0,
112 .type = CLK_TYPE_PERIPHERAL,
114 static struct clk ssc1_clk = {
116 .pmc_mask = 1 << AT91SAM9RL_ID_SSC1,
117 .type = CLK_TYPE_PERIPHERAL,
119 static struct clk tc0_clk = {
121 .pmc_mask = 1 << AT91SAM9RL_ID_TC0,
122 .type = CLK_TYPE_PERIPHERAL,
124 static struct clk tc1_clk = {
126 .pmc_mask = 1 << AT91SAM9RL_ID_TC1,
127 .type = CLK_TYPE_PERIPHERAL,
129 static struct clk tc2_clk = {
131 .pmc_mask = 1 << AT91SAM9RL_ID_TC2,
132 .type = CLK_TYPE_PERIPHERAL,
134 static struct clk pwmc_clk = {
136 .pmc_mask = 1 << AT91SAM9RL_ID_PWMC,
137 .type = CLK_TYPE_PERIPHERAL,
139 static struct clk tsc_clk = {
141 .pmc_mask = 1 << AT91SAM9RL_ID_TSC,
142 .type = CLK_TYPE_PERIPHERAL,
144 static struct clk dma_clk = {
146 .pmc_mask = 1 << AT91SAM9RL_ID_DMA,
147 .type = CLK_TYPE_PERIPHERAL,
149 static struct clk udphs_clk = {
151 .pmc_mask = 1 << AT91SAM9RL_ID_UDPHS,
152 .type = CLK_TYPE_PERIPHERAL,
154 static struct clk lcdc_clk = {
156 .pmc_mask = 1 << AT91SAM9RL_ID_LCDC,
157 .type = CLK_TYPE_PERIPHERAL,
159 static struct clk ac97_clk = {
161 .pmc_mask = 1 << AT91SAM9RL_ID_AC97C,
162 .type = CLK_TYPE_PERIPHERAL,
165 static struct clk *periph_clocks[] __initdata = {
193 * The two programmable clocks.
194 * You must configure pin multiplexing to bring these signals out.
196 static struct clk pck0 = {
198 .pmc_mask = AT91_PMC_PCK0,
199 .type = CLK_TYPE_PROGRAMMABLE,
202 static struct clk pck1 = {
204 .pmc_mask = AT91_PMC_PCK1,
205 .type = CLK_TYPE_PROGRAMMABLE,
209 static void __init at91sam9rl_register_clocks(void)
213 for (i = 0; i < ARRAY_SIZE(periph_clocks); i++)
214 clk_register(periph_clocks[i]);
220 /* --------------------------------------------------------------------
222 * -------------------------------------------------------------------- */
224 static struct at91_gpio_bank at91sam9rl_gpio[] = {
226 .id = AT91SAM9RL_ID_PIOA,
230 .id = AT91SAM9RL_ID_PIOB,
234 .id = AT91SAM9RL_ID_PIOC,
238 .id = AT91SAM9RL_ID_PIOD,
244 static void at91sam9rl_reset(void)
246 at91_sys_write(AT91_RSTC_CR, AT91_RSTC_KEY | AT91_RSTC_PROCRST | AT91_RSTC_PERRST);
249 static void at91sam9rl_poweroff(void)
251 at91_sys_write(AT91_SHDW_CR, AT91_SHDW_KEY | AT91_SHDW_SHDW);
255 /* --------------------------------------------------------------------
256 * AT91SAM9RL processor initialization
257 * -------------------------------------------------------------------- */
259 void __init at91sam9rl_initialize(unsigned long main_clock)
261 unsigned long cidr, sram_size;
263 /* Map peripherals */
264 iotable_init(at91sam9rl_io_desc, ARRAY_SIZE(at91sam9rl_io_desc));
266 cidr = at91_sys_read(AT91_DBGU_CIDR);
268 switch (cidr & AT91_CIDR_SRAMSIZ) {
269 case AT91_CIDR_SRAMSIZ_32K:
270 sram_size = 2 * SZ_16K;
272 case AT91_CIDR_SRAMSIZ_16K:
277 at91sam9rl_sram_desc->virtual = AT91_IO_VIRT_BASE - sram_size;
278 at91sam9rl_sram_desc->length = sram_size;
281 iotable_init(at91sam9rl_sram_desc, ARRAY_SIZE(at91sam9rl_sram_desc));
283 at91_arch_reset = at91sam9rl_reset;
284 pm_power_off = at91sam9rl_poweroff;
285 at91_extern_irq = (1 << AT91SAM9RL_ID_IRQ0);
287 /* Init clock subsystem */
288 at91_clock_init(main_clock);
290 /* Register the processor-specific clocks */
291 at91sam9rl_register_clocks();
293 /* Register GPIO subsystem */
294 at91_gpio_init(at91sam9rl_gpio, 4);
297 /* --------------------------------------------------------------------
298 * Interrupt initialization
299 * -------------------------------------------------------------------- */
302 * The default interrupt priority levels (0 = lowest, 7 = highest).
304 static unsigned int at91sam9rl_default_irq_priority[NR_AIC_IRQS] __initdata = {
305 7, /* Advanced Interrupt Controller */
306 7, /* System Peripherals */
307 1, /* Parallel IO Controller A */
308 1, /* Parallel IO Controller B */
309 1, /* Parallel IO Controller C */
310 1, /* Parallel IO Controller D */
315 0, /* Multimedia Card Interface */
316 6, /* Two-Wire Interface 0 */
317 6, /* Two-Wire Interface 1 */
318 5, /* Serial Peripheral Interface */
319 4, /* Serial Synchronous Controller 0 */
320 4, /* Serial Synchronous Controller 1 */
321 0, /* Timer Counter 0 */
322 0, /* Timer Counter 1 */
323 0, /* Timer Counter 2 */
325 0, /* Touch Screen Controller */
326 0, /* DMA Controller */
327 2, /* USB Device High speed port */
328 2, /* LCD Controller */
329 6, /* AC97 Controller */
336 0, /* Advanced Interrupt Controller */
339 void __init at91sam9rl_init_interrupts(unsigned int priority[NR_AIC_IRQS])
342 priority = at91sam9rl_default_irq_priority;
344 /* Initialize the AIC interrupt controller */
345 at91_aic_init(priority);
347 /* Enable GPIO interrupts */
348 at91_gpio_irq_setup();