summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorflorian <florian@3c298f89-4303-0410-b956-a3cf2f4a3e73>2010-11-25 11:58:02 +0000
committerflorian <florian@3c298f89-4303-0410-b956-a3cf2f4a3e73>2010-11-25 11:58:02 +0000
commit1a32a83a207cd3e28d8760b523e3e6fa31416e6b (patch)
treefa9e6a8f27b0ffd9c5c2d1e691c3906a3c26990a
parent87ae2b32716dc915b69561b0eac7c875d2c83f49 (diff)
[ar7] handle mvswitch in cpmac, rework MII probing logic, patch from sn9 and Wipster
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@24140 3c298f89-4303-0410-b956-a3cf2f4a3e73
-rw-r--r--target/linux/ar7/patches-2.6.32/970-remove_fixed_phy.patch89
-rw-r--r--target/linux/ar7/patches-2.6.32/971-cpmac_cleanup.patch48
-rw-r--r--target/linux/ar7/patches-2.6.32/972-cpmac_multi_probe.patch95
-rw-r--r--target/linux/ar7/patches-2.6.32/973-cpmac_handle_mvswitch.c65
4 files changed, 65 insertions, 232 deletions
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
deleted file mode 100644
index 0e72267ab5..0000000000
--- a/target/linux/ar7/patches-2.6.32/970-remove_fixed_phy.patch
+++ /dev/null
@@ -1,89 +0,0 @@
---- a/arch/mips/ar7/platform.c
-+++ b/arch/mips/ar7/platform.c
-@@ -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>
-@@ -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
deleted file mode 100644
index 754119a41c..0000000000
--- a/target/linux/ar7/patches-2.6.32/971-cpmac_cleanup.patch
+++ /dev/null
@@ -1,48 +0,0 @@
---- a/drivers/net/cpmac.c
-+++ b/drivers/net/cpmac.c
-@@ -33,7 +33,6 @@
- #include <linux/skbuff.h>
- #include <linux/mii.h>
- #include <linux/phy.h>
--#include <linux/phy_fixed.h>
- #include <linux/platform_device.h>
- #include <linux/dma-mapping.h>
- #include <asm/gpio.h>
-@@ -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
deleted file mode 100644
index 941d8889c1..0000000000
--- a/target/linux/ar7/patches-2.6.32/972-cpmac_multi_probe.patch
+++ /dev/null
@@ -1,95 +0,0 @@
---- a/drivers/net/cpmac.c
-+++ b/drivers/net/cpmac.c
-@@ -33,6 +33,7 @@
- #include <linux/skbuff.h>
- #include <linux/mii.h>
- #include <linux/phy.h>
-+#include <linux/phy_fixed.h>
- #include <linux/platform_device.h>
- #include <linux/dma-mapping.h>
- #include <asm/gpio.h>
-@@ -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;
-@@ -1111,9 +1118,13 @@ static int __devinit cpmac_probe(struct
- struct cpmac_priv *priv;
- struct net_device *dev;
- struct plat_cpmac_data *pdata;
-+ void __iomem *mii_reg;
-+ u32 tmp;
-+ unsigned external_mii = 0;
-
- pdata = pdev->dev.platform_data;
-
-+detect_again:
- for (phy_id = 0; phy_id < PHY_MAX_ADDR; phy_id++) {
- if (!(pdata->phy_mask & (1 << phy_id)))
- continue;
-@@ -1122,12 +1133,43 @@ 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 && !external_mii)
-+ goto dev_alloc;
-+
-+ /* Now disable EPHY and enable MII */
-+ dev_info(&pdev->dev, "trying external MII\n");
-+ ar7_device_disable(AR7_RESET_BIT_EPHY);
-+
-+ 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);
-+ external_mii++;
-+
-+ if (external_mii == 1)
-+ goto detect_again;
-+
-+ 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) {
---- a/arch/mips/include/asm/mach-ar7/ar7.h
-+++ b/arch/mips/include/asm/mach-ar7/ar7.h
-@@ -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)
diff --git a/target/linux/ar7/patches-2.6.32/973-cpmac_handle_mvswitch.c b/target/linux/ar7/patches-2.6.32/973-cpmac_handle_mvswitch.c
new file mode 100644
index 0000000000..23c66aa5b6
--- /dev/null
+++ b/target/linux/ar7/patches-2.6.32/973-cpmac_handle_mvswitch.c
@@ -0,0 +1,65 @@
+Index: linux-2.6.32.25/drivers/net/cpmac.c
+===================================================================
+--- linux-2.6.32.25.orig/drivers/net/cpmac.c 2010-11-24 12:16:56.067517245 -0800
++++ linux-2.6.32.25/drivers/net/cpmac.c 2010-11-24 12:17:56.279985384 -0800
+@@ -387,6 +387,7 @@
+ struct cpmac_desc *desc)
+ {
+ struct sk_buff *skb, *result = NULL;
++ int offset;
+
+ if (unlikely(netif_msg_hw(priv)))
+ cpmac_dump_desc(priv->dev, desc);
+@@ -400,9 +401,13 @@
+
+ skb = netdev_alloc_skb(priv->dev, CPMAC_SKB_SIZE);
+ if (likely(skb)) {
+- skb_reserve(skb, 2);
++ offset = 2;
++ if (priv->phy) {
++ offset += priv->phy->pkt_align;
++ }
++ skb_reserve(skb, offset);
++
+ skb_put(desc->skb, desc->datalen);
+- desc->skb->protocol = eth_type_trans(desc->skb, priv->dev);
+ desc->skb->ip_summed = CHECKSUM_NONE;
+ priv->dev->stats.rx_packets++;
+ priv->dev->stats.rx_bytes += desc->datalen;
+@@ -474,7 +479,12 @@
+
+ skb = cpmac_rx_one(priv, desc);
+ if (likely(skb)) {
+- netif_receive_skb(skb);
++ if (priv->phy->netif_receive_skb) {
++ priv->phy->netif_receive_skb(skb);
++ } else {
++ skb->protocol = eth_type_trans(skb, priv->dev);
++ netif_receive_skb(skb);
++ }
+ received++;
+ }
+ desc = desc->next;
+@@ -970,7 +980,7 @@
+
+ static int cpmac_open(struct net_device *dev)
+ {
+- int i, size, res;
++ int i, size, res, offset;
+ struct cpmac_priv *priv = netdev_priv(dev);
+ struct resource *mem;
+ struct cpmac_desc *desc;
+@@ -1014,7 +1024,12 @@
+ res = -ENOMEM;
+ goto fail_desc;
+ }
+- skb_reserve(skb, 2);
++ offset = 2;
++ if (priv->phy) {
++ offset += priv->phy->pkt_align;
++ }
++ skb_reserve(skb, offset);
++
+ desc->skb = skb;
+ desc->data_mapping = dma_map_single(&dev->dev, skb->data,
+ CPMAC_SKB_SIZE,