ARM: Realview/Versatile/Integrator: separate out common clock code
[safe/jmp/linux-2.6] / arch / arm / mach-realview / realview_pb1176.c
index a9fac65..217f7c1 100644 (file)
@@ -23,6 +23,8 @@
 #include <linux/platform_device.h>
 #include <linux/sysdev.h>
 #include <linux/amba/bus.h>
+#include <linux/amba/pl061.h>
+#include <linux/amba/mmci.h>
 #include <linux/io.h>
 
 #include <mach/hardware.h>
 #include <asm/leds.h>
 #include <asm/mach-types.h>
 #include <asm/hardware/gic.h>
-#include <asm/hardware/icst307.h>
 #include <asm/hardware/cache-l2x0.h>
 
 #include <asm/mach/arch.h>
 #include <asm/mach/flash.h>
 #include <asm/mach/map.h>
-#include <asm/mach/mmc.h>
 #include <asm/mach/time.h>
 
 #include <mach/board-pb1176.h>
 #include <mach/irqs.h>
 
 #include "core.h"
-#include "clock.h"
 
 static struct map_desc realview_pb1176_io_desc[] __initdata = {
        {
@@ -107,6 +106,21 @@ static void __init realview_pb1176_map_io(void)
        iotable_init(realview_pb1176_io_desc, ARRAY_SIZE(realview_pb1176_io_desc));
 }
 
+static struct pl061_platform_data gpio0_plat_data = {
+       .gpio_base      = 0,
+       .irq_base       = -1,
+};
+
+static struct pl061_platform_data gpio1_plat_data = {
+       .gpio_base      = 8,
+       .irq_base       = -1,
+};
+
+static struct pl061_platform_data gpio2_plat_data = {
+       .gpio_base      = 16,
+       .irq_base       = -1,
+};
+
 /*
  * RealView PB1176 AMBA devices
  */
@@ -154,29 +168,29 @@ static void __init realview_pb1176_map_io(void)
 #define PB1176_SSP_DMA         { 9, 8 }
 
 /* FPGA Primecells */
-AMBA_DEVICE(aaci,      "fpga:04",      AACI,           NULL);
-AMBA_DEVICE(mmc0,      "fpga:05",      MMCI0,          &realview_mmc0_plat_data);
-AMBA_DEVICE(kmi0,      "fpga:06",      KMI0,           NULL);
-AMBA_DEVICE(kmi1,      "fpga:07",      KMI1,           NULL);
-AMBA_DEVICE(uart3,     "fpga:09",      PB1176_UART3,   NULL);
+AMBA_DEVICE(aaci,      "fpga:aaci",    AACI,           NULL);
+AMBA_DEVICE(mmc0,      "fpga:mmc0",    MMCI0,          &realview_mmc0_plat_data);
+AMBA_DEVICE(kmi0,      "fpga:kmi0",    KMI0,           NULL);
+AMBA_DEVICE(kmi1,      "fpga:kmi1",    KMI1,           NULL);
+AMBA_DEVICE(uart3,     "fpga:uart3",   PB1176_UART3,   NULL);
 
 /* DevChip Primecells */
-AMBA_DEVICE(smc,       "dev:00",       PB1176_SMC,     NULL);
-AMBA_DEVICE(sctl,      "dev:e0",       SCTL,           NULL);
-AMBA_DEVICE(wdog,      "dev:e1",       PB1176_WATCHDOG,        NULL);
-AMBA_DEVICE(gpio0,     "dev:e4",       PB1176_GPIO0,   NULL);
-AMBA_DEVICE(gpio1,     "dev:e5",       GPIO1,          NULL);
-AMBA_DEVICE(gpio2,     "dev:e6",       GPIO2,          NULL);
-AMBA_DEVICE(rtc,       "dev:e8",       PB1176_RTC,     NULL);
-AMBA_DEVICE(sci0,      "dev:f0",       SCI,            NULL);
-AMBA_DEVICE(uart0,     "dev:f1",       PB1176_UART0,   NULL);
-AMBA_DEVICE(uart1,     "dev:f2",       PB1176_UART1,   NULL);
-AMBA_DEVICE(uart2,     "dev:f3",       PB1176_UART2,   NULL);
-AMBA_DEVICE(ssp0,      "dev:f4",       PB1176_SSP,     NULL);
+AMBA_DEVICE(smc,       "dev:smc",      PB1176_SMC,     NULL);
+AMBA_DEVICE(sctl,      "dev:sctl",     SCTL,           NULL);
+AMBA_DEVICE(wdog,      "dev:wdog",     PB1176_WATCHDOG,        NULL);
+AMBA_DEVICE(gpio0,     "dev:gpio0",    PB1176_GPIO0,   &gpio0_plat_data);
+AMBA_DEVICE(gpio1,     "dev:gpio1",    GPIO1,          &gpio1_plat_data);
+AMBA_DEVICE(gpio2,     "dev:gpio2",    GPIO2,          &gpio2_plat_data);
+AMBA_DEVICE(rtc,       "dev:rtc",      PB1176_RTC,     NULL);
+AMBA_DEVICE(sci0,      "dev:sci0",     SCI,            NULL);
+AMBA_DEVICE(uart0,     "dev:uart0",    PB1176_UART0,   NULL);
+AMBA_DEVICE(uart1,     "dev:uart1",    PB1176_UART1,   NULL);
+AMBA_DEVICE(uart2,     "dev:uart2",    PB1176_UART2,   NULL);
+AMBA_DEVICE(ssp0,      "dev:ssp0",     PB1176_SSP,     NULL);
 
 /* Primecells on the NEC ISSP chip */
-AMBA_DEVICE(clcd,      "issp:20",      PB1176_CLCD,    &clcd_plat_data);
-//AMBA_DEVICE(dmac,    "issp:30",      PB1176_DMAC,    NULL);
+AMBA_DEVICE(clcd,      "issp:clcd",    PB1176_CLCD,    &clcd_plat_data);
+//AMBA_DEVICE(dmac,    "issp:dmac",    PB1176_DMAC,    NULL);
 
 static struct amba_device *amba_devs[] __initdata = {
 //     &dmac_device,
@@ -203,11 +217,23 @@ static struct amba_device *amba_devs[] __initdata = {
 /*
  * RealView PB1176 platform devices
  */
-static struct resource realview_pb1176_flash_resource = {
-       .start                  = REALVIEW_PB1176_FLASH_BASE,
-       .end                    = REALVIEW_PB1176_FLASH_BASE + REALVIEW_PB1176_FLASH_SIZE - 1,
-       .flags                  = IORESOURCE_MEM,
+static struct resource realview_pb1176_flash_resources[] = {
+       [0] = {
+               .start          = REALVIEW_PB1176_FLASH_BASE,
+               .end            = REALVIEW_PB1176_FLASH_BASE + REALVIEW_PB1176_FLASH_SIZE - 1,
+               .flags          = IORESOURCE_MEM,
+       },
+       [1] = {
+               .start          = REALVIEW_PB1176_SEC_FLASH_BASE,
+               .end            = REALVIEW_PB1176_SEC_FLASH_BASE + REALVIEW_PB1176_SEC_FLASH_SIZE - 1,
+               .flags          = IORESOURCE_MEM,
+       },
 };
+#ifdef CONFIG_REALVIEW_PB1176_SECURE_FLASH
+#define PB1176_FLASH_BLOCKS    2
+#else
+#define PB1176_FLASH_BLOCKS    1
+#endif
 
 static struct resource realview_pb1176_smsc911x_resources[] = {
        [0] = {
@@ -222,11 +248,17 @@ static struct resource realview_pb1176_smsc911x_resources[] = {
        },
 };
 
-static struct platform_device realview_pb1176_smsc911x_device = {
-       .name           = "smc911x",
-       .id             = 0,
-       .num_resources  = ARRAY_SIZE(realview_pb1176_smsc911x_resources),
-       .resource       = realview_pb1176_smsc911x_resources,
+static struct resource realview_pb1176_isp1761_resources[] = {
+       [0] = {
+               .start          = REALVIEW_PB1176_USB_BASE,
+               .end            = REALVIEW_PB1176_USB_BASE + SZ_128K - 1,
+               .flags          = IORESOURCE_MEM,
+       },
+       [1] = {
+               .start          = IRQ_PB1176_USB,
+               .end            = IRQ_PB1176_USB,
+               .flags          = IORESOURCE_IRQ,
+       },
 };
 
 static void __init gic_init_irq(void)
@@ -256,6 +288,26 @@ static struct sys_timer realview_pb1176_timer = {
        .init           = realview_pb1176_timer_init,
 };
 
+static void realview_pb1176_reset(char mode)
+{
+       void __iomem *reset_ctrl = __io_address(REALVIEW_SYS_RESETCTL);
+       void __iomem *lock_ctrl = __io_address(REALVIEW_SYS_LOCK);
+       __raw_writel(REALVIEW_SYS_LOCK_VAL, lock_ctrl);
+       __raw_writel(REALVIEW_PB1176_SYS_SOFT_RESET, reset_ctrl);
+}
+
+static void realview_pb1176_fixup(struct machine_desc *mdesc,
+                                 struct tag *tags, char **from,
+                                 struct meminfo *meminfo)
+{
+       /*
+        * RealView PB1176 only has 128MB of RAM mapped at 0.
+        */
+       meminfo->bank[0].start = 0;
+       meminfo->bank[0].size = SZ_128M;
+       meminfo->nr_banks = 1;
+}
+
 static void __init realview_pb1176_init(void)
 {
        int i;
@@ -265,10 +317,11 @@ static void __init realview_pb1176_init(void)
        l2x0_init(__io_address(REALVIEW_PB1176_L220_BASE), 0x00730000, 0xfe000fff);
 #endif
 
-       clk_register(&realview_clcd_clk);
-
-       realview_flash_register(&realview_pb1176_flash_resource, 1);
-       platform_device_register(&realview_pb1176_smsc911x_device);
+       realview_flash_register(realview_pb1176_flash_resources,
+                               PB1176_FLASH_BLOCKS);
+       realview_eth_register(NULL, realview_pb1176_smsc911x_resources);
+       platform_device_register(&realview_i2c_device);
+       realview_usb_register(realview_pb1176_isp1761_resources);
 
        for (i = 0; i < ARRAY_SIZE(amba_devs); i++) {
                struct amba_device *d = amba_devs[i];
@@ -278,6 +331,7 @@ static void __init realview_pb1176_init(void)
 #ifdef CONFIG_LEDS
        leds_event = realview_leds_event;
 #endif
+       realview_reset = realview_pb1176_reset;
 }
 
 MACHINE_START(REALVIEW_PB1176, "ARM-RealView PB1176")
@@ -285,6 +339,7 @@ MACHINE_START(REALVIEW_PB1176, "ARM-RealView PB1176")
        .phys_io        = REALVIEW_PB1176_UART0_BASE,
        .io_pg_offst    = (IO_ADDRESS(REALVIEW_PB1176_UART0_BASE) >> 18) & 0xfffc,
        .boot_params    = PHYS_OFFSET + 0x00000100,
+       .fixup          = realview_pb1176_fixup,
        .map_io         = realview_pb1176_map_io,
        .init_irq       = gic_init_irq,
        .timer          = &realview_pb1176_timer,