Skip to contentSkip to conversation

MII bitbang driver should generate MII bus phy_mask dynamically

PATCH In review Mark Zhan 3 participants 4 messages Jun 11, 2007

Subsystems (2)
lore
Share & tools
lore

Mark Zhan

author
#0 lore raw

PATCH 1/1 MII bitbang driver should generate MII bus phy_mask dynamically

Current MII bitbang bus driver hard-codes the phy mask of mii_bus to ~0x09, which is actually specific to the FSL boards. This patch will make the bitbang driver to generate MII bus phy_mask dynamically, by the PHY irq info provided by the platform.

---
 b/drivers/net/fs_enet/mii-bitbang.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
(quoted diff) +0 -0

b/drivers/net/fs_enet/mii-bitbang.c
index d384010..3732d69 100644

drivers/net/fs_enet/mii-bitbang.c +6 -3
@@ -315,7 +315,7 @@ static int __devinit fs_enet_mdio_probe(
 	struct fs_mii_bb_platform_info *pdata;
 	struct mii_bus *new_bus;
 	struct bb_info *bitbang;
-	int err = 0;
+	int i, err = 0;
 
 	if (NULL == dev)
 		return -EINVAL;
@@ -336,14 +336,17 @@ static int __devinit fs_enet_mdio_probe(
 	new_bus->reset = &fs_enet_mii_bb_reset,
 	new_bus->id = pdev->id;
 
-	new_bus->phy_mask = ~0x9;
 	pdata = (struct fs_mii_bb_platform_info *)pdev->dev.platform_data;
-
 	if (NULL == pdata) {
 		printk(KERN_ERR "gfar mdio %d: Missing platform data!\n", pdev->id);
 		return -ENODEV;
 	}
 
+	new_bus->phy_mask = 0xFFFFFFFF;
+	for (i = 0; i < PHY_MAX_ADDR; i++)
+		if (pdata->irq[i] != -1)
+			new_bus->phy_mask &= ~(1 << i);
+
 	/*set up workspace*/
 	fs_mii_bitbang_init(bitbang, pdata);
 
#1 lore raw
Quoted 6 lines · Mark Zhan

Current MII bitbang bus driver hard-codes the phy mask of mii_bus to ~0x09, which is actually specific to the FSL boards. This patch will make the bitbang driver to generate MII bus phy_mask dynamically, by the PHY irq info provided by the platform.

[...]

drivers/net/fs_enet/mii-bitbang.c static int __devinit fs_enet_mdio_probe( · line 349

Quoted 6 lines
drivers/net/fs_enet/mii-bitbang.c +5 -0
+	new_bus->phy_mask = 0xFFFFFFFF;
+	for (i = 0; i < PHY_MAX_ADDR; i++)
+		if (pdata->irq[i] != -1)
+			new_bus->phy_mask &= ~(1 << i);
+

This doesn't work. There are a couple of things wrong:

1) Don't use -1, use PHY_POLL

2) As you can tell from #1, the absence of a set interrupt for a particular PHY does not indicate it doesn't exist. Rather, it indicates it doesn't have an interrupt.

I think you need to add a phy_mask to the platform data, and then set it appropriately. We also need to look into adding that for the mdio nodes in the device tree, so it will get passed in properly.

Andy

Acked-by on v1 1/1
#2 lore raw
In reply to Mark Zhan
Quoted 6 lines · Mark Zhan

Current MII bitbang bus driver hard-codes the phy mask of mii_bus to ~0x09, which is actually specific to the FSL boards. This patch will make the bitbang driver to generate MII bus phy_mask dynamically, by the PHY irq info provided by the platform.

Quoted 44 lines

---

 b/drivers/net/fs_enet/mii-bitbang.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/net/fs_enet/mii-bitbang.c +6 -3
index d384010..3732d69 100644
@@ -315,7 +315,7 @@ static int __devinit fs_enet_mdio_probe(
 	struct fs_mii_bb_platform_info *pdata;
 	struct mii_bus *new_bus;
 	struct bb_info *bitbang;
-	int err = 0;
+	int i, err = 0;
 
 	if (NULL == dev)
 		return -EINVAL;
@@ -336,14 +336,17 @@ static int __devinit fs_enet_mdio_probe(
 	new_bus->reset = &fs_enet_mii_bb_reset,
 	new_bus->id = pdev->id;
 
-	new_bus->phy_mask = ~0x9;
 	pdata = (struct fs_mii_bb_platform_info *)pdev->dev.platform_data;
-
 	if (NULL == pdata) {
 		printk(KERN_ERR "gfar mdio %d: Missing platform data!\n", pdev->id);
 		return -ENODEV;
 	}
 
+	new_bus->phy_mask = 0xFFFFFFFF;
+	for (i = 0; i < PHY_MAX_ADDR; i++)
+		if (pdata->irq[i] != -1)
+			new_bus->phy_mask &= ~(1 << i);
+
 	/*set up workspace*/
 	fs_mii_bitbang_init(bitbang, pdata);
 

_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://ozlabs.org/mailman/listinfo/linuxppc-dev

#3 lore raw
In reply to Mark Zhan
Quoted 4 lines · Mark Zhan

Current MII bitbang bus driver hard-codes the phy mask of mii_bus to ~0x09, which is actually specific to the FSL boards. This patch will make the bitbang driver to generate MII bus phy_mask dynamically, by the PHY irq info provided by the platform.

just realized that haven't mentioned that it's OK from me, assuming Andy's comment taken into account...

Quoted 45 lines
---
 b/drivers/net/fs_enet/mii-bitbang.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/net/fs_enet/mii-bitbang.c +6 -3
index d384010..3732d69 100644
@@ -315,7 +315,7 @@ static int __devinit fs_enet_mdio_probe(
 	struct fs_mii_bb_platform_info *pdata;
 	struct mii_bus *new_bus;
 	struct bb_info *bitbang;
-	int err = 0;
+	int i, err = 0;
 
 	if (NULL == dev)
 		return -EINVAL;
@@ -336,14 +336,17 @@ static int __devinit fs_enet_mdio_probe(
 	new_bus->reset = &fs_enet_mii_bb_reset,
 	new_bus->id = pdev->id;
 
-	new_bus->phy_mask = ~0x9;
 	pdata = (struct fs_mii_bb_platform_info *)pdev->dev.platform_data;
-
 	if (NULL == pdata) {
 		printk(KERN_ERR "gfar mdio %d: Missing platform data!\n", pdev->id);
 		return -ENODEV;
 	}
 
+	new_bus->phy_mask = 0xFFFFFFFF;
+	for (i = 0; i < PHY_MAX_ADDR; i++)
+		if (pdata->irq[i] != -1)
+			new_bus->phy_mask &= ~(1 << i);
+
 	/*set up workspace*/
 	fs_mii_bitbang_init(bitbang, pdata);
 

_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://ozlabs.org/mailman/listinfo/linuxppc-dev