2 * arch/arm/mach-at91/at91sam9260.c
4 * Copyright (C) 2006 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/cpu.h>
19 #include <asm/arch/at91sam9260.h>
20 #include <asm/arch/at91_pmc.h>
21 #include <asm/arch/at91_rstc.h>
22 #include <asm/arch/at91_shdwc.h>
27 static struct map_desc at91sam9260_io_desc[] __initdata = {
29 .virtual = AT91_VA_BASE_SYS,
30 .pfn = __phys_to_pfn(AT91_BASE_SYS),
36 static struct map_desc at91sam9260_sram_desc[] __initdata = {
38 .virtual = AT91_IO_VIRT_BASE - AT91SAM9260_SRAM0_SIZE,
39 .pfn = __phys_to_pfn(AT91SAM9260_SRAM0_BASE),
40 .length = AT91SAM9260_SRAM0_SIZE,
43 .virtual = AT91_IO_VIRT_BASE - AT91SAM9260_SRAM0_SIZE - AT91SAM9260_SRAM1_SIZE,
44 .pfn = __phys_to_pfn(AT91SAM9260_SRAM1_BASE),
45 .length = AT91SAM9260_SRAM1_SIZE,
50 static struct map_desc at91sam9g20_sram_desc[] __initdata = {
52 .virtual = AT91_IO_VIRT_BASE - AT91SAM9G20_SRAM0_SIZE,
53 .pfn = __phys_to_pfn(AT91SAM9G20_SRAM0_BASE),
54 .length = AT91SAM9G20_SRAM0_SIZE,
57 .virtual = AT91_IO_VIRT_BASE - AT91SAM9G20_SRAM0_SIZE - AT91SAM9G20_SRAM1_SIZE,
58 .pfn = __phys_to_pfn(AT91SAM9G20_SRAM1_BASE),
59 .length = AT91SAM9G20_SRAM1_SIZE,
64 static struct map_desc at91sam9xe_sram_desc[] __initdata = {
66 .pfn = __phys_to_pfn(AT91SAM9XE_SRAM_BASE),
71 /* --------------------------------------------------------------------
73 * -------------------------------------------------------------------- */
76 * The peripheral clocks.
78 static struct clk pioA_clk = {
80 .pmc_mask = 1 << AT91SAM9260_ID_PIOA,
81 .type = CLK_TYPE_PERIPHERAL,
83 static struct clk pioB_clk = {
85 .pmc_mask = 1 << AT91SAM9260_ID_PIOB,
86 .type = CLK_TYPE_PERIPHERAL,
88 static struct clk pioC_clk = {
90 .pmc_mask = 1 << AT91SAM9260_ID_PIOC,
91 .type = CLK_TYPE_PERIPHERAL,
93 static struct clk adc_clk = {
95 .pmc_mask = 1 << AT91SAM9260_ID_ADC,
96 .type = CLK_TYPE_PERIPHERAL,
98 static struct clk usart0_clk = {
100 .pmc_mask = 1 << AT91SAM9260_ID_US0,
101 .type = CLK_TYPE_PERIPHERAL,
103 static struct clk usart1_clk = {
104 .name = "usart1_clk",
105 .pmc_mask = 1 << AT91SAM9260_ID_US1,
106 .type = CLK_TYPE_PERIPHERAL,
108 static struct clk usart2_clk = {
109 .name = "usart2_clk",
110 .pmc_mask = 1 << AT91SAM9260_ID_US2,
111 .type = CLK_TYPE_PERIPHERAL,
113 static struct clk mmc_clk = {
115 .pmc_mask = 1 << AT91SAM9260_ID_MCI,
116 .type = CLK_TYPE_PERIPHERAL,
118 static struct clk udc_clk = {
120 .pmc_mask = 1 << AT91SAM9260_ID_UDP,
121 .type = CLK_TYPE_PERIPHERAL,
123 static struct clk twi_clk = {
125 .pmc_mask = 1 << AT91SAM9260_ID_TWI,
126 .type = CLK_TYPE_PERIPHERAL,
128 static struct clk spi0_clk = {
130 .pmc_mask = 1 << AT91SAM9260_ID_SPI0,
131 .type = CLK_TYPE_PERIPHERAL,
133 static struct clk spi1_clk = {
135 .pmc_mask = 1 << AT91SAM9260_ID_SPI1,
136 .type = CLK_TYPE_PERIPHERAL,
138 static struct clk ssc_clk = {
140 .pmc_mask = 1 << AT91SAM9260_ID_SSC,
141 .type = CLK_TYPE_PERIPHERAL,
143 static struct clk tc0_clk = {
145 .pmc_mask = 1 << AT91SAM9260_ID_TC0,
146 .type = CLK_TYPE_PERIPHERAL,
148 static struct clk tc1_clk = {
150 .pmc_mask = 1 << AT91SAM9260_ID_TC1,
151 .type = CLK_TYPE_PERIPHERAL,
153 static struct clk tc2_clk = {
155 .pmc_mask = 1 << AT91SAM9260_ID_TC2,
156 .type = CLK_TYPE_PERIPHERAL,
158 static struct clk ohci_clk = {
160 .pmc_mask = 1 << AT91SAM9260_ID_UHP,
161 .type = CLK_TYPE_PERIPHERAL,
163 static struct clk macb_clk = {
165 .pmc_mask = 1 << AT91SAM9260_ID_EMAC,
166 .type = CLK_TYPE_PERIPHERAL,
168 static struct clk isi_clk = {
170 .pmc_mask = 1 << AT91SAM9260_ID_ISI,
171 .type = CLK_TYPE_PERIPHERAL,
173 static struct clk usart3_clk = {
174 .name = "usart3_clk",
175 .pmc_mask = 1 << AT91SAM9260_ID_US3,
176 .type = CLK_TYPE_PERIPHERAL,
178 static struct clk usart4_clk = {
179 .name = "usart4_clk",
180 .pmc_mask = 1 << AT91SAM9260_ID_US4,
181 .type = CLK_TYPE_PERIPHERAL,
183 static struct clk usart5_clk = {
184 .name = "usart5_clk",
185 .pmc_mask = 1 << AT91SAM9260_ID_US5,
186 .type = CLK_TYPE_PERIPHERAL,
188 static struct clk tc3_clk = {
190 .pmc_mask = 1 << AT91SAM9260_ID_TC3,
191 .type = CLK_TYPE_PERIPHERAL,
193 static struct clk tc4_clk = {
195 .pmc_mask = 1 << AT91SAM9260_ID_TC4,
196 .type = CLK_TYPE_PERIPHERAL,
198 static struct clk tc5_clk = {
200 .pmc_mask = 1 << AT91SAM9260_ID_TC5,
201 .type = CLK_TYPE_PERIPHERAL,
204 static struct clk *periph_clocks[] __initdata = {
234 * The two programmable clocks.
235 * You must configure pin multiplexing to bring these signals out.
237 static struct clk pck0 = {
239 .pmc_mask = AT91_PMC_PCK0,
240 .type = CLK_TYPE_PROGRAMMABLE,
243 static struct clk pck1 = {
245 .pmc_mask = AT91_PMC_PCK1,
246 .type = CLK_TYPE_PROGRAMMABLE,
250 static void __init at91sam9260_register_clocks(void)
254 for (i = 0; i < ARRAY_SIZE(periph_clocks); i++)
255 clk_register(periph_clocks[i]);
261 /* --------------------------------------------------------------------
263 * -------------------------------------------------------------------- */
265 static struct at91_gpio_bank at91sam9260_gpio[] = {
267 .id = AT91SAM9260_ID_PIOA,
271 .id = AT91SAM9260_ID_PIOB,
275 .id = AT91SAM9260_ID_PIOC,
281 static void at91sam9260_reset(void)
283 at91_sys_write(AT91_RSTC_CR, AT91_RSTC_KEY | AT91_RSTC_PROCRST | AT91_RSTC_PERRST);
286 static void at91sam9260_poweroff(void)
288 at91_sys_write(AT91_SHDW_CR, AT91_SHDW_KEY | AT91_SHDW_SHDW);
292 /* --------------------------------------------------------------------
293 * AT91SAM9260 processor initialization
294 * -------------------------------------------------------------------- */
296 static void __init at91sam9xe_initialize(void)
298 unsigned long cidr, sram_size;
300 cidr = at91_sys_read(AT91_DBGU_CIDR);
302 switch (cidr & AT91_CIDR_SRAMSIZ) {
303 case AT91_CIDR_SRAMSIZ_32K:
304 sram_size = 2 * SZ_16K;
306 case AT91_CIDR_SRAMSIZ_16K:
311 at91sam9xe_sram_desc->virtual = AT91_IO_VIRT_BASE - sram_size;
312 at91sam9xe_sram_desc->length = sram_size;
314 iotable_init(at91sam9xe_sram_desc, ARRAY_SIZE(at91sam9xe_sram_desc));
317 void __init at91sam9260_initialize(unsigned long main_clock)
319 /* Map peripherals */
320 iotable_init(at91sam9260_io_desc, ARRAY_SIZE(at91sam9260_io_desc));
322 if (cpu_is_at91sam9xe())
323 at91sam9xe_initialize();
324 else if (cpu_is_at91sam9g20())
325 iotable_init(at91sam9g20_sram_desc, ARRAY_SIZE(at91sam9g20_sram_desc));
327 iotable_init(at91sam9260_sram_desc, ARRAY_SIZE(at91sam9260_sram_desc));
329 at91_arch_reset = at91sam9260_reset;
330 pm_power_off = at91sam9260_poweroff;
331 at91_extern_irq = (1 << AT91SAM9260_ID_IRQ0) | (1 << AT91SAM9260_ID_IRQ1)
332 | (1 << AT91SAM9260_ID_IRQ2);
334 /* Init clock subsystem */
335 at91_clock_init(main_clock);
337 /* Register the processor-specific clocks */
338 at91sam9260_register_clocks();
340 /* Register GPIO subsystem */
341 at91_gpio_init(at91sam9260_gpio, 3);
344 /* --------------------------------------------------------------------
345 * Interrupt initialization
346 * -------------------------------------------------------------------- */
349 * The default interrupt priority levels (0 = lowest, 7 = highest).
351 static unsigned int at91sam9260_default_irq_priority[NR_AIC_IRQS] __initdata = {
352 7, /* Advanced Interrupt Controller */
353 7, /* System Peripherals */
354 1, /* Parallel IO Controller A */
355 1, /* Parallel IO Controller B */
356 1, /* Parallel IO Controller C */
357 0, /* Analog-to-Digital Converter */
361 0, /* Multimedia Card Interface */
362 2, /* USB Device Port */
363 6, /* Two-Wire Interface */
364 5, /* Serial Peripheral Interface 0 */
365 5, /* Serial Peripheral Interface 1 */
366 5, /* Serial Synchronous Controller */
369 0, /* Timer Counter 0 */
370 0, /* Timer Counter 1 */
371 0, /* Timer Counter 2 */
372 2, /* USB Host port */
374 0, /* Image Sensor Interface */
378 0, /* Timer Counter 3 */
379 0, /* Timer Counter 4 */
380 0, /* Timer Counter 5 */
381 0, /* Advanced Interrupt Controller */
382 0, /* Advanced Interrupt Controller */
383 0, /* Advanced Interrupt Controller */
386 void __init at91sam9260_init_interrupts(unsigned int priority[NR_AIC_IRQS])
389 priority = at91sam9260_default_irq_priority;
391 /* Initialize the AIC interrupt controller */
392 at91_aic_init(priority);
394 /* Enable GPIO interrupts */
395 at91_gpio_irq_setup();