netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2 0/3] net-next: Broadcom PHY driver cleanup
@ 2017-01-25 20:00 Rafał Miłecki
  2017-01-25 20:00 ` [PATCH V2 1/3] net: phy: broadcom: use auxctl reading helper in BCM54612E code Rafał Miłecki
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Rafał Miłecki @ 2017-01-25 20:00 UTC (permalink / raw)
  To: David S . Miller, Florian Fainelli
  Cc: Xo Wang, Joel Stanley, Jon Mason, Jaedon Shin, netdev,
	Rafał Miłecki

From: Rafał Miłecki <rafal@milecki.pl>

I will probably need to use broadcom.ko for PHY connected to interface
of bgmac supported device so I started looking at it willing to
understand it better.

I found AUXCTL part of the driver / lib a bit confusing and hard to read
so I'm trying to clean it up a bit. I hope this patchset makes following
AUXCTL operations much easier making it clear which defines are for
registers and which for values.

There is no functional change in this pachset.

Rafał Miłecki (3):
  net: phy: broadcom: use auxctl reading helper in BCM54612E code
  net: phy: broadcom: drop duplicated define for RGMII SKEW delay
  net: phy: bcm-phy-lib: clean up remaining AUXCTL register defines

 drivers/net/phy/broadcom.c |  8 +++-----
 include/linux/brcmphy.h    | 16 +++++++---------
 2 files changed, 10 insertions(+), 14 deletions(-)

-- 
2.11.0

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

* [PATCH V2 1/3] net: phy: broadcom: use auxctl reading helper in BCM54612E code
  2017-01-25 20:00 [PATCH V2 0/3] net-next: Broadcom PHY driver cleanup Rafał Miłecki
@ 2017-01-25 20:00 ` Rafał Miłecki
  2017-01-25 20:00 ` [PATCH V2 2/3] net: phy: broadcom: drop duplicated define for RGMII SKEW delay Rafał Miłecki
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Rafał Miłecki @ 2017-01-25 20:00 UTC (permalink / raw)
  To: David S . Miller, Florian Fainelli
  Cc: Xo Wang, Joel Stanley, Jon Mason, Jaedon Shin, netdev,
	Rafał Miłecki

From: Rafał Miłecki <rafal@milecki.pl>

Starting with commit 5b4e29005123 ("net: phy: broadcom: add
bcm54xx_auxctl_read") we have a reading helper so use it and avoid code
duplication.
It also means we don't need MII_BCM54XX_AUXCTL_SHDWSEL_MISC define as
it's the same as MII_BCM54XX_AUXCTL_SHDWSEL_MISC just for reading needs
(same value shifted by 12 bits).

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/phy/broadcom.c | 6 ++----
 include/linux/brcmphy.h    | 1 -
 2 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/net/phy/broadcom.c b/drivers/net/phy/broadcom.c
index 4223e35490b0..25c6e6cea2dc 100644
--- a/drivers/net/phy/broadcom.c
+++ b/drivers/net/phy/broadcom.c
@@ -395,10 +395,8 @@ static int bcm54612e_config_aneg(struct phy_device *phydev)
 	    (phydev->interface != PHY_INTERFACE_MODE_RGMII_RXID)) {
 		u16 reg;
 
-		/* Errata: reads require filling in the write selector field */
-		bcm54xx_auxctl_write(phydev, MII_BCM54XX_AUXCTL_SHDWSEL_MISC,
-				     MII_BCM54XX_AUXCTL_MISC_RDSEL_MISC);
-		reg = phy_read(phydev, MII_BCM54XX_AUX_CTL);
+		reg = bcm54xx_auxctl_read(phydev,
+					  MII_BCM54XX_AUXCTL_SHDWSEL_MISC);
 		/* Disable RXD to RXC delay (default set) */
 		reg &= ~MII_BCM54XX_AUXCTL_MISC_RXD_RXC_SKEW;
 		/* Clear shadow selector field */
diff --git a/include/linux/brcmphy.h b/include/linux/brcmphy.h
index 295fb3e73de5..34e61004b9dc 100644
--- a/include/linux/brcmphy.h
+++ b/include/linux/brcmphy.h
@@ -111,7 +111,6 @@
 #define MII_BCM54XX_AUXCTL_MISC_WREN	0x8000
 #define MII_BCM54XX_AUXCTL_MISC_RXD_RXC_SKEW	0x0100
 #define MII_BCM54XX_AUXCTL_MISC_FORCE_AMDIX	0x0200
-#define MII_BCM54XX_AUXCTL_MISC_RDSEL_MISC	0x7000
 #define MII_BCM54XX_AUXCTL_SHDWSEL_MISC	0x0007
 #define MII_BCM54XX_AUXCTL_SHDWSEL_READ_SHIFT	12
 #define MII_BCM54XX_AUXCTL_SHDWSEL_MISC_RGMII_SKEW_EN	(1 << 8)
-- 
2.11.0

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

* [PATCH V2 2/3] net: phy: broadcom: drop duplicated define for RGMII SKEW delay
  2017-01-25 20:00 [PATCH V2 0/3] net-next: Broadcom PHY driver cleanup Rafał Miłecki
  2017-01-25 20:00 ` [PATCH V2 1/3] net: phy: broadcom: use auxctl reading helper in BCM54612E code Rafał Miłecki
@ 2017-01-25 20:00 ` Rafał Miłecki
  2017-01-25 20:34   ` Florian Fainelli
  2017-01-25 20:00 ` [PATCH V2 3/3] net: phy: bcm-phy-lib: clean up remaining AUXCTL register defines Rafał Miłecki
  2017-01-26  4:14 ` [PATCH V2 0/3] net-next: Broadcom PHY driver cleanup David Miller
  3 siblings, 1 reply; 7+ messages in thread
From: Rafał Miłecki @ 2017-01-25 20:00 UTC (permalink / raw)
  To: David S . Miller, Florian Fainelli
  Cc: Xo Wang, Joel Stanley, Jon Mason, Jaedon Shin, netdev,
	Rafał Miłecki

From: Rafał Miłecki <rafal@milecki.pl>

We had two defines for the same bit (both were used with the
MII_BCM54XX_AUXCTL_SHDWSEL_MISC register).

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
---
V2: Drop the other define to match datasheet. Thanks Florian.
---
 drivers/net/phy/broadcom.c | 2 +-
 include/linux/brcmphy.h    | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/phy/broadcom.c b/drivers/net/phy/broadcom.c
index 25c6e6cea2dc..97d1c057c0a1 100644
--- a/drivers/net/phy/broadcom.c
+++ b/drivers/net/phy/broadcom.c
@@ -398,7 +398,7 @@ static int bcm54612e_config_aneg(struct phy_device *phydev)
 		reg = bcm54xx_auxctl_read(phydev,
 					  MII_BCM54XX_AUXCTL_SHDWSEL_MISC);
 		/* Disable RXD to RXC delay (default set) */
-		reg &= ~MII_BCM54XX_AUXCTL_MISC_RXD_RXC_SKEW;
+		reg &= ~MII_BCM54XX_AUXCTL_SHDWSEL_MISC_RGMII_SKEW_EN;
 		/* Clear shadow selector field */
 		reg &= ~MII_BCM54XX_AUXCTL_SHDWSEL_MASK;
 		bcm54xx_auxctl_write(phydev, MII_BCM54XX_AUXCTL_SHDWSEL_MISC,
diff --git a/include/linux/brcmphy.h b/include/linux/brcmphy.h
index 34e61004b9dc..f9cb73df127e 100644
--- a/include/linux/brcmphy.h
+++ b/include/linux/brcmphy.h
@@ -109,7 +109,6 @@
 #define MII_BCM54XX_AUXCTL_ACTL_SMDSP_ENA	0x0800
 
 #define MII_BCM54XX_AUXCTL_MISC_WREN	0x8000
-#define MII_BCM54XX_AUXCTL_MISC_RXD_RXC_SKEW	0x0100
 #define MII_BCM54XX_AUXCTL_MISC_FORCE_AMDIX	0x0200
 #define MII_BCM54XX_AUXCTL_SHDWSEL_MISC	0x0007
 #define MII_BCM54XX_AUXCTL_SHDWSEL_READ_SHIFT	12
-- 
2.11.0

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

* [PATCH V2 3/3] net: phy: bcm-phy-lib: clean up remaining AUXCTL register defines
  2017-01-25 20:00 [PATCH V2 0/3] net-next: Broadcom PHY driver cleanup Rafał Miłecki
  2017-01-25 20:00 ` [PATCH V2 1/3] net: phy: broadcom: use auxctl reading helper in BCM54612E code Rafał Miłecki
  2017-01-25 20:00 ` [PATCH V2 2/3] net: phy: broadcom: drop duplicated define for RGMII SKEW delay Rafał Miłecki
@ 2017-01-25 20:00 ` Rafał Miłecki
  2017-01-25 20:35   ` Florian Fainelli
  2017-01-26  4:14 ` [PATCH V2 0/3] net-next: Broadcom PHY driver cleanup David Miller
  3 siblings, 1 reply; 7+ messages in thread
From: Rafał Miłecki @ 2017-01-25 20:00 UTC (permalink / raw)
  To: David S . Miller, Florian Fainelli
  Cc: Xo Wang, Joel Stanley, Jon Mason, Jaedon Shin, netdev,
	Rafał Miłecki

From: Rafał Miłecki <rafal@milecki.pl>

1) Use 0x%02x format for register number. This follows some other
   defines and makes it easier to distinct register from values.
2) Put register define above values and sort the values. It makes
   reading header code easier.
3) Use 0x%04x format for all values. It's about consistency with other
   values (and most of the header) not a personal preference.
4) Separate define for reading shift value with an extre empty line.
   It's user for all AUXCTL registers in a bcm54xx_auxctl_read.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
---
V2: Don't drop SHDWSEL_ as it seems to be used in datasheet. Thanks Florian.
---
 include/linux/brcmphy.h | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/include/linux/brcmphy.h b/include/linux/brcmphy.h
index f9cb73df127e..cf93f1399d3e 100644
--- a/include/linux/brcmphy.h
+++ b/include/linux/brcmphy.h
@@ -104,17 +104,17 @@
 /*
  * AUXILIARY CONTROL SHADOW ACCESS REGISTERS.  (PHY REG 0x18)
  */
-#define MII_BCM54XX_AUXCTL_SHDWSEL_AUXCTL	0x0000
+#define MII_BCM54XX_AUXCTL_SHDWSEL_AUXCTL	0x00
 #define MII_BCM54XX_AUXCTL_ACTL_TX_6DB		0x0400
 #define MII_BCM54XX_AUXCTL_ACTL_SMDSP_ENA	0x0800
 
-#define MII_BCM54XX_AUXCTL_MISC_WREN	0x8000
-#define MII_BCM54XX_AUXCTL_MISC_FORCE_AMDIX	0x0200
-#define MII_BCM54XX_AUXCTL_SHDWSEL_MISC	0x0007
-#define MII_BCM54XX_AUXCTL_SHDWSEL_READ_SHIFT	12
-#define MII_BCM54XX_AUXCTL_SHDWSEL_MISC_RGMII_SKEW_EN	(1 << 8)
-#define MII_BCM54XX_AUXCTL_SHDWSEL_MISC_WIRESPEED_EN	(1 << 4)
+#define MII_BCM54XX_AUXCTL_SHDWSEL_MISC			0x07
+#define MII_BCM54XX_AUXCTL_SHDWSEL_MISC_WIRESPEED_EN	0x0010
+#define MII_BCM54XX_AUXCTL_SHDWSEL_MISC_RGMII_SKEW_EN	0x0100
+#define MII_BCM54XX_AUXCTL_MISC_FORCE_AMDIX		0x0200
+#define MII_BCM54XX_AUXCTL_MISC_WREN			0x8000
 
+#define MII_BCM54XX_AUXCTL_SHDWSEL_READ_SHIFT	12
 #define MII_BCM54XX_AUXCTL_SHDWSEL_MASK	0x0007
 
 /*
-- 
2.11.0

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

* Re: [PATCH V2 2/3] net: phy: broadcom: drop duplicated define for RGMII SKEW delay
  2017-01-25 20:00 ` [PATCH V2 2/3] net: phy: broadcom: drop duplicated define for RGMII SKEW delay Rafał Miłecki
@ 2017-01-25 20:34   ` Florian Fainelli
  0 siblings, 0 replies; 7+ messages in thread
From: Florian Fainelli @ 2017-01-25 20:34 UTC (permalink / raw)
  To: Rafał Miłecki, David S . Miller
  Cc: Xo Wang, Joel Stanley, Jon Mason, Jaedon Shin, netdev,
	Rafał Miłecki

On 01/25/2017 12:00 PM, Rafał Miłecki wrote:
> From: Rafał Miłecki <rafal@milecki.pl>
> 
> We had two defines for the same bit (both were used with the
> MII_BCM54XX_AUXCTL_SHDWSEL_MISC register).
> 
> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

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

* Re: [PATCH V2 3/3] net: phy: bcm-phy-lib: clean up remaining AUXCTL register defines
  2017-01-25 20:00 ` [PATCH V2 3/3] net: phy: bcm-phy-lib: clean up remaining AUXCTL register defines Rafał Miłecki
@ 2017-01-25 20:35   ` Florian Fainelli
  0 siblings, 0 replies; 7+ messages in thread
From: Florian Fainelli @ 2017-01-25 20:35 UTC (permalink / raw)
  To: Rafał Miłecki, David S . Miller
  Cc: Xo Wang, Joel Stanley, Jon Mason, Jaedon Shin, netdev,
	Rafał Miłecki

On 01/25/2017 12:00 PM, Rafał Miłecki wrote:
> From: Rafał Miłecki <rafal@milecki.pl>
> 
> 1) Use 0x%02x format for register number. This follows some other
>    defines and makes it easier to distinct register from values.
> 2) Put register define above values and sort the values. It makes
>    reading header code easier.
> 3) Use 0x%04x format for all values. It's about consistency with other
>    values (and most of the header) not a personal preference.
> 4) Separate define for reading shift value with an extre empty line.
>    It's user for all AUXCTL registers in a bcm54xx_auxctl_read.
> 
> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

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

* Re: [PATCH V2 0/3] net-next: Broadcom PHY driver cleanup
  2017-01-25 20:00 [PATCH V2 0/3] net-next: Broadcom PHY driver cleanup Rafał Miłecki
                   ` (2 preceding siblings ...)
  2017-01-25 20:00 ` [PATCH V2 3/3] net: phy: bcm-phy-lib: clean up remaining AUXCTL register defines Rafał Miłecki
@ 2017-01-26  4:14 ` David Miller
  3 siblings, 0 replies; 7+ messages in thread
From: David Miller @ 2017-01-26  4:14 UTC (permalink / raw)
  To: zajec5; +Cc: f.fainelli, xow, joel, jon.mason, jaedon.shin, netdev, rafal

From: Rafał Miłecki <zajec5@gmail.com>
Date: Wed, 25 Jan 2017 21:00:24 +0100

> I will probably need to use broadcom.ko for PHY connected to interface
> of bgmac supported device so I started looking at it willing to
> understand it better.
> 
> I found AUXCTL part of the driver / lib a bit confusing and hard to read
> so I'm trying to clean it up a bit. I hope this patchset makes following
> AUXCTL operations much easier making it clear which defines are for
> registers and which for values.
> 
> There is no functional change in this pachset.

Series applied, thanks.

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

end of thread, other threads:[~2017-01-26  4:14 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-25 20:00 [PATCH V2 0/3] net-next: Broadcom PHY driver cleanup Rafał Miłecki
2017-01-25 20:00 ` [PATCH V2 1/3] net: phy: broadcom: use auxctl reading helper in BCM54612E code Rafał Miłecki
2017-01-25 20:00 ` [PATCH V2 2/3] net: phy: broadcom: drop duplicated define for RGMII SKEW delay Rafał Miłecki
2017-01-25 20:34   ` Florian Fainelli
2017-01-25 20:00 ` [PATCH V2 3/3] net: phy: bcm-phy-lib: clean up remaining AUXCTL register defines Rafał Miłecki
2017-01-25 20:35   ` Florian Fainelli
2017-01-26  4:14 ` [PATCH V2 0/3] net-next: Broadcom PHY driver cleanup 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).