diff options
| -rw-r--r-- | target/linux/ar7/patches-2.6.27/160-cpmac_up_and_running.patch | 47 | ||||
| -rw-r--r-- | target/linux/ar7/patches-2.6.27/910-cpmac_fixed_phy.patch | 92 | 
2 files changed, 139 insertions, 0 deletions
diff --git a/target/linux/ar7/patches-2.6.27/160-cpmac_up_and_running.patch b/target/linux/ar7/patches-2.6.27/160-cpmac_up_and_running.patch new file mode 100644 index 000000000..d11bbf2e5 --- /dev/null +++ b/target/linux/ar7/patches-2.6.27/160-cpmac_up_and_running.patch @@ -0,0 +1,47 @@ +--- a/arch/mips/ar7/platform.c ++++ b/arch/mips/ar7/platform.c +@@ -33,6 +33,8 @@ + #include <linux/vlynq.h> + #include <linux/leds.h> + #include <linux/string.h> ++#include <linux/phy.h> ++#include <linux/phy_fixed.h> +  + #include <asm/addrspace.h> + #include <asm/ar7/ar7.h> +@@ -205,6 +207,13 @@ + 	.width = 2, + }; +  ++/* lets assume this is suitable for both high and low cpmacs links */ ++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, +@@ -506,6 +515,10 @@ + 	} +  + 	if (ar7_has_high_cpmac()) { ++		res = fixed_phy_add(PHY_POLL, cpmac_high.id, &fixed_phy_status); ++		if (res && res != -ENODEV) ++			return res; ++ + 		cpmac_get_mac(1, cpmac_high_data.dev_addr); + 		res = platform_device_register(&cpmac_high); + 		if (res) +@@ -514,6 +527,10 @@ + 		cpmac_low_data.phy_mask = 0xffffffff; + 	} +  ++	res = fixed_phy_add(PHY_POLL, cpmac_low.id, &fixed_phy_status); ++	if (res && res != -ENODEV) ++		return res; ++ + 	cpmac_get_mac(0, cpmac_low_data.dev_addr); + 	res = platform_device_register(&cpmac_low); + 	if (res) diff --git a/target/linux/ar7/patches-2.6.27/910-cpmac_fixed_phy.patch b/target/linux/ar7/patches-2.6.27/910-cpmac_fixed_phy.patch new file mode 100644 index 000000000..dd4bb76a3 --- /dev/null +++ b/target/linux/ar7/patches-2.6.27/910-cpmac_fixed_phy.patch @@ -0,0 +1,92 @@ +This is a hack to make cpmac work with the external switch on a DG834 v3; it +should also work on other similar routers. It has not been tested on hardware +with multiple cpmac devices or with no external switch. It may be safer to +move external_switch to pdata rather than trying to detect it, and to set +phy_mask correctly rather than moving the phy search loop. + +--- a/drivers/net/cpmac.c	2008-11-11 06:18:24.000000000 +1100 ++++ b/drivers/net/cpmac.c	2009-04-11 10:58:58.000000000 +1000 +@@ -1124,8 +1124,8 @@ +  + static int __devinit cpmac_probe(struct platform_device *pdev) + { +	int rc, phy_id; +-	char *mdio_bus_id = "0"; ++	char mdio_bus_id[BUS_ID_SIZE]; + 	struct resource *mem; + 	struct cpmac_priv *priv; + 	struct net_device *dev; +@@ -1134,22 +1134,23 @@ +  + 	pdata = pdev->dev.platform_data; +  +-	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; +-		break; ++	if (external_switch || dumb_switch) { ++		strncpy(mdio_bus_id, "0", 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, BUS_ID_SIZE); ++			break; ++		} + 	} +  + 	if (phy_id == PHY_MAX_ADDR) { +-		if (external_switch || dumb_switch) { +-			mdio_bus_id = 0; /* fixed phys bus */ +-			phy_id = pdev->id; +-		} else { +-			dev_err(&pdev->dev, "no PHY present\n"); +-			return -ENODEV; +-		} ++		dev_err(&pdev->dev, "no PHY present\n"); ++		return -ENODEV; + 	} +  + #ifdef CONFIG_NETDEVICES_MULTIQUEUE +@@ -1189,9 +1190,11 @@ + 	priv->ring_size = 64; + 	priv->msg_enable = netif_msg_init(debug_level, 0xff); + 	memcpy(dev->dev_addr, pdata->dev_addr, sizeof(dev->dev_addr)); ++	 ++	snprintf(priv->phy_name, BUS_ID_SIZE, PHY_ID_FMT, mdio_bus_id, phy_id); +  +-	priv->phy = phy_connect(dev, cpmac_mii.phy_map[phy_id]->dev.bus_id, +-				&cpmac_adjust_link, 0, PHY_INTERFACE_MODE_MII); ++	priv->phy = phy_connect(dev, priv->phy_name, &cpmac_adjust_link, 0, ++	 			PHY_INTERFACE_MODE_MII); + 	if (IS_ERR(priv->phy)) { + 		if (netif_msg_drv(priv)) + 			printk(KERN_ERR "%s: Could not attach to PHY\n", +@@ -1250,11 +1253,11 @@ +  + 	cpmac_mii.reset(&cpmac_mii); +  +-	for (i = 0; i < 300000; i++) ++	for (i = 0; i < 300; i++) + 		if ((mask = cpmac_read(cpmac_mii.priv, CPMAC_MDIO_ALIVE))) + 			break; + 		else +-			cpu_relax(); ++			msleep(10); +  + 	mask &= 0x7fffffff; + 	if (mask & (mask - 1)) { +@@ -1267,7 +1270,7 @@ + 	} +  + 	cpmac_mii.phy_mask = ~(mask | 0x80000000); +-	snprintf(cpmac_mii.id, MII_BUS_ID_SIZE, "0"); ++	snprintf(cpmac_mii.id, MII_BUS_ID_SIZE, "1"); +  + 	res = mdiobus_register(&cpmac_mii); + 	if (res)  | 
