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>
15 #include <asm/mach/arch.h>
16 #include <asm/mach/map.h>
17 #include <asm/arch/cpu.h>
18 #include <asm/arch/at91sam9260.h>
19 #include <asm/arch/at91_pmc.h>
20 #include <asm/arch/at91_rstc.h>
25 static struct map_desc at91sam9260_io_desc
[] __initdata
= {
27 .virtual = AT91_VA_BASE_SYS
,
28 .pfn
= __phys_to_pfn(AT91_BASE_SYS
),
34 static struct map_desc at91sam9260_sram_desc
[] __initdata
= {
36 .virtual = AT91_IO_VIRT_BASE
- AT91SAM9260_SRAM0_SIZE
,
37 .pfn
= __phys_to_pfn(AT91SAM9260_SRAM0_BASE
),
38 .length
= AT91SAM9260_SRAM0_SIZE
,
41 .virtual = AT91_IO_VIRT_BASE
- AT91SAM9260_SRAM0_SIZE
- AT91SAM9260_SRAM1_SIZE
,
42 .pfn
= __phys_to_pfn(AT91SAM9260_SRAM1_BASE
),
43 .length
= AT91SAM9260_SRAM1_SIZE
,
48 static struct map_desc at91sam9xe_sram_desc
[] __initdata
= {
50 .pfn
= __phys_to_pfn(AT91SAM9XE_SRAM_BASE
),
55 /* --------------------------------------------------------------------
57 * -------------------------------------------------------------------- */
60 * The peripheral clocks.
62 static struct clk pioA_clk
= {
64 .pmc_mask
= 1 << AT91SAM9260_ID_PIOA
,
65 .type
= CLK_TYPE_PERIPHERAL
,
67 static struct clk pioB_clk
= {
69 .pmc_mask
= 1 << AT91SAM9260_ID_PIOB
,
70 .type
= CLK_TYPE_PERIPHERAL
,
72 static struct clk pioC_clk
= {
74 .pmc_mask
= 1 << AT91SAM9260_ID_PIOC
,
75 .type
= CLK_TYPE_PERIPHERAL
,
77 static struct clk adc_clk
= {
79 .pmc_mask
= 1 << AT91SAM9260_ID_ADC
,
80 .type
= CLK_TYPE_PERIPHERAL
,
82 static struct clk usart0_clk
= {
84 .pmc_mask
= 1 << AT91SAM9260_ID_US0
,
85 .type
= CLK_TYPE_PERIPHERAL
,
87 static struct clk usart1_clk
= {
89 .pmc_mask
= 1 << AT91SAM9260_ID_US1
,
90 .type
= CLK_TYPE_PERIPHERAL
,
92 static struct clk usart2_clk
= {
94 .pmc_mask
= 1 << AT91SAM9260_ID_US2
,
95 .type
= CLK_TYPE_PERIPHERAL
,
97 static struct clk mmc_clk
= {
99 .pmc_mask
= 1 << AT91SAM9260_ID_MCI
,
100 .type
= CLK_TYPE_PERIPHERAL
,
102 static struct clk udc_clk
= {
104 .pmc_mask
= 1 << AT91SAM9260_ID_UDP
,
105 .type
= CLK_TYPE_PERIPHERAL
,
107 static struct clk twi_clk
= {
109 .pmc_mask
= 1 << AT91SAM9260_ID_TWI
,
110 .type
= CLK_TYPE_PERIPHERAL
,
112 static struct clk spi0_clk
= {
114 .pmc_mask
= 1 << AT91SAM9260_ID_SPI0
,
115 .type
= CLK_TYPE_PERIPHERAL
,
117 static struct clk spi1_clk
= {
119 .pmc_mask
= 1 << AT91SAM9260_ID_SPI1
,
120 .type
= CLK_TYPE_PERIPHERAL
,
122 static struct clk ssc_clk
= {
124 .pmc_mask
= 1 << AT91SAM9260_ID_SSC
,
125 .type
= CLK_TYPE_PERIPHERAL
,
127 static struct clk tc0_clk
= {
129 .pmc_mask
= 1 << AT91SAM9260_ID_TC0
,
130 .type
= CLK_TYPE_PERIPHERAL
,
132 static struct clk tc1_clk
= {
134 .pmc_mask
= 1 << AT91SAM9260_ID_TC1
,
135 .type
= CLK_TYPE_PERIPHERAL
,
137 static struct clk tc2_clk
= {
139 .pmc_mask
= 1 << AT91SAM9260_ID_TC2
,
140 .type
= CLK_TYPE_PERIPHERAL
,
142 static struct clk ohci_clk
= {
144 .pmc_mask
= 1 << AT91SAM9260_ID_UHP
,
145 .type
= CLK_TYPE_PERIPHERAL
,
147 static struct clk macb_clk
= {
149 .pmc_mask
= 1 << AT91SAM9260_ID_EMAC
,
150 .type
= CLK_TYPE_PERIPHERAL
,
152 static struct clk isi_clk
= {
154 .pmc_mask
= 1 << AT91SAM9260_ID_ISI
,
155 .type
= CLK_TYPE_PERIPHERAL
,
157 static struct clk usart3_clk
= {
158 .name
= "usart3_clk",
159 .pmc_mask
= 1 << AT91SAM9260_ID_US3
,
160 .type
= CLK_TYPE_PERIPHERAL
,
162 static struct clk usart4_clk
= {
163 .name
= "usart4_clk",
164 .pmc_mask
= 1 << AT91SAM9260_ID_US4
,
165 .type
= CLK_TYPE_PERIPHERAL
,
167 static struct clk usart5_clk
= {
168 .name
= "usart5_clk",
169 .pmc_mask
= 1 << AT91SAM9260_ID_US5
,
170 .type
= CLK_TYPE_PERIPHERAL
,
172 static struct clk tc3_clk
= {
174 .pmc_mask
= 1 << AT91SAM9260_ID_TC3
,
175 .type
= CLK_TYPE_PERIPHERAL
,
177 static struct clk tc4_clk
= {
179 .pmc_mask
= 1 << AT91SAM9260_ID_TC4
,
180 .type
= CLK_TYPE_PERIPHERAL
,
182 static struct clk tc5_clk
= {
184 .pmc_mask
= 1 << AT91SAM9260_ID_TC5
,
185 .type
= CLK_TYPE_PERIPHERAL
,
188 static struct clk
*periph_clocks
[] __initdata
= {
218 * The two programmable clocks.
219 * You must configure pin multiplexing to bring these signals out.
221 static struct clk pck0
= {
223 .pmc_mask
= AT91_PMC_PCK0
,
224 .type
= CLK_TYPE_PROGRAMMABLE
,
227 static struct clk pck1
= {
229 .pmc_mask
= AT91_PMC_PCK1
,
230 .type
= CLK_TYPE_PROGRAMMABLE
,
234 static void __init
at91sam9260_register_clocks(void)
238 for (i
= 0; i
< ARRAY_SIZE(periph_clocks
); i
++)
239 clk_register(periph_clocks
[i
]);
245 /* --------------------------------------------------------------------
247 * -------------------------------------------------------------------- */
249 static struct at91_gpio_bank at91sam9260_gpio
[] = {
251 .id
= AT91SAM9260_ID_PIOA
,
255 .id
= AT91SAM9260_ID_PIOB
,
259 .id
= AT91SAM9260_ID_PIOC
,
265 static void at91sam9260_reset(void)
267 at91_sys_write(AT91_RSTC_CR
, AT91_RSTC_KEY
| AT91_RSTC_PROCRST
| AT91_RSTC_PERRST
);
271 /* --------------------------------------------------------------------
272 * AT91SAM9260 processor initialization
273 * -------------------------------------------------------------------- */
275 static void __init
at91sam9xe_initialize(void)
277 unsigned long cidr
, sram_size
;
279 cidr
= at91_sys_read(AT91_DBGU_CIDR
);
281 switch (cidr
& AT91_CIDR_SRAMSIZ
) {
282 case AT91_CIDR_SRAMSIZ_32K
:
283 sram_size
= 2 * SZ_16K
;
285 case AT91_CIDR_SRAMSIZ_16K
:
290 at91sam9xe_sram_desc
->virtual = AT91_IO_VIRT_BASE
- sram_size
;
291 at91sam9xe_sram_desc
->length
= sram_size
;
293 iotable_init(at91sam9xe_sram_desc
, ARRAY_SIZE(at91sam9xe_sram_desc
));
296 void __init
at91sam9260_initialize(unsigned long main_clock
)
298 /* Map peripherals */
299 iotable_init(at91sam9260_io_desc
, ARRAY_SIZE(at91sam9260_io_desc
));
301 if (cpu_is_at91sam9xe())
302 at91sam9xe_initialize();
304 iotable_init(at91sam9260_sram_desc
, ARRAY_SIZE(at91sam9260_sram_desc
));
306 at91_arch_reset
= at91sam9260_reset
;
307 at91_extern_irq
= (1 << AT91SAM9260_ID_IRQ0
) | (1 << AT91SAM9260_ID_IRQ1
)
308 | (1 << AT91SAM9260_ID_IRQ2
);
310 /* Init clock subsystem */
311 at91_clock_init(main_clock
);
313 /* Register the processor-specific clocks */
314 at91sam9260_register_clocks();
316 /* Register GPIO subsystem */
317 at91_gpio_init(at91sam9260_gpio
, 3);
320 /* --------------------------------------------------------------------
321 * Interrupt initialization
322 * -------------------------------------------------------------------- */
325 * The default interrupt priority levels (0 = lowest, 7 = highest).
327 static unsigned int at91sam9260_default_irq_priority
[NR_AIC_IRQS
] __initdata
= {
328 7, /* Advanced Interrupt Controller */
329 7, /* System Peripherals */
330 1, /* Parallel IO Controller A */
331 1, /* Parallel IO Controller B */
332 1, /* Parallel IO Controller C */
333 0, /* Analog-to-Digital Converter */
337 0, /* Multimedia Card Interface */
338 2, /* USB Device Port */
339 6, /* Two-Wire Interface */
340 5, /* Serial Peripheral Interface 0 */
341 5, /* Serial Peripheral Interface 1 */
342 5, /* Serial Synchronous Controller */
345 0, /* Timer Counter 0 */
346 0, /* Timer Counter 1 */
347 0, /* Timer Counter 2 */
348 2, /* USB Host port */
350 0, /* Image Sensor Interface */
354 0, /* Timer Counter 3 */
355 0, /* Timer Counter 4 */
356 0, /* Timer Counter 5 */
357 0, /* Advanced Interrupt Controller */
358 0, /* Advanced Interrupt Controller */
359 0, /* Advanced Interrupt Controller */
362 void __init
at91sam9260_init_interrupts(unsigned int priority
[NR_AIC_IRQS
])
365 priority
= at91sam9260_default_irq_priority
;
367 /* Initialize the AIC interrupt controller */
368 at91_aic_init(priority
);
370 /* Enable GPIO interrupts */
371 at91_gpio_irq_setup();