Commit db443a11 authored by Josua Mayer's avatar Josua Mayer

linux: backport serdes protocol switching driver from mainline

Signed-off-by: default avatarJosua Mayer <josua@solid-run.com>
parent 33cddb76
......@@ -43,7 +43,7 @@ CONFIG_CRYPTO_USER_API_SKCIPHER=y
CONFIG_CRYPTO_USER_API_RNG=y
CONFIG_CRYPTO_USER_API_AEAD=y
CONFIG_SFP=y
CONFIG_PHY_FSL_SERDES_28G=y
CONFIG_PHY_FSL_LYNX_28G=y
CONFIG_I40E=y
CONFIG_I40EVF=y
CONFIG_IAVF=y
......
This diff is collapsed.
From 7ff87b026321d30874de2866fb83cba65f7c0282 Mon Sep 17 00:00:00 2001
From: Josua Mayer <josua@solid-run.com>
Date: Sun, 20 Nov 2022 10:24:38 +0200
Subject: [PATCH 34/45] arm64: dts: lx2160a: remove serdes2 description
Signed-off-by: Josua Mayer <josua@solid-run.com>
---
.../arm64/boot/dts/freescale/fsl-lx2160a.dtsi | 41 -------------------
1 file changed, 41 deletions(-)
diff --git a/arch/arm64/boot/dts/freescale/fsl-lx2160a.dtsi b/arch/arm64/boot/dts/freescale/fsl-lx2160a.dtsi
index fd14b4c5b9fb..23b48824b139 100644
--- a/arch/arm64/boot/dts/freescale/fsl-lx2160a.dtsi
+++ b/arch/arm64/boot/dts/freescale/fsl-lx2160a.dtsi
@@ -613,47 +613,6 @@ soc {
ranges;
dma-ranges = <0x0 0x0 0x0 0x0 0x10000 0x00000000>;
- serdes_2: serdes_phy@1eb0000 {
- compatible = "fsl,serdes-28g";
- reg = <0x00 0x1eb0000 0x0 0x1e30>;
- #address-cells = <1>;
- #size-cells = <0>;
- #phy-cells = <1>;
-
- serdes2_lane_a: phy@0 {
- reg = <0>;
- #phy-cells = <0>;
- };
- serdes2_lane_b: phy@1 {
- reg = <1>;
- #phy-cells = <0>;
- };
- serdes2_lane_c: phy@2 {
- reg = <2>;
- #phy-cells = <0>;
- };
- serdes2_lane_d: phy@3 {
- reg = <3>;
- #phy-cells = <0>;
- };
- serdes2_lane_e: phy@4 {
- reg = <4>;
- #phy-cells = <0>;
- };
- serdes2_lane_f: phy@5 {
- reg = <5>;
- #phy-cells = <0>;
- };
- serdes2_lane_g: phy@6 {
- reg = <6>;
- #phy-cells = <0>;
- };
- serdes2_lane_h: phy@7 {
- reg = <7>;
- #phy-cells = <0>;
- };
- };
-
crypto: crypto@8000000 {
compatible = "fsl,sec-v5.0", "fsl,sec-v4.0";
fsl,sec-era = <10>;
--
2.38.1
From dbc6002ca885d1b7bf52c675cfde94256d17f2d9 Mon Sep 17 00:00:00 2001
From: Ioana Ciornei <ioana.ciornei@nxp.com>
Date: Fri, 11 Mar 2022 23:22:22 +0200
Subject: [PATCH 36/45] dt-bindings: phy: add bindings for Lynx 28G PHY
Add device tree binding for the Lynx 28G SerDes PHY driver used on
Layerscape based SoCs.
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
---
.../devicetree/bindings/phy/fsl,lynx-28g.yaml | 40 +++++++++++++++++++
MAINTAINERS | 1 +
2 files changed, 41 insertions(+)
create mode 100644 Documentation/devicetree/bindings/phy/fsl,lynx-28g.yaml
diff --git a/Documentation/devicetree/bindings/phy/fsl,lynx-28g.yaml b/Documentation/devicetree/bindings/phy/fsl,lynx-28g.yaml
new file mode 100644
index 000000000000..4d91e2f4f247
--- /dev/null
+++ b/Documentation/devicetree/bindings/phy/fsl,lynx-28g.yaml
@@ -0,0 +1,40 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/phy/fsl,lynx-28g.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Freescale Lynx 28G SerDes PHY binding
+
+maintainers:
+ - Ioana Ciornei <ioana.ciornei@nxp.com>
+
+properties:
+ compatible:
+ enum:
+ - fsl,lynx-28g
+
+ reg:
+ maxItems: 1
+
+ "#phy-cells":
+ const: 1
+
+required:
+ - compatible
+ - reg
+ - "#phy-cells"
+
+additionalProperties: false
+
+examples:
+ - |
+ soc {
+ #address-cells = <2>;
+ #size-cells = <2>;
+ serdes_1: phy@1ea0000 {
+ compatible = "fsl,lynx-28g";
+ reg = <0x0 0x1ea0000 0x0 0x1e30>;
+ #phy-cells = <1>;
+ };
+ };
diff --git a/MAINTAINERS b/MAINTAINERS
index 009d36524bef..4bbe6ba6cbfe 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -10385,6 +10385,7 @@ LYNX 28G SERDES PHY DRIVER
M: Ioana Ciornei <ioana.ciornei@nxp.com>
L: netdev@vger.kernel.org
S: Supported
+F: Documentation/devicetree/bindings/phy/fsl,lynx-28g.yaml
F: drivers/phy/freescale/phy-fsl-lynx-28g.c
LYNX PCS MODULE
--
2.38.1
From 7c4fb2f10a17f70c293082176f8ffb220722a5de Mon Sep 17 00:00:00 2001
From: Ioana Ciornei <ioana.ciornei@nxp.com>
Date: Fri, 11 Mar 2022 23:22:23 +0200
Subject: [PATCH 37/45] dpaa2-mac: add the MC API for retrieving the version
The dpmac_get_api_version command will be used in the next patches to
determine if the current firmware is capable or not to change the
Ethernet protocol running on the MAC.
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
---
.../net/ethernet/freescale/dpaa2/dpmac-cmd.h | 7 +++++
drivers/net/ethernet/freescale/dpaa2/dpmac.c | 31 +++++++++++++++++++
drivers/net/ethernet/freescale/dpaa2/dpmac.h | 2 ++
3 files changed, 40 insertions(+)
diff --git a/drivers/net/ethernet/freescale/dpaa2/dpmac-cmd.h b/drivers/net/ethernet/freescale/dpaa2/dpmac-cmd.h
index 326b8b231f6e..b5c119cb5cb1 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpmac-cmd.h
+++ b/drivers/net/ethernet/freescale/dpaa2/dpmac-cmd.h
@@ -19,6 +19,8 @@
#define DPMAC_CMDID_CLOSE DPMAC_CMD(0x800)
#define DPMAC_CMDID_OPEN DPMAC_CMD(0x80c)
+#define DPMAC_CMDID_GET_API_VERSION DPMAC_CMD(0xa0c)
+
#define DPMAC_CMDID_GET_ATTR DPMAC_CMD(0x004)
#define DPMAC_CMDID_SET_IRQ_ENABLE DPMAC_CMD(0x012)
@@ -128,4 +130,9 @@ struct dpmac_rsp_get_link_cfg {
u64 advertising;
};
+struct dpmac_rsp_get_api_version {
+ __le16 major;
+ __le16 minor;
+};
+
#endif /* _FSL_DPMAC_CMD_H */
diff --git a/drivers/net/ethernet/freescale/dpaa2/dpmac.c b/drivers/net/ethernet/freescale/dpaa2/dpmac.c
index 7d6649ae81ed..2a405f13b9d8 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpmac.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpmac.c
@@ -451,3 +451,34 @@ int dpmac_get_link_cfg(struct fsl_mc_io *mc_io,
return 0;
}
+
+/**
+ * dpmac_get_api_version() - Get Data Path MAC version
+ * @mc_io: Pointer to MC portal's I/O object
+ * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
+ * @major_ver: Major version of data path mac API
+ * @minor_ver: Minor version of data path mac API
+ *
+ * Return: '0' on Success; Error code otherwise.
+ */
+int dpmac_get_api_version(struct fsl_mc_io *mc_io, u32 cmd_flags,
+ u16 *major_ver, u16 *minor_ver)
+{
+ struct dpmac_rsp_get_api_version *rsp_params;
+ struct fsl_mc_command cmd = { 0 };
+ int err;
+
+ cmd.header = mc_encode_cmd_header(DPMAC_CMDID_GET_API_VERSION,
+ cmd_flags,
+ 0);
+
+ err = mc_send_command(mc_io, &cmd);
+ if (err)
+ return err;
+
+ rsp_params = (struct dpmac_rsp_get_api_version *)cmd.params;
+ *major_ver = le16_to_cpu(rsp_params->major);
+ *minor_ver = le16_to_cpu(rsp_params->minor);
+
+ return 0;
+}
diff --git a/drivers/net/ethernet/freescale/dpaa2/dpmac.h b/drivers/net/ethernet/freescale/dpaa2/dpmac.h
index 6022d9108f1d..2042bdcf4f47 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpmac.h
+++ b/drivers/net/ethernet/freescale/dpaa2/dpmac.h
@@ -298,4 +298,6 @@ int dpmac_clear_irq_status(struct fsl_mc_io *mc_io,
u8 irq_index,
u32 status);
+int dpmac_get_api_version(struct fsl_mc_io *mc_io, u32 cmd_flags,
+ u16 *major_ver, u16 *minor_ver);
#endif /* __FSL_DPMAC_H */
--
2.38.1
From b030f5defb06f13583ebc85cf3035f2c090691b8 Mon Sep 17 00:00:00 2001
From: Ioana Ciornei <ioana.ciornei@nxp.com>
Date: Fri, 11 Mar 2022 23:22:24 +0200
Subject: [PATCH 38/45] dpaa2-mac: add the MC API for reconfiguring the
protocol
The MC firmware gained recently a new command which can reconfigure the
running protocol on the underlying MAC. Add this new command which will
be used in the next patches in order to do a major reconfig on the
interface.
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
---
.../net/ethernet/freescale/dpaa2/dpmac-cmd.h | 6 +++++
drivers/net/ethernet/freescale/dpaa2/dpmac.c | 23 +++++++++++++++++++
drivers/net/ethernet/freescale/dpaa2/dpmac.h | 3 +++
3 files changed, 32 insertions(+)
diff --git a/drivers/net/ethernet/freescale/dpaa2/dpmac-cmd.h b/drivers/net/ethernet/freescale/dpaa2/dpmac-cmd.h
index b5c119cb5cb1..587a8efc55c6 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpmac-cmd.h
+++ b/drivers/net/ethernet/freescale/dpaa2/dpmac-cmd.h
@@ -34,6 +34,9 @@
#define DPMAC_CMDID_SET_LINK_STATE DPMAC_CMD_V2(0x0c3)
#define DPMAC_CMDID_GET_COUNTER DPMAC_CMD(0x0c4)
+
+#define DPMAC_CMDID_SET_PROTOCOL DPMAC_CMD(0x0c7)
+
/* Macros for accessing command fields smaller than 1byte */
#define DPMAC_MASK(field) \
GENMASK(DPMAC_##field##_SHIFT + DPMAC_##field##_SIZE - 1, \
@@ -135,4 +138,7 @@ struct dpmac_rsp_get_api_version {
__le16 minor;
};
+struct dpmac_cmd_set_protocol {
+ u8 eth_if;
+};
#endif /* _FSL_DPMAC_CMD_H */
diff --git a/drivers/net/ethernet/freescale/dpaa2/dpmac.c b/drivers/net/ethernet/freescale/dpaa2/dpmac.c
index 2a405f13b9d8..bd670fe87666 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpmac.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpmac.c
@@ -482,3 +482,26 @@ int dpmac_get_api_version(struct fsl_mc_io *mc_io, u32 cmd_flags,
return 0;
}
+
+/**
+ * dpmac_set_protocol() - Reconfigure the DPMAC protocol
+ * @mc_io: Pointer to opaque I/O object
+ * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token: Token of DPMAC object
+ * @protocol: New protocol for the DPMAC to be reconfigured in.
+ *
+ * Return: '0' on Success; Error code otherwise.
+ */
+int dpmac_set_protocol(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
+ enum dpmac_eth_if protocol)
+{
+ struct dpmac_cmd_set_protocol *cmd_params;
+ struct fsl_mc_command cmd = { 0 };
+
+ cmd.header = mc_encode_cmd_header(DPMAC_CMDID_SET_PROTOCOL,
+ cmd_flags, token);
+ cmd_params = (struct dpmac_cmd_set_protocol *)cmd.params;
+ cmd_params->eth_if = protocol;
+
+ return mc_send_command(mc_io, &cmd);
+}
diff --git a/drivers/net/ethernet/freescale/dpaa2/dpmac.h b/drivers/net/ethernet/freescale/dpaa2/dpmac.h
index 2042bdcf4f47..86c2003db9ae 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpmac.h
+++ b/drivers/net/ethernet/freescale/dpaa2/dpmac.h
@@ -300,4 +300,7 @@ int dpmac_clear_irq_status(struct fsl_mc_io *mc_io,
int dpmac_get_api_version(struct fsl_mc_io *mc_io, u32 cmd_flags,
u16 *major_ver, u16 *minor_ver);
+
+int dpmac_set_protocol(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
+ enum dpmac_eth_if protocol);
#endif /* __FSL_DPMAC_H */
--
2.38.1
From 045121b44b2f206194c8135e70bb8dad5267e074 Mon Sep 17 00:00:00 2001
From: Ioana Ciornei <ioana.ciornei@nxp.com>
Date: Fri, 11 Mar 2022 23:22:25 +0200
Subject: [PATCH 39/45] dpaa2-mac: retrieve API version and detect features
Retrieve the API version running on the firmware and based on it detect
which features are available for usage.
The first one to be listed is the capability to change the MAC protocol
at runtime.
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
---
.../net/ethernet/freescale/dpaa2/dpaa2-mac.c | 30 +++++++++++++++++++
.../net/ethernet/freescale/dpaa2/dpaa2-mac.h | 2 ++
2 files changed, 32 insertions(+)
diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
index b4d8dcb5e74b..4d2a0160cc48 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
@@ -13,6 +13,28 @@
#define phylink_to_dpaa2_mac(config) \
container_of((config), struct dpaa2_mac, phylink_config)
+#define DPMAC_PROTOCOL_CHANGE_VER_MAJOR 4
+#define DPMAC_PROTOCOL_CHANGE_VER_MINOR 8
+
+#define DPAA2_MAC_FEATURE_PROTOCOL_CHANGE BIT(0)
+
+static int dpaa2_mac_cmp_ver(struct dpaa2_mac *mac,
+ u16 ver_major, u16 ver_minor)
+{
+ if (mac->ver_major == ver_major)
+ return mac->ver_minor - ver_minor;
+ return mac->ver_major - ver_major;
+}
+
+static void dpaa2_mac_detect_features(struct dpaa2_mac *mac)
+{
+ mac->features = 0;
+
+ if (dpaa2_mac_cmp_ver(mac, DPMAC_PROTOCOL_CHANGE_VER_MAJOR,
+ DPMAC_PROTOCOL_CHANGE_VER_MINOR) >= 0)
+ mac->features |= DPAA2_MAC_FEATURE_PROTOCOL_CHANGE;
+}
+
static int phy_mode(enum dpmac_eth_if eth_if, phy_interface_t *if_mode)
{
*if_mode = PHY_INTERFACE_MODE_NA;
@@ -429,6 +451,14 @@ int dpaa2_mac_open(struct dpaa2_mac *mac)
goto err_close_dpmac;
}
+ err = dpmac_get_api_version(mac->mc_io, 0, &mac->ver_major, &mac->ver_minor);
+ if (err) {
+ netdev_err(net_dev, "dpmac_get_api_version() = %d\n", err);
+ goto err_close_dpmac;
+ }
+
+ dpaa2_mac_detect_features(mac);
+
/* Find the device node representing the MAC device and link the device
* behind the associated netdev to it.
*/
diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.h b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.h
index bb37a78d08a4..1d107b99053e 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.h
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.h
@@ -18,6 +18,8 @@ struct dpaa2_mac {
struct net_device *net_dev;
struct fsl_mc_io *mc_io;
struct dpmac_attr attr;
+ u16 ver_major, ver_minor;
+ unsigned long features;
struct phylink_config phylink_config;
struct phylink *phylink;
--
2.38.1
From 78d5e39c9155e89c41396160145fc3c9c8bd145f Mon Sep 17 00:00:00 2001
From: Ioana Ciornei <ioana.ciornei@nxp.com>
Date: Fri, 11 Mar 2022 23:22:27 +0200
Subject: [PATCH 40/45] dpaa2-mac: configure the SerDes phy on a protocol
change
This patch integrates the dpaa2-eth driver with the generic PHY
infrastructure in order to search, find and reconfigure the SerDes lanes
in case of a protocol change.
On the .mac_config() callback, the phy_set_mode_ext() API is called so
that the Lynx 28G SerDes PHY driver can change the lane's configuration.
In the same phylink callback the MC firmware is called so that it
reconfigures the MAC side to run using the new protocol.
The consumer drivers - dpaa2-eth and dpaa2-switch - are updated to call
the dpaa2_mac_start/stop functions newly added which will
power_on/power_off the associated SerDes lane.
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
---
.../net/ethernet/freescale/dpaa2/dpaa2-eth.c | 5 +-
.../net/ethernet/freescale/dpaa2/dpaa2-mac.c | 67 +++++++++++++++++++
.../net/ethernet/freescale/dpaa2/dpaa2-mac.h | 5 ++
3 files changed, 76 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
index ee5a22747455..430ab61f71dc 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
@@ -1830,8 +1830,10 @@ static int dpaa2_eth_open(struct net_device *net_dev)
goto enable_err;
}
- if (dpaa2_eth_is_type_phy(priv))
+ if (dpaa2_eth_is_type_phy(priv)) {
+ dpaa2_mac_start(priv->mac);
phylink_start(priv->mac->phylink);
+ }
return 0;
@@ -1906,6 +1908,7 @@ static int dpaa2_eth_stop(struct net_device *net_dev)
if (dpaa2_eth_is_type_phy(priv)) {
phylink_stop(priv->mac->phylink);
+ dpaa2_mac_stop(priv->mac);
} else {
netif_tx_stop_all_queues(net_dev);
netif_carrier_off(net_dev);
diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
index 4d2a0160cc48..815cd0018980 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
@@ -4,6 +4,8 @@
#include <linux/fsl/mc.h>
#include <linux/msi.h>
#include <linux/acpi.h>
+#include <linux/pcs-lynx.h>
+#include <linux/phy/phy.h>
#include <linux/property.h>
#include <linux/leds.h>
@@ -72,6 +74,29 @@ static bool dpaa2_mac_is_type_phy(struct dpaa2_mac *mac)
return false;
}
+static enum dpmac_eth_if dpmac_eth_if_mode(phy_interface_t if_mode)
+{
+ switch (if_mode) {
+ case PHY_INTERFACE_MODE_RGMII:
+ case PHY_INTERFACE_MODE_RGMII_ID:
+ case PHY_INTERFACE_MODE_RGMII_RXID:
+ case PHY_INTERFACE_MODE_RGMII_TXID:
+ return DPMAC_ETH_IF_RGMII;
+ case PHY_INTERFACE_MODE_USXGMII:
+ return DPMAC_ETH_IF_USXGMII;
+ case PHY_INTERFACE_MODE_QSGMII:
+ return DPMAC_ETH_IF_QSGMII;
+ case PHY_INTERFACE_MODE_SGMII:
+ return DPMAC_ETH_IF_SGMII;
+ case PHY_INTERFACE_MODE_10GBASER:
+ return DPMAC_ETH_IF_XFI;
+ case PHY_INTERFACE_MODE_1000BASEX:
+ return DPMAC_ETH_IF_1000BASEX;
+ default:
+ return DPMAC_ETH_IF_MII;
+ }
+}
+
static struct fwnode_handle *dpaa2_mac_get_node(struct device *dev,
u16 dpmac_id)
{
@@ -233,6 +258,19 @@ static void dpaa2_mac_config(struct phylink_config *config, unsigned int mode,
if (err)
netdev_err(mac->net_dev, "%s: dpmac_set_link_state() = %d\n",
__func__, err);
+
+ if (!mac->serdes_phy)
+ return;
+
+ /* This happens only if we support changing of protocol at runtime */
+ err = dpmac_set_protocol(mac->mc_io, 0, mac->mc_dev->mc_handle,
+ dpmac_eth_if_mode(state->interface));
+ if (err)
+ netdev_err(mac->net_dev, "dpmac_set_protocol() = %d\n", err);
+
+ err = phy_set_mode_ext(mac->serdes_phy, PHY_MODE_ETHERNET, state->interface);
+ if (err)
+ netdev_err(mac->net_dev, "phy_set_mode_ext() = %d\n", err);
}
static void dpaa2_mac_link_up(struct phylink_config *config,
@@ -346,10 +384,23 @@ static void dpaa2_pcs_destroy(struct dpaa2_mac *mac)
}
}
+void dpaa2_mac_start(struct dpaa2_mac *mac)
+{
+ if (mac->serdes_phy)
+ phy_power_on(mac->serdes_phy);
+}
+
+void dpaa2_mac_stop(struct dpaa2_mac *mac)
+{
+ if (mac->serdes_phy)
+ phy_power_off(mac->serdes_phy);
+}
+
int dpaa2_mac_connect(struct dpaa2_mac *mac)
{
struct net_device *net_dev = mac->net_dev;
struct fwnode_handle *dpmac_node;
+ struct phy *serdes_phy = NULL;
struct phylink *phylink;
int err;
@@ -366,6 +417,20 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac)
return -EINVAL;
mac->if_mode = err;
+ if (mac->features & DPAA2_MAC_FEATURE_PROTOCOL_CHANGE &&
+ !phy_interface_mode_is_rgmii(mac->if_mode) &&
+ is_of_node(dpmac_node)) {
+ serdes_phy = of_phy_get(to_of_node(dpmac_node), NULL);
+
+ if (serdes_phy == ERR_PTR(-ENODEV))
+ serdes_phy = NULL;
+ else if (IS_ERR(serdes_phy))
+ return PTR_ERR(serdes_phy);
+ else
+ phy_init(serdes_phy);
+ }
+ mac->serdes_phy = serdes_phy;
+
/* The MAC does not have the capability to add RGMII delays so
* error out if the interface mode requests them and there is no PHY
* to act upon them
@@ -429,6 +494,8 @@ void dpaa2_mac_disconnect(struct dpaa2_mac *mac)
rtnl_unlock();
phylink_destroy(mac->phylink);
dpaa2_pcs_destroy(mac);
+ of_phy_put(mac->serdes_phy);
+ mac->serdes_phy = NULL;
}
int dpaa2_mac_open(struct dpaa2_mac *mac)
diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.h b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.h
index 1d107b99053e..09163dd210be 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.h
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.h
@@ -28,6 +28,7 @@ struct dpaa2_mac {
enum dpmac_link_type if_link_type;
struct lynx_pcs *pcs;
struct fwnode_handle *fw_node;
+ struct phy *serdes_phy;
struct led_classdev *link_status_led;
};
@@ -49,4 +50,8 @@ void dpaa2_mac_get_strings(u8 *data);
void dpaa2_mac_get_ethtool_stats(struct dpaa2_mac *mac, u64 *data);
+void dpaa2_mac_start(struct dpaa2_mac *mac);
+
+void dpaa2_mac_stop(struct dpaa2_mac *mac);
+
#endif /* DPAA2_MAC_H */
--
2.38.1
From 3fef5ab21bebab810df37f7b737889848651a986 Mon Sep 17 00:00:00 2001
From: Josua Mayer <josua@solid-run.com>
Date: Sun, 20 Nov 2022 13:56:44 +0200
Subject: [PATCH 41/45] HACK: dpaa2-mac: only validate link modes supported by
serdes phy
Signed-off-by: Josua Mayer <josua@solid-run.com>
---
drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
index 815cd0018980..4452a056b580 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
@@ -190,10 +190,17 @@ static void dpaa2_mac_validate(struct phylink_config *config,
__ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
if (state->interface != PHY_INTERFACE_MODE_NA &&
+ !mac->serdes_phy &&
dpaa2_mac_phy_mode_mismatch(mac, state->interface)) {
goto empty_set;
}
+ if (state->interface != PHY_INTERFACE_MODE_NA &&
+ mac->serdes_phy &&
+ phy_validate(mac->serdes_phy, PHY_MODE_ETHERNET, state->interface, NULL)) {
+ goto empty_set;
+ }
+
phylink_set_port_modes(mask);
phylink_set(mask, Autoneg);
phylink_set(mask, Pause);
--
2.38.1
From c29576ac49708fb4d783ea49e17edb4226c0c1d3 Mon Sep 17 00:00:00 2001
From: Ioana Ciornei <ioana.ciornei@nxp.com>
Date: Fri, 11 Mar 2022 23:22:28 +0200
Subject: [PATCH 42/45] arch: arm64: dts: lx2160a: describe the SerDes block #1
Describe the SerDes block #1 using the generic phys infrastructure. This
way, the ethernet nodes can each reference their serdes lanes
individually using the 'phys' dts property.
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
---
arch/arm64/boot/dts/freescale/fsl-lx2160a-clearfog-itx.dtsi | 4 ++++
arch/arm64/boot/dts/freescale/fsl-lx2160a.dtsi | 6 ++++++
2 files changed, 10 insertions(+)
diff --git a/arch/arm64/boot/dts/freescale/fsl-lx2160a-clearfog-itx.dtsi b/arch/arm64/boot/dts/freescale/fsl-lx2160a-clearfog-itx.dtsi
index 74ae703e0f53..e1c900b71f7d 100644
--- a/arch/arm64/boot/dts/freescale/fsl-lx2160a-clearfog-itx.dtsi
+++ b/arch/arm64/boot/dts/freescale/fsl-lx2160a-clearfog-itx.dtsi
@@ -63,21 +63,25 @@ sfp3: sfp-3 {
&dpmac7 {
sfp = <&sfp0>;
managed = "in-band-status";
+ phys = <&serdes_1 3>;
};
&dpmac8 {
sfp = <&sfp1>;
managed = "in-band-status";
+ phys = <&serdes_1 2>;
};
&dpmac9 {
sfp = <&sfp2>;
managed = "in-band-status";
+ phys = <&serdes_1 1>;
};
&dpmac10 {
sfp = <&sfp3>;
managed = "in-band-status";
+ phys = <&serdes_1 0>;
};
&emdio2 {
diff --git a/arch/arm64/boot/dts/freescale/fsl-lx2160a.dtsi b/arch/arm64/boot/dts/freescale/fsl-lx2160a.dtsi
index 23b48824b139..f78e478a094e 100644
--- a/arch/arm64/boot/dts/freescale/fsl-lx2160a.dtsi
+++ b/arch/arm64/boot/dts/freescale/fsl-lx2160a.dtsi
@@ -613,6 +613,12 @@ soc {
ranges;
dma-ranges = <0x0 0x0 0x0 0x0 0x10000 0x00000000>;
+ serdes_1: phy@1ea0000 {
+ compatible = "fsl,lynx-28g";
+ reg = <0x0 0x1ea0000 0x0 0x1e30>;
+ #phy-cells = <1>;
+ };
+
crypto: crypto@8000000 {
compatible = "fsl,sec-v5.0", "fsl,sec-v4.0";
fsl,sec-era = <10>;
--
2.38.1
From 0cbebae9215bbbcd92fa101cd7d563c172b0b730 Mon Sep 17 00:00:00 2001
From: Josua Mayer <josua@solid-run.com>
Date: Sun, 20 Nov 2022 10:53:33 +0200
Subject: [PATCH 43/45] arch: arm64: dts: lx2160a: describe the SerDes block #2
Signed-off-by: Josua Mayer <josua@solid-run.com>
---
arch/arm64/boot/dts/freescale/fsl-lx2160a.dtsi | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/arch/arm64/boot/dts/freescale/fsl-lx2160a.dtsi b/arch/arm64/boot/dts/freescale/fsl-lx2160a.dtsi
index f78e478a094e..23ade0a13ca6 100644
--- a/arch/arm64/boot/dts/freescale/fsl-lx2160a.dtsi
+++ b/arch/arm64/boot/dts/freescale/fsl-lx2160a.dtsi
@@ -619,6 +619,12 @@ serdes_1: phy@1ea0000 {
#phy-cells = <1>;
};
+ serdes_2: phy@1eb0000 {
+ compatible = "fsl,lynx-28g";
+ reg = <0x0 0x1eb0000 0x0 0x1e30>;
+ #phy-cells = <1>;
+ };
+
crypto: crypto@8000000 {
compatible = "fsl,sec-v5.0", "fsl,sec-v4.0";
fsl,sec-era = <10>;
--
2.38.1
From a77f6bf8f2007426ab6c356e2377696a186dfa3e Mon Sep 17 00:00:00 2001
From: Josua Mayer <josua@solid-run.com>
Date: Sun, 20 Nov 2022 11:02:26 +0200
Subject: [PATCH 44/45] arm64: dts: lx2160a-half-twins: update serdes
references for new driver
Signed-off-by: Josua Mayer <josua@solid-run.com>
---
.../dts/freescale/fsl-lx2160a-half-twins.dts | 32 +++++++++----------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/arch/arm64/boot/dts/freescale/fsl-lx2160a-half-twins.dts b/arch/arm64/boot/dts/freescale/fsl-lx2160a-half-twins.dts
index e3175b5f5234..2dd8553ebd1f 100644
--- a/arch/arm64/boot/dts/freescale/fsl-lx2160a-half-twins.dts
+++ b/arch/arm64/boot/dts/freescale/fsl-lx2160a-half-twins.dts
@@ -386,89 +386,89 @@ led_ht_c3_bb: led-ht-c3-bb {
&dpmac3 {
sfp = <&c1_at_sfp>;
managed = "in-band-status";
- phys = <&serdes1_lane_h>;
+ phys = <&serdes_1 7>;
link-status-led = <&led_c1_at>;
};
&dpmac4 {
sfp = <&c1_bt_sfp>;
managed = "in-band-status";
- phys = <&serdes1_lane_g>;
+ phys = <&serdes_1 6>;
link-status-led = <&led_c1_bt>;
};
&dpmac5 {
sfp = <&ht_c3_bt_sfp>;
managed = "in-band-status";
- phys = <&serdes1_lane_f>;
+ phys = <&serdes_1 5>;
link-status-led = <&led_ht_c3_bt>;
};
&dpmac6 {
sfp = <&ht_c3_at_sfp>;
managed = "in-band-status";
- phys = <&serdes1_lane_e>;
+ phys = <&serdes_1 4>;
link-status-led = <&led_ht_c3_at>;
};
&dpmac7 {
sfp = <&c2_at_sfp>;
managed = "in-band-status";
- phys = <&serdes1_lane_d>;
+ phys = <&serdes_1 3>;
link-status-led = <&led_c2_at>;
};
&dpmac8 {
sfp = <&c2_bt_sfp>;
managed = "in-band-status";
- phys = <&serdes1_lane_c>;
+ phys = <&serdes_1 2>;
link-status-led = <&led_c2_bt>;
};
&dpmac9 {
sfp = <&c3_at_sfp>;
managed = "in-band-status";
- phys = <&serdes1_lane_b>;
+ phys = <&serdes_1 1>;
link-status-led = <&led_c3_at>;
};
&dpmac10 {
sfp = <&c3_bt_sfp>;
managed = "in-band-status";
- phys = <&serdes1_lane_a>;
+ phys = <&serdes_1 0>;
link-status-led = <&led_c3_bt>;
};
/* SD2 lanes #0.. #7 */
&dpmac11 {
sfp = <&ht_c3_ab_sfp>;
managed = "in-band-status";
- phys = <&serdes2_lane_a>;
+ phys = <&serdes_2 0>;
link-status-led = <&led_ht_c3_ab>;
};
&dpmac12 {
sfp = <&c1_ab_sfp>;
managed = "in-band-status";
- phys = <&serdes2_lane_b>;
+ phys = <&serdes_2 1>;
link-status-led = <&led_c1_ab>;
};
&dpmac13 { // ok
sfp = <&c3_ab_sfp>;
managed = "in-band-status";
phy-mode = "sgmii";
- phys = <&serdes2_lane_g>;
+ phys = <&serdes_2 6>;
link-status-led = <&led_c3_ab>;
};
&dpmac14 { // ok
sfp = <&c3_bb_sfp>;
managed = "in-band-status";
phy-mode = "sgmii";
- phys = <&serdes2_lane_h>;
+ phys = <&serdes_2 7>;
link-status-led = <&led_c3_bb>;
};
&dpmac15 {
sfp = <&ht_c3_bb_sfp>;
managed = "in-band-status";
- phys = <&serdes2_lane_e>;
+ phys = <&serdes_2 4>;
link-status-led = <&led_ht_c3_bb>;
};
&dpmac16 {
sfp = <&c2_bb_sfp>;
managed = "in-band-status";
- phys = <&serdes2_lane_f>;
+ phys = <&serdes_2 5>;
link-status-led = <&led_c2_bb>;
};
&dpmac17 {
@@ -476,13 +476,13 @@ &dpmac17 {
/delete-property/ phy-connection-type;
sfp = <&c1_bb_sfp>;
managed = "in-band-status";
- phys = <&serdes2_lane_c>;
+ phys = <&serdes_2 2>;
link-status-led = <&led_c1_bb>;
};
&dpmac18 {
sfp = <&c2_ab_sfp>;
managed = "in-band-status";
- phys = <&serdes2_lane_d>;
+ phys = <&serdes_2 3>;
link-status-led = <&led_c2_ab>;
};
--
2.38.1
From 4a9b40732e43171cabc031ef2a8bacb5766a6680 Mon Sep 17 00:00:00 2001
From: Josua Mayer <josua@solid-run.com>
Date: Sun, 20 Nov 2022 11:05:30 +0200
Subject: [PATCH 45/45] arm64: dts: lx2162-clearfog: update serdes references
for new driver
Signed-off-by: Josua Mayer <josua@solid-run.com>
---
.../dts/freescale/fsl-lx2162a-clearfog.dts | 24 +++++++++----------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/arch/arm64/boot/dts/freescale/fsl-lx2162a-clearfog.dts b/arch/arm64/boot/dts/freescale/fsl-lx2162a-clearfog.dts
index d21717592183..c949d260e3ae 100644
--- a/arch/arm64/boot/dts/freescale/fsl-lx2162a-clearfog.dts
+++ b/arch/arm64/boot/dts/freescale/fsl-lx2162a-clearfog.dts
@@ -190,7 +190,7 @@ pcieclk@6b {
/* upper 10G connector */
&dpmac3 {
status = "okay";
- phys = <&serdes1_lane_h>;
+ phys = <&serdes_1 7>;
managed = "in-band-status";
sfp = <&sfp_at>;
link-status-led = <&led_sfp_at>;
@@ -203,7 +203,7 @@ &pcs_mdio3 {
/* lower 10G connector */
&dpmac4 {
status = "okay";
- phys = <&serdes1_lane_g>;
+ phys = <&serdes_1 6>;
managed = "in-band-status";
sfp = <&sfp_ab>;
link-status-led = <&led_sfp_ab>;
@@ -215,7 +215,7 @@ &pcs_mdio4 {
&dpmac5 {
status = "okay";
- phys = <&serdes1_lane_f>;
+ phys = <&serdes_1 5>;
managed = "in-band-status";
sfp = <&sfp_bt>;
link-status-led = <&led_sfp_bt>;
@@ -227,7 +227,7 @@ &pcs_mdio5 {
&dpmac6 {
status = "okay";
- phys = <&serdes1_lane_e>;
+ phys = <&serdes_1 4>;
managed = "in-band-status";
sfp = <&sfp_bb>;
link-status-led = <&led_sfp_bb>;
@@ -288,7 +288,7 @@ &serdes_1 {
&dpmac11 {
status = "okay";
- phys = <&serdes2_lane_a>;
+ phys = <&serdes_2 0>;
phy-handle = <&ethernet_phy2>;
phy-mode = "rgmii";
};
@@ -299,7 +299,7 @@ &pcs_mdio11 {
&dpmac12 {
status = "okay";
- phys = <&serdes2_lane_b>;
+ phys = <&serdes_2 1>;
phy-handle = <&ethernet_phy0>;
phy-mode = "rgmii";
};
@@ -314,7 +314,7 @@ &dpmac17 {
/delete-property/ phy-connection-type;
status = "okay";
- phys = <&serdes2_lane_c>;
+ phys = <&serdes_2 2>;
phy-handle = <&ethernet_phy4>;
phy-mode = "rgmii";
};
@@ -325,7 +325,7 @@ &pcs_mdio17 {
&dpmac18 {
status = "okay";
- phys = <&serdes2_lane_d>;
+ phys = <&serdes_2 3>;
phy-handle = <&ethernet_phy6>;
phy-mode = "rgmii";
};
@@ -336,7 +336,7 @@ &pcs_mdio18 {
&dpmac15 {
status = "okay";
- phys = <&serdes2_lane_e>;
+ phys = <&serdes_2 4>;
phy-handle = <&ethernet_phy3>;
phy-mode = "rgmii";
};
@@ -347,7 +347,7 @@ &pcs_mdio15 {
&dpmac16 {
status = "okay";
- phys = <&serdes2_lane_f>;
+ phys = <&serdes_2 5>;
phy-handle = <&ethernet_phy1>;
phy-mode = "rgmii";
};
@@ -358,7 +358,7 @@ &pcs_mdio16 {
&dpmac13 {
status = "okay";
- phys = <&serdes2_lane_g>;
+ phys = <&serdes_2 6>;
phy-handle = <&ethernet_phy5>;
phy-mode = "rgmii";
};
@@ -369,7 +369,7 @@ &pcs_mdio13 {
&dpmac14 {
status = "okay";
- phys = <&serdes2_lane_h>;
+ phys = <&serdes_2 7>;
phy-handle = <&ethernet_phy7>;
phy-mode = "rgmii";
};
--
2.38.1
......@@ -59,7 +59,7 @@ case "${SERDES}" in
DPL=dpl-eth.8x10g.8x1g.dtb
# MC 10.28.1 is incapable of mapping all 16 dpnis. 10.28.100 fixes that
if [ "x$RELEASE" == "xLSDK-21.08" ]; then
MC_FORCE=patches/mc_10.28.100_lx2160a.itb
MC_FORCE=patches/mc_lx2160a_10.32.0.itb
fi
;;
2_*)
......@@ -119,19 +119,19 @@ case "${SERDES}" in
DPC=LX2162-USOM/clearfog-s1_0-s2_7-dpc.dtb
DPL=LX2162-USOM/clearfog-s1_0-s2_7-dpl.dtb
DEFAULT_FDT_FILE="fsl-lx2162a-clearfog.dtb"
MC_FORCE=patches/mc_10.28.100_lx2160a.itb
MC_FORCE=patches/mc_lx2160a_10.32.0.itb
;;
LX2162A_CLEARFOG_0_9_*)
DPC=LX2162-USOM/clearfog-s1_0-s2_9-dpc.dtb
DPL=LX2162-USOM/clearfog-s1_0-s2_9-dpl.dtb
DEFAULT_FDT_FILE="fsl-lx2162a-clearfog.dtb"
MC_FORCE=patches/mc_10.28.100_lx2160a.itb
MC_FORCE=patches/mc_lx2160a_10.32.0.itb
;;
LX2162A_CLEARFOG_0_11_*)
DPC=LX2162-USOM/clearfog-s1_0-s2_11-dpc.dtb
DPL=LX2162-USOM/clearfog-s1_0-s2_11-dpl.dtb
DEFAULT_FDT_FILE="fsl-lx2162a-clearfog.dtb"
MC_FORCE=patches/mc_10.28.100_lx2160a.itb
MC_FORCE=patches/mc_lx2160a_10.32.0.itb
;;
LX2162A_CLEARFOG_3_0_*)
DPC=LX2162-USOM/clearfog-s1_3-s2_0-dpc.dtb
......@@ -640,7 +640,8 @@ if [ "x$RELEASE" == "xLSDK-20.04" ]; then
else
if [ "x$MC_FORCE" == "x" ]; then
MC=`ls $ROOTDIR/build/qoriq-mc-binary/lx216?a/ | grep -v sha256sum | cut -f1`
dd if=$ROOTDIR/build/qoriq-mc-binary/lx216xa/${MC} of=images/${IMG} bs=512 seek=20480 conv=notrunc
MC=`ls $ROOTDIR/build/qoriq-mc-binary/lx216?a/${MC}`
dd if=${MC} of=images/${IMG} bs=512 seek=20480 conv=notrunc
else
echo "Forcing MC firmware selection"
MC=$MC_FORCE
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment