]> err.no Git - linux-2.6/commitdiff
[ARM] 3226/1: IXP4xx runtime expansion bus window size configuration
authorDeepak Saxena <dsaxena@plexity.net>
Thu, 5 Jan 2006 20:59:29 +0000 (20:59 +0000)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Thu, 5 Jan 2006 20:59:29 +0000 (20:59 +0000)
Patch from Deepak Saxena

The expansion bus on the IXP46x NPU can be configured for either 32MiB or
16MiB windows and changing the configuration causes the base address for
each chip select for each region to change. Because of this, we cannot
hardcode the physical base as we currently do. This patch checks the
expansion bus configuration registers at runtime to determine the
appropriate window size. Note that this requires that the bootloader
already configured the device sizes appropriately, but I feel that is
valid assumption to make as the bootloader must configure and access
the flash window, the output display (LCD, LEDs, etc) window, and
other expansion bus devices.

Signed-off-by: Deepak Saxena <dsaxena@plexity.net>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
arch/arm/mach-ixp4xx/common.c
arch/arm/mach-ixp4xx/coyote-setup.c
arch/arm/mach-ixp4xx/gtwx5715-setup.c
arch/arm/mach-ixp4xx/ixdp425-setup.c
arch/arm/mach-ixp4xx/nas100d-setup.c
include/asm-arm/arch-ixp4xx/coyote.h
include/asm-arm/arch-ixp4xx/gtwx5715.h
include/asm-arm/arch-ixp4xx/ixdp425.h
include/asm-arm/arch-ixp4xx/nas100d.h
include/asm-arm/arch-ixp4xx/nslu2.h
include/asm-arm/arch-ixp4xx/platform.h

index 9f33cb21e7f38d98adb33f4f0fe5c7d315281dcb..6b393691d0e898cdcc0b4aaebb6da5ab2469c470 100644 (file)
@@ -332,11 +332,27 @@ static struct platform_device *ixp46x_devices[] __initdata = {
        &ixp46x_i2c_controller
 };
 
+unsigned long ixp4xx_exp_bus_size;
+
 void __init ixp4xx_sys_init(void)
 {
+       ixp4xx_exp_bus_size = SZ_16M;
+
        if (cpu_is_ixp46x()) {
+               int region;
+
                platform_add_devices(ixp46x_devices,
                                ARRAY_SIZE(ixp46x_devices));
+
+               for (region = 0; region < 7; region++) {
+                       if((*(IXP4XX_EXP_REG(0x4 * region)) & 0x200)) {
+                               ixp4xx_exp_bus_size = SZ_32M;
+                               break;
+                       }
+               }
        }
+
+       printk("IXP4xx: Using %uMiB expansion bus window size\n",
+                       ixp4xx_exp_bus_size >> 20);
 }
 
index 050c92768913b73d542dab88a3a3f883ace1ed38..679594a73981704a3df75bea6d6e3f396474ab5c 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/serial.h>
 #include <linux/tty.h>
 #include <linux/serial_8250.h>
+#include <linux/slab.h>
 
 #include <asm/types.h>
 #include <asm/setup.h>
@@ -30,8 +31,6 @@ static struct flash_platform_data coyote_flash_data = {
 };
 
 static struct resource coyote_flash_resource = {
-       .start          = COYOTE_FLASH_BASE,
-       .end            = COYOTE_FLASH_BASE + COYOTE_FLASH_SIZE - 1,
        .flags          = IORESOURCE_MEM,
 };
 
@@ -81,6 +80,11 @@ static struct platform_device *coyote_devices[] __initdata = {
 
 static void __init coyote_init(void)
 {
+       ixp4xx_sys_init();
+
+       coyote_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
+       coyote_flash_resource.end = IXP4XX_EXP_BUS_BASE(0) + SZ_32M - 1;
+
        *IXP4XX_EXP_CS0 |= IXP4XX_FLASH_WRITABLE;
        *IXP4XX_EXP_CS1 = *IXP4XX_EXP_CS0;
 
@@ -91,8 +95,6 @@ static void __init coyote_init(void)
                coyote_uart_data[0].irq = IRQ_IXP4XX_UART1;
        }
 
-
-       ixp4xx_sys_init();
        platform_add_devices(coyote_devices, ARRAY_SIZE(coyote_devices));
 }
 
index 29a6d02fa851d4c19841545830af52788de21fbf..038670489970c2131145337490f64751db9eef8d 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/serial.h>
 #include <linux/tty.h>
 #include <linux/serial_8250.h>
+#include <linux/slab.h>
 
 #include <asm/types.h>
 #include <asm/setup.h>
@@ -106,11 +107,9 @@ static struct flash_platform_data gtwx5715_flash_data = {
        .width          = 2,
 };
 
-static struct resource gtwx5715_flash_resource = {
-       .start          = GTWX5715_FLASH_BASE,
-       .end            = GTWX5715_FLASH_BASE + GTWX5715_FLASH_SIZE - 1,
+static struct gtw5715_flash_resource = {
        .flags          = IORESOURCE_MEM,
-};
+}
 
 static struct platform_device gtwx5715_flash = {
        .name           = "IXP4XX-Flash",
@@ -129,6 +128,14 @@ static struct platform_device *gtwx5715_devices[] __initdata = {
 
 static void __init gtwx5715_init(void)
 {
+       ixp4xx_sys_init();
+
+       if (!flash_resource)
+               printk(KERN_ERR "Could not allocate flash resource\n");
+
+       gtwx5715_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
+       gtwx5715_flash_resource.end = IXP4XX_EXP_BUS_BASE(0) + SZ_8M - 1;
+
        platform_add_devices(gtwx5715_devices, ARRAY_SIZE(gtwx5715_devices));
 }
 
index 3a22d84e10478de8581b6d0eeb8d2c4287170eb9..c2e105c89c9561613e30f006f5e238f886f097e4 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/serial.h>
 #include <linux/tty.h>
 #include <linux/serial_8250.h>
+#include <linux/slab.h>
 
 #include <asm/types.h>
 #include <asm/setup.h>
@@ -30,8 +31,6 @@ static struct flash_platform_data ixdp425_flash_data = {
 };
 
 static struct resource ixdp425_flash_resource = {
-       .start          = IXDP425_FLASH_BASE,
-       .end            = IXDP425_FLASH_BASE + IXDP425_FLASH_SIZE - 1,
        .flags          = IORESOURCE_MEM,
 };
 
@@ -108,17 +107,13 @@ static struct platform_device *ixdp425_devices[] __initdata = {
        &ixdp425_uart
 };
 
-
 static void __init ixdp425_init(void)
 {
        ixp4xx_sys_init();
 
-       /*
-        * IXP465 has 32MB window
-        */
-       if (machine_is_ixdp465()) {
-               ixdp425_flash_resource.end += IXDP425_FLASH_SIZE;
-       }
+       ixdp425_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
+       ixdp425_flash_resource.end =
+               IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
 
        platform_add_devices(ixdp425_devices, ARRAY_SIZE(ixdp425_devices));
 }
index bde9648e7afc878ba769a012d5595291d5475933..49998a8bd4e8991d6b5ac15d2534ab5d1ea8d972 100644 (file)
@@ -26,8 +26,6 @@ static struct flash_platform_data nas100d_flash_data = {
 };
 
 static struct resource nas100d_flash_resource = {
-       .start                  = NAS100D_FLASH_BASE,
-       .end                    = NAS100D_FLASH_BASE + NAS100D_FLASH_SIZE,
        .flags                  = IORESOURCE_MEM,
 };
 
@@ -115,6 +113,10 @@ static void __init nas100d_init(void)
 {
        ixp4xx_sys_init();
 
+       nas100d_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
+       nas100d_flash_resource.end =
+               IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
+
        pm_power_off = nas100d_power_off;
 
        platform_add_devices(nas100d_devices, ARRAY_SIZE(nas100d_devices));
index dd0c2d2d85039e7749559b17e2b0b48b917db190..7ac9ba2c035cf9b4ed60989032410ed2bc3c6722 100644 (file)
@@ -16,9 +16,6 @@
 #error "Do not include this directly, instead #include <asm/hardware.h>"
 #endif
 
-#define        COYOTE_FLASH_BASE       IXP4XX_EXP_BUS_CS0_BASE_PHYS
-#define        COYOTE_FLASH_SIZE       IXP4XX_EXP_BUS_CSX_REGION_SIZE * 2
-
 /* PCI controller GPIO to IRQ pin mappings */
 #define        COYOTE_PCI_SLOT0_PIN    6
 #define        COYOTE_PCI_SLOT1_PIN    11
@@ -26,7 +23,7 @@
 #define        COYOTE_PCI_SLOT0_DEVID  14
 #define        COYOTE_PCI_SLOT1_DEVID  15
 
-#define        COYOTE_IDE_BASE_PHYS    IXP4XX_EXP_BUS_CS3_BASE_PHYS
+#define        COYOTE_IDE_BASE_PHYS    IXP4XX_EXP_BUS_BASE(3)
 #define        COYOTE_IDE_BASE_VIRT    0xFFFE1000
 #define        COYOTE_IDE_REGION_SIZE  0x1000
 
index fc460af70627a72fb54106d4a30e3556d1cd3e63..c3069d67c00efb54b378a3b211233f2ce073ecd4 100644 (file)
 #define GTWX5715_GPIO13_IRQ            IRQ_IXP4XX_SW_INT1
 #define GTWX5715_GPIO14_IRQ            IRQ_IXP4XX_SW_INT2
 
-
-#define        GTWX5715_FLASH_BASE     IXP4XX_EXP_BUS_CS0_BASE_PHYS
-#define        GTWX5715_FLASH_SIZE     (0x00800000)
-
 /* PCI controller GPIO to IRQ pin mappings
 
                        INTA    INTB
index 7d21bf941379033c288dc7fc2eba0c4c9c7e26d6..3d3820d7ba09f71847bb9256aac2c6a7bb71b1ea 100644 (file)
@@ -16,9 +16,6 @@
 #error "Do not include this directly, instead #include <asm/hardware.h>"
 #endif
 
-#define        IXDP425_FLASH_BASE      IXP4XX_EXP_BUS_CS0_BASE_PHYS
-#define        IXDP425_FLASH_SIZE      IXP4XX_EXP_BUS_CSX_REGION_SIZE
-
 #define        IXDP425_SDA_PIN         7
 #define        IXDP425_SCL_PIN         6
 
index ce7a86a98fc22baa53e61220c04561331a686c86..51ac0180427cac146b92e58ba043280d548fa55f 100644 (file)
@@ -19,9 +19,6 @@
 #error "Do not include this directly, instead #include <asm/hardware.h>"
 #endif
 
-#define NAS100D_FLASH_BASE     IXP4XX_EXP_BUS_CS0_BASE_PHYS
-#define NAS100D_FLASH_SIZE     IXP4XX_EXP_BUS_CSX_REGION_SIZE
-
 #define NAS100D_SDA_PIN                6
 #define NAS100D_SCL_PIN                5
 
index b8b347a559c75e8c7651f64fcff1d62e5f413e0d..4281838873eff89156e49a0c0e4c7500fc9505f1 100644 (file)
@@ -18,9 +18,6 @@
 #error "Do not include this directly, instead #include <asm/hardware.h>"
 #endif
 
-#define NSLU2_FLASH_BASE       IXP4XX_EXP_BUS_CS0_BASE_PHYS
-#define NSLU2_FLASH_SIZE       IXP4XX_EXP_BUS_CSX_REGION_SIZE
-
 #define NSLU2_SDA_PIN          7
 #define NSLU2_SCL_PIN          6
 
index 6b77ed26be7964296b19aeef5c49fa590c4de3c5..daf9790645ca2bd7746ddce03d50f7a1a67b5147 100644 (file)
  */
 #define IXP4XX_EXP_BUS_BASE_PHYS       (0x50000000)
 
-#define        IXP4XX_EXP_BUS_CSX_REGION_SIZE  (0x01000000)
-
-#define IXP4XX_EXP_BUS_CS0_BASE_PHYS   (IXP4XX_EXP_BUS_BASE_PHYS + 0x00000000)
-#define IXP4XX_EXP_BUS_CS1_BASE_PHYS   (IXP4XX_EXP_BUS_BASE_PHYS + 0x01000000)
-#define IXP4XX_EXP_BUS_CS2_BASE_PHYS   (IXP4XX_EXP_BUS_BASE_PHYS + 0x02000000)
-#define IXP4XX_EXP_BUS_CS3_BASE_PHYS   (IXP4XX_EXP_BUS_BASE_PHYS + 0x03000000)
-#define IXP4XX_EXP_BUS_CS4_BASE_PHYS   (IXP4XX_EXP_BUS_BASE_PHYS + 0x04000000)
-#define IXP4XX_EXP_BUS_CS5_BASE_PHYS   (IXP4XX_EXP_BUS_BASE_PHYS + 0x05000000)
-#define IXP4XX_EXP_BUS_CS6_BASE_PHYS   (IXP4XX_EXP_BUS_BASE_PHYS + 0x06000000)
-#define IXP4XX_EXP_BUS_CS7_BASE_PHYS   (IXP4XX_EXP_BUS_BASE_PHYS + 0x07000000)
+/*
+ * The expansion bus on the IXP4xx can be configured for either 16 or
+ * 32MB windows and the CS offset for each region changes based on the
+ * current configuration. This means that we cannot simply hardcode
+ * each offset. ixp4xx_sys_init() looks at the expansion bus configuration
+ * as setup by the bootloader to determine our window size.
+ */
+extern unsigned long ixp4xx_exp_bus_size;
+
+#define        IXP4XX_EXP_BUS_BASE(region)\
+               (IXP4XX_EXP_BUS_BASE_PHYS + ((region) * ixp4xx_exp_bus_size))
 
 #define IXP4XX_FLASH_WRITABLE  (0x2)
 #define IXP4XX_FLASH_DEFAULT   (0xbcd23c40)