From: Hauke Mehrtens Date: Sat, 5 Jul 2014 21:35:15 +0000 (+0000) Subject: brcm47xx: make it possible to unregister the adm switch X-Git-Tag: reboot~6648 X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=8e4efd42d98bbb5b5c4d891db3b889cb02dced01;p=openwrt%2Fstaging%2Fchunkeey.git brcm47xx: make it possible to unregister the adm switch Signed-off-by: Hauke Mehrtens SVN-Revision: 41517 --- diff --git a/target/linux/brcm47xx/patches-3.10/209-b44-register-adm-switch.patch b/target/linux/brcm47xx/patches-3.10/209-b44-register-adm-switch.patch index d44432cafb..62bb89ce20 100644 --- a/target/linux/brcm47xx/patches-3.10/209-b44-register-adm-switch.patch +++ b/target/linux/brcm47xx/patches-3.10/209-b44-register-adm-switch.patch @@ -19,66 +19,78 @@ Subject: [PATCH 210/210] b44: register adm switch #include #include -@@ -2227,6 +2229,58 @@ static void b44_adjust_link(struct net_d +@@ -2227,6 +2229,70 @@ static void b44_adjust_link(struct net_d } } +#ifdef CONFIG_BCM47XX -+static struct adm6996_gpio_platform_data b44_adm_data = { -+ .eecs = 2, -+ .eesk = 3, -+ .eedi = 4, -+ .eerc = 5, -+ .model = ADM6996L, -+}; -+ -+static struct platform_device b44_adm_dev = { -+ .name = "adm6996_gpio", -+ .id = -1, -+ .dev = { -+ .platform_data = &b44_adm_data, -+ }, -+}; -+ +static int b44_register_adm_switch(struct b44 *bp) +{ + int gpio; -+ int err; ++ struct platform_device *pdev; ++ struct adm6996_gpio_platform_data adm_data = {0}; ++ struct platform_device_info info = {0}; + ++ adm_data.model = ADM6996L; + gpio = bcm47xx_nvram_gpio_pin("adm_eecs"); + if (gpio >= 0) -+ b44_adm_data.eecs = gpio; ++ adm_data.eecs = gpio; ++ else ++ adm_data.eecs = 2; + + gpio = bcm47xx_nvram_gpio_pin("adm_eesk"); + if (gpio >= 0) -+ b44_adm_data.eesk = gpio; ++ adm_data.eesk = gpio; ++ else ++ adm_data.eesk = 3; + + gpio = bcm47xx_nvram_gpio_pin("adm_eedi"); + if (gpio >= 0) -+ b44_adm_data.eedi = gpio; ++ adm_data.eedi = gpio; ++ else ++ adm_data.eedi = 4; + + gpio = bcm47xx_nvram_gpio_pin("adm_rc"); + if (gpio >= 0) -+ b44_adm_data.eerc = gpio; ++ adm_data.eerc = gpio; ++ else ++ adm_data.eerc = 5; ++ ++ info.parent = bp->sdev->dev; ++ info.name = "adm6996_gpio"; ++ info.id = -1; ++ info.data = &adm_data; ++ info.size_data = sizeof(adm_data); + + if (!bp->adm_switch) { -+ err = platform_device_register(&b44_adm_dev); -+ if (!err) -+ bp->adm_switch = &b44_adm_dev; ++ pdev = platform_device_register_full(&info); ++ if (IS_ERR(pdev)) ++ return PTR_ERR(pdev); ++ ++ bp->adm_switch = pdev; + } -+ return err; ++ return 0; ++} ++static void b44_unregister_adm_switch(struct b44 *bp) ++{ ++ if (bp->adm_switch) ++ platform_device_unregister(bp->adm_switch); +} +#else +static int b44_register_adm_switch(struct b44 *bp) +{ + return 0; +} ++static void b44_unregister_adm_switch(struct b44 *bp) ++{ ++ ++} +#endif /* CONFIG_BCM47XX */ + static int b44_register_phy_one(struct b44 *bp) { struct mii_bus *mii_bus; -@@ -2270,6 +2324,9 @@ static int b44_register_phy_one(struct b +@@ -2270,6 +2336,9 @@ static int b44_register_phy_one(struct b if (!bp->mii_bus->phy_map[bp->phy_addr] && (sprom->boardflags_lo & (B44_BOARDFLAG_ROBO | B44_BOARDFLAG_ADM))) { @@ -88,6 +100,14 @@ Subject: [PATCH 210/210] b44: register adm switch dev_info(sdev->dev, "could not find PHY at %i, use fixed one\n", bp->phy_addr); +@@ -2465,6 +2534,7 @@ static void b44_remove_one(struct ssb_de + unregister_netdev(dev); + if (bp->flags & B44_FLAG_EXTERNAL_PHY) + b44_unregister_phy_one(bp); ++ b44_unregister_adm_switch(bp); + ssb_device_disable(sdev, 0); + ssb_bus_may_powerdown(sdev->bus); + free_netdev(dev); --- a/drivers/net/ethernet/broadcom/b44.h +++ b/drivers/net/ethernet/broadcom/b44.h @@ -404,6 +404,9 @@ struct b44 { diff --git a/target/linux/brcm47xx/patches-3.14/209-b44-register-adm-switch.patch b/target/linux/brcm47xx/patches-3.14/209-b44-register-adm-switch.patch index cd1072b684..108d79c0b8 100644 --- a/target/linux/brcm47xx/patches-3.14/209-b44-register-adm-switch.patch +++ b/target/linux/brcm47xx/patches-3.14/209-b44-register-adm-switch.patch @@ -19,66 +19,78 @@ Subject: [PATCH 210/210] b44: register adm switch #include #include -@@ -2239,6 +2241,58 @@ static void b44_adjust_link(struct net_d +@@ -2239,6 +2241,70 @@ static void b44_adjust_link(struct net_d } } +#ifdef CONFIG_BCM47XX -+static struct adm6996_gpio_platform_data b44_adm_data = { -+ .eecs = 2, -+ .eesk = 3, -+ .eedi = 4, -+ .eerc = 5, -+ .model = ADM6996L, -+}; -+ -+static struct platform_device b44_adm_dev = { -+ .name = "adm6996_gpio", -+ .id = -1, -+ .dev = { -+ .platform_data = &b44_adm_data, -+ }, -+}; -+ +static int b44_register_adm_switch(struct b44 *bp) +{ + int gpio; -+ int err; ++ struct platform_device *pdev; ++ struct adm6996_gpio_platform_data adm_data = {0}; ++ struct platform_device_info info = {0}; + ++ adm_data.model = ADM6996L; + gpio = bcm47xx_nvram_gpio_pin("adm_eecs"); + if (gpio >= 0) -+ b44_adm_data.eecs = gpio; ++ adm_data.eecs = gpio; ++ else ++ adm_data.eecs = 2; + + gpio = bcm47xx_nvram_gpio_pin("adm_eesk"); + if (gpio >= 0) -+ b44_adm_data.eesk = gpio; ++ adm_data.eesk = gpio; ++ else ++ adm_data.eesk = 3; + + gpio = bcm47xx_nvram_gpio_pin("adm_eedi"); + if (gpio >= 0) -+ b44_adm_data.eedi = gpio; ++ adm_data.eedi = gpio; ++ else ++ adm_data.eedi = 4; + + gpio = bcm47xx_nvram_gpio_pin("adm_rc"); + if (gpio >= 0) -+ b44_adm_data.eerc = gpio; ++ adm_data.eerc = gpio; ++ else ++ adm_data.eerc = 5; ++ ++ info.parent = bp->sdev->dev; ++ info.name = "adm6996_gpio"; ++ info.id = -1; ++ info.data = &adm_data; ++ info.size_data = sizeof(adm_data); + + if (!bp->adm_switch) { -+ err = platform_device_register(&b44_adm_dev); -+ if (!err) -+ bp->adm_switch = &b44_adm_dev; ++ pdev = platform_device_register_full(&info); ++ if (IS_ERR(pdev)) ++ return PTR_ERR(pdev); ++ ++ bp->adm_switch = pdev; + } -+ return err; ++ return 0; ++} ++static void b44_unregister_adm_switch(struct b44 *bp) ++{ ++ if (bp->adm_switch) ++ platform_device_unregister(bp->adm_switch); +} +#else +static int b44_register_adm_switch(struct b44 *bp) +{ + return 0; +} ++static void b44_unregister_adm_switch(struct b44 *bp) ++{ ++ ++} +#endif /* CONFIG_BCM47XX */ + static int b44_register_phy_one(struct b44 *bp) { struct mii_bus *mii_bus; -@@ -2282,6 +2336,9 @@ static int b44_register_phy_one(struct b +@@ -2282,6 +2348,9 @@ static int b44_register_phy_one(struct b if (!bp->mii_bus->phy_map[bp->phy_addr] && (sprom->boardflags_lo & (B44_BOARDFLAG_ROBO | B44_BOARDFLAG_ADM))) { @@ -88,6 +100,14 @@ Subject: [PATCH 210/210] b44: register adm switch dev_info(sdev->dev, "could not find PHY at %i, use fixed one\n", bp->phy_addr); +@@ -2476,6 +2545,7 @@ static void b44_remove_one(struct ssb_de + unregister_netdev(dev); + if (bp->flags & B44_FLAG_EXTERNAL_PHY) + b44_unregister_phy_one(bp); ++ b44_unregister_adm_switch(bp); + ssb_device_disable(sdev, 0); + ssb_bus_may_powerdown(sdev->bus); + free_netdev(dev); --- a/drivers/net/ethernet/broadcom/b44.h +++ b/drivers/net/ethernet/broadcom/b44.h @@ -404,6 +404,9 @@ struct b44 {