Skip to content

Commit fa989ae

Browse files
Sai Krishna PotthuriLinus Walleij
authored andcommitted
firmware: xilinx: Add pinctrl support
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> Link: https://lore.kernel.org/r/1619080202-31924-2-git-send-email-lakshmi.sai.krishna.potthuri@xilinx.com Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
1 parent fe202ea commit fa989ae

2 files changed

Lines changed: 204 additions & 0 deletions

File tree

‎drivers/firmware/xilinx/zynqmp.c‎

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -811,6 +811,120 @@ int zynqmp_pm_fpga_get_status(u32 *value)
811811
}
812812
EXPORT_SYMBOL_GPL(zynqmp_pm_fpga_get_status);
813813

814+
/**
815+
* zynqmp_pm_pinctrl_request - Request Pin from firmware
816+
* @pin: Pin number to request
817+
*
818+
* This function requests pin from firmware.
819+
*
820+
* Return: Returns status, either success or error+reason.
821+
*/
822+
int zynqmp_pm_pinctrl_request(const u32 pin)
823+
{
824+
return zynqmp_pm_invoke_fn(PM_PINCTRL_REQUEST, pin, 0, 0, 0, NULL);
825+
}
826+
EXPORT_SYMBOL_GPL(zynqmp_pm_pinctrl_request);
827+
828+
/**
829+
* zynqmp_pm_pinctrl_release - Inform firmware that Pin control is released
830+
* @pin: Pin number to release
831+
*
832+
* This function release pin from firmware.
833+
*
834+
* Return: Returns status, either success or error+reason.
835+
*/
836+
int zynqmp_pm_pinctrl_release(const u32 pin)
837+
{
838+
return zynqmp_pm_invoke_fn(PM_PINCTRL_RELEASE, pin, 0, 0, 0, NULL);
839+
}
840+
EXPORT_SYMBOL_GPL(zynqmp_pm_pinctrl_release);
841+
842+
/**
843+
* zynqmp_pm_pinctrl_get_function - Read function id set for the given pin
844+
* @pin: Pin number
845+
* @id: Buffer to store function ID
846+
*
847+
* This function provides the function currently set for the given pin.
848+
*
849+
* Return: Returns status, either success or error+reason
850+
*/
851+
int zynqmp_pm_pinctrl_get_function(const u32 pin, u32 *id)
852+
{
853+
u32 ret_payload[PAYLOAD_ARG_CNT];
854+
int ret;
855+
856+
if (!id)
857+
return -EINVAL;
858+
859+
ret = zynqmp_pm_invoke_fn(PM_PINCTRL_GET_FUNCTION, pin, 0,
860+
0, 0, ret_payload);
861+
*id = ret_payload[1];
862+
863+
return ret;
864+
}
865+
EXPORT_SYMBOL_GPL(zynqmp_pm_pinctrl_get_function);
866+
867+
/**
868+
* zynqmp_pm_pinctrl_set_function - Set requested function for the pin
869+
* @pin: Pin number
870+
* @id: Function ID to set
871+
*
872+
* This function sets requested function for the given pin.
873+
*
874+
* Return: Returns status, either success or error+reason.
875+
*/
876+
int zynqmp_pm_pinctrl_set_function(const u32 pin, const u32 id)
877+
{
878+
return zynqmp_pm_invoke_fn(PM_PINCTRL_SET_FUNCTION, pin, id,
879+
0, 0, NULL);
880+
}
881+
EXPORT_SYMBOL_GPL(zynqmp_pm_pinctrl_set_function);
882+
883+
/**
884+
* zynqmp_pm_pinctrl_get_config - Get configuration parameter for the pin
885+
* @pin: Pin number
886+
* @param: Parameter to get
887+
* @value: Buffer to store parameter value
888+
*
889+
* This function gets requested configuration parameter for the given pin.
890+
*
891+
* Return: Returns status, either success or error+reason.
892+
*/
893+
int zynqmp_pm_pinctrl_get_config(const u32 pin, const u32 param,
894+
u32 *value)
895+
{
896+
u32 ret_payload[PAYLOAD_ARG_CNT];
897+
int ret;
898+
899+
if (!value)
900+
return -EINVAL;
901+
902+
ret = zynqmp_pm_invoke_fn(PM_PINCTRL_CONFIG_PARAM_GET, pin, param,
903+
0, 0, ret_payload);
904+
*value = ret_payload[1];
905+
906+
return ret;
907+
}
908+
EXPORT_SYMBOL_GPL(zynqmp_pm_pinctrl_get_config);
909+
910+
/**
911+
* zynqmp_pm_pinctrl_set_config - Set configuration parameter for the pin
912+
* @pin: Pin number
913+
* @param: Parameter to set
914+
* @value: Parameter value to set
915+
*
916+
* This function sets requested configuration parameter for the given pin.
917+
*
918+
* Return: Returns status, either success or error+reason.
919+
*/
920+
int zynqmp_pm_pinctrl_set_config(const u32 pin, const u32 param,
921+
u32 value)
922+
{
923+
return zynqmp_pm_invoke_fn(PM_PINCTRL_CONFIG_PARAM_SET, pin,
924+
param, value, 0, NULL);
925+
}
926+
EXPORT_SYMBOL_GPL(zynqmp_pm_pinctrl_set_config);
927+
814928
/**
815929
* zynqmp_pm_init_finalize() - PM call to inform firmware that the caller
816930
* master has initialized its own power management

‎include/linux/firmware/xlnx-zynqmp.h‎

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ enum pm_api_id {
7272
PM_FPGA_LOAD = 22,
7373
PM_FPGA_GET_STATUS = 23,
7474
PM_GET_CHIPID = 24,
75+
PM_PINCTRL_REQUEST = 28,
76+
PM_PINCTRL_RELEASE = 29,
77+
PM_PINCTRL_GET_FUNCTION = 30,
78+
PM_PINCTRL_SET_FUNCTION = 31,
79+
PM_PINCTRL_CONFIG_PARAM_GET = 32,
80+
PM_PINCTRL_CONFIG_PARAM_SET = 33,
7581
PM_IOCTL = 34,
7682
PM_QUERY_DATA = 35,
7783
PM_CLOCK_ENABLE = 36,
@@ -122,6 +128,12 @@ enum pm_query_id {
122128
PM_QID_CLOCK_GET_FIXEDFACTOR_PARAMS = 3,
123129
PM_QID_CLOCK_GET_PARENTS = 4,
124130
PM_QID_CLOCK_GET_ATTRIBUTES = 5,
131+
PM_QID_PINCTRL_GET_NUM_PINS = 6,
132+
PM_QID_PINCTRL_GET_NUM_FUNCTIONS = 7,
133+
PM_QID_PINCTRL_GET_NUM_FUNCTION_GROUPS = 8,
134+
PM_QID_PINCTRL_GET_FUNCTION_NAME = 9,
135+
PM_QID_PINCTRL_GET_FUNCTION_GROUPS = 10,
136+
PM_QID_PINCTRL_GET_PIN_GROUPS = 11,
125137
PM_QID_CLOCK_GET_NUM_CLOCKS = 12,
126138
PM_QID_CLOCK_GET_MAX_DIVISOR = 13,
127139
};
@@ -285,6 +297,44 @@ enum dll_reset_type {
285297
PM_DLL_RESET_PULSE = 2,
286298
};
287299

300+
enum pm_pinctrl_config_param {
301+
PM_PINCTRL_CONFIG_SLEW_RATE = 0,
302+
PM_PINCTRL_CONFIG_BIAS_STATUS = 1,
303+
PM_PINCTRL_CONFIG_PULL_CTRL = 2,
304+
PM_PINCTRL_CONFIG_SCHMITT_CMOS = 3,
305+
PM_PINCTRL_CONFIG_DRIVE_STRENGTH = 4,
306+
PM_PINCTRL_CONFIG_VOLTAGE_STATUS = 5,
307+
PM_PINCTRL_CONFIG_TRI_STATE = 6,
308+
PM_PINCTRL_CONFIG_MAX = 7,
309+
};
310+
311+
enum pm_pinctrl_slew_rate {
312+
PM_PINCTRL_SLEW_RATE_FAST = 0,
313+
PM_PINCTRL_SLEW_RATE_SLOW = 1,
314+
};
315+
316+
enum pm_pinctrl_bias_status {
317+
PM_PINCTRL_BIAS_DISABLE = 0,
318+
PM_PINCTRL_BIAS_ENABLE = 1,
319+
};
320+
321+
enum pm_pinctrl_pull_ctrl {
322+
PM_PINCTRL_BIAS_PULL_DOWN = 0,
323+
PM_PINCTRL_BIAS_PULL_UP = 1,
324+
};
325+
326+
enum pm_pinctrl_schmitt_cmos {
327+
PM_PINCTRL_INPUT_TYPE_CMOS = 0,
328+
PM_PINCTRL_INPUT_TYPE_SCHMITT = 1,
329+
};
330+
331+
enum pm_pinctrl_drive_strength {
332+
PM_PINCTRL_DRIVE_STRENGTH_2MA = 0,
333+
PM_PINCTRL_DRIVE_STRENGTH_4MA = 1,
334+
PM_PINCTRL_DRIVE_STRENGTH_8MA = 2,
335+
PM_PINCTRL_DRIVE_STRENGTH_12MA = 3,
336+
};
337+
288338
enum zynqmp_pm_shutdown_type {
289339
ZYNQMP_PM_SHUTDOWN_TYPE_SHUTDOWN = 0,
290340
ZYNQMP_PM_SHUTDOWN_TYPE_RESET = 1,
@@ -353,6 +403,14 @@ int zynqmp_pm_write_pggs(u32 index, u32 value);
353403
int zynqmp_pm_read_pggs(u32 index, u32 *value);
354404
int zynqmp_pm_system_shutdown(const u32 type, const u32 subtype);
355405
int zynqmp_pm_set_boot_health_status(u32 value);
406+
int zynqmp_pm_pinctrl_request(const u32 pin);
407+
int zynqmp_pm_pinctrl_release(const u32 pin);
408+
int zynqmp_pm_pinctrl_get_function(const u32 pin, u32 *id);
409+
int zynqmp_pm_pinctrl_set_function(const u32 pin, const u32 id);
410+
int zynqmp_pm_pinctrl_get_config(const u32 pin, const u32 param,
411+
u32 *value);
412+
int zynqmp_pm_pinctrl_set_config(const u32 pin, const u32 param,
413+
u32 value);
356414
#else
357415
static inline struct zynqmp_eemi_ops *zynqmp_pm_get_eemi_ops(void)
358416
{
@@ -537,6 +595,38 @@ static inline int zynqmp_pm_set_boot_health_status(u32 value)
537595
{
538596
return -ENODEV;
539597
}
598+
599+
static inline int zynqmp_pm_pinctrl_request(const u32 pin)
600+
{
601+
return -ENODEV;
602+
}
603+
604+
static inline int zynqmp_pm_pinctrl_release(const u32 pin)
605+
{
606+
return -ENODEV;
607+
}
608+
609+
static inline int zynqmp_pm_pinctrl_get_function(const u32 pin, u32 *id)
610+
{
611+
return -ENODEV;
612+
}
613+
614+
static inline int zynqmp_pm_pinctrl_set_function(const u32 pin, const u32 id)
615+
{
616+
return -ENODEV;
617+
}
618+
619+
static inline int zynqmp_pm_pinctrl_get_config(const u32 pin, const u32 param,
620+
u32 *value)
621+
{
622+
return -ENODEV;
623+
}
624+
625+
static inline int zynqmp_pm_pinctrl_set_config(const u32 pin, const u32 param,
626+
u32 value)
627+
{
628+
return -ENODEV;
629+
}
540630
#endif
541631

542632
#endif /* __FIRMWARE_ZYNQMP_H__ */

0 commit comments

Comments
 (0)