Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1662164

[PATCH net-next 01/11] r8152: add r8153_phy_status function

From Hayes Wang <hayeswang@realtek.com>
Newsgroups linux.kernel
Subject [PATCH net-next 01/11] r8152: add r8153_phy_status function
Date 2017-06-09 11:20 +0200
Message-ID <tQofh-88B-47@gated-at.bofh.it> (permalink)
References <tQoff-88B-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Use r8153_phy_status() to check phy status of RTL8153.

Signed-off-by: Hayes Wang <hayeswang@realtek.com>
---
 drivers/net/usb/r8152.c | 37 +++++++++++++++++++++++++------------
 1 file changed, 25 insertions(+), 12 deletions(-)

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index fd31fab..9239dfb 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -394,6 +394,7 @@
 
 /* OCP_PHY_STATUS */
 #define PHY_STAT_MASK		0x0007
+#define PHY_STAT_EXT_INIT	2
 #define PHY_STAT_LAN_ON		3
 #define PHY_STAT_PWRDN		5
 
@@ -2452,6 +2453,28 @@ static void r8153_u2p3en(struct r8152 *tp, bool enable)
 	ocp_write_word(tp, MCU_TYPE_USB, USB_U2P3_CTRL, ocp_data);
 }
 
+static u16 r8153_phy_status(struct r8152 *tp, u16 desired)
+{
+	u16 data;
+	int i;
+
+	for (i = 0; i < 500; i++) {
+		data = ocp_reg_read(tp, OCP_PHY_STATUS);
+		data &= PHY_STAT_MASK;
+		if (desired) {
+			if (data == desired)
+				break;
+		} else if (data == PHY_STAT_LAN_ON || data == PHY_STAT_PWRDN ||
+			   data == PHY_STAT_EXT_INIT) {
+			break;
+		}
+
+		msleep(20);
+	}
+
+	return data;
+}
+
 static void r8153_power_cut_en(struct r8152 *tp, bool enable)
 {
 	u32 ocp_data;
@@ -3420,12 +3443,7 @@ static void r8153_init(struct r8152 *tp)
 		msleep(20);
 	}
 
-	for (i = 0; i < 500; i++) {
-		ocp_data = ocp_reg_read(tp, OCP_PHY_STATUS) & PHY_STAT_MASK;
-		if (ocp_data == PHY_STAT_LAN_ON || ocp_data == PHY_STAT_PWRDN)
-			break;
-		msleep(20);
-	}
+	data = r8153_phy_status(tp, 0);
 
 	if (tp->version == RTL_VER_03 || tp->version == RTL_VER_04 ||
 	    tp->version == RTL_VER_05)
@@ -3437,12 +3455,7 @@ static void r8153_init(struct r8152 *tp)
 		r8152_mdio_write(tp, MII_BMCR, data);
 	}
 
-	for (i = 0; i < 500; i++) {
-		ocp_data = ocp_reg_read(tp, OCP_PHY_STATUS) & PHY_STAT_MASK;
-		if (ocp_data == PHY_STAT_LAN_ON)
-			break;
-		msleep(20);
-	}
+	data = r8153_phy_status(tp, PHY_STAT_LAN_ON);
 
 	usb_disable_lpm(tp->udev);
 	r8153_u2p3en(tp, false);
-- 
2.7.4

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH net-next 00/11] r8152: minor adjustment Hayes Wang <hayeswang@realtek.com> - 2017-06-09 11:20 +0200
  [PATCH net-next 05/11] r8152: adjust rtl8153_runtime_enable function Hayes Wang <hayeswang@realtek.com> - 2017-06-09 11:20 +0200
  [PATCH net-next 11/11] r8152: replace napi_complete with napi_complete_done Hayes Wang <hayeswang@realtek.com> - 2017-06-09 11:20 +0200
  [PATCH net-next 03/11] r8152: adjust the settings about MAC clock speed down for RTL8153 Hayes Wang <hayeswang@realtek.com> - 2017-06-09 11:20 +0200
  [PATCH net-next 10/11] r8152: avoid rx queue more than 1000 packets Hayes Wang <hayeswang@realtek.com> - 2017-06-09 11:20 +0200
  [PATCH net-next 04/11] r8152: move the setting of rx aggregation Hayes Wang <hayeswang@realtek.com> - 2017-06-09 11:20 +0200
  [PATCH net-next 02/11] r8152: adjust lpm settings for RTL8153 Hayes Wang <hayeswang@realtek.com> - 2017-06-09 11:20 +0200
  [PATCH net-next 07/11] r8152: move the default coalesce setting for RTL8153 Hayes Wang <hayeswang@realtek.com> - 2017-06-09 11:20 +0200
  [PATCH net-next 01/11] r8152: add r8153_phy_status function Hayes Wang <hayeswang@realtek.com> - 2017-06-09 11:20 +0200
  Re: [PATCH net-next 00/11] r8152: minor adjustment David Miller <davem@davemloft.net> - 2017-06-09 21:40 +0200

csiph-web