Skip to content

Commit 3b0296b

Browse files
rajanv-xilinxMichal Simek
authored andcommitted
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: Rajan Vaja <rajan.vaja@xilinx.com> Signed-off-by: Jolly Shah <jollys@xilinx.com> Acked-by: Olof Johansson <olof@lixom.net> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
1 parent 8cc7bc8 commit 3b0296b

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

drivers/firmware/xilinx/zynqmp.c

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,47 @@ static int zynqmp_pm_clock_getparent(u32 clock_id, u32 *parent_id)
428428
return ret;
429429
}
430430

431+
/**
432+
* zynqmp_is_valid_ioctl() - Check whether IOCTL ID is valid or not
433+
* @ioctl_id: IOCTL ID
434+
*
435+
* Return: 1 if IOCTL is valid else 0
436+
*/
437+
static inline int zynqmp_is_valid_ioctl(u32 ioctl_id)
438+
{
439+
switch (ioctl_id) {
440+
case IOCTL_SET_PLL_FRAC_MODE:
441+
case IOCTL_GET_PLL_FRAC_MODE:
442+
case IOCTL_SET_PLL_FRAC_DATA:
443+
case IOCTL_GET_PLL_FRAC_DATA:
444+
return 1;
445+
default:
446+
return 0;
447+
}
448+
}
449+
450+
/**
451+
* zynqmp_pm_ioctl() - PM IOCTL API for device control and configs
452+
* @node_id: Node ID of the device
453+
* @ioctl_id: ID of the requested IOCTL
454+
* @arg1: Argument 1 to requested IOCTL call
455+
* @arg2: Argument 2 to requested IOCTL call
456+
* @out: Returned output value
457+
*
458+
* This function calls IOCTL to firmware for device control and configuration.
459+
*
460+
* Return: Returns status, either success or error+reason
461+
*/
462+
static int zynqmp_pm_ioctl(u32 node_id, u32 ioctl_id, u32 arg1, u32 arg2,
463+
u32 *out)
464+
{
465+
if (!zynqmp_is_valid_ioctl(ioctl_id))
466+
return -EINVAL;
467+
468+
return zynqmp_pm_invoke_fn(PM_IOCTL, node_id, ioctl_id,
469+
arg1, arg2, out);
470+
}
471+
431472
static const struct zynqmp_eemi_ops eemi_ops = {
432473
.get_api_version = zynqmp_pm_get_api_version,
433474
.query_data = zynqmp_pm_query_data,
@@ -440,6 +481,7 @@ static const struct zynqmp_eemi_ops eemi_ops = {
440481
.clock_getrate = zynqmp_pm_clock_getrate,
441482
.clock_setparent = zynqmp_pm_clock_setparent,
442483
.clock_getparent = zynqmp_pm_clock_getparent,
484+
.ioctl = zynqmp_pm_ioctl,
443485
};
444486

445487
/**

include/linux/firmware/xlnx-zynqmp.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434

3535
enum pm_api_id {
3636
PM_GET_API_VERSION = 1,
37-
PM_QUERY_DATA = 35,
37+
PM_IOCTL = 34,
38+
PM_QUERY_DATA,
3839
PM_CLOCK_ENABLE,
3940
PM_CLOCK_DISABLE,
4041
PM_CLOCK_GETSTATE,
@@ -99,6 +100,7 @@ struct zynqmp_eemi_ops {
99100
int (*clock_getrate)(u32 clock_id, u64 *rate);
100101
int (*clock_setparent)(u32 clock_id, u32 parent_id);
101102
int (*clock_getparent)(u32 clock_id, u32 *parent_id);
103+
int (*ioctl)(u32 node_id, u32 ioctl_id, u32 arg1, u32 arg2, u32 *out);
102104
};
103105

104106
#if IS_REACHABLE(CONFIG_ARCH_ZYNQMP)

0 commit comments

Comments
 (0)