netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][V2] MACB: Set PHY address in kernel parameters
@ 2010-03-31  8:46 Anders Darander
  2010-03-31  9:17 ` Marc Kleine-Budde
  0 siblings, 1 reply; 4+ messages in thread
From: Anders Darander @ 2010-03-31  8:46 UTC (permalink / raw)
  To: Haavard Skinnemoen
  Cc: David S. Miller, Jiri Pirko, Erik Waling, Patrick McHardy,
	Anders Darander, Grant Likely, netdev, linux-kernel

From: Anders Darander <ad@datarespons.se>

Add the possibility to set the phy address. This is needed if an integrated
switch is connected to the MAC, as it is often the case that the highest port
is the one connected to the MAC of the MCU.

E.g. in the case of the Micrel KSZ8873, port 3 is the one to connect to the
MCU, thus, the MAC needs to connect to phy address 0x03, instead of the first
phy found.

Signed-off-by: Anders Darander <ad@datarespons.se>
---

Changes from V1:
	* Made the variable type consistent with the module parameter
	  declaration. (I.e. made it unsigned short).

 drivers/net/macb.c |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index c8a18a6..af7b61b 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -53,6 +53,14 @@
 #define MACB_RX_INT_FLAGS	(MACB_BIT(RCOMP) | MACB_BIT(RXUBR)	\
 				 | MACB_BIT(ISR_ROVR))
 
+/*
+ * Setup PHY probeing
+ */
+
+static unsigned short phy_addr = PHY_MAX_ADDR;
+module_param(phy_addr, ushort, 0);
+MODULE_PARAM_DESC(phy_addr, "PHY address connected to the MACB");
+
 static void __macb_set_hwaddr(struct macb *bp)
 {
 	u32 bottom;
@@ -193,7 +201,11 @@ static int macb_mii_probe(struct net_device *dev)
 	struct eth_platform_data *pdata;
 	int ret;
 
-	phydev = phy_find_first(bp->mii_bus);
+	if (phy_addr >= PHY_MAX_ADDRESS)
+		phydev = phy_find_first(bp->mii_bus);
+	else
+		phydev = bp->mii_bus->phy_map[phy_addr];
+
 	if (!phydev) {
 		printk (KERN_ERR "%s: no PHY found\n", dev->name);
 		return -1;
-- 
1.7.0.3

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH][V2] MACB: Set PHY address in kernel parameters
  2010-03-31  8:46 [PATCH][V2] MACB: Set PHY address in kernel parameters Anders Darander
@ 2010-03-31  9:17 ` Marc Kleine-Budde
  2010-03-31  9:39   ` Anders Darander
  0 siblings, 1 reply; 4+ messages in thread
From: Marc Kleine-Budde @ 2010-03-31  9:17 UTC (permalink / raw)
  To: Anders Darander
  Cc: Haavard Skinnemoen, David S. Miller, Jiri Pirko, Erik Waling,
	Patrick McHardy, Anders Darander, Grant Likely, netdev,
	linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1055 bytes --]

Anders Darander wrote:
> From: Anders Darander <ad@datarespons.se>
> 
> Add the possibility to set the phy address. This is needed if an integrated
> switch is connected to the MAC, as it is often the case that the highest port
> is the one connected to the MAC of the MCU.
> 
> E.g. in the case of the Micrel KSZ8873, port 3 is the one to connect to the
> MCU, thus, the MAC needs to connect to phy address 0x03, instead of the first
> phy found.

We're using phy_mask in one of our projects, it's still using 2.6.29,
though. I think it's worth testing if it's still working.

static struct at91_eth_data __initdata p298_macb_data = {
       .is_rmii        = 0,
       .phy_mask       = ~(1 << 8),
};

at91_add_device_eth(&p298_macb_data);

cheers, Marc

-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH][V2] MACB: Set PHY address in kernel parameters
  2010-03-31  9:17 ` Marc Kleine-Budde
@ 2010-03-31  9:39   ` Anders Darander
  2010-03-31  9:48     ` Marc Kleine-Budde
  0 siblings, 1 reply; 4+ messages in thread
From: Anders Darander @ 2010-03-31  9:39 UTC (permalink / raw)
  To: Marc Kleine-Budde
  Cc: Haavard Skinnemoen, David S. Miller, Jiri Pirko, Erik Waling,
	Patrick McHardy, Grant Likely, netdev, linux-kernel

* Marc Kleine-Budde <mkl@pengutronix.de> [100331 11:18]:
> We're using phy_mask in one of our projects, it's still using 2.6.29,
> though. I think it's worth testing if it's still working.

Well, that was obviously something I overlooked / misinterpreted when I
tried to solve our problem!

As I understand it, phy_mask is a bitfield for setting which PHYs should
be enabled... Then this should have worked OK for us!

> static struct at91_eth_data __initdata p298_macb_data = {
>        .is_rmii        = 0,
>        .phy_mask       = ~(1 << 8),
> };

> at91_add_device_eth(&p298_macb_data);

I've not tested it, but it should probably have worked.

Regards,
Anders

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH][V2] MACB: Set PHY address in kernel parameters
  2010-03-31  9:39   ` Anders Darander
@ 2010-03-31  9:48     ` Marc Kleine-Budde
  0 siblings, 0 replies; 4+ messages in thread
From: Marc Kleine-Budde @ 2010-03-31  9:48 UTC (permalink / raw)
  To: Anders Darander
  Cc: Haavard Skinnemoen, David S. Miller, Jiri Pirko, Erik Waling,
	Patrick McHardy, Grant Likely, netdev, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1066 bytes --]

Anders Darander wrote:
> * Marc Kleine-Budde <mkl@pengutronix.de> [100331 11:18]:
>> We're using phy_mask in one of our projects, it's still using 2.6.29,
>> though. I think it's worth testing if it's still working.
> 
> Well, that was obviously something I overlooked / misinterpreted when I
> tried to solve our problem!
> 
> As I understand it, phy_mask is a bitfield for setting which PHYs should
> be enabled... Then this should have worked OK for us!

Yes, it's a bitmask of PHYs that should be probed.

>> static struct at91_eth_data __initdata p298_macb_data = {
>>        .is_rmii        = 0,
>>        .phy_mask       = ~(1 << 8),
>> };
> 
>> at91_add_device_eth(&p298_macb_data);
> 
> I've not tested it, but it should probably have worked.

Cheers, Marc

-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-03-31  9:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-31  8:46 [PATCH][V2] MACB: Set PHY address in kernel parameters Anders Darander
2010-03-31  9:17 ` Marc Kleine-Budde
2010-03-31  9:39   ` Anders Darander
2010-03-31  9:48     ` Marc Kleine-Budde

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).