diff options
author | Hauke Mehrtens <hauke@hauke-m.de> | 2017-10-03 18:02:59 +0200 |
---|---|---|
committer | Hauke Mehrtens <hauke@hauke-m.de> | 2017-10-11 22:32:39 +0200 |
commit | 7bbf4117c6fe4b764d9d7c62fb2bcf6dd93bff2c (patch) | |
tree | e42a4555f9845f78fb9baf7102da8d3d45adfacc /target/linux/ar71xx/files/drivers/net | |
parent | 2909a4b78e2bce5f6b9c35361866d5e9477a1bdc (diff) | |
download | upstream-7bbf4117c6fe4b764d9d7c62fb2bcf6dd93bff2c.tar.gz upstream-7bbf4117c6fe4b764d9d7c62fb2bcf6dd93bff2c.tar.bz2 upstream-7bbf4117c6fe4b764d9d7c62fb2bcf6dd93bff2c.zip |
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 <hauke@hauke-m.de>
Diffstat (limited to 'target/linux/ar71xx/files/drivers/net')
3 files changed, 72 insertions, 64 deletions
diff --git a/target/linux/ar71xx/files/drivers/net/dsa/mv88e6063.c b/target/linux/ar71xx/files/drivers/net/dsa/mv88e6063.c index b9e9af35b8..5b6da713f4 100644 --- a/target/linux/ar71xx/files/drivers/net/dsa/mv88e6063.c +++ b/target/linux/ar71xx/files/drivers/net/dsa/mv88e6063.c @@ -17,6 +17,7 @@ #include <linux/netdevice.h> #include <linux/phy.h> #include <net/dsa.h> +#include <linux/version.h> #define REG_BASE 0x10 #define REG_PHY(p) (REG_BASE + (p)) @@ -26,11 +27,12 @@ static int reg_read(struct dsa_switch *ds, int addr, int reg) { -#if LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0) - return mdiobus_read(ds->master_mii_bus, addr, reg); -#else +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,7,0) struct mii_bus *bus = dsa_host_dev_to_mii_bus(ds->master_dev); return mdiobus_read(bus, addr, reg); +#else + struct mii_bus *bus = dsa_host_dev_to_mii_bus(ds->dev); + return mdiobus_read(bus, addr, reg); #endif } @@ -47,14 +49,22 @@ static int reg_read(struct dsa_switch *ds, int addr, int reg) static int reg_write(struct dsa_switch *ds, int addr, int reg, u16 val) { -#if LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0) - return mdiobus_write(ds->master_mii_bus, addr, reg, val); -#else +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,7,0) struct mii_bus *bus = dsa_host_dev_to_mii_bus(ds->master_dev); return mdiobus_write(bus, addr, reg, val); +#else + struct mii_bus *bus = dsa_host_dev_to_mii_bus(ds->dev); + return mdiobus_write(bus, addr, reg, val); #endif } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,8,0) +static enum dsa_tag_protocol mv88e6063_get_tag_protocol(struct dsa_switch *ds) +{ + return DSA_TAG_PROTO_TRAILER; +} +#endif + #define REG_WRITE(addr, reg, val) \ ({ \ int __ret; \ @@ -64,16 +74,20 @@ static int reg_write(struct dsa_switch *ds, int addr, int reg, u16 val) return __ret; \ }) -#if LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0) -static char *mv88e6063_probe(struct mii_bus *bus, int sw_addr) -{ +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,7,0) +static char *mv88e6063_drv_probe(struct device *host_dev, int sw_addr) #else -static char *mv88e6063_probe(struct device *host_dev, int sw_addr) +static const char *mv88e6063_drv_probe(struct device *dsa_dev, + struct device *host_dev, int sw_addr, + void **_priv) +#endif { struct mii_bus *bus = dsa_host_dev_to_mii_bus(host_dev); -#endif int ret; + if (!bus) + return NULL; + ret = mdiobus_read(bus, REG_PORT(0), 0x03); if (ret >= 0) { ret &= 0xfff0; @@ -163,7 +177,11 @@ static int mv88e6063_setup_port(struct dsa_switch *ds, int p) REG_WRITE(addr, 0x06, ((p & 0xf) << 12) | (dsa_is_cpu_port(ds, p) ? +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,7,0) ds->phys_port_mask : +#else + ds->enabled_port_mask : +#endif (1 << ds->dst->cpu_port))); /* @@ -240,72 +258,32 @@ mv88e6063_phy_write(struct dsa_switch *ds, int port, int regnum, u16 val) return reg_write(ds, addr, regnum, val); } -static void mv88e6063_poll_link(struct dsa_switch *ds) -{ - int i; - - for (i = 0; i < DSA_MAX_PORTS; i++) { - struct net_device *dev; - int uninitialized_var(port_status); - int link; - int speed; - int duplex; - int fc; - - dev = ds->ports[i]; - if (dev == NULL) - continue; - - link = 0; - if (dev->flags & IFF_UP) { - port_status = reg_read(ds, REG_PORT(i), 0x00); - if (port_status < 0) - continue; - - link = !!(port_status & 0x1000); - } - - if (!link) { - if (netif_carrier_ok(dev)) { - printk(KERN_INFO "%s: link down\n", dev->name); - netif_carrier_off(dev); - } - continue; - } - - speed = (port_status & 0x0100) ? 100 : 10; - duplex = (port_status & 0x0200) ? 1 : 0; - fc = ((port_status & 0xc000) == 0xc000) ? 1 : 0; - - if (!netif_carrier_ok(dev)) { - printk(KERN_INFO "%s: link up, %d Mb/s, %s duplex, " - "flow control %sabled\n", dev->name, - speed, duplex ? "full" : "half", - fc ? "en" : "dis"); - netif_carrier_on(dev); - } - } -} - -static struct dsa_switch_driver mv88e6063_switch_driver = { +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,9,0) +static struct dsa_switch_driver mv88e6063_switch_ops = { +#else +static struct dsa_switch_ops mv88e6063_switch_ops = { +#endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,8,0) .tag_protocol = htons(ETH_P_TRAILER), - .probe = mv88e6063_probe, +#else + .get_tag_protocol = mv88e6063_get_tag_protocol, +#endif + .probe = mv88e6063_drv_probe, .setup = mv88e6063_setup, .set_addr = mv88e6063_set_addr, .phy_read = mv88e6063_phy_read, .phy_write = mv88e6063_phy_write, - .poll_link = mv88e6063_poll_link, }; static int __init mv88e6063_init(void) { - register_switch_driver(&mv88e6063_switch_driver); + register_switch_driver(&mv88e6063_switch_ops); return 0; } module_init(mv88e6063_init); static void __exit mv88e6063_cleanup(void) { - unregister_switch_driver(&mv88e6063_switch_driver); + unregister_switch_driver(&mv88e6063_switch_ops); } module_exit(mv88e6063_cleanup); 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; |