]> err.no Git - linux-2.6/blobdiff - arch/arm/mach-realview/realview_eb.c
RealView: Move the EB GIC definitions to the board file
[linux-2.6] / arch / arm / mach-realview / realview_eb.c
index 60d9eb810246f23957597695566de56af573750e..6848e51829948c96b8a86c405db30d3533d9477d 100644 (file)
@@ -51,13 +51,13 @@ static struct map_desc realview_eb_io_desc[] __initdata = {
                .length         = SZ_4K,
                .type           = MT_DEVICE,
        }, {
-               .virtual        = IO_ADDRESS(REALVIEW_GIC_CPU_BASE),
-               .pfn            = __phys_to_pfn(REALVIEW_GIC_CPU_BASE),
+               .virtual        = IO_ADDRESS(REALVIEW_EB_GIC_CPU_BASE),
+               .pfn            = __phys_to_pfn(REALVIEW_EB_GIC_CPU_BASE),
                .length         = SZ_4K,
                .type           = MT_DEVICE,
        }, {
-               .virtual        = IO_ADDRESS(REALVIEW_GIC_DIST_BASE),
-               .pfn            = __phys_to_pfn(REALVIEW_GIC_DIST_BASE),
+               .virtual        = IO_ADDRESS(REALVIEW_EB_GIC_DIST_BASE),
+               .pfn            = __phys_to_pfn(REALVIEW_EB_GIC_DIST_BASE),
                .length         = SZ_4K,
                .type           = MT_DEVICE,
        }, {
@@ -224,7 +224,7 @@ static struct amba_device *amba_devs[] __initdata = {
  * RealView EB platform devices
  */
 
-static struct resource realview_eb_smc91x_resources[] = {
+static struct resource realview_eb_eth_resources[] = {
        [0] = {
                .start          = REALVIEW_ETH_BASE,
                .end            = REALVIEW_ETH_BASE + SZ_64K - 1,
@@ -237,13 +237,36 @@ static struct resource realview_eb_smc91x_resources[] = {
        },
 };
 
-static struct platform_device realview_eb_smc91x_device = {
-       .name           = "smc91x",
+static struct platform_device realview_eb_eth_device = {
        .id             = 0,
-       .num_resources  = ARRAY_SIZE(realview_eb_smc91x_resources),
-       .resource       = realview_eb_smc91x_resources,
+       .num_resources  = ARRAY_SIZE(realview_eb_eth_resources),
+       .resource       = realview_eb_eth_resources,
 };
 
+/*
+ * Detect and register the correct Ethernet device. RealView/EB rev D
+ * platforms use the newer SMSC LAN9118 Ethernet chip
+ */
+static int eth_device_register(void)
+{
+       void __iomem *eth_addr = ioremap(REALVIEW_ETH_BASE, SZ_4K);
+       u32 idrev;
+
+       if (!eth_addr)
+               return -ENOMEM;
+
+       idrev = readl(eth_addr + 0x50);
+       if ((idrev & 0xFFFF0000) == 0x01180000)
+               /* SMSC LAN9118 chip present */
+               realview_eb_eth_device.name = "smc911x";
+       else
+               /* SMSC 91C111 chip present */
+               realview_eb_eth_device.name = "smc91x";
+
+       iounmap(eth_addr);
+       return platform_device_register(&realview_eb_eth_device);
+}
+
 static void __init gic_init_irq(void)
 {
        if (core_tile_eb11mp()) {
@@ -263,14 +286,14 @@ static void __init gic_init_irq(void)
 
 #ifndef CONFIG_REALVIEW_EB_ARM11MP_REVB
                /* board GIC, secondary */
-               gic_dist_init(1, __io_address(REALVIEW_GIC_DIST_BASE), 64);
-               gic_cpu_init(1, __io_address(REALVIEW_GIC_CPU_BASE));
+               gic_dist_init(1, __io_address(REALVIEW_EB_GIC_DIST_BASE), 64);
+               gic_cpu_init(1, __io_address(REALVIEW_EB_GIC_CPU_BASE));
                gic_cascade_irq(1, IRQ_EB11MP_EB_IRQ1);
 #endif
        } else {
                /* board GIC, primary */
-               gic_cpu_base_addr = __io_address(REALVIEW_GIC_CPU_BASE);
-               gic_dist_init(0, __io_address(REALVIEW_GIC_DIST_BASE), 29);
+               gic_cpu_base_addr = __io_address(REALVIEW_EB_GIC_CPU_BASE);
+               gic_dist_init(0, __io_address(REALVIEW_EB_GIC_DIST_BASE), 29);
                gic_cpu_init(0, gic_cpu_base_addr);
        }
 }
@@ -301,8 +324,8 @@ static void realview_eb11mp_fixup(void)
        kmi1_device.irq[0]      = IRQ_EB11MP_KMI1;
 
        /* platform devices */
-       realview_eb_smc91x_resources[1].start   = IRQ_EB11MP_ETH;
-       realview_eb_smc91x_resources[1].end     = IRQ_EB11MP_ETH;
+       realview_eb_eth_resources[1].start      = IRQ_EB11MP_ETH;
+       realview_eb_eth_resources[1].end        = IRQ_EB11MP_ETH;
 }
 
 static void __init realview_eb_timer_init(void)
@@ -340,8 +363,8 @@ static void __init realview_eb_init(void)
        clk_register(&realview_clcd_clk);
 
        platform_device_register(&realview_flash_device);
-       platform_device_register(&realview_eb_smc91x_device);
        platform_device_register(&realview_i2c_device);
+       eth_device_register();
 
        for (i = 0; i < ARRAY_SIZE(amba_devs); i++) {
                struct amba_device *d = amba_devs[i];