From 7205421c5b4a6b2b9306e323847eb8022abca72f Mon Sep 17 00:00:00 2001 From: Florian Fainelli Date: Sat, 13 Oct 2012 17:47:14 +0000 Subject: [PATCH] reinstate the fixed PHY fallback for devices with undetectable switches At least devices without a switch present on the MDIO bus still get a valid link and work as expected (such as the Linksys WAG54Gv2). SVN-Revision: 33751 --- .../ar7/patches-3.3/972-cpmac_fixup.patch | 94 +++++++------------ 1 file changed, 35 insertions(+), 59 deletions(-) diff --git a/target/linux/ar7/patches-3.3/972-cpmac_fixup.patch b/target/linux/ar7/patches-3.3/972-cpmac_fixup.patch index f6cc1a600458..456e9b379d0b 100644 --- a/target/linux/ar7/patches-3.3/972-cpmac_fixup.patch +++ b/target/linux/ar7/patches-3.3/972-cpmac_fixup.patch @@ -1,59 +1,38 @@ -Index: linux-3.3.8/arch/mips/ar7/platform.c -=================================================================== ---- linux-3.3.8.orig/arch/mips/ar7/platform.c 2012-10-06 21:15:51.930451885 -0700 -+++ linux-3.3.8/arch/mips/ar7/platform.c 2012-10-06 21:15:51.962452050 -0700 -@@ -33,7 +33,6 @@ - #include - #include - #include --#include - #include - #include - -@@ -248,12 +247,6 @@ - }, - }; - --static struct fixed_phy_status fixed_phy_status __initdata = { -- .link = 1, -- .speed = 100, -- .duplex = 1, --}; -- - static struct plat_cpmac_data cpmac_low_data = { - .reset_bit = 17, - .power_bit = 20, -@@ -709,26 +702,19 @@ +--- a/arch/mips/ar7/platform.c ++++ b/arch/mips/ar7/platform.c +@@ -709,26 +709,23 @@ static int __init ar7_register_devices(v } if (ar7_has_high_cpmac()) { -- res = fixed_phy_add(PHY_POLL, cpmac_high.id, &fixed_phy_status); ++ cpmac_get_mac(0, cpmac_high_data.dev_addr); ++ + res = fixed_phy_add(PHY_POLL, cpmac_high.id, &fixed_phy_status); - if (!res) { - cpmac_get_mac(1, cpmac_high_data.dev_addr); -- ++ if (!res) ++ pr_warning("unable to register fixed phy for cpmac-high: %d\n", res); + - res = platform_device_register(&cpmac_high); - if (res) - pr_warning("unable to register cpmac-high: %d\n", res); - } else - pr_warning("unable to add cpmac-high phy: %d\n", res); - } else -- cpmac_low_data.phy_mask = 0xffffffff; -+ cpmac_get_mac(0, cpmac_high_data.dev_addr); - ++ res = platform_device_register(&cpmac_high); ++ if (res) ++ pr_warning("unable to register cpmac-high: %d\n", res); ++ cpmac_get_mac(1, cpmac_low_data.dev_addr); ++ } else { + cpmac_low_data.phy_mask = 0xffffffff; +- - res = fixed_phy_add(PHY_POLL, cpmac_low.id, &fixed_phy_status); - if (!res) { -- cpmac_get_mac(0, cpmac_low_data.dev_addr); + cpmac_get_mac(0, cpmac_low_data.dev_addr); - res = platform_device_register(&cpmac_low); -+ res = platform_device_register(&cpmac_high); - if (res) +- if (res) - pr_warning("unable to register cpmac-low: %d\n", res); - } else - pr_warning("unable to add cpmac-low phy: %d\n", res); -+ pr_warning("unable to register cpmac-high: %d\n", res); -+ cpmac_get_mac(1, cpmac_low_data.dev_addr); -+ } else { -+ cpmac_low_data.phy_mask = 0xffffffff; -+ cpmac_get_mac(0, cpmac_low_data.dev_addr); + } + res = platform_device_register(&cpmac_low); + if (res) @@ -61,7 +40,7 @@ Index: linux-3.3.8/arch/mips/ar7/platform.c detect_leds(); res = platform_device_register(&ar7_gpio_leds); -@@ -741,8 +727,10 @@ +@@ -741,8 +738,10 @@ static int __init ar7_register_devices(v /* Register watchdog only if enabled in hardware */ bootcr = ioremap_nocache(AR7_REGS_DCL, 4); @@ -74,10 +53,8 @@ Index: linux-3.3.8/arch/mips/ar7/platform.c if (val & AR7_WDT_HW_ENA) { if (ar7_has_high_vlynq()) ar7_wdt_res.start = UR8_REGS_WDT; -Index: linux-3.3.8/arch/mips/include/asm/mach-ar7/ar7.h -=================================================================== ---- linux-3.3.8.orig/arch/mips/include/asm/mach-ar7/ar7.h 2012-06-01 00:16:13.000000000 -0700 -+++ linux-3.3.8/arch/mips/include/asm/mach-ar7/ar7.h 2012-10-06 21:15:51.966452059 -0700 +--- a/arch/mips/include/asm/mach-ar7/ar7.h ++++ b/arch/mips/include/asm/mach-ar7/ar7.h @@ -42,6 +42,7 @@ #define AR7_REGS_PINSEL (AR7_REGS_BASE + 0x160C) #define AR7_REGS_VLYNQ0 (AR7_REGS_BASE + 0x1800) @@ -86,10 +63,8 @@ Index: linux-3.3.8/arch/mips/include/asm/mach-ar7/ar7.h #define AR7_REGS_VLYNQ1 (AR7_REGS_BASE + 0x1c00) #define AR7_REGS_MDIO (AR7_REGS_BASE + 0x1e00) #define AR7_REGS_IRQ (AR7_REGS_BASE + 0x2400) -Index: linux-3.3.8/drivers/net/ethernet/ti/cpmac.c -=================================================================== ---- linux-3.3.8.orig/drivers/net/ethernet/ti/cpmac.c 2012-10-06 21:15:51.946451965 -0700 -+++ linux-3.3.8/drivers/net/ethernet/ti/cpmac.c 2012-10-11 11:23:17.459719956 -0700 +--- a/drivers/net/ethernet/ti/cpmac.c ++++ b/drivers/net/ethernet/ti/cpmac.c @@ -35,7 +35,6 @@ #include #include @@ -98,7 +73,7 @@ Index: linux-3.3.8/drivers/net/ethernet/ti/cpmac.c #include #include #include -@@ -48,14 +47,11 @@ +@@ -48,14 +47,11 @@ MODULE_LICENSE("GPL"); MODULE_ALIAS("platform:cpmac"); static int debug_level = 8; @@ -114,7 +89,7 @@ Index: linux-3.3.8/drivers/net/ethernet/ti/cpmac.c #define CPMAC_VERSION "0.5.2" /* frame size + 802.1q tag + FCS size */ -@@ -674,9 +670,8 @@ +@@ -674,9 +670,8 @@ static void cpmac_hw_start(struct net_de for (i = 0; i < 8; i++) cpmac_write(priv->regs, CPMAC_MAC_ADDR_LO(i), dev->dev_addr[5]); cpmac_write(priv->regs, CPMAC_MAC_ADDR_MID, dev->dev_addr[4]); @@ -126,7 +101,7 @@ Index: linux-3.3.8/drivers/net/ethernet/ti/cpmac.c cpmac_write(priv->regs, CPMAC_MAX_LENGTH, CPMAC_SKB_SIZE); cpmac_write(priv->regs, CPMAC_UNICAST_CLEAR, 0xff); cpmac_write(priv->regs, CPMAC_RX_INT_CLEAR, 0xff); -@@ -1121,25 +1116,18 @@ +@@ -1121,25 +1116,19 @@ static int __devinit cpmac_probe(struct pdata = pdev->dev.platform_data; @@ -151,17 +126,18 @@ Index: linux-3.3.8/drivers/net/ethernet/ti/cpmac.c + break; } - if (phy_id == PHY_MAX_ADDR) { +- if (phy_id == PHY_MAX_ADDR) { - dev_err(&pdev->dev, "no PHY present, falling back " - "to switch on MDIO bus 0\n"); - strncpy(mdio_bus_id, "fixed-0", MII_BUS_ID_SIZE); /* fixed phys bus */ -- phy_id = pdev->id; -+ printk(KERN_ERR "cpmac: No PHY present\n"); -+ return -ENXIO; ++ if (phy_id == PHY_MAX_ADDR && pdev->id == 1) { ++ printk(KERN_ERR "cpmac: No PHY present, using fixed PHY\n"); + phy_id = pdev->id; ++ strncpy(mdio_bus_id, "fixed-0", MII_BUS_ID_SIZE); } dev = alloc_etherdev_mq(sizeof(*priv), CPMAC_QUEUES); -@@ -1178,6 +1166,13 @@ +@@ -1178,6 +1167,13 @@ static int __devinit cpmac_probe(struct snprintf(priv->phy_name, MII_BUS_ID_SIZE, PHY_ID_FMT, mdio_bus_id, phy_id); @@ -175,7 +151,7 @@ Index: linux-3.3.8/drivers/net/ethernet/ti/cpmac.c priv->phy = phy_connect(dev, priv->phy_name, cpmac_adjust_link, 0, PHY_INTERFACE_MODE_MII); -@@ -1189,13 +1184,6 @@ +@@ -1189,13 +1185,6 @@ static int __devinit cpmac_probe(struct goto fail; } @@ -189,7 +165,7 @@ Index: linux-3.3.8/drivers/net/ethernet/ti/cpmac.c if (netif_msg_probe(priv)) { printk(KERN_INFO "cpmac: device %s (regs: %p, irq: %d, phy: %s, " -@@ -1228,6 +1216,7 @@ +@@ -1228,6 +1217,7 @@ int __devinit cpmac_init(void) { u32 mask; int i, res; @@ -197,7 +173,7 @@ Index: linux-3.3.8/drivers/net/ethernet/ti/cpmac.c cpmac_mii = mdiobus_alloc(); if (cpmac_mii == NULL) -@@ -1251,31 +1240,51 @@ +@@ -1251,31 +1241,51 @@ int __devinit cpmac_init(void) ar7_gpio_disable(26); ar7_gpio_disable(27); -- 2.30.2