at91: add arch specific ioremap support
[pandora-kernel.git] / arch / arm / mach-at91 / at91cap9.c
index 7337617..bfc6844 100644 (file)
 #include <mach/at91_rstc.h>
 #include <mach/at91_shdwc.h>
 
+#include "soc.h"
 #include "generic.h"
 #include "clock.h"
 
-static struct map_desc at91cap9_io_desc[] __initdata = {
-       {
-               .virtual        = AT91_VA_BASE_SYS,
-               .pfn            = __phys_to_pfn(AT91_BASE_SYS),
-               .length         = SZ_16K,
-               .type           = MT_DEVICE,
-       }, {
-               .virtual        = AT91_IO_VIRT_BASE - AT91CAP9_SRAM_SIZE,
-               .pfn            = __phys_to_pfn(AT91CAP9_SRAM_BASE),
-               .length         = AT91CAP9_SRAM_SIZE,
-               .type           = MT_DEVICE,
-       },
-};
-
 /* --------------------------------------------------------------------
  *  Clocks
  * -------------------------------------------------------------------- */
@@ -222,6 +209,25 @@ static struct clk *periph_clocks[] __initdata = {
        // irq0 .. irq1
 };
 
+static struct clk_lookup periph_clocks_lookups[] = {
+       CLKDEV_CON_DEV_ID("hclk", "atmel_usba_udc", &utmi_clk),
+       CLKDEV_CON_DEV_ID("pclk", "atmel_usba_udc", &udphs_clk),
+       CLKDEV_CON_DEV_ID("mci_clk", "at91_mci.0", &mmc0_clk),
+       CLKDEV_CON_DEV_ID("mci_clk", "at91_mci.1", &mmc1_clk),
+       CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi.0", &spi0_clk),
+       CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi.1", &spi1_clk),
+       CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.0", &tcb_clk),
+       CLKDEV_CON_DEV_ID("pclk", "ssc.0", &ssc0_clk),
+       CLKDEV_CON_DEV_ID("pclk", "ssc.1", &ssc1_clk),
+};
+
+static struct clk_lookup usart_clocks_lookups[] = {
+       CLKDEV_CON_DEV_ID("usart", "atmel_usart.0", &mck),
+       CLKDEV_CON_DEV_ID("usart", "atmel_usart.1", &usart0_clk),
+       CLKDEV_CON_DEV_ID("usart", "atmel_usart.2", &usart1_clk),
+       CLKDEV_CON_DEV_ID("usart", "atmel_usart.3", &usart2_clk),
+};
+
 /*
  * The four programmable clocks.
  * You must configure pin multiplexing to bring these signals out.
@@ -258,12 +264,29 @@ static void __init at91cap9_register_clocks(void)
        for (i = 0; i < ARRAY_SIZE(periph_clocks); i++)
                clk_register(periph_clocks[i]);
 
+       clkdev_add_table(periph_clocks_lookups,
+                        ARRAY_SIZE(periph_clocks_lookups));
+       clkdev_add_table(usart_clocks_lookups,
+                        ARRAY_SIZE(usart_clocks_lookups));
+
        clk_register(&pck0);
        clk_register(&pck1);
        clk_register(&pck2);
        clk_register(&pck3);
 }
 
+static struct clk_lookup console_clock_lookup;
+
+void __init at91cap9_set_console_clock(int id)
+{
+       if (id >= ARRAY_SIZE(usart_clocks_lookups))
+               return;
+
+       console_clock_lookup.con_id = "usart";
+       console_clock_lookup.clk = usart_clocks_lookups[id].clk;
+       clkdev_add(&console_clock_lookup);
+}
+
 /* --------------------------------------------------------------------
  *  GPIO
  * -------------------------------------------------------------------- */
@@ -303,21 +326,17 @@ static void at91cap9_poweroff(void)
  *  AT91CAP9 processor initialization
  * -------------------------------------------------------------------- */
 
-void __init at91cap9_initialize(unsigned long main_clock)
+static void __init at91cap9_map_io(void)
 {
-       /* Map peripherals */
-       iotable_init(at91cap9_io_desc, ARRAY_SIZE(at91cap9_io_desc));
+       at91_init_sram(0, AT91CAP9_SRAM_BASE, AT91CAP9_SRAM_SIZE);
+}
 
+static void __init at91cap9_initialize(void)
+{
        at91_arch_reset = at91cap9_reset;
        pm_power_off = at91cap9_poweroff;
        at91_extern_irq = (1 << AT91CAP9_ID_IRQ0) | (1 << AT91CAP9_ID_IRQ1);
 
-       /* Init clock subsystem */
-       at91_clock_init(main_clock);
-
-       /* Register the processor-specific clocks */
-       at91cap9_register_clocks();
-
        /* Register GPIO subsystem */
        at91_gpio_init(at91cap9_gpio, 4);
 
@@ -370,14 +389,9 @@ static unsigned int at91cap9_default_irq_priority[NR_AIC_IRQS] __initdata = {
        0,      /* Advanced Interrupt Controller (IRQ1) */
 };
 
-void __init at91cap9_init_interrupts(unsigned int priority[NR_AIC_IRQS])
-{
-       if (!priority)
-               priority = at91cap9_default_irq_priority;
-
-       /* Initialize the AIC interrupt controller */
-       at91_aic_init(priority);
-
-       /* Enable GPIO interrupts */
-       at91_gpio_irq_setup();
-}
+struct at91_init_soc __initdata at91cap9_soc = {
+       .map_io = at91cap9_map_io,
+       .default_irq_priority = at91cap9_default_irq_priority,
+       .register_clocks = at91cap9_register_clocks,
+       .init = at91cap9_initialize,
+};