Message ID | 1486224132-15420-1-git-send-email-lukma@denx.de |
---|---|
State | Changes Requested, archived |
Delegated to: | David Miller |
Headers | show |
On Sat, Feb 04, 2017 at 05:02:11PM +0100, Lukasz Majewski wrote: > This patch adds support for enabling or disabling the port mirroring > (at CFG4 register) feature of the DP83867 TI's PHY device. As we discussed before, "port mirroring" is bad naming. Yes, we should use it, because that is what the datasheet calls this feature. But the commit message should also contain a description of what this means, and reference that the linux name for this concept is lane swapping. > +enum { Maybe give the 0 value a name. DP83867_PORT_MIRROING_KEEP? > + DP83867_PORT_MIRROING_EN = 1, > + DP83867_PORT_MIRROING_DIS, > +}; > + That extra enum value can then make this more obvious: if (dp83867->port_mirroring != DP83867_PORT_MIRROING_KEEP) dp83867_config_port_mirroring(phydev); On the first reading of the patch, i though you were setting mirroring on/off under all conditions, but in fact you don't. This makes it clearer. Thanks Andrew
Hi Andrew, > On Sat, Feb 04, 2017 at 05:02:11PM +0100, Lukasz Majewski wrote: > > This patch adds support for enabling or disabling the port > > mirroring (at CFG4 register) feature of the DP83867 TI's PHY device. > > As we discussed before, "port mirroring" is bad naming. Yes, we should > use it, because that is what the datasheet calls this feature. That was my goal - to use naming from datasheet. > But the > commit message should also contain a description of what this means, > and reference that the linux name for this concept is lane swapping. Ok. No problem with that. > > > +enum { > > Maybe give the 0 value a name. DP83867_PORT_MIRROING_KEEP? I can add this - no problem. > > > + DP83867_PORT_MIRROING_EN = 1, > > + DP83867_PORT_MIRROING_DIS, > > +}; > > + > > That extra enum value can then make this more obvious: > > if (dp83867->port_mirroring != DP83867_PORT_MIRROING_KEEP) > dp83867_config_port_mirroring(phydev); > > On the first reading of the patch, i though you were setting mirroring > on/off under all conditions, but in fact you don't. This makes it > clearer. Ok. I see your point. > > Thanks > Andrew Thanks for review :-) Best regards, Lukasz Majewski -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd@denx.de
diff --git a/drivers/net/phy/dp83867.c b/drivers/net/phy/dp83867.c index ca1b462..b5f0c2d 100644 --- a/drivers/net/phy/dp83867.c +++ b/drivers/net/phy/dp83867.c @@ -32,6 +32,7 @@ #define DP83867_CFG3 0x1e /* Extended Registers */ +#define DP83867_CFG4 0x0031 #define DP83867_RGMIICTL 0x0032 #define DP83867_RGMIIDCTL 0x0086 #define DP83867_IO_MUX_CFG 0x0170 @@ -70,11 +71,20 @@ #define DP83867_IO_MUX_CFG_IO_IMPEDANCE_MAX 0x0 #define DP83867_IO_MUX_CFG_IO_IMPEDANCE_MIN 0x1f +/* CFG4 bits */ +#define DP83867_CFG4_PORT_MIRROR_EN BIT(0) + +enum { + DP83867_PORT_MIRROING_EN = 1, + DP83867_PORT_MIRROING_DIS, +}; + struct dp83867_private { int rx_id_delay; int tx_id_delay; int fifo_depth; int io_impedance; + int port_mirroring; }; static int dp83867_ack_interrupt(struct phy_device *phydev) @@ -111,6 +121,24 @@ static int dp83867_config_intr(struct phy_device *phydev) return phy_write(phydev, MII_DP83867_MICR, micr_status); } +static int dp83867_config_port_mirroring(struct phy_device *phydev) +{ + struct dp83867_private *dp83867 = + (struct dp83867_private *)phydev->priv; + u16 val; + + val = phy_read_mmd_indirect(phydev, DP83867_CFG4, DP83867_DEVADDR); + + if (dp83867->port_mirroring == DP83867_PORT_MIRROING_EN) + val |= DP83867_CFG4_PORT_MIRROR_EN; + else + val &= ~DP83867_CFG4_PORT_MIRROR_EN; + + phy_write_mmd_indirect(phydev, DP83867_CFG4, DP83867_DEVADDR, val); + + return 0; +} + #ifdef CONFIG_OF_MDIO static int dp83867_of_init(struct phy_device *phydev) { @@ -144,6 +172,12 @@ static int dp83867_of_init(struct phy_device *phydev) phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID)) return ret; + if (of_property_read_bool(of_node, "enet-phy-lane-swap")) + dp83867->port_mirroring = DP83867_PORT_MIRROING_EN; + + if (of_property_read_bool(of_node, "enet-phy-lane-no-swap")) + dp83867->port_mirroring = DP83867_PORT_MIRROING_DIS; + return of_property_read_u32(of_node, "ti,fifo-depth", &dp83867->fifo_depth); } @@ -228,6 +262,9 @@ static int dp83867_config_init(struct phy_device *phydev) phy_write(phydev, DP83867_CFG3, val); } + if (dp83867->port_mirroring) + dp83867_config_port_mirroring(phydev); + return 0; }
This patch adds support for enabling or disabling the port mirroring (at CFG4 register) feature of the DP83867 TI's PHY device. One use case is when bootstrap configuration enables this feature (because of e.g. LED wiring) so then one needs to disable it in software (u-boot/Linux). Signed-off-by: Lukasz Majewski <lukma@denx.de> --- Changes for v2: - use "net-phy-lane-swap" and "net-phy-lane-no-swap" generic PHY properties. instead of TI specific one --- drivers/net/phy/dp83867.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+)