mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-27 00:51:35 +00:00
drivers: firmware: xilinx: Add support for feature check
Query for corresponding feature before calling EEMI API from the driver. Signed-off-by: Ravi Patel <ravi.patel@xilinx.com> Signed-off-by: Michal Simek <michal.simek@xilinx.com> Signed-off-by: Rajan Vaja <rajan.vaja@xilinx.com>
This commit is contained in:
parent
e42617b825
commit
461011b1e1
2 changed files with 50 additions and 0 deletions
|
@ -26,6 +26,9 @@
|
||||||
|
|
||||||
static const struct zynqmp_eemi_ops *eemi_ops_tbl;
|
static const struct zynqmp_eemi_ops *eemi_ops_tbl;
|
||||||
|
|
||||||
|
static bool feature_check_enabled;
|
||||||
|
static u32 zynqmp_pm_features[PM_API_MAX];
|
||||||
|
|
||||||
static const struct mfd_cell firmware_devs[] = {
|
static const struct mfd_cell firmware_devs[] = {
|
||||||
{
|
{
|
||||||
.name = "zynqmp_power_controller",
|
.name = "zynqmp_power_controller",
|
||||||
|
@ -44,6 +47,8 @@ static int zynqmp_pm_ret_code(u32 ret_status)
|
||||||
case XST_PM_SUCCESS:
|
case XST_PM_SUCCESS:
|
||||||
case XST_PM_DOUBLE_REQ:
|
case XST_PM_DOUBLE_REQ:
|
||||||
return 0;
|
return 0;
|
||||||
|
case XST_PM_NO_FEATURE:
|
||||||
|
return -ENOTSUPP;
|
||||||
case XST_PM_NO_ACCESS:
|
case XST_PM_NO_ACCESS:
|
||||||
return -EACCES;
|
return -EACCES;
|
||||||
case XST_PM_ABORT_SUSPEND:
|
case XST_PM_ABORT_SUSPEND:
|
||||||
|
@ -126,6 +131,39 @@ static noinline int do_fw_call_hvc(u64 arg0, u64 arg1, u64 arg2,
|
||||||
return zynqmp_pm_ret_code((enum pm_ret_status)res.a0);
|
return zynqmp_pm_ret_code((enum pm_ret_status)res.a0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* zynqmp_pm_feature() - Check weather given feature is supported or not
|
||||||
|
* @api_id: API ID to check
|
||||||
|
*
|
||||||
|
* Return: Returns status, either success or error+reason
|
||||||
|
*/
|
||||||
|
static int zynqmp_pm_feature(u32 api_id)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
u32 ret_payload[PAYLOAD_ARG_CNT];
|
||||||
|
u64 smc_arg[2];
|
||||||
|
|
||||||
|
if (!feature_check_enabled)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/* Return value if feature is already checked */
|
||||||
|
if (zynqmp_pm_features[api_id] != PM_FEATURE_UNCHECKED)
|
||||||
|
return zynqmp_pm_features[api_id];
|
||||||
|
|
||||||
|
smc_arg[0] = PM_SIP_SVC | PM_FEATURE_CHECK;
|
||||||
|
smc_arg[1] = api_id;
|
||||||
|
|
||||||
|
ret = do_fw_call(smc_arg[0], smc_arg[1], 0, ret_payload);
|
||||||
|
if (ret) {
|
||||||
|
zynqmp_pm_features[api_id] = PM_FEATURE_INVALID;
|
||||||
|
return PM_FEATURE_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
zynqmp_pm_features[api_id] = ret_payload[1];
|
||||||
|
|
||||||
|
return zynqmp_pm_features[api_id];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* zynqmp_pm_invoke_fn() - Invoke the system-level platform management layer
|
* zynqmp_pm_invoke_fn() - Invoke the system-level platform management layer
|
||||||
* caller function depending on the configuration
|
* caller function depending on the configuration
|
||||||
|
@ -160,6 +198,9 @@ int zynqmp_pm_invoke_fn(u32 pm_api_id, u32 arg0, u32 arg1,
|
||||||
*/
|
*/
|
||||||
u64 smc_arg[4];
|
u64 smc_arg[4];
|
||||||
|
|
||||||
|
if (zynqmp_pm_feature(pm_api_id) == PM_FEATURE_INVALID)
|
||||||
|
return -ENOTSUPP;
|
||||||
|
|
||||||
smc_arg[0] = PM_SIP_SVC | pm_api_id;
|
smc_arg[0] = PM_SIP_SVC | pm_api_id;
|
||||||
smc_arg[1] = ((u64)arg1 << 32) | arg0;
|
smc_arg[1] = ((u64)arg1 << 32) | arg0;
|
||||||
smc_arg[2] = ((u64)arg3 << 32) | arg2;
|
smc_arg[2] = ((u64)arg3 << 32) | arg2;
|
||||||
|
@ -715,6 +756,8 @@ static int zynqmp_firmware_probe(struct platform_device *pdev)
|
||||||
np = of_find_compatible_node(NULL, NULL, "xlnx,versal");
|
np = of_find_compatible_node(NULL, NULL, "xlnx,versal");
|
||||||
if (!np)
|
if (!np)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
feature_check_enabled = true;
|
||||||
}
|
}
|
||||||
of_node_put(np);
|
of_node_put(np);
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,10 @@
|
||||||
#define ZYNQMP_PM_CAPABILITY_WAKEUP 0x4U
|
#define ZYNQMP_PM_CAPABILITY_WAKEUP 0x4U
|
||||||
#define ZYNQMP_PM_CAPABILITY_UNUSABLE 0x8U
|
#define ZYNQMP_PM_CAPABILITY_UNUSABLE 0x8U
|
||||||
|
|
||||||
|
/* Feature check status */
|
||||||
|
#define PM_FEATURE_INVALID -1
|
||||||
|
#define PM_FEATURE_UNCHECKED 0
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Firmware FPGA Manager flags
|
* Firmware FPGA Manager flags
|
||||||
* XILINX_ZYNQMP_PM_FPGA_FULL: FPGA full reconfiguration
|
* XILINX_ZYNQMP_PM_FPGA_FULL: FPGA full reconfiguration
|
||||||
|
@ -78,11 +82,14 @@ enum pm_api_id {
|
||||||
PM_CLOCK_GETRATE,
|
PM_CLOCK_GETRATE,
|
||||||
PM_CLOCK_SETPARENT,
|
PM_CLOCK_SETPARENT,
|
||||||
PM_CLOCK_GETPARENT,
|
PM_CLOCK_GETPARENT,
|
||||||
|
PM_FEATURE_CHECK = 63,
|
||||||
|
PM_API_MAX,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* PMU-FW return status codes */
|
/* PMU-FW return status codes */
|
||||||
enum pm_ret_status {
|
enum pm_ret_status {
|
||||||
XST_PM_SUCCESS = 0,
|
XST_PM_SUCCESS = 0,
|
||||||
|
XST_PM_NO_FEATURE = 19,
|
||||||
XST_PM_INTERNAL = 2000,
|
XST_PM_INTERNAL = 2000,
|
||||||
XST_PM_CONFLICT,
|
XST_PM_CONFLICT,
|
||||||
XST_PM_NO_ACCESS,
|
XST_PM_NO_ACCESS,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue