aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/ar7
diff options
context:
space:
mode:
authorFlorian Fainelli <florian@openwrt.org>2010-11-25 12:18:41 +0000
committerFlorian Fainelli <florian@openwrt.org>2010-11-25 12:18:41 +0000
commite8881e29b67ce8cb51010f87bc8af6e9132d0103 (patch)
tree2a2fba22fcce7536c5298da5e2532fe65cbd7527 /target/linux/ar7
parent4b3ffba803b4041bd7d3649d2cfcadb6dca9eca1 (diff)
downloadupstream-e8881e29b67ce8cb51010f87bc8af6e9132d0103.tar.gz
upstream-e8881e29b67ce8cb51010f87bc8af6e9132d0103.tar.bz2
upstream-e8881e29b67ce8cb51010f87bc8af6e9132d0103.zip
patch 972-cpmac_multi_probe.patch correctly, thanks sn9
SVN-Revision: 24142
Diffstat (limited to 'target/linux/ar7')
-rw-r--r--target/linux/ar7/patches-2.6.32/972-cpmac_multi_probe.patch238
1 files changed, 238 insertions, 0 deletions
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 0000000000..d79783a79d
--- /dev/null
+++ b/target/linux/ar7/patches-2.6.32/972-cpmac_multi_probe.patch
@@ -0,0 +1,238 @@
+Index: linux-2.6.32.26/arch/mips/ar7/platform.c
+===================================================================
+--- linux-2.6.32.26.orig/arch/mips/ar7/platform.c 2010-11-24 13:16:31.367487844 -0800
++++ linux-2.6.32.26/arch/mips/ar7/platform.c 2010-11-24 13:16:49.677512306 -0800
+@@ -33,7 +33,6 @@
+ #include <linux/string.h>
+ #include <linux/etherdevice.h>
+ #include <linux/phy.h>
+-#include <linux/phy_fixed.h>
+
+ #include <asm/addrspace.h>
+ #include <asm/mach-ar7/ar7.h>
+@@ -46,7 +45,6 @@
+ int reset_bit;
+ };
+
+-
+ static int vlynq_on(struct vlynq_device *dev)
+ {
+ int result;
+@@ -72,7 +70,8 @@
+
+ msleep(50);
+
+- gpio_set_value(pdata->gpio_bit, 1);
++ gpio_set_value(pdata->gpio_bit,
++ __vlynq_rev_reg(dev->local) < 0x00010205);
+ msleep(50);
+
+ return 0;
+@@ -294,16 +293,10 @@
+ .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,
+- .phy_mask = 0x80000000,
++ .phy_mask = 0xffffffff,
+ };
+
+ static struct plat_cpmac_data cpmac_high_data = {
+@@ -716,11 +709,6 @@
+ }
+
+ 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 :
+@@ -728,19 +716,8 @@
+
+ if (res)
+ return res;
+- } else {
+- if (ar7_is_titan())
+- cpmac_low_data_titan.phy_mask = 0xffffffff;
+- else
+- cpmac_low_data.phy_mask = 0xffffffff;
+-
+ }
+
+- 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 :
+Index: linux-2.6.32.26/arch/mips/include/asm/mach-ar7/ar7.h
+===================================================================
+--- linux-2.6.32.26.orig/arch/mips/include/asm/mach-ar7/ar7.h 2010-11-24 13:16:31.387502677 -0800
++++ linux-2.6.32.26/arch/mips/include/asm/mach-ar7/ar7.h 2010-11-24 13:16:37.117485679 -0800
+@@ -41,6 +41,7 @@
+ #define AR7_REGS_RESET (AR7_REGS_BASE + 0x1600)
+ #define AR7_REGS_VLYNQ0 (AR7_REGS_BASE + 0x1800)
+ #define AR7_REGS_DCL (AR7_REGS_BASE + 0x1a00)
++#define AR7_REGS_MII (AR7_REGS_BASE + 0x1a08)
+ #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-2.6.32.26/drivers/net/cpmac.c
+===================================================================
+--- linux-2.6.32.26.orig/drivers/net/cpmac.c 2010-11-24 13:16:31.397493402 -0800
++++ linux-2.6.32.26/drivers/net/cpmac.c 2010-11-24 13:16:37.117485679 -0800
+@@ -218,6 +218,12 @@
+ 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;
+@@ -269,6 +275,18 @@
+ printk("\n");
+ }
+
++static void auto_mdix_on(void)
++{
++ ar7_gpio_enable(28);
++ ar7_gpio_disable(30);
++}
++
++/*static void auto_mdix_off(void)
++{
++ ar7_gpio_disable(28);
++ ar7_gpio_disable(30);
++}*/
++
+ static int cpmac_mdio_read(struct mii_bus *bus, int phy_id, int reg)
+ {
+ u32 val;
+@@ -1104,8 +1122,6 @@
+ .ndo_set_mac_address = eth_mac_addr,
+ };
+
+-static int external_switch;
+-
+ static int __devinit cpmac_probe(struct platform_device *pdev)
+ {
+ int rc, phy_id;
+@@ -1114,13 +1130,15 @@
+ struct cpmac_priv *priv;
+ struct net_device *dev;
+ struct plat_cpmac_data *pdata;
++ void __iomem *mii_reg;
++ u32 tmp;
++ unsigned external_mii;
+
+ 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 {
++ if (dumb_switch)
++ phy_id = PHY_MAX_ADDR;
++ else for (external_mii = 0; external_mii <= 1; external_mii++) {
+ for (phy_id = 0; phy_id < PHY_MAX_ADDR; phy_id++) {
+ if (!(pdata->phy_mask & (1 << phy_id)))
+ continue;
+@@ -1129,13 +1147,45 @@
+ strncpy(mdio_bus_id, cpmac_mii->id, MII_BUS_ID_SIZE);
+ break;
+ }
++
++ if (phy_id == PHY_MAX_ADDR || external_mii || ar7_is_titan())
++ break;
++
++ /* Now disable EPHY and enable MII */
++ dev_info(&pdev->dev, "trying external MII\n");
++ ar7_device_disable(AR7_RESET_BIT_EPHY);
++
++ if (!ar7_has_high_cpmac()) {
++ mii_reg = ioremap(AR7_REGS_MII, 4);
++ if (!mii_reg) {
++ dev_err(&pdev->dev, "failed to iorenamp MII_SEL\n");
++ return -ENOMEM;
++ }
++
++ tmp = readl(mii_reg);
++ tmp |= 1;
++ writel(tmp, mii_reg);
++ iounmap(mii_reg);
++ }
++
++ ar7_gpio_disable(17);
++ mdelay(20);
++ ar7_gpio_enable(17);
+ }
+
+ if (phy_id == PHY_MAX_ADDR) {
+- dev_err(&pdev->dev, "no PHY present, falling back to switch mode\n");
++ /* 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;
+- }
++ } else
++ auto_mdix_on();
+
+ dev = alloc_etherdev_mq(sizeof(*priv), CPMAC_QUEUES);
+
+@@ -1244,14 +1294,14 @@
+ ar7_gpio_disable(26);
+ ar7_gpio_disable(27);
+
+- if (!ar7_is_titan()) {
++ if (ar7_is_titan()) {
++ ar7_device_reset(AR7_RESET_BIT_EPHY);
++ ar7_device_reset(TITAN_RESET_BIT_EPHY1);
++ } else {
+ ar7_device_reset(AR7_RESET_BIT_CPMAC_LO);
+ ar7_device_reset(AR7_RESET_BIT_CPMAC_HI);
+- }
+- ar7_device_reset(AR7_RESET_BIT_EPHY);
+
+- if (ar7_is_titan()) {
+- ar7_device_reset(TITAN_RESET_BIT_EPHY1);
++ ar7_device_reset(AR7_RESET_BIT_EPHY);
+ }
+
+ cpmac_mii->reset(cpmac_mii);
+@@ -1262,12 +1312,6 @@
+ 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 | 0x80000000);
+ snprintf(cpmac_mii->id, MII_BUS_ID_SIZE, "1");