add dts for yt8521 and yt8531s, add driver for yt8531
Subsystems (5)
Frank Sae
maintainerv3 cover add dts for yt8521 and yt8531s, add driver for yt8531
Add dts for yt8521 and yt8531s, add driver for yt8531. These patches have been verified on our AM335x platform (motherboard) which has one integrated yt8521 and one RGMII interface. It can connect to daughter boards like yt8531s or yt8531 board.
v3:
- change default rx delay from 1900ps to 1950ps
- moved ytphy_rgmii_clk_delay_config_with_lock from yt8521's patch to yt8531's patch
- removed unnecessary checks of phydev->attached_dev->dev_addr
v2:
- split BIT macro as one patch
- split "dts for yt8521/yt8531s ... " patch as two patches
- use standard rx-internal-delay-ps and tx-internal-delay-ps, removed motorcomm,sds-tx-amplitude
- removed ytphy_parse_dt, ytphy_probe_helper and ytphy_config_init_helper
- not store dts arg to yt8521_priv
Frank Sae (5):
dt-bindings: net: Add Motorcomm yt8xxx ethernet phy
net: phy: Add BIT macro for Motorcomm yt8521/yt8531 gigabit ethernet
phy
net: phy: Add dts support for Motorcomm yt8521 gigabit ethernet phy
net: phy: Add dts support for Motorcomm yt8531s gigabit ethernet phy
net: phy: Add driver for Motorcomm yt8531 gigabit ethernet phy
.../bindings/net/motorcomm,yt8xxx.yaml | 102 ++++ .../devicetree/bindings/vendor-prefixes.yaml | 2 + MAINTAINERS | 1 + drivers/net/phy/Kconfig | 2 +- drivers/net/phy/motorcomm.c | 553 +++++++++++++++--- 5 files changed, 582 insertions(+), 78 deletions(-) create mode 100644 Documentation/devicetree/bindings/net/motorcomm,yt8xxx.yaml
Signature · 1 line
2.34.1
Frank Sae
maintainerPATCH v3 1/5 dt-bindings: net: Add Motorcomm yt8xxx ethernet phy
Add a YAML binding document for the Motorcom yt8xxx Ethernet phy driver.
--- .../bindings/net/motorcomm,yt8xxx.yaml | 102 ++++++++++++++++++ .../devicetree/bindings/vendor-prefixes.yaml | 2 + MAINTAINERS | 1 + 3 files changed, 105 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/motorcomm,yt8xxx.yaml
Documentation/devicetree/bindings/net/motorcomm,yt8xxx.yaml new file +102 -0
@@ -0,0 +1,102 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/motorcomm,yt8xxx.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: MotorComm yt8xxx Ethernet PHY + +maintainers: + - frank sae <[email protected]> + +allOf: + - $ref: ethernet-phy.yaml# + +properties: + rx-internal-delay-ps: + description: | + RGMII RX Clock Delay used only when PHY operates in RGMII mode with + internal delay (phy-mode is 'rgmii-id' or 'rgmii-rxid') in pico-seconds. + enum: [ 0, 150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500, 1650, + 1800, 1900, 1950, 2050, 2100, 2200, 2250, 2350, 2500, 2650, 2800, + 2950, 3100, 3250, 3400, 3550, 3700, 3850, 4000, 4150 ] + default: 1950 + + tx-internal-delay-ps: + description: | + RGMII TX Clock Delay used only when PHY operates in RGMII mode with + internal delay (phy-mode is 'rgmii-id' or 'rgmii-txid') in pico-seconds. + enum: [ 0, 150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500, 1650, 1800, + 1950, 2100, 2250 ] + default: 150 + + motorcomm,clk-out-frequency-hz: + description: clock output on clock output pin. + enum: [0, 25000000, 125000000] + default: 0 + + motorcomm,keep-pll-enabled: + description: | + If set, keep the PLL enabled even if there is no link. Useful if you + want to use the clock output without an ethernet link. + type: boolean + + motorcomm,auto-sleep-disabled: + description: | + If set, PHY will not enter sleep mode and close AFE after unplug cable + for a timer. + type: boolean + + motorcomm,tx-clk-adj-enabled: + description: | + This configuration is mainly to adapt to VF2 with JH7110 SoC. + Useful if you want to use tx-clk-xxxx-inverted to adj the delay of tx clk. + type: boolean + + motorcomm,tx-clk-10-inverted: + description: | + Use original or inverted RGMII Transmit PHY Clock to drive the RGMII + Transmit PHY Clock delay train configuration when speed is 10Mbps. + type: boolean + + motorcomm,tx-clk-100-inverted: + description: | + Use original or inverted RGMII Transmit PHY Clock to drive the RGMII + Transmit PHY Clock delay train configuration when speed is 100Mbps. + type: boolean + + motorcomm,tx-clk-1000-inverted: + description: | + Use original or inverted RGMII Transmit PHY Clock to drive the RGMII + Transmit PHY Clock delay train configuration when speed is 1000Mbps. + type: boolean + +unevaluatedProperties: false + +examples: + - | + mdio0 { + #address-cells = <1>; + #size-cells = <0>; + phy-mode = "rgmii-id"; + ethernet-phy@4 { + reg = <4>; + rx-internal-delay-ps = <2100>; + tx-internal-delay-ps = <150>; + motorcomm,clk-out-frequency-hz = <0>; + motorcomm,keep-pll-enabled; + motorcomm,auto-sleep-disabled; + }; + }; + - | + mdio0 { + #address-cells = <1>; + #size-cells = <0>; + phy-mode = "rgmii"; + ethernet-phy@5 { + reg = <5>; + motorcomm,clk-out-frequency-hz = <125000000>; + motorcomm,keep-pll-enabled; + motorcomm,auto-sleep-disabled; + }; + };
Documentation/devicetree/bindings/vendor-prefixes.yaml +2 -0
@@ -847,6 +847,8 @@ patternProperties: description: Moortec Semiconductor Ltd. "^mosaixtech,.*": description: Mosaix Technologies, Inc. + "^motorcomm,.*": + description: MotorComm, Inc. "^motorola,.*": description: Motorola, Inc. "^moxa,.*":
MAINTAINERS +1 -0
@@ -14163,6 +14163,7 @@ M: Peter Geis <[email protected]> M: Frank <[email protected]> L: [email protected] S: Maintained +F: Documentation/devicetree/bindings/net/motorcomm,yt8xxx.yaml F: drivers/net/phy/motorcomm.c MOXA SMARTIO/INDUSTIO/INTELLIO SERIAL CARD
Signature · 1 line
2.34.1
Andrew Lunn
maintainerRe: [PATCH net-next v3 1/5] dt-bindings: net: Add Motorcomm yt8xxx ethernet phy
Quoted 29 lines · Frank Sae
Add a YAML binding document for the Motorcom yt8xxx Ethernet phy driver.
Signed-off-by Frank Sae <[email protected]>--- .../bindings/net/motorcomm,yt8xxx.yaml | 102 ++++++++++++++++++ .../devicetree/bindings/vendor-prefixes.yaml | 2 + MAINTAINERS | 1 + 3 files changed, 105 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/motorcomm,yt8xxx.yamlDocumentation/devicetree/bindings/net/motorcomm,yt8xxx.yaml new file +13
-0@@ -0,0 +1,102 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/motorcomm,yt8xxx.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: MotorComm yt8xxx Ethernet PHY + +maintainers: + - frank sae <[email protected]> + +allOf: + - $ref: ethernet-phy.yaml#
Documentation/devicetree/bindings/net/motorcomm,yt8xxx.yaml line 23
Quoted 10 lines
Documentation/devicetree/bindings/net/motorcomm,yt8xxx.yaml new file +10
-0+ +properties: + rx-internal-delay-ps: + description: | + RGMII RX Clock Delay used only when PHY operates in RGMII mode with + internal delay (phy-mode is 'rgmii-id' or 'rgmii-rxid') in pico-seconds. + enum: [ 0, 150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500, 1650, + 1800, 1900, 1950, 2050, 2100, 2200, 2250, 2350, 2500, 2650, 2800, + 2950, 3100, 3250, 3400, 3550, 3700, 3850, 4000, 4150 ] + default: 1950
Ah! There has been a misunderstand. Yes, this changes does make sense, but ....
Documentation/devicetree/bindings/net/motorcomm,yt8xxx.yaml line 31
Quoted 8 lines
Documentation/devicetree/bindings/net/motorcomm,yt8xxx.yaml new file +8
-0+ + tx-internal-delay-ps: + description: | + RGMII TX Clock Delay used only when PHY operates in RGMII mode with + internal delay (phy-mode is 'rgmii-id' or 'rgmii-txid') in pico-seconds. + enum: [ 0, 150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500, 1650, 1800, + 1950, 2100, 2250 ] + default: 150
... i was actually trying to say this 150 is odd. Why is this not 1950?
Andrew
Frank.Sae
maintainerRe: [PATCH net-next v3 1/5] dt-bindings: net: Add Motorcomm yt8xxx ethernet phy
Hi Andrew,
Quoted 51 lines · Andrew Lunn
Quoted 29 lines · Frank Sae
Add a YAML binding document for the Motorcom yt8xxx Ethernet phy driver.
Signed-off-by Frank Sae <[email protected]>--- .../bindings/net/motorcomm,yt8xxx.yaml | 102 ++++++++++++++++++ .../devicetree/bindings/vendor-prefixes.yaml | 2 + MAINTAINERS | 1 + 3 files changed, 105 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/motorcomm,yt8xxx.yamlDocumentation/devicetree/bindings/net/motorcomm,yt8xxx.yaml new file +13
-0@@ -0,0 +1,102 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/motorcomm,yt8xxx.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: MotorComm yt8xxx Ethernet PHY + +maintainers: + - frank sae <[email protected]> + +allOf: + - $ref: ethernet-phy.yaml#Documentation/devicetree/bindings/net/motorcomm,yt8xxx.yaml line 23
Quoted 10 lines
Documentation/devicetree/bindings/net/motorcomm,yt8xxx.yaml new file +10
-0+ +properties: + rx-internal-delay-ps: + description: | + RGMII RX Clock Delay used only when PHY operates in RGMII mode with + internal delay (phy-mode is 'rgmii-id' or 'rgmii-rxid') in pico-seconds. + enum: [ 0, 150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500, 1650, + 1800, 1900, 1950, 2050, 2100, 2200, 2250, 2350, 2500, 2650, 2800, + 2950, 3100, 3250, 3400, 3550, 3700, 3850, 4000, 4150 ] + default: 1950Ah! There has been a misunderstand. Yes, this changes does make sense, but >
Documentation/devicetree/bindings/net/motorcomm,yt8xxx.yaml line 31
Quoted 8 lines
Documentation/devicetree/bindings/net/motorcomm,yt8xxx.yaml new file +8
-0+ + tx-internal-delay-ps: + description: | + RGMII TX Clock Delay used only when PHY operates in RGMII mode with + internal delay (phy-mode is 'rgmii-id' or 'rgmii-txid') in pico-seconds. + enum: [ 0, 150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500, 1650, 1800, + 1950, 2100, 2250 ] + default: 150
Quoted 2 lines
... i was actually trying to say this 150 is odd. Why is this not 1950?
Tx-delay is usually adjusted by the mac (~ 2ns).
So here is only fine-turn for the tx-delay.
Quoted 2 lines
Andrew
Andrew Lunn
maintainerRe: [PATCH net-next v3 1/5] dt-bindings: net: Add Motorcomm yt8xxx ethernet phy
Quoted 20 lines
Quoted 20 lines
Documentation/devicetree/bindings/net/motorcomm,yt8xxx.yaml line 23
Quoted 9 lines
Documentation/devicetree/bindings/net/motorcomm,yt8xxx.yaml new file +9
-0+properties: + rx-internal-delay-ps: + description: | + RGMII RX Clock Delay used only when PHY operates in RGMII mode with + internal delay (phy-mode is 'rgmii-id' or 'rgmii-rxid') in pico-seconds. + enum: [ 0, 150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500, 1650, + 1800, 1900, 1950, 2050, 2100, 2200, 2250, 2350, 2500, 2650, 2800, + 2950, 3100, 3250, 3400, 3550, 3700, 3850, 4000, 4150 ] + default: 1950Ah! There has been a misunderstand. Yes, this changes does make sense, but >
Quoted 8 lines
Documentation/devicetree/bindings/net/motorcomm,yt8xxx.yaml new file +8
-0+ + tx-internal-delay-ps: + description: | + RGMII TX Clock Delay used only when PHY operates in RGMII mode with + internal delay (phy-mode is 'rgmii-id' or 'rgmii-txid') in pico-seconds. + enum: [ 0, 150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500, 1650, 1800, + 1950, 2100, 2250 ] + default: 150
Quoted 5 lines
Quoted 2 lines
... i was actually trying to say this 150 is odd. Why is this not 1950?
Tx-delay is usually adjusted by the mac (~ 2ns).
So here is only fine-turn for the tx-delay.
In general, in Linux, this is not true. The PHY inserts both delays. Yes, you can have the MAC insert the delay, but it then means the MAC needs to modify phy-mode to indicate it has inserted the delay, changing rgmii-id to rmgmii-rxid when it calls phy_connect_*(). And few MAC drivers get this correct. So i would avoid this. Default to 1950. And if there is a device which needs a fine tune, it can use 2100, or 2250 in its DTS file.
Andrew
Rob Herring
maintainerRe: [PATCH net-next v3 1/5] dt-bindings: net: Add Motorcomm yt8xxx ethernet phy
In reply to Frank SaeQuoted 1 line · Frank Sae
Add a YAML binding document for the Motorcom yt8xxx Ethernet phy driver.
Bindings are for h/w devices, not drivers.
Quoted 18 lines
Signed-off-by Frank Sae <[email protected]>--- .../bindings/net/motorcomm,yt8xxx.yaml | 102 ++++++++++++++++++ .../devicetree/bindings/vendor-prefixes.yaml | 2 + MAINTAINERS | 1 + 3 files changed, 105 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/motorcomm,yt8xxx.yamlDocumentation/devicetree/bindings/net/motorcomm,yt8xxx.yaml new file +3
-0@@ -0,0 +1,102 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +---
Documentation/devicetree/bindings/net/motorcomm,yt8xxx.yaml line 13
Quoted 10 lines
Documentation/devicetree/bindings/net/motorcomm,yt8xxx.yaml new file +10
-0+$id: http://devicetree.org/schemas/net/motorcomm,yt8xxx.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: MotorComm yt8xxx Ethernet PHY + +maintainers: + - frank sae <[email protected]> + +allOf: + - $ref: ethernet-phy.yaml#
This schema doesn't work because there is no way to determine whether to apply it or not. You need a compatible for your phy.
Rob
Frank.Sae
maintainerRe: [PATCH net-next v3 1/5] dt-bindings: net: Add Motorcomm yt8xxx ethernet phy
Hi Rob,
Quoted 28 lines · Rob Herring
Quoted 1 line · Frank Sae
Add a YAML binding document for the Motorcom yt8xxx Ethernet phy driver.
Bindings are for h/w devices, not drivers.
Quoted 23 lines
Signed-off-by Frank Sae <[email protected]>--- .../bindings/net/motorcomm,yt8xxx.yaml | 102 ++++++++++++++++++ .../devicetree/bindings/vendor-prefixes.yaml | 2 + MAINTAINERS | 1 + 3 files changed, 105 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/motorcomm,yt8xxx.yamlDocumentation/devicetree/bindings/net/motorcomm,yt8xxx.yaml new file +8
-0@@ -0,0 +1,102 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/motorcomm,yt8xxx.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: MotorComm yt8xxx Ethernet PHY +
Quoted 9 lines
Documentation/devicetree/bindings/net/motorcomm,yt8xxx.yaml line 13
Quoted 5 lines
Documentation/devicetree/bindings/net/motorcomm,yt8xxx.yaml new file +5
-0+maintainers: + - frank sae <[email protected]> + +allOf: + - $ref: ethernet-phy.yaml#This schema doesn't work because there is no way to determine whether to apply it or not. You need a compatible for your phy.
I don't understand how to add a compatible for my phy.
compatible:
oneOf:
- enum:
- fsl,imx25-fec
- fsl,imx27-fec
compatible usually like this, but it is usually for mac or mdio.
phy id list:
YT8511 0x0000010a
YT8521 0x0000011A
YT8531 0x4f51e91b
motorcomm,yt8xxx.yaml
mdio0 {
...
ethernet-phy@5 {
compatible = "ethernet-phy-id0000.010a",
"ethernet-phy-id0000.011a",
"ethernet-phy-id4f51.e91b",
"ethernet-phy-ieee802.3-c22";
reg = <5>;
...
};
}; Should i add compatible like this ?
If above is error, please give me an example, thanks!
Quoted 1 line
Rob
Andrew Lunn
maintainerRe: [PATCH net-next v3 1/5] dt-bindings: net: Add Motorcomm yt8xxx ethernet phy
Quoted 4 lines
phy id list:
YT85110x0000010a
YT85210x0000011A
YT85310x4f51e91b
The first two are clearly invalid, the OUI part is zero. So i would not list those. Just use the last one.
In the binding part, you need something like
properties:
compatible:
const: ethernet-phy-id4f51.e91b
description: Only needed for DT lint tools
What i don't know is how this will work in combination with the compatibles gained from ethernet-phy.yaml. You might need to follow the same structure, include a oneOf:
In the example part, you would do something like:
Quoted 4 lines
mdio0 {
...
ethernet-phy@5 {# Only needed to make DT lint tools work. Do not copy/paste # into real DTS files.
Quoted 5 lines
compatible = "ethernet-phy-id4f51.e91b";
reg = <5>;
...
};
};I don't think there are any examples to follow because the kernel does not need any of this, is probes using the IDs. Listing compatibles like this is purely for the DT tools, which is why i put in the comments about not copy/pasting it to real DT blobs.
Andrew
Re: [PATCH net-next v3 1/5] dt-bindings: net: Add Motorcomm yt8xxx ethernet phy
In reply to Frank SaeQuoted 4 lines · Frank Sae
Add a YAML binding document for the Motorcom yt8xxx Ethernet phy driver.
Signed-off-by Frank Sae <[email protected]>---
Some of my comments from your v2 still apply. This was sent before I replied to v2, so it's okay - but fix the points I asked.
Best regards,
Krzysztof
Frank Sae
maintainerPATCH v3 2/5 net: phy: Add BIT macro for Motorcomm yt8521/yt8531 gigabit ethernet phy
In reply to Frank Sae Add BIT macro for Motorcomm yt8521/yt8531 gigabit ethernet phy. This is a preparatory patch. Add BIT macro for 0xA012 reg, and supplement for 0xA001 and 0xA003 reg. These will be used to support dts.
--- drivers/net/phy/motorcomm.c | 55 ++++++++++++++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 4 deletions(-)
drivers/net/phy/motorcomm.c +51 -4
@@ -161,6 +161,11 @@#define YT8521_CHIP_CONFIG_REG 0xA001#define YT8521_CCR_SW_RST BIT(15) +/* 1b0 disable 1.9ns rxc clock delay *default* +* 1b1 enable 1.9ns rxc clock delay +*/ +#define YT8521_CCR_RXC_DLY_EN BIT(8) +#define YT8521_CCR_RXC_DLY_1_900_NS 1900#define YT8521_CCR_MODE_SEL_MASK (BIT(2) | BIT(1) | BIT(0))#define YT8521_CCR_MODE_UTP_TO_RGMII 0
@@ -178,22 +183,41 @@#define YT8521_MODE_POLL 0x3#define YT8521_RGMII_CONFIG1_REG 0xA003 - +/* 1b0 use original tx_clk_rgmii *default* +* 1b1 use inverted tx_clk_rgmii. +*/ +#define YT8521_RC1R_TX_CLK_SEL_INVERTED BIT(14)/* TX Gig-E Delay is bits 3:0, default 0x1 * TX Fast-E Delay is bits 7:4, default 0xf * RX Delay is bits 13:10, default 0x0 * Delay = 150ps * N * On = 2250ps, off = 0ps */ -#define YT8521_RC1R_RX_DELAY_MASK (0xF << 10) +#define YT8521_RC1R_RX_DELAY_MASK GENMASK(13, 10)#define YT8521_RC1R_RX_DELAY_EN (0xF << 10)#define YT8521_RC1R_RX_DELAY_DIS (0x0 << 10) -#define YT8521_RC1R_FE_TX_DELAY_MASK (0xF << 4) +#define YT8521_RC1R_FE_TX_DELAY_MASK GENMASK(7, 4)#define YT8521_RC1R_FE_TX_DELAY_EN (0xF << 4)#define YT8521_RC1R_FE_TX_DELAY_DIS (0x0 << 4) -#define YT8521_RC1R_GE_TX_DELAY_MASK (0xF << 0) +#define YT8521_RC1R_GE_TX_DELAY_MASK GENMASK(3, 0)#define YT8521_RC1R_GE_TX_DELAY_EN (0xF << 0)#define YT8521_RC1R_GE_TX_DELAY_DIS (0x0 << 0) +#define YT8521_RC1R_RGMII_0_000_NS 0 +#define YT8521_RC1R_RGMII_0_150_NS 1 +#define YT8521_RC1R_RGMII_0_300_NS 2 +#define YT8521_RC1R_RGMII_0_450_NS 3 +#define YT8521_RC1R_RGMII_0_600_NS 4 +#define YT8521_RC1R_RGMII_0_750_NS 5 +#define YT8521_RC1R_RGMII_0_900_NS 6 +#define YT8521_RC1R_RGMII_1_050_NS 7 +#define YT8521_RC1R_RGMII_1_200_NS 8 +#define YT8521_RC1R_RGMII_1_350_NS 9 +#define YT8521_RC1R_RGMII_1_500_NS 10 +#define YT8521_RC1R_RGMII_1_650_NS 11 +#define YT8521_RC1R_RGMII_1_800_NS 12 +#define YT8521_RC1R_RGMII_1_950_NS 13 +#define YT8521_RC1R_RGMII_2_100_NS 14 +#define YT8521_RC1R_RGMII_2_250_NS 15#define YTPHY_MISC_CONFIG_REG 0xA006#define YTPHY_MCR_FIBER_SPEED_MASK BIT(0)
@@ -222,6 +246,29 @@*/ #define YTPHY_WCR_TYPE_PULSE BIT(0) +#define YTPHY_SYNCE_CFG_REG 0xA012 +#define YT8521_SCR_SYNCE_ENABLE BIT(5) +/* 1b0 output 25m clock +* 1b1 output 125m clock *default* +*/ +#define YT8521_SCR_CLK_FRE_SEL_125M BIT(3) +#define YT8521_SCR_CLK_SRC_MASK GENMASK(2, 1) +#define YT8521_SCR_CLK_SRC_PLL_125M 0 +#define YT8521_SCR_CLK_SRC_UTP_RX 1 +#define YT8521_SCR_CLK_SRC_SDS_RX 2 +#define YT8521_SCR_CLK_SRC_REF_25M 3 +#define YT8531_SCR_SYNCE_ENABLE BIT(6) +/* 1b0 output 25m clock *default* +* 1b1 output 125m clock +*/ +#define YT8531_SCR_CLK_FRE_SEL_125M BIT(4) +#define YT8531_SCR_CLK_SRC_MASK GENMASK(3, 1) +#define YT8531_SCR_CLK_SRC_PLL_125M 0 +#define YT8531_SCR_CLK_SRC_UTP_RX 1 +#define YT8531_SCR_CLK_SRC_SDS_RX 2 +#define YT8531_SCR_CLK_SRC_CLOCK_FROM_DIGITAL 3 +#define YT8531_SCR_CLK_SRC_REF_25M 4 +#define YT8531_SCR_CLK_SRC_SSC_25M 5#define YT8531S_SYNCE_CFG_REG 0xA012#define YT8531S_SCR_SYNCE_ENABLE BIT(6)
Signature · 1 line
2.34.1
Frank Sae
maintainerPATCH v3 3/5 net: phy: Add dts support for Motorcomm yt8521 gigabit ethernet phy
In reply to Frank Sae Add dts support for Motorcomm yt8521 gigabit ethernet phy. Add ytphy_rgmii_clk_delay_config function to support dst config for the delay of rgmii clk. This funciont is common for yt8521, yt8531s and yt8531.
This patch has been verified on AM335x platform.
--- drivers/net/phy/motorcomm.c | 253 ++++++++++++++++++++++++++++-------- 1 file changed, 199 insertions(+), 54 deletions(-)
drivers/net/phy/motorcomm.c +199 -54
@@ -10,6 +10,7 @@#include <linux/kernel.h> #include <linux/module.h> #include <linux/phy.h> +#include <linux/of.h> #define PHY_ID_YT8511 0x0000010a#define PHY_ID_YT8521 0x0000011A
@@ -187,21 +188,9 @@* 1b1 use inverted tx_clk_rgmii. */ #define YT8521_RC1R_TX_CLK_SEL_INVERTED BIT(14) -/* TX Gig-E Delay is bits 3:0, default 0x1 -* TX Fast-E Delay is bits 7:4, default 0xf -* RX Delay is bits 13:10, default 0x0 -* Delay = 150ps * N -* On = 2250ps, off = 0ps -*/ #define YT8521_RC1R_RX_DELAY_MASK GENMASK(13, 10) -#define YT8521_RC1R_RX_DELAY_EN (0xF << 10) -#define YT8521_RC1R_RX_DELAY_DIS (0x0 << 10)#define YT8521_RC1R_FE_TX_DELAY_MASK GENMASK(7, 4) -#define YT8521_RC1R_FE_TX_DELAY_EN (0xF << 4) -#define YT8521_RC1R_FE_TX_DELAY_DIS (0x0 << 4)#define YT8521_RC1R_GE_TX_DELAY_MASK GENMASK(3, 0) -#define YT8521_RC1R_GE_TX_DELAY_EN (0xF << 0) -#define YT8521_RC1R_GE_TX_DELAY_DIS (0x0 << 0)#define YT8521_RC1R_RGMII_0_000_NS 0#define YT8521_RC1R_RGMII_0_150_NS 1#define YT8521_RC1R_RGMII_0_300_NS 2
@@ -274,6 +263,10 @@/* Extended Register end */ +#define YTPHY_DTS_OUTPUT_CLK_DIS 0 +#define YTPHY_DTS_OUTPUT_CLK_25M 25000000 +#define YTPHY_DTS_OUTPUT_CLK_125M 125000000 +struct yt8521_priv {/* combo_advertising is used for case of YT8521 in combo mode, * this means that yt8521 may work in utp or fiber mode which depends
@@ -640,6 +633,142 @@ static int yt8521_write_page(struct phy_device *phydev, int page)return ytphy_modify_ext (phydev,YT8521_REG_SPACE_SELECT_REG , mask, set); }; +/** +* struct ytphy_cfg_reg_map - map a config value to a register value +* @cfg: value in device configuration +* @reg: value in the register +*/ +struct ytphy_cfg_reg_map { +u32 cfg; +u32 reg; +}; + +static const struct ytphy_cfg_reg_map ytphy_rgmii_delays[] = { +/* for tx delay / rx delay with YT8521_CCR_RXC_DLY_EN is not set. */ + {0 ,YT8521_RC1R_RGMII_0_000_NS }, + {150 ,YT8521_RC1R_RGMII_0_150_NS },/* default tx delay */ + {300 ,YT8521_RC1R_RGMII_0_300_NS }, + {450 ,YT8521_RC1R_RGMII_0_450_NS }, + {600 ,YT8521_RC1R_RGMII_0_600_NS }, + {750 ,YT8521_RC1R_RGMII_0_750_NS }, + {900 ,YT8521_RC1R_RGMII_0_900_NS }, + {1050 ,YT8521_RC1R_RGMII_1_050_NS }, + {1200 ,YT8521_RC1R_RGMII_1_200_NS }, + {1350 ,YT8521_RC1R_RGMII_1_350_NS }, + {1500 ,YT8521_RC1R_RGMII_1_500_NS }, + {1650 ,YT8521_RC1R_RGMII_1_650_NS }, + {1800 ,YT8521_RC1R_RGMII_1_800_NS }, + {1950 ,YT8521_RC1R_RGMII_1_950_NS },/* default rx delay */ + {2100 ,YT8521_RC1R_RGMII_2_100_NS }, + {2250 ,YT8521_RC1R_RGMII_2_250_NS }, + +/* only for rx delay with YT8521_CCR_RXC_DLY_EN is set. */ + {0 +YT8521_CCR_RXC_DLY_1_900_NS ,YT8521_RC1R_RGMII_0_000_NS }, + {150 +YT8521_CCR_RXC_DLY_1_900_NS ,YT8521_RC1R_RGMII_0_150_NS }, + {300 +YT8521_CCR_RXC_DLY_1_900_NS ,YT8521_RC1R_RGMII_0_300_NS }, + {450 +YT8521_CCR_RXC_DLY_1_900_NS ,YT8521_RC1R_RGMII_0_450_NS }, + {600 +YT8521_CCR_RXC_DLY_1_900_NS ,YT8521_RC1R_RGMII_0_600_NS }, + {750 +YT8521_CCR_RXC_DLY_1_900_NS ,YT8521_RC1R_RGMII_0_750_NS }, + {900 +YT8521_CCR_RXC_DLY_1_900_NS ,YT8521_RC1R_RGMII_0_900_NS }, + {1050 +YT8521_CCR_RXC_DLY_1_900_NS ,YT8521_RC1R_RGMII_1_050_NS }, + {1200 +YT8521_CCR_RXC_DLY_1_900_NS ,YT8521_RC1R_RGMII_1_200_NS }, + {1350 +YT8521_CCR_RXC_DLY_1_900_NS ,YT8521_RC1R_RGMII_1_350_NS }, + {1500 +YT8521_CCR_RXC_DLY_1_900_NS ,YT8521_RC1R_RGMII_1_500_NS }, + {1650 +YT8521_CCR_RXC_DLY_1_900_NS ,YT8521_RC1R_RGMII_1_650_NS }, + {1800 +YT8521_CCR_RXC_DLY_1_900_NS ,YT8521_RC1R_RGMII_1_800_NS }, + {1950 +YT8521_CCR_RXC_DLY_1_900_NS ,YT8521_RC1R_RGMII_1_950_NS }, + {2100 +YT8521_CCR_RXC_DLY_1_900_NS ,YT8521_RC1R_RGMII_2_100_NS }, + {2250 +YT8521_CCR_RXC_DLY_1_900_NS ,YT8521_RC1R_RGMII_2_250_NS } +}; + +static u32 ytphy_get_delay_reg_value (struct phy_device *phydev, +const char *prop_name, +const struct ytphy_cfg_reg_map *tbl, +int tb_size, +u16 *rxc_dly_en, +u32 dflt) +{ +struct device_node *node = phydev->mdio.dev.of_node; +int tb_size_half = tb_size /2 ; +u32 val; +int i; + +if (of_property_read_u32 (node, prop_name, &val)) + goto err_dts_val; + +/* when rxc_dly_en is NULL, it is get the delay for tx, only half of +* tb_size is valid. +*/ +if (!rxc_dly_en) + tb_size = tb_size_half; + +for (i =0 ; i < tb_size; i++) { +if (tbl[i].cfg == val) { +if (rxc_dly_en && i < tb_size_half) + *rxc_dly_en =0 ; +return tbl[i].reg; + } + } + +phydev_warn (phydev,"Unsupported value %d for %s using default (%u)\n" , + val, prop_name, dflt); + +err_dts_val: +/* when rxc_dly_en is not NULL, it is get the delay for rx. +* The rx default in dts and ytphy_rgmii_clk_delay_config is 1950 ps, +* so YT8521_CCR_RXC_DLY_EN should not be set. +*/ +if (rxc_dly_en) + *rxc_dly_en =0 ; + +return dflt; +} + +static int ytphy_rgmii_clk_delay_config (struct phy_device *phydev) +{ +int tb_size =ARRAY_SIZE (ytphy_rgmii_delays); +u16 rxc_dly_en =YT8521_CCR_RXC_DLY_EN ; +u32 rx_reg, tx_reg; +u16 mask, val =0 ; +int ret; + + rx_reg =ytphy_get_delay_reg_value (phydev,"rx-internal-delay-ps" , + ytphy_rgmii_delays, tb_size, + &rxc_dly_en, +YT8521_RC1R_RGMII_1_950_NS ); + tx_reg =ytphy_get_delay_reg_value (phydev,"tx-internal-delay-ps" , + ytphy_rgmii_delays, tb_size,NULL , +YT8521_RC1R_RGMII_0_150_NS ); + +switch (phydev->interface) { +case PHY_INTERFACE_MODE_RGMII : + rxc_dly_en =0 ; +break ; +case PHY_INTERFACE_MODE_RGMII_RXID : + val |=FIELD_PREP (YT8521_RC1R_RX_DELAY_MASK , rx_reg); +break ; +case PHY_INTERFACE_MODE_RGMII_TXID : + rxc_dly_en =0 ; + val |=FIELD_PREP (YT8521_RC1R_GE_TX_DELAY_MASK , tx_reg); +break ; +case PHY_INTERFACE_MODE_RGMII_ID : + val |=FIELD_PREP (YT8521_RC1R_RX_DELAY_MASK , rx_reg) | +FIELD_PREP (YT8521_RC1R_GE_TX_DELAY_MASK , tx_reg); +break ; +default :/* do not support other modes */ +return -EOPNOTSUPP ; + } + + ret =ytphy_modify_ext (phydev,YT8521_CHIP_CONFIG_REG , +YT8521_CCR_RXC_DLY_EN , rxc_dly_en); +if (ret <0 ) +return ret; + +/* Generally, it is not necessary to adjust YT8521_RC1R_FE_TX_DELAY */ + mask =YT8521_RC1R_RX_DELAY_MASK |YT8521_RC1R_GE_TX_DELAY_MASK ; +return ytphy_modify_ext (phydev,YT8521_RGMII_CONFIG1_REG , mask, val); +} +/** * yt8521_probe() - read chip config then set suitable polling_mode * @phydev: a pointer to a &struct phy_device
@@ -648,9 +777,12 @@ static int yt8521_write_page(struct phy_device *phydev, int page)*/ static int yt8521_probe (struct phy_device *phydev) { +struct device_node *node = phydev->mdio.dev.of_node;struct device *dev = &phydev->mdio.dev;struct yt8521_priv *priv;int chip_config; +u16 mask, val; +u32 freq;int ret; priv =devm_kzalloc (dev,sizeof (*priv),GFP_KERNEL );
@@ -695,7 +827,45 @@ static int yt8521_probe(struct phy_device *phydev)return ret; } -return 0 ; +if (of_property_read_u32 (node,"motorcomm,clk-out-frequency-hz" , &freq)) + freq =YTPHY_DTS_OUTPUT_CLK_DIS ; + +if (phydev->drv->phy_id ==PHY_ID_YT8521 ) { +switch (freq) { +case YTPHY_DTS_OUTPUT_CLK_DIS : + mask =YT8521_SCR_SYNCE_ENABLE ; + val =0 ; +break ; +case YTPHY_DTS_OUTPUT_CLK_25M : + mask =YT8521_SCR_SYNCE_ENABLE | +YT8521_SCR_CLK_SRC_MASK | +YT8521_SCR_CLK_FRE_SEL_125M ; + val =YT8521_SCR_SYNCE_ENABLE | +FIELD_PREP (YT8521_SCR_CLK_SRC_MASK , +YT8521_SCR_CLK_SRC_REF_25M ); +break ; +case YTPHY_DTS_OUTPUT_CLK_125M : + mask =YT8521_SCR_SYNCE_ENABLE | +YT8521_SCR_CLK_SRC_MASK | +YT8521_SCR_CLK_FRE_SEL_125M ; + val =YT8521_SCR_SYNCE_ENABLE | +YT8521_SCR_CLK_FRE_SEL_125M | +FIELD_PREP (YT8521_SCR_CLK_SRC_MASK , +YT8521_SCR_CLK_SRC_PLL_125M ); +break ; +default : +phydev_warn (phydev,"Freq err:%u\n" , freq); +return -EINVAL ; + } + }else if (phydev->drv->phy_id ==PHY_ID_YT8531S ) { +return 0 ; + }else { +phydev_warn (phydev,"PHY id err\n" ); +return -EINVAL ; + } + +return ytphy_modify_ext_with_lock (phydev,YTPHY_SYNCE_CFG_REG , mask, + val); }/**
@@ -1180,61 +1350,36 @@ static int yt8521_resume(struct phy_device *phydev)*/ static int yt8521_config_init (struct phy_device *phydev) { +struct device_node *node = phydev->mdio.dev.of_node;int old_page;int ret =0 ; -u16 val; old_page =phy_select_page (phydev,YT8521_RSSR_UTP_SPACE );if (old_page <0 ) goto err_restore_page; -switch (phydev->interface) { -case PHY_INTERFACE_MODE_RGMII : - val =YT8521_RC1R_GE_TX_DELAY_DIS |YT8521_RC1R_FE_TX_DELAY_DIS ; - val |=YT8521_RC1R_RX_DELAY_DIS ; -break ; -case PHY_INTERFACE_MODE_RGMII_RXID : - val =YT8521_RC1R_GE_TX_DELAY_DIS |YT8521_RC1R_FE_TX_DELAY_DIS ; - val |=YT8521_RC1R_RX_DELAY_EN ; -break ; -case PHY_INTERFACE_MODE_RGMII_TXID : - val =YT8521_RC1R_GE_TX_DELAY_EN |YT8521_RC1R_FE_TX_DELAY_EN ; - val |=YT8521_RC1R_RX_DELAY_DIS ; -break ; -case PHY_INTERFACE_MODE_RGMII_ID : - val =YT8521_RC1R_GE_TX_DELAY_EN |YT8521_RC1R_FE_TX_DELAY_EN ; - val |=YT8521_RC1R_RX_DELAY_EN ; -break ; -case PHY_INTERFACE_MODE_SGMII : -break ; -default :/* do not support other modes */ - ret = -EOPNOTSUPP ; - goto err_restore_page; - } -/* set rgmii delay mode */ if (phydev->interface !=PHY_INTERFACE_MODE_SGMII ) { - ret =ytphy_modify_ext (phydev,YT8521_RGMII_CONFIG1_REG , - (YT8521_RC1R_RX_DELAY_MASK | -YT8521_RC1R_FE_TX_DELAY_MASK | -YT8521_RC1R_GE_TX_DELAY_MASK ), - val); + ret =ytphy_rgmii_clk_delay_config (phydev);if (ret <0 ) goto err_restore_page; } -/* disable auto sleep */ - ret =ytphy_modify_ext (phydev,YT8521_EXTREG_SLEEP_CONTROL1_REG , -YT8521_ESC1R_SLEEP_SW ,0 ); -if (ret <0 ) - goto err_restore_page; - -/* enable RXC clock when no wire plug */ - ret =ytphy_modify_ext (phydev,YT8521_CLOCK_GATING_REG , -YT8521_CGR_RX_CLK_EN ,0 ); -if (ret <0 ) - goto err_restore_page; +if (of_property_read_bool (node,"motorcomm,auto-sleep-disabled" )) { +/* disable auto sleep */ + ret =ytphy_modify_ext (phydev,YT8521_EXTREG_SLEEP_CONTROL1_REG , +YT8521_ESC1R_SLEEP_SW ,0 ); +if (ret <0 ) + goto err_restore_page; + } +if (of_property_read_bool (node,"motorcomm,keep-pll-enabled" )) { +/* enable RXC clock when no wire plug */ + ret =ytphy_modify_ext (phydev,YT8521_CLOCK_GATING_REG , +YT8521_CGR_RX_CLK_EN ,0 ); +if (ret <0 ) + goto err_restore_page; + } err_restore_page:return phy_restore_page (phydev, old_page, ret); }
Signature · 1 line
2.34.1
Frank Sae
maintainerPATCH v3 4/5 net: phy: Add dts support for Motorcomm yt8531s gigabit ethernet phy
In reply to Frank Sae Add dts support for Motorcomm yt8531s gigabit ethernet phy. Change yt8521_probe to support clk config of yt8531s. Becase yt8521_probe does the things which yt8531s is needed, so removed yt8531s function.
This patch has been verified on AM335x platform with yt8531s board.
--- drivers/net/phy/motorcomm.c | 51 ++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 24 deletions(-)
drivers/net/phy/motorcomm.c +27 -24
@@ -258,8 +258,6 @@#define YT8531_SCR_CLK_SRC_CLOCK_FROM_DIGITAL 3#define YT8531_SCR_CLK_SRC_REF_25M 4#define YT8531_SCR_CLK_SRC_SSC_25M 5 -#define YT8531S_SYNCE_CFG_REG 0xA012 -#define YT8531S_SCR_SYNCE_ENABLE BIT(6)/* Extended Register end */
@@ -858,7 +856,32 @@ static int yt8521_probe(struct phy_device *phydev)return -EINVAL ; } }else if (phydev->drv->phy_id ==PHY_ID_YT8531S ) { -return 0 ; +switch (freq) { +case YTPHY_DTS_OUTPUT_CLK_DIS : + mask =YT8531_SCR_SYNCE_ENABLE ; + val =0 ; +break ; +case YTPHY_DTS_OUTPUT_CLK_25M : + mask =YT8531_SCR_SYNCE_ENABLE | +YT8531_SCR_CLK_SRC_MASK | +YT8531_SCR_CLK_FRE_SEL_125M ; + val =YT8531_SCR_SYNCE_ENABLE | +FIELD_PREP (YT8531_SCR_CLK_SRC_MASK , +YT8531_SCR_CLK_SRC_REF_25M ); +break ; +case YTPHY_DTS_OUTPUT_CLK_125M : + mask =YT8531_SCR_SYNCE_ENABLE | +YT8531_SCR_CLK_SRC_MASK | +YT8531_SCR_CLK_FRE_SEL_125M ; + val =YT8531_SCR_SYNCE_ENABLE | +YT8531_SCR_CLK_FRE_SEL_125M | +FIELD_PREP (YT8531_SCR_CLK_SRC_MASK , +YT8531_SCR_CLK_SRC_PLL_125M ); +break ; +default : +phydev_warn (phydev,"Freq err:%u\n" , freq); +return -EINVAL ; + } }else {phydev_warn (phydev,"PHY id err\n" );return -EINVAL ;
@@ -868,26 +891,6 @@ static int yt8521_probe(struct phy_device *phydev) val); } -/** -* yt8531s_probe() - read chip config then set suitable polling_mode -* @phydev: a pointer to a &struct phy_device -* -* returns 0 or negative errno code -*/ -static int yt8531s_probe (struct phy_device *phydev) -{ -int ret; - -/* Disable SyncE clock output by default */ - ret =ytphy_modify_ext_with_lock (phydev,YT8531S_SYNCE_CFG_REG , -YT8531S_SCR_SYNCE_ENABLE ,0 ); -if (ret <0 ) -return ret; - -/* same as yt8521_probe */ -return yt8521_probe (phydev); -} -/** * ytphy_utp_read_lpa() - read LPA then setup lp_advertising for utp * @phydev: a pointer to a &struct phy_device
@@ -1970,7 +1973,7 @@ static struct phy_driver motorcomm_phy_drvs[] = {PHY_ID_MATCH_EXACT (PHY_ID_YT8531S ), .name = "YT8531S Gigabit Ethernet", .get_features = yt8521_get_features, - .probe = yt8531s_probe, + .probe = yt8521_probe, .read_page = yt8521_read_page, .write_page = yt8521_write_page, .get_wol = ytphy_get_wol,
Signature · 1 line
2.34.1
Frank Sae
maintainerPATCH v3 5/5 net: phy: Add driver for Motorcomm yt8531 gigabit ethernet phy
In reply to Frank SaeAdd a driver for the motorcomm yt8531 gigabit ethernet phy. We have verified the driver on AM335x platform with yt8531 board. On the board, yt8531 gigabit ethernet phy works in utp mode, RGMII interface, supports 1000M/100M/10M speeds, and wol(magic package).
--- drivers/net/phy/Kconfig | 2 +- drivers/net/phy/motorcomm.c | 208 +++++++++++++++++++++++++++++++++++- 2 files changed, 207 insertions(+), 3 deletions(-)
drivers/net/phy/Kconfig +1 -1
@@ -257,7 +257,7 @@ config MOTORCOMM_PHY tristate "Motorcomm PHYs" help Enables support for Motorcomm network PHYs. - Currently supports the YT8511, YT8521, YT8531S Gigabit Ethernet PHYs. + Currently supports YT85xx Gigabit Ethernet PHYs. config NATIONAL_PHY tristate "National Semiconductor PHYs"
drivers/net/phy/motorcomm.c +206 -2
261 lines not on this page · raw message
Signature · 1 line
2.34.1