From dbbc404cba420ad7ddbc5c91445ec397a9561308 Mon Sep 17 00:00:00 2001 From: florian Date: Mon, 23 Aug 2010 08:45:36 +0000 Subject: [PATCH] backport r22727, r22728, r22770 and r22771 git-svn-id: svn://svn.openwrt.org/openwrt/branches/backfire@22778 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- target/linux/ar7/Makefile | 2 +- .../patches-2.6.32/970-remove_fixed_phy.patch | 89 +++++++++++++++++++ .../patches-2.6.32/971-cpmac_cleanup.patch | 48 ++++++++++ .../972-cpmac_multi_probe.patch | 67 ++++++++++++++ 4 files changed, 205 insertions(+), 1 deletion(-) create mode 100644 target/linux/ar7/patches-2.6.32/970-remove_fixed_phy.patch create mode 100644 target/linux/ar7/patches-2.6.32/971-cpmac_cleanup.patch create mode 100644 target/linux/ar7/patches-2.6.32/972-cpmac_multi_probe.patch diff --git a/target/linux/ar7/Makefile b/target/linux/ar7/Makefile index 72b3d5c4a..ff9ebe0ba 100644 --- a/target/linux/ar7/Makefile +++ b/target/linux/ar7/Makefile @@ -16,7 +16,7 @@ LINUX_VERSION:=2.6.32.16 include $(INCLUDE_DIR)/target.mk DEFAULT_PACKAGES+= kmod-pppoa ppp-mod-pppoa linux-atm atm-tools br2684ctl \ - kmod-acx + kmod-acx swconfig define Target/Description Build firmware images for TI AR7 based routers. diff --git a/target/linux/ar7/patches-2.6.32/970-remove_fixed_phy.patch b/target/linux/ar7/patches-2.6.32/970-remove_fixed_phy.patch new file mode 100644 index 000000000..0e72267ab --- /dev/null +++ b/target/linux/ar7/patches-2.6.32/970-remove_fixed_phy.patch @@ -0,0 +1,89 @@ +--- a/arch/mips/ar7/platform.c ++++ b/arch/mips/ar7/platform.c +@@ -33,7 +33,6 @@ + #include + #include + #include +-#include + + #include + #include +@@ -294,12 +293,6 @@ static struct physmap_flash_data physmap + .width = 2, + }; + +-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, +@@ -716,11 +709,6 @@ static int __init ar7_register_devices(v + } + + if (ar7_has_high_cpmac()) { +- res = fixed_phy_add(PHY_POLL, ar7_is_titan() ? cpmac_high_titan.id : cpmac_high.id, +- &fixed_phy_status); +- if (res && res != -ENODEV) +- return res; +- + cpmac_get_mac(1, ar7_is_titan() ? cpmac_high_data_titan.dev_addr : + cpmac_high_data.dev_addr); + res = platform_device_register(ar7_is_titan() ? &cpmac_high_titan : +@@ -736,11 +724,6 @@ static int __init ar7_register_devices(v + + } + +- res = fixed_phy_add(PHY_POLL, ar7_is_titan() ? cpmac_low_titan.id : +- cpmac_low.id, &fixed_phy_status); +- if (res && res != -ENODEV) +- return res; +- + cpmac_get_mac(0, ar7_is_titan() ? cpmac_low_data_titan.dev_addr : + cpmac_low_data.dev_addr); + res = platform_device_register(ar7_is_titan() ? &cpmac_low_titan : +--- a/drivers/net/cpmac.c ++++ b/drivers/net/cpmac.c +@@ -1117,21 +1117,17 @@ static int __devinit cpmac_probe(struct + + pdata = pdev->dev.platform_data; + +- if (external_switch || dumb_switch) { +- strncpy(mdio_bus_id, "0", MII_BUS_ID_SIZE); /* fixed phys bus */ +- phy_id = pdev->id; +- } else { +- for (phy_id = 0; phy_id < PHY_MAX_ADDR; phy_id++) { +- if (!(pdata->phy_mask & (1 << phy_id))) +- continue; +- if (!cpmac_mii->phy_map[phy_id]) +- continue; +- strncpy(mdio_bus_id, cpmac_mii->id, MII_BUS_ID_SIZE); +- break; +- } ++ for (phy_id = 0; phy_id < PHY_MAX_ADDR; phy_id++) { ++ if (!(pdata->phy_mask & (1 << phy_id))) ++ continue; ++ if (!cpmac_mii->phy_map[phy_id]) ++ continue; ++ strncpy(mdio_bus_id, cpmac_mii->id, MII_BUS_ID_SIZE); ++ break; + } +- ++ + if (phy_id == PHY_MAX_ADDR) { ++ //This probably wont work as no fixed bus anymore. + dev_err(&pdev->dev, "no PHY present, falling back to switch mode\n"); + strncpy(mdio_bus_id, "0", MII_BUS_ID_SIZE); /* fixed phys bus */ + phy_id = pdev->id; +@@ -1269,7 +1265,7 @@ int __devinit cpmac_init(void) + } + + cpmac_mii->phy_mask = ar7_is_titan()? ~(mask | 0x80000000 | 0x40000000): +- ~(mask | 0x80000000); ++ ~(mask | 0x80000001); + snprintf(cpmac_mii->id, MII_BUS_ID_SIZE, "1"); + + res = mdiobus_register(cpmac_mii); diff --git a/target/linux/ar7/patches-2.6.32/971-cpmac_cleanup.patch b/target/linux/ar7/patches-2.6.32/971-cpmac_cleanup.patch new file mode 100644 index 000000000..754119a41 --- /dev/null +++ b/target/linux/ar7/patches-2.6.32/971-cpmac_cleanup.patch @@ -0,0 +1,48 @@ +--- a/drivers/net/cpmac.c ++++ b/drivers/net/cpmac.c +@@ -33,7 +33,6 @@ + #include + #include + #include +-#include + #include + #include + #include +@@ -1104,8 +1103,6 @@ static const struct net_device_ops cpmac + .ndo_set_mac_address = eth_mac_addr, + }; + +-static int external_switch; +- + static int __devinit cpmac_probe(struct platform_device *pdev) + { + int rc, phy_id; +@@ -1127,10 +1124,8 @@ static int __devinit cpmac_probe(struct + } + + if (phy_id == PHY_MAX_ADDR) { +- //This probably wont work as no fixed bus anymore. +- dev_err(&pdev->dev, "no PHY present, falling back to switch mode\n"); +- strncpy(mdio_bus_id, "0", MII_BUS_ID_SIZE); /* fixed phys bus */ +- phy_id = pdev->id; ++ dev_err(&pdev->dev, "no PHY present\n"); ++ return -ENODEV; + } + + dev = alloc_etherdev_mq(sizeof(*priv), CPMAC_QUEUES); +@@ -1258,14 +1253,8 @@ int __devinit cpmac_init(void) + else + msleep(10); + +- mask &= 0x7fffffff; +- if (mask & (mask - 1)) { +- external_switch = 1; +- mask = 0; +- } +- + cpmac_mii->phy_mask = ar7_is_titan()? ~(mask | 0x80000000 | 0x40000000): +- ~(mask | 0x80000001); ++ ~(mask | 0x80000000); + snprintf(cpmac_mii->id, MII_BUS_ID_SIZE, "1"); + + res = mdiobus_register(cpmac_mii); diff --git a/target/linux/ar7/patches-2.6.32/972-cpmac_multi_probe.patch b/target/linux/ar7/patches-2.6.32/972-cpmac_multi_probe.patch new file mode 100644 index 000000000..44933d0c1 --- /dev/null +++ b/target/linux/ar7/patches-2.6.32/972-cpmac_multi_probe.patch @@ -0,0 +1,67 @@ +--- a/drivers/net/cpmac.c ++++ b/drivers/net/cpmac.c +@@ -33,6 +33,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -217,6 +218,12 @@ static void cpmac_hw_stop(struct net_dev + static int cpmac_stop(struct net_device *dev); + static int cpmac_open(struct net_device *dev); + ++static struct fixed_phy_status fixed_phy_status = { ++ .link = 1, ++ .speed = 100, ++ .duplex = 1, ++}; ++ + static void cpmac_dump_regs(struct net_device *dev) + { + int i; +@@ -1122,12 +1129,39 @@ static int __devinit cpmac_probe(struct + strncpy(mdio_bus_id, cpmac_mii->id, MII_BUS_ID_SIZE); + break; + } +- +- if (phy_id == PHY_MAX_ADDR) { +- dev_err(&pdev->dev, "no PHY present\n"); +- return -ENODEV; ++ ++ if (phy_id < PHY_MAX_ADDR) ++ goto dev_alloc; ++ ++ dev_info(&pdev->dev, "trying external MII\n"); ++ /* Now disable EPHY and enable MII */ ++ ar7_device_disable(AR7_RESET_BIT_EPHY); ++ *(unsigned long*) ioremap(0x08611A08, 4) |= 0x00000001; ++ ++ for (phy_id = 0; phy_id < PHY_MAX_ADDR; phy_id++) { ++ if (!(pdata->phy_mask & (1 << phy_id))) ++ continue; ++ if (!cpmac_mii->phy_map[phy_id]) ++ continue; ++ strncpy(mdio_bus_id, cpmac_mii->id, MII_BUS_ID_SIZE); ++ break; ++ } ++ ++ if (phy_id < PHY_MAX_ADDR) ++ goto dev_alloc; ++ ++ /* This still does not work, so now we register a fixed phy */ ++ dev_info(&pdev->dev, "using fixed PHY\n"); ++ rc = fixed_phy_add(PHY_POLL, pdev->id, &fixed_phy_status); ++ if (rc && rc != -ENODEV) { ++ dev_err(&pdev->dev, "unable to register fixed PHY\n"); ++ return rc; + } + ++ strncpy(mdio_bus_id, "0", MII_BUS_ID_SIZE); /* fixed phys bus */ ++ phy_id = pdev->id; ++ ++dev_alloc: + dev = alloc_etherdev_mq(sizeof(*priv), CPMAC_QUEUES); + + if (!dev) {