2 * Chip-specific setup code for the AT91SAM9G45 family
4 * Copyright (C) 2009 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>
17 #include <asm/mach/arch.h>
18 #include <asm/mach/map.h>
19 #include <mach/at91sam9g45.h>
20 #include <mach/at91_pmc.h>
21 #include <mach/at91_rstc.h>
22 #include <mach/at91_shdwc.h>
29 static struct map_desc at91sam9g45_sram_desc[] __initdata = {
31 .virtual = AT91_IO_VIRT_BASE - AT91SAM9G45_SRAM_SIZE,
32 .pfn = __phys_to_pfn(AT91SAM9G45_SRAM_BASE),
33 .length = AT91SAM9G45_SRAM_SIZE,
38 /* --------------------------------------------------------------------
40 * -------------------------------------------------------------------- */
43 * The peripheral clocks.
45 static struct clk pioA_clk = {
47 .pmc_mask = 1 << AT91SAM9G45_ID_PIOA,
48 .type = CLK_TYPE_PERIPHERAL,
50 static struct clk pioB_clk = {
52 .pmc_mask = 1 << AT91SAM9G45_ID_PIOB,
53 .type = CLK_TYPE_PERIPHERAL,
55 static struct clk pioC_clk = {
57 .pmc_mask = 1 << AT91SAM9G45_ID_PIOC,
58 .type = CLK_TYPE_PERIPHERAL,
60 static struct clk pioDE_clk = {
62 .pmc_mask = 1 << AT91SAM9G45_ID_PIODE,
63 .type = CLK_TYPE_PERIPHERAL,
65 static struct clk usart0_clk = {
67 .pmc_mask = 1 << AT91SAM9G45_ID_US0,
68 .type = CLK_TYPE_PERIPHERAL,
70 static struct clk usart1_clk = {
72 .pmc_mask = 1 << AT91SAM9G45_ID_US1,
73 .type = CLK_TYPE_PERIPHERAL,
75 static struct clk usart2_clk = {
77 .pmc_mask = 1 << AT91SAM9G45_ID_US2,
78 .type = CLK_TYPE_PERIPHERAL,
80 static struct clk usart3_clk = {
82 .pmc_mask = 1 << AT91SAM9G45_ID_US3,
83 .type = CLK_TYPE_PERIPHERAL,
85 static struct clk mmc0_clk = {
87 .pmc_mask = 1 << AT91SAM9G45_ID_MCI0,
88 .type = CLK_TYPE_PERIPHERAL,
90 static struct clk twi0_clk = {
92 .pmc_mask = 1 << AT91SAM9G45_ID_TWI0,
93 .type = CLK_TYPE_PERIPHERAL,
95 static struct clk twi1_clk = {
97 .pmc_mask = 1 << AT91SAM9G45_ID_TWI1,
98 .type = CLK_TYPE_PERIPHERAL,
100 static struct clk spi0_clk = {
102 .pmc_mask = 1 << AT91SAM9G45_ID_SPI0,
103 .type = CLK_TYPE_PERIPHERAL,
105 static struct clk spi1_clk = {
107 .pmc_mask = 1 << AT91SAM9G45_ID_SPI1,
108 .type = CLK_TYPE_PERIPHERAL,
110 static struct clk ssc0_clk = {
112 .pmc_mask = 1 << AT91SAM9G45_ID_SSC0,
113 .type = CLK_TYPE_PERIPHERAL,
115 static struct clk ssc1_clk = {
117 .pmc_mask = 1 << AT91SAM9G45_ID_SSC1,
118 .type = CLK_TYPE_PERIPHERAL,
120 static struct clk tcb0_clk = {
122 .pmc_mask = 1 << AT91SAM9G45_ID_TCB,
123 .type = CLK_TYPE_PERIPHERAL,
125 static struct clk pwm_clk = {
127 .pmc_mask = 1 << AT91SAM9G45_ID_PWMC,
128 .type = CLK_TYPE_PERIPHERAL,
130 static struct clk tsc_clk = {
132 .pmc_mask = 1 << AT91SAM9G45_ID_TSC,
133 .type = CLK_TYPE_PERIPHERAL,
135 static struct clk dma_clk = {
137 .pmc_mask = 1 << AT91SAM9G45_ID_DMA,
138 .type = CLK_TYPE_PERIPHERAL,
140 static struct clk uhphs_clk = {
142 .pmc_mask = 1 << AT91SAM9G45_ID_UHPHS,
143 .type = CLK_TYPE_PERIPHERAL,
145 static struct clk lcdc_clk = {
147 .pmc_mask = 1 << AT91SAM9G45_ID_LCDC,
148 .type = CLK_TYPE_PERIPHERAL,
150 static struct clk ac97_clk = {
152 .pmc_mask = 1 << AT91SAM9G45_ID_AC97C,
153 .type = CLK_TYPE_PERIPHERAL,
155 static struct clk macb_clk = {
157 .pmc_mask = 1 << AT91SAM9G45_ID_EMAC,
158 .type = CLK_TYPE_PERIPHERAL,
160 static struct clk isi_clk = {
162 .pmc_mask = 1 << AT91SAM9G45_ID_ISI,
163 .type = CLK_TYPE_PERIPHERAL,
165 static struct clk udphs_clk = {
167 .pmc_mask = 1 << AT91SAM9G45_ID_UDPHS,
168 .type = CLK_TYPE_PERIPHERAL,
170 static struct clk mmc1_clk = {
172 .pmc_mask = 1 << AT91SAM9G45_ID_MCI1,
173 .type = CLK_TYPE_PERIPHERAL,
176 /* Video decoder clock - Only for sam9m10/sam9m11 */
177 static struct clk vdec_clk = {
179 .pmc_mask = 1 << AT91SAM9G45_ID_VDEC,
180 .type = CLK_TYPE_PERIPHERAL,
183 static struct clk *periph_clocks[] __initdata = {
213 static struct clk_lookup periph_clocks_lookups[] = {
214 /* One additional fake clock for ohci */
215 CLKDEV_CON_ID("ohci_clk", &uhphs_clk),
216 CLKDEV_CON_DEV_ID("ehci_clk", "atmel-ehci", &uhphs_clk),
217 CLKDEV_CON_DEV_ID("hclk", "atmel_usba_udc", &utmi_clk),
218 CLKDEV_CON_DEV_ID("pclk", "atmel_usba_udc", &udphs_clk),
219 CLKDEV_CON_DEV_ID("mci_clk", "atmel_mci.0", &mmc0_clk),
220 CLKDEV_CON_DEV_ID("mci_clk", "atmel_mci.1", &mmc1_clk),
221 CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi.0", &spi0_clk),
222 CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi.1", &spi1_clk),
223 CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.0", &tcb0_clk),
224 CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.1", &tcb0_clk),
225 CLKDEV_CON_DEV_ID("pclk", "ssc.0", &ssc0_clk),
226 CLKDEV_CON_DEV_ID("pclk", "ssc.1", &ssc1_clk),
229 static struct clk_lookup usart_clocks_lookups[] = {
230 CLKDEV_CON_DEV_ID("usart", "atmel_usart.0", &mck),
231 CLKDEV_CON_DEV_ID("usart", "atmel_usart.1", &usart0_clk),
232 CLKDEV_CON_DEV_ID("usart", "atmel_usart.2", &usart1_clk),
233 CLKDEV_CON_DEV_ID("usart", "atmel_usart.3", &usart2_clk),
234 CLKDEV_CON_DEV_ID("usart", "atmel_usart.4", &usart3_clk),
238 * The two programmable clocks.
239 * You must configure pin multiplexing to bring these signals out.
241 static struct clk pck0 = {
243 .pmc_mask = AT91_PMC_PCK0,
244 .type = CLK_TYPE_PROGRAMMABLE,
247 static struct clk pck1 = {
249 .pmc_mask = AT91_PMC_PCK1,
250 .type = CLK_TYPE_PROGRAMMABLE,
254 static void __init at91sam9g45_register_clocks(void)
258 for (i = 0; i < ARRAY_SIZE(periph_clocks); i++)
259 clk_register(periph_clocks[i]);
261 clkdev_add_table(periph_clocks_lookups,
262 ARRAY_SIZE(periph_clocks_lookups));
263 clkdev_add_table(usart_clocks_lookups,
264 ARRAY_SIZE(usart_clocks_lookups));
266 if (cpu_is_at91sam9m10() || cpu_is_at91sam9m11())
267 clk_register(&vdec_clk);
273 static struct clk_lookup console_clock_lookup;
275 void __init at91sam9g45_set_console_clock(int id)
277 if (id >= ARRAY_SIZE(usart_clocks_lookups))
280 console_clock_lookup.con_id = "usart";
281 console_clock_lookup.clk = usart_clocks_lookups[id].clk;
282 clkdev_add(&console_clock_lookup);
285 /* --------------------------------------------------------------------
287 * -------------------------------------------------------------------- */
289 static struct at91_gpio_bank at91sam9g45_gpio[] = {
291 .id = AT91SAM9G45_ID_PIOA,
295 .id = AT91SAM9G45_ID_PIOB,
299 .id = AT91SAM9G45_ID_PIOC,
303 .id = AT91SAM9G45_ID_PIODE,
307 .id = AT91SAM9G45_ID_PIODE,
313 static void at91sam9g45_reset(void)
315 at91_sys_write(AT91_RSTC_CR, AT91_RSTC_KEY | AT91_RSTC_PROCRST | AT91_RSTC_PERRST);
318 static void at91sam9g45_poweroff(void)
320 at91_sys_write(AT91_SHDW_CR, AT91_SHDW_KEY | AT91_SHDW_SHDW);
324 /* --------------------------------------------------------------------
325 * AT91SAM9G45 processor initialization
326 * -------------------------------------------------------------------- */
328 static void __init at91sam9g45_map_io(void)
330 iotable_init(at91sam9g45_sram_desc, ARRAY_SIZE(at91sam9g45_sram_desc));
333 static void __init at91sam9g45_initialize(void)
335 at91_arch_reset = at91sam9g45_reset;
336 pm_power_off = at91sam9g45_poweroff;
337 at91_extern_irq = (1 << AT91SAM9G45_ID_IRQ0);
339 /* Register GPIO subsystem */
340 at91_gpio_init(at91sam9g45_gpio, 5);
343 /* --------------------------------------------------------------------
344 * Interrupt initialization
345 * -------------------------------------------------------------------- */
348 * The default interrupt priority levels (0 = lowest, 7 = highest).
350 static unsigned int at91sam9g45_default_irq_priority[NR_AIC_IRQS] __initdata = {
351 7, /* Advanced Interrupt Controller (FIQ) */
352 7, /* System Peripherals */
353 1, /* Parallel IO Controller A */
354 1, /* Parallel IO Controller B */
355 1, /* Parallel IO Controller C */
356 1, /* Parallel IO Controller D and E */
362 0, /* Multimedia Card Interface 0 */
363 6, /* Two-Wire Interface 0 */
364 6, /* Two-Wire Interface 1 */
365 5, /* Serial Peripheral Interface 0 */
366 5, /* Serial Peripheral Interface 1 */
367 4, /* Serial Synchronous Controller 0 */
368 4, /* Serial Synchronous Controller 1 */
369 0, /* Timer Counter 0, 1, 2, 3, 4 and 5 */
370 0, /* Pulse Width Modulation Controller */
371 0, /* Touch Screen Controller */
372 0, /* DMA Controller */
373 2, /* USB Host High Speed port */
374 3, /* LDC Controller */
375 5, /* AC97 Controller */
377 0, /* Image Sensor Interface */
378 2, /* USB Device High speed port */
380 0, /* Multimedia Card Interface 1 */
382 0, /* Advanced Interrupt Controller (IRQ0) */
385 struct at91_init_soc __initdata at91sam9g45_soc = {
386 .map_io = at91sam9g45_map_io,
387 .default_irq_priority = at91sam9g45_default_irq_priority,
388 .register_clocks = at91sam9g45_register_clocks,
389 .init = at91sam9g45_initialize,