brcm47xx: b44: bgmac: some small changes to the phylib patches

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>

SVN-Revision: 38044
This commit is contained in:
Hauke Mehrtens 2013-09-18 16:49:52 +00:00
parent 5799adc238
commit 86f7ca96af
2 changed files with 24 additions and 38 deletions

View file

@ -35,8 +35,8 @@
- default: - default:
- return -EOPNOTSUPP; - return -EOPNOTSUPP;
- } - }
+ if (!netif_running(net_dev)) + if (!netif_running(net_dev))
+ return -EINVAL; + return -EINVAL;
+ +
+ if (!bgmac->phydev) + if (!bgmac->phydev)
+ return -EINVAL; + return -EINVAL;
@ -45,7 +45,7 @@
} }
static const struct net_device_ops bgmac_netdev_ops = { static const struct net_device_ops bgmac_netdev_ops = {
@@ -1271,61 +1258,18 @@ static int bgmac_get_settings(struct net @@ -1271,61 +1258,16 @@ static int bgmac_get_settings(struct net
{ {
struct bgmac *bgmac = netdev_priv(net_dev); struct bgmac *bgmac = netdev_priv(net_dev);
@ -97,7 +97,6 @@
} }
-#if 0 -#if 0
+
static int bgmac_set_settings(struct net_device *net_dev, static int bgmac_set_settings(struct net_device *net_dev,
struct ethtool_cmd *cmd) struct ethtool_cmd *cmd)
{ {
@ -107,11 +106,10 @@
+ return phy_ethtool_sset(bgmac->phydev, cmd); + return phy_ethtool_sset(bgmac->phydev, cmd);
} }
-#endif -#endif
+
static void bgmac_get_drvinfo(struct net_device *net_dev, static void bgmac_get_drvinfo(struct net_device *net_dev,
struct ethtool_drvinfo *info) struct ethtool_drvinfo *info)
@@ -1336,6 +1280,7 @@ static void bgmac_get_drvinfo(struct net @@ -1336,6 +1278,7 @@ static void bgmac_get_drvinfo(struct net
static const struct ethtool_ops bgmac_ethtool_ops = { static const struct ethtool_ops bgmac_ethtool_ops = {
.get_settings = bgmac_get_settings, .get_settings = bgmac_get_settings,
@ -119,7 +117,7 @@
.get_drvinfo = bgmac_get_drvinfo, .get_drvinfo = bgmac_get_drvinfo,
}; };
@@ -1354,10 +1299,42 @@ static int bgmac_mii_write(struct mii_bu @@ -1354,10 +1297,36 @@ static int bgmac_mii_write(struct mii_bu
return bgmac_phy_write(bus->priv, mii_id, regnum, value); return bgmac_phy_write(bus->priv, mii_id, regnum, value);
} }
@ -127,7 +125,7 @@
+{ +{
+ struct bgmac *bgmac = netdev_priv(dev); + struct bgmac *bgmac = netdev_priv(dev);
+ struct phy_device *phydev = bgmac->phydev; + struct phy_device *phydev = bgmac->phydev;
+ int status_changed = 0; + bool status_changed = 0;
+ +
+ BUG_ON(!phydev); + BUG_ON(!phydev);
+ +
@ -142,14 +140,8 @@
+ bgmac->old_duplex = phydev->duplex; + bgmac->old_duplex = phydev->duplex;
+ } + }
+ +
+ if (status_changed) { + if (status_changed)
+ pr_info("%s: link %s", dev->name, phydev->link ? + phy_print_status(phydev);
+ "UP" : "DOWN");
+ if (phydev->link)
+ pr_cont(" - %d/%s", phydev->speed,
+ phydev->duplex == DUPLEX_FULL ? "full" : "half");
+ pr_cont("\n");
+ }
+} +}
+ +
static int bgmac_mii_register(struct bgmac *bgmac) static int bgmac_mii_register(struct bgmac *bgmac)
@ -162,7 +154,7 @@
mii_bus = mdiobus_alloc(); mii_bus = mdiobus_alloc();
if (!mii_bus) if (!mii_bus)
@@ -1388,7 +1365,29 @@ static int bgmac_mii_register(struct bgm @@ -1388,7 +1357,28 @@ static int bgmac_mii_register(struct bgm
bgmac->mii_bus = mii_bus; bgmac->mii_bus = mii_bus;
@ -175,7 +167,7 @@
+ PHY_INTERFACE_MODE_MII); + PHY_INTERFACE_MODE_MII);
+ +
+ if (IS_ERR(phydev)) { + if (IS_ERR(phydev)) {
+ netdev_err(net_dev, "could not attach PHY: %s", phy_id); + netdev_err(net_dev, "could not attach PHY: %s\n", phy_id);
+ bgmac->phyaddr = BGMAC_PHY_NOREGS; + bgmac->phyaddr = BGMAC_PHY_NOREGS;
+ return PTR_ERR(phydev); + return PTR_ERR(phydev);
+ } + }
@ -185,9 +177,8 @@
+ bgmac->old_duplex = -1; + bgmac->old_duplex = -1;
+ bgmac->phyaddr = phydev->addr; + bgmac->phyaddr = phydev->addr;
+ +
+ netdev_info(net_dev, "attached PHY driver [%s] " + netdev_info(net_dev, "attached PHY driver [%s] (mii_bus:phy_addr=%s)\n",
+ "(mii_bus:phy_addr=%s)\n", + phydev->drv->name, dev_name(&phydev->dev));
+ phydev->drv->name, dev_name(&phydev->dev));
+ +
+ return 0; + return 0;

View file

@ -155,7 +155,7 @@
} }
static void b44_get_ringparam(struct net_device *dev, static void b44_get_ringparam(struct net_device *dev,
@@ -2102,20 +2027,81 @@ static const struct ethtool_ops b44_etht @@ -2102,20 +2027,74 @@ static const struct ethtool_ops b44_etht
static int b44_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) static int b44_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
{ {
@ -181,7 +181,7 @@
+{ +{
+ struct b44 *bp = netdev_priv(dev); + struct b44 *bp = netdev_priv(dev);
+ struct phy_device *phydev = bp->phydev; + struct phy_device *phydev = bp->phydev;
+ int status_changed = 0; + bool status_changed = 0;
+ +
+ BUG_ON(!phydev); + BUG_ON(!phydev);
+ +
@ -196,14 +196,8 @@
+ bp->old_duplex = phydev->duplex; + bp->old_duplex = phydev->duplex;
+ } + }
+ +
+ if (status_changed) { + if (status_changed)
+ pr_info("%s: link %s", dev->name, phydev->link ? + phy_print_status(phydev);
+ "UP" : "DOWN");
+ if (phydev->link)
+ pr_cont(" - %d/%s", phydev->speed,
+ phydev->duplex == DUPLEX_FULL ? "full" : "half");
+ pr_cont("\n");
+ }
+} +}
+ +
+static int b44_mii_probe(struct net_device *dev) +static int b44_mii_probe(struct net_device *dev)
@ -219,7 +213,7 @@
+ phydev = phy_connect(dev, phy_id, &b44_adjust_link, + phydev = phy_connect(dev, phy_id, &b44_adjust_link,
+ PHY_INTERFACE_MODE_MII); + PHY_INTERFACE_MODE_MII);
+ if (IS_ERR(phydev)) { + if (IS_ERR(phydev)) {
+ netdev_err(dev, "could not attach PHY: %s", phy_id); + netdev_err(dev, "could not attach PHY: %s\n", phy_id);
+ bp->phy_addr = B44_PHY_ADDR_NO_PHY; + bp->phy_addr = B44_PHY_ADDR_NO_PHY;
+ return PTR_ERR(phydev); + return PTR_ERR(phydev);
+ } + }
@ -229,9 +223,8 @@
+ bp->old_duplex = -1; + bp->old_duplex = -1;
+ bp->phy_addr = phydev->addr; + bp->phy_addr = phydev->addr;
+ +
+ netdev_info(dev, "attached PHY driver [%s] " + netdev_info(dev, "attached PHY driver [%s] (mii_bus:phy_addr=%s)\n",
+ "(mii_bus:phy_addr=%s)\n", + phydev->drv->name, dev_name(&phydev->dev));
+ phydev->drv->name, dev_name(&phydev->dev));
+ +
+ return 0; + return 0;
+} +}
@ -239,7 +232,7 @@
static int b44_get_invariants(struct b44 *bp) static int b44_get_invariants(struct b44 *bp)
{ {
struct ssb_device *sdev = bp->sdev; struct ssb_device *sdev = bp->sdev;
@@ -2235,12 +2221,38 @@ static int b44_init_one(struct ssb_devic @@ -2235,12 +2214,40 @@ static int b44_init_one(struct ssb_devic
goto err_out_powerdown; goto err_out_powerdown;
} }
@ -260,6 +253,8 @@
+ bp->mii_bus->read = b44_mii_read; + bp->mii_bus->read = b44_mii_read;
+ bp->mii_bus->write = b44_mii_write; + bp->mii_bus->write = b44_mii_write;
+ bp->mii_bus->name = "b44_eth_mii"; + bp->mii_bus->name = "b44_eth_mii";
+ bp->mii_bus->parent = sdev->dev;
+ bp->mii_bus->phy_mask = ~(1 << bp->phy_addr);
+ snprintf(bp->mii_bus->id, MII_BUS_ID_SIZE, "%x", instance); + snprintf(bp->mii_bus->id, MII_BUS_ID_SIZE, "%x", instance);
+ bp->mii_bus->irq = kmalloc(sizeof(int) * PHY_MAX_ADDR, GFP_KERNEL); + bp->mii_bus->irq = kmalloc(sizeof(int) * PHY_MAX_ADDR, GFP_KERNEL);
+ if (!bp->mii_bus->irq) { + if (!bp->mii_bus->irq) {
@ -284,7 +279,7 @@
/* By default, advertise all speed/duplex settings. */ /* By default, advertise all speed/duplex settings. */
bp->flags |= (B44_FLAG_ADV_10HALF | B44_FLAG_ADV_10FULL | bp->flags |= (B44_FLAG_ADV_10HALF | B44_FLAG_ADV_10FULL |
@@ -2272,6 +2284,16 @@ static int b44_init_one(struct ssb_devic @@ -2272,6 +2279,16 @@ static int b44_init_one(struct ssb_devic
return 0; return 0;
@ -301,7 +296,7 @@
err_out_powerdown: err_out_powerdown:
ssb_bus_may_powerdown(sdev->bus); ssb_bus_may_powerdown(sdev->bus);
@@ -2285,8 +2307,12 @@ out: @@ -2285,8 +2302,12 @@ out:
static void b44_remove_one(struct ssb_device *sdev) static void b44_remove_one(struct ssb_device *sdev)
{ {
struct net_device *dev = ssb_get_drvdata(sdev); struct net_device *dev = ssb_get_drvdata(sdev);