adds gpiodev support to ifxmips
[librecmc/librecmc.git] / target / linux / ifxmips / files / arch / mips / ifxmips / board.c
index 05a0715d1fb7e36a10ab459306b3c5d4fef95f0d..d925cf23620821d6413478ec34529220e94c9ce3 100644 (file)
@@ -27,7 +27,7 @@
 #include <linux/mtd/physmap.h>
 #include <linux/kernel.h>
 #include <linux/reboot.h>
-#include <linux/platform_device.h> 
+#include <linux/platform_device.h>
 #include <asm/bootinfo.h>
 #include <asm/reboot.h>
 #include <asm/time.h>
 #include <asm/io.h>
 #include <asm/ifxmips/ifxmips.h>
 
-#define MAX_IFXMIPS_DEVS               5
+#define MAX_IFXMIPS_DEVS               6
 
 #define BOARD_DANUBE                   "Danube"
 #define BOARD_DANUBE_CHIPID            0x10129083
 
 #define BOARD_TWINPASS                 "Twinpass"
+#define BOARD_TWINPASS_CHIPID  0x3012D083
 
 #define BOARD_DANUBE                   "Danube"
 
@@ -72,14 +73,60 @@ static struct platform_device ifxmips_mii[] =
        },
 };
 
+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,
+       },
+};
+
+#ifdef CONFIG_GPIO_DEVICE
+static struct resource ifxmips_gpio_dev_resources[] = {
+       {
+               .name = "gpio",
+               .flags  = 0,
+               .start = (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3) | (1 << 4) | (1 << 5) | (1 << 8) | (1 << 9) | (1 << 12),
+               .end = (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3) | (1 << 4) | (1 << 5) | (1 << 8) | (1 << 9) | (1 << 12),
+       },
+};
+
+static struct platform_device ifxmips_gpio_dev[] = {
+       {
+               .name     = "GPIODEV",
+               .id     = -1,
+               .num_resources    = ARRAY_SIZE(ifxmips_gpio_dev_resources),
+               .resource   = ifxmips_gpio_dev_resources,
+       }
+};
+#endif
+
 const char*
 get_system_type (void)
 {
-       chiprev = readl(IFXMIPS_MPS_CHIPID);
+       chiprev = ifxmips_r32(IFXMIPS_MPS_CHIPID);
        switch(chiprev)
        {
        case BOARD_DANUBE_CHIPID:
                return BOARD_DANUBE;
+
+       case BOARD_TWINPASS_CHIPID:
+               return BOARD_TWINPASS;
        }
 
        return BOARD_SYSTEM_TYPE;
@@ -92,17 +139,18 @@ int __init ifxmips_init_devices(void)
        *       Currently we support 3 chips
        *       1.) Danube
        *       2.) Twinpass (Danube without dsl phy)
-       *       3.) KDbg74 (used for debuging)
        */
 
        int dev = 0;
 
        /* 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;
+#ifdef CONFIG_GPIO_DEVICE
+       ifxmips_devs[dev++] = ifxmips_gpio_dev;
+#endif
        return platform_add_devices(ifxmips_devs, dev);
 }