2022-11-08 08:14:41

by Siddharth Vadapalli

[permalink] [raw]
Subject: [PATCH v4 0/3] Add support for QSGMII mode for J721e CPSW9G to am65-cpsw driver

Add compatible to am65-cpsw driver for J721e CPSW9G, which contains 8
external ports and 1 internal host port.

Add support to power on and power off the SERDES PHY which is used by the
CPSW MAC.

=========
Changelog
=========
v3 -> v4:
1. Fix subject of patch-1/3, updating it to:
"dt-bindings: net: ti: k3-am654-cpsw-nuss: Add J721e CPSW9G support"
and collect Reviewed-by tag.
2. Rebase series on linux-next tree tagged: next-20221107.

v2 -> v3:
1. Run 'make DT_CHECKER_FLAGS=-m dt_binding_check' and fix errors and
warnings corresponding to the patch for:
Documentation/devicetree/bindings/net/ti,k3-am654-cpsw-nuss.yaml
with the latest dt-schema and yamllint.

v1 -> v2:
1. Drop all patches corresponding to SGMII mode. This is done since I do
not have a method to test SGMII in the standard mode which uses an
SGMII PHY. The previous series used SGMII in a fixed-link mode,
bypassing the SGMII PHY. I will post the SGMII patches in a future
series after testing them.
2. Drop all patches corresponding to fixed-link in the am65-cpsw driver.
This is done since PHYLINK takes care of fixed-link automatically and
there is no need to deal with fixed-link in a custom fashion.
3. Fix indentation errors in k3-am65-cpsw-nuss.yaml.
4. Remove the stale code which tries to power on and power off the CPSW
MAC's phy, since the CPSW MAC's phy driver does not support it.
5. Rename the function "am65_cpsw_init_phy()" to
"am65_cpsw_init_serdes_phy()", to indicate that the phy corresponds to
the SERDES.
6. Invoke "am65_cpsw_disable_serdes_phy()" as a part of the cleanup that
is associated with the "am65_cpsw_nuss_remove()" function.

v3:
https://lore.kernel.org/r/[email protected]/
v2:
https://lore.kernel.org/r/[email protected]/
v1:
https://lore.kernel.org/r/[email protected]/

Siddharth Vadapalli (3):
dt-bindings: net: ti: k3-am654-cpsw-nuss: Add J721e CPSW9G support
net: ethernet: ti: am65-cpsw: Enable QSGMII mode for J721e CPSW9G
net: ethernet: ti: am65-cpsw: Add support for SERDES configuration

.../bindings/net/ti,k3-am654-cpsw-nuss.yaml | 33 ++++++++-
drivers/net/ethernet/ti/am65-cpsw-nuss.c | 73 +++++++++++++++++++
2 files changed, 102 insertions(+), 4 deletions(-)

--
2.25.1



2022-11-08 08:14:50

by Siddharth Vadapalli

[permalink] [raw]
Subject: [PATCH v4 1/3] dt-bindings: net: ti: k3-am654-cpsw-nuss: Add J721e CPSW9G support

Update bindings for TI K3 J721e SoC which contains 9 ports (8 external
ports) CPSW9G module and add compatible for it.

Changes made:
- Add new compatible ti,j721e-cpswxg-nuss for CPSW9G.
- Extend pattern properties for new compatible.
- Change maximum number of CPSW ports to 8 for new compatible.

Signed-off-by: Siddharth Vadapalli <[email protected]>
Reviewed-by: Rob Herring <[email protected]>
---
.../bindings/net/ti,k3-am654-cpsw-nuss.yaml | 33 ++++++++++++++++---
1 file changed, 29 insertions(+), 4 deletions(-)

diff --git a/Documentation/devicetree/bindings/net/ti,k3-am654-cpsw-nuss.yaml b/Documentation/devicetree/bindings/net/ti,k3-am654-cpsw-nuss.yaml
index 821974815dec..900063411a20 100644
--- a/Documentation/devicetree/bindings/net/ti,k3-am654-cpsw-nuss.yaml
+++ b/Documentation/devicetree/bindings/net/ti,k3-am654-cpsw-nuss.yaml
@@ -57,6 +57,7 @@ properties:
- ti,am654-cpsw-nuss
- ti,j7200-cpswxg-nuss
- ti,j721e-cpsw-nuss
+ - ti,j721e-cpswxg-nuss
- ti,am642-cpsw-nuss

reg:
@@ -111,7 +112,7 @@ properties:
const: 0

patternProperties:
- "^port@[1-4]$":
+ "^port@[1-8]$":
type: object
description: CPSWxG NUSS external ports

@@ -121,7 +122,7 @@ properties:
properties:
reg:
minimum: 1
- maximum: 4
+ maximum: 8
description: CPSW port number

phys:
@@ -186,12 +187,36 @@ allOf:
properties:
compatible:
contains:
- const: ti,j7200-cpswxg-nuss
+ const: ti,j721e-cpswxg-nuss
then:
properties:
ethernet-ports:
patternProperties:
- "^port@[3-4]$": false
+ "^port@[5-8]$": false
+ "^port@[1-4]$":
+ properties:
+ reg:
+ minimum: 1
+ maximum: 4
+
+ - if:
+ not:
+ properties:
+ compatible:
+ contains:
+ enum:
+ - ti,j721e-cpswxg-nuss
+ - ti,j7200-cpswxg-nuss
+ then:
+ properties:
+ ethernet-ports:
+ patternProperties:
+ "^port@[3-8]$": false
+ "^port@[1-2]$":
+ properties:
+ reg:
+ minimum: 1
+ maximum: 2

additionalProperties: false

--
2.25.1


2022-11-08 08:15:14

by Siddharth Vadapalli

[permalink] [raw]
Subject: [PATCH v4 3/3] net: ethernet: ti: am65-cpsw: Add support for SERDES configuration

Use PHY framework APIs to initialize the SERDES PHY connected to CPSW MAC.

Define the functions am65_cpsw_disable_phy(), am65_cpsw_enable_phy(),
am65_cpsw_disable_serdes_phy() and am65_cpsw_enable_serdes_phy().

Power on and initialize the SerDes PHY in am65_cpsw_nuss_init_slave_ports()
by invoking am65_cpsw_enable_serdes_phy().

Power off the SerDes PHY in am65_cpsw_nuss_remove() by invoking
am65_cpsw_disable_serdes_phy().

Signed-off-by: Siddharth Vadapalli <[email protected]>
---
drivers/net/ethernet/ti/am65-cpsw-nuss.c | 65 ++++++++++++++++++++++++
1 file changed, 65 insertions(+)

diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
index 4d4e1c8bd715..1234681c035a 100644
--- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c
+++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
@@ -1395,6 +1395,65 @@ static const struct net_device_ops am65_cpsw_nuss_netdev_ops = {
.ndo_setup_tc = am65_cpsw_qos_ndo_setup_tc,
};

+static void am65_cpsw_disable_phy(struct phy *phy)
+{
+ phy_power_off(phy);
+ phy_exit(phy);
+}
+
+static int am65_cpsw_enable_phy(struct phy *phy)
+{
+ int ret;
+
+ ret = phy_init(phy);
+ if (ret < 0)
+ return ret;
+
+ ret = phy_power_on(phy);
+ if (ret < 0) {
+ phy_exit(phy);
+ return ret;
+ }
+
+ return 0;
+}
+
+static void am65_cpsw_disable_serdes_phy(struct am65_cpsw_common *common)
+{
+ struct device_node *node, *port_np;
+ struct device *dev = common->dev;
+ const char *name = "serdes-phy";
+ struct phy *phy;
+
+ node = of_get_child_by_name(dev->of_node, "ethernet-ports");
+
+ for_each_child_of_node(node, port_np) {
+ phy = devm_of_phy_get(dev, port_np, name);
+ am65_cpsw_disable_phy(phy);
+ }
+}
+
+static int am65_cpsw_init_serdes_phy(struct device *dev, struct device_node *port_np)
+{
+ const char *name = "serdes-phy";
+ struct phy *phy;
+ int ret;
+
+ phy = devm_of_phy_get(dev, port_np, name);
+ if (PTR_ERR(phy) == -ENODEV)
+ return 0;
+
+ ret = am65_cpsw_enable_phy(phy);
+ if (ret < 0)
+ goto err_phy;
+
+ return 0;
+
+err_phy:
+ devm_phy_put(dev, phy);
+ return ret;
+}
+
static void am65_cpsw_nuss_mac_config(struct phylink_config *config, unsigned int mode,
const struct phylink_link_state *state)
{
@@ -1872,6 +1931,11 @@ static int am65_cpsw_nuss_init_slave_ports(struct am65_cpsw_common *common)
goto of_node_put;
}

+ /* Initialize the phy for the port */
+ ret = am65_cpsw_init_serdes_phy(dev, port_np);
+ if (ret)
+ return ret;
+
port->slave.mac_only =
of_property_read_bool(port_np, "ti,mac-only");

@@ -2822,6 +2886,7 @@ static int am65_cpsw_nuss_remove(struct platform_device *pdev)
return ret;

am65_cpsw_unregister_devlink(common);
+ am65_cpsw_disable_serdes_phy(common);
am65_cpsw_unregister_notifiers(common);

/* must unregister ndevs here because DD release_driver routine calls
--
2.25.1


2022-11-09 01:59:32

by Jakub Kicinski

[permalink] [raw]
Subject: Re: [PATCH v4 0/3] Add support for QSGMII mode for J721e CPSW9G to am65-cpsw driver

On Tue, 8 Nov 2022 13:36:03 +0530 Siddharth Vadapalli wrote:
> 2. Rebase series on linux-next tree tagged: next-20221107.

You need to based on the tree which you're expecting to apply the patch.
Which should be net-next here- throw that into the subject while at it
([PATCH net-next v5 0/3] ....). v4 does not apply cleanly.

2022-11-09 05:15:52

by Siddharth Vadapalli

[permalink] [raw]
Subject: Re: [PATCH v4 0/3] Add support for QSGMII mode for J721e CPSW9G to am65-cpsw driver

Hello Jakub,

On 09/11/22 07:23, Jakub Kicinski wrote:
> On Tue, 8 Nov 2022 13:36:03 +0530 Siddharth Vadapalli wrote:
>> 2. Rebase series on linux-next tree tagged: next-20221107.
>
> You need to based on the tree which you're expecting to apply the patch.
> Which should be net-next here- throw that into the subject while at it
> ([PATCH net-next v5 0/3] ....). v4 does not apply cleanly.

I will rebase the series on the net-next tree and use "PATCH net-next"
in the subject and then post the v5 series. It looks like a few patches
got merged to the net-next tree after I had posted my series.

Regards,
Siddharth.