diff options
author | Rajan Vaja <rajan.vaja@xilinx.com> | 2018-10-08 14:21:44 -0400 |
---|---|---|
committer | Michal Simek <michal.simek@xilinx.com> | 2018-10-09 07:26:21 -0400 |
commit | 3b0296b8c893adb17b422179b9e779e4c32aa347 (patch) | |
tree | 81fe6d6d0ff3a833097c5cfe11442a4037bf7b07 | |
parent | 8cc7bc8ee21f539ffabf4ff7f30a0c6be9ac5ba9 (diff) |
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>
-rw-r--r-- | drivers/firmware/xilinx/zynqmp.c | 42 | ||||
-rw-r--r-- | include/linux/firmware/xlnx-zynqmp.h | 4 |
2 files changed, 45 insertions, 1 deletions
diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c index 84b3fd2eca8b..9a1c72a9280f 100644 --- a/drivers/firmware/xilinx/zynqmp.c +++ b/drivers/firmware/xilinx/zynqmp.c | |||
@@ -428,6 +428,47 @@ static int zynqmp_pm_clock_getparent(u32 clock_id, u32 *parent_id) | |||
428 | return ret; | 428 | return ret; |
429 | } | 429 | } |
430 | 430 | ||
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 | |||
431 | static const struct zynqmp_eemi_ops eemi_ops = { | 472 | static const struct zynqmp_eemi_ops eemi_ops = { |
432 | .get_api_version = zynqmp_pm_get_api_version, | 473 | .get_api_version = zynqmp_pm_get_api_version, |
433 | .query_data = zynqmp_pm_query_data, | 474 | .query_data = zynqmp_pm_query_data, |
@@ -440,6 +481,7 @@ static const struct zynqmp_eemi_ops eemi_ops = { | |||
440 | .clock_getrate = zynqmp_pm_clock_getrate, | 481 | .clock_getrate = zynqmp_pm_clock_getrate, |
441 | .clock_setparent = zynqmp_pm_clock_setparent, | 482 | .clock_setparent = zynqmp_pm_clock_setparent, |
442 | .clock_getparent = zynqmp_pm_clock_getparent, | 483 | .clock_getparent = zynqmp_pm_clock_getparent, |
484 | .ioctl = zynqmp_pm_ioctl, | ||
443 | }; | 485 | }; |
444 | 486 | ||
445 | /** | 487 | /** |
diff --git a/include/linux/firmware/xlnx-zynqmp.h b/include/linux/firmware/xlnx-zynqmp.h index 015e130431e6..7a9db0861803 100644 --- a/include/linux/firmware/xlnx-zynqmp.h +++ b/include/linux/firmware/xlnx-zynqmp.h | |||
@@ -34,7 +34,8 @@ | |||
34 | 34 | ||
35 | enum pm_api_id { | 35 | enum pm_api_id { |
36 | PM_GET_API_VERSION = 1, | 36 | PM_GET_API_VERSION = 1, |
37 | PM_QUERY_DATA = 35, | 37 | PM_IOCTL = 34, |
38 | PM_QUERY_DATA, | ||
38 | PM_CLOCK_ENABLE, | 39 | PM_CLOCK_ENABLE, |
39 | PM_CLOCK_DISABLE, | 40 | PM_CLOCK_DISABLE, |
40 | PM_CLOCK_GETSTATE, | 41 | PM_CLOCK_GETSTATE, |
@@ -99,6 +100,7 @@ struct zynqmp_eemi_ops { | |||
99 | int (*clock_getrate)(u32 clock_id, u64 *rate); | 100 | int (*clock_getrate)(u32 clock_id, u64 *rate); |
100 | int (*clock_setparent)(u32 clock_id, u32 parent_id); | 101 | int (*clock_setparent)(u32 clock_id, u32 parent_id); |
101 | int (*clock_getparent)(u32 clock_id, u32 *parent_id); | 102 | int (*clock_getparent)(u32 clock_id, u32 *parent_id); |
103 | int (*ioctl)(u32 node_id, u32 ioctl_id, u32 arg1, u32 arg2, u32 *out); | ||
102 | }; | 104 | }; |
103 | 105 | ||
104 | #if IS_REACHABLE(CONFIG_ARCH_ZYNQMP) | 106 | #if IS_REACHABLE(CONFIG_ARCH_ZYNQMP) |