diff options
Diffstat (limited to 'target/linux/ar71xx/files/drivers')
11 files changed, 359 insertions, 71 deletions
diff --git a/target/linux/ar71xx/files/drivers/gpio/gpio-nxp-74hc153.c b/target/linux/ar71xx/files/drivers/gpio/gpio-nxp-74hc153.c index 8c01efe4a0..1355e3ff6e 100644 --- a/target/linux/ar71xx/files/drivers/gpio/gpio-nxp-74hc153.c +++ b/target/linux/ar71xx/files/drivers/gpio/gpio-nxp-74hc153.c @@ -168,7 +168,11 @@ static int nxp_74hc153_probe(struct platform_device *pdev) gc->base = pdata->gpio_base; gc->ngpio = NXP_74HC153_NUM_GPIOS; gc->label = dev_name(nxp->parent); +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,5,0) gc->dev = nxp->parent; +#else + gc->parent = nxp->parent; +#endif gc->owner = THIS_MODULE; err = gpiochip_add(&nxp->gpio_chip); diff --git a/target/linux/ar71xx/files/drivers/mtd/cybertan_part.c b/target/linux/ar71xx/files/drivers/mtd/cybertan_part.c index 391411f8de..4d33c19b7e 100644 --- a/target/linux/ar71xx/files/drivers/mtd/cybertan_part.c +++ b/target/linux/ar71xx/files/drivers/mtd/cybertan_part.c @@ -28,6 +28,7 @@ #include <linux/mtd/mtd.h> #include <linux/mtd/partitions.h> +#include <linux/version.h> struct cybertan_header { char magic[4]; @@ -82,7 +83,11 @@ struct firmware_header { #define NVRAM_LEN 0x10000 static int cybertan_parse_partitions(struct mtd_info *master, +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,5,0) struct mtd_partition **pparts, +#else + const struct mtd_partition **pparts, +#endif struct mtd_part_parser_data *data) { struct firmware_header *header; diff --git a/target/linux/ar71xx/files/drivers/mtd/nand/ar934x_nfc.c b/target/linux/ar71xx/files/drivers/mtd/nand/ar934x_nfc.c index a47fc0468e..a135e0f52f 100644 --- a/target/linux/ar71xx/files/drivers/mtd/nand/ar934x_nfc.c +++ b/target/linux/ar71xx/files/drivers/mtd/nand/ar934x_nfc.c @@ -18,6 +18,7 @@ #include <linux/platform_device.h> #include <linux/delay.h> #include <linux/slab.h> +#include <linux/version.h> #include <linux/platform/ar934x_nfc.h> @@ -187,7 +188,9 @@ nfc_debug_data(const char *label, void *data, int len) {} #endif /* AR934X_NFC_DEBUG_DATA */ struct ar934x_nfc { +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,6,0) struct mtd_info mtd; +#endif struct nand_chip nand_chip; struct device *parent; void __iomem *base; @@ -259,7 +262,22 @@ ar934x_nfc_get_platform_data(struct ar934x_nfc *nfc) static inline struct ar934x_nfc *mtd_to_ar934x_nfc(struct mtd_info *mtd) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,6,0) return container_of(mtd, struct ar934x_nfc, mtd); +#else + struct nand_chip *chip = mtd_to_nand(mtd); + + return container_of(chip, struct ar934x_nfc, nand_chip); +#endif +} + +static struct mtd_info *ar934x_nfc_to_mtd(struct ar934x_nfc *nfc) +{ +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,6,0) + return &nfc->mtd; +#else + return nand_to_mtd(&nfc->nand_chip); +#endif } static inline bool ar934x_nfc_use_irq(struct ar934x_nfc *nfc) @@ -648,7 +666,7 @@ ar934x_nfc_cmdfunc(struct mtd_info *mtd, unsigned int command, int column, int page_addr) { struct ar934x_nfc *nfc = mtd_to_ar934x_nfc(mtd); - struct nand_chip *nand = mtd->priv; + struct nand_chip *nand = &nfc->nand_chip; nfc->read_id = false; if (command != NAND_CMD_PAGEPROG) @@ -1241,6 +1259,7 @@ ar934x_nfc_init_tail(struct mtd_info *mtd) return err; } +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,6,0) static struct nand_ecclayout ar934x_nfc_oob_64_hwecc = { .eccbytes = 28, .eccpos = { @@ -1261,19 +1280,60 @@ static struct nand_ecclayout ar934x_nfc_oob_64_hwecc = { }, }; +#else + +static int ar934x_nfc_ooblayout_ecc(struct mtd_info *mtd, int section, + struct mtd_oob_region *oobregion) +{ + if (section) + return -ERANGE; + + oobregion->offset = 20; + oobregion->length = 28; + + return 0; +} + +static int ar934x_nfc_ooblayout_free(struct mtd_info *mtd, int section, + struct mtd_oob_region *oobregion) +{ + switch (section) { + case 0: + oobregion->offset = 4; + oobregion->length = 16; + return 0; + case 1: + oobregion->offset = 48; + oobregion->length = 16; + return 0; + default: + return -ERANGE; + } +} + +static const struct mtd_ooblayout_ops ar934x_nfc_ecclayout_ops = { + .ecc = ar934x_nfc_ooblayout_ecc, + .free = ar934x_nfc_ooblayout_free, +}; +#endif /* < 4.6 */ + static int ar934x_nfc_setup_hwecc(struct ar934x_nfc *nfc) { struct nand_chip *nand = &nfc->nand_chip; + struct mtd_info *mtd = ar934x_nfc_to_mtd(nfc); u32 ecc_cap; u32 ecc_thres; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0) + struct mtd_oob_region oobregion; +#endif - if (!config_enabled(CONFIG_MTD_NAND_AR934X_HW_ECC)) { + if (!IS_ENABLED(CONFIG_MTD_NAND_AR934X_HW_ECC)) { dev_err(nfc->parent, "hardware ECC support is disabled\n"); return -EINVAL; } - switch (nfc->mtd.writesize) { + switch (mtd->writesize) { case 2048: /* * Writing a subpage separately is not supported, because @@ -1284,17 +1344,25 @@ ar934x_nfc_setup_hwecc(struct ar934x_nfc *nfc) nand->ecc.size = 512; nand->ecc.bytes = 7; nand->ecc.strength = 4; +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,6,0) nand->ecc.layout = &ar934x_nfc_oob_64_hwecc; +#else + mtd_set_ooblayout(mtd, &ar934x_nfc_ecclayout_ops); +#endif break; default: dev_err(nfc->parent, "hardware ECC is not available for %d byte pages\n", - nfc->mtd.writesize); + mtd->writesize); return -EINVAL; } +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,6,0) BUG_ON(!nand->ecc.layout); +#else + BUG_ON(!mtd->ooblayout->ecc); +#endif switch (nand->ecc.strength) { case 4: @@ -1309,12 +1377,17 @@ ar934x_nfc_setup_hwecc(struct ar934x_nfc *nfc) } nfc->ecc_thres = ecc_thres; +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,6,0) nfc->ecc_oob_pos = nand->ecc.layout->eccpos[0]; +#else + mtd->ooblayout->ecc(mtd, 0, &oobregion); + nfc->ecc_oob_pos = oobregion.offset; +#endif nfc->ecc_ctrl_reg = ecc_cap << AR934X_NFC_ECC_CTRL_ECC_CAP_S; nfc->ecc_ctrl_reg |= ecc_thres << AR934X_NFC_ECC_CTRL_ERR_THRES_S; - nfc->ecc_offset_reg = nfc->mtd.writesize + nfc->ecc_oob_pos; + nfc->ecc_offset_reg = mtd->writesize + nfc->ecc_oob_pos; nand->ecc.mode = NAND_ECC_HW; nand->ecc.read_page = ar934x_nfc_read_page; @@ -1382,9 +1455,11 @@ ar934x_nfc_probe(struct platform_device *pdev) nfc->swap_dma = pdata->swap_dma; nand = &nfc->nand_chip; - mtd = &nfc->mtd; + mtd = ar934x_nfc_to_mtd(nfc); +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,6,0) mtd->priv = nand; +#endif mtd->owner = THIS_MODULE; if (pdata->name) mtd->name = pdata->name; @@ -1429,10 +1504,18 @@ ar934x_nfc_probe(struct platform_device *pdev) switch (pdata->ecc_mode) { case AR934X_NFC_ECC_SOFT: nand->ecc.mode = NAND_ECC_SOFT; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0) + nand->ecc.algo = NAND_ECC_HAMMING; +#endif break; case AR934X_NFC_ECC_SOFT_BCH: +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,6,0) nand->ecc.mode = NAND_ECC_SOFT_BCH; +#else + nand->ecc.mode = NAND_ECC_SOFT; + nand->ecc.algo = NAND_ECC_BCH; +#endif break; case AR934X_NFC_ECC_HW: @@ -1474,10 +1557,12 @@ static int ar934x_nfc_remove(struct platform_device *pdev) { struct ar934x_nfc *nfc; + struct mtd_info *mtd; nfc = platform_get_drvdata(pdev); if (nfc) { - nand_release(&nfc->mtd); + mtd = ar934x_nfc_to_mtd(nfc); + nand_release(mtd); ar934x_nfc_free_buf(nfc); free_irq(nfc->irq, nfc); } diff --git a/target/linux/ar71xx/files/drivers/mtd/nand/rb4xx_nand.c b/target/linux/ar71xx/files/drivers/mtd/nand/rb4xx_nand.c index 96ec5dd1e5..b397575f77 100644 --- a/target/linux/ar71xx/files/drivers/mtd/nand/rb4xx_nand.c +++ b/target/linux/ar71xx/files/drivers/mtd/nand/rb4xx_nand.c @@ -23,6 +23,7 @@ #include <linux/io.h> #include <linux/gpio.h> #include <linux/slab.h> +#include <linux/version.h> #include <asm/mach-ath79/ath79.h> #include <asm/mach-ath79/rb4xx_cpld.h> @@ -41,6 +42,7 @@ struct rb4xx_nand_info { struct mtd_info mtd; }; +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,6,0) /* * We need to use the OLD Yaffs-1 OOB layout, otherwise the RB bootloader * will not be able to find the kernel that we load. @@ -52,6 +54,56 @@ static struct nand_ecclayout rb4xx_nand_ecclayout = { .oobfree = { { 0, 4 }, { 6, 2 }, { 11, 2 }, { 4, 1 } } }; +#else + +static int rb4xx_ooblayout_ecc(struct mtd_info *mtd, int section, + struct mtd_oob_region *oobregion) +{ + switch (section) { + case 0: + oobregion->offset = 8; + oobregion->length = 3; + return 0; + case 1: + oobregion->offset = 13; + oobregion->length = 3; + return 0; + default: + return -ERANGE; + } +} + +static int rb4xx_ooblayout_free(struct mtd_info *mtd, int section, + struct mtd_oob_region *oobregion) +{ + switch (section) { + case 0: + oobregion->offset = 0; + oobregion->length = 4; + return 0; + case 1: + oobregion->offset = 4; + oobregion->length = 1; + return 0; + case 2: + oobregion->offset = 6; + oobregion->length = 2; + return 0; + case 3: + oobregion->offset = 11; + oobregion->length = 2; + return 0; + default: + return -ERANGE; + } +} + +static const struct mtd_ooblayout_ops rb4xx_nand_ecclayout_ops = { + .ecc = rb4xx_ooblayout_ecc, + .free = rb4xx_ooblayout_free, +}; +#endif /* < 4.6 */ + static struct mtd_partition rb4xx_nand_partitions[] = { { .name = "booter", @@ -229,7 +281,11 @@ static int rb4xx_nand_probe(struct platform_device *pdev) } if (info->mtd.writesize == 512) +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,6,0) info->chip.ecc.layout = &rb4xx_nand_ecclayout; +#else + mtd_set_ooblayout(&info->mtd, &rb4xx_nand_ecclayout_ops); +#endif ret = nand_scan_tail(&info->mtd); if (ret) { diff --git a/target/linux/ar71xx/files/drivers/mtd/nand/rb750_nand.c b/target/linux/ar71xx/files/drivers/mtd/nand/rb750_nand.c index 0604c5a235..f8a6722cba 100644 --- a/target/linux/ar71xx/files/drivers/mtd/nand/rb750_nand.c +++ b/target/linux/ar71xx/files/drivers/mtd/nand/rb750_nand.c @@ -16,6 +16,7 @@ #include <linux/platform_device.h> #include <linux/io.h> #include <linux/slab.h> +#include <linux/version.h> #include <asm/mach-ath79/ar71xx_regs.h> #include <asm/mach-ath79/ath79.h> @@ -49,6 +50,7 @@ static inline struct rb750_nand_info *mtd_to_rbinfo(struct mtd_info *mtd) return container_of(mtd, struct rb750_nand_info, mtd); } +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,6,0) /* * We need to use the OLD Yaffs-1 OOB layout, otherwise the RB bootloader * will not be able to find the kernel that we load. @@ -60,6 +62,56 @@ static struct nand_ecclayout rb750_nand_ecclayout = { .oobfree = { { 0, 4 }, { 6, 2 }, { 11, 2 }, { 4, 1 } } }; +#else + +static int rb750_ooblayout_ecc(struct mtd_info *mtd, int section, + struct mtd_oob_region *oobregion) +{ + switch (section) { + case 0: + oobregion->offset = 8; + oobregion->length = 3; + return 0; + case 1: + oobregion->offset = 13; + oobregion->length = 3; + return 0; + default: + return -ERANGE; + } +} + +static int rb750_ooblayout_free(struct mtd_info *mtd, int section, + struct mtd_oob_region *oobregion) +{ + switch (section) { + case 0: + oobregion->offset = 0; + oobregion->length = 4; + return 0; + case 1: + oobregion->offset = 4; + oobregion->length = 1; + return 0; + case 2: + oobregion->offset = 6; + oobregion->length = 2; + return 0; + case 3: + oobregion->offset = 11; + oobregion->length = 2; + return 0; + default: + return -ERANGE; + } +} + +static const struct mtd_ooblayout_ops rb750_nand_ecclayout_ops = { + .ecc = rb750_ooblayout_ecc, + .free = rb750_ooblayout_free, +}; +#endif /* < 4.6 */ + static struct mtd_partition rb750_nand_partitions[] = { { .name = "booter", @@ -292,7 +344,11 @@ static int rb750_nand_probe(struct platform_device *pdev) } if (info->mtd.writesize == 512) +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,6,0) info->chip.ecc.layout = &rb750_nand_ecclayout; +#else + mtd_set_ooblayout(&info->mtd, &rb750_nand_ecclayout_ops); +#endif ret = nand_scan_tail(&info->mtd); if (ret) { diff --git a/target/linux/ar71xx/files/drivers/mtd/nand/rb91x_nand.c b/target/linux/ar71xx/files/drivers/mtd/nand/rb91x_nand.c index 1308e18ba6..15b1816ae1 100644 --- a/target/linux/ar71xx/files/drivers/mtd/nand/rb91x_nand.c +++ b/target/linux/ar71xx/files/drivers/mtd/nand/rb91x_nand.c @@ -19,6 +19,7 @@ #include <linux/slab.h> #include <linux/gpio.h> #include <linux/platform_data/rb91x_nand.h> +#include <linux/version.h> #include <asm/mach-ath79/ar71xx_regs.h> #include <asm/mach-ath79/ath79.h> @@ -56,6 +57,7 @@ static inline struct rb91x_nand_info *mtd_to_rbinfo(struct mtd_info *mtd) return container_of(mtd, struct rb91x_nand_info, mtd); } +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,6,0) /* * We need to use the OLD Yaffs-1 OOB layout, otherwise the RB bootloader * will not be able to find the kernel that we load. @@ -67,6 +69,56 @@ static struct nand_ecclayout rb91x_nand_ecclayout = { .oobfree = { { 0, 4 }, { 6, 2 }, { 11, 2 }, { 4, 1 } } }; +#else + +static int rb91x_ooblayout_ecc(struct mtd_info *mtd, int section, + struct mtd_oob_region *oobregion) +{ + switch (section) { + case 0: + oobregion->offset = 8; + oobregion->length = 3; + return 0; + case 1: + oobregion->offset = 13; + oobregion->length = 3; + return 0; + default: + return -ERANGE; + } +} + +static int rb91x_ooblayout_free(struct mtd_info *mtd, int section, + struct mtd_oob_region *oobregion) +{ + switch (section) { + case 0: + oobregion->offset = 0; + oobregion->length = 4; + return 0; + case 1: + oobregion->offset = 4; + oobregion->length = 1; + return 0; + case 2: + oobregion->offset = 6; + oobregion->length = 2; + return 0; + case 3: + oobregion->offset = 11; + oobregion->length = 2; + return 0; + default: + return -ERANGE; + } +} + +static const struct mtd_ooblayout_ops rb91x_nand_ecclayout_ops = { + .ecc = rb91x_ooblayout_ecc, + .free = rb91x_ooblayout_free, +}; +#endif /* < 4.6 */ + static struct mtd_partition rb91x_nand_partitions[] = { { .name = "booter", @@ -334,7 +386,11 @@ static int rb91x_nand_probe(struct platform_device *pdev) return ret; if (rbni->mtd.writesize == 512) +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,6,0) rbni->chip.ecc.layout = &rb91x_nand_ecclayout; +#else + mtd_set_ooblayout(&rbni->mtd, &rb91x_nand_ecclayout_ops); +#endif ret = nand_scan_tail(&rbni->mtd); if (ret) diff --git a/target/linux/ar71xx/files/drivers/mtd/tplinkpart.c b/target/linux/ar71xx/files/drivers/mtd/tplinkpart.c index ac1efa1c22..1b94163b83 100644 --- a/target/linux/ar71xx/files/drivers/mtd/tplinkpart.c +++ b/target/linux/ar71xx/files/drivers/mtd/tplinkpart.c @@ -15,6 +15,7 @@ #include <linux/mtd/mtd.h> #include <linux/mtd/partitions.h> +#include <linux/version.h> #define TPLINK_NUM_PARTS 5 #define TPLINK_HEADER_V1 0x01000000 @@ -109,7 +110,11 @@ static int tplink_check_rootfs_magic(struct mtd_info *mtd, size_t offset) } static int tplink_parse_partitions_offset(struct mtd_info *master, +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,5,0) struct mtd_partition **pparts, +#else + const struct mtd_partition **pparts, +#endif struct mtd_part_parser_data *data, size_t offset) { @@ -181,7 +186,11 @@ err: } static int tplink_parse_partitions(struct mtd_info *master, +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,5,0) struct mtd_partition **pparts, +#else + const struct mtd_partition **pparts, +#endif struct mtd_part_parser_data *data) { return tplink_parse_partitions_offset(master, pparts, data, @@ -189,7 +198,11 @@ static int tplink_parse_partitions(struct mtd_info *master, } static int tplink_parse_64k_partitions(struct mtd_info *master, +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,5,0) struct mtd_partition **pparts, +#else + const struct mtd_partition **pparts, +#endif struct mtd_part_parser_data *data) { return tplink_parse_partitions_offset(master, pparts, data, 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; diff --git a/target/linux/ar71xx/files/drivers/spi/spi-rb4xx-cpld.c b/target/linux/ar71xx/files/drivers/spi/spi-rb4xx-cpld.c index 0534c7c374..18af83b67c 100644 --- a/target/linux/ar71xx/files/drivers/spi/spi-rb4xx-cpld.c +++ b/target/linux/ar71xx/files/drivers/spi/spi-rb4xx-cpld.c @@ -21,6 +21,7 @@ #include <linux/spi/spi.h> #include <linux/gpio.h> #include <linux/slab.h> +#include <linux/version.h> #include <asm/mach-ath79/rb4xx_cpld.h> @@ -246,7 +247,11 @@ static int rb4xx_cpld_gpio_init(struct rb4xx_cpld *cpld, unsigned int base) cpld->chip.base = base; cpld->chip.ngpio = CPLD_NUM_GPIOS; cpld->chip.can_sleep = 1; +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,5,0) cpld->chip.dev = &cpld->spi->dev; +#else + cpld->chip.parent = &cpld->spi->dev; +#endif cpld->chip.owner = THIS_MODULE; err = gpiochip_add(&cpld->chip); |