netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net 0/2] r8152: couldn't read OCP_SRAM_DATA
@ 2015-01-19  9:02 Hayes Wang
  2015-01-19  9:02 ` [PATCH net 1/2] r8152: remove generic_ocp_read before writing Hayes Wang
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Hayes Wang @ 2015-01-19  9:02 UTC (permalink / raw)
  To: netdev; +Cc: nic_swsd, linux-kernel, linux-usb, Hayes Wang

Read OCP_SRAM_DATA would read additional bytes and may let
the hw abnormal.

Hayes Wang (2):
  r8152: remove generic_ocp_read before writing
  r8152: remove sram_read

 drivers/net/usb/r8152.c | 30 ++++++------------------------
 1 file changed, 6 insertions(+), 24 deletions(-)

-- 
2.1.0

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

* [PATCH net 1/2] r8152: remove generic_ocp_read before writing
  2015-01-19  9:02 [PATCH net 0/2] r8152: couldn't read OCP_SRAM_DATA Hayes Wang
@ 2015-01-19  9:02 ` Hayes Wang
  2015-01-19  9:02 ` [PATCH net 2/2] r8152: remove sram_read Hayes Wang
  2015-01-19 21:18 ` [PATCH net 0/2] r8152: couldn't read OCP_SRAM_DATA David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Hayes Wang @ 2015-01-19  9:02 UTC (permalink / raw)
  To: netdev; +Cc: nic_swsd, linux-kernel, linux-usb, Hayes Wang

For ocp_write_word() and ocp_write_byte(), there is a generic_ocp_read()
which is used to read the whole 4 byte data, keep the unchanged bytes,
and modify the expected bytes. However, the "byen" could be used to
determine which bytes of the 4 bytes to write, so the action could be
removed.

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

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 57ec23e..0aa83fb 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -833,9 +833,6 @@ static void ocp_write_word(struct r8152 *tp, u16 type, u16 index, u32 data)
 		index &= ~3;
 	}
 
-	generic_ocp_read(tp, index, sizeof(tmp), &tmp, type);
-
-	data |= __le32_to_cpu(tmp) & ~mask;
 	tmp = __cpu_to_le32(data);
 
 	generic_ocp_write(tp, index, byen, sizeof(tmp), &tmp, type);
@@ -874,9 +871,6 @@ static void ocp_write_byte(struct r8152 *tp, u16 type, u16 index, u32 data)
 		index &= ~3;
 	}
 
-	generic_ocp_read(tp, index, sizeof(tmp), &tmp, type);
-
-	data |= __le32_to_cpu(tmp) & ~mask;
 	tmp = __cpu_to_le32(data);
 
 	generic_ocp_write(tp, index, byen, sizeof(tmp), &tmp, type);
-- 
2.1.0

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

* [PATCH net 2/2] r8152: remove sram_read
  2015-01-19  9:02 [PATCH net 0/2] r8152: couldn't read OCP_SRAM_DATA Hayes Wang
  2015-01-19  9:02 ` [PATCH net 1/2] r8152: remove generic_ocp_read before writing Hayes Wang
@ 2015-01-19  9:02 ` Hayes Wang
  2015-01-19 21:18 ` [PATCH net 0/2] r8152: couldn't read OCP_SRAM_DATA David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Hayes Wang @ 2015-01-19  9:02 UTC (permalink / raw)
  To: netdev; +Cc: nic_swsd, linux-kernel, linux-usb, Hayes Wang

Read OCP register 0xa43a~0xa43b would clear some flags which the hw
would use, and it may let the device lost. However, the unit of
reading is 4 bytes. That is, it would read 0xa438~0xa43b when calling
sram_read() to read OCP_SRAM_DATA.

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

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 0aa83fb..bf405f1 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -920,12 +920,6 @@ static void sram_write(struct r8152 *tp, u16 addr, u16 data)
 	ocp_reg_write(tp, OCP_SRAM_DATA, data);
 }
 
-static u16 sram_read(struct r8152 *tp, u16 addr)
-{
-	ocp_reg_write(tp, OCP_SRAM_ADDR, addr);
-	return ocp_reg_read(tp, OCP_SRAM_DATA);
-}
-
 static int read_mii_word(struct net_device *netdev, int phy_id, int reg)
 {
 	struct r8152 *tp = netdev_priv(netdev);
@@ -2512,24 +2506,18 @@ static void r8153_hw_phy_cfg(struct r8152 *tp)
 	data = ocp_reg_read(tp, OCP_POWER_CFG);
 	data |= EN_10M_PLLOFF;
 	ocp_reg_write(tp, OCP_POWER_CFG, data);
-	data = sram_read(tp, SRAM_IMPEDANCE);
-	data &= ~RX_DRIVING_MASK;
-	sram_write(tp, SRAM_IMPEDANCE, data);
+	sram_write(tp, SRAM_IMPEDANCE, 0x0b13);
 
 	ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_PHY_PWR);
 	ocp_data |= PFM_PWM_SWITCH;
 	ocp_write_word(tp, MCU_TYPE_PLA, PLA_PHY_PWR, ocp_data);
 
-	data = sram_read(tp, SRAM_LPF_CFG);
-	data |= LPF_AUTO_TUNE;
-	sram_write(tp, SRAM_LPF_CFG, data);
+	/* Enable LPF corner auto tune */
+	sram_write(tp, SRAM_LPF_CFG, 0xf70f);
 
-	data = sram_read(tp, SRAM_10M_AMP1);
-	data |= GDAC_IB_UPALL;
-	sram_write(tp, SRAM_10M_AMP1, data);
-	data = sram_read(tp, SRAM_10M_AMP2);
-	data |= AMP_DN;
-	sram_write(tp, SRAM_10M_AMP2, data);
+	/* Adjust 10M Amplitude */
+	sram_write(tp, SRAM_10M_AMP1, 0x00af);
+	sram_write(tp, SRAM_10M_AMP2, 0x0208);
 
 	set_bit(PHY_RESET, &tp->flags);
 }
-- 
2.1.0

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

* Re: [PATCH net 0/2] r8152: couldn't read OCP_SRAM_DATA
  2015-01-19  9:02 [PATCH net 0/2] r8152: couldn't read OCP_SRAM_DATA Hayes Wang
  2015-01-19  9:02 ` [PATCH net 1/2] r8152: remove generic_ocp_read before writing Hayes Wang
  2015-01-19  9:02 ` [PATCH net 2/2] r8152: remove sram_read Hayes Wang
@ 2015-01-19 21:18 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2015-01-19 21:18 UTC (permalink / raw)
  To: hayeswang; +Cc: netdev, nic_swsd, linux-kernel, linux-usb

From: Hayes Wang <hayeswang@realtek.com>
Date: Mon, 19 Jan 2015 17:02:44 +0800

> Read OCP_SRAM_DATA would read additional bytes and may let
> the hw abnormal.

Series applied, thanks.

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

end of thread, other threads:[~2015-01-19 21:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-19  9:02 [PATCH net 0/2] r8152: couldn't read OCP_SRAM_DATA Hayes Wang
2015-01-19  9:02 ` [PATCH net 1/2] r8152: remove generic_ocp_read before writing Hayes Wang
2015-01-19  9:02 ` [PATCH net 2/2] r8152: remove sram_read Hayes Wang
2015-01-19 21:18 ` [PATCH net 0/2] r8152: couldn't read OCP_SRAM_DATA David Miller

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).