]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/arm/mach-at91rm9200/at91rm9200.c
0816a8d2e863a76d08fd8f34d888fc73adb405e3
[linux-2.6-omap-h63xx.git] / arch / arm / mach-at91rm9200 / at91rm9200.c
1 /*
2  * arch/arm/mach-at91rm9200/at91rm9200.c
3  *
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
13 #include <linux/module.h>
14
15 #include <asm/mach/arch.h>
16 #include <asm/mach/map.h>
17 #include <asm/arch/at91rm9200.h>
18 #include <asm/arch/at91_pmc.h>
19 #include <asm/arch/at91_st.h>
20
21 #include "generic.h"
22 #include "clock.h"
23
24 static 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,
32                 .pfn            = __phys_to_pfn(AT91RM9200_BASE_SPI),
33                 .length         = SZ_16K,
34                 .type           = MT_DEVICE,
35         }, {
36                 .virtual        = AT91_VA_BASE_EMAC,
37                 .pfn            = __phys_to_pfn(AT91RM9200_BASE_EMAC),
38                 .length         = SZ_16K,
39                 .type           = MT_DEVICE,
40         }, {
41                 .virtual        = AT91_VA_BASE_TWI,
42                 .pfn            = __phys_to_pfn(AT91RM9200_BASE_TWI),
43                 .length         = SZ_16K,
44                 .type           = MT_DEVICE,
45         }, {
46                 .virtual        = AT91_VA_BASE_MCI,
47                 .pfn            = __phys_to_pfn(AT91RM9200_BASE_MCI),
48                 .length         = SZ_16K,
49                 .type           = MT_DEVICE,
50         }, {
51                 .virtual        = AT91_VA_BASE_UDP,
52                 .pfn            = __phys_to_pfn(AT91RM9200_BASE_UDP),
53                 .length         = SZ_16K,
54                 .type           = MT_DEVICE,
55         }, {
56                 .virtual        = AT91_SRAM_VIRT_BASE,
57                 .pfn            = __phys_to_pfn(AT91RM9200_SRAM_BASE),
58                 .length         = AT91RM9200_SRAM_SIZE,
59                 .type           = MT_DEVICE,
60         },
61 };
62
63 /* --------------------------------------------------------------------
64  *  Clocks
65  * -------------------------------------------------------------------- */
66
67 /*
68  * The peripheral clocks.
69  */
70 static struct clk udc_clk = {
71         .name           = "udc_clk",
72         .pmc_mask       = 1 << AT91RM9200_ID_UDP,
73         .type           = CLK_TYPE_PERIPHERAL,
74 };
75 static struct clk ohci_clk = {
76         .name           = "ohci_clk",
77         .pmc_mask       = 1 << AT91RM9200_ID_UHP,
78         .type           = CLK_TYPE_PERIPHERAL,
79 };
80 static struct clk ether_clk = {
81         .name           = "ether_clk",
82         .pmc_mask       = 1 << AT91RM9200_ID_EMAC,
83         .type           = CLK_TYPE_PERIPHERAL,
84 };
85 static struct clk mmc_clk = {
86         .name           = "mci_clk",
87         .pmc_mask       = 1 << AT91RM9200_ID_MCI,
88         .type           = CLK_TYPE_PERIPHERAL,
89 };
90 static struct clk twi_clk = {
91         .name           = "twi_clk",
92         .pmc_mask       = 1 << AT91RM9200_ID_TWI,
93         .type           = CLK_TYPE_PERIPHERAL,
94 };
95 static struct clk usart0_clk = {
96         .name           = "usart0_clk",
97         .pmc_mask       = 1 << AT91RM9200_ID_US0,
98         .type           = CLK_TYPE_PERIPHERAL,
99 };
100 static struct clk usart1_clk = {
101         .name           = "usart1_clk",
102         .pmc_mask       = 1 << AT91RM9200_ID_US1,
103         .type           = CLK_TYPE_PERIPHERAL,
104 };
105 static struct clk usart2_clk = {
106         .name           = "usart2_clk",
107         .pmc_mask       = 1 << AT91RM9200_ID_US2,
108         .type           = CLK_TYPE_PERIPHERAL,
109 };
110 static struct clk usart3_clk = {
111         .name           = "usart3_clk",
112         .pmc_mask       = 1 << AT91RM9200_ID_US3,
113         .type           = CLK_TYPE_PERIPHERAL,
114 };
115 static struct clk spi_clk = {
116         .name           = "spi_clk",
117         .pmc_mask       = 1 << AT91RM9200_ID_SPI,
118         .type           = CLK_TYPE_PERIPHERAL,
119 };
120 static struct clk pioA_clk = {
121         .name           = "pioA_clk",
122         .pmc_mask       = 1 << AT91RM9200_ID_PIOA,
123         .type           = CLK_TYPE_PERIPHERAL,
124 };
125 static struct clk pioB_clk = {
126         .name           = "pioB_clk",
127         .pmc_mask       = 1 << AT91RM9200_ID_PIOB,
128         .type           = CLK_TYPE_PERIPHERAL,
129 };
130 static struct clk pioC_clk = {
131         .name           = "pioC_clk",
132         .pmc_mask       = 1 << AT91RM9200_ID_PIOC,
133         .type           = CLK_TYPE_PERIPHERAL,
134 };
135 static struct clk pioD_clk = {
136         .name           = "pioD_clk",
137         .pmc_mask       = 1 << AT91RM9200_ID_PIOD,
138         .type           = CLK_TYPE_PERIPHERAL,
139 };
140
141 static 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  */
165 static struct clk pck0 = {
166         .name           = "pck0",
167         .pmc_mask       = AT91_PMC_PCK0,
168         .type           = CLK_TYPE_PROGRAMMABLE,
169         .id             = 0,
170 };
171 static struct clk pck1 = {
172         .name           = "pck1",
173         .pmc_mask       = AT91_PMC_PCK1,
174         .type           = CLK_TYPE_PROGRAMMABLE,
175         .id             = 1,
176 };
177 static struct clk pck2 = {
178         .name           = "pck2",
179         .pmc_mask       = AT91_PMC_PCK2,
180         .type           = CLK_TYPE_PROGRAMMABLE,
181         .id             = 2,
182 };
183 static struct clk pck3 = {
184         .name           = "pck3",
185         .pmc_mask       = AT91_PMC_PCK3,
186         .type           = CLK_TYPE_PROGRAMMABLE,
187         .id             = 3,
188 };
189
190 static void __init at91rm9200_register_clocks(void)
191 {
192         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
203 /* --------------------------------------------------------------------
204  *  GPIO
205  * -------------------------------------------------------------------- */
206
207 static 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 };
226
227 static 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
237 /* --------------------------------------------------------------------
238  *  AT91RM9200 processor initialization
239  * -------------------------------------------------------------------- */
240 void __init at91rm9200_initialize(unsigned long main_clock, unsigned short banks)
241 {
242         /* Map peripherals */
243         iotable_init(at91rm9200_io_desc, ARRAY_SIZE(at91rm9200_io_desc));
244
245         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
251         /* Init clock subsystem */
252         at91_clock_init(main_clock);
253
254         /* Register the processor-specific clocks */
255         at91rm9200_register_clocks();
256
257         /* Initialize GPIO subsystem */
258         at91_gpio_init(at91rm9200_gpio, banks);
259 }
260
261
262 /* --------------------------------------------------------------------
263  *  Interrupt initialization
264  * -------------------------------------------------------------------- */
265
266 /*
267  * The default interrupt priority levels (0 = lowest, 7 = highest).
268  */
269 static 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
304 void __init at91rm9200_init_interrupts(unsigned int priority[NR_AIC_IRQS])
305 {
306         if (!priority)
307                 priority = at91rm9200_default_irq_priority;
308
309         /* Initialize the AIC interrupt controller */
310         at91_aic_init(priority);
311
312         /* Enable GPIO interrupts */
313         at91_gpio_irq_setup();
314 }