[PATCH] smc91x: Add support for an external PHY

From: Shaun Jackman
Date: Wed Jul 19 2006 - 17:27:42 EST


[PATCH] smc91x: Add support for an external PHY

Add an `extphy' module parameter to the smc91x Ethernet driver. This
parameter enables use of the external MII port and disables the
internal PHY.

Signed-off-by: Shaun Jackman <sjackman@xxxxxxxxx>

diff --git a/drivers/net/smc91x.c b/drivers/net/smc91x.c
index 3d8dcb6..d784565 100644
--- a/drivers/net/smc91x.c
+++ b/drivers/net/smc91x.c
@@ -26,6 +26,7 @@
* io = for the base address
* irq = for the IRQ
* nowait = 0 for normal wait states, 1 eliminates additional wait states
+ * extphy = use an external PHY
*
* original author:
* Erik Stahlman <erik@xxxxxx>
@@ -37,6 +38,7 @@
* Daris A Nevil <dnevil@xxxxxxxx>
* Nicolas Pitre <nico@xxxxxxx>
* Russell King <rmk@xxxxxxxxxxxxxxxx>
+ * Shaun Jackman <sjackman@xxxxxxxxx>
*
* History:
* 08/20/00 Arnaldo Melo fix kfree(skb) in smc_hardware_send_packet
@@ -56,6 +58,7 @@
* - clean up (and fix stack overrun) in PHY
* MII read/write functions
* 22/09/04 Nicolas Pitre big update (see commit log for details)
+ * 18/07/06 Shaun Jackman add extphy parameter
*/
static const char version[] =
"smc91x.c: v1.1, sep 22 2004 by Nicolas Pitre <nico@xxxxxxx>\n";
@@ -124,6 +127,13 @@ static int nowait = SMC_NOWAIT;
module_param(nowait, int, 0400);
MODULE_PARM_DESC(nowait, "set to 1 for no wait state");

+#ifndef SMC_EXTPHY
+# define SMC_EXTPHY 0
+#endif
+static int extphy = SMC_EXTPHY;
+module_param(extphy, int, 0400);
+MODULE_PARM_DESC(extphy, "set to 1 to use an external PHY");
+
/*
* Transmit timeout, default 5 seconds.
*/
@@ -359,6 +369,10 @@ static void smc_reset(struct net_device
if (nowait)
cfg |= CONFIG_NO_WAIT;

+ /* Use an external PHY if requested. */
+ if (extphy)
+ cfg |= CONFIG_EXT_PHY;
+
/*
* Release from possible power-down state
* Configuration register is not affected by Soft Reset
@@ -949,6 +963,9 @@ static void smc_phy_detect(struct net_de

lp->phy_type = 0;

+ if (extphy)
+ return;
+
/*
* Scan all 32 PHY addresses if necessary, starting at
* PHY#1 to PHY#31, and then PHY#0 last.
@@ -1583,7 +1600,7 @@ smc_open(struct net_device *dev)
* If we are not using a MII interface, we need to
* monitor our own carrier signal to detect faults.
*/
- if (lp->phy_type == 0)
+ if (lp->phy_type == 0 && !extphy)
lp->tcr_cur_mode |= TCR_MON_CSN;

/* reset the hardware */
@@ -2025,8 +2042,9 @@ #endif
if (dev->dma != (unsigned char)-1)
printk(" DMA %d", dev->dma);

- printk("%s%s\n", nowait ? " [nowait]" : "",
- THROTTLE_TX_PKTS ? " [throttle_tx]" : "");
+ printk("%s%s%s\n", nowait ? " [nowait]" : "",
+ THROTTLE_TX_PKTS ? " [throttle_tx]" : "",
+ extphy ? " [extphy]" : "");

if (!is_valid_ether_addr(dev->dev_addr)) {
printk("%s: Invalid ethernet MAC address. Please "
@@ -2046,6 +2064,8 @@ #endif
} else if ((lp->phy_type & 0xfffffff0) == 0x02821c50) {
PRINTK("%s: PHY LAN83C180\n", dev->name);
}
+ if (extphy)
+ PRINTK("%s: Using external PHY\n", dev->name);
}

err_out: [PATCH] smc91x: Add support for an external PHY

Add an `extphy' module parameter to the smc91x Ethernet driver. This
parameter enables use of the external MII port and disables the
internal PHY.

Signed-off-by: Shaun Jackman <sjackman@xxxxxxxxx>

diff --git a/drivers/net/smc91x.c b/drivers/net/smc91x.c
index 3d8dcb6..d784565 100644
--- a/drivers/net/smc91x.c
+++ b/drivers/net/smc91x.c
@@ -26,6 +26,7 @@
* io = for the base address
* irq = for the IRQ
* nowait = 0 for normal wait states, 1 eliminates additional wait states
+ * extphy = use an external PHY
*
* original author:
* Erik Stahlman <erik@xxxxxx>
@@ -37,6 +38,7 @@
* Daris A Nevil <dnevil@xxxxxxxx>
* Nicolas Pitre <nico@xxxxxxx>
* Russell King <rmk@xxxxxxxxxxxxxxxx>
+ * Shaun Jackman <sjackman@xxxxxxxxx>
*
* History:
* 08/20/00 Arnaldo Melo fix kfree(skb) in smc_hardware_send_packet
@@ -56,6 +58,7 @@
* - clean up (and fix stack overrun) in PHY
* MII read/write functions
* 22/09/04 Nicolas Pitre big update (see commit log for details)
+ * 18/07/06 Shaun Jackman add extphy parameter
*/
static const char version[] =
"smc91x.c: v1.1, sep 22 2004 by Nicolas Pitre <nico@xxxxxxx>\n";
@@ -124,6 +127,13 @@ static int nowait = SMC_NOWAIT;
module_param(nowait, int, 0400);
MODULE_PARM_DESC(nowait, "set to 1 for no wait state");

+#ifndef SMC_EXTPHY
+# define SMC_EXTPHY 0
+#endif
+static int extphy = SMC_EXTPHY;
+module_param(extphy, int, 0400);
+MODULE_PARM_DESC(extphy, "set to 1 to use an external PHY");
+
/*
* Transmit timeout, default 5 seconds.
*/
@@ -359,6 +369,10 @@ static void smc_reset(struct net_device
if (nowait)
cfg |= CONFIG_NO_WAIT;

+ /* Use an external PHY if requested. */
+ if (extphy)
+ cfg |= CONFIG_EXT_PHY;
+
/*
* Release from possible power-down state
* Configuration register is not affected by Soft Reset
@@ -949,6 +963,9 @@ static void smc_phy_detect(struct net_de

lp->phy_type = 0;

+ if (extphy)
+ return;
+
/*
* Scan all 32 PHY addresses if necessary, starting at
* PHY#1 to PHY#31, and then PHY#0 last.
@@ -1583,7 +1600,7 @@ smc_open(struct net_device *dev)
* If we are not using a MII interface, we need to
* monitor our own carrier signal to detect faults.
*/
- if (lp->phy_type == 0)
+ if (lp->phy_type == 0 && !extphy)
lp->tcr_cur_mode |= TCR_MON_CSN;

/* reset the hardware */
@@ -2025,8 +2042,9 @@ #endif
if (dev->dma != (unsigned char)-1)
printk(" DMA %d", dev->dma);

- printk("%s%s\n", nowait ? " [nowait]" : "",
- THROTTLE_TX_PKTS ? " [throttle_tx]" : "");
+ printk("%s%s%s\n", nowait ? " [nowait]" : "",
+ THROTTLE_TX_PKTS ? " [throttle_tx]" : "",
+ extphy ? " [extphy]" : "");

if (!is_valid_ether_addr(dev->dev_addr)) {
printk("%s: Invalid ethernet MAC address. Please "
@@ -2046,6 +2064,8 @@ #endif
} else if ((lp->phy_type & 0xfffffff0) == 0x02821c50) {
PRINTK("%s: PHY LAN83C180\n", dev->name);
}
+ if (extphy)
+ PRINTK("%s: Using external PHY\n", dev->name);
}

err_out: