[v2,2/4] firmware: xilinx: Add version check for TRISTATE configuration

Message ID 20230724084554.1924378-3-sai.krishna.potthuri@amd.com
State New
Headers
Series pinctrl: pinctrl-zynqmp: Add tri-state configuration support |

Commit Message

Sai Krishna Potthuri July 24, 2023, 8:45 a.m. UTC
  Support for configuring TRISTATE parameter is added in ZYNQMP PMUFW(Xilinx
ZynqMP Platform Management Firmware) Configuration Param Set version 2.0.
If the requested configuration is TRISTATE and platform is ZYNQMP then
check the version before requesting Xilinx firmware to set the
configuration.

Signed-off-by: Sai Krishna Potthuri <sai.krishna.potthuri@amd.com>
---
 drivers/firmware/xilinx/zynqmp.c     | 9 +++++++++
 include/linux/firmware/xlnx-zynqmp.h | 2 ++
 2 files changed, 11 insertions(+)
  

Comments

Michal Simek July 24, 2023, 10:16 a.m. UTC | #1
On 7/24/23 10:45, Sai Krishna Potthuri wrote:
> Support for configuring TRISTATE parameter is added in ZYNQMP PMUFW(Xilinx
> ZynqMP Platform Management Firmware) Configuration Param Set version 2.0.
> If the requested configuration is TRISTATE and platform is ZYNQMP then
> check the version before requesting Xilinx firmware to set the
> configuration.
> 
> Signed-off-by: Sai Krishna Potthuri <sai.krishna.potthuri@amd.com>
> ---
>   drivers/firmware/xilinx/zynqmp.c     | 9 +++++++++
>   include/linux/firmware/xlnx-zynqmp.h | 2 ++
>   2 files changed, 11 insertions(+)
> 
> diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c
> index f9498e7ea694..307717f24a98 100644
> --- a/drivers/firmware/xilinx/zynqmp.c
> +++ b/drivers/firmware/xilinx/zynqmp.c
> @@ -1150,6 +1150,15 @@ EXPORT_SYMBOL_GPL(zynqmp_pm_pinctrl_get_config);
>   int zynqmp_pm_pinctrl_set_config(const u32 pin, const u32 param,
>   				 u32 value)
>   {
> +	int ret;
> +
> +	if (pm_family_code == ZYNQMP_FAMILY_CODE &&
> +	    param == PM_PINCTRL_CONFIG_TRI_STATE) {
> +		ret = zynqmp_pm_feature(PM_PINCTRL_CONFIG_PARAM_SET);
> +		if (ret < PM_PINCTRL_PARAM_SET_VERSION)
> +			return -EOPNOTSUPP;
> +	}
> +
>   	return zynqmp_pm_invoke_fn(PM_PINCTRL_CONFIG_PARAM_SET, pin,
>   				   param, value, 0, NULL);
>   }
> diff --git a/include/linux/firmware/xlnx-zynqmp.h b/include/linux/firmware/xlnx-zynqmp.h
> index d7f94b42ad4c..6359eeea8dd7 100644
> --- a/include/linux/firmware/xlnx-zynqmp.h
> +++ b/include/linux/firmware/xlnx-zynqmp.h
> @@ -34,6 +34,8 @@
>   /* PM API versions */
>   #define PM_API_VERSION_2	2
>   
> +#define PM_PINCTRL_PARAM_SET_VERSION	2
> +
>   #define ZYNQMP_FAMILY_CODE 0x23
>   #define VERSAL_FAMILY_CODE 0x26
>   

Reviewed-by: Michal Simek <michal.simek@amd.com>

Thanks,
Michal
  
Sai Krishna Potthuri July 27, 2023, 5:20 a.m. UTC | #2
From: Shah, Tanmay <tanmay.shah@amd.com> 
Sent: Monday, July 24, 2023 8:57 PM
To: Potthuri, Sai Krishna <sai.krishna.potthuri@amd.com>; Linus Walleij <linus.walleij@linaro.org>; Simek, Michal <michal.simek@amd.com>; Rob Herring <robh+dt@kernel.org>; Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>; Conor Dooley <conor+dt@kernel.org>; Mathieu Poirier <mathieu.poirier@linaro.org>; Levinsky, Ben <ben.levinsky@amd.com>; Marek Vasut <marex@denx.de>; Roman Gushchin <roman.gushchin@linux.dev>; Arnd Bergmann <arnd@arndb.de>
Cc: linux-arm-kernel@lists.infradead.org; linux-kernel@vger.kernel.org; linux-gpio@vger.kernel.org; devicetree@vger.kernel.org; saikrishna12468@gmail.com; git (AMD-Xilinx) <git@amd.com>
Subject: Re: [PATCH v2 2/4] firmware: xilinx: Add version check for TRISTATE configuration


On 7/24/23 3:45 AM, Sai Krishna Potthuri wrote:
Support for configuring TRISTATE parameter is added in ZYNQMP PMUFW(Xilinx
ZynqMP Platform Management Firmware) Configuration Param Set version 2.0.
If the requested configuration is TRISTATE and platform is ZYNQMP then
check the version before requesting Xilinx firmware to set the
configuration.

Signed-off-by: Sai Krishna Potthuri mailto:sai.krishna.potthuri@amd.com
---
 drivers/firmware/xilinx/zynqmp.c     | 9 +++++++++
 include/linux/firmware/xlnx-zynqmp.h | 2 ++
 2 files changed, 11 insertions(+)

diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c
index f9498e7ea694..307717f24a98 100644
--- a/drivers/firmware/xilinx/zynqmp.c
+++ b/drivers/firmware/xilinx/zynqmp.c
@@ -1150,6 +1150,15 @@ EXPORT_SYMBOL_GPL(zynqmp_pm_pinctrl_get_config);
 int zynqmp_pm_pinctrl_set_config(const u32 pin, const u32 param,
 				 u32 value)
 {
+	int ret;
+
+	if (pm_family_code == ZYNQMP_FAMILY_CODE &&
+	    param == PM_PINCTRL_CONFIG_TRI_STATE) {
+		ret = zynqmp_pm_feature(PM_PINCTRL_CONFIG_PARAM_SET);
+		if (ret < PM_PINCTRL_PARAM_SET_VERSION)
+			return -EOPNOTSUPP;
Hi Sai,
If you get version 1 as response of feature_check then, it is possible to handle call as per old payload arguments?
something as following:
if (ret == 2) {
    //hanlde modified payload as per v2 of this call
} else if (ret == 1) {
    //handle original payload of this call as firmware is old.
} else {
    //fail here with -EOPNOTSUPP as we don't support this version.
} 
This way we can maintain backward compatibility with old firmware.

Hi Tanmay,

TRISTATE feature support added in version 2.0, hence we are checking the SET PARAM
version if the requested configuration is TRISTATE. If the version is 2.0 then we are
allowing the call otherwise will return error. This change will not impact the other
configurations and not impact the backward compatibility as we are checking the
version only for the TRISTATE configuration.

Regards
Sai Krishna


+	}
+
 	return zynqmp_pm_invoke_fn(PM_PINCTRL_CONFIG_PARAM_SET, pin,
 				   param, value, 0, NULL);
 }
diff --git a/include/linux/firmware/xlnx-zynqmp.h b/include/linux/firmware/xlnx-zynqmp.h
index d7f94b42ad4c..6359eeea8dd7 100644
--- a/include/linux/firmware/xlnx-zynqmp.h
+++ b/include/linux/firmware/xlnx-zynqmp.h
@@ -34,6 +34,8 @@
 /* PM API versions */
 #define PM_API_VERSION_2	2
 
+#define PM_PINCTRL_PARAM_SET_VERSION	2
+
 #define ZYNQMP_FAMILY_CODE 0x23
 #define VERSAL_FAMILY_CODE 0x26
  

Patch

diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c
index f9498e7ea694..307717f24a98 100644
--- a/drivers/firmware/xilinx/zynqmp.c
+++ b/drivers/firmware/xilinx/zynqmp.c
@@ -1150,6 +1150,15 @@  EXPORT_SYMBOL_GPL(zynqmp_pm_pinctrl_get_config);
 int zynqmp_pm_pinctrl_set_config(const u32 pin, const u32 param,
 				 u32 value)
 {
+	int ret;
+
+	if (pm_family_code == ZYNQMP_FAMILY_CODE &&
+	    param == PM_PINCTRL_CONFIG_TRI_STATE) {
+		ret = zynqmp_pm_feature(PM_PINCTRL_CONFIG_PARAM_SET);
+		if (ret < PM_PINCTRL_PARAM_SET_VERSION)
+			return -EOPNOTSUPP;
+	}
+
 	return zynqmp_pm_invoke_fn(PM_PINCTRL_CONFIG_PARAM_SET, pin,
 				   param, value, 0, NULL);
 }
diff --git a/include/linux/firmware/xlnx-zynqmp.h b/include/linux/firmware/xlnx-zynqmp.h
index d7f94b42ad4c..6359eeea8dd7 100644
--- a/include/linux/firmware/xlnx-zynqmp.h
+++ b/include/linux/firmware/xlnx-zynqmp.h
@@ -34,6 +34,8 @@ 
 /* PM API versions */
 #define PM_API_VERSION_2	2
 
+#define PM_PINCTRL_PARAM_SET_VERSION	2
+
 #define ZYNQMP_FAMILY_CODE 0x23
 #define VERSAL_FAMILY_CODE 0x26