broadcom-diag: add GPIO configuration for Linksys E2000 V1
[openwrt/svn-archive/archive.git] / package / kernel / broadcom-diag / src / diag.c
index f5c834617fe9b85e911241237b8ace3508309cbd..d4ba0b0fbe9cea285bf3409cf75bc8c7ca56ed4a 100644 (file)
@@ -83,14 +83,18 @@ enum {
        WRT160NV1,
        WRT160NV3,
        WRT300NV11,
+       WRT310NV1,
        WRT350N,
        WRT600N,
        WRT600NV11,
        WRT610N,
        WRT610NV2,
        E1000V1,
+       E1000V21,
+       E2000V1,
        E3000V1,
        E3200V1,
+       E4200V1,
 
        /* ASUS */
        WLHDD,
@@ -106,7 +110,9 @@ enum {
        WL520GU,
        ASUS_4702,
        WL700GE,
+       RTN12,
        RTN16,
+       RTN66U,
 
        /* Buffalo */
        WBR2_G54,
@@ -118,7 +124,6 @@ enum {
        WZR_G300N,
        WZR_RS_G54,
        WZR_RS_G54HP,
-       BUFFALO_UNKNOWN,
        BUFFALO_UNKNOWN_4710,
 
        /* Siemens */
@@ -178,6 +183,9 @@ enum {
 
        /* Edimax */
        PS1208MFG,
+
+       /* Huawei */
+       HUAWEI_E970,
 };
 
 static void __init bcm4780_init(void) {
@@ -376,6 +384,18 @@ static struct platform_t __initdata platforms[] = {
                },
                .platform_init = bcm57xx_init,
        },
+       [WRT310NV1] = {
+               .name           = "Linksys WRT310N V1",
+               .buttons        = {
+                       { .name = "reset",      .gpio = 1 << 6 }, // "Reset" on back panel
+                       { .name = "ses",        .gpio = 1 << 8 }, // "Reserved" on top panel
+               },
+               .leds           = {
+                       { .name = "power",      .gpio = 1 << 1, .polarity = NORMAL }, // Power LED
+                       { .name = "ses_amber",  .gpio = 1 << 3, .polarity = REVERSE }, // "Security" Amber
+                       { .name = "ses_blue",   .gpio = 1 << 9, .polarity = REVERSE }, // "Security" Blue
+               },
+       },
        [WRT350N] = {
                .name           = "Linksys WRT350N",
                .buttons        = {
@@ -469,6 +489,32 @@ static struct platform_t __initdata platforms[] = {
                        { .name = "ses_orange", .gpio = 1 << 2, .polarity = REVERSE }, /* nvram get gpio2=wps_status_led */
                },
        },
+       [E1000V21] = {
+               .name           = "Linksys E1000 V2.1",
+               .buttons        = {
+                       { .name = "reset",      .gpio = 1 << 10 }, /* nvram get reset_gpio=10 */
+                       { .name = "wps",        .gpio = 1 << 9 }, /* nvram get gpio9=wps_button */
+               },
+               .leds           = {
+                       { .name = "power",      .gpio = 1 << 6, .polarity = REVERSE },
+                       { .name = "wlan",       .gpio = 1 << 5, .polarity = NORMAL },
+                       { .name = "ses_blue",   .gpio = 1 << 8, .polarity = NORMAL }, /* nvram get gpio8=wps_led */
+                       { .name = "ses_orange", .gpio = 1 << 7, .polarity = NORMAL }, /* nvram get gpio7=wps_status_led */
+               },
+       },
+       [E2000V1] = {
+               .name           = "Linksys E2000 V1",
+               .buttons        = {
+                       { .name = "reset",      .gpio = 1 << 8 },
+                       { .name = "ses",        .gpio = 1 << 5 },
+               },
+               .leds           = {
+                       { .name = "power",      .gpio = 1 << 2, .polarity = NORMAL },
+                       { .name = "ses_amber",  .gpio = 1 << 4, .polarity = REVERSE },
+                       { .name = "ses_blue",   .gpio = 1 << 3, .polarity = REVERSE },
+                       { .name = "wlan",       .gpio = 1 << 1, .polarity = NORMAL },
+               },
+       },
        [E3000V1] = {
                .name           = "Linksys E3000 V1",
                .buttons        = {
@@ -495,6 +541,16 @@ static struct platform_t __initdata platforms[] = {
                        { .name = "power",      .gpio = 1 << 3, .polarity = REVERSE },  /* Power LED */
                },
        },
+       [E4200V1] = {
+               .name           = "Linksys E4200 V1",
+               .buttons        = {
+                       { .name = "reset",      .gpio = 1 << 6 },
+                       { .name = "wps",        .gpio = 1 << 4 },
+               },
+               .leds   = {
+                       { .name = "power",      .gpio = 1 << 5, .polarity = REVERSE },
+               },
+       },
        /* Asus */
        [WLHDD] = {
                .name           = "ASUS WL-HDD",
@@ -634,6 +690,23 @@ static struct platform_t __initdata platforms[] = {
                },
                .platform_init = bcm4780_init,
        },
+       [RTN12] = {
+               .name           = "ASUS RT-N12",
+               .buttons        = {
+                       { .name = "wps",        .gpio = 1 << 0 },
+                       { .name = "reset",      .gpio = 1 << 1 },
+                       // this is the router/repeater/ap switch
+                       { .name = "sw1",        .gpio = 1 << 4 },
+                       { .name = "sw2",        .gpio = 1 << 5 },
+                       { .name = "sw3",        .gpio = 1 << 6 },
+               },
+               .leds           = {
+                       { .name = "power",      .gpio = 1 << 2, .polarity = REVERSE },
+                       { .name = "wlan",       .gpio = 1 << 7, .polarity = NORMAL },
+                       // gpio3 forces WAN and LAN1-4 all on
+                       //{ .name = "eth",      .gpio = 1 << 3, .polarity = REVERSE },
+               },
+       },
        [RTN16] = {
                .name           = "ASUS RT-N16",
                .buttons        = {
@@ -645,6 +718,17 @@ static struct platform_t __initdata platforms[] = {
                        { .name = "wlan",       .gpio = 1 << 7, .polarity = NORMAL },
                },
        },
+       [RTN66U] = {
+               .name           = "ASUS RT-N66U",
+               .buttons        = {
+                       { .name = "reset",      .gpio = 1 << 9 },
+                       { .name = "wps",        .gpio = 1 << 4 },
+               },
+               .leds           = {
+                       { .name = "power",      .gpio = 1 << 12, .polarity = REVERSE },
+                       { .name = "usb",        .gpio = 1 << 15, .polarity = REVERSE },
+               },
+       },
        /* Buffalo */
        [WHR_G54S] = {
                .name           = "Buffalo WHR-G54S",
@@ -755,15 +839,6 @@ static struct platform_t __initdata platforms[] = {
                        { .name = "vpn",        .gpio = 1 << 1, .polarity = REVERSE },
                },
        },
-       [BUFFALO_UNKNOWN] = {
-               .name           = "Buffalo (unknown)",
-               .buttons        = {
-                       { .name = "reset",      .gpio = 1 << 7 },
-               },
-               .leds           = {
-                       { .name = "diag",       .gpio = 1 << 1, .polarity = REVERSE },
-               },
-       },
        [BUFFALO_UNKNOWN_4710] = {
                .name           = "Buffalo (unknown, BCM4710)",
                .buttons        = {
@@ -1114,6 +1189,16 @@ static struct platform_t __initdata platforms[] = {
                        { .name = "wlan",       .gpio = 1 << 0, .polarity = NORMAL },
                },
        },
+       /* Huawei */
+       [HUAWEI_E970] = {
+               .name           = "Huawei E970",
+               .buttons        = {
+                       { .name = "reset",      .gpio = 1 << 6 },
+               },
+               .leds           = {
+                       { .name = "wlan",       .gpio = 1 << 0, .polarity = NORMAL },
+               },
+       },
 };
 
 static struct platform_t __init *platform_detect_legacy(void)
@@ -1145,8 +1230,9 @@ static struct platform_t __init *platform_detect_legacy(void)
                        if (!strcmp(boardtype, "0x0101") && !strcmp(getvar("boot_ver"), "v3.6"))
                                return &platforms[WRT54G3G];
 
-                       /* default to WRT54G */
-                       return &platforms[WRT54G];
+                       /* default to WRT54G if no boot_hw_model is set */
+                       if (nvram_get("boot_hw_model") == NULL)
+                               return &platforms[WRT54G];
                }
                if (!strcmp(boardnum, "1024") && !strcmp(boardtype, "0x0446"))
                        return &platforms[WAP54GV2];
@@ -1160,15 +1246,6 @@ static struct platform_t __init *platform_detect_legacy(void)
                                return &platforms[TM2300V2]; /* Dell TrueMobile 2300 v2 */
                }
 
-               if (!strcmp(boardnum, "45")) { /* ASUS */
-                       if (!strcmp(boardtype,"0x0472"))
-                               return &platforms[WL500W];
-                       else if (!strcmp(boardtype,"0x467"))
-                               return &platforms[WL320GE];
-                       else
-                               return &platforms[WL500GD];
-               }
-
                if (!strcmp(boardnum, "10496"))
                        return &platforms[USR5461];
 
@@ -1208,15 +1285,6 @@ static struct platform_t __init *platform_detect_legacy(void)
                        else
                                return &platforms[WL500G];
                }
-               if (startswith(getvar("hardware_version"), "WL300-")) {
-                       /* Either WL-300g or WL-HDD, do more extensive checks */
-                       if ((simple_strtoul(getvar("et0phyaddr"), NULL, 0) == 0) &&
-                               (simple_strtoul(getvar("et1phyaddr"), NULL, 0) == 1))
-                               return &platforms[WLHDD];
-                       if ((simple_strtoul(getvar("et0phyaddr"), NULL, 0) == 0) &&
-                               (simple_strtoul(getvar("et1phyaddr"), NULL, 0) == 10))
-                               return &platforms[WL300G];
-               }
                /* Sitecom WL-105b */
                if (startswith(boardnum, "2") && simple_strtoul(getvar("GemtekPmonVer"), NULL, 0) == 1)
                        return &platforms[WL105B];
@@ -1241,8 +1309,6 @@ static struct platform_t __init *platform_detect_legacy(void)
        if (boardnum || !strcmp(boardnum, "00")) {/* probably buffalo */
                if (startswith(boardtype, "bcm94710ap"))
                        return &platforms[BUFFALO_UNKNOWN_4710];
-               else
-                       return &platforms[BUFFALO_UNKNOWN];
        }
 
        if (startswith(getvar("CFEver"), "MotoWRv2") ||
@@ -1282,20 +1348,34 @@ static struct platform_t __init *platform_detect(void)
                printk(MODULE_NAME ": kernel found a \"%s\"\n", board_name);
 
        switch(board) {
+       case BCM47XX_BOARD_ASUS_RTN12:
+               return &platforms[RTN12];
        case BCM47XX_BOARD_ASUS_RTN16:
                return &platforms[RTN16];
+       case BCM47XX_BOARD_ASUS_RTN66U:
+               return &platforms[RTN66U];
+       case BCM47XX_BOARD_ASUS_WL300G:
+               return &platforms[WL300G];
+       case BCM47XX_BOARD_ASUS_WL320GE:
+               return &platforms[WL320GE];
        case BCM47XX_BOARD_ASUS_WL330GE:
                return &platforms[WL330GE];
+       case BCM47XX_BOARD_ASUS_WL500GD:
+               return &platforms[WL500GD];
        case BCM47XX_BOARD_ASUS_WL500GPV1:
                return &platforms[WL500GP];
        case BCM47XX_BOARD_ASUS_WL500GPV2:
                return &platforms[WL500GPV2];
+       case BCM47XX_BOARD_ASUS_WL500W:
+               return &platforms[WL500W];
        case BCM47XX_BOARD_ASUS_WL520GC:
                return &platforms[WL520GC];
        case BCM47XX_BOARD_ASUS_WL520GU:
                return &platforms[WL520GU];
        case BCM47XX_BOARD_ASUS_WL700GE:
                return &platforms[WL700GE];
+       case BCM47XX_BOARD_ASUS_WLHDD:
+               return &platforms[WLHDD];
        case BCM47XX_BOARD_BELKIN_F7D4301:
                return &platforms[BELKIN_F7D4301];
        case BCM47XX_BOARD_BUFFALO_WBR2_G54:
@@ -1322,12 +1402,20 @@ static struct platform_t __init *platform_detect(void)
                return &platforms[DIR130];
        case BCM47XX_BOARD_DLINK_DIR330:
                return &platforms[DIR330];
+       case BCM47XX_BOARD_HUAWEI_E970:
+               return &platforms[HUAWEI_E970];
        case BCM47XX_BOARD_LINKSYS_E1000V1:
                return &platforms[E1000V1];
+       case BCM47XX_BOARD_LINKSYS_E1000V21:
+               return &platforms[E1000V21];
+       case BCM47XX_BOARD_LINKSYS_E2000V1:
+               return &platforms[E2000V1];
        case BCM47XX_BOARD_LINKSYS_E3000V1:
                return &platforms[E3000V1];
        case BCM47XX_BOARD_LINKSYS_E3200V1:
                return &platforms[E3200V1];
+       case BCM47XX_BOARD_LINKSYS_E4200V1:
+               return &platforms[E4200V1];
        case BCM47XX_BOARD_LINKSYS_WRT150NV1:
                return &platforms[WRT150NV1];
        case BCM47XX_BOARD_LINKSYS_WRT150NV11:
@@ -1338,6 +1426,8 @@ static struct platform_t __init *platform_detect(void)
                return &platforms[WRT160NV3];
        case BCM47XX_BOARD_LINKSYS_WRT300NV11:
                return &platforms[WRT300NV11];
+       case BCM47XX_BOARD_LINKSYS_WRT310NV1:
+               return &platforms[WRT310NV1];
        case BCM47XX_BOARD_LINKSYS_WRT54G3GV2:
                return &platforms[WRT54G3GV2_VF];
        case BCM47XX_BOARD_LINKSYS_WRT610NV1:
@@ -1377,13 +1467,20 @@ static inline void ssb_maskset32(struct ssb_device *dev,
 static void gpio_set_irqenable(int enabled, irqreturn_t (*handler)(int, void *))
 {
        int irq;
+       int err;
 
        irq = gpio_to_irq(0);
-       if (irq == -EINVAL) return;
+       if (irq < 0) {
+               pr_err("no irq for gpio available\n");
+               return;
+       }
        
        if (enabled) {
-               if (request_irq(irq, handler, IRQF_SHARED, "gpio", handler))
+               err = request_irq(irq, handler, IRQF_SHARED, "gpio", handler);
+               if (err) {
+                       pr_err("can not reqeust irq\n");
                        return;
+               }
        } else {
                free_irq(irq, handler);
        }