pinctrl: pinctrl-zynqmp: Add tri-state configuration support
Subsystems (4)
v2 cover pinctrl: pinctrl-zynqmp: Add tri-state configuration support
Add pinctrl driver support to handle 'output-enable' and 'bias-high-impedance' configurations with proper Configuration Set version check. This will ensure system not to crash even if older Xilinx ZynqMP Platform Management Firmware is used.
Initial Commit details:
Commit 133ad0d9af99bdca9070 ("dt-bindings: pinctrl-zynqmp: Add output-enable configuration").
Commit ad2bea79ef0144043721 ("pinctrl: pinctrl-zynqmp: Add support for output-enable and bias-high-impedance").
With the above patches, using these pinctrl properties in the device-tree cause system hang issues with older Xilinx ZynqMP Platform Management Firmware, hence reverted the patches.
Reverted Commit details:
Commit ff8356060e3a5e126abb ("Revert "dt-bindings: pinctrl-zynqmp: Add output-enable configuration"").
Commit 9989bc33c4894e075167 ("Revert "pinctrl: pinctrl-zynqmp: Add support for output-enable and bias-high-impedance"").
With the latest firmware and driver changes, driver will ask firmware if that feature is supported or not by checking the version. This way it works with all Xilinx firmwares.
changes in v2:
- Updated commit description in 3/4 patch as suggested by Conor Dooley.
Dhaval Shah (1):
firmware: xilinx: Add support to get platform information
Sai Krishna Potthuri (3):
firmware: xilinx: Add version check for TRISTATE configuration
dt-bindings: pinctrl-zynqmp: Add output-enable configuration
pinctrl: pinctrl-zynqmp: Add support for output-enable and bias-high
impedance
.../bindings/pinctrl/xlnx,zynqmp-pinctrl.yaml | 4 ++ drivers/firmware/xilinx/zynqmp.c | 51 +++++++++++++++++++ drivers/pinctrl/pinctrl-zynqmp.c | 9 ++++ include/linux/firmware/xlnx-zynqmp.h | 15 ++++++ 4 files changed, 79 insertions(+)
Signature · 1 line
2.25.1
PATCH v2 1/4 firmware: xilinx: Add support to get platform information
From: Dhaval Shah <[email protected]>
Add function to get family code and sub family code from the idcode. This family code and sub family code helps to identify the platform. Family code of any platform is on bits 21 to 27 and Sub family code is on bits 19 and 20.
--- drivers/firmware/xilinx/zynqmp.c | 42 ++++++++++++++++++++++++++++ include/linux/firmware/xlnx-zynqmp.h | 13 +++++++++ 2 files changed, 55 insertions(+)
drivers/firmware/xilinx/zynqmp.c +42 -0
@@ -339,6 +339,8 @@ int zynqmp_pm_invoke_fn(u32 pm_api_id, u32 arg0, u32 arg1,static u32 pm_api_version;static u32 pm_tz_version; +static u32 pm_family_code; +static u32 pm_sub_family_code;int zynqmp_pm_register_sgi (u32 sgi_num,u32 reset) {
@@ -404,6 +406,41 @@ int zynqmp_pm_get_chipid(u32 *idcode, u32 *version) }EXPORT_SYMBOL_GPL (zynqmp_pm_get_chipid); +/** +* zynqmp_pm_get_family_info() - Get family info of platform +* @family: Returned family code value +* @subfamily: Returned sub-family code value +* +* Return: Returns status, either success or error+reason +*/ +static int zynqmp_pm_get_family_info (u32 *family,u32 *subfamily) +{ +u32 ret_payload[PAYLOAD_ARG_CNT ]; +u32 idcode; +int ret; + +/* Check is family or sub-family code already received */ +if (pm_family_code && pm_sub_family_code) { + *family = pm_family_code; + *subfamily = pm_sub_family_code; +return 0 ; + } + + ret =zynqmp_pm_invoke_fn (PM_GET_CHIPID ,0 ,0 ,0 ,0 , ret_payload); +if (ret <0 ) +return ret; + + idcode = ret_payload[1 ]; + pm_family_code =FIELD_GET (GENMASK (FAMILY_CODE_MSB ,FAMILY_CODE_LSB ), + idcode); + pm_sub_family_code =FIELD_GET (GENMASK (SUB_FAMILY_CODE_MSB , +SUB_FAMILY_CODE_LSB ), idcode); + *family = pm_family_code; + *subfamily = pm_sub_family_code; + +return 0 ; +} +/** * zynqmp_pm_get_trustzone_version() - Get secure trustzone firmware version * @version: Returned version value
@@ -1911,6 +1948,11 @@ static int zynqmp_firmware_probe(struct platform_device *pdev)pr_info ("%s Platform Management API v%d.%d\n" , __func__, pm_api_version >>16 , pm_api_version &0xFFFF ); +/* Get the Family code and sub family code of platform */ + ret =zynqmp_pm_get_family_info (&pm_family_code, &pm_sub_family_code); +if (ret <0 ) +return ret; +/* Check trustzone version number */ ret =zynqmp_pm_get_trustzone_version (&pm_tz_version);if (ret)
include/linux/firmware/xlnx-zynqmp.h +13 -0
@@ -34,6 +34,19 @@/* PM API versions */ #define PM_API_VERSION_2 2 +#define ZYNQMP_FAMILY_CODE 0x23 +#define VERSAL_FAMILY_CODE 0x26 + +/* When all subfamily of platform need to support */ +#define ALL_SUB_FAMILY_CODE 0x00 +#define VERSAL_SUB_FAMILY_CODE 0x01 +#define VERSALNET_SUB_FAMILY_CODE 0x03 + +#define FAMILY_CODE_LSB 21 +#define FAMILY_CODE_MSB 27 +#define SUB_FAMILY_CODE_LSB 19 +#define SUB_FAMILY_CODE_MSB 20 +/* ATF only commands */ #define TF_A_PM_REGISTER_SGI 0xa04#define PM_GET_TRUSTZONE_VERSION 0xa03
Signature · 1 line
2.25.1
Re: [PATCH v2 1/4] firmware: xilinx: Add support to get platform information
Quoted 91 lines · Sai Krishna Potthuri
From: Dhaval Shah <[email protected]>
Add function to get family code and sub family code from the idcode. This family code and sub family code helps to identify the platform. Family code of any platform is on bits 21 to 27 and Sub family code is on bits 19 and 20.
Signed-off-by Dhaval Shah <[email protected]>Signed-off-by Sai Krishna Potthuri <[email protected]>--- drivers/firmware/xilinx/zynqmp.c | 42 ++++++++++++++++++++++++++++ include/linux/firmware/xlnx-zynqmp.h | 13 +++++++++ 2 files changed, 55 insertions(+)drivers/firmware/xilinx/zynqmp.c +42
-0@@ -339,6 +339,8 @@ int zynqmp_pm_invoke_fn(u32 pm_api_id, u32 arg0, u32 arg1,static u32 pm_api_version;static u32 pm_tz_version; +static u32 pm_family_code; +static u32 pm_sub_family_code;int zynqmp_pm_register_sgi (u32 sgi_num,u32 reset) {@@ -404,6 +406,41 @@ int zynqmp_pm_get_chipid(u32 *idcode, u32 *version) }EXPORT_SYMBOL_GPL (zynqmp_pm_get_chipid); +/** +* zynqmp_pm_get_family_info() - Get family info of platform +* @family: Returned family code value +* @subfamily: Returned sub-family code value +* +* Return: Returns status, either success or error+reason +*/ +static int zynqmp_pm_get_family_info (u32 *family,u32 *subfamily) +{ +u32 ret_payload[PAYLOAD_ARG_CNT ]; +u32 idcode; +int ret; + +/* Check is family or sub-family code already received */ +if (pm_family_code && pm_sub_family_code) { + *family = pm_family_code; + *subfamily = pm_sub_family_code; +return 0 ; + } + + ret =zynqmp_pm_invoke_fn (PM_GET_CHIPID ,0 ,0 ,0 ,0 , ret_payload); +if (ret <0 ) +return ret; + + idcode = ret_payload[1 ]; + pm_family_code =FIELD_GET (GENMASK (FAMILY_CODE_MSB ,FAMILY_CODE_LSB ), + idcode); + pm_sub_family_code =FIELD_GET (GENMASK (SUB_FAMILY_CODE_MSB , +SUB_FAMILY_CODE_LSB ), idcode); + *family = pm_family_code; + *subfamily = pm_sub_family_code; + +return 0 ; +} +/** * zynqmp_pm_get_trustzone_version() - Get secure trustzone firmware version * @version: Returned version value @@ -1911,6 +1948,11 @@ static int zynqmp_firmware_probe(struct platform_device *pdev)pr_info ("%s Platform Management API v%d.%d\n" , __func__, pm_api_version >>16 , pm_api_version &0xFFFF ); +/* Get the Family code and sub family code of platform */ + ret =zynqmp_pm_get_family_info (&pm_family_code, &pm_sub_family_code); +if (ret <0 ) +return ret; +/* Check trustzone version number */ ret =zynqmp_pm_get_trustzone_version (&pm_tz_version);if (ret)include/linux/firmware/xlnx-zynqmp.h +2
-0@@ -34,6 +34,19 @@/* PM API versions */ #define PM_API_VERSION_2 2 +#define ZYNQMP_FAMILY_CODE 0x23 +#define VERSAL_FAMILY_CODE 0x26
include/linux/firmware/xlnx-zynqmp.h line 48
Quoted 10 lines
include/linux/firmware/xlnx-zynqmp.h +10
-0+ +/* When all subfamily of platform need to support */ +#define ALL_SUB_FAMILY_CODE 0x00 +#define VERSAL_SUB_FAMILY_CODE 0x01 +#define VERSALNET_SUB_FAMILY_CODE 0x03 + +#define FAMILY_CODE_LSB 21 +#define FAMILY_CODE_MSB 27 +#define SUB_FAMILY_CODE_LSB 19 +#define SUB_FAMILY_CODE_MSB 20
nit: It was likely easier to do it like below. You can avoid so many defines.
#define FAMILY_CODE_MASK GENMASK(27, 21)
#define SUB_FAMILY_CODE_MASK GENMASK(20, 19)
include/linux/firmware/xlnx-zynqmp.h line 52
Quoted 4 lines
include/linux/firmware/xlnx-zynqmp.h +1
-0+/* ATF only commands */ #define TF_A_PM_REGISTER_SGI 0xa04#define PM_GET_TRUSTZONE_VERSION 0xa03
Thanks,
Michal
PATCH v2 2/4 firmware: xilinx: Add version check for TRISTATE configuration
In reply to Sai Krishna PotthuriSupport 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.
--- drivers/firmware/xilinx/zynqmp.c | 9 +++++++++ include/linux/firmware/xlnx-zynqmp.h | 2 ++ 2 files changed, 11 insertions(+)
drivers/firmware/xilinx/zynqmp.c +9 -0
@@ -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 ); }
include/linux/firmware/xlnx-zynqmp.h +2 -0
@@ -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
Signature · 1 line
2.25.1
Re: [PATCH v2 2/4] firmware: xilinx: Add version check for TRISTATE configuration
Quoted 37 lines · Sai Krishna Potthuri
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 <[email protected]>--- drivers/firmware/xilinx/zynqmp.c | 9 +++++++++ include/linux/firmware/xlnx-zynqmp.h | 2 ++ 2 files changed, 11 insertions(+)drivers/firmware/xilinx/zynqmp.c +9
-0@@ -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 ); }include/linux/firmware/xlnx-zynqmp.h +0
-0
include/linux/firmware/xlnx-zynqmp.h line 41
Quoted 8 lines
include/linux/firmware/xlnx-zynqmp.h +2
-0@@ -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
Thanks,
Michal
A message that is not in the archive (sent off-list or not yet received): [email protected]
RE: [PATCH v2 2/4] firmware: xilinx: Add version check for TRISTATE configuration
From: Shah, Tanmay <[email protected]>
Sent: Monday, July 24, 2023 8:57 PM
To: Potthuri, Sai Krishna <[email protected]>; Linus Walleij <[email protected]>; Simek, Michal <[email protected]>; Rob Herring <[email protected]>; Krzysztof Kozlowski <[email protected]>; Conor Dooley <[email protected]>; Mathieu Poirier <[email protected]>; Levinsky, Ben <[email protected]>; Marek Vasut <[email protected]>; Roman Gushchin <[email protected]>; Arnd Bergmann <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; git (AMD-Xilinx) <[email protected]>
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.
--- drivers/firmware/xilinx/zynqmp.c | 9 +++++++++ include/linux/firmware/xlnx-zynqmp.h | 2 ++ 2 files changed, 11 insertions(+)
drivers/firmware/xilinx/zynqmp.c +7 -0
@@ -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);
}
include/linux/firmware/xlnx-zynqmp.h +2 -0
@@ -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 v2 3/4 dt-bindings: pinctrl-zynqmp: Add output-enable configuration
In reply to Sai Krishna PotthuriAdd 'output-enable' configuration parameter to the properties list.
Using these pinctrl properties observed hang issues with older Xilinx ZynqMP Platform Management Firmware, hence reverted the patch previously. Commit ff8356060e3a5e126abb ("Revert "dt-bindings: pinctrl-zynqmp: Add output-enable configuration"").
Support for configuring these properties added in Xilinx ZynqMP Platform Management firmware(PMUFW) Configuration Set version 2.0. Linux firmware driver checks if the configuration is supported by the PMUFW when it gets request for TRISTATE configuration from pinctrl driver. If it supports, then calls will be made otherwise it returns error.
--- .../devicetree/bindings/pinctrl/xlnx,zynqmp-pinctrl.yaml | 4 ++++ 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/pinctrl/xlnx,zynqmp-pinctrl.yaml +4 -0
@@ -274,6 +274,10 @@ patternProperties: slew-rate: enum: [0, 1] + output-enable: + description: + This will internally disable the tri-state for MIO pins. + drive-strength: description: Selects the drive strength for MIO pins, in mA.
Signature · 1 line
2.25.1
PATCH v2 4/4 pinctrl: pinctrl-zynqmp: Add support for output-enable and bias-high impedance
In reply to Sai Krishna PotthuriAdd support to handle 'output-enable' and 'bias-high-impedance' configurations.
Using these pinctrl properties observed hang issues with older PMUFW(Xilinx ZynqMP Platform Management Firmware), hence reverted the patch. Commit 9989bc33c4894e075167 ("Revert "pinctrl: pinctrl-zynqmp: Add support for output-enable and bias-high-impedance"").
Support for configuring these properties added in PMUFW Configuration Set version 2.0. When there is a request for these configurations from pinctrl driver for ZynqMP platform, xilinx firmware driver checks for this version before configuring these properties to avoid the hang issue and proceeds further only when firmware version is >=2 otherwise it returns error.
--- drivers/pinctrl/pinctrl-zynqmp.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/pinctrl/pinctrl-zynqmp.c +9 -0
@@ -415,6 +415,10 @@ static int zynqmp_pinconf_cfg_set(struct pinctrl_dev *pctldev,break ;case PIN_CONFIG_BIAS_HIGH_IMPEDANCE : + param =PM_PINCTRL_CONFIG_TRI_STATE ; + arg =PM_PINCTRL_TRI_STATE_ENABLE ; + ret =zynqmp_pm_pinctrl_set_config (pin, param, arg); +break ;case PIN_CONFIG_MODE_LOW_POWER :/* * These cases are mentioned in dts but configurable
@@ -423,6 +427,11 @@ static int zynqmp_pinconf_cfg_set(struct pinctrl_dev *pctldev,*/ ret =0 ;break ; +case PIN_CONFIG_OUTPUT_ENABLE : + param =PM_PINCTRL_CONFIG_TRI_STATE ; + arg =PM_PINCTRL_TRI_STATE_DISABLE ; + ret =zynqmp_pm_pinctrl_set_config (pin, param, arg); +break ;default : dev_warn(pctldev->dev, "unsupported configuration parameter '%u'\n",
Signature · 1 line
2.25.1