fix wr850g detection (#1936)
[openwrt/openwrt.git] / package / broadcom-diag / src / diag.c
index 6a70ed002c21f27a02c321dda73bb654fe4ec1bd..35737b002f92f8c26c184c40fdf2480264075c09 100644 (file)
@@ -113,6 +113,7 @@ enum {
        /* D-Link */
        DIR130,
        DIR330,
+       DWL3150,
 };
 
 static void __init bcm4780_init(void) {
@@ -491,7 +492,7 @@ static struct platform_t __initdata platforms[] = {
                .leds           = {
                        { .name = "power",      .gpio = 1 << 1, .polarity = NORMAL },
                        { .name = "wlan",       .gpio = 1 << 0, .polarity = REVERSE },
-                       { .name = "dmz",        .gpio = 1 << 6, .polarity = REVERSE },
+                       { .name = "wan",        .gpio = 1 << 6, .polarity = INPUT },
                        { .name = "diag",       .gpio = 1 << 7, .polarity = REVERSE },
                },
        },
@@ -579,6 +580,16 @@ static struct platform_t __initdata platforms[] = {
                        { .name = "blue",       .gpio = 1 << 6},
                },
        },
+       [DWL3150] = {
+               .name   = "D-Link DWL-3150",
+               .buttons        = {
+                       { .name = "reset",      .gpio = 1 << 7},
+               },
+               .leds     = {
+                       { .name = "diag",       .gpio = 1 << 2},
+                       { .name = "status",     .gpio = 1 << 1},
+               },
+       },
 };
 
 static struct platform_t __init *platform_detect(void)
@@ -702,7 +713,8 @@ static struct platform_t __init *platform_detect(void)
                        return &platforms[BUFFALO_UNKNOWN];
        }
 
-       if (!strcmp(getvar("CFEver"), "MotoWRv203") ||
+       if (!strncmp(getvar("CFEver"), "MotoWRv2", 8) ||
+               !strncmp(getvar("CFEver"), "MotoWRv3", 8) ||
                !strcmp(getvar("MOTO_BOARD_TYPE"), "WR_FEM1")) {
 
                return &platforms[WR850GV2V3];
@@ -715,6 +727,9 @@ static struct platform_t __init *platform_detect(void)
        if (!strncmp(boardnum, "04FN52", 6)) /* SimpleTech SimpleShare */
                return &platforms[STI_NAS];
 
+       if (!strcmp(getvar("boardnum"), "10") && !strcmp(getvar("boardrev"), "0x13")) /* D-Link DWL-3150 */
+               return &platforms[DWL3150];
+
        /* not found */
        return NULL;
 }
@@ -879,6 +894,7 @@ static void register_leds(struct led_t *l)
 {
        struct proc_dir_entry *p;
        u32 mask = 0;
+       u32 oe_mask = 0;
        u32 val = 0;
 
        leds = proc_mkdir("led", diag);
@@ -893,10 +909,13 @@ static void register_leds(struct led_t *l)
                        l->state = 0;
                        set_led_extif(l);
                } else {
+                       if (l->polarity != INPUT) oe_mask != l->gpio;
                        mask |= l->gpio;
                        val |= (l->polarity == NORMAL)?0:l->gpio;
                }
 
+               if (l->polarity == INPUT) continue;
+
                if ((p = create_proc_entry(l->name, S_IRUSR, leds))) {
                        l->proc.type = PROC_LED;
                        l->proc.ptr = l;
@@ -905,7 +924,7 @@ static void register_leds(struct led_t *l)
                }
        }
 
-       gpio_outen(mask, mask);
+       gpio_outen(mask, oe_mask);
        gpio_control(mask, 0);
        gpio_out(mask, val);
 }