SAN People | 73a59c1 | 2006-01-09 17:05:41 +0000 | [diff] [blame] | 1 | /* |
Andrew Victor | 8fc5ffa | 2006-06-29 16:06:33 +0100 | [diff] [blame] | 2 | * arch/arm/mach-at91rm9200/at91rm9200.c |
SAN People | 73a59c1 | 2006-01-09 17:05:41 +0000 | [diff] [blame] | 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 | |
SAN People | 73a59c1 | 2006-01-09 17:05:41 +0000 | [diff] [blame] | 13 | #include <linux/module.h> |
| 14 | |
| 15 | #include <asm/mach/arch.h> |
| 16 | #include <asm/mach/map.h> |
| 17 | |
Russell King | ea75ee9 | 2006-06-20 19:53:16 +0100 | [diff] [blame] | 18 | #include <asm/hardware.h> |
Andrew Victor | 10e8e1f | 2006-06-19 15:26:51 +0100 | [diff] [blame] | 19 | #include "generic.h" |
Andrew Victor | 2eeaaa2 | 2006-09-27 10:50:59 +0100 | [diff] [blame^] | 20 | #include "clock.h" |
SAN People | 73a59c1 | 2006-01-09 17:05:41 +0000 | [diff] [blame] | 21 | |
| 22 | static struct map_desc at91rm9200_io_desc[] __initdata = { |
| 23 | { |
| 24 | .virtual = AT91_VA_BASE_SYS, |
| 25 | .pfn = __phys_to_pfn(AT91_BASE_SYS), |
| 26 | .length = SZ_4K, |
| 27 | .type = MT_DEVICE, |
| 28 | }, { |
| 29 | .virtual = AT91_VA_BASE_SPI, |
Andrew Victor | 7272991 | 2006-09-27 09:44:11 +0100 | [diff] [blame] | 30 | .pfn = __phys_to_pfn(AT91RM9200_BASE_SPI), |
SAN People | 73a59c1 | 2006-01-09 17:05:41 +0000 | [diff] [blame] | 31 | .length = SZ_16K, |
| 32 | .type = MT_DEVICE, |
| 33 | }, { |
| 34 | .virtual = AT91_VA_BASE_SSC2, |
Andrew Victor | 7272991 | 2006-09-27 09:44:11 +0100 | [diff] [blame] | 35 | .pfn = __phys_to_pfn(AT91RM9200_BASE_SSC2), |
SAN People | 73a59c1 | 2006-01-09 17:05:41 +0000 | [diff] [blame] | 36 | .length = SZ_16K, |
| 37 | .type = MT_DEVICE, |
| 38 | }, { |
| 39 | .virtual = AT91_VA_BASE_SSC1, |
Andrew Victor | 7272991 | 2006-09-27 09:44:11 +0100 | [diff] [blame] | 40 | .pfn = __phys_to_pfn(AT91RM9200_BASE_SSC1), |
SAN People | 73a59c1 | 2006-01-09 17:05:41 +0000 | [diff] [blame] | 41 | .length = SZ_16K, |
| 42 | .type = MT_DEVICE, |
| 43 | }, { |
| 44 | .virtual = AT91_VA_BASE_SSC0, |
Andrew Victor | 7272991 | 2006-09-27 09:44:11 +0100 | [diff] [blame] | 45 | .pfn = __phys_to_pfn(AT91RM9200_BASE_SSC0), |
SAN People | 73a59c1 | 2006-01-09 17:05:41 +0000 | [diff] [blame] | 46 | .length = SZ_16K, |
| 47 | .type = MT_DEVICE, |
| 48 | }, { |
| 49 | .virtual = AT91_VA_BASE_US3, |
Andrew Victor | 7272991 | 2006-09-27 09:44:11 +0100 | [diff] [blame] | 50 | .pfn = __phys_to_pfn(AT91RM9200_BASE_US3), |
SAN People | 73a59c1 | 2006-01-09 17:05:41 +0000 | [diff] [blame] | 51 | .length = SZ_16K, |
| 52 | .type = MT_DEVICE, |
| 53 | }, { |
| 54 | .virtual = AT91_VA_BASE_US2, |
Andrew Victor | 7272991 | 2006-09-27 09:44:11 +0100 | [diff] [blame] | 55 | .pfn = __phys_to_pfn(AT91RM9200_BASE_US2), |
SAN People | 73a59c1 | 2006-01-09 17:05:41 +0000 | [diff] [blame] | 56 | .length = SZ_16K, |
| 57 | .type = MT_DEVICE, |
| 58 | }, { |
| 59 | .virtual = AT91_VA_BASE_US1, |
Andrew Victor | 7272991 | 2006-09-27 09:44:11 +0100 | [diff] [blame] | 60 | .pfn = __phys_to_pfn(AT91RM9200_BASE_US1), |
SAN People | 73a59c1 | 2006-01-09 17:05:41 +0000 | [diff] [blame] | 61 | .length = SZ_16K, |
| 62 | .type = MT_DEVICE, |
| 63 | }, { |
| 64 | .virtual = AT91_VA_BASE_US0, |
Andrew Victor | 7272991 | 2006-09-27 09:44:11 +0100 | [diff] [blame] | 65 | .pfn = __phys_to_pfn(AT91RM9200_BASE_US0), |
SAN People | 73a59c1 | 2006-01-09 17:05:41 +0000 | [diff] [blame] | 66 | .length = SZ_16K, |
| 67 | .type = MT_DEVICE, |
| 68 | }, { |
| 69 | .virtual = AT91_VA_BASE_EMAC, |
Andrew Victor | 7272991 | 2006-09-27 09:44:11 +0100 | [diff] [blame] | 70 | .pfn = __phys_to_pfn(AT91RM9200_BASE_EMAC), |
SAN People | 73a59c1 | 2006-01-09 17:05:41 +0000 | [diff] [blame] | 71 | .length = SZ_16K, |
| 72 | .type = MT_DEVICE, |
| 73 | }, { |
| 74 | .virtual = AT91_VA_BASE_TWI, |
Andrew Victor | 7272991 | 2006-09-27 09:44:11 +0100 | [diff] [blame] | 75 | .pfn = __phys_to_pfn(AT91RM9200_BASE_TWI), |
SAN People | 73a59c1 | 2006-01-09 17:05:41 +0000 | [diff] [blame] | 76 | .length = SZ_16K, |
| 77 | .type = MT_DEVICE, |
| 78 | }, { |
| 79 | .virtual = AT91_VA_BASE_MCI, |
Andrew Victor | 7272991 | 2006-09-27 09:44:11 +0100 | [diff] [blame] | 80 | .pfn = __phys_to_pfn(AT91RM9200_BASE_MCI), |
SAN People | 73a59c1 | 2006-01-09 17:05:41 +0000 | [diff] [blame] | 81 | .length = SZ_16K, |
| 82 | .type = MT_DEVICE, |
| 83 | }, { |
| 84 | .virtual = AT91_VA_BASE_UDP, |
Andrew Victor | 7272991 | 2006-09-27 09:44:11 +0100 | [diff] [blame] | 85 | .pfn = __phys_to_pfn(AT91RM9200_BASE_UDP), |
SAN People | 73a59c1 | 2006-01-09 17:05:41 +0000 | [diff] [blame] | 86 | .length = SZ_16K, |
| 87 | .type = MT_DEVICE, |
| 88 | }, { |
| 89 | .virtual = AT91_VA_BASE_TCB1, |
Andrew Victor | 7272991 | 2006-09-27 09:44:11 +0100 | [diff] [blame] | 90 | .pfn = __phys_to_pfn(AT91RM9200_BASE_TCB1), |
SAN People | 73a59c1 | 2006-01-09 17:05:41 +0000 | [diff] [blame] | 91 | .length = SZ_16K, |
| 92 | .type = MT_DEVICE, |
| 93 | }, { |
| 94 | .virtual = AT91_VA_BASE_TCB0, |
Andrew Victor | 7272991 | 2006-09-27 09:44:11 +0100 | [diff] [blame] | 95 | .pfn = __phys_to_pfn(AT91RM9200_BASE_TCB0), |
SAN People | 73a59c1 | 2006-01-09 17:05:41 +0000 | [diff] [blame] | 96 | .length = SZ_16K, |
| 97 | .type = MT_DEVICE, |
Andrew Victor | 10e8e1f | 2006-06-19 15:26:51 +0100 | [diff] [blame] | 98 | }, { |
| 99 | .virtual = AT91_SRAM_VIRT_BASE, |
Andrew Victor | 7272991 | 2006-09-27 09:44:11 +0100 | [diff] [blame] | 100 | .pfn = __phys_to_pfn(AT91RM9200_SRAM_BASE), |
| 101 | .length = AT91RM9200_SRAM_SIZE, |
Andrew Victor | 10e8e1f | 2006-06-19 15:26:51 +0100 | [diff] [blame] | 102 | .type = MT_DEVICE, |
SAN People | 73a59c1 | 2006-01-09 17:05:41 +0000 | [diff] [blame] | 103 | }, |
| 104 | }; |
| 105 | |
Andrew Victor | 2eeaaa2 | 2006-09-27 10:50:59 +0100 | [diff] [blame^] | 106 | /* -------------------------------------------------------------------- |
| 107 | * Clocks |
| 108 | * -------------------------------------------------------------------- */ |
| 109 | |
| 110 | /* |
| 111 | * The peripheral clocks. |
| 112 | */ |
| 113 | static struct clk udc_clk = { |
| 114 | .name = "udc_clk", |
| 115 | .pmc_mask = 1 << AT91RM9200_ID_UDP, |
| 116 | .type = CLK_TYPE_PERIPHERAL, |
| 117 | }; |
| 118 | static struct clk ohci_clk = { |
| 119 | .name = "ohci_clk", |
| 120 | .pmc_mask = 1 << AT91RM9200_ID_UHP, |
| 121 | .type = CLK_TYPE_PERIPHERAL, |
| 122 | }; |
| 123 | static struct clk ether_clk = { |
| 124 | .name = "ether_clk", |
| 125 | .pmc_mask = 1 << AT91RM9200_ID_EMAC, |
| 126 | .type = CLK_TYPE_PERIPHERAL, |
| 127 | }; |
| 128 | static struct clk mmc_clk = { |
| 129 | .name = "mci_clk", |
| 130 | .pmc_mask = 1 << AT91RM9200_ID_MCI, |
| 131 | .type = CLK_TYPE_PERIPHERAL, |
| 132 | }; |
| 133 | static struct clk twi_clk = { |
| 134 | .name = "twi_clk", |
| 135 | .pmc_mask = 1 << AT91RM9200_ID_TWI, |
| 136 | .type = CLK_TYPE_PERIPHERAL, |
| 137 | }; |
| 138 | static struct clk usart0_clk = { |
| 139 | .name = "usart0_clk", |
| 140 | .pmc_mask = 1 << AT91RM9200_ID_US0, |
| 141 | .type = CLK_TYPE_PERIPHERAL, |
| 142 | }; |
| 143 | static struct clk usart1_clk = { |
| 144 | .name = "usart1_clk", |
| 145 | .pmc_mask = 1 << AT91RM9200_ID_US1, |
| 146 | .type = CLK_TYPE_PERIPHERAL, |
| 147 | }; |
| 148 | static struct clk usart2_clk = { |
| 149 | .name = "usart2_clk", |
| 150 | .pmc_mask = 1 << AT91RM9200_ID_US2, |
| 151 | .type = CLK_TYPE_PERIPHERAL, |
| 152 | }; |
| 153 | static struct clk usart3_clk = { |
| 154 | .name = "usart3_clk", |
| 155 | .pmc_mask = 1 << AT91RM9200_ID_US3, |
| 156 | .type = CLK_TYPE_PERIPHERAL, |
| 157 | }; |
| 158 | static struct clk spi_clk = { |
| 159 | .name = "spi_clk", |
| 160 | .pmc_mask = 1 << AT91RM9200_ID_SPI, |
| 161 | .type = CLK_TYPE_PERIPHERAL, |
| 162 | }; |
| 163 | static struct clk pioA_clk = { |
| 164 | .name = "pioA_clk", |
| 165 | .pmc_mask = 1 << AT91RM9200_ID_PIOA, |
| 166 | .type = CLK_TYPE_PERIPHERAL, |
| 167 | }; |
| 168 | static struct clk pioB_clk = { |
| 169 | .name = "pioB_clk", |
| 170 | .pmc_mask = 1 << AT91RM9200_ID_PIOB, |
| 171 | .type = CLK_TYPE_PERIPHERAL, |
| 172 | }; |
| 173 | static struct clk pioC_clk = { |
| 174 | .name = "pioC_clk", |
| 175 | .pmc_mask = 1 << AT91RM9200_ID_PIOC, |
| 176 | .type = CLK_TYPE_PERIPHERAL, |
| 177 | }; |
| 178 | static struct clk pioD_clk = { |
| 179 | .name = "pioD_clk", |
| 180 | .pmc_mask = 1 << AT91RM9200_ID_PIOD, |
| 181 | .type = CLK_TYPE_PERIPHERAL, |
| 182 | }; |
| 183 | |
| 184 | static struct clk *periph_clocks[] __initdata = { |
| 185 | &pioA_clk, |
| 186 | &pioB_clk, |
| 187 | &pioC_clk, |
| 188 | &pioD_clk, |
| 189 | &usart0_clk, |
| 190 | &usart1_clk, |
| 191 | &usart2_clk, |
| 192 | &usart3_clk, |
| 193 | &mmc_clk, |
| 194 | &udc_clk, |
| 195 | &twi_clk, |
| 196 | &spi_clk, |
| 197 | // ssc 0 .. ssc2 |
| 198 | // tc0 .. tc5 |
| 199 | &ohci_clk, |
| 200 | ðer_clk, |
| 201 | // irq0 .. irq6 |
| 202 | }; |
| 203 | |
| 204 | /* |
| 205 | * The four programmable clocks. |
| 206 | * You must configure pin multiplexing to bring these signals out. |
| 207 | */ |
| 208 | static struct clk pck0 = { |
| 209 | .name = "pck0", |
| 210 | .pmc_mask = AT91_PMC_PCK0, |
| 211 | .type = CLK_TYPE_PROGRAMMABLE, |
| 212 | .id = 0, |
| 213 | }; |
| 214 | static struct clk pck1 = { |
| 215 | .name = "pck1", |
| 216 | .pmc_mask = AT91_PMC_PCK1, |
| 217 | .type = CLK_TYPE_PROGRAMMABLE, |
| 218 | .id = 1, |
| 219 | }; |
| 220 | static struct clk pck2 = { |
| 221 | .name = "pck2", |
| 222 | .pmc_mask = AT91_PMC_PCK2, |
| 223 | .type = CLK_TYPE_PROGRAMMABLE, |
| 224 | .id = 2, |
| 225 | }; |
| 226 | static struct clk pck3 = { |
| 227 | .name = "pck3", |
| 228 | .pmc_mask = AT91_PMC_PCK3, |
| 229 | .type = CLK_TYPE_PROGRAMMABLE, |
| 230 | .id = 3, |
| 231 | }; |
| 232 | |
| 233 | static void __init at91rm9200_register_clocks(void) |
SAN People | 73a59c1 | 2006-01-09 17:05:41 +0000 | [diff] [blame] | 234 | { |
Andrew Victor | 2eeaaa2 | 2006-09-27 10:50:59 +0100 | [diff] [blame^] | 235 | int i; |
| 236 | |
| 237 | for (i = 0; i < ARRAY_SIZE(periph_clocks); i++) |
| 238 | clk_register(periph_clocks[i]); |
| 239 | |
| 240 | clk_register(&pck0); |
| 241 | clk_register(&pck1); |
| 242 | clk_register(&pck2); |
| 243 | clk_register(&pck3); |
| 244 | } |
| 245 | |
| 246 | |
| 247 | /* -------------------------------------------------------------------- |
| 248 | * AT91RM9200 processor initialization |
| 249 | * -------------------------------------------------------------------- */ |
| 250 | void __init at91rm9200_initialize(unsigned long main_clock) |
| 251 | { |
| 252 | /* Map peripherals */ |
SAN People | 73a59c1 | 2006-01-09 17:05:41 +0000 | [diff] [blame] | 253 | iotable_init(at91rm9200_io_desc, ARRAY_SIZE(at91rm9200_io_desc)); |
Andrew Victor | 2eeaaa2 | 2006-09-27 10:50:59 +0100 | [diff] [blame^] | 254 | |
| 255 | /* Init clock subsystem */ |
| 256 | at91_clock_init(main_clock); |
| 257 | |
| 258 | /* Register the processor-specific clocks */ |
| 259 | at91rm9200_register_clocks(); |
SAN People | 73a59c1 | 2006-01-09 17:05:41 +0000 | [diff] [blame] | 260 | } |
| 261 | |
Andrew Victor | ba854e1 | 2006-07-05 17:22:52 +0100 | [diff] [blame] | 262 | /* |
| 263 | * The default interrupt priority levels (0 = lowest, 7 = highest). |
| 264 | */ |
| 265 | static unsigned int at91rm9200_default_irq_priority[NR_AIC_IRQS] __initdata = { |
| 266 | 7, /* Advanced Interrupt Controller (FIQ) */ |
| 267 | 7, /* System Peripherals */ |
| 268 | 0, /* Parallel IO Controller A */ |
| 269 | 0, /* Parallel IO Controller B */ |
| 270 | 0, /* Parallel IO Controller C */ |
| 271 | 0, /* Parallel IO Controller D */ |
| 272 | 6, /* USART 0 */ |
| 273 | 6, /* USART 1 */ |
| 274 | 6, /* USART 2 */ |
| 275 | 6, /* USART 3 */ |
| 276 | 0, /* Multimedia Card Interface */ |
| 277 | 4, /* USB Device Port */ |
| 278 | 0, /* Two-Wire Interface */ |
| 279 | 6, /* Serial Peripheral Interface */ |
| 280 | 5, /* Serial Synchronous Controller 0 */ |
| 281 | 5, /* Serial Synchronous Controller 1 */ |
| 282 | 5, /* Serial Synchronous Controller 2 */ |
| 283 | 0, /* Timer Counter 0 */ |
| 284 | 0, /* Timer Counter 1 */ |
| 285 | 0, /* Timer Counter 2 */ |
| 286 | 0, /* Timer Counter 3 */ |
| 287 | 0, /* Timer Counter 4 */ |
| 288 | 0, /* Timer Counter 5 */ |
| 289 | 3, /* USB Host port */ |
| 290 | 3, /* Ethernet MAC */ |
| 291 | 0, /* Advanced Interrupt Controller (IRQ0) */ |
| 292 | 0, /* Advanced Interrupt Controller (IRQ1) */ |
| 293 | 0, /* Advanced Interrupt Controller (IRQ2) */ |
| 294 | 0, /* Advanced Interrupt Controller (IRQ3) */ |
| 295 | 0, /* Advanced Interrupt Controller (IRQ4) */ |
| 296 | 0, /* Advanced Interrupt Controller (IRQ5) */ |
| 297 | 0 /* Advanced Interrupt Controller (IRQ6) */ |
| 298 | }; |
| 299 | |
| 300 | void __init at91rm9200_init_irq(unsigned int priority[NR_AIC_IRQS]) |
| 301 | { |
| 302 | if (!priority) |
| 303 | priority = at91rm9200_default_irq_priority; |
| 304 | |
| 305 | at91_aic_init(priority); |
| 306 | } |