net-next: Broadcom PHY driver cleanup
Subsystems (4)
v2 cover net-next: Broadcom PHY driver cleanup
From: Rafał Miłecki <[email protected]>
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(-)
Signature · 1 line
2.11.0
PATCH v2 1/3 net: phy: broadcom: use auxctl reading helper in BCM54612E code
From: Rafał Miłecki <[email protected]>
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).
--- drivers/net/phy/broadcom.c | 6 ++---- include/linux/brcmphy.h | 1 - 2 files changed, 2 insertions(+), 5 deletions(-)
drivers/net/phy/broadcom.c +2 -4
@@ -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 */
include/linux/brcmphy.h +0 -1
@@ -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)
Signature · 1 line
2.11.0
PATCH v2 2/3 net: phy: broadcom: drop duplicated define for RGMII SKEW delay
In reply to Rafał MiłeckiFrom: Rafał Miłecki <[email protected]>
We had two defines for the same bit (both were used with the MII_BCM54XX_AUXCTL_SHDWSEL_MISC register).
---
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(-)
drivers/net/phy/broadcom.c +1 -1
@@ -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,
include/linux/brcmphy.h +0 -1
@@ -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
Signature · 1 line
2.11.0
PATCH v2 3/3 net: phy: bcm-phy-lib: clean up remaining AUXCTL register defines
In reply to Rafał MiłeckiFrom: Rafał Miłecki <[email protected]>
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.
---
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(-)
include/linux/brcmphy.h +7 -7
@@ -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/*
Signature · 1 line
2.11.0
Re: [PATCH V2 2/3] net: phy: broadcom: drop duplicated define for RGMII SKEW delay
In reply to Rafał MiłeckiQuoted 6 lines · Rafał Miłecki
From: Rafał Miłecki <[email protected]>
We had two defines for the same bit (both were used with the
MII_BCM54XX_AUXCTL_SHDWSEL_MISCregister).Signed-off-by Rafał Miłecki <[email protected]>
Signature · 1 line
Florian
Re: [PATCH V2 3/3] net: phy: bcm-phy-lib: clean up remaining AUXCTL register defines
In reply to Rafał MiłeckiQuoted 11 lines · Rafał Miłecki
From: Rafał Miłecki <[email protected]>
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 abcm54xx_auxctl_read.
Quoted 1 line
Signed-off-by Rafał Miłecki <[email protected]>
Signature · 1 line
Florian
David Miller
maintainerFrom: Rafał Miłecki <[email protected]>
Date: Wed, 25 Jan 2017 21:00:24 +0100
Quoted 10 lines
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.