2 * arch/arm/mach-at91/at91sam9263.c
4 * Copyright (C) 2007 Atmel Corporation.
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>
16 #include <asm/mach/arch.h>
17 #include <asm/mach/map.h>
18 #include <mach/at91sam9263.h>
19 #include <mach/at91_pmc.h>
20 #include <mach/at91_rstc.h>
27 /* --------------------------------------------------------------------
29 * -------------------------------------------------------------------- */
32 * The peripheral clocks.
34 static struct clk pioA_clk = {
36 .pmc_mask = 1 << AT91SAM9263_ID_PIOA,
37 .type = CLK_TYPE_PERIPHERAL,
39 static struct clk pioB_clk = {
41 .pmc_mask = 1 << AT91SAM9263_ID_PIOB,
42 .type = CLK_TYPE_PERIPHERAL,
44 static struct clk pioCDE_clk = {
46 .pmc_mask = 1 << AT91SAM9263_ID_PIOCDE,
47 .type = CLK_TYPE_PERIPHERAL,
49 static struct clk usart0_clk = {
51 .pmc_mask = 1 << AT91SAM9263_ID_US0,
52 .type = CLK_TYPE_PERIPHERAL,
54 static struct clk usart1_clk = {
56 .pmc_mask = 1 << AT91SAM9263_ID_US1,
57 .type = CLK_TYPE_PERIPHERAL,
59 static struct clk usart2_clk = {
61 .pmc_mask = 1 << AT91SAM9263_ID_US2,
62 .type = CLK_TYPE_PERIPHERAL,
64 static struct clk mmc0_clk = {
66 .pmc_mask = 1 << AT91SAM9263_ID_MCI0,
67 .type = CLK_TYPE_PERIPHERAL,
69 static struct clk mmc1_clk = {
71 .pmc_mask = 1 << AT91SAM9263_ID_MCI1,
72 .type = CLK_TYPE_PERIPHERAL,
74 static struct clk can_clk = {
76 .pmc_mask = 1 << AT91SAM9263_ID_CAN,
77 .type = CLK_TYPE_PERIPHERAL,
79 static struct clk twi_clk = {
81 .pmc_mask = 1 << AT91SAM9263_ID_TWI,
82 .type = CLK_TYPE_PERIPHERAL,
84 static struct clk spi0_clk = {
86 .pmc_mask = 1 << AT91SAM9263_ID_SPI0,
87 .type = CLK_TYPE_PERIPHERAL,
89 static struct clk spi1_clk = {
91 .pmc_mask = 1 << AT91SAM9263_ID_SPI1,
92 .type = CLK_TYPE_PERIPHERAL,
94 static struct clk ssc0_clk = {
96 .pmc_mask = 1 << AT91SAM9263_ID_SSC0,
97 .type = CLK_TYPE_PERIPHERAL,
99 static struct clk ssc1_clk = {
101 .pmc_mask = 1 << AT91SAM9263_ID_SSC1,
102 .type = CLK_TYPE_PERIPHERAL,
104 static struct clk ac97_clk = {
106 .pmc_mask = 1 << AT91SAM9263_ID_AC97C,
107 .type = CLK_TYPE_PERIPHERAL,
109 static struct clk tcb_clk = {
111 .pmc_mask = 1 << AT91SAM9263_ID_TCB,
112 .type = CLK_TYPE_PERIPHERAL,
114 static struct clk pwm_clk = {
116 .pmc_mask = 1 << AT91SAM9263_ID_PWMC,
117 .type = CLK_TYPE_PERIPHERAL,
119 static struct clk macb_clk = {
121 .pmc_mask = 1 << AT91SAM9263_ID_EMAC,
122 .type = CLK_TYPE_PERIPHERAL,
124 static struct clk dma_clk = {
126 .pmc_mask = 1 << AT91SAM9263_ID_DMA,
127 .type = CLK_TYPE_PERIPHERAL,
129 static struct clk twodge_clk = {
131 .pmc_mask = 1 << AT91SAM9263_ID_2DGE,
132 .type = CLK_TYPE_PERIPHERAL,
134 static struct clk udc_clk = {
136 .pmc_mask = 1 << AT91SAM9263_ID_UDP,
137 .type = CLK_TYPE_PERIPHERAL,
139 static struct clk isi_clk = {
141 .pmc_mask = 1 << AT91SAM9263_ID_ISI,
142 .type = CLK_TYPE_PERIPHERAL,
144 static struct clk lcdc_clk = {
146 .pmc_mask = 1 << AT91SAM9263_ID_LCDC,
147 .type = CLK_TYPE_PERIPHERAL,
149 static struct clk ohci_clk = {
151 .pmc_mask = 1 << AT91SAM9263_ID_UHP,
152 .type = CLK_TYPE_PERIPHERAL,
155 static struct clk *periph_clocks[] __initdata = {
183 static struct clk_lookup periph_clocks_lookups[] = {
184 /* One additional fake clock for macb_hclk */
185 CLKDEV_CON_ID("hclk", &macb_clk),
186 CLKDEV_CON_DEV_ID("pclk", "ssc.0", &ssc0_clk),
187 CLKDEV_CON_DEV_ID("pclk", "ssc.1", &ssc1_clk),
188 CLKDEV_CON_DEV_ID("mci_clk", "at91_mci.0", &mmc0_clk),
189 CLKDEV_CON_DEV_ID("mci_clk", "at91_mci.1", &mmc1_clk),
190 CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi.0", &spi0_clk),
191 CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi.1", &spi1_clk),
192 CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.0", &tcb_clk),
193 /* fake hclk clock */
194 CLKDEV_CON_DEV_ID("hclk", "at91_ohci", &ohci_clk),
195 CLKDEV_CON_ID("pioA", &pioA_clk),
196 CLKDEV_CON_ID("pioB", &pioB_clk),
197 CLKDEV_CON_ID("pioC", &pioCDE_clk),
198 CLKDEV_CON_ID("pioD", &pioCDE_clk),
199 CLKDEV_CON_ID("pioE", &pioCDE_clk),
202 static struct clk_lookup usart_clocks_lookups[] = {
203 CLKDEV_CON_DEV_ID("usart", "atmel_usart.0", &mck),
204 CLKDEV_CON_DEV_ID("usart", "atmel_usart.1", &usart0_clk),
205 CLKDEV_CON_DEV_ID("usart", "atmel_usart.2", &usart1_clk),
206 CLKDEV_CON_DEV_ID("usart", "atmel_usart.3", &usart2_clk),
210 * The four programmable clocks.
211 * You must configure pin multiplexing to bring these signals out.
213 static struct clk pck0 = {
215 .pmc_mask = AT91_PMC_PCK0,
216 .type = CLK_TYPE_PROGRAMMABLE,
219 static struct clk pck1 = {
221 .pmc_mask = AT91_PMC_PCK1,
222 .type = CLK_TYPE_PROGRAMMABLE,
225 static struct clk pck2 = {
227 .pmc_mask = AT91_PMC_PCK2,
228 .type = CLK_TYPE_PROGRAMMABLE,
231 static struct clk pck3 = {
233 .pmc_mask = AT91_PMC_PCK3,
234 .type = CLK_TYPE_PROGRAMMABLE,
238 static void __init at91sam9263_register_clocks(void)
242 for (i = 0; i < ARRAY_SIZE(periph_clocks); i++)
243 clk_register(periph_clocks[i]);
245 clkdev_add_table(periph_clocks_lookups,
246 ARRAY_SIZE(periph_clocks_lookups));
247 clkdev_add_table(usart_clocks_lookups,
248 ARRAY_SIZE(usart_clocks_lookups));
256 static struct clk_lookup console_clock_lookup;
258 void __init at91sam9263_set_console_clock(int id)
260 if (id >= ARRAY_SIZE(usart_clocks_lookups))
263 console_clock_lookup.con_id = "usart";
264 console_clock_lookup.clk = usart_clocks_lookups[id].clk;
265 clkdev_add(&console_clock_lookup);
268 /* --------------------------------------------------------------------
270 * -------------------------------------------------------------------- */
272 static struct at91_gpio_bank at91sam9263_gpio[] __initdata = {
274 .id = AT91SAM9263_ID_PIOA,
275 .regbase = AT91SAM9263_BASE_PIOA,
277 .id = AT91SAM9263_ID_PIOB,
278 .regbase = AT91SAM9263_BASE_PIOB,
280 .id = AT91SAM9263_ID_PIOCDE,
281 .regbase = AT91SAM9263_BASE_PIOC,
283 .id = AT91SAM9263_ID_PIOCDE,
284 .regbase = AT91SAM9263_BASE_PIOD,
286 .id = AT91SAM9263_ID_PIOCDE,
287 .regbase = AT91SAM9263_BASE_PIOE,
291 /* --------------------------------------------------------------------
292 * AT91SAM9263 processor initialization
293 * -------------------------------------------------------------------- */
295 static void __init at91sam9263_map_io(void)
297 at91_init_sram(0, AT91SAM9263_SRAM0_BASE, AT91SAM9263_SRAM0_SIZE);
298 at91_init_sram(1, AT91SAM9263_SRAM1_BASE, AT91SAM9263_SRAM1_SIZE);
301 static void __init at91sam9263_ioremap_registers(void)
303 at91_ioremap_shdwc(AT91SAM9263_BASE_SHDWC);
304 at91sam926x_ioremap_pit(AT91SAM9263_BASE_PIT);
305 at91sam9_ioremap_smc(0, AT91SAM9263_BASE_SMC0);
306 at91sam9_ioremap_smc(1, AT91SAM9263_BASE_SMC1);
309 static void __init at91sam9263_initialize(void)
311 arm_pm_restart = at91sam9_alt_restart;
312 at91_extern_irq = (1 << AT91SAM9263_ID_IRQ0) | (1 << AT91SAM9263_ID_IRQ1);
314 /* Register GPIO subsystem */
315 at91_gpio_init(at91sam9263_gpio, 5);
318 /* --------------------------------------------------------------------
319 * Interrupt initialization
320 * -------------------------------------------------------------------- */
323 * The default interrupt priority levels (0 = lowest, 7 = highest).
325 static unsigned int at91sam9263_default_irq_priority[NR_AIC_IRQS] __initdata = {
326 7, /* Advanced Interrupt Controller (FIQ) */
327 7, /* System Peripherals */
328 1, /* Parallel IO Controller A */
329 1, /* Parallel IO Controller B */
330 1, /* Parallel IO Controller C, D and E */
336 0, /* Multimedia Card Interface 0 */
337 0, /* Multimedia Card Interface 1 */
339 6, /* Two-Wire Interface */
340 5, /* Serial Peripheral Interface 0 */
341 5, /* Serial Peripheral Interface 1 */
342 4, /* Serial Synchronous Controller 0 */
343 4, /* Serial Synchronous Controller 1 */
344 5, /* AC97 Controller */
345 0, /* Timer Counter 0, 1 and 2 */
346 0, /* Pulse Width Modulation Controller */
349 0, /* 2D Graphic Engine */
350 2, /* USB Device Port */
351 0, /* Image Sensor Interface */
352 3, /* LDC Controller */
353 0, /* DMA Controller */
355 2, /* USB Host port */
356 0, /* Advanced Interrupt Controller (IRQ0) */
357 0, /* Advanced Interrupt Controller (IRQ1) */
360 struct at91_init_soc __initdata at91sam9263_soc = {
361 .map_io = at91sam9263_map_io,
362 .default_irq_priority = at91sam9263_default_irq_priority,
363 .ioremap_registers = at91sam9263_ioremap_registers,
364 .register_clocks = at91sam9263_register_clocks,
365 .init = at91sam9263_initialize,