blob: 0422593032fc8b24b8bbb0cb39efc2068e8fb5ed [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>
SAN People73a59c12006-01-09 17:05:41 +000018
Russell Kingea75ee92006-06-20 19:53:16 +010019#include <asm/hardware.h>
Andrew Victor10e8e1f2006-06-19 15:26:51 +010020#include "generic.h"
Andrew Victor2eeaaa22006-09-27 10:50:59 +010021#include "clock.h"
SAN People73a59c12006-01-09 17:05:41 +000022
23static struct map_desc at91rm9200_io_desc[] __initdata = {
24 {
25 .virtual = AT91_VA_BASE_SYS,
26 .pfn = __phys_to_pfn(AT91_BASE_SYS),
27 .length = SZ_4K,
28 .type = MT_DEVICE,
29 }, {
30 .virtual = AT91_VA_BASE_SPI,
Andrew Victor72729912006-09-27 09:44:11 +010031 .pfn = __phys_to_pfn(AT91RM9200_BASE_SPI),
SAN People73a59c12006-01-09 17:05:41 +000032 .length = SZ_16K,
33 .type = MT_DEVICE,
34 }, {
SAN People73a59c12006-01-09 17:05:41 +000035 .virtual = AT91_VA_BASE_EMAC,
Andrew Victor72729912006-09-27 09:44:11 +010036 .pfn = __phys_to_pfn(AT91RM9200_BASE_EMAC),
SAN People73a59c12006-01-09 17:05:41 +000037 .length = SZ_16K,
38 .type = MT_DEVICE,
39 }, {
40 .virtual = AT91_VA_BASE_TWI,
Andrew Victor72729912006-09-27 09:44:11 +010041 .pfn = __phys_to_pfn(AT91RM9200_BASE_TWI),
SAN People73a59c12006-01-09 17:05:41 +000042 .length = SZ_16K,
43 .type = MT_DEVICE,
44 }, {
45 .virtual = AT91_VA_BASE_MCI,
Andrew Victor72729912006-09-27 09:44:11 +010046 .pfn = __phys_to_pfn(AT91RM9200_BASE_MCI),
SAN People73a59c12006-01-09 17:05:41 +000047 .length = SZ_16K,
48 .type = MT_DEVICE,
49 }, {
50 .virtual = AT91_VA_BASE_UDP,
Andrew Victor72729912006-09-27 09:44:11 +010051 .pfn = __phys_to_pfn(AT91RM9200_BASE_UDP),
SAN People73a59c12006-01-09 17:05:41 +000052 .length = SZ_16K,
53 .type = MT_DEVICE,
54 }, {
Andrew Victor10e8e1f2006-06-19 15:26:51 +010055 .virtual = AT91_SRAM_VIRT_BASE,
Andrew Victor72729912006-09-27 09:44:11 +010056 .pfn = __phys_to_pfn(AT91RM9200_SRAM_BASE),
57 .length = AT91RM9200_SRAM_SIZE,
Andrew Victor10e8e1f2006-06-19 15:26:51 +010058 .type = MT_DEVICE,
SAN People73a59c12006-01-09 17:05:41 +000059 },
60};
61
Andrew Victor2eeaaa22006-09-27 10:50:59 +010062/* --------------------------------------------------------------------
63 * Clocks
64 * -------------------------------------------------------------------- */
65
66/*
67 * The peripheral clocks.
68 */
69static struct clk udc_clk = {
70 .name = "udc_clk",
71 .pmc_mask = 1 << AT91RM9200_ID_UDP,
72 .type = CLK_TYPE_PERIPHERAL,
73};
74static struct clk ohci_clk = {
75 .name = "ohci_clk",
76 .pmc_mask = 1 << AT91RM9200_ID_UHP,
77 .type = CLK_TYPE_PERIPHERAL,
78};
79static struct clk ether_clk = {
80 .name = "ether_clk",
81 .pmc_mask = 1 << AT91RM9200_ID_EMAC,
82 .type = CLK_TYPE_PERIPHERAL,
83};
84static struct clk mmc_clk = {
85 .name = "mci_clk",
86 .pmc_mask = 1 << AT91RM9200_ID_MCI,
87 .type = CLK_TYPE_PERIPHERAL,
88};
89static struct clk twi_clk = {
90 .name = "twi_clk",
91 .pmc_mask = 1 << AT91RM9200_ID_TWI,
92 .type = CLK_TYPE_PERIPHERAL,
93};
94static struct clk usart0_clk = {
95 .name = "usart0_clk",
96 .pmc_mask = 1 << AT91RM9200_ID_US0,
97 .type = CLK_TYPE_PERIPHERAL,
98};
99static struct clk usart1_clk = {
100 .name = "usart1_clk",
101 .pmc_mask = 1 << AT91RM9200_ID_US1,
102 .type = CLK_TYPE_PERIPHERAL,
103};
104static struct clk usart2_clk = {
105 .name = "usart2_clk",
106 .pmc_mask = 1 << AT91RM9200_ID_US2,
107 .type = CLK_TYPE_PERIPHERAL,
108};
109static struct clk usart3_clk = {
110 .name = "usart3_clk",
111 .pmc_mask = 1 << AT91RM9200_ID_US3,
112 .type = CLK_TYPE_PERIPHERAL,
113};
114static struct clk spi_clk = {
115 .name = "spi_clk",
116 .pmc_mask = 1 << AT91RM9200_ID_SPI,
117 .type = CLK_TYPE_PERIPHERAL,
118};
119static struct clk pioA_clk = {
120 .name = "pioA_clk",
121 .pmc_mask = 1 << AT91RM9200_ID_PIOA,
122 .type = CLK_TYPE_PERIPHERAL,
123};
124static struct clk pioB_clk = {
125 .name = "pioB_clk",
126 .pmc_mask = 1 << AT91RM9200_ID_PIOB,
127 .type = CLK_TYPE_PERIPHERAL,
128};
129static struct clk pioC_clk = {
130 .name = "pioC_clk",
131 .pmc_mask = 1 << AT91RM9200_ID_PIOC,
132 .type = CLK_TYPE_PERIPHERAL,
133};
134static struct clk pioD_clk = {
135 .name = "pioD_clk",
136 .pmc_mask = 1 << AT91RM9200_ID_PIOD,
137 .type = CLK_TYPE_PERIPHERAL,
138};
139
140static struct clk *periph_clocks[] __initdata = {
141 &pioA_clk,
142 &pioB_clk,
143 &pioC_clk,
144 &pioD_clk,
145 &usart0_clk,
146 &usart1_clk,
147 &usart2_clk,
148 &usart3_clk,
149 &mmc_clk,
150 &udc_clk,
151 &twi_clk,
152 &spi_clk,
153 // ssc 0 .. ssc2
154 // tc0 .. tc5
155 &ohci_clk,
156 &ether_clk,
157 // irq0 .. irq6
158};
159
160/*
161 * The four programmable clocks.
162 * You must configure pin multiplexing to bring these signals out.
163 */
164static struct clk pck0 = {
165 .name = "pck0",
166 .pmc_mask = AT91_PMC_PCK0,
167 .type = CLK_TYPE_PROGRAMMABLE,
168 .id = 0,
169};
170static struct clk pck1 = {
171 .name = "pck1",
172 .pmc_mask = AT91_PMC_PCK1,
173 .type = CLK_TYPE_PROGRAMMABLE,
174 .id = 1,
175};
176static struct clk pck2 = {
177 .name = "pck2",
178 .pmc_mask = AT91_PMC_PCK2,
179 .type = CLK_TYPE_PROGRAMMABLE,
180 .id = 2,
181};
182static struct clk pck3 = {
183 .name = "pck3",
184 .pmc_mask = AT91_PMC_PCK3,
185 .type = CLK_TYPE_PROGRAMMABLE,
186 .id = 3,
187};
188
189static void __init at91rm9200_register_clocks(void)
SAN People73a59c12006-01-09 17:05:41 +0000190{
Andrew Victor2eeaaa22006-09-27 10:50:59 +0100191 int i;
192
193 for (i = 0; i < ARRAY_SIZE(periph_clocks); i++)
194 clk_register(periph_clocks[i]);
195
196 clk_register(&pck0);
197 clk_register(&pck1);
198 clk_register(&pck2);
199 clk_register(&pck3);
200}
201
Andrew Victorf2173832006-09-27 13:23:00 +0100202/* --------------------------------------------------------------------
203 * GPIO
204 * -------------------------------------------------------------------- */
205
206static struct at91_gpio_bank at91rm9200_gpio[] = {
207 {
208 .id = AT91RM9200_ID_PIOA,
209 .offset = AT91_PIOA,
210 .clock = &pioA_clk,
211 }, {
212 .id = AT91RM9200_ID_PIOB,
213 .offset = AT91_PIOB,
214 .clock = &pioB_clk,
215 }, {
216 .id = AT91RM9200_ID_PIOC,
217 .offset = AT91_PIOC,
218 .clock = &pioC_clk,
219 }, {
220 .id = AT91RM9200_ID_PIOD,
221 .offset = AT91_PIOD,
222 .clock = &pioD_clk,
223 }
224};
Andrew Victor2eeaaa22006-09-27 10:50:59 +0100225
Andrew Victor1f4fd0a2006-11-30 10:01:47 +0100226static void at91rm9200_reset(void)
227{
228 /*
229 * Perform a hardware reset with the use of the Watchdog timer.
230 */
231 at91_sys_write(AT91_ST_WDMR, AT91_ST_RSTEN | AT91_ST_EXTEN | 1);
232 at91_sys_write(AT91_ST_CR, AT91_ST_WDRST);
233}
234
235
Andrew Victor2eeaaa22006-09-27 10:50:59 +0100236/* --------------------------------------------------------------------
237 * AT91RM9200 processor initialization
238 * -------------------------------------------------------------------- */
Andrew Victorf2173832006-09-27 13:23:00 +0100239void __init at91rm9200_initialize(unsigned long main_clock, unsigned short banks)
Andrew Victor2eeaaa22006-09-27 10:50:59 +0100240{
241 /* Map peripherals */
SAN People73a59c12006-01-09 17:05:41 +0000242 iotable_init(at91rm9200_io_desc, ARRAY_SIZE(at91rm9200_io_desc));
Andrew Victor2eeaaa22006-09-27 10:50:59 +0100243
Andrew Victor1f4fd0a2006-11-30 10:01:47 +0100244 at91_arch_reset = at91rm9200_reset;
245 at91_extern_irq = (1 << AT91RM9200_ID_IRQ0) | (1 << AT91RM9200_ID_IRQ1)
246 | (1 << AT91RM9200_ID_IRQ2) | (1 << AT91RM9200_ID_IRQ3)
247 | (1 << AT91RM9200_ID_IRQ4) | (1 << AT91RM9200_ID_IRQ5)
248 | (1 << AT91RM9200_ID_IRQ6);
249
Andrew Victor2eeaaa22006-09-27 10:50:59 +0100250 /* Init clock subsystem */
251 at91_clock_init(main_clock);
252
253 /* Register the processor-specific clocks */
254 at91rm9200_register_clocks();
Andrew Victorf2173832006-09-27 13:23:00 +0100255
256 /* Initialize GPIO subsystem */
257 at91_gpio_init(at91rm9200_gpio, banks);
SAN People73a59c12006-01-09 17:05:41 +0000258}
259
Andrew Victorf2173832006-09-27 13:23:00 +0100260
261/* --------------------------------------------------------------------
262 * Interrupt initialization
263 * -------------------------------------------------------------------- */
264
Andrew Victorba854e12006-07-05 17:22:52 +0100265/*
266 * The default interrupt priority levels (0 = lowest, 7 = highest).
267 */
268static unsigned int at91rm9200_default_irq_priority[NR_AIC_IRQS] __initdata = {
269 7, /* Advanced Interrupt Controller (FIQ) */
270 7, /* System Peripherals */
271 0, /* Parallel IO Controller A */
272 0, /* Parallel IO Controller B */
273 0, /* Parallel IO Controller C */
274 0, /* Parallel IO Controller D */
275 6, /* USART 0 */
276 6, /* USART 1 */
277 6, /* USART 2 */
278 6, /* USART 3 */
279 0, /* Multimedia Card Interface */
280 4, /* USB Device Port */
281 0, /* Two-Wire Interface */
282 6, /* Serial Peripheral Interface */
283 5, /* Serial Synchronous Controller 0 */
284 5, /* Serial Synchronous Controller 1 */
285 5, /* Serial Synchronous Controller 2 */
286 0, /* Timer Counter 0 */
287 0, /* Timer Counter 1 */
288 0, /* Timer Counter 2 */
289 0, /* Timer Counter 3 */
290 0, /* Timer Counter 4 */
291 0, /* Timer Counter 5 */
292 3, /* USB Host port */
293 3, /* Ethernet MAC */
294 0, /* Advanced Interrupt Controller (IRQ0) */
295 0, /* Advanced Interrupt Controller (IRQ1) */
296 0, /* Advanced Interrupt Controller (IRQ2) */
297 0, /* Advanced Interrupt Controller (IRQ3) */
298 0, /* Advanced Interrupt Controller (IRQ4) */
299 0, /* Advanced Interrupt Controller (IRQ5) */
300 0 /* Advanced Interrupt Controller (IRQ6) */
301};
302
Andrew Victorf2173832006-09-27 13:23:00 +0100303void __init at91rm9200_init_interrupts(unsigned int priority[NR_AIC_IRQS])
Andrew Victorba854e12006-07-05 17:22:52 +0100304{
305 if (!priority)
306 priority = at91rm9200_default_irq_priority;
307
Andrew Victorf2173832006-09-27 13:23:00 +0100308 /* Initialize the AIC interrupt controller */
Andrew Victorba854e12006-07-05 17:22:52 +0100309 at91_aic_init(priority);
Andrew Victorf2173832006-09-27 13:23:00 +0100310
311 /* Enable GPIO interrupts */
312 at91_gpio_irq_setup();
Andrew Victorba854e12006-07-05 17:22:52 +0100313}