From 7bbf4117c6fe4b764d9d7c62fb2bcf6dd93bff2c Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Tue, 3 Oct 2017 18:02:59 +0200 Subject: ar71xx: Add kernel 4.9 support This add support for kernel 4.9 to the ar71xx target. It was compile tested with the generic, NAND and mikrotik subtarget. Multiple members of the community tested it on their boards and did not report any major problem so far. Especially the NAND part received some changes to adapt to the new kernel APIs. The serial driver hack used for the Arduino Yun was not ported because the kernel changed there a lot. Signed-off-by: Hauke Mehrtens --- .../net/ethernet/atheros/ag71xx/ag71xx_mdio.c | 4 ++++ .../net/ethernet/atheros/ag71xx/ag71xx_phy.c | 28 +++++++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) (limited to 'target/linux/ar71xx/files/drivers/net/ethernet') diff --git a/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_mdio.c b/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_mdio.c index b63a4b7f9d..2915476569 100644 --- a/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_mdio.c +++ b/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_mdio.c @@ -254,7 +254,11 @@ static int ag71xx_mdio_probe(struct platform_device *pdev) am->mii_bus->read = ag71xx_mdio_read; am->mii_bus->write = ag71xx_mdio_write; am->mii_bus->reset = ag71xx_mdio_reset; +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,5,0) am->mii_bus->irq = am->mii_irq; +#else + memcpy(am->mii_bus->irq, am->mii_irq, sizeof(am->mii_bus->irq)); +#endif am->mii_bus->priv = am; am->mii_bus->parent = &pdev->dev; snprintf(am->mii_bus->id, MII_BUS_ID_SIZE, "%s", dev_name(&pdev->dev)); diff --git a/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_phy.c b/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_phy.c index 9de77e924b..12fa2e301b 100644 --- a/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_phy.c +++ b/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_phy.c @@ -112,6 +112,7 @@ static int ag71xx_phy_connect_multi(struct ag71xx *ag) if (!(pdata->phy_mask & (1 << phy_addr))) continue; +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,5,0) if (ag->mii_bus->phy_map[phy_addr] == NULL) continue; @@ -122,6 +123,18 @@ static int ag71xx_phy_connect_multi(struct ag71xx *ag) if (phydev == NULL) phydev = ag->mii_bus->phy_map[phy_addr]; +#else + if (ag->mii_bus->mdio_map[phy_addr] == NULL) + continue; + + DBG("%s: PHY found at %s, uid=%08x\n", + dev_name(dev), + dev_name(&ag->mii_bus->mdio_map[phy_addr]->dev), + ag->mii_bus->mdio_map[phy_addr]->phy_id); + + if (phydev == NULL) + phydev = mdiobus_get_phy(ag->mii_bus, phy_addr); +#endif } if (!phydev) { @@ -130,13 +143,21 @@ static int ag71xx_phy_connect_multi(struct ag71xx *ag) return -ENODEV; } +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,5,0) ag->phy_dev = phy_connect(ag->dev, dev_name(&phydev->dev), +#else + ag->phy_dev = phy_connect(ag->dev, phydev_name(phydev), +#endif &ag71xx_phy_link_adjust, pdata->phy_if_mode); if (IS_ERR(ag->phy_dev)) { dev_err(dev, "could not connect to PHY at %s\n", +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,5,0) dev_name(&phydev->dev)); +#else + phydev_name(phydev)); +#endif return PTR_ERR(ag->phy_dev); } @@ -149,7 +170,12 @@ static int ag71xx_phy_connect_multi(struct ag71xx *ag) phydev->advertising = phydev->supported; dev_info(dev, "connected to PHY at %s [uid=%08x, driver=%s]\n", - dev_name(&phydev->dev), phydev->phy_id, phydev->drv->name); +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,5,0) + dev_name(&phydev->dev), +#else + phydev_name(phydev), +#endif + phydev->phy_id, phydev->drv->name); ag->link = 0; ag->speed = 0; -- cgit v1.2.3