Adding the Sparx5 Serdes driver
Subsystems (4)
Steen Hegelund
maintainerv4 cover Adding the Sparx5 Serdes driver
Adding the Sparx5 Serdes driver
This series of patches provides the serdes driver for the Microchip Sparx5 ethernet switch.
The serdes driver supports the 10G and 25G serdes instances available in the Sparx5.
The Sparx5 serdes support several interface modes with several speeds and also allows the client to change the mode and the speed according to changing in the environment such as changing cables from DAC to fiber.
The serdes driver is to be used by the Sparx5 switchdev driver that will follow in subsequent series.
History:
--------
v3 -> v4:
- Add a reg-names item to the binding description
- Add a clocks item to the binding description
- Removed the clock parameter from the configuration interface
- Use the clock dt node to get the coreclock, and using that when doing the actual serdes configuration
- Added a clocks entry with a system clock reference to the serdes node in the device tree
v2 -> v3:
- Sorted the Kconfig sourced folders
- Sorted the Makefile included folders
- Changed the configuration interface documentation to use kernel style
v1 -> v2: Fixed kernel test robot warnings
- Made these structures static:
- media_presets_25g
- mode_presets_25g
- media_presets_10g
- mode_presets_10g
- Removed these duplicate initializations:
- sparx5_sd25g28_params.cfg_rx_reserve_15_8
- sparx5_sd25g28_params.cfg_pi_en
- sparx5_sd25g28_params.cfg_cdrck_en
- sparx5_sd10g28_params.cfg_cdrck_en
Lars Povlsen (2):
dt-bindings: phy: Add sparx5-serdes bindings
arm64: dts: sparx5: Add Sparx5 serdes driver node
Steen Hegelund (2):
phy: Add ethernet serdes configuration option
phy: Add Sparx5 ethernet serdes PHY driver
.../bindings/phy/microchip,sparx5-serdes.yaml | 296 ++ arch/arm64/boot/dts/microchip/sparx5.dtsi | 196 ++ drivers/phy/Kconfig | 3 +- drivers/phy/Makefile | 1 + drivers/phy/microchip/Kconfig | 12 + drivers/phy/microchip/Makefile | 6 + drivers/phy/microchip/sparx5_serdes.c | 2479 +++++++++++++++ drivers/phy/microchip/sparx5_serdes_regs.h | 2773 +++++++++++++++++ include/linux/phy/phy-ethernet-serdes.h | 30 + include/linux/phy/phy.h | 4 + 10 files changed, 5799 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/phy/microchip,sparx5-serdes.yaml create mode 100644 drivers/phy/microchip/Kconfig create mode 100644 drivers/phy/microchip/Makefile create mode 100644 drivers/phy/microchip/sparx5_serdes.c create mode 100644 drivers/phy/microchip/sparx5_serdes_regs.h create mode 100644 include/linux/phy/phy-ethernet-serdes.h
base-commit: 3cea11cd5e3b00d91caf0b4730194039b45c5891
prerequisite-patch-id: b155844f6a5e402ba62a39b1a2b276c8378eeb49
prerequisite-patch-id: 1605ab05e4212d0bba88a858c6dd16df64194282
prerequisite-patch-id: 8d9741ec8a716b179e39d640b3aab8f934c2573d
Signature · 1 line
2.29.2
Steen Hegelund
maintainerPATCH v4 1/4 dt-bindings: phy: Add sparx5-serdes bindings
Document the Sparx5 ethernet serdes phy driver bindings.
--- .../bindings/phy/microchip,sparx5-serdes.yaml | 296 ++++++++++++++++++ 1 file changed, 296 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/microchip,sparx5-serdes.yaml
Documentation/devicetree/bindings/phy/microchip,sparx5-serdes.yaml new file +296 -0
@@ -0,0 +1,296 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/phy/microchip,sparx5-serdes.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Microchip Sparx5 Serdes controller + +maintainers: + - Steen Hegelund <[email protected]> + +description: | + The Sparx5 SERDES interfaces share the same basic functionality, but + support different operating modes and line rates. + + The following list lists the SERDES features: + + * RX Adaptive Decision Feedback Equalizer (DFE) + * Programmable continuous time linear equalizer (CTLE) + * Rx variable gain control + * Rx built-in fault detector (loss-of-lock/loss-of-signal) + * Adjustable tx de-emphasis (FFE) + * Tx output amplitude control + * Supports rx eye monitor + * Multiple loopback modes + * Prbs generator and checker + * Polarity inversion control + + SERDES6G: + + The SERDES6G is a high-speed SERDES interface, which can operate at + the following data rates: + + * 100 Mbps (100BASE-FX) + * 1.25 Gbps (SGMII/1000BASE-X/1000BASE-KX) + * 3.125 Gbps (2.5GBASE-X/2.5GBASE-KX) + * 5.15625 Gbps (5GBASE-KR/5G-USXGMII) + + SERDES10G + + The SERDES10G is a high-speed SERDES interface, which can operate at + the following data rates: + + * 100 Mbps (100BASE-FX) + * 1.25 Gbps (SGMII/1000BASE-X/1000BASE-KX) + * 3.125 Gbps (2.5GBASE-X/2.5GBASE-KX) + * 5 Gbps (QSGMII/USGMII) + * 5.15625 Gbps (5GBASE-KR/5G-USXGMII) + * 10 Gbps (10G-USGMII) + * 10.3125 Gbps (10GBASE-R/10GBASE-KR/USXGMII) + + SERDES25G + + The SERDES25G is a high-speed SERDES interface, which can operate at + the following data rates: + + * 1.25 Gbps (SGMII/1000BASE-X/1000BASE-KX) + * 3.125 Gbps (2.5GBASE-X/2.5GBASE-KX) + * 5 Gbps (QSGMII/USGMII) + * 5.15625 Gbps (5GBASE-KR/5G-USXGMII) + * 10 Gbps (10G-USGMII) + * 10.3125 Gbps (10GBASE-R/10GBASE-KR/USXGMII) + * 25.78125 Gbps (25GBASE-KR/25GBASE-CR/25GBASE-SR/25GBASE-LR/25GBASE-ER) + +properties: + $nodename: + pattern: "^serdes@[0-9a-f]+$" + + compatible: + const: microchip,sparx5-serdes.yaml + + reg: + description: Address and length of the register set for the device + + reg-names: + description: | + Names for each of the address spaces defined in + the 'reg' property. Expects the names in the same order as the + corresponding memory region in the that property. + + '#phy-cells': + const: 1 + description: | + - The main serdes input port + + clocks: + description: + A list containing the phandle to the core clock of the Sparx5 device. + +required: + - compatible + - reg + - reg-names + - '#phy-cells' + - clocks + +additionalProperties: false + +examples: + - | + serdes: serdes@10808000 { + compatible = "microchip,sparx5-serdes"; + #phy-cells = <1>; + clocks = <&sys_clk>; + reg = <0x10808000 0x8000>, /* sd_cmu_0 */ + <0x10810000 0x8000>, /* sd_cmu_1 */ + <0x10818000 0x8000>, /* sd_cmu_2 */ + <0x10820000 0x8000>, /* sd_cmu_3 */ + <0x10828000 0x8000>, /* sd_cmu_4 */ + <0x10830000 0x8000>, /* sd_cmu_5 */ + <0x10838000 0x8000>, /* sd_cmu_6 */ + <0x10840000 0x8000>, /* sd_cmu_7 */ + <0x10848000 0x8000>, /* sd_cmu_8 */ + <0x10850000 0x8000>, /* sd_cmu_cfg_0 */ + <0x10858000 0x8000>, /* sd_cmu_cfg_1 */ + <0x10860000 0x8000>, /* sd_cmu_cfg_2 */ + <0x10868000 0x8000>, /* sd_cmu_cfg_3 */ + <0x10870000 0x8000>, /* sd_cmu_cfg_4 */ + <0x10878000 0x8000>, /* sd_cmu_cfg_5 */ + <0x10880000 0x8000>, /* sd_cmu_cfg_6 */ + <0x10888000 0x8000>, /* sd_cmu_cfg_7 */ + <0x10890000 0x8000>, /* sd_cmu_cfg_8 */ + <0x10898000 0x8000>, /* sd6g_lane_0 */ + <0x108a0000 0x8000>, /* sd6g_lane_1 */ + <0x108a8000 0x8000>, /* sd6g_lane_2 */ + <0x108b0000 0x8000>, /* sd6g_lane_3 */ + <0x108b8000 0x8000>, /* sd6g_lane_4 */ + <0x108c0000 0x8000>, /* sd6g_lane_5 */ + <0x108c8000 0x8000>, /* sd6g_lane_6 */ + <0x108d0000 0x8000>, /* sd6g_lane_7 */ + <0x108d8000 0x8000>, /* sd6g_lane_8 */ + <0x108e0000 0x8000>, /* sd6g_lane_9 */ + <0x108e8000 0x8000>, /* sd6g_lane_10 */ + <0x108f0000 0x8000>, /* sd6g_lane_11 */ + <0x108f8000 0x8000>, /* sd6g_lane_12 */ + <0x10900000 0x8000>, /* sd10g_lane_0 */ + <0x10908000 0x8000>, /* sd10g_lane_1 */ + <0x10910000 0x8000>, /* sd10g_lane_2 */ + <0x10918000 0x8000>, /* sd10g_lane_3 */ + <0x109a8000 0x8000>, /* sd_lane_0 */ + <0x109b0000 0x8000>, /* sd_lane_1 */ + <0x109b8000 0x8000>, /* sd_lane_2 */ + <0x109c0000 0x8000>, /* sd_lane_3 */ + <0x109c8000 0x8000>, /* sd_lane_4 */ + <0x109d0000 0x8000>, /* sd_lane_5 */ + <0x109d8000 0x8000>, /* sd_lane_6 */ + <0x109e0000 0x8000>, /* sd_lane_7 */ + <0x109e8000 0x8000>, /* sd_lane_8 */ + <0x109f0000 0x8000>, /* sd_lane_9 */ + <0x109f8000 0x8000>, /* sd_lane_10 */ + <0x10a00000 0x8000>, /* sd_lane_11 */ + <0x10a08000 0x8000>, /* sd_lane_12 */ + <0x10a10000 0x8000>, /* sd_lane_13 */ + <0x10a18000 0x8000>, /* sd_lane_14 */ + <0x10a20000 0x8000>, /* sd_lane_15 */ + <0x10a28000 0x8000>, /* sd_lane_16 */ + <0x10c08000 0x8000>, /* sd_cmu_9 */ + <0x10c10000 0x8000>, /* sd_cmu_10 */ + <0x10c18000 0x8000>, /* sd_cmu_11 */ + <0x10c20000 0x8000>, /* sd_cmu_12 */ + <0x10c28000 0x8000>, /* sd_cmu_13 */ + <0x10c30000 0x8000>, /* sd_cmu_cfg_9 */ + <0x10c38000 0x8000>, /* sd_cmu_cfg_10 */ + <0x10c40000 0x8000>, /* sd_cmu_cfg_11 */ + <0x10c48000 0x8000>, /* sd_cmu_cfg_12 */ + <0x10c50000 0x8000>, /* sd_cmu_cfg_13 */ + <0x10c58000 0x8000>, /* sd10g_lane_4 */ + <0x10c60000 0x8000>, /* sd10g_lane_5 */ + <0x10c68000 0x8000>, /* sd10g_lane_6 */ + <0x10c70000 0x8000>, /* sd10g_lane_7 */ + <0x10c78000 0x8000>, /* sd10g_lane_8 */ + <0x10c80000 0x8000>, /* sd10g_lane_9 */ + <0x10c88000 0x8000>, /* sd10g_lane_10 */ + <0x10c90000 0x8000>, /* sd10g_lane_11 */ + <0x10c98000 0x8000>, /* sd25g_lane_0 */ + <0x10ca0000 0x8000>, /* sd25g_lane_1 */ + <0x10ca8000 0x8000>, /* sd25g_lane_2 */ + <0x10cb0000 0x8000>, /* sd25g_lane_3 */ + <0x10cb8000 0x8000>, /* sd25g_lane_4 */ + <0x10cc0000 0x8000>, /* sd25g_lane_5 */ + <0x10cc8000 0x8000>, /* sd25g_lane_6 */ + <0x10cd0000 0x8000>, /* sd25g_lane_7 */ + <0x10d58000 0x8000>, /* sd_lane_17 */ + <0x10d60000 0x8000>, /* sd_lane_18 */ + <0x10d68000 0x8000>, /* sd_lane_19 */ + <0x10d70000 0x8000>, /* sd_lane_20 */ + <0x10d78000 0x8000>, /* sd_lane_21 */ + <0x10d80000 0x8000>, /* sd_lane_22 */ + <0x10d88000 0x8000>, /* sd_lane_23 */ + <0x10d90000 0x8000>, /* sd_lane_24 */ + <0x10d98000 0x8000>, /* sd_lane_25g_25 */ + <0x10da0000 0x8000>, /* sd_lane_25g_26 */ + <0x10da8000 0x8000>, /* sd_lane_25g_27 */ + <0x10db0000 0x8000>, /* sd_lane_25g_28 */ + <0x10db8000 0x8000>, /* sd_lane_25g_29 */ + <0x10dc0000 0x8000>, /* sd_lane_25g_30 */ + <0x10dc8000 0x8000>, /* sd_lane_25g_31 */ + <0x10dd0000 0x8000>; /* sd_lane_25g_32 */ + reg-names = + "sd_cmu_0", + "sd_cmu_1", + "sd_cmu_2", + "sd_cmu_3", + "sd_cmu_4", + "sd_cmu_5", + "sd_cmu_6", + "sd_cmu_7", + "sd_cmu_8", + "sd_cmu_cfg_0", + "sd_cmu_cfg_1", + "sd_cmu_cfg_2", + "sd_cmu_cfg_3", + "sd_cmu_cfg_4", + "sd_cmu_cfg_5", + "sd_cmu_cfg_6", + "sd_cmu_cfg_7", + "sd_cmu_cfg_8", + "sd6g_lane_0", + "sd6g_lane_1", + "sd6g_lane_2", + "sd6g_lane_3", + "sd6g_lane_4", + "sd6g_lane_5", + "sd6g_lane_6", + "sd6g_lane_7", + "sd6g_lane_8", + "sd6g_lane_9", + "sd6g_lane_10", + "sd6g_lane_11", + "sd6g_lane_12", + "sd10g_lane_0", + "sd10g_lane_1", + "sd10g_lane_2", + "sd10g_lane_3", + "sd_lane_0", + "sd_lane_1", + "sd_lane_2", + "sd_lane_3", + "sd_lane_4", + "sd_lane_5", + "sd_lane_6", + "sd_lane_7", + "sd_lane_8", + "sd_lane_9", + "sd_lane_10", + "sd_lane_11", + "sd_lane_12", + "sd_lane_13", + "sd_lane_14", + "sd_lane_15", + "sd_lane_16", + "sd_cmu_9", + "sd_cmu_10", + "sd_cmu_11", + "sd_cmu_12", + "sd_cmu_13", + "sd_cmu_cfg_9", + "sd_cmu_cfg_10", + "sd_cmu_cfg_11", + "sd_cmu_cfg_12", + "sd_cmu_cfg_13", + "sd10g_lane_4", + "sd10g_lane_5", + "sd10g_lane_6", + "sd10g_lane_7", + "sd10g_lane_8", + "sd10g_lane_9", + "sd10g_lane_10", + "sd10g_lane_11", + "sd25g_lane_0", + "sd25g_lane_1", + "sd25g_lane_2", + "sd25g_lane_3", + "sd25g_lane_4", + "sd25g_lane_5", + "sd25g_lane_6", + "sd25g_lane_7", + "sd_lane_17", + "sd_lane_18", + "sd_lane_19", + "sd_lane_20", + "sd_lane_21", + "sd_lane_22", + "sd_lane_23", + "sd_lane_24", + "sd_lane_25g_25", + "sd_lane_25g_26", + "sd_lane_25g_27", + "sd_lane_25g_28", + "sd_lane_25g_29", + "sd_lane_25g_30", + "sd_lane_25g_31", + "sd_lane_25g_32"; + }; + +...
Signature · 1 line
2.29.2
Re: [PATCH v4 1/4] dt-bindings: phy: Add sparx5-serdes bindings
Hi,
Quoted 75 lines · Steen Hegelund
Document the Sparx5 ethernet serdes phy driver bindings.
Signed-off-by Lars Povlsen <[email protected]>Signed-off-by Steen Hegelund <[email protected]>--- .../bindings/phy/microchip,sparx5-serdes.yaml | 296 ++++++++++++++++++ 1 file changed, 296 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/microchip,sparx5-serdes.yamlDocumentation/devicetree/bindings/phy/microchip,sparx5-serdes.yaml new file +60
-0@@ -0,0 +1,296 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/phy/microchip,sparx5-serdes.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Microchip Sparx5 Serdes controller + +maintainers: + - Steen Hegelund <[email protected]> + +description: | + The Sparx5 SERDES interfaces share the same basic functionality, but + support different operating modes and line rates. + + The following list lists the SERDES features: + + * RX Adaptive Decision Feedback Equalizer (DFE) + * Programmable continuous time linear equalizer (CTLE) + * Rx variable gain control + * Rx built-in fault detector (loss-of-lock/loss-of-signal) + * Adjustable tx de-emphasis (FFE) + * Tx output amplitude control + * Supports rx eye monitor + * Multiple loopback modes + * Prbs generator and checker + * Polarity inversion control + + SERDES6G: + + The SERDES6G is a high-speed SERDES interface, which can operate at + the following data rates: + + * 100 Mbps (100BASE-FX) + * 1.25 Gbps (SGMII/1000BASE-X/1000BASE-KX) + * 3.125 Gbps (2.5GBASE-X/2.5GBASE-KX) + * 5.15625 Gbps (5GBASE-KR/5G-USXGMII) + + SERDES10G + + The SERDES10G is a high-speed SERDES interface, which can operate at + the following data rates: + + * 100 Mbps (100BASE-FX) + * 1.25 Gbps (SGMII/1000BASE-X/1000BASE-KX) + * 3.125 Gbps (2.5GBASE-X/2.5GBASE-KX) + * 5 Gbps (QSGMII/USGMII) + * 5.15625 Gbps (5GBASE-KR/5G-USXGMII) + * 10 Gbps (10G-USGMII) + * 10.3125 Gbps (10GBASE-R/10GBASE-KR/USXGMII) + + SERDES25G + + The SERDES25G is a high-speed SERDES interface, which can operate at + the following data rates: + + * 1.25 Gbps (SGMII/1000BASE-X/1000BASE-KX) + * 3.125 Gbps (2.5GBASE-X/2.5GBASE-KX) + * 5 Gbps (QSGMII/USGMII) + * 5.15625 Gbps (5GBASE-KR/5G-USXGMII)
Documentation/devicetree/bindings/phy/microchip,sparx5-serdes.yaml line 70
Quoted 10 lines
Documentation/devicetree/bindings/phy/microchip,sparx5-serdes.yaml new file +10
-0+ * 10 Gbps (10G-USGMII) + * 10.3125 Gbps (10GBASE-R/10GBASE-KR/USXGMII) + * 25.78125 Gbps (25GBASE-KR/25GBASE-CR/25GBASE-SR/25GBASE-LR/25GBASE-ER) + +properties: + $nodename: + pattern: "^serdes@[0-9a-f]+$" + + compatible: + const: microchip,sparx5-serdes.yaml
This has a spurious .yaml suffix ;)
Documentation/devicetree/bindings/phy/microchip,sparx5-serdes.yaml line 73
Quoted 3 lines
Documentation/devicetree/bindings/phy/microchip,sparx5-serdes.yaml new file +3
-0+ + reg: + description: Address and length of the register set for the device
You don't actually have to describe this property a sit comes from the generic schema. But maybe you could set maxItems
Documentation/devicetree/bindings/phy/microchip,sparx5-serdes.yaml line 80
Quoted 7 lines
Documentation/devicetree/bindings/phy/microchip,sparx5-serdes.yaml new file +7
-0+ + reg-names: + description: | + Names for each of the address spaces defined in + the 'reg' property. Expects the names in the same order as the + corresponding memory region in the that property. +
Same comment, even better, I tink you could list the expected names in an enum or a const list
Documentation/devicetree/bindings/phy/microchip,sparx5-serdes.yaml line 88
Quoted 8 lines
Documentation/devicetree/bindings/phy/microchip,sparx5-serdes.yaml new file +8
-0+ '#phy-cells': + const: 1 + description: | + - The main serdes input port + + clocks: + description: + A list containing the phandle to the core clock of the Sparx5 device.
You can drop the description and simply have maxItems: 1
Signature · 3 lines
Alexandre Belloni, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Steen Hegelund
maintainerRe: [PATCH v4 1/4] dt-bindings: phy: Add sparx5-serdes bindings
Quoted 84 lines · Alexandre Belloni
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
Hi,
Quoted 79 lines · Steen Hegelund
Document the Sparx5 ethernet serdes phy driver bindings.
Signed-off-by Lars Povlsen <[email protected]>Signed-off-by Steen Hegelund <[email protected]>--- .../bindings/phy/microchip,sparx5-serdes.yaml | 296 ++++++++++++++++++ 1 file changed, 296 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/microchip,sparx5-serdes.yamlDocumentation/devicetree/bindings/phy/microchip,sparx5-serdes.yaml new file +64
-0@@ -0,0 +1,296 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/phy/microchip,sparx5-serdes.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Microchip Sparx5 Serdes controller + +maintainers: + - Steen Hegelund <[email protected]> + +description: | + The Sparx5 SERDES interfaces share the same basic functionality, but + support different operating modes and line rates. + + The following list lists the SERDES features: + + * RX Adaptive Decision Feedback Equalizer (DFE) + * Programmable continuous time linear equalizer (CTLE) + * Rx variable gain control + * Rx built-in fault detector (loss-of-lock/loss-of-signal) + * Adjustable tx de-emphasis (FFE) + * Tx output amplitude control + * Supports rx eye monitor + * Multiple loopback modes + * Prbs generator and checker + * Polarity inversion control + + SERDES6G: + + The SERDES6G is a high-speed SERDES interface, which can operate at + the following data rates: + + * 100 Mbps (100BASE-FX) + * 1.25 Gbps (SGMII/1000BASE-X/1000BASE-KX) + * 3.125 Gbps (2.5GBASE-X/2.5GBASE-KX) + * 5.15625 Gbps (5GBASE-KR/5G-USXGMII) + + SERDES10G + + The SERDES10G is a high-speed SERDES interface, which can operate at + the following data rates: + + * 100 Mbps (100BASE-FX) + * 1.25 Gbps (SGMII/1000BASE-X/1000BASE-KX) + * 3.125 Gbps (2.5GBASE-X/2.5GBASE-KX) + * 5 Gbps (QSGMII/USGMII) + * 5.15625 Gbps (5GBASE-KR/5G-USXGMII) + * 10 Gbps (10G-USGMII) + * 10.3125 Gbps (10GBASE-R/10GBASE-KR/USXGMII) + + SERDES25G + + The SERDES25G is a high-speed SERDES interface, which can operate at + the following data rates: + + * 1.25 Gbps (SGMII/1000BASE-X/1000BASE-KX) + * 3.125 Gbps (2.5GBASE-X/2.5GBASE-KX) + * 5 Gbps (QSGMII/USGMII) + * 5.15625 Gbps (5GBASE-KR/5G-USXGMII) + * 10 Gbps (10G-USGMII) + * 10.3125 Gbps (10GBASE-R/10GBASE-KR/USXGMII) + * 25.78125 Gbps (25GBASE-KR/25GBASE-CR/25GBASE-SR/25GBASE-LR/25GBASE-ER) +
Quoted 8 lines
Documentation/devicetree/bindings/phy/microchip,sparx5-serdes.yaml line 70
Quoted 6 lines
Documentation/devicetree/bindings/phy/microchip,sparx5-serdes.yaml new file +6
-0+properties: + $nodename: + pattern: "^serdes@[0-9a-f]+$" + + compatible: + const: microchip,sparx5-serdes.yamlThis has a spurious .yaml suffix ;)
I will remove that.
Quoted 7 lines
Documentation/devicetree/bindings/phy/microchip,sparx5-serdes.yaml line 73
Quoted 4 lines
Documentation/devicetree/bindings/phy/microchip,sparx5-serdes.yaml new file +3
-0+ + reg: + description: Address and length of the register set for the deviceYou don't actually have to describe this property a sit comes from the generic schema. But maybe you could set maxItems
OK, I will remove the description.
Wouldn't minItems be better here, since there might be more targets in the future, to support more modes?
Quoted 11 lines
Documentation/devicetree/bindings/phy/microchip,sparx5-serdes.yaml line 80
Quoted 8 lines
Documentation/devicetree/bindings/phy/microchip,sparx5-serdes.yaml new file +7
-0+ + reg-names: + description: | + Names for each of the address spaces defined in + the 'reg' property. Expects the names in the same order as the + corresponding memory region in the that property. +Same comment, even better, I tink you could list the expected names in an enum or a const list
OK, it is a long list, but then it will be automatically checked.
Quoted 11 lines
Documentation/devicetree/bindings/phy/microchip,sparx5-serdes.yaml line 88
Quoted 9 lines
Documentation/devicetree/bindings/phy/microchip,sparx5-serdes.yaml new file +8
-0+ '#phy-cells': + const: 1 + description: | + - The main serdes input port + + clocks: + description: + A list containing the phandle to the core clock of the Sparx5 device.You can drop the description and simply have maxItems: 1
OK
Quoted 6 lines
--
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
BR
Steen
---------------------------------------
Steen Hegelund
[email protected]
Steen Hegelund
maintainerPATCH v4 2/4 phy: Add ethernet serdes configuration option
In reply to Steen HegelundProvide a new ethernet phy configuration structure, that allow PHYs used for ethernet to be configured with speed, media type and clock information.
--- include/linux/phy/phy-ethernet-serdes.h | 30 +++++++++++++++++++++++++ include/linux/phy/phy.h | 4 ++++ 2 files changed, 34 insertions(+) create mode 100644 include/linux/phy/phy-ethernet-serdes.h
include/linux/phy/phy-ethernet-serdes.h new file +30 -0
@@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: (GPL-2.0 OR MIT) */ +/* +* Microchip Sparx5 Ethernet SerDes driver +* +* Copyright (c) 2020 Microschip Inc +*/ +#ifndef __PHY_ETHERNET_SERDES_H_ +#define __PHY_ETHERNET_SERDES_H_ + +#include <linux/phy.h> + +enum ethernet_media_type { +ETH_MEDIA_DEFAULT , +ETH_MEDIA_SR , +ETH_MEDIA_DAC , +}; + +/** +* struct phy_configure_opts_eth_serdes - Ethernet SerDes This structure is used +* to represent the configuration state of a Ethernet Serdes PHY. +* @speed: Speed of the serdes interface in Mbps +* @media_type: Specifies which media the serdes will be using +*/ +struct phy_configure_opts_eth_serdes { +u32 speed; +enum ethernet_media_type media_type; +}; + +#endif +
include/linux/phy/phy.h +4 -0
@@ -18,6 +18,7 @@#include <linux/phy/phy-dp.h> #include <linux/phy/phy-mipi-dphy.h> +#include <linux/phy/phy-ethernet-serdes.h> struct phy ;
@@ -49,11 +50,14 @@ enum phy_mode {* * @mipi_dphy: Configuration set applicable for phys supporting * the MIPI_DPHY phy mode. +* @eth_serdes: Configuration set applicable for phys supporting +* the ethernet serdes. * @dp: Configuration set applicable for phys supporting * the DisplayPort protocol. */ union phy_configure_opts {struct phy_configure_opts_mipi_dphy mipi_dphy; +struct phy_configure_opts_eth_serdes eth_serdes;struct phy_configure_opts_dp dp; };
Signature · 1 line
2.29.2
kernel test robot
build botRe: [PATCH v4 2/4] phy: Add ethernet serdes configuration option
I love your patch! Yet something to improve:
Hi Steen,
I love your patch! Yet something to improve:
[auto build test ERROR on robh/dt/next]
[also build test ERROR on linus/master robh/for-next linux/master 3cea11cd5e3b00d91caf0b4730194039b45c5891 v5.10-rc4 next-20201120] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Steen-Hegelund/Adding-the-Sparx5-Serdes-driver/20201120-230836 base: https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git dt/next config: powerpc64-randconfig-r015-20201120 (attached as .config) compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project 3ded927cf80ac519f9f9c4664fef08787f7c537d)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# install powerpc64 cross compiling tool for clang build
# apt-get install binutils-powerpc64-linux-gnu
# https://github.com/0day-ci/linux/commit/e184a313fca4f75b4f4f8abca27c8c2f1fb29540
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Steen-Hegelund/Adding-the-Sparx5-Serdes-driver/20201120-230836 git checkout e184a313fca4f75b4f4f8abca27c8c2f1fb29540
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=powerpc64
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>):
drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c:110:12: error: conflicting types for 'phy_write' static int phy_write(struct phy *phy, u32 value, unsigned int reg)
^
include/linux/phy.h:987:19: note: previous definition is here
static inline int phy_write(struct phy_device *phydev, u32 regnum, u16 val)
^
>> drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c:292:12: error: incompatible pointer types passing 'struct phy *' to parameter of type 'struct phy_device *' [-Werror,-Wincompatible-pointer-types]
phy_write(phy, priv->cfg.m_prg_hs_prepare, DPHY_M_PRG_HS_PREPARE);
^~~
include/linux/phy.h:987:48: note: passing argument to parameter 'phydev' here
static inline int phy_write(struct phy_device *phydev, u32 regnum, u16 val)
^
drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c:293:12: error: incompatible pointer types passing 'struct phy *' to parameter of type 'struct phy_device *' [-Werror,-Wincompatible-pointer-types]
phy_write(phy, priv->cfg.mc_prg_hs_prepare, DPHY_MC_PRG_HS_PREPARE);
^~~
include/linux/phy.h:987:48: note: passing argument to parameter 'phydev' here
static inline int phy_write(struct phy_device *phydev, u32 regnum, u16 val)
^
drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c:294:12: error: incompatible pointer types passing 'struct phy *' to parameter of type 'struct phy_device *' [-Werror,-Wincompatible-pointer-types]
phy_write(phy, priv->cfg.m_prg_hs_zero, DPHY_M_PRG_HS_ZERO);
^~~
include/linux/phy.h:987:48: note: passing argument to parameter 'phydev' here
static inline int phy_write(struct phy_device *phydev, u32 regnum, u16 val)
^
drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c:295:12: error: incompatible pointer types passing 'struct phy *' to parameter of type 'struct phy_device *' [-Werror,-Wincompatible-pointer-types]
phy_write(phy, priv->cfg.mc_prg_hs_zero, DPHY_MC_PRG_HS_ZERO);
^~~
include/linux/phy.h:987:48: note: passing argument to parameter 'phydev' here
static inline int phy_write(struct phy_device *phydev, u32 regnum, u16 val)
^
drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c:296:12: error: incompatible pointer types passing 'struct phy *' to parameter of type 'struct phy_device *' [-Werror,-Wincompatible-pointer-types]
phy_write(phy, priv->cfg.m_prg_hs_trail, DPHY_M_PRG_HS_TRAIL);
^~~
include/linux/phy.h:987:48: note: passing argument to parameter 'phydev' here
static inline int phy_write(struct phy_device *phydev, u32 regnum, u16 val)
^
drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c:297:12: error: incompatible pointer types passing 'struct phy *' to parameter of type 'struct phy_device *' [-Werror,-Wincompatible-pointer-types]
phy_write(phy, priv->cfg.mc_prg_hs_trail, DPHY_MC_PRG_HS_TRAIL);
^~~
include/linux/phy.h:987:48: note: passing argument to parameter 'phydev' here
static inline int phy_write(struct phy_device *phydev, u32 regnum, u16 val)
^
drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c:298:12: error: incompatible pointer types passing 'struct phy *' to parameter of type 'struct phy_device *' [-Werror,-Wincompatible-pointer-types]
phy_write(phy, priv->cfg.rxhs_settle, priv->devdata->reg_rxhs_settle);
^~~
include/linux/phy.h:987:48: note: passing argument to parameter 'phydev' here
static inline int phy_write(struct phy_device *phydev, u32 regnum, u16 val)
^
drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c:314:12: error: incompatible pointer types passing 'struct phy *' to parameter of type 'struct phy_device *' [-Werror,-Wincompatible-pointer-types]
phy_write(phy, CM(priv->cfg.cm), DPHY_CM);
^~~
include/linux/phy.h:987:48: note: passing argument to parameter 'phydev' here
static inline int phy_write(struct phy_device *phydev, u32 regnum, u16 val)
^
drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c:315:12: error: incompatible pointer types passing 'struct phy *' to parameter of type 'struct phy_device *' [-Werror,-Wincompatible-pointer-types]
phy_write(phy, CN(priv->cfg.cn), DPHY_CN);
^~~
include/linux/phy.h:987:48: note: passing argument to parameter 'phydev' here
static inline int phy_write(struct phy_device *phydev, u32 regnum, u16 val)
^
drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c:316:12: error: incompatible pointer types passing 'struct phy *' to parameter of type 'struct phy_device *' [-Werror,-Wincompatible-pointer-types]
phy_write(phy, CO(priv->cfg.co), DPHY_CO);
^~~
include/linux/phy.h:987:48: note: passing argument to parameter 'phydev' here
static inline int phy_write(struct phy_device *phydev, u32 regnum, u16 val)
^
drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c:333:12: error: incompatible pointer types passing 'struct phy *' to parameter of type 'struct phy_device *' [-Werror,-Wincompatible-pointer-types]
phy_write(phy, 0x00, DPHY_LOCK_BYP);
^~~
include/linux/phy.h:987:48: note: passing argument to parameter 'phydev' here
static inline int phy_write(struct phy_device *phydev, u32 regnum, u16 val)
^
drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c:334:12: error: incompatible pointer types passing 'struct phy *' to parameter of type 'struct phy_device *' [-Werror,-Wincompatible-pointer-types]
phy_write(phy, 0x01, priv->devdata->reg_tx_rcal);
^~~
include/linux/phy.h:987:48: note: passing argument to parameter 'phydev' here
static inline int phy_write(struct phy_device *phydev, u32 regnum, u16 val)
^
drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c:335:12: error: incompatible pointer types passing 'struct phy *' to parameter of type 'struct phy_device *' [-Werror,-Wincompatible-pointer-types]
phy_write(phy, 0x00, priv->devdata->reg_auto_pd_en);
^~~
include/linux/phy.h:987:48: note: passing argument to parameter 'phydev' here
static inline int phy_write(struct phy_device *phydev, u32 regnum, u16 val)
^
drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c:336:12: error: incompatible pointer types passing 'struct phy *' to parameter of type 'struct phy_device *' [-Werror,-Wincompatible-pointer-types]
phy_write(phy, 0x02, priv->devdata->reg_rxlprp);
^~~
include/linux/phy.h:987:48: note: passing argument to parameter 'phydev' here
static inline int phy_write(struct phy_device *phydev, u32 regnum, u16 val)
^
drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c:337:12: error: incompatible pointer types passing 'struct phy *' to parameter of type 'struct phy_device *' [-Werror,-Wincompatible-pointer-types]
phy_write(phy, 0x02, priv->devdata->reg_rxcdrp);
^~~
include/linux/phy.h:987:48: note: passing argument to parameter 'phydev' here
static inline int phy_write(struct phy_device *phydev, u32 regnum, u16 val)
^
drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c:338:12: error: incompatible pointer types passing 'struct phy *' to parameter of type 'struct phy_device *' [-Werror,-Wincompatible-pointer-types]
phy_write(phy, 0x25, DPHY_TST);
^~~
include/linux/phy.h:987:48: note: passing argument to parameter 'phydev' here
static inline int phy_write(struct phy_device *phydev, u32 regnum, u16 val)
^
drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c:361:12: error: incompatible pointer types passing 'struct phy *' to parameter of type 'struct phy_device *' [-Werror,-Wincompatible-pointer-types]
phy_write(phy, PWR_OFF, DPHY_PD_PLL);
^~~ include/linux/phy.h:987:48: note: passing argument to parameter 'phydev' here static inline int phy_write(struct phy_device *phydev, u32 regnum, u16 val)
vim +292 drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c
f4c8116e294b12c Guido Günther 2019-06-20 109
f4c8116e294b12c Guido Günther 2019-06-20 @110 static int phy_write(struct phy *phy, u32 value, unsigned int reg)
f4c8116e294b12c Guido Günther 2019-06-20 111 {
f4c8116e294b12c Guido Günther 2019-06-20 112 struct mixel_dphy_priv *priv = phy_get_drvdata(phy);
f4c8116e294b12c Guido Günther 2019-06-20 113 int ret;
f4c8116e294b12c Guido Günther 2019-06-20 114
f4c8116e294b12c Guido Günther 2019-06-20 115 ret = regmap_write(priv->regmap, reg, value);
f4c8116e294b12c Guido Günther 2019-06-20 116 if (ret < 0)
f4c8116e294b12c Guido Günther 2019-06-20 117 dev_err(&phy->dev, "Failed to write DPHY reg %d: %d\n", reg,
f4c8116e294b12c Guido Günther 2019-06-20 118 ret);
f4c8116e294b12c Guido Günther 2019-06-20 119 return ret;
f4c8116e294b12c Guido Günther 2019-06-20 120 }
f4c8116e294b12c Guido Günther 2019-06-20 121
f4c8116e294b12c Guido Günther 2019-06-20 122 /*
f4c8116e294b12c Guido Günther 2019-06-20 123 * Find a ratio close to the desired one using continued fraction
f4c8116e294b12c Guido Günther 2019-06-20 124 * approximation ending either at exact match or maximum allowed
f4c8116e294b12c Guido Günther 2019-06-20 125 * nominator, denominator.
f4c8116e294b12c Guido Günther 2019-06-20 126 */
f4c8116e294b12c Guido Günther 2019-06-20 127 static void get_best_ratio(u32 *pnum, u32 *pdenom, u32 max_n, u32 max_d)
f4c8116e294b12c Guido Günther 2019-06-20 128 {
f4c8116e294b12c Guido Günther 2019-06-20 129 u32 a = *pnum;
f4c8116e294b12c Guido Günther 2019-06-20 130 u32 b = *pdenom;
f4c8116e294b12c Guido Günther 2019-06-20 131 u32 c;
f4c8116e294b12c Guido Günther 2019-06-20 132 u32 n[] = {0, 1};
f4c8116e294b12c Guido Günther 2019-06-20 133 u32 d[] = {1, 0};
f4c8116e294b12c Guido Günther 2019-06-20 134 u32 whole;
f4c8116e294b12c Guido Günther 2019-06-20 135 unsigned int i = 1;
f4c8116e294b12c Guido Günther 2019-06-20 136
f4c8116e294b12c Guido Günther 2019-06-20 137 while (b) {
f4c8116e294b12c Guido Günther 2019-06-20 138 i ^= 1;
f4c8116e294b12c Guido Günther 2019-06-20 139 whole = a / b;
f4c8116e294b12c Guido Günther 2019-06-20 140 n[i] += (n[i ^ 1] * whole);
f4c8116e294b12c Guido Günther 2019-06-20 141 d[i] += (d[i ^ 1] * whole);
f4c8116e294b12c Guido Günther 2019-06-20 142 if ((n[i] > max_n) || (d[i] > max_d)) {
f4c8116e294b12c Guido Günther 2019-06-20 143 i ^= 1;
f4c8116e294b12c Guido Günther 2019-06-20 144 break;
f4c8116e294b12c Guido Günther 2019-06-20 145 }
f4c8116e294b12c Guido Günther 2019-06-20 146 c = a - (b * whole);
f4c8116e294b12c Guido Günther 2019-06-20 147 a = b;
f4c8116e294b12c Guido Günther 2019-06-20 148 b = c;
f4c8116e294b12c Guido Günther 2019-06-20 149 }
f4c8116e294b12c Guido Günther 2019-06-20 150 *pnum = n[i];
f4c8116e294b12c Guido Günther 2019-06-20 151 *pdenom = d[i];
f4c8116e294b12c Guido Günther 2019-06-20 152 }
f4c8116e294b12c Guido Günther 2019-06-20 153
f4c8116e294b12c Guido Günther 2019-06-20 154 static int mixel_dphy_config_from_opts(struct phy *phy,
f4c8116e294b12c Guido Günther 2019-06-20 155 struct phy_configure_opts_mipi_dphy *dphy_opts,
f4c8116e294b12c Guido Günther 2019-06-20 156 struct mixel_dphy_cfg *cfg)
f4c8116e294b12c Guido Günther 2019-06-20 157 {
f4c8116e294b12c Guido Günther 2019-06-20 158 struct mixel_dphy_priv *priv = dev_get_drvdata(phy->dev.parent);
f4c8116e294b12c Guido Günther 2019-06-20 159 unsigned long ref_clk = clk_get_rate(priv->phy_ref_clk);
f4c8116e294b12c Guido Günther 2019-06-20 160 u32 lp_t, numerator, denominator;
f4c8116e294b12c Guido Günther 2019-06-20 161 unsigned long long tmp;
f4c8116e294b12c Guido Günther 2019-06-20 162 u32 n;
f4c8116e294b12c Guido Günther 2019-06-20 163 int i;
f4c8116e294b12c Guido Günther 2019-06-20 164
f4c8116e294b12c Guido Günther 2019-06-20 165 if (dphy_opts->hs_clk_rate > DATA_RATE_MAX_SPEED ||
f4c8116e294b12c Guido Günther 2019-06-20 166 dphy_opts->hs_clk_rate < DATA_RATE_MIN_SPEED)
f4c8116e294b12c Guido Günther 2019-06-20 167 return -EINVAL;
f4c8116e294b12c Guido Günther 2019-06-20 168
f4c8116e294b12c Guido Günther 2019-06-20 169 numerator = dphy_opts->hs_clk_rate;
f4c8116e294b12c Guido Günther 2019-06-20 170 denominator = ref_clk;
f4c8116e294b12c Guido Günther 2019-06-20 171 get_best_ratio(&numerator, &denominator, 255, 256);
f4c8116e294b12c Guido Günther 2019-06-20 172 if (!numerator || !denominator) {
f4c8116e294b12c Guido Günther 2019-06-20 173 dev_err(&phy->dev, "Invalid %d/%d for %ld/%ld\n",
f4c8116e294b12c Guido Günther 2019-06-20 174 numerator, denominator,
f4c8116e294b12c Guido Günther 2019-06-20 175 dphy_opts->hs_clk_rate, ref_clk);
f4c8116e294b12c Guido Günther 2019-06-20 176 return -EINVAL;
f4c8116e294b12c Guido Günther 2019-06-20 177 }
f4c8116e294b12c Guido Günther 2019-06-20 178
f4c8116e294b12c Guido Günther 2019-06-20 179 while ((numerator < 16) && (denominator <= 128)) {
f4c8116e294b12c Guido Günther 2019-06-20 180 numerator <<= 1;
f4c8116e294b12c Guido Günther 2019-06-20 181 denominator <<= 1;
f4c8116e294b12c Guido Günther 2019-06-20 182 }
f4c8116e294b12c Guido Günther 2019-06-20 183 /*
f4c8116e294b12c Guido Günther 2019-06-20 184 * CM ranges between 16 and 255
f4c8116e294b12c Guido Günther 2019-06-20 185 * CN ranges between 1 and 32
f4c8116e294b12c Guido Günther 2019-06-20 186 * CO is power of 2: 1, 2, 4, 8
f4c8116e294b12c Guido Günther 2019-06-20 187 */
f4c8116e294b12c Guido Günther 2019-06-20 188 i = __ffs(denominator);
f4c8116e294b12c Guido Günther 2019-06-20 189 if (i > 3)
f4c8116e294b12c Guido Günther 2019-06-20 190 i = 3;
f4c8116e294b12c Guido Günther 2019-06-20 191 cfg->cn = denominator >> i;
f4c8116e294b12c Guido Günther 2019-06-20 192 cfg->co = 1 << i;
f4c8116e294b12c Guido Günther 2019-06-20 193 cfg->cm = numerator;
f4c8116e294b12c Guido Günther 2019-06-20 194
f4c8116e294b12c Guido Günther 2019-06-20 195 if (cfg->cm < 16 || cfg->cm > 255 ||
f4c8116e294b12c Guido Günther 2019-06-20 196 cfg->cn < 1 || cfg->cn > 32 ||
f4c8116e294b12c Guido Günther 2019-06-20 197 cfg->co < 1 || cfg->co > 8) {
f4c8116e294b12c Guido Günther 2019-06-20 198 dev_err(&phy->dev, "Invalid CM/CN/CO values: %u/%u/%u\n",
f4c8116e294b12c Guido Günther 2019-06-20 199 cfg->cm, cfg->cn, cfg->co);
f4c8116e294b12c Guido Günther 2019-06-20 200 dev_err(&phy->dev, "for hs_clk/ref_clk=%ld/%ld ~ %d/%d\n",
f4c8116e294b12c Guido Günther 2019-06-20 201 dphy_opts->hs_clk_rate, ref_clk,
f4c8116e294b12c Guido Günther 2019-06-20 202 numerator, denominator);
f4c8116e294b12c Guido Günther 2019-06-20 203 return -EINVAL;
f4c8116e294b12c Guido Günther 2019-06-20 204 }
f4c8116e294b12c Guido Günther 2019-06-20 205
f4c8116e294b12c Guido Günther 2019-06-20 206 dev_dbg(&phy->dev, "hs_clk/ref_clk=%ld/%ld ~ %d/%d\n",
f4c8116e294b12c Guido Günther 2019-06-20 207 dphy_opts->hs_clk_rate, ref_clk, numerator, denominator);
f4c8116e294b12c Guido Günther 2019-06-20 208
f4c8116e294b12c Guido Günther 2019-06-20 209 /* LP clock period */
f4c8116e294b12c Guido Günther 2019-06-20 210 tmp = 1000000000000LL;
f4c8116e294b12c Guido Günther 2019-06-20 211 do_div(tmp, dphy_opts->lp_clk_rate); /* ps */
f4c8116e294b12c Guido Günther 2019-06-20 212 if (tmp > ULONG_MAX)
f4c8116e294b12c Guido Günther 2019-06-20 213 return -EINVAL;
f4c8116e294b12c Guido Günther 2019-06-20 214
f4c8116e294b12c Guido Günther 2019-06-20 215 lp_t = tmp;
f4c8116e294b12c Guido Günther 2019-06-20 216 dev_dbg(&phy->dev, "LP clock %lu, period: %u ps\n",
f4c8116e294b12c Guido Günther 2019-06-20 217 dphy_opts->lp_clk_rate, lp_t);
f4c8116e294b12c Guido Günther 2019-06-20 218
f4c8116e294b12c Guido Günther 2019-06-20 219 /* hs_prepare: in lp clock periods */
f4c8116e294b12c Guido Günther 2019-06-20 220 if (2 * dphy_opts->hs_prepare > 5 * lp_t) {
f4c8116e294b12c Guido Günther 2019-06-20 221 dev_err(&phy->dev,
f4c8116e294b12c Guido Günther 2019-06-20 222 "hs_prepare (%u) > 2.5 * lp clock period (%u)\n",
f4c8116e294b12c Guido Günther 2019-06-20 223 dphy_opts->hs_prepare, lp_t);
f4c8116e294b12c Guido Günther 2019-06-20 224 return -EINVAL;
f4c8116e294b12c Guido Günther 2019-06-20 225 }
f4c8116e294b12c Guido Günther 2019-06-20 226 /* 00: lp_t, 01: 1.5 * lp_t, 10: 2 * lp_t, 11: 2.5 * lp_t */
f4c8116e294b12c Guido Günther 2019-06-20 227 if (dphy_opts->hs_prepare < lp_t) {
f4c8116e294b12c Guido Günther 2019-06-20 228 n = 0;
f4c8116e294b12c Guido Günther 2019-06-20 229 } else {
f4c8116e294b12c Guido Günther 2019-06-20 230 tmp = 2 * (dphy_opts->hs_prepare - lp_t);
f4c8116e294b12c Guido Günther 2019-06-20 231 do_div(tmp, lp_t);
f4c8116e294b12c Guido Günther 2019-06-20 232 n = tmp;
f4c8116e294b12c Guido Günther 2019-06-20 233 }
f4c8116e294b12c Guido Günther 2019-06-20 234 cfg->m_prg_hs_prepare = n;
f4c8116e294b12c Guido Günther 2019-06-20 235
f4c8116e294b12c Guido Günther 2019-06-20 236 /* clk_prepare: in lp clock periods */
f4c8116e294b12c Guido Günther 2019-06-20 237 if (2 * dphy_opts->clk_prepare > 3 * lp_t) {
f4c8116e294b12c Guido Günther 2019-06-20 238 dev_err(&phy->dev,
f4c8116e294b12c Guido Günther 2019-06-20 239 "clk_prepare (%u) > 1.5 * lp clock period (%u)\n",
f4c8116e294b12c Guido Günther 2019-06-20 240 dphy_opts->clk_prepare, lp_t);
f4c8116e294b12c Guido Günther 2019-06-20 241 return -EINVAL;
f4c8116e294b12c Guido Günther 2019-06-20 242 }
f4c8116e294b12c Guido Günther 2019-06-20 243 /* 00: lp_t, 01: 1.5 * lp_t */
f4c8116e294b12c Guido Günther 2019-06-20 244 cfg->mc_prg_hs_prepare = dphy_opts->clk_prepare > lp_t ? 1 : 0;
f4c8116e294b12c Guido Günther 2019-06-20 245
f4c8116e294b12c Guido Günther 2019-06-20 246 /* hs_zero: formula from NXP BSP */
f4c8116e294b12c Guido Günther 2019-06-20 247 n = (144 * (dphy_opts->hs_clk_rate / 1000000) - 47500) / 10000;
f4c8116e294b12c Guido Günther 2019-06-20 248 cfg->m_prg_hs_zero = n < 1 ? 1 : n;
f4c8116e294b12c Guido Günther 2019-06-20 249
f4c8116e294b12c Guido Günther 2019-06-20 250 /* clk_zero: formula from NXP BSP */
f4c8116e294b12c Guido Günther 2019-06-20 251 n = (34 * (dphy_opts->hs_clk_rate / 1000000) - 2500) / 1000;
f4c8116e294b12c Guido Günther 2019-06-20 252 cfg->mc_prg_hs_zero = n < 1 ? 1 : n;
f4c8116e294b12c Guido Günther 2019-06-20 253
f4c8116e294b12c Guido Günther 2019-06-20 254 /* clk_trail, hs_trail: formula from NXP BSP */
f4c8116e294b12c Guido Günther 2019-06-20 255 n = (103 * (dphy_opts->hs_clk_rate / 1000000) + 10000) / 10000;
f4c8116e294b12c Guido Günther 2019-06-20 256 if (n > 15)
f4c8116e294b12c Guido Günther 2019-06-20 257 n = 15;
f4c8116e294b12c Guido Günther 2019-06-20 258 if (n < 1)
f4c8116e294b12c Guido Günther 2019-06-20 259 n = 1;
f4c8116e294b12c Guido Günther 2019-06-20 260 cfg->m_prg_hs_trail = n;
f4c8116e294b12c Guido Günther 2019-06-20 261 cfg->mc_prg_hs_trail = n;
f4c8116e294b12c Guido Günther 2019-06-20 262
f4c8116e294b12c Guido Günther 2019-06-20 263 /* rxhs_settle: formula from NXP BSP */
f4c8116e294b12c Guido Günther 2019-06-20 264 if (dphy_opts->hs_clk_rate < MBPS(80))
f4c8116e294b12c Guido Günther 2019-06-20 265 cfg->rxhs_settle = 0x0d;
f4c8116e294b12c Guido Günther 2019-06-20 266 else if (dphy_opts->hs_clk_rate < MBPS(90))
f4c8116e294b12c Guido Günther 2019-06-20 267 cfg->rxhs_settle = 0x0c;
f4c8116e294b12c Guido Günther 2019-06-20 268 else if (dphy_opts->hs_clk_rate < MBPS(125))
f4c8116e294b12c Guido Günther 2019-06-20 269 cfg->rxhs_settle = 0x0b;
f4c8116e294b12c Guido Günther 2019-06-20 270 else if (dphy_opts->hs_clk_rate < MBPS(150))
f4c8116e294b12c Guido Günther 2019-06-20 271 cfg->rxhs_settle = 0x0a;
f4c8116e294b12c Guido Günther 2019-06-20 272 else if (dphy_opts->hs_clk_rate < MBPS(225))
f4c8116e294b12c Guido Günther 2019-06-20 273 cfg->rxhs_settle = 0x09;
f4c8116e294b12c Guido Günther 2019-06-20 274 else if (dphy_opts->hs_clk_rate < MBPS(500))
f4c8116e294b12c Guido Günther 2019-06-20 275 cfg->rxhs_settle = 0x08;
f4c8116e294b12c Guido Günther 2019-06-20 276 else
f4c8116e294b12c Guido Günther 2019-06-20 277 cfg->rxhs_settle = 0x07;
f4c8116e294b12c Guido Günther 2019-06-20 278
f4c8116e294b12c Guido Günther 2019-06-20 279 dev_dbg(&phy->dev, "phy_config: %u %u %u %u %u %u %u\n",
f4c8116e294b12c Guido Günther 2019-06-20 280 cfg->m_prg_hs_prepare, cfg->mc_prg_hs_prepare,
f4c8116e294b12c Guido Günther 2019-06-20 281 cfg->m_prg_hs_zero, cfg->mc_prg_hs_zero,
f4c8116e294b12c Guido Günther 2019-06-20 282 cfg->m_prg_hs_trail, cfg->mc_prg_hs_trail,
f4c8116e294b12c Guido Günther 2019-06-20 283 cfg->rxhs_settle);
f4c8116e294b12c Guido Günther 2019-06-20 284
f4c8116e294b12c Guido Günther 2019-06-20 285 return 0;
f4c8116e294b12c Guido Günther 2019-06-20 286 }
f4c8116e294b12c Guido Günther 2019-06-20 287
f4c8116e294b12c Guido Günther 2019-06-20 288 static void mixel_phy_set_hs_timings(struct phy *phy)
f4c8116e294b12c Guido Günther 2019-06-20 289 {
f4c8116e294b12c Guido Günther 2019-06-20 290 struct mixel_dphy_priv *priv = phy_get_drvdata(phy);
f4c8116e294b12c Guido Günther 2019-06-20 291
f4c8116e294b12c Guido Günther 2019-06-20 @292 phy_write(phy, priv->cfg.m_prg_hs_prepare, DPHY_M_PRG_HS_PREPARE);
f4c8116e294b12c Guido Günther 2019-06-20 293 phy_write(phy, priv->cfg.mc_prg_hs_prepare, DPHY_MC_PRG_HS_PREPARE);
f4c8116e294b12c Guido Günther 2019-06-20 294 phy_write(phy, priv->cfg.m_prg_hs_zero, DPHY_M_PRG_HS_ZERO);
f4c8116e294b12c Guido Günther 2019-06-20 295 phy_write(phy, priv->cfg.mc_prg_hs_zero, DPHY_MC_PRG_HS_ZERO);
f4c8116e294b12c Guido Günther 2019-06-20 296 phy_write(phy, priv->cfg.m_prg_hs_trail, DPHY_M_PRG_HS_TRAIL);
f4c8116e294b12c Guido Günther 2019-06-20 297 phy_write(phy, priv->cfg.mc_prg_hs_trail, DPHY_MC_PRG_HS_TRAIL);
f4c8116e294b12c Guido Günther 2019-06-20 298 phy_write(phy, priv->cfg.rxhs_settle, priv->devdata->reg_rxhs_settle);
f4c8116e294b12c Guido Günther 2019-06-20 299 }f4c8116e294b12c Guido Günther 2019-06-20 300
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
Steen Hegelund
maintainerPATCH v4 3/4 phy: Add Sparx5 ethernet serdes PHY driver
In reply to Steen HegelundAdd the Microchip Sparx5 ethernet serdes PHY driver for the 6G, 10G and 25G interfaces available in the Sparx5 SoC.
--- drivers/phy/Kconfig | 3 +- drivers/phy/Makefile | 1 + drivers/phy/microchip/Kconfig | 12 + drivers/phy/microchip/Makefile | 6 + drivers/phy/microchip/sparx5_serdes.c | 2479 +++++++++++++++++ drivers/phy/microchip/sparx5_serdes_regs.h | 2773 ++++++++++++++++++++ 6 files changed, 5273 insertions(+), 1 deletion(-) create mode 100644 drivers/phy/microchip/Kconfig create mode 100644 drivers/phy/microchip/Makefile create mode 100644 drivers/phy/microchip/sparx5_serdes.c create mode 100644 drivers/phy/microchip/sparx5_serdes_regs.h
drivers/phy/Kconfig +2 -1
@@ -66,9 +66,11 @@ source "drivers/phy/broadcom/Kconfig" source "drivers/phy/cadence/Kconfig" source "drivers/phy/freescale/Kconfig" source "drivers/phy/hisilicon/Kconfig" +source "drivers/phy/intel/Kconfig" source "drivers/phy/lantiq/Kconfig" source "drivers/phy/marvell/Kconfig" source "drivers/phy/mediatek/Kconfig" +source "drivers/phy/microchip/Kconfig" source "drivers/phy/motorola/Kconfig" source "drivers/phy/mscc/Kconfig" source "drivers/phy/qualcomm/Kconfig"
@@ -80,7 +82,6 @@ source "drivers/phy/socionext/Kconfig" source "drivers/phy/st/Kconfig" source "drivers/phy/tegra/Kconfig" source "drivers/phy/ti/Kconfig" -source "drivers/phy/intel/Kconfig" source "drivers/phy/xilinx/Kconfig" endmenu
drivers/phy/Makefile +1 -0
@@ -19,6 +19,7 @@ obj-y += allwinner/ \ lantiq/ \ marvell/ \ mediatek/ \ + microchip/ \ motorola/ \ mscc/ \ qualcomm/ \
drivers/phy/microchip/Kconfig new file +12 -0
@@ -0,0 +1,12 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# Phy drivers for Microchip devices +# + +config PHY_SPARX5_SERDES + tristate "Microchip Sparx5 SerDes PHY driver" + select GENERIC_PHY + depends on OF + depends on HAS_IOMEM + help + Enable this for support of the 10G/25G SerDes on Microchip Sparx5.
drivers/phy/microchip/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# Makefile for the Microchip phy drivers. +# + +obj-$(CONFIG_PHY_SPARX5_SERDES) := sparx5_serdes.o
drivers/phy/microchip/sparx5_serdes.c new file +2479 -0
2,479 lines not on this page · raw message
drivers/phy/microchip/sparx5_serdes_regs.h new file +2773 -0
478 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.29.2
Part of the diff is not shown here. View the raw message.
Steen Hegelund
maintainerPATCH v4 4/4 arm64: dts: sparx5: Add Sparx5 serdes driver node
In reply to Steen HegelundAdd Sparx5 serdes driver node, and enable it generally for all reference boards.
--- arch/arm64/boot/dts/microchip/sparx5.dtsi | 196 ++++++++++++++++++++++ 1 file changed, 196 insertions(+)
arch/arm64/boot/dts/microchip/sparx5.dtsi +196 -0
@@ -287,5 +287,201 @@ tmon0: tmon@610508110 { #thermal-sensor-cells = <0>; clocks = <&ahb_clk>; }; + + serdes: serdes@10808000 { + compatible = "microchip,sparx5-serdes"; + #phy-cells = <1>; + clocks = <&sys_clk>; + reg = <0x6 0x10808000 0x8000>, /* sd_cmu_0 */ + <0x6 0x10810000 0x8000>, /* sd_cmu_1 */ + <0x6 0x10818000 0x8000>, /* sd_cmu_2 */ + <0x6 0x10820000 0x8000>, /* sd_cmu_3 */ + <0x6 0x10828000 0x8000>, /* sd_cmu_4 */ + <0x6 0x10830000 0x8000>, /* sd_cmu_5 */ + <0x6 0x10838000 0x8000>, /* sd_cmu_6 */ + <0x6 0x10840000 0x8000>, /* sd_cmu_7 */ + <0x6 0x10848000 0x8000>, /* sd_cmu_8 */ + <0x6 0x10850000 0x8000>, /* sd_cmu_cfg_0 */ + <0x6 0x10858000 0x8000>, /* sd_cmu_cfg_1 */ + <0x6 0x10860000 0x8000>, /* sd_cmu_cfg_2 */ + <0x6 0x10868000 0x8000>, /* sd_cmu_cfg_3 */ + <0x6 0x10870000 0x8000>, /* sd_cmu_cfg_4 */ + <0x6 0x10878000 0x8000>, /* sd_cmu_cfg_5 */ + <0x6 0x10880000 0x8000>, /* sd_cmu_cfg_6 */ + <0x6 0x10888000 0x8000>, /* sd_cmu_cfg_7 */ + <0x6 0x10890000 0x8000>, /* sd_cmu_cfg_8 */ + <0x6 0x10898000 0x8000>, /* sd6g_lane_0 */ + <0x6 0x108a0000 0x8000>, /* sd6g_lane_1 */ + <0x6 0x108a8000 0x8000>, /* sd6g_lane_2 */ + <0x6 0x108b0000 0x8000>, /* sd6g_lane_3 */ + <0x6 0x108b8000 0x8000>, /* sd6g_lane_4 */ + <0x6 0x108c0000 0x8000>, /* sd6g_lane_5 */ + <0x6 0x108c8000 0x8000>, /* sd6g_lane_6 */ + <0x6 0x108d0000 0x8000>, /* sd6g_lane_7 */ + <0x6 0x108d8000 0x8000>, /* sd6g_lane_8 */ + <0x6 0x108e0000 0x8000>, /* sd6g_lane_9 */ + <0x6 0x108e8000 0x8000>, /* sd6g_lane_10 */ + <0x6 0x108f0000 0x8000>, /* sd6g_lane_11 */ + <0x6 0x108f8000 0x8000>, /* sd6g_lane_12 */ + <0x6 0x10900000 0x8000>, /* sd10g_lane_0 */ + <0x6 0x10908000 0x8000>, /* sd10g_lane_1 */ + <0x6 0x10910000 0x8000>, /* sd10g_lane_2 */ + <0x6 0x10918000 0x8000>, /* sd10g_lane_3 */ + <0x6 0x109a8000 0x8000>, /* sd_lane_0 */ + <0x6 0x109b0000 0x8000>, /* sd_lane_1 */ + <0x6 0x109b8000 0x8000>, /* sd_lane_2 */ + <0x6 0x109c0000 0x8000>, /* sd_lane_3 */ + <0x6 0x109c8000 0x8000>, /* sd_lane_4 */ + <0x6 0x109d0000 0x8000>, /* sd_lane_5 */ + <0x6 0x109d8000 0x8000>, /* sd_lane_6 */ + <0x6 0x109e0000 0x8000>, /* sd_lane_7 */ + <0x6 0x109e8000 0x8000>, /* sd_lane_8 */ + <0x6 0x109f0000 0x8000>, /* sd_lane_9 */ + <0x6 0x109f8000 0x8000>, /* sd_lane_10 */ + <0x6 0x10a00000 0x8000>, /* sd_lane_11 */ + <0x6 0x10a08000 0x8000>, /* sd_lane_12 */ + <0x6 0x10a10000 0x8000>, /* sd_lane_13 */ + <0x6 0x10a18000 0x8000>, /* sd_lane_14 */ + <0x6 0x10a20000 0x8000>, /* sd_lane_15 */ + <0x6 0x10a28000 0x8000>, /* sd_lane_16 */ + <0x6 0x10c08000 0x8000>, /* sd_cmu_9 */ + <0x6 0x10c10000 0x8000>, /* sd_cmu_10 */ + <0x6 0x10c18000 0x8000>, /* sd_cmu_11 */ + <0x6 0x10c20000 0x8000>, /* sd_cmu_12 */ + <0x6 0x10c28000 0x8000>, /* sd_cmu_13 */ + <0x6 0x10c30000 0x8000>, /* sd_cmu_cfg_9 */ + <0x6 0x10c38000 0x8000>, /* sd_cmu_cfg_10 */ + <0x6 0x10c40000 0x8000>, /* sd_cmu_cfg_11 */ + <0x6 0x10c48000 0x8000>, /* sd_cmu_cfg_12 */ + <0x6 0x10c50000 0x8000>, /* sd_cmu_cfg_13 */ + <0x6 0x10c58000 0x8000>, /* sd10g_lane_4 */ + <0x6 0x10c60000 0x8000>, /* sd10g_lane_5 */ + <0x6 0x10c68000 0x8000>, /* sd10g_lane_6 */ + <0x6 0x10c70000 0x8000>, /* sd10g_lane_7 */ + <0x6 0x10c78000 0x8000>, /* sd10g_lane_8 */ + <0x6 0x10c80000 0x8000>, /* sd10g_lane_9 */ + <0x6 0x10c88000 0x8000>, /* sd10g_lane_10 */ + <0x6 0x10c90000 0x8000>, /* sd10g_lane_11 */ + <0x6 0x10c98000 0x8000>, /* sd25g_lane_0 */ + <0x6 0x10ca0000 0x8000>, /* sd25g_lane_1 */ + <0x6 0x10ca8000 0x8000>, /* sd25g_lane_2 */ + <0x6 0x10cb0000 0x8000>, /* sd25g_lane_3 */ + <0x6 0x10cb8000 0x8000>, /* sd25g_lane_4 */ + <0x6 0x10cc0000 0x8000>, /* sd25g_lane_5 */ + <0x6 0x10cc8000 0x8000>, /* sd25g_lane_6 */ + <0x6 0x10cd0000 0x8000>, /* sd25g_lane_7 */ + <0x6 0x10d58000 0x8000>, /* sd_lane_17 */ + <0x6 0x10d60000 0x8000>, /* sd_lane_18 */ + <0x6 0x10d68000 0x8000>, /* sd_lane_19 */ + <0x6 0x10d70000 0x8000>, /* sd_lane_20 */ + <0x6 0x10d78000 0x8000>, /* sd_lane_21 */ + <0x6 0x10d80000 0x8000>, /* sd_lane_22 */ + <0x6 0x10d88000 0x8000>, /* sd_lane_23 */ + <0x6 0x10d90000 0x8000>, /* sd_lane_24 */ + <0x6 0x10d98000 0x8000>, /* sd_lane_25g_25 */ + <0x6 0x10da0000 0x8000>, /* sd_lane_25g_26 */ + <0x6 0x10da8000 0x8000>, /* sd_lane_25g_27 */ + <0x6 0x10db0000 0x8000>, /* sd_lane_25g_28 */ + <0x6 0x10db8000 0x8000>, /* sd_lane_25g_29 */ + <0x6 0x10dc0000 0x8000>, /* sd_lane_25g_30 */ + <0x6 0x10dc8000 0x8000>, /* sd_lane_25g_31 */ + <0x6 0x10dd0000 0x8000>; /* sd_lane_25g_32 */ + reg-names = + "sd_cmu_0", + "sd_cmu_1", + "sd_cmu_2", + "sd_cmu_3", + "sd_cmu_4", + "sd_cmu_5", + "sd_cmu_6", + "sd_cmu_7", + "sd_cmu_8", + "sd_cmu_cfg_0", + "sd_cmu_cfg_1", + "sd_cmu_cfg_2", + "sd_cmu_cfg_3", + "sd_cmu_cfg_4", + "sd_cmu_cfg_5", + "sd_cmu_cfg_6", + "sd_cmu_cfg_7", + "sd_cmu_cfg_8", + "sd6g_lane_0", + "sd6g_lane_1", + "sd6g_lane_2", + "sd6g_lane_3", + "sd6g_lane_4", + "sd6g_lane_5", + "sd6g_lane_6", + "sd6g_lane_7", + "sd6g_lane_8", + "sd6g_lane_9", + "sd6g_lane_10", + "sd6g_lane_11", + "sd6g_lane_12", + "sd10g_lane_0", + "sd10g_lane_1", + "sd10g_lane_2", + "sd10g_lane_3", + "sd_lane_0", + "sd_lane_1", + "sd_lane_2", + "sd_lane_3", + "sd_lane_4", + "sd_lane_5", + "sd_lane_6", + "sd_lane_7", + "sd_lane_8", + "sd_lane_9", + "sd_lane_10", + "sd_lane_11", + "sd_lane_12", + "sd_lane_13", + "sd_lane_14", + "sd_lane_15", + "sd_lane_16", + "sd_cmu_9", + "sd_cmu_10", + "sd_cmu_11", + "sd_cmu_12", + "sd_cmu_13", + "sd_cmu_cfg_9", + "sd_cmu_cfg_10", + "sd_cmu_cfg_11", + "sd_cmu_cfg_12", + "sd_cmu_cfg_13", + "sd10g_lane_4", + "sd10g_lane_5", + "sd10g_lane_6", + "sd10g_lane_7", + "sd10g_lane_8", + "sd10g_lane_9", + "sd10g_lane_10", + "sd10g_lane_11", + "sd25g_lane_0", + "sd25g_lane_1", + "sd25g_lane_2", + "sd25g_lane_3", + "sd25g_lane_4", + "sd25g_lane_5", + "sd25g_lane_6", + "sd25g_lane_7", + "sd_lane_17", + "sd_lane_18", + "sd_lane_19", + "sd_lane_20", + "sd_lane_21", + "sd_lane_22", + "sd_lane_23", + "sd_lane_24", + "sd_lane_25g_25", + "sd_lane_25g_26", + "sd_lane_25g_27", + "sd_lane_25g_28", + "sd_lane_25g_29", + "sd_lane_25g_30", + "sd_lane_25g_31", + "sd_lane_25g_32"; + }; + }; };
Signature · 1 line
2.29.2