+static struct platform_t __init *platform_detect(void)
+{
+ enum bcm47xx_board board;
+ const char *board_name;
+
+
+ board = bcm47xx_board_get();
+ board_name = bcm47xx_board_get_name();
+ if (board != BCM47XX_BOARD_UNKNOWN && board != BCM47XX_BOARD_NON)
+ printk(MODULE_NAME ": kernel found a \"%s\"\n", board_name);
+
+ switch(board) {
+ case BCM47XX_BOARD_ASUS_RTN16:
+ return &platforms[RTN16];
+ case BCM47XX_BOARD_ASUS_WL330GE:
+ return &platforms[WL330GE];
+ case BCM47XX_BOARD_ASUS_WL500GPV1:
+ return &platforms[WL500GP];
+ case BCM47XX_BOARD_ASUS_WL500GPV2:
+ return &platforms[WL500GPV2];
+ 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_BELKIN_F7D4301:
+ return &platforms[BELKIN_F7D4301];
+ case BCM47XX_BOARD_BUFFALO_WBR2_G54:
+ return &platforms[WBR2_G54];
+ case BCM47XX_BOARD_BUFFALO_WHR2_A54G54:
+ return &platforms[WHR2_A54G54];
+ case BCM47XX_BOARD_BUFFALO_WHR_G125:
+ return &platforms[WHR_G125];
+ case BCM47XX_BOARD_BUFFALO_WHR_G54S:
+ return &platforms[WHR_G54S];
+ case BCM47XX_BOARD_BUFFALO_WHR_HP_G54:
+ return &platforms[WHR_HP_G54];
+ case BCM47XX_BOARD_BUFFALO_WLA2_G54L:
+ return &platforms[WLA2_G54L];
+ case BCM47XX_BOARD_BUFFALO_WZR_G300N:
+ return &platforms[WZR_G300N];
+ case BCM47XX_BOARD_BUFFALO_WZR_RS_G54:
+ return &platforms[WZR_RS_G54];
+ case BCM47XX_BOARD_BUFFALO_WZR_RS_G54HP:
+ return &platforms[WZR_RS_G54HP];
+ case BCM47XX_BOARD_DELL_TM2300:
+ return &platforms[TM2300];
+ case BCM47XX_BOARD_DLINK_DIR130:
+ return &platforms[DIR130];
+ case BCM47XX_BOARD_DLINK_DIR330:
+ return &platforms[DIR330];
+ case BCM47XX_BOARD_LINKSYS_E1000V1:
+ return &platforms[E1000V1];
+ case BCM47XX_BOARD_LINKSYS_E3000V1:
+ return &platforms[E3000V1];
+ case BCM47XX_BOARD_LINKSYS_E3200V1:
+ return &platforms[E3200V1];
+ case BCM47XX_BOARD_LINKSYS_WRT150NV1:
+ return &platforms[WRT150NV1];
+ case BCM47XX_BOARD_LINKSYS_WRT150NV11:
+ return &platforms[WRT150NV11];
+ case BCM47XX_BOARD_LINKSYS_WRT160NV1:
+ return &platforms[WRT160NV1];
+ case BCM47XX_BOARD_LINKSYS_WRT160NV3:
+ return &platforms[WRT160NV3];
+ case BCM47XX_BOARD_LINKSYS_WRT300NV11:
+ return &platforms[WRT300NV11];
+ case BCM47XX_BOARD_LINKSYS_WRT54G3GV2:
+ return &platforms[WRT54G3GV2_VF];
+ case BCM47XX_BOARD_LINKSYS_WRT610NV1:
+ return &platforms[WRT610N];
+ case BCM47XX_BOARD_LINKSYS_WRT610NV2:
+ return &platforms[WRT610NV2];
+ case BCM47XX_BOARD_MOTOROLA_WE800G:
+ return &platforms[WE800G];
+ case BCM47XX_BOARD_MOTOROLA_WR850GP:
+ return &platforms[WR850GP];
+ case BCM47XX_BOARD_MOTOROLA_WR850GV2V3:
+ return &platforms[WR850GV2V3];
+ case BCM47XX_BOARD_NETGEAR_WNDR3400V1:
+ return &platforms[WNDR3400V1];
+ case BCM47XX_BOARD_NETGEAR_WNDR3700V3:
+ return &platforms[WNDR3700V3];
+ case BCM47XX_BOARD_UNKNOWN:
+ case BCM47XX_BOARD_NON:
+ printk(MODULE_NAME ": unknown board found, try legacy detect\n");
+ printk(MODULE_NAME ": please open a ticket at https://dev.openwrt.org and attach the complete nvram\n");
+ return platform_detect_legacy();
+ default:
+ printk(MODULE_NAME ": board was detected as \"%s\", but not gpio configuration available\n", board_name);
+ printk(MODULE_NAME ": now trying legacy detect\n");
+ return platform_detect_legacy();
+ }
+}
+
+static inline void ssb_maskset32(struct ssb_device *dev,
+ u16 offset, u32 mask, u32 set)
+{
+ ssb_write32(dev, offset, (ssb_read32(dev, offset) & mask) | set);
+}
+
+static void gpio_set_irqenable(int enabled, irqreturn_t (*handler)(int, void *))
+{
+ int irq;
+
+ irq = gpio_to_irq(0);
+ if (irq == -EINVAL) return;
+
+ if (enabled) {
+ if (request_irq(irq, handler, IRQF_SHARED, "gpio", handler))
+ return;
+ } else {
+ free_irq(irq, handler);
+ }
+
+ switch (bcm47xx_bus_type) {
+#ifdef CONFIG_BCM47XX_SSB
+ case BCM47XX_BUS_TYPE_SSB:
+ if (bcm47xx_bus.ssb.chipco.dev)
+ ssb_maskset32(bcm47xx_bus.ssb.chipco.dev, SSB_CHIPCO_IRQMASK, ~SSB_CHIPCO_IRQ_GPIO, (enabled ? SSB_CHIPCO_IRQ_GPIO : 0));
+ break;
+#endif
+#ifdef CONFIG_BCM47XX_BCMA
+ case BCM47XX_BUS_TYPE_BCMA:
+ if (bcm47xx_bus.bcma.bus.drv_cc.core)
+ bcma_maskset32(bcm47xx_bus.bcma.bus.drv_cc.core, BCMA_CC_IRQMASK, ~BCMA_CC_IRQ_GPIO, (enabled ? BCMA_CC_IRQ_GPIO : 0));
+ break;
+#endif
+ }
+}
+