Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

firmware: xilinx: Add support for runtime features

Add support for runtime features by using an IOCTL call. The features
can be enabled or disabled from the firmware as well as the features
can be configured at runtime by querying IOCTL_SET_FEATURE_CONFIG id.
Similarly, the user can get the configured values of features by
querying IOCTL_GET_FEATURE_CONFIG id.

Acked-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Ronak Jain <ronak.jain@xilinx.com>
Link: https://lore.kernel.org/r/20220209082709.32378-2-ronak.jain@xilinx.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Ronak Jain and committed by
Greg Kroah-Hartman
f1d0821b 86f4c65f

+52
+27
drivers/firmware/xilinx/zynqmp.c
··· 1157 1157 } 1158 1158 1159 1159 /** 1160 + * zynqmp_pm_set_feature_config - PM call to request IOCTL for feature config 1161 + * @id: The config ID of the feature to be configured 1162 + * @value: The config value of the feature to be configured 1163 + * 1164 + * Return: Returns 0 on success or error value on failure. 1165 + */ 1166 + int zynqmp_pm_set_feature_config(enum pm_feature_config_id id, u32 value) 1167 + { 1168 + return zynqmp_pm_invoke_fn(PM_IOCTL, 0, IOCTL_SET_FEATURE_CONFIG, 1169 + id, value, NULL); 1170 + } 1171 + 1172 + /** 1173 + * zynqmp_pm_get_feature_config - PM call to get value of configured feature 1174 + * @id: The config id of the feature to be queried 1175 + * @payload: Returned value array 1176 + * 1177 + * Return: Returns 0 on success or error value on failure. 1178 + */ 1179 + int zynqmp_pm_get_feature_config(enum pm_feature_config_id id, 1180 + u32 *payload) 1181 + { 1182 + return zynqmp_pm_invoke_fn(PM_IOCTL, 0, IOCTL_GET_FEATURE_CONFIG, 1183 + id, 0, payload); 1184 + } 1185 + 1186 + /** 1160 1187 * struct zynqmp_pm_shutdown_scope - Struct for shutdown scope 1161 1188 * @subtype: Shutdown subtype 1162 1189 * @name: Matching string for scope argument
+25
include/linux/firmware/xlnx-zynqmp.h
··· 143 143 IOCTL_OSPI_MUX_SELECT = 21, 144 144 /* Register SGI to ATF */ 145 145 IOCTL_REGISTER_SGI = 25, 146 + /* Runtime feature configuration */ 147 + IOCTL_SET_FEATURE_CONFIG = 26, 148 + IOCTL_GET_FEATURE_CONFIG = 27, 146 149 }; 147 150 148 151 enum pm_query_id { ··· 379 376 PM_OSPI_MUX_SEL_LINEAR = 1, 380 377 }; 381 378 379 + enum pm_feature_config_id { 380 + PM_FEATURE_INVALID = 0, 381 + PM_FEATURE_OVERTEMP_STATUS = 1, 382 + PM_FEATURE_OVERTEMP_VALUE = 2, 383 + PM_FEATURE_EXTWDT_STATUS = 3, 384 + PM_FEATURE_EXTWDT_VALUE = 4, 385 + }; 386 + 382 387 /** 383 388 * struct zynqmp_pm_query_data - PM query data 384 389 * @qid: query ID ··· 458 447 int zynqmp_pm_register_notifier(const u32 node, const u32 event, 459 448 const u32 wake, const u32 enable); 460 449 int zynqmp_pm_feature(const u32 api_id); 450 + int zynqmp_pm_set_feature_config(enum pm_feature_config_id id, u32 value); 451 + int zynqmp_pm_get_feature_config(enum pm_feature_config_id id, u32 *payload); 461 452 #else 462 453 static inline int zynqmp_pm_get_api_version(u32 *version) 463 454 { ··· 699 686 } 700 687 701 688 static inline int zynqmp_pm_feature(const u32 api_id) 689 + { 690 + return -ENODEV; 691 + } 692 + 693 + static inline int zynqmp_pm_set_feature_config(enum pm_feature_config_id id, 694 + u32 value) 695 + { 696 + return -ENODEV; 697 + } 698 + 699 + static inline int zynqmp_pm_get_feature_config(enum pm_feature_config_id id, 700 + u32 *payload) 702 701 { 703 702 return -ENODEV; 704 703 }