net: altera: tse: phylink conversion
Subsystems (5)
v2 cover net: altera: tse: phylink conversion
This is V2 of a series converting the Altera TSE driver to phylink, introducing a new PCS driver along the way.
The Altera TSE can be built with a SGMII/1000BaseX PCS, allowing to use SFP ports with this MAC, which is the end goal of adding phylink support and a proper PCS driver.
The PCS itself can either be mapped in the MAC's register space, in that case, it's accessed through 32 bits registers, with the higher 16 bits always 0. Alternatively, it can sit on its own register space, exposing 16 bits registers, some of which ressemble the standard PHY registers.
To tackle that rework, several things needs updating, starting by the DT binding, since we add support for a new register range for the PCS.
Hence, the first patch of the series is a conversion to YAML of the existing binding.
Then, patch 2 does a bit of simple cleanup to the TSE driver, using nice reverse xmas tree definitions.
Patch 3 adds the actual PCS driver, as a standalone driver. Some future series will then reuse that PCS driver from the dwmac-socfpga driver, which implements support for this exact PCS too, allowing to share the code nicely.
Patch 4 is then a phylink conversion of the altera_tse driver, to use this new PCS driver.
Finally, patch 5 updates the newly converted DT binding to support the pcs register range.
This series contains bits and pieces for this conversion, please tell me if you want me to send it as individual patches.
Thanks,
Maxime
V2 Changes :
- Fixed the binding after the YAML conversion
- Added a pcs_validate() callback
- Introduced a comment to justify a soft reset for the PCS
Maxime Chevallier (5):
dt-bindings: net: Convert Altera TSE bindings to yaml
net: altera: tse: cosmetic change to use reverse xmas tree ordering
net: pcs: add new PCS driver for altera TSE PCS
net: altera: tse: convert to phylink
dt-bindings: net: altera: tse: add an optional pcs register range
.../devicetree/bindings/net/altera_tse.txt | 113 ----- .../devicetree/bindings/net/altr,tse.yaml | 183 +++++++ MAINTAINERS | 7 + drivers/net/ethernet/altera/Kconfig | 2 + drivers/net/ethernet/altera/altera_tse.h | 19 +- .../net/ethernet/altera/altera_tse_ethtool.c | 22 +- drivers/net/ethernet/altera/altera_tse_main.c | 453 +++++------------- drivers/net/pcs/Kconfig | 6 + drivers/net/pcs/Makefile | 1 + drivers/net/pcs/pcs-altera-tse.c | 171 +++++++ include/linux/pcs-altera-tse.h | 17 + 11 files changed, 547 insertions(+), 447 deletions(-) delete mode 100644 Documentation/devicetree/bindings/net/altera_tse.txt create mode 100644 Documentation/devicetree/bindings/net/altr,tse.yaml create mode 100644 drivers/net/pcs/pcs-altera-tse.c create mode 100644 include/linux/pcs-altera-tse.h
Signature · 1 line
2.37.2
PATCH v2 1/5 dt-bindings: net: Convert Altera TSE bindings to yaml
This converts the bindings for the Altera Triple-Speed Ethernet to yaml.
---V1->V2:
- Removed unnedded maxItems
- Added missing minItems
- Fixed typos in some properties names
- Fixed the mdio subnode definition
.../devicetree/bindings/net/altera_tse.txt | 113 ------------- .../devicetree/bindings/net/altr,tse.yaml | 156 ++++++++++++++++++ 2 files changed, 156 insertions(+), 113 deletions(-) delete mode 100644 Documentation/devicetree/bindings/net/altera_tse.txt create mode 100644 Documentation/devicetree/bindings/net/altr,tse.yaml
Documentation/devicetree/bindings/net/altera_tse.txt deleted +0 -113
@@ -1,113 +0,0 @@ -* Altera Triple-Speed Ethernet MAC driver (TSE) - -Required properties: -- compatible: Should be "altr,tse-1.0" for legacy SGDMA based TSE, and should - be "altr,tse-msgdma-1.0" for the preferred MSGDMA based TSE. - ALTR is supported for legacy device trees, but is deprecated. - altr should be used for all new designs. -- reg: Address and length of the register set for the device. It contains - the information of registers in the same order as described by reg-names -- reg-names: Should contain the reg names - "control_port": MAC configuration space region - "tx_csr": xDMA Tx dispatcher control and status space region - "tx_desc": MSGDMA Tx dispatcher descriptor space region - "rx_csr" : xDMA Rx dispatcher control and status space region - "rx_desc": MSGDMA Rx dispatcher descriptor space region - "rx_resp": MSGDMA Rx dispatcher response space region - "s1": SGDMA descriptor memory -- interrupts: Should contain the TSE interrupts and its mode. -- interrupt-names: Should contain the interrupt names - "rx_irq": xDMA Rx dispatcher interrupt - "tx_irq": xDMA Tx dispatcher interrupt -- rx-fifo-depth: MAC receive FIFO buffer depth in bytes -- tx-fifo-depth: MAC transmit FIFO buffer depth in bytes -- phy-mode: See ethernet.txt in the same directory. -- phy-handle: See ethernet.txt in the same directory. -- phy-addr: See ethernet.txt in the same directory. A configuration should - include phy-handle or phy-addr. -- altr,has-supplementary-unicast: - If present, TSE supports additional unicast addresses. - Otherwise additional unicast addresses are not supported. -- altr,has-hash-multicast-filter: - If present, TSE supports a hash based multicast filter. - Otherwise, hash-based multicast filtering is not supported. - -- mdio device tree subnode: When the TSE has a phy connected to its local - mdio, there must be device tree subnode with the following - required properties: - - - compatible: Must be "altr,tse-mdio". - - #address-cells: Must be <1>. - - #size-cells: Must be <0>. - - For each phy on the mdio bus, there must be a node with the following - fields: - - - reg: phy id used to communicate to phy. - - device_type: Must be "ethernet-phy". - -The MAC address will be determined using the optional properties defined in -ethernet.txt. - -Example: - - tse_sub_0_eth_tse_0: ethernet@1,00000000 { - compatible = "altr,tse-msgdma-1.0"; - reg = <0x00000001 0x00000000 0x00000400>, - <0x00000001 0x00000460 0x00000020>, - <0x00000001 0x00000480 0x00000020>, - <0x00000001 0x000004A0 0x00000008>, - <0x00000001 0x00000400 0x00000020>, - <0x00000001 0x00000420 0x00000020>; - reg-names = "control_port", "rx_csr", "rx_desc", "rx_resp", "tx_csr", "tx_desc"; - interrupt-parent = <&hps_0_arm_gic_0>; - interrupts = <0 41 4>, <0 40 4>; - interrupt-names = "rx_irq", "tx_irq"; - rx-fifo-depth = <2048>; - tx-fifo-depth = <2048>; - address-bits = <48>; - max-frame-size = <1500>; - local-mac-address = [ 00 00 00 00 00 00 ]; - phy-mode = "gmii"; - altr,has-supplementary-unicast; - altr,has-hash-multicast-filter; - phy-handle = <&phy0>; - mdio { - compatible = "altr,tse-mdio"; - #address-cells = <1>; - #size-cells = <0>; - phy0: ethernet-phy@0 { - reg = <0x0>; - device_type = "ethernet-phy"; - }; - - phy1: ethernet-phy@1 { - reg = <0x1>; - device_type = "ethernet-phy"; - }; - - }; - }; - - tse_sub_1_eth_tse_0: ethernet@1,00001000 { - compatible = "altr,tse-msgdma-1.0"; - reg = <0x00000001 0x00001000 0x00000400>, - <0x00000001 0x00001460 0x00000020>, - <0x00000001 0x00001480 0x00000020>, - <0x00000001 0x000014A0 0x00000008>, - <0x00000001 0x00001400 0x00000020>, - <0x00000001 0x00001420 0x00000020>; - reg-names = "control_port", "rx_csr", "rx_desc", "rx_resp", "tx_csr", "tx_desc"; - interrupt-parent = <&hps_0_arm_gic_0>; - interrupts = <0 43 4>, <0 42 4>; - interrupt-names = "rx_irq", "tx_irq"; - rx-fifo-depth = <2048>; - tx-fifo-depth = <2048>; - address-bits = <48>; - max-frame-size = <1500>; - local-mac-address = [ 00 00 00 00 00 00 ]; - phy-mode = "gmii"; - altr,has-supplementary-unicast; - altr,has-hash-multicast-filter; - phy-handle = <&phy1>; - };
Documentation/devicetree/bindings/net/altr,tse.yaml new file +156 -0
156 lines not on this page · raw message
Signature · 1 line
2.37.2
Re: [PATCH net-next v2 1/5] dt-bindings: net: Convert Altera TSE bindings to yaml
Quoted 1 line · Maxime Chevallier
This converts the bindings for the Altera Triple-Speed Ethernet to yaml.
Do not use "This commit/patch".
https://elixir.bootlin.com/linux/v5.17.1/source/Documentation/process/submitting-patches.rst#L95
Quoted 2 lines
Signed-off-by Maxime Chevallier <[email protected]>
Rebase your changes on some decent kernel and use get_maintainers.pl...
Quoted 13 lines
---
V1->V2:
- Removed unnedded maxItems
- Added missing minItems
- Fixed typos in some properties names
- Fixed the mdio subnode definition.../devicetree/bindings/net/altera_tse.txt | 113 ------------- .../devicetree/bindings/net/altr,tse.yaml | 156 ++++++++++++++++++ 2 files changed, 156 insertions(+), 113 deletions(-) delete mode 100644 Documentation/devicetree/bindings/net/altera_tse.txt create mode 100644 Documentation/devicetree/bindings/net/altr,tse.yaml
(...)
Quoted 8 lines
Documentation/devicetree/bindings/net/altr,tse.yaml new file +2
-0@@ -0,0 +1,156 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2
Documentation/devicetree/bindings/net/altr,tse.yaml line 12
Quoted 10 lines
Documentation/devicetree/bindings/net/altr,tse.yaml new file +10
-0+--- +$id: http://devicetree.org/schemas/net/altr,tse.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Altera Triple Speed Ethernet MAC driver (TSE) + +maintainers: + - Maxime Chevallier <[email protected]> + +allOf:
Put allOf below "required".
Quoted 21 lines
Documentation/devicetree/bindings/net/altr,tse.yaml new file +21
-0+ - $ref: "ethernet-controller.yaml#" + - if: + properties: + compatible: + contains: + enum: + - altr,tse-1.0 + - ALTR,tse-1.0 + then: + properties: + reg: + minItems: 4 + reg-names: + items: + - const: control_port + - const: rx_csr + - const: tx_csr + - const: s1 + + - if: + properties:
Documentation/devicetree/bindings/net/altr,tse.yaml line 43
Quoted 10 lines
Documentation/devicetree/bindings/net/altr,tse.yaml new file +10
-0+ compatible: + contains: + enum: + - altr,tse-msgdma-1.0 + then: + properties: + reg: + minItems: 6 + reg-names: + minItems: 6
No need for minItems.
Documentation/devicetree/bindings/net/altr,tse.yaml line 56
Quoted 13 lines
Documentation/devicetree/bindings/net/altr,tse.yaml new file +13
-0+ items: + - const: control_port + - const: rx_csr + - const: rx_desc + - const: rx_resp + - const: tx_csr + - const: tx_desc + +properties: + compatible: + enum: + - altr,tse-1.0 + - ALTR,tse-1.0
This is deprecated compatible. You need oneOf and then deprecated: true.
Quoted 6 lines
Documentation/devicetree/bindings/net/altr,tse.yaml new file +6
-0+ - altr,tse-msgdma-1.0 + + reg: + minItems: 4 + maxItems: 6 +
Documentation/devicetree/bindings/net/altr,tse.yaml line 72
Quoted 10 lines
Documentation/devicetree/bindings/net/altr,tse.yaml new file +10
-0+ reg-names: + minItems: 4 + items: + - const: control_port + - const: rx_csr + - const: rx_desc + - const: rx_resp + - const: tx_csr + - const: tx_desc + - const: s1
This is messed up. You allow only 6 items maximum, but list 7. It contradicts your other variants in allOf:if:then.
Best regards,
Krzysztof
Re: [PATCH net-next v2 1/5] dt-bindings: net: Convert Altera TSE bindings to yaml
Quoted 6 lines · On Tue, 30 Aug 2022 20:13:56 +0300 Krzysztof Kozlowski…
Quoted 2 lines · Maxime Chevallier
This converts the bindings for the Altera Triple-Speed Ethernet to yaml.
Do not use "This commit/patch".
https://elixir.bootlin.com/linux/v5.17.1/source/Documentation/process/submitting-patches.rst#L95
ack
Quoted 5 lines
Quoted 2 lines
Signed-off-by Maxime Chevallier <[email protected]>Rebase your changes on some decent kernel and use
get_maintainers.pl...
I'm rebased against net-next, so I don't understand how I'm supposed to do for this series, should I sent binding patches separately and based on another tree ?
I'll cc you next time, sorry about that.
Quoted 28 lines
Quoted 13 lines
---
V1->V2:
- Removed unnedded maxItems
- Added missing minItems
- Fixed typos in some properties names
- Fixed the mdio subnode definition.../devicetree/bindings/net/altera_tse.txt | 113 ------------- .../devicetree/bindings/net/altr,tse.yaml | 156++++++++++++++++++ 2 files changed, 156 insertions(+), 113 deletions(-) delete mode 100644
Documentation/devicetree/bindings/net/altera_tse.txtcreate mode 100644Documentation/devicetree/bindings/net/altr,tse.yaml(...)
Quoted 12 lines
(quoted diff) +0
-0
b/Documentation/devicetree/bindings/net/altr,tse.yamlnew file mode 100644 index 000000000000..1676e13b8c64Documentation/devicetree/bindings/net/altr,tse.yaml new file +6
-0@@ -0,0 +1,156 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/altr,tse.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# +
Quoted 8 lines
Documentation/devicetree/bindings/net/altr,tse.yaml line 12
Quoted 6 lines
Documentation/devicetree/bindings/net/altr,tse.yaml new file +6
-0+title: Altera Triple Speed Ethernet MAC driver (TSE) + +maintainers: + - Maxime Chevallier <[email protected]> + +allOf:Put allOf below "required".
Ack
Quoted 32 lines
Quoted 21 lines
Documentation/devicetree/bindings/net/altr,tse.yaml new file +21
-0+ - $ref: "ethernet-controller.yaml#" + - if: + properties: + compatible: + contains: + enum: + - altr,tse-1.0 + - ALTR,tse-1.0 + then: + properties: + reg: + minItems: 4 + reg-names: + items: + - const: control_port + - const: rx_csr + - const: tx_csr + - const: s1 + + - if: + properties:Documentation/devicetree/bindings/net/altr,tse.yaml line 43
Quoted 10 lines
Documentation/devicetree/bindings/net/altr,tse.yaml new file +10
-0+ compatible: + contains: + enum: + - altr,tse-msgdma-1.0 + then: + properties: + reg: + minItems: 6 + reg-names: + minItems: 6
Quoted 1 line
No need for minItems.
Ok I'll remove it
Quoted 8 lines
Quoted 8 lines
Documentation/devicetree/bindings/net/altr,tse.yaml new file +8
-0+ items: + - const: control_port + - const: rx_csr + - const: rx_desc + - const: rx_resp + - const: tx_csr + - const: tx_desc +
Quoted 8 lines
Documentation/devicetree/bindings/net/altr,tse.yaml line 20
Quoted 5 lines
Documentation/devicetree/bindings/net/altr,tse.yaml new file +5
-0+properties: + compatible: + enum: + - altr,tse-1.0 + - ALTR,tse-1.0This is deprecated compatible. You need oneOf and then deprecated:
true.
Ok thanks for the tip
Quoted 11 lines
Quoted 11 lines
Documentation/devicetree/bindings/net/altr,tse.yaml new file +11
-0+ - altr,tse-msgdma-1.0 + + reg: + minItems: 4 + maxItems: 6 + + reg-names: + minItems: 4 + items: + - const: control_port + - const: rx_csr
Quoted 8 lines
Documentation/devicetree/bindings/net/altr,tse.yaml line 72
Quoted 5 lines
Documentation/devicetree/bindings/net/altr,tse.yaml new file +5
-0+ - const: rx_desc + - const: rx_resp + - const: tx_csr + - const: tx_desc + - const: s1This is messed up. You allow only 6 items maximum, but list 7. It contradicts your other variants in allOf:if:then.
I'll remove that part then, apparently it's not needed at all if the allOf:if:then cover all cases.
Thanks for the review,
Maxime
Quoted 3 lines
Best regards,
Krzysztof
Re: [PATCH net-next v2 1/5] dt-bindings: net: Convert Altera TSE bindings to yaml
Quoted 10 lines · Maxime Chevallier
Quoted 4 lines
Quoted 1 line
Signed-off-by Maxime Chevallier <[email protected]>Rebase your changes on some decent kernel and use
get_maintainers.pl...I'm rebased against net-next, so I don't understand how I'm supposed to do for this series, should I sent binding patches separately and based on another tree ?
I'll cc you next time, sorry about that.
net-next is correct, I just assumed it is some older tree since you did not Cc me.
Quoted 115 lines
Quoted 29 lines
Quoted 14 lines
---
V1->V2:
- Removed unnedded maxItems
- Added missing minItems
- Fixed typos in some properties names
- Fixed the mdio subnode definition.../devicetree/bindings/net/altera_tse.txt | 113 ------------- .../devicetree/bindings/net/altr,tse.yaml | 156++++++++++++++++++ 2 files changed, 156 insertions(+), 113 deletions(-) delete mode 100644
Documentation/devicetree/bindings/net/altera_tse.txtcreate mode 100644Documentation/devicetree/bindings/net/altr,tse.yaml(...)
Quoted 12 lines
(quoted diff) +0
-0
b/Documentation/devicetree/bindings/net/altr,tse.yamlnew file mode 100644 index 000000000000..1676e13b8c64Documentation/devicetree/bindings/net/altr,tse.yaml new file +6
-0@@ -0,0 +1,156 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/altr,tse.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# +Quoted 8 lines
Documentation/devicetree/bindings/net/altr,tse.yaml line 12
Quoted 6 lines
Documentation/devicetree/bindings/net/altr,tse.yaml new file +6
-0+title: Altera Triple Speed Ethernet MAC driver (TSE) + +maintainers: + - Maxime Chevallier <[email protected]> + +allOf:Put allOf below "required".
Ack
Quoted 32 lines
Quoted 21 lines
Documentation/devicetree/bindings/net/altr,tse.yaml new file +21
-0+ - $ref: "ethernet-controller.yaml#" + - if: + properties: + compatible: + contains: + enum: + - altr,tse-1.0 + - ALTR,tse-1.0 + then: + properties: + reg: + minItems: 4 + reg-names: + items: + - const: control_port + - const: rx_csr + - const: tx_csr + - const: s1 + + - if: + properties:Documentation/devicetree/bindings/net/altr,tse.yaml line 43
Quoted 10 lines
Documentation/devicetree/bindings/net/altr,tse.yaml new file +10
-0+ compatible: + contains: + enum: + - altr,tse-msgdma-1.0 + then: + properties: + reg: + minItems: 6 + reg-names: + minItems: 6Quoted 1 line
No need for minItems.
Ok I'll remove it
Quoted 8 lines
Quoted 8 lines
Documentation/devicetree/bindings/net/altr,tse.yaml new file +8
-0+ items: + - const: control_port + - const: rx_csr + - const: rx_desc + - const: rx_resp + - const: tx_csr + - const: tx_desc +Quoted 8 lines
Documentation/devicetree/bindings/net/altr,tse.yaml line 20
Quoted 5 lines
Documentation/devicetree/bindings/net/altr,tse.yaml new file +5
-0+properties: + compatible: + enum: + - altr,tse-1.0 + - ALTR,tse-1.0This is deprecated compatible. You need oneOf and then deprecated:
true.Ok thanks for the tip
Quoted 11 lines
Quoted 11 lines
Documentation/devicetree/bindings/net/altr,tse.yaml new file +11
-0+ - altr,tse-msgdma-1.0 + + reg: + minItems: 4 + maxItems: 6 + + reg-names: + minItems: 4 + items: + - const: control_port + - const: rx_csrQuoted 8 lines
Documentation/devicetree/bindings/net/altr,tse.yaml line 72
Quoted 5 lines
Documentation/devicetree/bindings/net/altr,tse.yaml new file +5
-0+ - const: rx_desc + - const: rx_resp + - const: tx_csr + - const: tx_desc + - const: s1This is messed up. You allow only 6 items maximum, but list 7. It contradicts your other variants in allOf:if:then.
Quoted 2 lines
I'll remove that part then, apparently it's not needed at all if the allOf:if:then cover all cases.
Right. The typical pattern is like clocks/clock-names here:
Best regards,
Krzysztof
PATCH v2 2/5 net: altera: tse: cosmetic change to use reverse xmas tree ordering
In reply to Maxime ChevallierThis commit is a strictly cosmetic change, to use the reverse xmas tree variable declaration ordering, and introduces no functional changes.
---V1->V2 : No changes
.../net/ethernet/altera/altera_tse_ethtool.c | 2 +- drivers/net/ethernet/altera/altera_tse_main.c | 43 ++++++++++--------- 2 files changed, 23 insertions(+), 22 deletions(-)
drivers/net/ethernet/altera/altera_tse_ethtool.c +1 -1
@@ -199,9 +199,9 @@ static int tse_reglen(struct net_device *dev)static void tse_get_regs (struct net_device *dev,struct ethtool_regs *regs,void *regbuf) { -int i;struct altera_tse_private *priv =netdev_priv (dev);u32 *buf = regbuf; +int i;/* Set version to a known value, so ethtool knows * how to do any special formatting of this data.
drivers/net/ethernet/altera/altera_tse_main.c +22 -21
149 lines not on this page · raw message
Signature · 1 line
2.37.2
PATCH v2 3/5 net: pcs: add new PCS driver for altera TSE PCS
In reply to Maxime ChevallierThe Altera Triple Speed Ethernet has a SGMII/1000BaseC PCS that can be integrated in several ways. It can either be part of the TSE MAC's address space, accessed through 32 bits accesses on the mapped mdio device 0, or through a dedicated 16 bits register set.
This driver allows using the TSE PCS outside of altera TSE's driver, since it can be used standalone by other MACs.
---V1->V2 :
- Added a pcs_validate() callback to filter interface modes
- Added comments on the need for a soft reset at an_restart
MAINTAINERS | 7 ++ drivers/net/pcs/Kconfig | 6 ++ drivers/net/pcs/Makefile | 1 + drivers/net/pcs/pcs-altera-tse.c | 171 +++++++++++++++++++++++++++++++ include/linux/pcs-altera-tse.h | 17 +++ 5 files changed, 202 insertions(+) create mode 100644 drivers/net/pcs/pcs-altera-tse.c create mode 100644 include/linux/pcs-altera-tse.h
MAINTAINERS +7 -0
@@ -878,6 +878,13 @@ L: [email protected] S: Maintained F: drivers/net/ethernet/altera/ +ALTERA TSE PCS +M: Maxime Chevallier <[email protected]> +L: [email protected] +S: Supported +F: drivers/net/pcs/pcs-altera-tse.c +F: include/linux/pcs-altera-tse.h + ALTERA UART/JTAG UART SERIAL DRIVERS M: Tobias Klauser <[email protected]> L: [email protected]
drivers/net/pcs/Kconfig +6 -0
@@ -26,4 +26,10 @@ config PCS_RZN1_MIIC on RZ/N1 SoCs. This PCS converts MII to RMII/RGMII or can be set in pass-through mode for MII. +config PCS_ALTERA_TSE + tristate + help + This module provides helper functions for the Altera Triple Speed + Ethernet SGMII PCS, that can be found on the Intel Socfpga family. + endmenu
drivers/net/pcs/Makefile +1 -0
@@ -6,3 +6,4 @@ pcs_xpcs-$(CONFIG_PCS_XPCS) := pcs-xpcs.o pcs-xpcs-nxp.o obj-$(CONFIG_PCS_XPCS) += pcs_xpcs.o obj-$(CONFIG_PCS_LYNX) += pcs-lynx.o obj-$(CONFIG_PCS_RZN1_MIIC) += pcs-rzn1-miic.o +obj-$(CONFIG_PCS_ALTERA_TSE) += pcs-altera-tse.o
drivers/net/pcs/pcs-altera-tse.c new file +171 -0
171 lines not on this page · raw message
include/linux/pcs-altera-tse.h new file +17 -0
@@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (C) 2022 Bootlin +* +* Maxime Chevallier <[email protected]> +*/ + +#ifndef __LINUX_PCS_ALTERA_TSE_H +#define __LINUX_PCS_ALTERA_TSE_H + +struct phylink_pcs ; +struct net_device ; + +struct phylink_pcs *alt_tse_pcs_create (struct net_device *ndev, +void __iomem *pcs_base,int reg_width); + +#endif /* __LINUX_PCS_ALTERA_TSE_H */
Signature · 1 line
2.37.2
PATCH v2 4/5 net: altera: tse: convert to phylink
In reply to Maxime ChevallierThis commit converts the Altera Triple Speed Ethernet Controller to phylink. This controller supports MII, GMII and RGMII with its MAC, and SGMII + 1000BaseX through a small embedded PCS.
The PCS itself has a register set very similar to what is found in a typical 802.3 ethernet PHY, but this register set memory-mapped instead of lying on an mdio bus.
---V1->V2 : Removed stray DT makefile patching that had nothing to do with this patch
drivers/net/ethernet/altera/Kconfig | 2 + drivers/net/ethernet/altera/altera_tse.h | 19 +- .../net/ethernet/altera/altera_tse_ethtool.c | 20 +- drivers/net/ethernet/altera/altera_tse_main.c | 414 +++++------------- 4 files changed, 141 insertions(+), 314 deletions(-)
drivers/net/ethernet/altera/Kconfig +2 -0
@@ -3,6 +3,8 @@ config ALTERA_TSE tristate "Altera Triple-Speed Ethernet MAC support" depends on HAS_DMA select PHYLIB + select PHYLINK + select PCS_ALTERA_TSE help This driver supports the Altera Triple-Speed (TSE) Ethernet MAC.
drivers/net/ethernet/altera/altera_tse.h +8 -11
@@ -27,6 +27,7 @@#include <linux/list.h> #include <linux/netdevice.h> #include <linux/phy.h> +#include <linux/phylink.h> #define ALTERA_TSE_SW_RESET_WATCHDOG_CNTR 10000#define ALTERA_TSE_MAC_FIFO_WIDTH 4/* TX/RX FIFO width in
@@ -109,17 +110,6 @@#define MAC_CMDCFG_DISABLE_READ_TIMEOUT_GET (v) GET_BIT_VALUE(v, 27)#define MAC_CMDCFG_CNT_RESET_GET (v) GET_BIT_VALUE(v, 31) -/* SGMII PCS register addresses -*/ -#define SGMII_PCS_SCRATCH 0x10 -#define SGMII_PCS_REV 0x11 -#define SGMII_PCS_LINK_TIMER_0 0x12 -#define SGMII_PCS_LINK_TIMER_1 0x13 -#define SGMII_PCS_IF_MODE 0x14 -#define SGMII_PCS_DIS_READ_TO 0x15 -#define SGMII_PCS_READ_TO 0x16 -#define SGMII_PCS_SW_RESET_TIMEOUT 100/* usecs */ -/* MDIO registers within MAC register Space */ struct altera_tse_mdio {
@@ -423,6 +413,9 @@ struct altera_tse_private {void __iomem *tx_dma_csr;void __iomem *tx_dma_desc; +/* SGMII PCS address space */ +void __iomem *pcs_base; +/* Rx buffers queue */ struct tse_buffer *rx_ring;u32 rx_cons;
@@ -480,6 +473,10 @@ struct altera_tse_private {u32 msg_enable;struct altera_dmaops *dmaops; + +struct phylink *phylink; +struct phylink_config phylink_config; +struct phylink_pcs *pcs; };/* Function prototypes
drivers/net/ethernet/altera/altera_tse_ethtool.c +18 -2
@@ -221,6 +221,22 @@ static void tse_get_regs(struct net_device *dev, struct ethtool_regs *regs, buf[i] =csrrd32 (priv->mac_dev, i *4 ); } +static int tse_ethtool_set_link_ksettings (struct net_device *dev, +const struct ethtool_link_ksettings *cmd) +{ +struct altera_tse_private *priv =netdev_priv (dev); + +return phylink_ethtool_ksettings_set (priv->phylink, cmd); +} + +static int tse_ethtool_get_link_ksettings (struct net_device *dev, +struct ethtool_link_ksettings *cmd) +{ +struct altera_tse_private *priv =netdev_priv (dev); + +return phylink_ethtool_ksettings_get (priv->phylink, cmd); +} +static const struct ethtool_ops tse_ethtool_ops = { .get_drvinfo = tse_get_drvinfo, .get_regs_len = tse_reglen,
@@ -231,8 +247,8 @@ static const struct ethtool_ops tse_ethtool_ops = { .get_ethtool_stats = tse_fill_stats, .get_msglevel = tse_get_msglevel, .set_msglevel = tse_set_msglevel, - .get_link_ksettings = phy_ethtool_get_link_ksettings, - .set_link_ksettings = phy_ethtool_set_link_ksettings, + .get_link_ksettings = tse_ethtool_get_link_ksettings, + .set_link_ksettings = tse_ethtool_set_link_ksettings, .get_ts_info = ethtool_op_get_ts_info, };
drivers/net/ethernet/altera/altera_tse_main.c +113 -301
499 lines not on this page · raw message
Signature · 1 line
2.37.2
PATCH v2 5/5 dt-bindings: net: altera: tse: add an optional pcs register range
In reply to Maxime ChevallierSome implementations of the TSE have their PCS as an external bloc, exposed at its own register range. Document this, and add a new example showing a case using the pcs and the new phylink conversion to connect an sfp port to a TSE mac.
---V1->V2 :
- Fixed example
.../devicetree/bindings/net/altr,tse.yaml | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/net/altr,tse.yaml +28 -1
@@ -39,6 +39,7 @@ allOf: properties: reg: minItems: 6 + maxItems: 7 reg-names: minItems: 6 items:
@@ -48,6 +49,7 @@ allOf: - const: rx_resp - const: tx_csr - const: tx_desc + - const: pcs properties: compatible:
@@ -58,7 +60,7 @@ properties: reg: minItems: 4 - maxItems: 6 + maxItems: 7 reg-names: minItems: 4
@@ -69,6 +71,7 @@ properties: - const: rx_resp - const: tx_csr - const: tx_desc + - const: pcs - const: s1 interrupts:
@@ -122,6 +125,30 @@ required: unevaluatedProperties: false examples: + - | + tse_sub_0: ethernet@c0100000 { + compatible = "altr,tse-msgdma-1.0"; + reg = <0xc0100000 0x00000400>, + <0xc0101000 0x00000020>, + <0xc0102000 0x00000020>, + <0xc0103000 0x00000008>, + <0xc0104000 0x00000020>, + <0xc0105000 0x00000020>, + <0xc0106000 0x00000100>; + reg-names = "control_port", "rx_csr", "rx_desc", "rx_resp", "tx_csr", "tx_desc", "pcs"; + interrupt-parent = <&intc>; + interrupts = <0 44 4>,<0 45 4>; + interrupt-names = "rx_irq","tx_irq"; + rx-fifo-depth = <2048>; + tx-fifo-depth = <2048>; + max-frame-size = <1500>; + local-mac-address = [ 00 0C ED 00 00 02 ]; + altr,has-supplementary-unicast; + altr,has-hash-multicast-filter; + sfp = <&sfp0>; + phy-mode = "sgmii"; + managed = "in-band-status"; + }; - | tse_sub_1_eth_tse_0: ethernet@1,00001000 { compatible = "altr,tse-msgdma-1.0";
Signature · 1 line
2.37.2
Re: [PATCH net-next v2 5/5] dt-bindings: net: altera: tse: add an optional pcs register range
Quoted 43 lines · Maxime Chevallier
Some implementations of the TSE have their PCS as an external bloc, exposed at its own register range. Document this, and add a new example showing a case using the pcs and the new phylink conversion to connect an sfp port to a TSE mac.
Signed-off-by Maxime Chevallier <[email protected]>---
V1->V2:
- Fixed example.../devicetree/bindings/net/altr,tse.yaml | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-)Documentation/devicetree/bindings/net/altr,tse.yaml +3
-1@@ -39,6 +39,7 @@ allOf: properties: reg: minItems: 6 + maxItems: 7 reg-names: minItems: 6 items:@@ -48,6 +49,7 @@ allOf: - const: rx_resp - const: tx_csr - const: tx_desc + - const: pcs properties: compatible:@@ -58,7 +60,7 @@ properties: reg: minItems: 4 - maxItems: 6 + maxItems: 7 reg-names: minItems: 4
Documentation/devicetree/bindings/net/altr,tse.yaml properties: · line 76
Quoted 6 lines
Documentation/devicetree/bindings/net/altr,tse.yaml +1
-0@@ -69,6 +71,7 @@ properties: - const: rx_resp - const: tx_csr - const: tx_desc + - const: pcs - const: s1
So now 8 items?
Quoted 13 lines
Documentation/devicetree/bindings/net/altr,tse.yaml +8
-0interrupts:@@ -122,6 +125,30 @@ required: unevaluatedProperties: false examples: + - | + tse_sub_0: ethernet@c0100000 { + compatible = "altr,tse-msgdma-1.0"; + reg = <0xc0100000 0x00000400>, + <0xc0101000 0x00000020>, + <0xc0102000 0x00000020>, + <0xc0103000 0x00000008>, + <0xc0104000 0x00000020>,
Documentation/devicetree/bindings/net/altr,tse.yaml required: · line 145
Quoted 10 lines
Documentation/devicetree/bindings/net/altr,tse.yaml +10
-0+ <0xc0105000 0x00000020>, + <0xc0106000 0x00000100>; + reg-names = "control_port", "rx_csr", "rx_desc", "rx_resp", "tx_csr", "tx_desc", "pcs"; + interrupt-parent = <&intc>; + interrupts = <0 44 4>,<0 45 4>; + interrupt-names = "rx_irq","tx_irq"; + rx-fifo-depth = <2048>; + tx-fifo-depth = <2048>; + max-frame-size = <1500>; + local-mac-address = [ 00 0C ED 00 00 02 ];
00 00 00 00 00 00
(easier to spot that it is invalid)
Best regards,
Krzysztof
Re: [PATCH net-next v2 5/5] dt-bindings: net: altera: tse: add an optional pcs register range
Quoted 41 lines · On Tue, 30 Aug 2022 20:14:52 +0300 Krzysztof Kozlowski…
Quoted 40 lines · Maxime Chevallier
Some implementations of the TSE have their PCS as an external bloc, exposed at its own register range. Document this, and add a new example showing a case using the pcs and the new phylink conversion to connect an sfp port to a TSE mac.
Signed-off-by Maxime Chevallier <[email protected]>---
V1->V2:
- Fixed example.../devicetree/bindings/net/altr,tse.yaml | 29++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-)
(quoted diff) +0
-0
b/Documentation/devicetree/bindings/net/altr,tse.yamlindex1676e13b8c64..4b314861a831100644 ---a/Documentation/devicetree/bindings/net/altr,tse.yaml+++b/Documentation/devicetree/bindings/net/altr,tse.yaml@@ -39,6 +39,7 @@ allOf: properties:
reg:
minItems: 6Documentation/devicetree/bindings/net/altr,tse.yaml +3
-1+ maxItems: 7 reg-names: minItems: 6 items:@@ -48,6 +49,7 @@ allOf: - const: rx_resp - const: tx_csr - const: tx_desc + - const: pcs properties: compatible:@@ -58,7 +60,7 @@ properties: reg: minItems: 4 - maxItems: 6 + maxItems: 7
Quoted 11 lines
Documentation/devicetree/bindings/net/altr,tse.yaml properties: · line 76
Quoted 9 lines
Documentation/devicetree/bindings/net/altr,tse.yaml +1
-0reg-names: minItems: 4@@ -69,6 +71,7 @@ properties: - const: rx_resp - const: tx_csr - const: tx_desc + - const: pcs - const: s1So now 8 items?
I'll also remove that. My understanding was that on top of the allOf:if/then, I was supposed to re-list all possible values. I got that wrong, so that's not needed at all.
Quoted 20 lines
Quoted 20 lines
Documentation/devicetree/bindings/net/altr,tse.yaml +13
-0interrupts:@@ -122,6 +125,30 @@ required: unevaluatedProperties: false examples: + - | + tse_sub_0: ethernet@c0100000 { + compatible = "altr,tse-msgdma-1.0"; + reg = <0xc0100000 0x00000400>, + <0xc0101000 0x00000020>, + <0xc0102000 0x00000020>, + <0xc0103000 0x00000008>, + <0xc0104000 0x00000020>, + <0xc0105000 0x00000020>, + <0xc0106000 0x00000100>; + reg-names = "control_port", "rx_csr", "rx_desc", "rx_resp", "tx_csr", "tx_desc", "pcs"; + interrupt-parent = <&intc>; + interrupts = <0 44 4>,<0 45 4>;
Quoted 8 lines
Documentation/devicetree/bindings/net/altr,tse.yaml required: · line 145
Quoted 5 lines
Documentation/devicetree/bindings/net/altr,tse.yaml +5
-0+ interrupt-names = "rx_irq","tx_irq"; + rx-fifo-depth = <2048>; + tx-fifo-depth = <2048>; + max-frame-size = <1500>; + local-mac-address = [ 00 0C ED 00 00 02 ];00 00 00 00 00 00
(easier to spot that it is invalid)
Ack, thanks !
Best regards,
Maxime
Quoted 3 lines
Best regards,
Krzysztof