blob: 0816a8d2e863a76d08fd8f34d888fc73adb405e3 [file] [log] [blame]
SAN People73a59c12006-01-09 17:05:41 +00001/*
Andrew Victor8fc5ffa2006-06-29 16:06:33 +01002 * arch/arm/mach-at91rm9200/at91rm9200.c
SAN People73a59c12006-01-09 17:05:41 +00003 *
4 * Copyright (C) 2005 SAN People
5 *
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.
10 *
11 */
12
SAN People73a59c12006-01-09 17:05:41 +000013#include <linux/module.h>
14
15#include <asm/mach/arch.h>
16#include <asm/mach/map.h>
Andrew Victor1f4fd0a2006-11-30 10:01:47 +010017#include <asm/arch/at91rm9200.h>
Andrew Victor55d8bae2006-11-30 17:16:43 +010018#include <asm/arch/at91_pmc.h>
19#include <asm/arch/at91_st.h>
SAN People73a59c12006-01-09 17:05:41 +000020
Andrew Victor10e8e1f2006-06-19 15:26:51 +010021#include "generic.h"
Andrew Victor2eeaaa22006-09-27 10:50:59 +010022#include "clock.h"
SAN People73a59c12006-01-09 17:05:41 +000023
24static struct map_desc at91rm9200_io_desc[] __initdata = {
25 {
26 .virtual = AT91_VA_BASE_SYS,
27 .pfn = __phys_to_pfn(AT91_BASE_SYS),
28 .length = SZ_4K,
29 .type = MT_DEVICE,
30 }, {
31 .virtual = AT91_VA_BASE_SPI,
Andrew Victor72729912006-09-27 09:44:11 +010032 .pfn = __phys_to_pfn(AT91RM9200_BASE_SPI),
SAN People73a59c12006-01-09 17:05:41 +000033 .length = SZ_16K,
34 .type = MT_DEVICE,
35 }, {
SAN People73a59c12006-01-09 17:05:41 +000036 .virtual = AT91_VA_BASE_EMAC,
Andrew Victor72729912006-09-27 09:44:11 +010037 .pfn = __phys_to_pfn(AT91RM9200_BASE_EMAC),
SAN People73a59c12006-01-09 17:05:41 +000038 .length = SZ_16K,
39 .type = MT_DEVICE,
40 }, {
41 .virtual = AT91_VA_BASE_TWI,
Andrew Victor72729912006-09-27 09:44:11 +010042 .pfn = __phys_to_pfn(AT91RM9200_BASE_TWI),
SAN People73a59c12006-01-09 17:05:41 +000043 .length = SZ_16K,
44 .type = MT_DEVICE,
45 }, {
46 .virtual = AT91_VA_BASE_MCI,
Andrew Victor72729912006-09-27 09:44:11 +010047 .pfn = __phys_to_pfn(AT91RM9200_BASE_MCI),
SAN People73a59c12006-01-09 17:05:41 +000048 .length = SZ_16K,
49 .type = MT_DEVICE,
50 }, {
51 .virtual = AT91_VA_BASE_UDP,
Andrew Victor72729912006-09-27 09:44:11 +010052 .pfn = __phys_to_pfn(AT91RM9200_BASE_UDP),
SAN People73a59c12006-01-09 17:05:41 +000053 .length = SZ_16K,
54 .type = MT_DEVICE,
55 }, {
Andrew Victor10e8e1f2006-06-19 15:26:51 +010056 .virtual = AT91_SRAM_VIRT_BASE,
Andrew Victor72729912006-09-27 09:44:11 +010057 .pfn = __phys_to_pfn(AT91RM9200_SRAM_BASE),
58 .length = AT91RM9200_SRAM_SIZE,
Andrew Victor10e8e1f2006-06-19 15:26:51 +010059 .type = MT_DEVICE,
SAN People73a59c12006-01-09 17:05:41 +000060 },
61};
62
Andrew Victor2eeaaa22006-09-27 10:50:59 +010063/* --------------------------------------------------------------------
64 * Clocks
65 * -------------------------------------------------------------------- */
66
67/*
68 * The peripheral clocks.
69 */
70static struct clk udc_clk = {
71 .name = "udc_clk",
72 .pmc_mask = 1 << AT91RM9200_ID_UDP,
73 .type = CLK_TYPE_PERIPHERAL,
74};
75static struct clk ohci_clk = {
76 .name = "ohci_clk",
77 .pmc_mask = 1 << AT91RM9200_ID_UHP,
78 .type = CLK_TYPE_PERIPHERAL,
79};
80static struct clk ether_clk = {
81 .name = "ether_clk",
82 .pmc_mask = 1 << AT91RM9200_ID_EMAC,
83 .type = CLK_TYPE_PERIPHERAL,
84};
85static struct clk mmc_clk = {
86 .name = "mci_clk",
87 .pmc_mask = 1 << AT91RM9200_ID_MCI,
88 .type = CLK_TYPE_PERIPHERAL,
89};
90static struct clk twi_clk = {
91 .name = "twi_clk",
92 .pmc_mask = 1 << AT91RM9200_ID_TWI,
93 .type = CLK_TYPE_PERIPHERAL,
94};
95static struct clk usart0_clk = {
96 .name = "usart0_clk",
97 .pmc_mask = 1 << AT91RM9200_ID_US0,
98 .type = CLK_TYPE_PERIPHERAL,
99};
100static struct clk usart1_clk = {
101 .name = "usart1_clk",
102 .pmc_mask = 1 << AT91RM9200_ID_US1,
103 .type = CLK_TYPE_PERIPHERAL,
104};
105static struct clk usart2_clk = {
106 .name = "usart2_clk",
107 .pmc_mask = 1 << AT91RM9200_ID_US2,
108 .type = CLK_TYPE_PERIPHERAL,
109};
110static struct clk usart3_clk = {
111 .name = "usart3_clk",
112 .pmc_mask = 1 << AT91RM9200_ID_US3,
113 .type = CLK_TYPE_PERIPHERAL,
114};
115static struct clk spi_clk = {
116 .name = "spi_clk",
117 .pmc_mask = 1 << AT91RM9200_ID_SPI,
118 .type = CLK_TYPE_PERIPHERAL,
119};
120static struct clk pioA_clk = {
121 .name = "pioA_clk",
122 .pmc_mask = 1 << AT91RM9200_ID_PIOA,
123 .type = CLK_TYPE_PERIPHERAL,
124};
125static struct clk pioB_clk = {
126 .name = "pioB_clk",
127 .pmc_mask = 1 << AT91RM9200_ID_PIOB,
128 .type = CLK_TYPE_PERIPHERAL,
129};
130static struct clk pioC_clk = {
131 .name = "pioC_clk",
132 .pmc_mask = 1 << AT91RM9200_ID_PIOC,
133 .type = CLK_TYPE_PERIPHERAL,
134};
135static struct clk pioD_clk = {
136 .name = "pioD_clk",
137 .pmc_mask = 1 << AT91RM9200_ID_PIOD,
138 .type = CLK_TYPE_PERIPHERAL,
139};
140
141static struct clk *periph_clocks[] __initdata = {
142 &pioA_clk,
143 &pioB_clk,
144 &pioC_clk,
145 &pioD_clk,
146 &usart0_clk,
147 &usart1_clk,
148 &usart2_clk,
149 &usart3_clk,
150 &mmc_clk,
151 &udc_clk,
152 &twi_clk,
153 &spi_clk,
154 // ssc 0 .. ssc2
155 // tc0 .. tc5
156 &ohci_clk,
157 &ether_clk,
158 // irq0 .. irq6
159};
160
161/*
162 * The four programmable clocks.
163 * You must configure pin multiplexing to bring these signals out.
164 */
165static struct clk pck0 = {
166 .name = "pck0",
167 .pmc_mask = AT91_PMC_PCK0,
168 .type = CLK_TYPE_PROGRAMMABLE,
169 .id = 0,
170};
171static struct clk pck1 = {
172 .name = "pck1",
173 .pmc_mask = AT91_PMC_PCK1,
174 .type = CLK_TYPE_PROGRAMMABLE,
175 .id = 1,
176};
177static struct clk pck2 = {
178 .name = "pck2",
179 .pmc_mask = AT91_PMC_PCK2,
180 .type = CLK_TYPE_PROGRAMMABLE,
181 .id = 2,
182};
183static struct clk pck3 = {
184 .name = "pck3",
185 .pmc_mask = AT91_PMC_PCK3,
186 .type = CLK_TYPE_PROGRAMMABLE,
187 .id = 3,
188};
189
190static void __init at91rm9200_register_clocks(void)
SAN People73a59c12006-01-09 17:05:41 +0000191{
Andrew Victor2eeaaa22006-09-27 10:50:59 +0100192 int i;
193
194 for (i = 0; i < ARRAY_SIZE(periph_clocks); i++)
195 clk_register(periph_clocks[i]);
196
197 clk_register(&pck0);
198 clk_register(&pck1);
199 clk_register(&pck2);
200 clk_register(&pck3);
201}
202
Andrew Victorf2173832006-09-27 13:23:00 +0100203/* --------------------------------------------------------------------
204 * GPIO
205 * -------------------------------------------------------------------- */
206
207static struct at91_gpio_bank at91rm9200_gpio[] = {
208 {
209 .id = AT91RM9200_ID_PIOA,
210 .offset = AT91_PIOA,
211 .clock = &pioA_clk,
212 }, {
213 .id = AT91RM9200_ID_PIOB,
214 .offset = AT91_PIOB,
215 .clock = &pioB_clk,
216 }, {
217 .id = AT91RM9200_ID_PIOC,
218 .offset = AT91_PIOC,
219 .clock = &pioC_clk,
220 }, {
221 .id = AT91RM9200_ID_PIOD,
222 .offset = AT91_PIOD,
223 .clock = &pioD_clk,
224 }
225};
Andrew Victor2eeaaa22006-09-27 10:50:59 +0100226
Andrew Victor1f4fd0a2006-11-30 10:01:47 +0100227static void at91rm9200_reset(void)
228{
229 /*
230 * Perform a hardware reset with the use of the Watchdog timer.
231 */
232 at91_sys_write(AT91_ST_WDMR, AT91_ST_RSTEN | AT91_ST_EXTEN | 1);
233 at91_sys_write(AT91_ST_CR, AT91_ST_WDRST);
234}
235
236
Andrew Victor2eeaaa22006-09-27 10:50:59 +0100237/* --------------------------------------------------------------------
238 * AT91RM9200 processor initialization
239 * -------------------------------------------------------------------- */
Andrew Victorf2173832006-09-27 13:23:00 +0100240void __init at91rm9200_initialize(unsigned long main_clock, unsigned short banks)
Andrew Victor2eeaaa22006-09-27 10:50:59 +0100241{
242 /* Map peripherals */
SAN People73a59c12006-01-09 17:05:41 +0000243 iotable_init(at91rm9200_io_desc, ARRAY_SIZE(at91rm9200_io_desc));
Andrew Victor2eeaaa22006-09-27 10:50:59 +0100244
Andrew Victor1f4fd0a2006-11-30 10:01:47 +0100245 at91_arch_reset = at91rm9200_reset;
246 at91_extern_irq = (1 << AT91RM9200_ID_IRQ0) | (1 << AT91RM9200_ID_IRQ1)
247 | (1 << AT91RM9200_ID_IRQ2) | (1 << AT91RM9200_ID_IRQ3)
248 | (1 << AT91RM9200_ID_IRQ4) | (1 << AT91RM9200_ID_IRQ5)
249 | (1 << AT91RM9200_ID_IRQ6);
250
Andrew Victor2eeaaa22006-09-27 10:50:59 +0100251 /* Init clock subsystem */
252 at91_clock_init(main_clock);
253
254 /* Register the processor-specific clocks */
255 at91rm9200_register_clocks();
Andrew Victorf2173832006-09-27 13:23:00 +0100256
257 /* Initialize GPIO subsystem */
258 at91_gpio_init(at91rm9200_gpio, banks);
SAN People73a59c12006-01-09 17:05:41 +0000259}
260
Andrew Victorf2173832006-09-27 13:23:00 +0100261
262/* --------------------------------------------------------------------
263 * Interrupt initialization
264 * -------------------------------------------------------------------- */
265
Andrew Victorba854e12006-07-05 17:22:52 +0100266/*
267 * The default interrupt priority levels (0 = lowest, 7 = highest).
268 */
269static unsigned int at91rm9200_default_irq_priority[NR_AIC_IRQS] __initdata = {
270 7, /* Advanced Interrupt Controller (FIQ) */
271 7, /* System Peripherals */
272 0, /* Parallel IO Controller A */
273 0, /* Parallel IO Controller B */
274 0, /* Parallel IO Controller C */
275 0, /* Parallel IO Controller D */
276 6, /* USART 0 */
277 6, /* USART 1 */
278 6, /* USART 2 */
279 6, /* USART 3 */
280 0, /* Multimedia Card Interface */
281 4, /* USB Device Port */
282 0, /* Two-Wire Interface */
283 6, /* Serial Peripheral Interface */
284 5, /* Serial Synchronous Controller 0 */
285 5, /* Serial Synchronous Controller 1 */
286 5, /* Serial Synchronous Controller 2 */
287 0, /* Timer Counter 0 */
288 0, /* Timer Counter 1 */
289 0, /* Timer Counter 2 */
290 0, /* Timer Counter 3 */
291 0, /* Timer Counter 4 */
292 0, /* Timer Counter 5 */
293 3, /* USB Host port */
294 3, /* Ethernet MAC */
295 0, /* Advanced Interrupt Controller (IRQ0) */
296 0, /* Advanced Interrupt Controller (IRQ1) */
297 0, /* Advanced Interrupt Controller (IRQ2) */
298 0, /* Advanced Interrupt Controller (IRQ3) */
299 0, /* Advanced Interrupt Controller (IRQ4) */
300 0, /* Advanced Interrupt Controller (IRQ5) */
301 0 /* Advanced Interrupt Controller (IRQ6) */
302};
303
Andrew Victorf2173832006-09-27 13:23:00 +0100304void __init at91rm9200_init_interrupts(unsigned int priority[NR_AIC_IRQS])
Andrew Victorba854e12006-07-05 17:22:52 +0100305{
306 if (!priority)
307 priority = at91rm9200_default_irq_priority;
308
Andrew Victorf2173832006-09-27 13:23:00 +0100309 /* Initialize the AIC interrupt controller */
Andrew Victorba854e12006-07-05 17:22:52 +0100310 at91_aic_init(priority);
Andrew Victorf2173832006-09-27 13:23:00 +0100311
312 /* Enable GPIO interrupts */
313 at91_gpio_irq_setup();
Andrew Victorba854e12006-07-05 17:22:52 +0100314}