dt-bindings: phy: dp83867: Describe how driver behaves w.r.t rgmii delay
Subsystems (4)
PATCH v2 1/8 dt-bindings: phy: dp83867: Describe how driver behaves w.r.t rgmii delay
Add a note to make it more clear how the driver behaves when "rgmii" vs "rgmii-id", "rgmii-idrx", or "rgmii-idtx" interface modes are selected.
---
Notes:
Changes from v1:
Clarify behavior may change to enforce no delay in "rgmii" mode
Documentation/devicetree/bindings/net/ti,dp83867.txt | 8 ++++++++ 1 file changed, 8 insertions(+)
Documentation/devicetree/bindings/net/ti,dp83867.txt +8 -0
@@ -11,6 +11,14 @@ Required properties: - ti,fifo-depth - Transmitt FIFO depth- see dt-bindings/net/ti-dp83867.h for applicable values +Note: If the interface type is PHY_INTERFACE_MODE_RGMII the TX/RX clock delays + will be left at their default values, as set by the PHY's pin strapping. + The default strapping will use a delay of 2.00 ns. Thus + PHY_INTERFACE_MODE_RGMII, by default, does not behave as RGMII with no + internal delay, but as PHY_INTERFACE_MODE_RGMII_ID. The device tree + should use "rgmii-id" if internal delays are desired as this may be + changed in future to cause "rgmii" mode to disable delays. + Optional property: - ti,min-output-impedance - MAC Interface Impedance control to set the programmable output impedance to
Signature · 1 line
2.14.5
PATCH v2 2/8 dt-bindings: phy: dp83867: Add documentation for disabling clock output
The clock output is generally only used for testing and development and not used to daisy-chain PHYs. It's just a source of RF noise afterward.
Add a mux value for "off". I've added it as another enumeration to the output property. In the actual PHY, the mux and the output enable are independently controllable. However, it doesn't seem useful to be able to describe the mux setting when the output is disabled.
Document that PHY's default setting will be left as is if the property is omitted.
--- Documentation/devicetree/bindings/net/ti,dp83867.txt | 6 ++++-- include/dt-bindings/net/ti-dp83867.h | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/net/ti,dp83867.txt +4 -2
@@ -33,8 +33,10 @@ Optional property: software needs to take when this pin is strapped in these modes. See data manual for details. - - ti,clk-output-sel - Muxing option for CLK_OUT pin - see dt-bindings/net/ti-dp83867.h - for applicable values. + - ti,clk-output-sel - Muxing option for CLK_OUT pin. See dt-bindings/net/ti-dp83867.h + for applicable values. The CLK_OUT pin can also + be disabled by this property. When omitted, the + PHY's default will be left as is. Note: ti,min-output-impedance and ti,max-output-impedance are mutually exclusive. When both properties are present ti,max-output-impedance
include/dt-bindings/net/ti-dp83867.h +2 -0
@@ -56,4 +56,6 @@#define DP83867_CLK_O_SEL_CHN_C_TCLK 0xA#define DP83867_CLK_O_SEL_CHN_D_TCLK 0xB#define DP83867_CLK_O_SEL_REF_CLK 0xC +/* Special flag to indicate clock should be off */ +#define DP83867_CLK_O_SEL_OFF 0xFFFFFFFF#endif
Signature · 1 line
2.14.5
Re: [PATCH net-next v2 2/8] dt-bindings: phy: dp83867: Add documentation for disabling clock output
Quoted 8 lines · Trent Piepho
The clock output is generally only used for testing and development and not used to daisy-chain PHYs. It's just a source of RF noise afterward.
Add a mux value for "off". I've added it as another enumeration to the output property. In the actual PHY, the mux and the output enable are independently controllable. However, it doesn't seem useful to be able to describe the mux setting when the output is disabled.
Quoted 6 lines
Document that PHY's default setting will be left as is if the property is omitted.
Cc Rob Herring <[email protected]>Cc Mark Rutland <[email protected]>Signed-off-by Trent Piepho <[email protected]>
Andrew
Re: [PATCH net-next v2 2/8] dt-bindings: phy: dp83867: Add documentation for disabling clock output
In reply to Trent PiephoFrom: Trent Piepho <[email protected]>
Date: Wed, 22 May 2019 18:43:21 +0000
Quoted 8 lines
The clock output is generally only used for testing and development and not used to daisy-chain PHYs. It's just a source of RF noise afterward.
Add a mux value for "off". I've added it as another enumeration to the output property. In the actual PHY, the mux and the output enable are independently controllable. However, it doesn't seem useful to be able to describe the mux setting when the output is disabled.
Quoted 6 lines
Document that PHY's default setting will be left as is if the property is omitted.
Cc Rob Herring <[email protected]>Cc Mark Rutland <[email protected]>Signed-off-by Trent Piepho <[email protected]>
Applied.
PATCH v2 3/8 net: phy: dp83867: Add ability to disable output clock
In reply to Trent PiephoGenerally, the output clock pin is only used for testing and only serves as a source of RF noise after this. It could be used to daisy-chain PHYs, but this is uncommon. Since the PHY can disable the output, make doing so an option. I do this by adding another enumeration to the allowed values of ti,clk-output-sel.
The code was not using the value DP83867_CLK_O_SEL_REF_CLK as one might
expect: to select the REF_CLK as the output. Rather it meant "keep clock output setting as is", which, depending on PHY strapping, might not be outputting REF_CLK.
Change this so DP83867_CLK_O_SEL_REF_CLK means enable REF_CLK output. Omitting the property will leave the setting as is (which was the previous behavior in this case).
Out of range values were silently converted into DP83867_CLK_O_SEL_REF_CLK. Change this so they generate an error.
--- drivers/net/phy/dp83867.c | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-)
drivers/net/phy/dp83867.c +28 -9
@@ -68,6 +68,7 @@#define DP83867_IO_MUX_CFG_IO_IMPEDANCE_MAX 0x0#define DP83867_IO_MUX_CFG_IO_IMPEDANCE_MIN 0x1f +#define DP83867_IO_MUX_CFG_CLK_O_DISABLE BIT(6)#define DP83867_IO_MUX_CFG_CLK_O_SEL_MASK (0x1f << 8)#define DP83867_IO_MUX_CFG_CLK_O_SEL_SHIFT 8
@@ -87,7 +88,8 @@ struct dp83867_private {int io_impedance;int port_mirroring;bool rxctrl_strap_quirk; -int clk_output_sel; +bool set_clk_output; +u32 clk_output_sel; };static int dp83867_ack_interrupt (struct phy_device *phydev)
@@ -154,11 +156,19 @@ static int dp83867_of_init(struct phy_device *phydev)/* Optional configuration */ ret =of_property_read_u32 (of_node,"ti,clk-output-sel" , &dp83867->clk_output_sel); -if (ret || dp83867->clk_output_sel >DP83867_CLK_O_SEL_REF_CLK ) -/* Keep the default value if ti,clk-output-sel is not set -* or too high +/* If not set, keep default */ +if (!ret) { + dp83867->set_clk_output = true; +/* Valid values are 0 to DP83867_CLK_O_SEL_REF_CLK or +* DP83867_CLK_O_SEL_OFF. */ - dp83867->clk_output_sel =DP83867_CLK_O_SEL_REF_CLK ; +if (dp83867->clk_output_sel >DP83867_CLK_O_SEL_REF_CLK && + dp83867->clk_output_sel !=DP83867_CLK_O_SEL_OFF ) { +phydev_err (phydev,"ti,clk-output-sel value %u out of range\n" , + dp83867->clk_output_sel); +return -EINVAL ; + } + }if (of_property_read_bool (of_node,"ti,max-output-impedance" )) dp83867->io_impedance =DP83867_IO_MUX_CFG_IO_IMPEDANCE_MAX ;
@@ -288,11 +298,20 @@ static int dp83867_config_init(struct phy_device *phydev)dp83867_config_port_mirroring (phydev);/* Clock output selection if muxing property is set */ -if (dp83867->clk_output_sel !=DP83867_CLK_O_SEL_REF_CLK ) +if (dp83867->set_clk_output) { +u16 mask =DP83867_IO_MUX_CFG_CLK_O_DISABLE ; + +if (dp83867->clk_output_sel ==DP83867_CLK_O_SEL_OFF ) { + val =DP83867_IO_MUX_CFG_CLK_O_DISABLE ; + }else { + mask |=DP83867_IO_MUX_CFG_CLK_O_SEL_MASK ; + val = dp83867->clk_output_sel << +DP83867_IO_MUX_CFG_CLK_O_SEL_SHIFT ; + } +phy_modify_mmd (phydev,DP83867_DEVADDR ,DP83867_IO_MUX_CFG , -DP83867_IO_MUX_CFG_CLK_O_SEL_MASK , - dp83867->clk_output_sel << -DP83867_IO_MUX_CFG_CLK_O_SEL_SHIFT ); + mask, val); + }return 0 ; }
Signature · 1 line
2.14.5
Re: [PATCH net-next v2 3/8] net: phy: dp83867: Add ability to disable output clock
Quoted 15 lines · Trent Piepho
Generally, the output clock pin is only used for testing and only serves as a source of RF noise after this. It could be used to daisy-chain PHYs, but this is uncommon. Since the PHY can disable the output, make doing so an option. I do this by adding another enumeration to the allowed values of ti,clk-output-sel.
The code was not using the value
DP83867_CLK_O_SEL_REF_CLKas one might
expect: to select theREF_CLKas the output. Rather it meant "keep clock output setting as is", which, depending on PHY strapping, might not be outputtingREF_CLK.Change this so
DP83867_CLK_O_SEL_REF_CLKmeans enableREF_CLKoutput. Omitting the property will leave the setting as is (which was the previous behavior in this case).
Quoted 7 lines
Out of range values were silently converted into
DP83867_CLK_O_SEL_REF_CLK. Change this so they generate an error.Cc Andrew Lunn <[email protected]>Cc Florian Fainelli <[email protected]>Cc Heiner Kallweit <[email protected]>Signed-off-by Trent Piepho <[email protected]>
Andrew
Re: [PATCH net-next v2 3/8] net: phy: dp83867: Add ability to disable output clock
In reply to Trent PiephoFrom: Trent Piepho <[email protected]>
Date: Wed, 22 May 2019 18:43:22 +0000
Quoted 15 lines
Generally, the output clock pin is only used for testing and only serves as a source of RF noise after this. It could be used to daisy-chain PHYs, but this is uncommon. Since the PHY can disable the output, make doing so an option. I do this by adding another enumeration to the allowed values of ti,clk-output-sel.
The code was not using the value
DP83867_CLK_O_SEL_REF_CLKas one might
expect: to select theREF_CLKas the output. Rather it meant "keep clock output setting as is", which, depending on PHY strapping, might not be outputtingREF_CLK.Change this so
DP83867_CLK_O_SEL_REF_CLKmeans enableREF_CLKoutput. Omitting the property will leave the setting as is (which was the previous behavior in this case).
Quoted 7 lines
Out of range values were silently converted into
DP83867_CLK_O_SEL_REF_CLK. Change this so they generate an error.Cc Andrew Lunn <[email protected]>Cc Florian Fainelli <[email protected]>Cc Heiner Kallweit <[email protected]>Signed-off-by Trent Piepho <[email protected]>
Applied.
PATCH v2 4/8 net: phy: dp83867: Rework delay rgmii delay handling
In reply to Trent PiephoThe code was assuming the reset default of the delay control register was to have delay disabled. This is what the datasheet shows as the register's initial value. However, that's not actually true: the default is controlled by the PHY's pin strapping.
If the interface mode is selected as RX or TX delay only, insure the other direction's delay is disabled.
If the interface mode is just "rgmii", with neither TX or RX internal delay, one might expect that the driver should disable both delays. But this is not what the driver does. It leaves the setting at the PHY's strapping's default. And that default, for no pins with strapping resistors, is to have delay enabled and 2.00 ns.
Rather than change this behavior, I've kept it the same and documented it. No delay will most likely not work and will break ethernet on any board using "rgmii" mode. If the board is strapped to have a delay and is configured to use "rgmii" mode a warning is generated that "rgmii-id" should have been used.
Also validate the delay values and fail if they are not in range.
---
Notes:
Changes from v1:
Print warning if pin strapping has delay when "rgmii" mode is used.
drivers/net/phy/dp83867.c | 78 +++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 66 insertions(+), 12 deletions(-)
drivers/net/phy/dp83867.c +66 -12
@@ -28,6 +28,7 @@#define DP83867_CFG4 0x0031#define DP83867_RGMIICTL 0x0032#define DP83867_STRAP_STS1 0x006E +#define DP83867_STRAP_STS2 0x006f#define DP83867_RGMIIDCTL 0x0086#define DP83867_IO_MUX_CFG 0x0170
@@ -55,13 +56,23 @@/* STRAP_STS1 bits */ #define DP83867_STRAP_STS1_RESERVED BIT(11) +/* STRAP_STS2 bits */ +#define DP83867_STRAP_STS2_CLK_SKEW_TX_MASK GENMASK(6, 4) +#define DP83867_STRAP_STS2_CLK_SKEW_TX_SHIFT 4 +#define DP83867_STRAP_STS2_CLK_SKEW_RX_MASK GENMASK(2, 0) +#define DP83867_STRAP_STS2_CLK_SKEW_RX_SHIFT 0 +#define DP83867_STRAP_STS2_CLK_SKEW_NONE BIT(2) +/* PHY CTRL bits */ #define DP83867_PHYCR_FIFO_DEPTH_SHIFT 14#define DP83867_PHYCR_FIFO_DEPTH_MASK (3 << 14)#define DP83867_PHYCR_RESERVED_MASK BIT(11)/* RGMIIDCTL bits */ +#define DP83867_RGMII_TX_CLK_DELAY_MAX 0xf#define DP83867_RGMII_TX_CLK_DELAY_SHIFT 4 +#define DP83867_RGMII_RX_CLK_DELAY_MAX 0xf +#define DP83867_RGMII_RX_CLK_DELAY_SHIFT 0/* IO_MUX_CFG bits */ #define DP83867_IO_MUX_CFG_IO_IMPEDANCE_CTRL 0x1f
@@ -178,19 +189,56 @@ static int dp83867_of_init(struct phy_device *phydev) dp83867->rxctrl_strap_quirk =of_property_read_bool (of_node,"ti,dp83867-rxctrl-strap-quirk" ); - ret =of_property_read_u32 (of_node,"ti,rx-internal-delay" , - &dp83867->rx_id_delay); -if (ret && - (phydev->interface ==PHY_INTERFACE_MODE_RGMII_ID || - phydev->interface ==PHY_INTERFACE_MODE_RGMII_RXID )) -return ret; +/* Existing behavior was to use default pin strapping delay in rgmii +* mode, but rgmii should have meant no delay. Warn existing users. +*/ +if (phydev->interface ==PHY_INTERFACE_MODE_RGMII ) { +const u16 val =phy_read_mmd (phydev,DP83867_DEVADDR ,DP83867_STRAP_STS2 ); +const u16 txskew = (val &DP83867_STRAP_STS2_CLK_SKEW_TX_MASK ) >> +DP83867_STRAP_STS2_CLK_SKEW_TX_SHIFT ; +const u16 rxskew = (val &DP83867_STRAP_STS2_CLK_SKEW_RX_MASK ) >> +DP83867_STRAP_STS2_CLK_SKEW_RX_SHIFT ; + +if (txskew !=DP83867_STRAP_STS2_CLK_SKEW_NONE || + rxskew !=DP83867_STRAP_STS2_CLK_SKEW_NONE ) +phydev_warn (phydev, +"PHY has delays via pin strapping, but phy-mode = 'rgmii'\n" +"Should be 'rgmii-id' to use internal delays\n" ); + } - ret =of_property_read_u32 (of_node,"ti,tx-internal-delay" , - &dp83867->tx_id_delay); -if (ret && - (phydev->interface ==PHY_INTERFACE_MODE_RGMII_ID || - phydev->interface ==PHY_INTERFACE_MODE_RGMII_TXID )) -return ret; +/* RX delay *must* be specified if internal delay of RX is used. */ +if (phydev->interface ==PHY_INTERFACE_MODE_RGMII_ID || + phydev->interface ==PHY_INTERFACE_MODE_RGMII_RXID ) { + ret =of_property_read_u32 (of_node,"ti,rx-internal-delay" , + &dp83867->rx_id_delay); +if (ret) { +phydev_err (phydev,"ti,rx-internal-delay must be specified\n" ); +return ret; + } +if (dp83867->rx_id_delay >DP83867_RGMII_RX_CLK_DELAY_MAX ) { +phydev_err (phydev, +"ti,rx-internal-delay value of %u out of range\n" , + dp83867->rx_id_delay); +return -EINVAL ; + } + } + +/* TX delay *must* be specified if internal delay of RX is used. */ +if (phydev->interface ==PHY_INTERFACE_MODE_RGMII_ID || + phydev->interface ==PHY_INTERFACE_MODE_RGMII_TXID ) { + ret =of_property_read_u32 (of_node,"ti,tx-internal-delay" , + &dp83867->tx_id_delay); +if (ret) { +phydev_err (phydev,"ti,tx-internal-delay must be specified\n" ); +return ret; + } +if (dp83867->tx_id_delay >DP83867_RGMII_TX_CLK_DELAY_MAX ) { +phydev_err (phydev, +"ti,tx-internal-delay value of %u out of range\n" , + dp83867->tx_id_delay); +return -EINVAL ; + } + }if (of_property_read_bool (of_node,"enet-phy-lane-swap" )) dp83867->port_mirroring =DP83867_PORT_MIRROING_EN ;
@@ -259,10 +307,16 @@ static int dp83867_config_init(struct phy_device *phydev)return ret; } +/* If rgmii mode with no internal delay is selected, we do NOT use +* aligned mode as one might expect. Instead we use the PHY's default +* based on pin strapping. And the "mode 0" default is to *use* +* internal delay with a value of 7 (2.00 ns). +*/ if ((phydev->interface >=PHY_INTERFACE_MODE_RGMII_ID ) && (phydev->interface <=PHY_INTERFACE_MODE_RGMII_RXID )) { val =phy_read_mmd (phydev,DP83867_DEVADDR ,DP83867_RGMIICTL ); + val &= ~(DP83867_RGMII_TX_CLK_DELAY_EN |DP83867_RGMII_RX_CLK_DELAY_EN );if (phydev->interface ==PHY_INTERFACE_MODE_RGMII_ID ) val |= (DP83867_RGMII_TX_CLK_DELAY_EN |DP83867_RGMII_RX_CLK_DELAY_EN );
Signature · 1 line
2.14.5
Re: [PATCH net-next v2 4/8] net: phy: dp83867: Rework delay rgmii delay handling
Quoted 20 lines · Trent Piepho
The code was assuming the reset default of the delay control register was to have delay disabled. This is what the datasheet shows as the register's initial value. However, that's not actually true: the default is controlled by the PHY's pin strapping.
If the interface mode is selected as RX or TX delay only, insure the other direction's delay is disabled.
If the interface mode is just "rgmii", with neither TX or RX internal delay, one might expect that the driver should disable both delays. But this is not what the driver does. It leaves the setting at the PHY's strapping's default. And that default, for no pins with strapping resistors, is to have delay enabled and 2.00 ns.
Rather than change this behavior, I've kept it the same and documented it. No delay will most likely not work and will break ethernet on any board using "rgmii" mode. If the board is strapped to have a delay and is configured to use "rgmii" mode a warning is generated that "rgmii-id" should have been used.
Quoted 6 lines
Also validate the delay values and fail if they are not in range.
Cc Andrew Lunn <[email protected]>Cc Florian Fainelli <[email protected]>Cc Heiner Kallweit <[email protected]>Signed-off-by Trent Piepho <[email protected]>
Andrew
Re: [PATCH net-next v2 4/8] net: phy: dp83867: Rework delay rgmii delay handling
In reply to Trent PiephoFrom: Trent Piepho <[email protected]>
Date: Wed, 22 May 2019 18:43:23 +0000
Quoted 20 lines
The code was assuming the reset default of the delay control register was to have delay disabled. This is what the datasheet shows as the register's initial value. However, that's not actually true: the default is controlled by the PHY's pin strapping.
If the interface mode is selected as RX or TX delay only, insure the other direction's delay is disabled.
If the interface mode is just "rgmii", with neither TX or RX internal delay, one might expect that the driver should disable both delays. But this is not what the driver does. It leaves the setting at the PHY's strapping's default. And that default, for no pins with strapping resistors, is to have delay enabled and 2.00 ns.
Rather than change this behavior, I've kept it the same and documented it. No delay will most likely not work and will break ethernet on any board using "rgmii" mode. If the board is strapped to have a delay and is configured to use "rgmii" mode a warning is generated that "rgmii-id" should have been used.
Quoted 6 lines
Also validate the delay values and fail if they are not in range.
Cc Andrew Lunn <[email protected]>Cc Florian Fainelli <[email protected]>Cc Heiner Kallweit <[email protected]>Signed-off-by Trent Piepho <[email protected]>
Applied.
PATCH v2 5/8 net: phy: dp83867: Use unsigned variables to store unsigned properties
In reply to Trent PiephoThe variables used to store u32 DT properties were signed ints. This doesn't work properly if the value of the property were to overflow. Use unsigned variables so this doesn't happen.
--- drivers/net/phy/dp83867.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/phy/dp83867.c +3 -3
@@ -93,9 +93,9 @@ enum { };struct dp83867_private { -int rx_id_delay; -int tx_id_delay; -int fifo_depth; +u32 rx_id_delay; +u32 tx_id_delay; +u32 fifo_depth;int io_impedance;int port_mirroring;bool rxctrl_strap_quirk;
Signature · 1 line
2.14.5
Re: [PATCH net-next v2 5/8] net: phy: dp83867: Use unsigned variables to store unsigned properties
Quoted 8 lines · Trent Piepho
The variables used to store u32 DT properties were signed ints. This doesn't work properly if the value of the property were to overflow. Use unsigned variables so this doesn't happen.
Cc Andrew Lunn <[email protected]>Cc Florian Fainelli <[email protected]>Cc Heiner Kallweit <[email protected]>Signed-off-by Trent Piepho <[email protected]>
Andrew
Re: [PATCH net-next v2 5/8] net: phy: dp83867: Use unsigned variables to store unsigned properties
In reply to Trent PiephoFrom: Trent Piepho <[email protected]>
Date: Wed, 22 May 2019 18:43:24 +0000
Quoted 8 lines
The variables used to store u32 DT properties were signed ints. This doesn't work properly if the value of the property were to overflow. Use unsigned variables so this doesn't happen.
Cc Andrew Lunn <[email protected]>Cc Florian Fainelli <[email protected]>Cc Heiner Kallweit <[email protected]>Signed-off-by Trent Piepho <[email protected]>
Applied.
PATCH v2 6/8 net: phy: dp83867: IO impedance is not dependent on RGMII delay
In reply to Trent PiephoThe driver would only set the IO impedance value when RGMII internal delays were enabled. There is no reason for this. Move the IO impedance block out of the RGMII delay block.
---
Notes:
Changes from v1:
Patch added in v2.
drivers/net/phy/dp83867.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)
drivers/net/phy/dp83867.c +9 -10
@@ -75,8 +75,7 @@#define DP83867_RGMII_RX_CLK_DELAY_SHIFT 0/* IO_MUX_CFG bits */ -#define DP83867_IO_MUX_CFG_IO_IMPEDANCE_CTRL 0x1f - +#define DP83867_IO_MUX_CFG_IO_IMPEDANCE_MASK 0x1f#define DP83867_IO_MUX_CFG_IO_IMPEDANCE_MAX 0x0#define DP83867_IO_MUX_CFG_IO_IMPEDANCE_MIN 0x1f#define DP83867_IO_MUX_CFG_CLK_O_DISABLE BIT(6)
@@ -162,8 +161,6 @@ static int dp83867_of_init(struct phy_device *phydev)if (!of_node)return -ENODEV ; - dp83867->io_impedance = -EINVAL ; -/* Optional configuration */ ret =of_property_read_u32 (of_node,"ti,clk-output-sel" , &dp83867->clk_output_sel);
@@ -185,6 +182,8 @@ static int dp83867_of_init(struct phy_device *phydev) dp83867->io_impedance =DP83867_IO_MUX_CFG_IO_IMPEDANCE_MAX ; else if (of_property_read_bool(of_node, "ti,min-output-impedance")) dp83867->io_impedance =DP83867_IO_MUX_CFG_IO_IMPEDANCE_MIN ; + else + dp83867->io_impedance = -1; /* leave at default */ dp83867->rxctrl_strap_quirk =of_property_read_bool (of_node,"ti,dp83867-rxctrl-strap-quirk" );
@@ -333,14 +332,14 @@ static int dp83867_config_init(struct phy_device *phydev)phy_write_mmd (phydev,DP83867_DEVADDR ,DP83867_RGMIIDCTL , delay); - -if (dp83867->io_impedance >=0 ) -phy_modify_mmd (phydev,DP83867_DEVADDR ,DP83867_IO_MUX_CFG , -DP83867_IO_MUX_CFG_IO_IMPEDANCE_CTRL , - dp83867->io_impedance & -DP83867_IO_MUX_CFG_IO_IMPEDANCE_CTRL ); } +/* If specified, set io impedance */ +if (dp83867->io_impedance >=0 ) +phy_modify_mmd (phydev,DP83867_DEVADDR ,DP83867_IO_MUX_CFG , +DP83867_IO_MUX_CFG_IO_IMPEDANCE_MASK , + dp83867->io_impedance); +/* Enable Interrupt output INT_OE in CFG3 register */ if (phy_interrupt_is_valid (phydev)) { val =phy_read (phydev,DP83867_CFG3 );
Signature · 1 line
2.14.5
Re: [PATCH net-next v2 6/8] net: phy: dp83867: IO impedance is not dependent on RGMII delay
Quoted 8 lines · Trent Piepho
The driver would only set the IO impedance value when RGMII internal delays were enabled. There is no reason for this. Move the IO impedance block out of the RGMII delay block.
Cc Andrew Lunn <[email protected]>Cc Florian Fainelli <[email protected]>Cc Heiner Kallweit <[email protected]>Signed-off-by Trent Piepho <[email protected]>
Andrew
Re: [PATCH net-next v2 6/8] net: phy: dp83867: IO impedance is not dependent on RGMII delay
In reply to Trent PiephoFrom: Trent Piepho <[email protected]>
Date: Wed, 22 May 2019 18:43:25 +0000
Quoted 8 lines
The driver would only set the IO impedance value when RGMII internal delays were enabled. There is no reason for this. Move the IO impedance block out of the RGMII delay block.
Cc Andrew Lunn <[email protected]>Cc Florian Fainelli <[email protected]>Cc Heiner Kallweit <[email protected]>Signed-off-by Trent Piepho <[email protected]>
Applied.
PATCH v2 7/8 net: phy: dp83867: Validate FIFO depth property
In reply to Trent PiephoInsure property is in valid range and fail when reading DT if it is not. Also add error message for existing failure if required property is not present.
---
Notes:
Changes from v1:
New patch in series v2
drivers/net/phy/dp83867.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
drivers/net/phy/dp83867.c +15 -2
@@ -65,7 +65,8 @@/* PHY CTRL bits */ #define DP83867_PHYCR_FIFO_DEPTH_SHIFT 14 -#define DP83867_PHYCR_FIFO_DEPTH_MASK (3 << 14) +#define DP83867_PHYCR_FIFO_DEPTH_MAX 0x03 +#define DP83867_PHYCR_FIFO_DEPTH_MASK GENMASK(15, 14)#define DP83867_PHYCR_RESERVED_MASK BIT(11)/* RGMIIDCTL bits */
@@ -245,8 +246,20 @@ static int dp83867_of_init(struct phy_device *phydev)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" , + ret =of_property_read_u32 (of_node,"ti,fifo-depth" , &dp83867->fifo_depth); +if (ret) { +phydev_err (phydev, +"ti,fifo-depth property is required\n" ); +return ret; + } +if (dp83867->fifo_depth >DP83867_PHYCR_FIFO_DEPTH_MAX ) { +phydev_err (phydev, +"ti,fifo-depth value %u out of range\n" , + dp83867->fifo_depth); +return -EINVAL ; + } + return 0; }#else static int dp83867_of_init (struct phy_device *phydev)
Signature · 1 line
2.14.5
Re: [PATCH net-next v2 7/8] net: phy: dp83867: Validate FIFO depth property
Quoted 8 lines · Trent Piepho
Insure property is in valid range and fail when reading DT if it is not. Also add error message for existing failure if required property is not present.
Cc Andrew Lunn <[email protected]>Cc Florian Fainelli <[email protected]>Cc Heiner Kallweit <[email protected]>Signed-off-by Trent Piepho <[email protected]>
Andrew
Re: [PATCH net-next v2 7/8] net: phy: dp83867: Validate FIFO depth property
In reply to Trent PiephoFrom: Trent Piepho <[email protected]>
Date: Wed, 22 May 2019 18:43:26 +0000
Quoted 8 lines
Insure property is in valid range and fail when reading DT if it is not. Also add error message for existing failure if required property is not present.
Cc Andrew Lunn <[email protected]>Cc Florian Fainelli <[email protected]>Cc Heiner Kallweit <[email protected]>Signed-off-by Trent Piepho <[email protected]>
Applied.
PATCH v2 8/8 net: phy: dp83867: Allocate state struct in probe
In reply to Trent PiephoThis was being done in config the first time the phy was configured. Should be in the probe method.
---
Notes:
Changes from v1:
New patch in series v2
drivers/net/phy/dp83867.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-)
drivers/net/phy/dp83867.c +19 -14
@@ -268,25 +268,29 @@ static int dp83867_of_init(struct phy_device *phydev) }#endif /* CONFIG_OF_MDIO */ -static int dp83867_config_init (struct phy_device *phydev) +static int dp83867_probe (struct phy_device *phydev) {struct dp83867_private *dp83867; + + dp83867 =devm_kzalloc (&phydev->mdio.dev,sizeof (*dp83867), +GFP_KERNEL ); +if (!dp83867) +return -ENOMEM ; + + phydev->priv = dp83867; + +return 0 ; +} + +static int dp83867_config_init (struct phy_device *phydev) +{ +struct dp83867_private *dp83867 = phydev->priv;int ret, val, bs;u16 delay; -if (!phydev->priv) { - dp83867 =devm_kzalloc (&phydev->mdio.dev,sizeof (*dp83867), -GFP_KERNEL ); -if (!dp83867) -return -ENOMEM ; - - phydev->priv = dp83867; - ret =dp83867_of_init (phydev); -if (ret) -return ret; - }else { - dp83867 = (struct dp83867_private *)phydev->priv; - } + ret =dp83867_of_init (phydev); +if (ret) +return ret;/* RX_DV/RX_CTRL strapped in mode 1 or mode 2 workaround */ if (dp83867->rxctrl_strap_quirk)
@@ -402,6 +406,7 @@ static struct phy_driver dp83867_driver[] = { .name = "TI DP83867",/* PHY_GBIT_FEATURES */ + .probe = dp83867_probe, .config_init = dp83867_config_init, .soft_reset = dp83867_phy_reset,
Signature · 1 line
2.14.5
Re: [PATCH net-next v2 8/8] net: phy: dp83867: Allocate state struct in probe
Quoted 7 lines · Trent Piepho
This was being done in config the first time the phy was configured. Should be in the probe method.
Cc Andrew Lunn <[email protected]>Cc Florian Fainelli <[email protected]>Cc Heiner Kallweit <[email protected]>Signed-off-by Trent Piepho <[email protected]>
Andrew
Re: [PATCH net-next v2 8/8] net: phy: dp83867: Allocate state struct in probe
In reply to Trent PiephoFrom: Trent Piepho <[email protected]>
Date: Wed, 22 May 2019 18:43:27 +0000
Quoted 7 lines
This was being done in config the first time the phy was configured. Should be in the probe method.
Cc Andrew Lunn <[email protected]>Cc Florian Fainelli <[email protected]>Cc Heiner Kallweit <[email protected]>Signed-off-by Trent Piepho <[email protected]>
Applied.
Quoted 7 lines · Trent Piepho
Add a note to make it more clear how the driver behaves when "rgmii" vs "rgmii-id", "rgmii-idrx", or "rgmii-idtx" interface modes are selected.
Cc Rob Herring <[email protected]>Cc Mark Rutland <[email protected]>Signed-off-by Trent Piepho <[email protected]>
Andrew
From: Trent Piepho <[email protected]>
Date: Wed, 22 May 2019 18:43:19 +0000
Quoted 6 lines
Add a note to make it more clear how the driver behaves when "rgmii" vs "rgmii-id", "rgmii-idrx", or "rgmii-idtx" interface modes are selected.
Cc Rob Herring <[email protected]>Cc Mark Rutland <[email protected]>Signed-off-by Trent Piepho <[email protected]>
Applied.