[PATCH v3 net-next 0/2] macb: add zynqmp SGMII dynamic configuration support

STALE1448d LANDED

Revision v3 of 3 in this series; landed in mainline as 5f4e25641c71 on 2022-09-20.

6 messages, 3 authors, 2022-09-20 · open the first message on its own page

[PATCH v3 net-next 0/2] macb: add zynqmp SGMII dynamic configuration support

From: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>
Date: 2022-09-14 12:33:50

This patchset add firmware and driver support to do SD/GEM dynamic
configuration. In traditional flow GEM secure space configuration
is done by FSBL. However in specific usescases like dynamic designs
where GEM is not enabled in base vivado design, FSBL skips GEM
initialization and we need a mechanism to configure GEM secure space
in linux space at runtime. 

Changes for v3:
- Introduce goto for common phy_exit return path.
- Use enum kernel-doc comment style for enum pm_sd_config_type and
  pm_gem_config_type.

Changes for v2:
- Add phy_exit() in error return paths.
- Use tab indent for zynqmp_pm_set_sd/gem_config return documentation.


Radhey Shyam Pandey (1):
  net: macb: Add zynqmp SGMII dynamic configuration support

Ronak Jain (1):
  firmware: xilinx: add support for sd/gem config

 drivers/firmware/xilinx/zynqmp.c         | 31 ++++++++++++++++
 drivers/net/ethernet/cadence/macb_main.c | 22 ++++++++++++
 include/linux/firmware/xlnx-zynqmp.h     | 45 ++++++++++++++++++++++++
 3 files changed, 98 insertions(+)

-- 
2.25.1

[PATCH v3 net-next 1/2] firmware: xilinx: add support for sd/gem config

From: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>
Date: 2022-09-14 12:34:52

From: Ronak Jain <redacted>

Add new APIs in firmware to configure SD/GEM registers. Internally
it calls PM IOCTL for below SD/GEM register configuration:
- SD/EMMC select
- SD slot type
- SD base clock
- SD 8 bit support
- SD fixed config
- GEM SGMII Mode
- GEM fixed config

Signed-off-by: Ronak Jain <redacted>
Signed-off-by: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>
---
- Changes for v3:
  Use enum kernel-doc comment style for enum pm_sd_config_type and
  pm_gem_config_type.

- Changes for v2:
  Use tab indent for zynqmp_pm_set_sd/gem_config() return
  documentation
---
 drivers/firmware/xilinx/zynqmp.c     | 31 +++++++++++++++++++
 include/linux/firmware/xlnx-zynqmp.h | 45 ++++++++++++++++++++++++++++
 2 files changed, 76 insertions(+)
diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c
index d1f652802181..ff5cabe70a2b 100644
--- a/drivers/firmware/xilinx/zynqmp.c
+++ b/drivers/firmware/xilinx/zynqmp.c
@@ -1311,6 +1311,37 @@ int zynqmp_pm_get_feature_config(enum pm_feature_config_id id,
 				   id, 0, payload);
 }
 
+/**
+ * zynqmp_pm_set_sd_config - PM call to set value of SD config registers
+ * @node:	SD node ID
+ * @config:	The config type of SD registers
+ * @value:	Value to be set
+ *
+ * Return:	Returns 0 on success or error value on failure.
+ */
+int zynqmp_pm_set_sd_config(u32 node, enum pm_sd_config_type config, u32 value)
+{
+	return zynqmp_pm_invoke_fn(PM_IOCTL, node, IOCTL_SET_SD_CONFIG,
+				   config, value, NULL);
+}
+EXPORT_SYMBOL_GPL(zynqmp_pm_set_sd_config);
+
+/**
+ * zynqmp_pm_set_gem_config - PM call to set value of GEM config registers
+ * @node:	GEM node ID
+ * @config:	The config type of GEM registers
+ * @value:	Value to be set
+ *
+ * Return:	Returns 0 on success or error value on failure.
+ */
+int zynqmp_pm_set_gem_config(u32 node, enum pm_gem_config_type config,
+			     u32 value)
+{
+	return zynqmp_pm_invoke_fn(PM_IOCTL, node, IOCTL_SET_GEM_CONFIG,
+				   config, value, NULL);
+}
+EXPORT_SYMBOL_GPL(zynqmp_pm_set_gem_config);
+
 /**
  * struct zynqmp_pm_shutdown_scope - Struct for shutdown scope
  * @subtype:	Shutdown subtype
diff --git a/include/linux/firmware/xlnx-zynqmp.h b/include/linux/firmware/xlnx-zynqmp.h
index 9f50dacbf7d6..76d2b3ebad84 100644
--- a/include/linux/firmware/xlnx-zynqmp.h
+++ b/include/linux/firmware/xlnx-zynqmp.h
@@ -153,6 +153,9 @@ enum pm_ioctl_id {
 	/* Runtime feature configuration */
 	IOCTL_SET_FEATURE_CONFIG = 26,
 	IOCTL_GET_FEATURE_CONFIG = 27,
+	/* Dynamic SD/GEM configuration */
+	IOCTL_SET_SD_CONFIG = 30,
+	IOCTL_SET_GEM_CONFIG = 31,
 };
 
 enum pm_query_id {
@@ -399,6 +402,30 @@ enum pm_feature_config_id {
 	PM_FEATURE_EXTWDT_VALUE = 4,
 };
 
+/**
+ * enum pm_sd_config_type - PM SD configuration.
+ * @SD_CONFIG_EMMC_SEL: To set SD_EMMC_SEL in CTRL_REG_SD and SD_SLOTTYPE
+ * @SD_CONFIG_BASECLK: To set SD_BASECLK in SD_CONFIG_REG1
+ * @SD_CONFIG_8BIT: To set SD_8BIT in SD_CONFIG_REG2
+ * @SD_CONFIG_FIXED: To set fixed config registers
+ */
+enum pm_sd_config_type {
+	SD_CONFIG_EMMC_SEL = 1,
+	SD_CONFIG_BASECLK = 2,
+	SD_CONFIG_8BIT = 3,
+	SD_CONFIG_FIXED = 4,
+};
+
+/**
+ * enum pm_gem_config_type - PM GEM configuration.
+ * @GEM_CONFIG_SGMII_MODE: To set GEM_SGMII_MODE in GEM_CLK_CTRL register
+ * @GEM_CONFIG_FIXED: To set fixed config registers
+ */
+enum pm_gem_config_type {
+	GEM_CONFIG_SGMII_MODE = 1,
+	GEM_CONFIG_FIXED = 2,
+};
+
 /**
  * struct zynqmp_pm_query_data - PM query data
  * @qid:	query ID
@@ -475,6 +502,9 @@ int zynqmp_pm_is_function_supported(const u32 api_id, const u32 id);
 int zynqmp_pm_set_feature_config(enum pm_feature_config_id id, u32 value);
 int zynqmp_pm_get_feature_config(enum pm_feature_config_id id, u32 *payload);
 int zynqmp_pm_register_sgi(u32 sgi_num, u32 reset);
+int zynqmp_pm_set_sd_config(u32 node, enum pm_sd_config_type config, u32 value);
+int zynqmp_pm_set_gem_config(u32 node, enum pm_gem_config_type config,
+			     u32 value);
 #else
 static inline int zynqmp_pm_get_api_version(u32 *version)
 {
@@ -745,6 +775,21 @@ static inline int zynqmp_pm_register_sgi(u32 sgi_num, u32 reset)
 {
 	return -ENODEV;
 }
+
+static inline int zynqmp_pm_set_sd_config(u32 node,
+					  enum pm_sd_config_type config,
+					  u32 value)
+{
+	return -ENODEV;
+}
+
+static inline int zynqmp_pm_set_gem_config(u32 node,
+					   enum pm_gem_config_type config,
+					   u32 value)
+{
+	return -ENODEV;
+}
+
 #endif
 
 #endif /* __FIRMWARE_ZYNQMP_H__ */
-- 
2.25.1

[PATCH v3 net-next 2/2] net: macb: Add zynqmp SGMII dynamic configuration support

From: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>
Date: 2022-09-14 12:34:58

Add support for the dynamic configuration which takes care of
configuring the GEM secure space configuration registers
using EEMI APIs.
High level sequence is to:
- Check for the PM dynamic configuration support, if no error proceed with
  GEM dynamic configurations(next steps) otherwise skip the dynamic
  configuration.
- Configure GEM Fixed configurations.
- Configure GEM_CLK_CTRL (gemX_sgmii_mode).
- Trigger GEM reset.

Signed-off-by: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Tested-by: Conor Dooley <conor.dooley@microchip.com> (for MPFS)
---
Changes for v3:
- Introduce goto for common phy_exit return path.
- Change return check to if(ret) for of_property_read_u32_array
  and zynqmp_pm_set_gem_config APIs.

Changes for v2:
- Add phy_exit() in error return paths.
---
 drivers/net/ethernet/cadence/macb_main.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index 66c7d08d376a..4769c8a0c73a 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -38,6 +38,7 @@
 #include <linux/pm_runtime.h>
 #include <linux/ptp_classify.h>
 #include <linux/reset.h>
+#include <linux/firmware/xlnx-zynqmp.h>
 #include "macb.h"
 
 /* This structure is only used for MACB on SiFive FU540 devices */
@@ -4621,6 +4622,25 @@ static int init_reset_optional(struct platform_device *pdev)
 					     "failed to init SGMII PHY\n");
 	}
 
+	ret = zynqmp_pm_is_function_supported(PM_IOCTL, IOCTL_SET_GEM_CONFIG);
+	if (!ret) {
+		u32 pm_info[2];
+
+		ret = of_property_read_u32_array(pdev->dev.of_node, "power-domains",
+						 pm_info, ARRAY_SIZE(pm_info));
+		if (ret) {
+			dev_err(&pdev->dev, "Failed to read power management information\n");
+			goto err_out_phy_exit;
+		}
+		ret = zynqmp_pm_set_gem_config(pm_info[1], GEM_CONFIG_FIXED, 0);
+		if (ret)
+			goto err_out_phy_exit;
+
+		ret = zynqmp_pm_set_gem_config(pm_info[1], GEM_CONFIG_SGMII_MODE, 1);
+		if (ret)
+			goto err_out_phy_exit;
+	}
+
 	/* Fully reset controller at hardware level if mapped in device tree */
 	ret = device_reset_optional(&pdev->dev);
 	if (ret) {
@@ -4629,6 +4649,8 @@ static int init_reset_optional(struct platform_device *pdev)
 	}
 
 	ret = macb_init(pdev);
+
+err_out_phy_exit:
 	if (ret)
 		phy_exit(bp->sgmii_phy);
 
-- 
2.25.1

Re: [PATCH v3 net-next 1/2] firmware: xilinx: add support for sd/gem config

From: <hidden>
Date: 2022-09-15 07:43:28

On 14.09.2022 15:33, Radhey Shyam Pandey wrote:
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

From: Ronak Jain <redacted>

Add new APIs in firmware to configure SD/GEM registers. Internally
it calls PM IOCTL for below SD/GEM register configuration:
- SD/EMMC select
- SD slot type
- SD base clock
- SD 8 bit support
- SD fixed config
- GEM SGMII Mode
- GEM fixed config

Signed-off-by: Ronak Jain <redacted>
Signed-off-by: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>
Reviewed-by: Claudiu Beznea <redacted>

quoted hunk
---
- Changes for v3:
  Use enum kernel-doc comment style for enum pm_sd_config_type and
  pm_gem_config_type.

- Changes for v2:
  Use tab indent for zynqmp_pm_set_sd/gem_config() return
  documentation
---
 drivers/firmware/xilinx/zynqmp.c     | 31 +++++++++++++++++++
 include/linux/firmware/xlnx-zynqmp.h | 45 ++++++++++++++++++++++++++++
 2 files changed, 76 insertions(+)
diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c
index d1f652802181..ff5cabe70a2b 100644
--- a/drivers/firmware/xilinx/zynqmp.c
+++ b/drivers/firmware/xilinx/zynqmp.c
@@ -1311,6 +1311,37 @@ int zynqmp_pm_get_feature_config(enum pm_feature_config_id id,
                                   id, 0, payload);
 }

+/**
+ * zynqmp_pm_set_sd_config - PM call to set value of SD config registers
+ * @node:      SD node ID
+ * @config:    The config type of SD registers
+ * @value:     Value to be set
+ *
+ * Return:     Returns 0 on success or error value on failure.
+ */
+int zynqmp_pm_set_sd_config(u32 node, enum pm_sd_config_type config, u32 value)
+{
+       return zynqmp_pm_invoke_fn(PM_IOCTL, node, IOCTL_SET_SD_CONFIG,
+                                  config, value, NULL);
+}
+EXPORT_SYMBOL_GPL(zynqmp_pm_set_sd_config);
+
+/**
+ * zynqmp_pm_set_gem_config - PM call to set value of GEM config registers
+ * @node:      GEM node ID
+ * @config:    The config type of GEM registers
+ * @value:     Value to be set
+ *
+ * Return:     Returns 0 on success or error value on failure.
+ */
+int zynqmp_pm_set_gem_config(u32 node, enum pm_gem_config_type config,
+                            u32 value)
+{
+       return zynqmp_pm_invoke_fn(PM_IOCTL, node, IOCTL_SET_GEM_CONFIG,
+                                  config, value, NULL);
+}
+EXPORT_SYMBOL_GPL(zynqmp_pm_set_gem_config);
+
 /**
  * struct zynqmp_pm_shutdown_scope - Struct for shutdown scope
  * @subtype:   Shutdown subtype
diff --git a/include/linux/firmware/xlnx-zynqmp.h b/include/linux/firmware/xlnx-zynqmp.h
index 9f50dacbf7d6..76d2b3ebad84 100644
--- a/include/linux/firmware/xlnx-zynqmp.h
+++ b/include/linux/firmware/xlnx-zynqmp.h
@@ -153,6 +153,9 @@ enum pm_ioctl_id {
        /* Runtime feature configuration */
        IOCTL_SET_FEATURE_CONFIG = 26,
        IOCTL_GET_FEATURE_CONFIG = 27,
+       /* Dynamic SD/GEM configuration */
+       IOCTL_SET_SD_CONFIG = 30,
+       IOCTL_SET_GEM_CONFIG = 31,
 };

 enum pm_query_id {
@@ -399,6 +402,30 @@ enum pm_feature_config_id {
        PM_FEATURE_EXTWDT_VALUE = 4,
 };

+/**
+ * enum pm_sd_config_type - PM SD configuration.
+ * @SD_CONFIG_EMMC_SEL: To set SD_EMMC_SEL in CTRL_REG_SD and SD_SLOTTYPE
+ * @SD_CONFIG_BASECLK: To set SD_BASECLK in SD_CONFIG_REG1
+ * @SD_CONFIG_8BIT: To set SD_8BIT in SD_CONFIG_REG2
+ * @SD_CONFIG_FIXED: To set fixed config registers
+ */
+enum pm_sd_config_type {
+       SD_CONFIG_EMMC_SEL = 1,
+       SD_CONFIG_BASECLK = 2,
+       SD_CONFIG_8BIT = 3,
+       SD_CONFIG_FIXED = 4,
+};
+
+/**
+ * enum pm_gem_config_type - PM GEM configuration.
+ * @GEM_CONFIG_SGMII_MODE: To set GEM_SGMII_MODE in GEM_CLK_CTRL register
+ * @GEM_CONFIG_FIXED: To set fixed config registers
+ */
+enum pm_gem_config_type {
+       GEM_CONFIG_SGMII_MODE = 1,
+       GEM_CONFIG_FIXED = 2,
+};
+
 /**
  * struct zynqmp_pm_query_data - PM query data
  * @qid:       query ID
@@ -475,6 +502,9 @@ int zynqmp_pm_is_function_supported(const u32 api_id, const u32 id);
 int zynqmp_pm_set_feature_config(enum pm_feature_config_id id, u32 value);
 int zynqmp_pm_get_feature_config(enum pm_feature_config_id id, u32 *payload);
 int zynqmp_pm_register_sgi(u32 sgi_num, u32 reset);
+int zynqmp_pm_set_sd_config(u32 node, enum pm_sd_config_type config, u32 value);
+int zynqmp_pm_set_gem_config(u32 node, enum pm_gem_config_type config,
+                            u32 value);
 #else
 static inline int zynqmp_pm_get_api_version(u32 *version)
 {
@@ -745,6 +775,21 @@ static inline int zynqmp_pm_register_sgi(u32 sgi_num, u32 reset)
 {
        return -ENODEV;
 }
+
+static inline int zynqmp_pm_set_sd_config(u32 node,
+                                         enum pm_sd_config_type config,
+                                         u32 value)
+{
+       return -ENODEV;
+}
+
+static inline int zynqmp_pm_set_gem_config(u32 node,
+                                          enum pm_gem_config_type config,
+                                          u32 value)
+{
+       return -ENODEV;
+}
+
 #endif

 #endif /* __FIRMWARE_ZYNQMP_H__ */
--
2.25.1

Re: [PATCH v3 net-next 2/2] net: macb: Add zynqmp SGMII dynamic configuration support

From: <hidden>
Date: 2022-09-15 07:43:48

On 14.09.2022 15:33, Radhey Shyam Pandey wrote:
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

Add support for the dynamic configuration which takes care of
configuring the GEM secure space configuration registers
using EEMI APIs.
High level sequence is to:
- Check for the PM dynamic configuration support, if no error proceed with
  GEM dynamic configurations(next steps) otherwise skip the dynamic
  configuration.
- Configure GEM Fixed configurations.
- Configure GEM_CLK_CTRL (gemX_sgmii_mode).
- Trigger GEM reset.

Signed-off-by: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Tested-by: Conor Dooley <conor.dooley@microchip.com> (for MPFS)
Reviewed-by: Claudiu Beznea <redacted>

quoted hunk
---
Changes for v3:
- Introduce goto for common phy_exit return path.
- Change return check to if(ret) for of_property_read_u32_array
  and zynqmp_pm_set_gem_config APIs.

Changes for v2:
- Add phy_exit() in error return paths.
---
 drivers/net/ethernet/cadence/macb_main.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index 66c7d08d376a..4769c8a0c73a 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -38,6 +38,7 @@
 #include <linux/pm_runtime.h>
 #include <linux/ptp_classify.h>
 #include <linux/reset.h>
+#include <linux/firmware/xlnx-zynqmp.h>
 #include "macb.h"

 /* This structure is only used for MACB on SiFive FU540 devices */
@@ -4621,6 +4622,25 @@ static int init_reset_optional(struct platform_device *pdev)
                                             "failed to init SGMII PHY\n");
        }

+       ret = zynqmp_pm_is_function_supported(PM_IOCTL, IOCTL_SET_GEM_CONFIG);
+       if (!ret) {
+               u32 pm_info[2];
+
+               ret = of_property_read_u32_array(pdev->dev.of_node, "power-domains",
+                                                pm_info, ARRAY_SIZE(pm_info));
+               if (ret) {
+                       dev_err(&pdev->dev, "Failed to read power management information\n");
+                       goto err_out_phy_exit;
+               }
+               ret = zynqmp_pm_set_gem_config(pm_info[1], GEM_CONFIG_FIXED, 0);
+               if (ret)
+                       goto err_out_phy_exit;
+
+               ret = zynqmp_pm_set_gem_config(pm_info[1], GEM_CONFIG_SGMII_MODE, 1);
+               if (ret)
+                       goto err_out_phy_exit;
+       }
+
        /* Fully reset controller at hardware level if mapped in device tree */
        ret = device_reset_optional(&pdev->dev);
        if (ret) {
@@ -4629,6 +4649,8 @@ static int init_reset_optional(struct platform_device *pdev)
        }

        ret = macb_init(pdev);
+
+err_out_phy_exit:
        if (ret)
                phy_exit(bp->sgmii_phy);

--
2.25.1

Re: [PATCH v3 net-next 0/2] macb: add zynqmp SGMII dynamic configuration support

From: patchwork-bot+netdevbpf@kernel.org
Date: 2022-09-20 15:40:28

Hello:

This series was applied to netdev/net-next.git (master)
by Jakub Kicinski [off-list ref]:

On Wed, 14 Sep 2022 18:03:14 +0530 you wrote:
This patchset add firmware and driver support to do SD/GEM dynamic
configuration. In traditional flow GEM secure space configuration
is done by FSBL. However in specific usescases like dynamic designs
where GEM is not enabled in base vivado design, FSBL skips GEM
initialization and we need a mechanism to configure GEM secure space
in linux space at runtime.

[...]
Here is the summary with links:
  - [v3,net-next,1/2] firmware: xilinx: add support for sd/gem config
    https://git.kernel.org/netdev/net-next/c/256dea9134c3
  - [v3,net-next,2/2] net: macb: Add zynqmp SGMII dynamic configuration support
    https://git.kernel.org/netdev/net-next/c/32cee7818111

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help