add twinpass detection to ifxmips
[openwrt.git] / target / linux / ifxmips / files / arch / mips / ifxmips / board.c
index 017a8a62b7fd5f481129f4b33c5c00917dfe593e..580dc6a8f7bad30e19ff67770bd7d68caf05b9d4 100644 (file)
 #include <linux/types.h>
 #include <linux/string.h>
 #include <linux/mtd/physmap.h>
-#include <linux/platform_device.h>
 #include <linux/kernel.h>
 #include <linux/reboot.h>
+#include <linux/platform_device.h>
 #include <asm/bootinfo.h>
 #include <asm/reboot.h>
 #include <asm/time.h>
 #include <asm/irq.h>
 #include <asm/io.h>
+#include <asm/ifxmips/ifxmips.h>
 
 #define MAX_IFXMIPS_DEVS               5
 
+#define BOARD_DANUBE                   "Danube"
+#define BOARD_DANUBE_CHIPID            0x10129083
+
+#define BOARD_TWINPASS                 "Twinpass"
+#define BOARD_TWINPASS_CHIPID  0x3012D083
+
+#define BOARD_DANUBE                   "Danube"
+
+static unsigned int chiprev;
+
 static struct platform_device *ifxmips_devs[MAX_IFXMIPS_DEVS];
 
 static struct platform_device ifxmips_led[] =
@@ -46,6 +57,61 @@ static struct platform_device ifxmips_led[] =
        },
 };
 
+static struct platform_device ifxmips_gpio[] =
+{
+       {
+               .id = 0,
+               .name = "ifxmips_gpio",
+       },
+};
+
+static struct platform_device ifxmips_mii[] =
+{
+       {
+               .id = 0,
+               .name = "ifxmips_mii0",
+       },
+};
+
+static struct physmap_flash_data ifxmips_mtd_data = {
+       .width    = 2,
+};
+
+static struct resource ifxmips_mtd_resource = {
+       .start  = IFXMIPS_FLASH_START,
+       .end    = IFXMIPS_FLASH_START + IFXMIPS_FLASH_MAX - 1,
+       .flags  = IORESOURCE_MEM,
+};
+
+static struct platform_device ifxmips_mtd[] =
+{
+       {
+               .id = 0,
+               .name = "ifxmips_mtd",
+               .dev = {
+                       .platform_data = &ifxmips_mtd_data,
+               },
+               .num_resources  = 1,
+               .resource   = &ifxmips_mtd_resource,
+       },
+};
+
+const char*
+get_system_type (void)
+{
+       chiprev = readl(IFXMIPS_MPS_CHIPID);
+       switch(chiprev)
+       {
+       case BOARD_DANUBE_CHIPID:
+               return BOARD_DANUBE;
+
+       case BOARD_TWINPASS_CHIPID:
+               return BOARD_TWINPASS;
+       }
+
+       return BOARD_SYSTEM_TYPE;
+}
+
 int __init ifxmips_init_devices(void)
 {
        /*
@@ -61,6 +127,9 @@ int __init ifxmips_init_devices(void)
        /* the following devices are generic for all targets */
 
        ifxmips_devs[dev++] = ifxmips_led;
+       ifxmips_devs[dev++] = ifxmips_gpio;
+       ifxmips_devs[dev++] = ifxmips_mii;
+       ifxmips_devs[dev++] = ifxmips_mtd;
 
        return platform_add_devices(ifxmips_devs, dev);
 }