From 38c0b2521a0ea0951f4e1ee678ccdbce5fc07a98 Mon Sep 17 00:00:00 2001 From: Ronak Jain Date: Sun, 27 Jun 2021 22:31:20 -0700 Subject: [PATCH 1/2] feat(plat/xilinx/zynqmp): sync IOCTL IDs Sync IOCTL IDs in order to avoid conflict with other components like, Linux and firmware. Hence assigning value to IDs to make it more specific. Signed-off-by: Ronak Jain Change-Id: I11ae679fbd0a953290306b62d661cc142f50dc28 --- plat/xilinx/zynqmp/pm_service/pm_api_ioctl.h | 50 ++++++++++++-------- 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/plat/xilinx/zynqmp/pm_service/pm_api_ioctl.h b/plat/xilinx/zynqmp/pm_service/pm_api_ioctl.h index 337f7321b..7f9686184 100644 --- a/plat/xilinx/zynqmp/pm_service/pm_api_ioctl.h +++ b/plat/xilinx/zynqmp/pm_service/pm_api_ioctl.h @@ -15,28 +15,40 @@ //ioctl id enum { - IOCTL_GET_RPU_OPER_MODE, - IOCTL_SET_RPU_OPER_MODE, - IOCTL_RPU_BOOT_ADDR_CONFIG, - IOCTL_TCM_COMB_CONFIG, - IOCTL_SET_TAPDELAY_BYPASS, - IOCTL_SET_SGMII_MODE, - IOCTL_SD_DLL_RESET, - IOCTL_SET_SD_TAPDELAY, + IOCTL_GET_RPU_OPER_MODE = 0, + IOCTL_SET_RPU_OPER_MODE = 1, + IOCTL_RPU_BOOT_ADDR_CONFIG = 2, + IOCTL_TCM_COMB_CONFIG = 3, + IOCTL_SET_TAPDELAY_BYPASS = 4, + IOCTL_SET_SGMII_MODE = 5, + IOCTL_SD_DLL_RESET = 6, + IOCTL_SET_SD_TAPDELAY = 7, /* Ioctl for clock driver */ - IOCTL_SET_PLL_FRAC_MODE, - IOCTL_GET_PLL_FRAC_MODE, - IOCTL_SET_PLL_FRAC_DATA, - IOCTL_GET_PLL_FRAC_DATA, - IOCTL_WRITE_GGS, - IOCTL_READ_GGS, - IOCTL_WRITE_PGGS, - IOCTL_READ_PGGS, + IOCTL_SET_PLL_FRAC_MODE = 8, + IOCTL_GET_PLL_FRAC_MODE = 9, + IOCTL_SET_PLL_FRAC_DATA = 10, + IOCTL_GET_PLL_FRAC_DATA = 11, + IOCTL_WRITE_GGS = 12, + IOCTL_READ_GGS = 13, + IOCTL_WRITE_PGGS = 14, + IOCTL_READ_PGGS = 15, /* IOCTL for ULPI reset */ - IOCTL_ULPI_RESET, + IOCTL_ULPI_RESET = 16, /* Set healthy bit value */ - IOCTL_SET_BOOT_HEALTH_STATUS, - IOCTL_AFI, + IOCTL_SET_BOOT_HEALTH_STATUS = 17, + IOCTL_AFI = 18, + /* Probe counter read/write */ + IOCTL_PROBE_COUNTER_READ = 19, + IOCTL_PROBE_COUNTER_WRITE = 20, + IOCTL_OSPI_MUX_SELECT = 21, + /* IOCTL for USB power request */ + IOCTL_USB_SET_STATE = 22, + /* IOCTL to get last reset reason */ + IOCTL_GET_LAST_RESET_REASON = 23, + /* AI engine NPI ISR clear */ + IOCTL_AIE_ISR_CLEAR = 24, + /* Register SGI to ATF */ + IOCTL_REGISTER_SGI = 25, }; //RPU operation mode From 578f468ac058bbb60b08f78e2aa2c20cdc601620 Mon Sep 17 00:00:00 2001 From: Ronak Jain Date: Wed, 11 Aug 2021 00:26:28 -0700 Subject: [PATCH 2/2] feat(plat/xilinx/zynqmp): add support for runtime feature config Add support for runtime feature configuration which are running on the firmware. Add new IOCTL IDs like IOCTL_SET_FEATURE_CONFIG and IOCTL_GET_FEATURE_CONFIG for configuring the features. Signed-off-by: Ronak Jain Change-Id: I976aef15932783a25396b2adeb4c8f140cc87e79 --- plat/xilinx/zynqmp/pm_service/pm_api_ioctl.c | 4 +++ plat/xilinx/zynqmp/pm_service/pm_api_ioctl.h | 3 ++ plat/xilinx/zynqmp/pm_service/pm_api_sys.c | 33 ++++++++++++++++++++ plat/xilinx/zynqmp/pm_service/pm_api_sys.h | 5 +++ 4 files changed, 45 insertions(+) diff --git a/plat/xilinx/zynqmp/pm_service/pm_api_ioctl.c b/plat/xilinx/zynqmp/pm_service/pm_api_ioctl.c index f165fb022..9c5af88bb 100644 --- a/plat/xilinx/zynqmp/pm_service/pm_api_ioctl.c +++ b/plat/xilinx/zynqmp/pm_service/pm_api_ioctl.c @@ -677,6 +677,10 @@ enum pm_ret_status pm_api_ioctl(enum pm_node_id nid, case IOCTL_AFI: ret = pm_ioctl_afi(arg1, arg2); break; + case IOCTL_SET_FEATURE_CONFIG: + case IOCTL_GET_FEATURE_CONFIG: + ret = pm_feature_config(ioctl_id, arg1, arg2, value); + break; default: ret = PM_RET_ERROR_NOTSUPPORTED; break; diff --git a/plat/xilinx/zynqmp/pm_service/pm_api_ioctl.h b/plat/xilinx/zynqmp/pm_service/pm_api_ioctl.h index 7f9686184..f18dc00a2 100644 --- a/plat/xilinx/zynqmp/pm_service/pm_api_ioctl.h +++ b/plat/xilinx/zynqmp/pm_service/pm_api_ioctl.h @@ -49,6 +49,9 @@ enum { IOCTL_AIE_ISR_CLEAR = 24, /* Register SGI to ATF */ IOCTL_REGISTER_SGI = 25, + /* Runtime feature configuration */ + IOCTL_SET_FEATURE_CONFIG = 26, + IOCTL_GET_FEATURE_CONFIG = 27, }; //RPU operation mode diff --git a/plat/xilinx/zynqmp/pm_service/pm_api_sys.c b/plat/xilinx/zynqmp/pm_service/pm_api_sys.c index 62260bc40..5d9408cd5 100644 --- a/plat/xilinx/zynqmp/pm_service/pm_api_sys.c +++ b/plat/xilinx/zynqmp/pm_service/pm_api_sys.c @@ -1648,3 +1648,36 @@ enum pm_ret_status em_send_errors(unsigned int *value) EM_PACK_PAYLOAD1(payload, EM_SEND_ERRORS); return pm_ipi_send_sync(primary_proc, payload, value, 1); } + +/** + * pm_feature_config() - feature configuration at runtime + * + * This function is used to send IPI request to PMUFW to configure feature + * at runtime. The feature can be enable or disable as well as the feature + * can be configure at runtime using an IOCTL call. + * + * @ioctl_id The ioctl id for the feature configuration + * @config_id The config id of the feature to be configured + * @value The value to be configured + * @response Return to reference pointer + * + * @return Returns 0 on success or error value on failure + */ +enum pm_ret_status pm_feature_config(unsigned int ioctl_id, + unsigned int config_id, + unsigned int value, + unsigned int *response) +{ + uint32_t payload[PAYLOAD_ARG_CNT]; + + /* Send request to the PMU */ + PM_PACK_PAYLOAD5(payload, PM_IOCTL, 0, ioctl_id, config_id, value); + + if (ioctl_id == IOCTL_GET_FEATURE_CONFIG) { + return pm_ipi_send_sync(primary_proc, payload, response, 1); + } else if (ioctl_id == IOCTL_SET_FEATURE_CONFIG) { + return pm_ipi_send_sync(primary_proc, payload, NULL, 0); + } else { + return PM_RET_ERROR_ARGS; + } +} diff --git a/plat/xilinx/zynqmp/pm_service/pm_api_sys.h b/plat/xilinx/zynqmp/pm_service/pm_api_sys.h index b0c26529d..ca07cef75 100644 --- a/plat/xilinx/zynqmp/pm_service/pm_api_sys.h +++ b/plat/xilinx/zynqmp/pm_service/pm_api_sys.h @@ -202,4 +202,9 @@ enum pm_ret_status em_set_action(unsigned int *value); enum pm_ret_status em_remove_action(unsigned int *value); enum pm_ret_status em_send_errors(unsigned int *value); +enum pm_ret_status pm_feature_config(unsigned int ioctl_id, + unsigned int config_id, + unsigned int value, + unsigned int *response); + #endif /* PM_API_SYS_H */