#include <common.h>
#include <dm.h>
+#include <log.h>
#include <zynqmp_firmware.h>
+#include <asm/cache.h>
+#include <asm/ptrace.h>
#if defined(CONFIG_ZYNQMP_IPI)
#include <mailbox.h>
static int send_req(const u32 *req, size_t req_len, u32 *res, size_t res_maxlen)
{
- if (IS_ENABLED(CONFIG_SPL_BUILD))
+ if (IS_ENABLED(CONFIG_SPL_BUILD) || current_el() == 3)
return ipi_req(req, req_len, res, res_maxlen);
- return invoke_smc(req[0] + PM_SIP_SVC, 0, 0, 0, 0, res);
+ return xilinx_pm_request(req[0], 0, 0, 0, 0, res);
}
unsigned int zynqmp_firmware_version(void)
static int zynqmp_power_probe(struct udevice *dev)
{
- int ret = 0;
+ int ret;
debug("%s, (dev=%p)\n", __func__, dev);
ret = mbox_get_by_name(dev, "tx", &zynqmp_power.tx_chan);
if (ret) {
- debug("%s, cannot tx mailbox\n", __func__);
+ debug("%s: Cannot find tx mailbox\n", __func__);
return ret;
}
ret = mbox_get_by_name(dev, "rx", &zynqmp_power.rx_chan);
if (ret) {
- debug("%s, cannot rx mailbox\n", __func__);
+ debug("%s: Cannot find rx mailbox\n", __func__);
return ret;
}
};
#endif
-int __maybe_unused invoke_smc(u32 pm_api_id, u32 arg0, u32 arg1, u32 arg2,
- u32 arg3, u32 *ret_payload)
+int __maybe_unused xilinx_pm_request(u32 api_id, u32 arg0, u32 arg1, u32 arg2,
+ u32 arg3, u32 *ret_payload)
{
/*
* Added SIP service call Function Identifier
*/
struct pt_regs regs;
- if (current_el() == 3)
- return 0;
+ if (current_el() == 3) {
+ printf("%s: Can't call SMC from EL3 context\n", __func__);
+ return -EPERM;
+ }
- regs.regs[0] = pm_api_id;
+ regs.regs[0] = PM_SIP_SVC | api_id;
regs.regs[1] = ((u64)arg1 << 32) | arg0;
regs.regs[2] = ((u64)arg3 << 32) | arg2;
return regs.regs[0];
}
-int __maybe_unused versal_pm_request(u32 api_id, u32 arg0, u32 arg1, u32 arg2,
- u32 arg3, u32 *ret_payload)
-{
- return invoke_smc(PM_SIP_SVC | api_id, arg0, arg1, arg2, arg3,
- ret_payload);
-}
-
static const struct udevice_id zynqmp_firmware_ids[] = {
{ .compatible = "xlnx,zynqmp-firmware" },
{ .compatible = "xlnx,versal-firmware"},
U_BOOT_DRIVER(zynqmp_firmware) = {
.id = UCLASS_FIRMWARE,
.name = "zynqmp-firmware",
- .probe = dm_scan_fdt_dev,
.of_match = zynqmp_firmware_ids,
};