Commit 3b0296b8 authored by Rajan Vaja's avatar Rajan Vaja Committed by Michal Simek

firmware: xilinx: Add zynqmp IOCTL API for device control

Add ZynqMP firmware IOCTL API to control and configure
devices like PLLs, SD, Gem, etc.
Signed-off-by: default avatarRajan Vaja <rajan.vaja@xilinx.com>
Signed-off-by: default avatarJolly Shah <jollys@xilinx.com>
Acked-by: default avatarOlof Johansson <olof@lixom.net>
Signed-off-by: default avatarMichal Simek <michal.simek@xilinx.com>
parent 8cc7bc8e
...@@ -428,6 +428,47 @@ static int zynqmp_pm_clock_getparent(u32 clock_id, u32 *parent_id) ...@@ -428,6 +428,47 @@ static int zynqmp_pm_clock_getparent(u32 clock_id, u32 *parent_id)
return ret; return ret;
} }
/**
* zynqmp_is_valid_ioctl() - Check whether IOCTL ID is valid or not
* @ioctl_id: IOCTL ID
*
* Return: 1 if IOCTL is valid else 0
*/
static inline int zynqmp_is_valid_ioctl(u32 ioctl_id)
{
switch (ioctl_id) {
case IOCTL_SET_PLL_FRAC_MODE:
case IOCTL_GET_PLL_FRAC_MODE:
case IOCTL_SET_PLL_FRAC_DATA:
case IOCTL_GET_PLL_FRAC_DATA:
return 1;
default:
return 0;
}
}
/**
* zynqmp_pm_ioctl() - PM IOCTL API for device control and configs
* @node_id: Node ID of the device
* @ioctl_id: ID of the requested IOCTL
* @arg1: Argument 1 to requested IOCTL call
* @arg2: Argument 2 to requested IOCTL call
* @out: Returned output value
*
* This function calls IOCTL to firmware for device control and configuration.
*
* Return: Returns status, either success or error+reason
*/
static int zynqmp_pm_ioctl(u32 node_id, u32 ioctl_id, u32 arg1, u32 arg2,
u32 *out)
{
if (!zynqmp_is_valid_ioctl(ioctl_id))
return -EINVAL;
return zynqmp_pm_invoke_fn(PM_IOCTL, node_id, ioctl_id,
arg1, arg2, out);
}
static const struct zynqmp_eemi_ops eemi_ops = { static const struct zynqmp_eemi_ops eemi_ops = {
.get_api_version = zynqmp_pm_get_api_version, .get_api_version = zynqmp_pm_get_api_version,
.query_data = zynqmp_pm_query_data, .query_data = zynqmp_pm_query_data,
...@@ -440,6 +481,7 @@ static const struct zynqmp_eemi_ops eemi_ops = { ...@@ -440,6 +481,7 @@ static const struct zynqmp_eemi_ops eemi_ops = {
.clock_getrate = zynqmp_pm_clock_getrate, .clock_getrate = zynqmp_pm_clock_getrate,
.clock_setparent = zynqmp_pm_clock_setparent, .clock_setparent = zynqmp_pm_clock_setparent,
.clock_getparent = zynqmp_pm_clock_getparent, .clock_getparent = zynqmp_pm_clock_getparent,
.ioctl = zynqmp_pm_ioctl,
}; };
/** /**
......
...@@ -34,7 +34,8 @@ ...@@ -34,7 +34,8 @@
enum pm_api_id { enum pm_api_id {
PM_GET_API_VERSION = 1, PM_GET_API_VERSION = 1,
PM_QUERY_DATA = 35, PM_IOCTL = 34,
PM_QUERY_DATA,
PM_CLOCK_ENABLE, PM_CLOCK_ENABLE,
PM_CLOCK_DISABLE, PM_CLOCK_DISABLE,
PM_CLOCK_GETSTATE, PM_CLOCK_GETSTATE,
...@@ -99,6 +100,7 @@ struct zynqmp_eemi_ops { ...@@ -99,6 +100,7 @@ struct zynqmp_eemi_ops {
int (*clock_getrate)(u32 clock_id, u64 *rate); int (*clock_getrate)(u32 clock_id, u64 *rate);
int (*clock_setparent)(u32 clock_id, u32 parent_id); int (*clock_setparent)(u32 clock_id, u32 parent_id);
int (*clock_getparent)(u32 clock_id, u32 *parent_id); int (*clock_getparent)(u32 clock_id, u32 *parent_id);
int (*ioctl)(u32 node_id, u32 ioctl_id, u32 arg1, u32 arg2, u32 *out);
}; };
#if IS_REACHABLE(CONFIG_ARCH_ZYNQMP) #if IS_REACHABLE(CONFIG_ARCH_ZYNQMP)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment