diff mbox series

[v3,1/3] firmware: xilinx: Add pinctrl support

Message ID 1613131643-60062-2-git-send-email-lakshmi.sai.krishna.potthuri@xilinx.com (mailing list archive)
State New, archived
Headers show
Series Add ZynqMP pinctrl driver | expand

Commit Message

Sai Krishna Potthuri Feb. 12, 2021, 12:07 p.m. UTC
Adding pinctrl support to query platform specific information (pins)
from firmware.

Signed-off-by: Sai Krishna Potthuri <lakshmi.sai.krishna.potthuri@xilinx.com>
Acked-by: Michal Simek <michal.simek@xilinx.com>
---
 drivers/firmware/xilinx/zynqmp.c     | 114 +++++++++++++++++++++++++++
 include/linux/firmware/xlnx-zynqmp.h |  90 +++++++++++++++++++++
 2 files changed, 204 insertions(+)

Comments

Nobuhiro Iwamatsu Feb. 28, 2021, 12:17 a.m. UTC | #1
Hi,

2021年2月12日(金) 21:10 Sai Krishna Potthuri
<lakshmi.sai.krishna.potthuri@xilinx.com>:
>
> Adding pinctrl support to query platform specific information (pins)
> from firmware.
>
> Signed-off-by: Sai Krishna Potthuri <lakshmi.sai.krishna.potthuri@xilinx.com>
> Acked-by: Michal Simek <michal.simek@xilinx.com>
> ---
>  drivers/firmware/xilinx/zynqmp.c     | 114 +++++++++++++++++++++++++++
>  include/linux/firmware/xlnx-zynqmp.h |  90 +++++++++++++++++++++
>  2 files changed, 204 insertions(+)
>
> diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c
> index efb8a66efc68..299c3d5a9ebd 100644
> --- a/drivers/firmware/xilinx/zynqmp.c
> +++ b/drivers/firmware/xilinx/zynqmp.c
> @@ -784,6 +784,120 @@ int zynqmp_pm_fpga_get_status(u32 *value)
>  }
>  EXPORT_SYMBOL_GPL(zynqmp_pm_fpga_get_status);
>

<snip>

> @@ -125,6 +131,12 @@ enum pm_query_id {
>         PM_QID_CLOCK_GET_FIXEDFACTOR_PARAMS,
>         PM_QID_CLOCK_GET_PARENTS,
>         PM_QID_CLOCK_GET_ATTRIBUTES,
> +       PM_QID_PINCTRL_GET_NUM_PINS = 6,
> +       PM_QID_PINCTRL_GET_NUM_FUNCTIONS = 7,
> +       PM_QID_PINCTRL_GET_NUM_FUNCTION_GROUPS = 8,
> +       PM_QID_PINCTRL_GET_FUNCTION_NAME = 9,
> +       PM_QID_PINCTRL_GET_FUNCTION_GROUPS = 10,
> +       PM_QID_PINCTRL_GET_PIN_GROUPS = 11,

These do not have to have values, Because PM_QID_INVALID is 0.

>         PM_QID_CLOCK_GET_NUM_CLOCKS = 12,

And you can drop value from this.

>         PM_QID_CLOCK_GET_MAX_DIVISOR,
>  };
> @@ -288,6 +300,44 @@ enum dll_reset_type {
>         PM_DLL_RESET_PULSE,
>  };
>
> +enum pm_pinctrl_config_param {
> +       PM_PINCTRL_CONFIG_SLEW_RATE = 0,
> +       PM_PINCTRL_CONFIG_BIAS_STATUS = 1,
> +       PM_PINCTRL_CONFIG_PULL_CTRL = 2,
> +       PM_PINCTRL_CONFIG_SCHMITT_CMOS = 3,
> +       PM_PINCTRL_CONFIG_DRIVE_STRENGTH = 4,
> +       PM_PINCTRL_CONFIG_VOLTAGE_STATUS = 5,
> +       PM_PINCTRL_CONFIG_TRI_STATE = 6,
> +       PM_PINCTRL_CONFIG_MAX = 7,
> +};

Same as above.

> +
> +enum pm_pinctrl_slew_rate {
> +       PM_PINCTRL_SLEW_RATE_FAST = 0,
> +       PM_PINCTRL_SLEW_RATE_SLOW = 1,
> +};

Same as above. Others are also specified.

> +
> +enum pm_pinctrl_bias_status {
> +       PM_PINCTRL_BIAS_DISABLE = 0,
> +       PM_PINCTRL_BIAS_ENABLE = 1,
> +};

Best regards,
  Nobuhiro
Michal Simek March 1, 2021, 7:07 a.m. UTC | #2
Hi Noburiho,

On 2/28/21 1:17 AM, Nobuhiro Iwamatsu wrote:
> Hi,
> 
> 2021年2月12日(金) 21:10 Sai Krishna Potthuri
> <lakshmi.sai.krishna.potthuri@xilinx.com>:
>>
>> Adding pinctrl support to query platform specific information (pins)
>> from firmware.
>>
>> Signed-off-by: Sai Krishna Potthuri <lakshmi.sai.krishna.potthuri@xilinx.com>
>> Acked-by: Michal Simek <michal.simek@xilinx.com>
>> ---
>>  drivers/firmware/xilinx/zynqmp.c     | 114 +++++++++++++++++++++++++++
>>  include/linux/firmware/xlnx-zynqmp.h |  90 +++++++++++++++++++++
>>  2 files changed, 204 insertions(+)
>>
>> diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c
>> index efb8a66efc68..299c3d5a9ebd 100644
>> --- a/drivers/firmware/xilinx/zynqmp.c
>> +++ b/drivers/firmware/xilinx/zynqmp.c
>> @@ -784,6 +784,120 @@ int zynqmp_pm_fpga_get_status(u32 *value)
>>  }
>>  EXPORT_SYMBOL_GPL(zynqmp_pm_fpga_get_status);
>>
> 
> <snip>
> 
>> @@ -125,6 +131,12 @@ enum pm_query_id {
>>         PM_QID_CLOCK_GET_FIXEDFACTOR_PARAMS,
>>         PM_QID_CLOCK_GET_PARENTS,
>>         PM_QID_CLOCK_GET_ATTRIBUTES,
>> +       PM_QID_PINCTRL_GET_NUM_PINS = 6,
>> +       PM_QID_PINCTRL_GET_NUM_FUNCTIONS = 7,
>> +       PM_QID_PINCTRL_GET_NUM_FUNCTION_GROUPS = 8,
>> +       PM_QID_PINCTRL_GET_FUNCTION_NAME = 9,
>> +       PM_QID_PINCTRL_GET_FUNCTION_GROUPS = 10,
>> +       PM_QID_PINCTRL_GET_PIN_GROUPS = 11,
> 
> These do not have to have values, Because PM_QID_INVALID is 0.
> 
>>         PM_QID_CLOCK_GET_NUM_CLOCKS = 12,
> 
> And you can drop value from this.

Please take a look at
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/include/linux/firmware/xlnx-zynqmp.h?h=v5.12-rc1&id=1077d4367ab3b97f6db2f66c87289af863652215

We are using explicit values as was recommended by Greg.

Thanks,
Michal
Nobuhiro Iwamatsu March 2, 2021, 8:09 a.m. UTC | #3
Hi,

2021年3月1日(月) 16:07 Michal Simek <monstr@monstr.eu>:
>
> Hi Noburiho,
>
> On 2/28/21 1:17 AM, Nobuhiro Iwamatsu wrote:
> > Hi,
> >
> > 2021年2月12日(金) 21:10 Sai Krishna Potthuri
> > <lakshmi.sai.krishna.potthuri@xilinx.com>:
> >>
> >> Adding pinctrl support to query platform specific information (pins)
> >> from firmware.
> >>
> >> Signed-off-by: Sai Krishna Potthuri <lakshmi.sai.krishna.potthuri@xilinx.com>
> >> Acked-by: Michal Simek <michal.simek@xilinx.com>
> >> ---
> >>  drivers/firmware/xilinx/zynqmp.c     | 114 +++++++++++++++++++++++++++
> >>  include/linux/firmware/xlnx-zynqmp.h |  90 +++++++++++++++++++++
> >>  2 files changed, 204 insertions(+)
> >>
> >> diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c
> >> index efb8a66efc68..299c3d5a9ebd 100644
> >> --- a/drivers/firmware/xilinx/zynqmp.c
> >> +++ b/drivers/firmware/xilinx/zynqmp.c
> >> @@ -784,6 +784,120 @@ int zynqmp_pm_fpga_get_status(u32 *value)
> >>  }
> >>  EXPORT_SYMBOL_GPL(zynqmp_pm_fpga_get_status);
> >>
> >
> > <snip>
> >
> >> @@ -125,6 +131,12 @@ enum pm_query_id {
> >>         PM_QID_CLOCK_GET_FIXEDFACTOR_PARAMS,
> >>         PM_QID_CLOCK_GET_PARENTS,
> >>         PM_QID_CLOCK_GET_ATTRIBUTES,
> >> +       PM_QID_PINCTRL_GET_NUM_PINS = 6,
> >> +       PM_QID_PINCTRL_GET_NUM_FUNCTIONS = 7,
> >> +       PM_QID_PINCTRL_GET_NUM_FUNCTION_GROUPS = 8,
> >> +       PM_QID_PINCTRL_GET_FUNCTION_NAME = 9,
> >> +       PM_QID_PINCTRL_GET_FUNCTION_GROUPS = 10,
> >> +       PM_QID_PINCTRL_GET_PIN_GROUPS = 11,
> >
> > These do not have to have values, Because PM_QID_INVALID is 0.
> >
> >>         PM_QID_CLOCK_GET_NUM_CLOCKS = 12,
> >
> > And you can drop value from this.
>
> Please take a look at
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/include/linux/firmware/xlnx-zynqmp.h?h=v5.12-rc1&id=1077d4367ab3b97f6db2f66c87289af863652215
>
> We are using explicit values as was recommended by Greg.

Oh, sorry.
I didn't see this comment. Thank you for this information.

>
> Thanks,
> Michal
>

Best regards,
  Nobuhiro
diff mbox series

Patch

diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c
index efb8a66efc68..299c3d5a9ebd 100644
--- a/drivers/firmware/xilinx/zynqmp.c
+++ b/drivers/firmware/xilinx/zynqmp.c
@@ -784,6 +784,120 @@  int zynqmp_pm_fpga_get_status(u32 *value)
 }
 EXPORT_SYMBOL_GPL(zynqmp_pm_fpga_get_status);
 
+/**
+ * zynqmp_pm_pinctrl_request - Request Pin from firmware
+ * @pin: Pin number to request
+ *
+ * This function requests pin from firmware.
+ *
+ * Return: Returns status, either success or error+reason.
+ */
+int zynqmp_pm_pinctrl_request(const u32 pin)
+{
+	return zynqmp_pm_invoke_fn(PM_PINCTRL_REQUEST, pin, 0, 0, 0, NULL);
+}
+EXPORT_SYMBOL_GPL(zynqmp_pm_pinctrl_request);
+
+/**
+ * zynqmp_pm_pinctrl_release - Inform firmware that Pin control is released
+ * @pin: Pin number to release
+ *
+ * This function release pin from firmware.
+ *
+ * Return: Returns status, either success or error+reason.
+ */
+int zynqmp_pm_pinctrl_release(const u32 pin)
+{
+	return zynqmp_pm_invoke_fn(PM_PINCTRL_RELEASE, pin, 0, 0, 0, NULL);
+}
+EXPORT_SYMBOL_GPL(zynqmp_pm_pinctrl_release);
+
+/**
+ * zynqmp_pm_pinctrl_get_function - Read function id set for the given pin
+ * @pin: Pin number
+ * @id: Buffer to store function ID
+ *
+ * This function provides the function currently set for the given pin.
+ *
+ * Return: Returns status, either success or error+reason
+ */
+int zynqmp_pm_pinctrl_get_function(const u32 pin, u32 *id)
+{
+	u32 ret_payload[PAYLOAD_ARG_CNT];
+	int ret;
+
+	if (!id)
+		return -EINVAL;
+
+	ret = zynqmp_pm_invoke_fn(PM_PINCTRL_GET_FUNCTION, pin, 0,
+				  0, 0, ret_payload);
+	*id = ret_payload[1];
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(zynqmp_pm_pinctrl_get_function);
+
+/**
+ * zynqmp_pm_pinctrl_set_function - Set requested function for the pin
+ * @pin: Pin number
+ * @id: Function ID to set
+ *
+ * This function sets requested function for the given pin.
+ *
+ * Return: Returns status, either success or error+reason.
+ */
+int zynqmp_pm_pinctrl_set_function(const u32 pin, const u32 id)
+{
+	return zynqmp_pm_invoke_fn(PM_PINCTRL_SET_FUNCTION, pin, id,
+				   0, 0, NULL);
+}
+EXPORT_SYMBOL_GPL(zynqmp_pm_pinctrl_set_function);
+
+/**
+ * zynqmp_pm_pinctrl_get_config - Get configuration parameter for the pin
+ * @pin: Pin number
+ * @param: Parameter to get
+ * @value: Buffer to store parameter value
+ *
+ * This function gets requested configuration parameter for the given pin.
+ *
+ * Return: Returns status, either success or error+reason.
+ */
+int zynqmp_pm_pinctrl_get_config(const u32 pin, const u32 param,
+				 u32 *value)
+{
+	u32 ret_payload[PAYLOAD_ARG_CNT];
+	int ret;
+
+	if (!value)
+		return -EINVAL;
+
+	ret = zynqmp_pm_invoke_fn(PM_PINCTRL_CONFIG_PARAM_GET, pin, param,
+				  0, 0, ret_payload);
+	*value = ret_payload[1];
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(zynqmp_pm_pinctrl_get_config);
+
+/**
+ * zynqmp_pm_pinctrl_set_config - Set configuration parameter for the pin
+ * @pin: Pin number
+ * @param: Parameter to set
+ * @value: Parameter value to set
+ *
+ * This function sets requested configuration parameter for the given pin.
+ *
+ * Return: Returns status, either success or error+reason.
+ */
+int zynqmp_pm_pinctrl_set_config(const u32 pin, const u32 param,
+				 u32 value)
+{
+	return zynqmp_pm_invoke_fn(PM_PINCTRL_CONFIG_PARAM_SET, pin,
+				   param, value, 0, NULL);
+}
+EXPORT_SYMBOL_GPL(zynqmp_pm_pinctrl_set_config);
+
 /**
  * zynqmp_pm_init_finalize() - PM call to inform firmware that the caller
  *			       master has initialized its own power management
diff --git a/include/linux/firmware/xlnx-zynqmp.h b/include/linux/firmware/xlnx-zynqmp.h
index 5968df82b991..75aa6a5afa28 100644
--- a/include/linux/firmware/xlnx-zynqmp.h
+++ b/include/linux/firmware/xlnx-zynqmp.h
@@ -74,6 +74,12 @@  enum pm_api_id {
 	PM_FPGA_LOAD,
 	PM_FPGA_GET_STATUS,
 	PM_GET_CHIPID = 24,
+	PM_PINCTRL_REQUEST = 28,
+	PM_PINCTRL_RELEASE = 29,
+	PM_PINCTRL_GET_FUNCTION = 30,
+	PM_PINCTRL_SET_FUNCTION = 31,
+	PM_PINCTRL_CONFIG_PARAM_GET = 32,
+	PM_PINCTRL_CONFIG_PARAM_SET = 33,
 	PM_IOCTL = 34,
 	PM_QUERY_DATA,
 	PM_CLOCK_ENABLE,
@@ -125,6 +131,12 @@  enum pm_query_id {
 	PM_QID_CLOCK_GET_FIXEDFACTOR_PARAMS,
 	PM_QID_CLOCK_GET_PARENTS,
 	PM_QID_CLOCK_GET_ATTRIBUTES,
+	PM_QID_PINCTRL_GET_NUM_PINS = 6,
+	PM_QID_PINCTRL_GET_NUM_FUNCTIONS = 7,
+	PM_QID_PINCTRL_GET_NUM_FUNCTION_GROUPS = 8,
+	PM_QID_PINCTRL_GET_FUNCTION_NAME = 9,
+	PM_QID_PINCTRL_GET_FUNCTION_GROUPS = 10,
+	PM_QID_PINCTRL_GET_PIN_GROUPS = 11,
 	PM_QID_CLOCK_GET_NUM_CLOCKS = 12,
 	PM_QID_CLOCK_GET_MAX_DIVISOR,
 };
@@ -288,6 +300,44 @@  enum dll_reset_type {
 	PM_DLL_RESET_PULSE,
 };
 
+enum pm_pinctrl_config_param {
+	PM_PINCTRL_CONFIG_SLEW_RATE = 0,
+	PM_PINCTRL_CONFIG_BIAS_STATUS = 1,
+	PM_PINCTRL_CONFIG_PULL_CTRL = 2,
+	PM_PINCTRL_CONFIG_SCHMITT_CMOS = 3,
+	PM_PINCTRL_CONFIG_DRIVE_STRENGTH = 4,
+	PM_PINCTRL_CONFIG_VOLTAGE_STATUS = 5,
+	PM_PINCTRL_CONFIG_TRI_STATE = 6,
+	PM_PINCTRL_CONFIG_MAX = 7,
+};
+
+enum pm_pinctrl_slew_rate {
+	PM_PINCTRL_SLEW_RATE_FAST = 0,
+	PM_PINCTRL_SLEW_RATE_SLOW = 1,
+};
+
+enum pm_pinctrl_bias_status {
+	PM_PINCTRL_BIAS_DISABLE = 0,
+	PM_PINCTRL_BIAS_ENABLE = 1,
+};
+
+enum pm_pinctrl_pull_ctrl {
+	PM_PINCTRL_BIAS_PULL_DOWN = 0,
+	PM_PINCTRL_BIAS_PULL_UP = 1,
+};
+
+enum pm_pinctrl_schmitt_cmos {
+	PM_PINCTRL_INPUT_TYPE_CMOS = 0,
+	PM_PINCTRL_INPUT_TYPE_SCHMITT = 1,
+};
+
+enum pm_pinctrl_drive_strength {
+	PM_PINCTRL_DRIVE_STRENGTH_2MA = 0,
+	PM_PINCTRL_DRIVE_STRENGTH_4MA = 1,
+	PM_PINCTRL_DRIVE_STRENGTH_8MA = 2,
+	PM_PINCTRL_DRIVE_STRENGTH_12MA = 3,
+};
+
 enum zynqmp_pm_shutdown_type {
 	ZYNQMP_PM_SHUTDOWN_TYPE_SHUTDOWN,
 	ZYNQMP_PM_SHUTDOWN_TYPE_RESET,
@@ -357,6 +407,14 @@  int zynqmp_pm_write_pggs(u32 index, u32 value);
 int zynqmp_pm_read_pggs(u32 index, u32 *value);
 int zynqmp_pm_system_shutdown(const u32 type, const u32 subtype);
 int zynqmp_pm_set_boot_health_status(u32 value);
+int zynqmp_pm_pinctrl_request(const u32 pin);
+int zynqmp_pm_pinctrl_release(const u32 pin);
+int zynqmp_pm_pinctrl_get_function(const u32 pin, u32 *id);
+int zynqmp_pm_pinctrl_set_function(const u32 pin, const u32 id);
+int zynqmp_pm_pinctrl_get_config(const u32 pin, const u32 param,
+				 u32 *value);
+int zynqmp_pm_pinctrl_set_config(const u32 pin, const u32 param,
+				 u32 value);
 #else
 static inline struct zynqmp_eemi_ops *zynqmp_pm_get_eemi_ops(void)
 {
@@ -507,6 +565,38 @@  static inline int zynqmp_pm_set_boot_health_status(u32 value)
 {
 	return -ENODEV;
 }
+
+static inline int zynqmp_pm_pinctrl_request(const u32 pin)
+{
+	return -ENODEV;
+}
+
+static inline int zynqmp_pm_pinctrl_release(const u32 pin)
+{
+	return -ENODEV;
+}
+
+static inline int zynqmp_pm_pinctrl_get_function(const u32 pin, u32 *id)
+{
+	return -ENODEV;
+}
+
+static inline int zynqmp_pm_pinctrl_set_function(const u32 pin, const u32 id)
+{
+	return -ENODEV;
+}
+
+static inline int zynqmp_pm_pinctrl_get_config(const u32 pin, const u32 param,
+					       u32 *value)
+{
+	return -ENODEV;
+}
+
+static inline int zynqmp_pm_pinctrl_set_config(const u32 pin, const u32 param,
+					       u32 value)
+{
+	return -ENODEV;
+}
 #endif
 
 #endif /* __FIRMWARE_ZYNQMP_H__ */