public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] staging: et131x: converting et131x_ioctl to use phy_mii_ioctl
@ 2011-08-30 11:47 Mark Einon
  2011-08-30 11:47 ` [PATCH 2/3] staging: et131x: Remove xcvr_addr and et131x_xcvr_find Mark Einon
  2011-08-30 11:47 ` [PATCH 3/3] staging: et131x: Remove redundant phy code Mark Einon
  0 siblings, 2 replies; 3+ messages in thread
From: Mark Einon @ 2011-08-30 11:47 UTC (permalink / raw)
  To: gregkh; +Cc: greg, devel, linux-kernel, o.hartmann, Mark Einon

Handing over ioctls handled by the driver to the phydev.

Signed-off-by: Mark Einon <mark.einon@gmail.com>
---
 drivers/staging/et131x/et131x_netdev.c |   56 ++-----------------------------
 1 files changed, 4 insertions(+), 52 deletions(-)

diff --git a/drivers/staging/et131x/et131x_netdev.c b/drivers/staging/et131x/et131x_netdev.c
index ce21433..d12e05e 100644
--- a/drivers/staging/et131x/et131x_netdev.c
+++ b/drivers/staging/et131x/et131x_netdev.c
@@ -208,47 +208,6 @@ int et131x_close(struct net_device *netdev)
 }
 
 /**
- * et131x_ioctl_mii - The function which handles MII IOCTLs
- * @netdev: device on which the query is being made
- * @reqbuf: the request-specific data buffer
- * @cmd: the command request code
- *
- * Returns 0 on success, errno on failure (as defined in errno.h)
- */
-int et131x_ioctl_mii(struct net_device *netdev, struct ifreq *reqbuf, int cmd)
-{
-	int status = 0;
-	struct et131x_adapter *adapter = netdev_priv(netdev);
-	struct mii_ioctl_data *data = if_mii(reqbuf);
-
-	switch (cmd) {
-	case SIOCGMIIPHY:
-		data->phy_id = adapter->stats.xcvr_addr;
-		break;
-
-	case SIOCGMIIREG:
-		if (!capable(CAP_NET_ADMIN))
-			status = -EPERM;
-		else
-			status = et131x_mii_read(adapter,
-					data->reg_num, &data->val_out);
-		break;
-
-	case SIOCSMIIREG:
-		if (!capable(CAP_NET_ADMIN))
-			status = -EPERM;
-		else
-			status = et131x_mii_write(adapter, data->reg_num,
-					 data->val_in);
-		break;
-
-	default:
-		status = -EOPNOTSUPP;
-	}
-	return status;
-}
-
-/**
  * et131x_ioctl - The I/O Control handler for the driver
  * @netdev: device on which the control request is being made
  * @reqbuf: a pointer to the IOCTL request buffer
@@ -258,19 +217,12 @@ int et131x_ioctl_mii(struct net_device *netdev, struct ifreq *reqbuf, int cmd)
  */
 int et131x_ioctl(struct net_device *netdev, struct ifreq *reqbuf, int cmd)
 {
-	int status = 0;
+	struct et131x_adapter *adapter = netdev_priv(netdev);
 
-	switch (cmd) {
-	case SIOCGMIIPHY:
-	case SIOCGMIIREG:
-	case SIOCSMIIREG:
-		status = et131x_ioctl_mii(netdev, reqbuf, cmd);
-		break;
+	if (!adapter->phydev)
+		return -EINVAL;
 
-	default:
-		status = -EOPNOTSUPP;
-	}
-	return status;
+	return phy_mii_ioctl(adapter->phydev, reqbuf, cmd);
 }
 
 /**
-- 
1.7.6


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

* [PATCH 2/3] staging: et131x: Remove xcvr_addr and et131x_xcvr_find
  2011-08-30 11:47 [PATCH 1/3] staging: et131x: converting et131x_ioctl to use phy_mii_ioctl Mark Einon
@ 2011-08-30 11:47 ` Mark Einon
  2011-08-30 11:47 ` [PATCH 3/3] staging: et131x: Remove redundant phy code Mark Einon
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Einon @ 2011-08-30 11:47 UTC (permalink / raw)
  To: gregkh; +Cc: greg, devel, linux-kernel, o.hartmann, Mark Einon

Use the phy_device equivalents instead.

Signed-off-by: Mark Einon <mark.einon@gmail.com>
---
 drivers/staging/et131x/et1310_phy.c     |   72 ++++++++++++------------------
 drivers/staging/et131x/et131x.h         |   17 +++----
 drivers/staging/et131x/et131x_adapter.h |    3 -
 drivers/staging/et131x/et131x_initpci.c |   15 +------
 4 files changed, 38 insertions(+), 69 deletions(-)

diff --git a/drivers/staging/et131x/et1310_phy.c b/drivers/staging/et131x/et1310_phy.c
index 5e21a18..9613846 100644
--- a/drivers/staging/et131x/et1310_phy.c
+++ b/drivers/staging/et131x/et1310_phy.c
@@ -114,7 +114,6 @@ int et131x_mdio_write(struct mii_bus *bus, int phy_addr, int reg, u16 value)
 	struct net_device *netdev = bus->priv;
 	struct et131x_adapter *adapter = netdev_priv(netdev);
 
-	/* mii_write always uses the same phy_addr, xcvr_addr */
 	return et131x_mii_write(adapter, reg, value);
 }
 
@@ -128,17 +127,28 @@ int et131x_mdio_reset(struct mii_bus *bus)
 	return 0;
 }
 
+
+int et131x_mii_read(struct et131x_adapter *adapter, u8 reg, u16 *value)
+{
+	struct phy_device *phydev = adapter->phydev;
+
+	if(!phydev)
+		return -EIO;
+
+	return et131x_phy_mii_read(adapter, phydev->addr, reg, value);
+}
+
 /**
  * et131x_phy_mii_read - Read from the PHY through the MII Interface on the MAC
  * @adapter: pointer to our private adapter structure
- * @xcvr_addr: the address of the transceiver
- * @xcvr_reg: the register to read
+ * @addr: the address of the transceiver
+ * @reg: the register to read
  * @value: pointer to a 16-bit value in which the value will be stored
  *
  * Returns 0 on success, errno on failure (as defined in errno.h)
  */
-int et131x_phy_mii_read(struct et131x_adapter *adapter, u8 xcvr_addr,
-	      u8 xcvr_reg, u16 *value)
+int et131x_phy_mii_read(struct et131x_adapter *adapter, u8 addr,
+	      u8 reg, u16 *value)
 {
 	struct mac_regs __iomem *mac = &adapter->regs->mac;
 	int status = 0;
@@ -157,7 +167,7 @@ int et131x_phy_mii_read(struct et131x_adapter *adapter, u8 xcvr_addr,
 	writel(0, &mac->mii_mgmt_cmd);
 
 	/* Set up the register we need to read from on the correct PHY */
-	writel(MII_ADDR(xcvr_addr, xcvr_reg), &mac->mii_mgmt_addr);
+	writel(MII_ADDR(addr, reg), &mac->mii_mgmt_addr);
 
 	writel(0x1, &mac->mii_mgmt_cmd);
 
@@ -170,7 +180,7 @@ int et131x_phy_mii_read(struct et131x_adapter *adapter, u8 xcvr_addr,
 	/* If we hit the max delay, we could not read the register */
 	if (delay == 50) {
 		dev_warn(&adapter->pdev->dev,
-			    "xcvrReg 0x%08x could not be read\n", xcvr_reg);
+			    "reg 0x%08x could not be read\n", reg);
 		dev_warn(&adapter->pdev->dev, "status is  0x%08x\n",
 			    mii_indicator);
 
@@ -196,23 +206,29 @@ int et131x_phy_mii_read(struct et131x_adapter *adapter, u8 xcvr_addr,
 /**
  * et131x_mii_write - Write to a PHY register through the MII interface of the MAC
  * @adapter: pointer to our private adapter structure
- * @xcvr_reg: the register to read
+ * @reg: the register to read
  * @value: 16-bit value to write
  *
  * FIXME: one caller in netdev still
  *
  * Return 0 on success, errno on failure (as defined in errno.h)
  */
-int et131x_mii_write(struct et131x_adapter *adapter, u8 xcvr_reg, u16 value)
+int et131x_mii_write(struct et131x_adapter *adapter, u8 reg, u16 value)
 {
 	struct mac_regs __iomem *mac = &adapter->regs->mac;
+	struct phy_device *phydev = adapter->phydev;
 	int status = 0;
-	u8 xcvr_addr = adapter->stats.xcvr_addr;
+	u8 addr;
 	u32 delay = 0;
 	u32 mii_addr;
 	u32 mii_cmd;
 	u32 mii_indicator;
 
+	if(!phydev)
+		return -EIO;
+
+	addr = phydev->addr;
+
 	/* Save a local copy of the registers we are dealing with so we can
 	 * set them back
 	 */
@@ -223,7 +239,7 @@ int et131x_mii_write(struct et131x_adapter *adapter, u8 xcvr_reg, u16 value)
 	writel(0, &mac->mii_mgmt_cmd);
 
 	/* Set up the register we need to write to on the correct PHY */
-	writel(MII_ADDR(xcvr_addr, xcvr_reg), &mac->mii_mgmt_addr);
+	writel(MII_ADDR(addr, reg), &mac->mii_mgmt_addr);
 
 	/* Add the value to write to the registers to the mac */
 	writel(value, &mac->mii_mgmt_ctrl);
@@ -239,13 +255,13 @@ int et131x_mii_write(struct et131x_adapter *adapter, u8 xcvr_reg, u16 value)
 		u16 tmp;
 
 		dev_warn(&adapter->pdev->dev,
-		    "xcvrReg 0x%08x could not be written", xcvr_reg);
+		    "reg 0x%08x could not be written", reg);
 		dev_warn(&adapter->pdev->dev, "status is  0x%08x\n",
 			    mii_indicator);
 		dev_warn(&adapter->pdev->dev, "command is  0x%08x\n",
 			    readl(&mac->mii_mgmt_cmd));
 
-		et131x_mii_read(adapter, xcvr_reg, &tmp);
+		et131x_mii_read(adapter, reg, &tmp);
 
 		status = -EIO;
 	}
@@ -262,36 +278,6 @@ int et131x_mii_write(struct et131x_adapter *adapter, u8 xcvr_reg, u16 value)
 	return status;
 }
 
-/**
- * et131x_xcvr_find - Find the PHY ID
- * @adapter: pointer to our private adapter structure
- *
- * Returns 0 on success, errno on failure (as defined in errno.h)
- */
-int et131x_xcvr_find(struct et131x_adapter *adapter)
-{
-	u8 xcvr_addr;
-	u16 idr1;
-	u16 idr2;
-
-	/* We need to get xcvr id and address we just get the first one */
-	for (xcvr_addr = 0; xcvr_addr < 32; xcvr_addr++) {
-		/* Read the ID from the PHY */
-		et131x_phy_mii_read(adapter, xcvr_addr,
-			     (u8) offsetof(struct mi_regs, idr1),
-			     &idr1);
-		et131x_phy_mii_read(adapter, xcvr_addr,
-			     (u8) offsetof(struct mi_regs, idr2),
-			     &idr2);
-
-		if (idr1 != 0 && idr1 != 0xffff) {
-			adapter->stats.xcvr_addr = xcvr_addr;
-			return 0;
-		}
-	}
-	return -ENODEV;
-}
-
 void et1310_phy_reset(struct et131x_adapter *adapter)
 {
 	et131x_mii_write(adapter, PHY_CONTROL, 0x8000);
diff --git a/drivers/staging/et131x/et131x.h b/drivers/staging/et131x/et131x.h
index 9dee7bc..763396a 100644
--- a/drivers/staging/et131x/et131x.h
+++ b/drivers/staging/et131x/et131x.h
@@ -59,7 +59,7 @@ void et131x_align_allocated_memory(struct et131x_adapter *adapter,
 				   u64 *phys_addr,
 				   u64 *offset, u64 mask);
 
-int et131x_adapter_setup(struct et131x_adapter *adapter);
+void et131x_adapter_setup(struct et131x_adapter *adapter);
 int et131x_adapter_memory_alloc(struct et131x_adapter *adapter);
 void et131x_adapter_memory_free(struct et131x_adapter *adapter);
 void et131x_hwaddr_init(struct et131x_adapter *adapter);
@@ -104,16 +104,13 @@ void et131x_setphy_normal(struct et131x_adapter *adapter);
 /* static inline function does not work because et131x_adapter is not always
  * defined
  */
-int et131x_phy_mii_read(struct et131x_adapter *adapter, u8 xcvrAddr,
-	      u8 xcvrReg, u16 *value);
-#define et131x_mii_read(adapter, xcvrReg, value) \
-	et131x_phy_mii_read((adapter), \
-			    (adapter)->stats.xcvr_addr, \
-			    (xcvrReg), (value))
-
+int et131x_phy_mii_read(struct et131x_adapter *adapter, u8 addr,
+	      u8 reg, u16 *value);
+int32_t et131x_mii_read(struct et131x_adapter *adapter,
+		u8 reg, u16 *value);
 int32_t et131x_mii_write(struct et131x_adapter *adapter,
-		u8 xcvReg, u16 value);
-void et131x_mii_check(struct et131x_adapter *pAdapter,
+		u8 reg, u16 value);
+void et131x_mii_check(struct et131x_adapter *adapter,
 		      u16 bmsr, u16 bmsr_ints);
 
 int et131x_mdio_read(struct mii_bus *bus, int phy_addr, int reg);
diff --git a/drivers/staging/et131x/et131x_adapter.h b/drivers/staging/et131x/et131x_adapter.h
index dbb14fe..fbefd2e 100644
--- a/drivers/staging/et131x/et131x_adapter.h
+++ b/drivers/staging/et131x/et131x_adapter.h
@@ -113,9 +113,6 @@ struct ce_stats {
 	atomic_t	broadcast_pkts_xmtd;
 	u32		rcvd_pkts_dropped;
 
-	/* Transceiver state informations. */
-	u8		xcvr_addr;
-
 	/* Tx Statistics. */
 	u32		tx_underflows;
 
diff --git a/drivers/staging/et131x/et131x_initpci.c b/drivers/staging/et131x/et131x_initpci.c
index fbbef76..66cf1ce 100644
--- a/drivers/staging/et131x/et131x_initpci.c
+++ b/drivers/staging/et131x/et131x_initpci.c
@@ -328,10 +328,8 @@ void et131x_configure_global_regs(struct et131x_adapter *adapter)
  *
  * Returns 0 on success, errno on failure (as defined in errno.h)
  */
-int et131x_adapter_setup(struct et131x_adapter *adapter)
+void et131x_adapter_setup(struct et131x_adapter *adapter)
 {
-	int status;
-
 	/* Configure the JAGCore */
 	et131x_configure_global_regs(adapter);
 
@@ -349,12 +347,6 @@ int et131x_adapter_setup(struct et131x_adapter *adapter)
 
 	et1310_config_macstat_regs(adapter);
 
-	/* Move the following code to Timer function?? */
-	status = et131x_xcvr_find(adapter);
-
-	if (status)
-		dev_warn(&adapter->pdev->dev, "Could not find the xcvr\n");
-
 	/* Prepare the TRUEPHY library. */
 	et1310_phy_init(adapter);
 
@@ -377,7 +369,6 @@ int et131x_adapter_setup(struct et131x_adapter *adapter)
 	et1310_phy_power_down(adapter, 0);
 
 	et131x_setphy_normal(adapter);
-	return status;
 }
 
 /**
@@ -493,9 +484,7 @@ static void et131x_adjust_link(struct net_device *netdev)
 		et1310_disable_phy_coma(adapter);
 	}
 
-	et131x_mii_read(adapter,
-	       (uint8_t) offsetof(struct mi_regs, bmsr),
-	       &bmsr_data);
+	et131x_phy_mii_read(adapter, phydev->addr, MII_BMSR, &bmsr_data);
 
 	bmsr_ints = adapter->bmsr ^ bmsr_data;
 	adapter->bmsr = bmsr_data;
-- 
1.7.6


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

* [PATCH 3/3] staging: et131x: Remove redundant phy code
  2011-08-30 11:47 [PATCH 1/3] staging: et131x: converting et131x_ioctl to use phy_mii_ioctl Mark Einon
  2011-08-30 11:47 ` [PATCH 2/3] staging: et131x: Remove xcvr_addr and et131x_xcvr_find Mark Einon
@ 2011-08-30 11:47 ` Mark Einon
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Einon @ 2011-08-30 11:47 UTC (permalink / raw)
  To: gregkh; +Cc: greg, devel, linux-kernel, o.hartmann, Mark Einon

Now we are using a phy_device, remove driver functionality that is now handled by the phydev.

Signed-off-by: Mark Einon <mark.einon@gmail.com>
---
 drivers/staging/et131x/et1310_phy.c     |  415 +------------------------------
 drivers/staging/et131x/et1310_pm.c      |   15 +-
 drivers/staging/et131x/et131x.h         |    7 +-
 drivers/staging/et131x/et131x_initpci.c |   30 +---
 4 files changed, 15 insertions(+), 452 deletions(-)

diff --git a/drivers/staging/et131x/et1310_phy.c b/drivers/staging/et131x/et1310_phy.c
index 9613846..c216bbb 100644
--- a/drivers/staging/et131x/et1310_phy.c
+++ b/drivers/staging/et131x/et1310_phy.c
@@ -122,7 +122,7 @@ int et131x_mdio_reset(struct mii_bus *bus)
 	struct net_device *netdev = bus->priv;
 	struct et131x_adapter *adapter = netdev_priv(netdev);
 
-	et1310_phy_reset(adapter);
+	et131x_mii_write(adapter, PHY_CONTROL, 0x8000);
 
 	return 0;
 }
@@ -278,11 +278,6 @@ int et131x_mii_write(struct et131x_adapter *adapter, u8 reg, u16 value)
 	return status;
 }
 
-void et1310_phy_reset(struct et131x_adapter *adapter)
-{
-	et131x_mii_write(adapter, PHY_CONTROL, 0x8000);
-}
-
 /**
  *	et1310_phy_power_down	-	PHY power control
  *	@adapter: device to control
@@ -305,63 +300,6 @@ void et1310_phy_power_down(struct et131x_adapter *adapter, bool down)
 }
 
 /**
- *	et1310_phy_auto_neg	-	autonegotiate control
- *	@adapter: device to control
- *	@enabe: autoneg on/off
- *
- *	Set up the autonegotiation state according to whether we will be
- *	negotiating the state or forcing a speed.
- */
-static void et1310_phy_auto_neg(struct et131x_adapter *adapter, bool enable)
-{
-	u16 data;
-
-	et131x_mii_read(adapter, PHY_CONTROL, &data);
-	data &= ~0x1000;	/* Autonegotiation OFF */
-	if (enable)
-		data |= 0x1000;		/* Autonegotiation ON */
-	et131x_mii_write(adapter, PHY_CONTROL, data);
-}
-
-/**
- *	et1310_phy_duplex_mode	-	duplex control
- *	@adapter: device to control
- *	@duplex: duplex on/off
- *
- *	Set up the duplex state on the PHY
- */
-static void et1310_phy_duplex_mode(struct et131x_adapter *adapter, u16 duplex)
-{
-	u16 data;
-
-	et131x_mii_read(adapter, PHY_CONTROL, &data);
-	data &= ~0x100;		/* Set Half Duplex */
-	if (duplex == TRUEPHY_DUPLEX_FULL)
-		data |= 0x100;	/* Set Full Duplex */
-	et131x_mii_write(adapter, PHY_CONTROL, data);
-}
-
-/**
- *	et1310_phy_speed_select	-	speed control
- *	@adapter: device to control
- *	@duplex: duplex on/off
- *
- *	Set the speed of our PHY.
- */
-static void et1310_phy_speed_select(struct et131x_adapter *adapter, u16 speed)
-{
-	u16 data;
-	static const u16 bits[3] = {0x0000, 0x2000, 0x0040};
-
-	/* Read the PHY control register */
-	et131x_mii_read(adapter, PHY_CONTROL, &data);
-	/* Clear all Speed settings (Bits 6, 13) */
-	data &= ~0x2040;
-	/* Write back the new speed */
-	et131x_mii_write(adapter, PHY_CONTROL, data | bits[speed]);
-}
-
-/**
  *	et1310_phy_link_status	-	read link state
  *	@adapter: device to read
  *	@link_status: reported link state
@@ -450,122 +388,12 @@ void et1310_phy_access_mii_bit(struct et131x_adapter *adapter, u16 action,
 	}
 }
 
-void et1310_phy_advertise_1000BaseT(struct et131x_adapter *adapter,
-				  u16 duplex)
-{
-	u16 data;
-
-	/* Read the PHY 1000 Base-T Control Register */
-	et131x_mii_read(adapter, PHY_1000_CONTROL, &data);
-
-	/* Clear Bits 8,9 */
-	data &= ~0x0300;
-
-	switch (duplex) {
-	case TRUEPHY_ADV_DUPLEX_NONE:
-		/* Duplex already cleared, do nothing */
-		break;
-
-	case TRUEPHY_ADV_DUPLEX_FULL:
-		/* Set Bit 9 */
-		data |= 0x0200;
-		break;
-
-	case TRUEPHY_ADV_DUPLEX_HALF:
-		/* Set Bit 8 */
-		data |= 0x0100;
-		break;
-
-	case TRUEPHY_ADV_DUPLEX_BOTH:
-	default:
-		data |= 0x0300;
-		break;
-	}
-
-	/* Write back advertisement */
-	et131x_mii_write(adapter, PHY_1000_CONTROL, data);
-}
-
-static void et1310_phy_advertise_100BaseT(struct et131x_adapter *adapter,
-					  u16 duplex)
-{
-	u16 data;
-
-	/* Read the Autonegotiation Register (10/100) */
-	et131x_mii_read(adapter, PHY_AUTO_ADVERTISEMENT, &data);
-
-	/* Clear bits 7,8 */
-	data &= ~0x0180;
-
-	switch (duplex) {
-	case TRUEPHY_ADV_DUPLEX_NONE:
-		/* Duplex already cleared, do nothing */
-		break;
-
-	case TRUEPHY_ADV_DUPLEX_FULL:
-		/* Set Bit 8 */
-		data |= 0x0100;
-		break;
-
-	case TRUEPHY_ADV_DUPLEX_HALF:
-		/* Set Bit 7 */
-		data |= 0x0080;
-		break;
-
-	case TRUEPHY_ADV_DUPLEX_BOTH:
-	default:
-		/* Set Bits 7,8 */
-		data |= 0x0180;
-		break;
-	}
-
-	/* Write back advertisement */
-	et131x_mii_write(adapter, PHY_AUTO_ADVERTISEMENT, data);
-}
-
-static void et1310_phy_advertise_10BaseT(struct et131x_adapter *adapter,
-				u16 duplex)
-{
-	u16 data;
-
-	/* Read the Autonegotiation Register (10/100) */
-	et131x_mii_read(adapter, PHY_AUTO_ADVERTISEMENT, &data);
-
-	/* Clear bits 5,6 */
-	data &= ~0x0060;
-
-	switch (duplex) {
-	case TRUEPHY_ADV_DUPLEX_NONE:
-		/* Duplex already cleared, do nothing */
-		break;
-
-	case TRUEPHY_ADV_DUPLEX_FULL:
-		/* Set Bit 6 */
-		data |= 0x0040;
-		break;
-
-	case TRUEPHY_ADV_DUPLEX_HALF:
-		/* Set Bit 5 */
-		data |= 0x0020;
-		break;
-
-	case TRUEPHY_ADV_DUPLEX_BOTH:
-	default:
-		/* Set Bits 5,6 */
-		data |= 0x0060;
-		break;
-	}
-
-	/* Write back advertisement */
-	et131x_mii_write(adapter, PHY_AUTO_ADVERTISEMENT, data);
-}
-
 /**
  * et131x_xcvr_init - Init the phy if we are setting it into force mode
  * @adapter: pointer to our private adapter structure
  *
  */
-static void et131x_xcvr_init(struct et131x_adapter *adapter)
+void et131x_xcvr_init(struct et131x_adapter *adapter)
 {
 	u16 imr;
 	u16 isr;
@@ -607,132 +435,6 @@ static void et131x_xcvr_init(struct et131x_adapter *adapter)
 		et131x_mii_write(adapter, (u8) offsetof(struct mi_regs, lcr2),
 			lcr2);
 	}
-
-	/* Determine if we need to go into a force mode and set it */
-	if (adapter->ai_force_speed == 0 && adapter->ai_force_duplex == 0) {
-		if (adapter->wanted_flow == FLOW_TXONLY ||
-		    adapter->wanted_flow == FLOW_BOTH)
-			et1310_phy_access_mii_bit(adapter,
-					      TRUEPHY_BIT_SET, 4, 11, NULL);
-		else
-			et1310_phy_access_mii_bit(adapter,
-					      TRUEPHY_BIT_CLEAR, 4, 11, NULL);
-
-		if (adapter->wanted_flow == FLOW_BOTH)
-			et1310_phy_access_mii_bit(adapter,
-					      TRUEPHY_BIT_SET, 4, 10, NULL);
-		else
-			et1310_phy_access_mii_bit(adapter,
-					      TRUEPHY_BIT_CLEAR, 4, 10, NULL);
-
-		/* Set the phy to autonegotiation */
-		et1310_phy_auto_neg(adapter, true);
-
-		/* NOTE - Do we need this? */
-		et1310_phy_access_mii_bit(adapter, TRUEPHY_BIT_SET, 0, 9, NULL);
-		return;
-	}
-
-	et1310_phy_auto_neg(adapter, false);
-
-	/* Set to the correct force mode. */
-	if (adapter->ai_force_duplex != 1) {
-		if (adapter->wanted_flow == FLOW_TXONLY ||
-		    adapter->wanted_flow == FLOW_BOTH)
-			et1310_phy_access_mii_bit(adapter,
-				      TRUEPHY_BIT_SET, 4, 11, NULL);
-		else
-			et1310_phy_access_mii_bit(adapter,
-					      TRUEPHY_BIT_CLEAR, 4, 11, NULL);
-
-		if (adapter->wanted_flow == FLOW_BOTH)
-			et1310_phy_access_mii_bit(adapter,
-					      TRUEPHY_BIT_SET, 4, 10, NULL);
-		else
-			et1310_phy_access_mii_bit(adapter,
-					      TRUEPHY_BIT_CLEAR, 4, 10, NULL);
-	} else {
-		et1310_phy_access_mii_bit(adapter, TRUEPHY_BIT_CLEAR,
-					  4, 10, NULL);
-		et1310_phy_access_mii_bit(adapter, TRUEPHY_BIT_CLEAR,
-					  4, 11, NULL);
-	}
-	et1310_phy_power_down(adapter, 1);
-	switch (adapter->ai_force_speed) {
-	case 10:
-		/* First we need to turn off all other advertisement */
-		et1310_phy_advertise_1000BaseT(adapter, TRUEPHY_ADV_DUPLEX_NONE);
-		et1310_phy_advertise_100BaseT(adapter, TRUEPHY_ADV_DUPLEX_NONE);
-		if (adapter->ai_force_duplex == 1) {
-			/* Set our advertise values accordingly */
-			et1310_phy_advertise_10BaseT(adapter,
-						TRUEPHY_ADV_DUPLEX_HALF);
-		} else if (adapter->ai_force_duplex == 2) {
-			/* Set our advertise values accordingly */
-			et1310_phy_advertise_10BaseT(adapter,
-						TRUEPHY_ADV_DUPLEX_FULL);
-		} else {
-			/* Disable autoneg */
-			et1310_phy_auto_neg(adapter, false);
-			/* Disable rest of the advertisements */
-			et1310_phy_advertise_10BaseT(adapter,
-					TRUEPHY_ADV_DUPLEX_NONE);
-			/* Force 10 Mbps */
-			et1310_phy_speed_select(adapter, TRUEPHY_SPEED_10MBPS);
-			/* Force Full duplex */
-			et1310_phy_duplex_mode(adapter, TRUEPHY_DUPLEX_FULL);
-		}
-		break;
-	case 100:
-		/* first we need to turn off all other advertisement */
-		et1310_phy_advertise_1000BaseT(adapter, TRUEPHY_ADV_DUPLEX_NONE);
-		et1310_phy_advertise_10BaseT(adapter, TRUEPHY_ADV_DUPLEX_NONE);
-		if (adapter->ai_force_duplex == 1) {
-			/* Set our advertise values accordingly */
-			et1310_phy_advertise_100BaseT(adapter,
-						TRUEPHY_ADV_DUPLEX_HALF);
-			/* Set speed */
-			et1310_phy_speed_select(adapter, TRUEPHY_SPEED_100MBPS);
-		} else if (adapter->ai_force_duplex == 2) {
-			/* Set our advertise values accordingly */
-			et1310_phy_advertise_100BaseT(adapter,
-						TRUEPHY_ADV_DUPLEX_FULL);
-		} else {
-			/* Disable autoneg */
-			et1310_phy_auto_neg(adapter, false);
-			/* Disable other advertisement */
-			et1310_phy_advertise_100BaseT(adapter,
-						TRUEPHY_ADV_DUPLEX_NONE);
-			/* Force 100 Mbps */
-			et1310_phy_speed_select(adapter, TRUEPHY_SPEED_100MBPS);
-			/* Force Full duplex */
-			et1310_phy_duplex_mode(adapter, TRUEPHY_DUPLEX_FULL);
-		}
-		break;
-	case 1000:
-		/* first we need to turn off all other advertisement */
-		et1310_phy_advertise_100BaseT(adapter, TRUEPHY_ADV_DUPLEX_NONE);
-		et1310_phy_advertise_10BaseT(adapter, TRUEPHY_ADV_DUPLEX_NONE);
-		/* set our advertise values accordingly */
-		et1310_phy_advertise_1000BaseT(adapter, TRUEPHY_ADV_DUPLEX_FULL);
-		break;
-	}
-	et1310_phy_power_down(adapter, 0);
-}
-
-/**
- * et131x_setphy_normal - Set PHY for normal operation.
- * @adapter: pointer to our private adapter structure
- *
- * Used by Power Management to force the PHY into 10 Base T half-duplex mode,
- * when going to D3 in WOL mode. Also used during initialization to set the
- * PHY for normal operation.
- */
-void et131x_setphy_normal(struct et131x_adapter *adapter)
-{
-	/* Make sure the PHY is powered up */
-	et1310_phy_power_down(adapter, 0);
-	et131x_xcvr_init(adapter);
 }
 
 void et131x_mii_check(struct et131x_adapter *adapter,
@@ -847,116 +549,3 @@ void et131x_mii_check(struct et131x_adapter *adapter,
 	}
 }
 
-/*
- * The routines which follow provide low-level access to the PHY, and are used
- * primarily by the routines above (although there are a few places elsewhere
- * in the driver where this level of access is required).
- */
-static const u16 config_phy[25][2] = {
-	/* Reg	 Value		Register */
-	/* Addr                         */
-	{0x880B, 0x0926},	/* AfeIfCreg4B1000Msbs */
-	{0x880C, 0x0926},	/* AfeIfCreg4B100Msbs */
-	{0x880D, 0x0926},	/* AfeIfCreg4B10Msbs */
-
-	{0x880E, 0xB4D3},	/* AfeIfCreg4B1000Lsbs */
-	{0x880F, 0xB4D3},	/* AfeIfCreg4B100Lsbs */
-	{0x8810, 0xB4D3},	/* AfeIfCreg4B10Lsbs */
-
-	{0x8805, 0xB03E},	/* AfeIfCreg3B1000Msbs */
-	{0x8806, 0xB03E},	/* AfeIfCreg3B100Msbs */
-	{0x8807, 0xFF00},	/* AfeIfCreg3B10Msbs */
-
-	{0x8808, 0xE090},	/* AfeIfCreg3B1000Lsbs */
-	{0x8809, 0xE110},	/* AfeIfCreg3B100Lsbs */
-	{0x880A, 0x0000},	/* AfeIfCreg3B10Lsbs */
-
-	{0x300D, 1},		/* DisableNorm */
-
-	{0x280C, 0x0180},	/* LinkHoldEnd */
-
-	{0x1C21, 0x0002},	/* AlphaM */
-
-	{0x3821, 6},		/* FfeLkgTx0 */
-	{0x381D, 1},		/* FfeLkg1g4 */
-	{0x381E, 1},		/* FfeLkg1g5 */
-	{0x381F, 1},		/* FfeLkg1g6 */
-	{0x3820, 1},		/* FfeLkg1g7 */
-
-	{0x8402, 0x01F0},	/* Btinact */
-	{0x800E, 20},		/* LftrainTime */
-	{0x800F, 24},		/* DvguardTime */
-	{0x8010, 46},		/* IdlguardTime */
-
-	{0, 0}
-};
-
-/* condensed version of the phy initialization routine */
-void et1310_phy_init(struct et131x_adapter *adapter)
-{
-	u16 data, index;
-
-	/* get the identity (again ?) */
-	et131x_mii_read(adapter, PHY_ID_1, &data);
-	et131x_mii_read(adapter, PHY_ID_2, &data);
-
-	/* what does this do/achieve ? */
-	/* should read 0002 */
-	et131x_mii_read(adapter, PHY_MPHY_CONTROL_REG, &data);
-	et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG,	0x0006);
-
-	/* read modem register 0402, should I do something with the return
-	   data ? */
-	et131x_mii_write(adapter, PHY_INDEX_REG, 0x0402);
-	et131x_mii_read(adapter, PHY_DATA_REG, &data);
-
-	/* what does this do/achieve ? */
-	et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG, 0x0002);
-
-	/* get the identity (again ?) */
-	et131x_mii_read(adapter, PHY_ID_1, &data);
-	et131x_mii_read(adapter, PHY_ID_2, &data);
-
-	/* what does this achieve ? */
-	/* should read 0002 */
-	et131x_mii_read(adapter, PHY_MPHY_CONTROL_REG, &data);
-	et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG, 0x0006);
-
-	/* read modem register 0402, should I do something with
-	   the return data? */
-	et131x_mii_write(adapter, PHY_INDEX_REG, 0x0402);
-	et131x_mii_read(adapter, PHY_DATA_REG, &data);
-
-	et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG, 0x0002);
-
-	/* what does this achieve (should return 0x1040) */
-	et131x_mii_read(adapter, PHY_CONTROL, &data);
-	/* should read 0002 */
-	et131x_mii_read(adapter, PHY_MPHY_CONTROL_REG, &data);
-	et131x_mii_write(adapter, PHY_CONTROL, 0x1840);
-
-	et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG, 0x0007);
-
-	/* here the writing of the array starts.... */
-	index = 0;
-	while (config_phy[index][0] != 0x0000) {
-		/* write value */
-		et131x_mii_write(adapter, PHY_INDEX_REG, config_phy[index][0]);
-		et131x_mii_write(adapter, PHY_DATA_REG, config_phy[index][1]);
-
-		/* read it back */
-		et131x_mii_write(adapter, PHY_INDEX_REG, config_phy[index][0]);
-		et131x_mii_read(adapter, PHY_DATA_REG, &data);
-
-		/* do a check on the value read back ? */
-		index++;
-	}
-	/* here the writing of the array ends... */
-
-	et131x_mii_read(adapter, PHY_CONTROL, &data);		/* 0x1840 */
-	/* should read 0007 */
-	et131x_mii_read(adapter, PHY_MPHY_CONTROL_REG, &data);
-	et131x_mii_write(adapter, PHY_CONTROL, 0x1040);
-	et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG, 0x0002);
-}
-
diff --git a/drivers/staging/et131x/et1310_pm.c b/drivers/staging/et131x/et1310_pm.c
index 5ebf064..b20d5d6 100644
--- a/drivers/staging/et131x/et1310_pm.c
+++ b/drivers/staging/et131x/et1310_pm.c
@@ -116,8 +116,12 @@ void et1310_enable_phy_coma(struct et131x_adapter *adapter)
 	/* Save the GbE PHY speed and duplex modes. Need to restore this
 	 * when cable is plugged back in
 	 */
-	adapter->pdown_speed = adapter->ai_force_speed;
-	adapter->pdown_duplex = adapter->ai_force_duplex;
+	/*
+	 * TODO - when PM is re-enabled, check if we need to
+	 * perform a similar task as this -
+	 * adapter->pdown_speed = adapter->ai_force_speed;
+	 * adapter->pdown_duplex = adapter->ai_force_duplex;
+	 */
 
 	/* Stop sending packets. */
 	spin_lock_irqsave(&adapter->send_hw_lock, flags);
@@ -153,8 +157,11 @@ void et1310_disable_phy_coma(struct et131x_adapter *adapter)
 	/* Restore the GbE PHY speed and duplex modes;
 	 * Reset JAGCore; re-configure and initialize JAGCore and gigE PHY
 	 */
-	adapter->ai_force_speed = adapter->pdown_speed;
-	adapter->ai_force_duplex = adapter->pdown_duplex;
+	/* TODO - when PM is re-enabled, check if we need to
+	 * perform a similar task as this -
+	 * adapter->ai_force_speed = adapter->pdown_speed;
+	 * adapter->ai_force_duplex = adapter->pdown_duplex;
+	 */
 
 	/* Re-initialize the send structures */
 	et131x_init_send(adapter);
diff --git a/drivers/staging/et131x/et131x.h b/drivers/staging/et131x/et131x.h
index 763396a..f52fa18 100644
--- a/drivers/staging/et131x/et131x.h
+++ b/drivers/staging/et131x/et131x.h
@@ -89,17 +89,12 @@ void et1310_enable_phy_coma(struct et131x_adapter *adapter);
 void et1310_disable_phy_coma(struct et131x_adapter *adapter);
 
 /* et1310_phy.c */
-void et1310_phy_init(struct et131x_adapter *adapter);
-void et1310_phy_reset(struct et131x_adapter *adapter);
 void et1310_phy_power_down(struct et131x_adapter *adapter, bool down);
-void et1310_phy_advertise_1000BaseT(struct et131x_adapter *adapter,
-				    u16 duplex);
 void et1310_phy_access_mii_bit(struct et131x_adapter *adapter,
 			       u16 action,
 			       u16 regnum, u16 bitnum, u8 *value);
 
-int et131x_xcvr_find(struct et131x_adapter *adapter);
-void et131x_setphy_normal(struct et131x_adapter *adapter);
+void et131x_xcvr_init(struct et131x_adapter *adapter);
 
 /* static inline function does not work because et131x_adapter is not always
  * defined
diff --git a/drivers/staging/et131x/et131x_initpci.c b/drivers/staging/et131x/et131x_initpci.c
index 66cf1ce..6ffebfa 100644
--- a/drivers/staging/et131x/et131x_initpci.c
+++ b/drivers/staging/et131x/et131x_initpci.c
@@ -137,7 +137,6 @@ void et131x_hwaddr_init(struct et131x_adapter *adapter)
 	}
 }
 
-
 /**
  * et131x_pci_init	 - initial PCI setup
  * @adapter: pointer to our private adapter structure
@@ -146,7 +145,6 @@ void et131x_hwaddr_init(struct et131x_adapter *adapter)
  * Perform the initial setup of PCI registers and if possible initialise
  * the MAC address. At this point the I/O registers have yet to be mapped
  */
-
 static int et131x_pci_init(struct et131x_adapter *adapter,
 						struct pci_dev *pdev)
 {
@@ -347,28 +345,8 @@ void et131x_adapter_setup(struct et131x_adapter *adapter)
 
 	et1310_config_macstat_regs(adapter);
 
-	/* Prepare the TRUEPHY library. */
-	et1310_phy_init(adapter);
-
-	/* Reset the phy now so changes take place */
-	et1310_phy_reset(adapter);
-
-	/* Power down PHY */
-	et1310_phy_power_down(adapter, 1);
-
-	/*
-	 * We need to turn off 1000 base half dulplex, the mac does not
-	 * support it. For the 10/100 part, turn off all gig advertisement
-	 */
-	if (adapter->pdev->device != ET131X_PCI_DEVICE_ID_FAST)
-		et1310_phy_advertise_1000BaseT(adapter, TRUEPHY_ADV_DUPLEX_FULL);
-	else
-		et1310_phy_advertise_1000BaseT(adapter, TRUEPHY_ADV_DUPLEX_NONE);
-
-	/* Power up PHY */
 	et1310_phy_power_down(adapter, 0);
-
-	et131x_setphy_normal(adapter);
+	et131x_xcvr_init(adapter);
 }
 
 /**
@@ -547,8 +525,6 @@ static struct et131x_adapter *et131x_adapter_init(struct net_device *netdev,
 		struct pci_dev *pdev)
 {
 	static const u8 default_mac[] = { 0x00, 0x05, 0x3d, 0x00, 0x02, 0x00 };
-	static const u8 duplex[] = { 0, 1, 2, 1, 2, 2 };
-	static const u16 speed[] = { 0, 10, 10, 100, 100, 1000 };
 
 	struct et131x_adapter *adapter;
 
@@ -571,15 +547,11 @@ static struct et131x_adapter *et131x_adapter_init(struct net_device *netdev,
 	spin_lock_init(&adapter->fbr_lock);
 	spin_lock_init(&adapter->phy_lock);
 
-	adapter->speed_duplex = 0; /* Auto Speed Auto Duplex */
 	adapter->registry_jumbo_packet = 1514;	/* 1514-9216 */
 
 	/* Set the MAC address to a default */
 	memcpy(adapter->addr, default_mac, ETH_ALEN);
 
-	adapter->ai_force_speed = speed[adapter->speed_duplex];
-	adapter->ai_force_duplex = duplex[adapter->speed_duplex];	/* Auto FDX */
-
 	return adapter;
 }
 
-- 
1.7.6


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

end of thread, other threads:[~2011-08-30 11:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-30 11:47 [PATCH 1/3] staging: et131x: converting et131x_ioctl to use phy_mii_ioctl Mark Einon
2011-08-30 11:47 ` [PATCH 2/3] staging: et131x: Remove xcvr_addr and et131x_xcvr_find Mark Einon
2011-08-30 11:47 ` [PATCH 3/3] staging: et131x: Remove redundant phy code Mark Einon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox