summaryrefslogtreecommitdiff
path: root/drivers/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/firmware')
-rw-r--r--drivers/firmware/Kconfig1
-rw-r--r--drivers/firmware/firmware-zynqmp.c60
-rw-r--r--drivers/firmware/ti_sci.c99
-rw-r--r--drivers/firmware/ti_sci.h42
4 files changed, 177 insertions, 25 deletions
diff --git a/drivers/firmware/Kconfig b/drivers/firmware/Kconfig
index 8789b1ea141..a094e6c3afe 100644
--- a/drivers/firmware/Kconfig
+++ b/drivers/firmware/Kconfig
@@ -29,6 +29,7 @@ config TI_SCI_PROTOCOL
config ZYNQMP_FIRMWARE
bool "ZynqMP Firmware interface"
+ depends on ARCH_ZYNQMP || ARCH_VERSAL || ARCH_VERSAL_NET || ARCH_VERSAL2
select FIRMWARE
help
Firmware interface driver is used by different
diff --git a/drivers/firmware/firmware-zynqmp.c b/drivers/firmware/firmware-zynqmp.c
index 2940181e83e..d18ae523b6b 100644
--- a/drivers/firmware/firmware-zynqmp.c
+++ b/drivers/firmware/firmware-zynqmp.c
@@ -422,6 +422,30 @@ U_BOOT_DRIVER(zynqmp_power) = {
};
#endif
+smc_call_handler_t __data smc_call_handler;
+
+static int smc_call_legacy(u32 api_id, u32 arg0, u32 arg1, u32 arg2,
+ u32 arg3, u32 *ret_payload)
+{
+ struct pt_regs regs;
+
+ regs.regs[0] = PM_SIP_SVC | api_id;
+ regs.regs[1] = ((u64)arg1 << 32) | arg0;
+ regs.regs[2] = ((u64)arg3 << 32) | arg2;
+
+ smc_call(&regs);
+
+ if (ret_payload) {
+ ret_payload[0] = (u32)regs.regs[0];
+ ret_payload[1] = upper_32_bits(regs.regs[0]);
+ ret_payload[2] = (u32)regs.regs[1];
+ ret_payload[3] = upper_32_bits(regs.regs[1]);
+ ret_payload[4] = (u32)regs.regs[2];
+ }
+
+ return (ret_payload) ? ret_payload[0] : 0;
+}
+
int __maybe_unused xilinx_pm_request(u32 api_id, u32 arg0, u32 arg1, u32 arg2,
u32 arg3, u32 *ret_payload)
{
@@ -450,38 +474,20 @@ int __maybe_unused xilinx_pm_request(u32 api_id, u32 arg0, u32 arg1, u32 arg2,
PAYLOAD_ARG_CNT);
if (ret)
return ret;
+
+ return (ret_payload) ? ret_payload[0] : 0;
#else
return -EPERM;
#endif
- } else {
- /*
- * Added SIP service call Function Identifier
- * Make sure to stay in x0 register
- */
- struct pt_regs regs;
-
- regs.regs[0] = PM_SIP_SVC | api_id;
- regs.regs[1] = ((u64)arg1 << 32) | arg0;
- regs.regs[2] = ((u64)arg3 << 32) | arg2;
-
- smc_call(&regs);
-
- if (ret_payload) {
- ret_payload[0] = (u32)regs.regs[0];
- ret_payload[1] = upper_32_bits(regs.regs[0]);
- ret_payload[2] = (u32)regs.regs[1];
- ret_payload[3] = upper_32_bits(regs.regs[1]);
- ret_payload[4] = (u32)regs.regs[2];
- }
-
}
- return (ret_payload) ? ret_payload[0] : 0;
+
+ return smc_call_handler(api_id, arg0, arg1, arg2, arg3, ret_payload);
}
static const struct udevice_id zynqmp_firmware_ids[] = {
- { .compatible = "xlnx,zynqmp-firmware" },
- { .compatible = "xlnx,versal-firmware"},
- { .compatible = "xlnx,versal-net-firmware"},
+ { .compatible = "xlnx,zynqmp-firmware", .data = (ulong)smc_call_legacy },
+ { .compatible = "xlnx,versal-firmware", .data = (ulong)smc_call_legacy},
+ { .compatible = "xlnx,versal-net-firmware", .data = (ulong)smc_call_legacy },
{ }
};
@@ -490,6 +496,10 @@ static int zynqmp_firmware_bind(struct udevice *dev)
int ret;
struct udevice *child;
+ smc_call_handler = (smc_call_handler_t)dev_get_driver_data(dev);
+ if (!smc_call_handler)
+ return -EINVAL;
+
if ((IS_ENABLED(CONFIG_XPL_BUILD) &&
IS_ENABLED(CONFIG_SPL_POWER_DOMAIN) &&
IS_ENABLED(CONFIG_ZYNQMP_POWER_DOMAIN)) ||
diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c
index 344df9454b3..8013afef304 100644
--- a/drivers/firmware/ti_sci.c
+++ b/drivers/firmware/ti_sci.c
@@ -279,6 +279,101 @@ static int ti_sci_do_xfer(struct ti_sci_info *info,
}
/**
+ * ti_sci_cmd_query_dm_cap() - Command to query DM firmware's capabilities
+ * @handle: Pointer to TI SCI handle
+ * @fw_caps: Pointer to firmware capabilities
+ *
+ * Return: 0 if all went fine, else return appropriate error.
+ */
+static int ti_sci_cmd_query_dm_cap(struct ti_sci_handle *handle, u64 *fw_caps)
+{
+ struct ti_sci_query_fw_caps_resp *cap_info;
+ struct ti_sci_msg_hdr hdr;
+ struct ti_sci_info *info;
+ struct ti_sci_xfer *xfer;
+ int ret;
+
+ if (IS_ERR(handle))
+ return PTR_ERR(handle);
+ if (!handle)
+ return -EINVAL;
+
+ info = handle_to_ti_sci_info(handle);
+
+ xfer = ti_sci_setup_one_xfer(info, TI_SCI_MSG_QUERY_FW_CAPS,
+ TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
+ (u32 *)&hdr, sizeof(struct ti_sci_msg_hdr),
+ sizeof(*cap_info));
+ if (IS_ERR(xfer)) {
+ ret = PTR_ERR(xfer);
+ return ret;
+ }
+
+ ret = ti_sci_do_xfer(info, xfer);
+ if (ret)
+ return ret;
+
+ cap_info = (struct ti_sci_query_fw_caps_resp *)xfer->tx_message.buf;
+
+ *fw_caps = cap_info->fw_caps;
+
+ return 0;
+}
+
+/**
+ * ti_sci_cmd_get_dm_version() - command to get the DM version of the SCI
+ * entity
+ * @handle: Pointer to TI SCI handle
+ * @dm_info: Pointer to DM version information structure
+ *
+ * Return: 0 if all went fine, else return appropriate error.
+ */
+
+static int ti_sci_cmd_get_dm_version(struct ti_sci_handle *handle,
+ struct ti_sci_dm_version_info *dm_info)
+{
+ struct ti_sci_msg_dm_resp_version *ver_info;
+ struct ti_sci_msg_hdr hdr;
+ struct ti_sci_info *info;
+ struct ti_sci_xfer *xfer;
+ int ret;
+
+ if (IS_ERR(handle))
+ return PTR_ERR(handle);
+ if (!handle || !dm_info)
+ return -EINVAL;
+
+ info = handle_to_ti_sci_info(handle);
+
+ xfer = ti_sci_setup_one_xfer(info, TI_SCI_MSG_DM_VERSION,
+ TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
+ (u32 *)&hdr, sizeof(struct ti_sci_msg_hdr),
+ sizeof(*ver_info));
+ if (IS_ERR(xfer)) {
+ ret = PTR_ERR(xfer);
+ return ret;
+ }
+
+ ret = ti_sci_do_xfer(info, xfer);
+ if (ret)
+ return ret;
+
+ ver_info = (struct ti_sci_msg_dm_resp_version *)xfer->tx_message.buf;
+
+ dm_info->abi_major = ver_info->abi_major;
+ dm_info->abi_minor = ver_info->abi_minor;
+ dm_info->dm_ver = ver_info->version;
+ dm_info->patch_ver = ver_info->patch_version;
+ dm_info->sub_ver = ver_info->sub_version;
+ strlcpy(dm_info->sci_server_version, ver_info->sci_server_version,
+ sizeof(ver_info->sci_server_version));
+ strlcpy(dm_info->rm_pm_hal_version, ver_info->rm_pm_hal_version,
+ sizeof(ver_info->rm_pm_hal_version));
+
+ return 0;
+}
+
+/**
* ti_sci_cmd_get_revision() - command to get the revision of the SCI entity
* @handle: pointer to TI SCI handle
*
@@ -2624,6 +2719,7 @@ static void ti_sci_setup_ops(struct ti_sci_info *info)
struct ti_sci_dev_ops *dops = &ops->dev_ops;
struct ti_sci_clk_ops *cops = &ops->clk_ops;
struct ti_sci_core_ops *core_ops = &ops->core_ops;
+ struct ti_sci_firmware_ops *fw_ops = &ops->fw_ops;
struct ti_sci_rm_core_ops *rm_core_ops = &ops->rm_core_ops;
struct ti_sci_proc_ops *pops = &ops->proc_ops;
struct ti_sci_rm_ringacc_ops *rops = &ops->rm_ring_ops;
@@ -2694,6 +2790,9 @@ static void ti_sci_setup_ops(struct ti_sci_info *info)
fwl_ops->set_fwl_region = ti_sci_cmd_set_fwl_region;
fwl_ops->get_fwl_region = ti_sci_cmd_get_fwl_region;
fwl_ops->change_fwl_owner = ti_sci_cmd_change_fwl_owner;
+
+ fw_ops->get_dm_version = ti_sci_cmd_get_dm_version;
+ fw_ops->query_dm_cap = ti_sci_cmd_query_dm_cap;
}
/**
diff --git a/drivers/firmware/ti_sci.h b/drivers/firmware/ti_sci.h
index bb8bc7beead..ce50bf6800e 100644
--- a/drivers/firmware/ti_sci.h
+++ b/drivers/firmware/ti_sci.h
@@ -26,7 +26,9 @@
#define TI_SCI_MSG_BOARD_CONFIG_RM 0x000c
#define TI_SCI_MSG_BOARD_CONFIG_SECURITY 0x000d
#define TI_SCI_MSG_BOARD_CONFIG_PM 0x000e
+#define TI_SCI_MSG_DM_VERSION 0x000f
#define TISCI_MSG_QUERY_MSMC 0x0020
+#define TI_SCI_MSG_QUERY_FW_CAPS 0x0022
/* Device requests */
#define TI_SCI_MSG_SET_DEVICE_STATE 0x0200
@@ -135,6 +137,46 @@ struct ti_sci_msg_resp_version {
} __packed;
/**
+ * struct ti_sci_msg_dm_resp_version - Response for a message
+ * @hdr: Generic header
+ * @version: Version number of the firmware
+ * @sub_version: Sub-version number of the firmware
+ * @patch_version: Patch version number of the firmware
+ * @abi_major: Major version of the ABI that firmware supports
+ * @abi_minor: Minor version of the ABI that firmware supports
+ * @sci_server_version: String describing the SCI server version
+ * @rm_pm_hal_version: String describing the RM PM HAL version
+ *
+ * In general, ABI version changes follow the rule that minor version increments
+ * are backward compatible. Major revision changes in ABI may not be
+ * backward compatible.
+ *
+ * Response to a message with message type TI_SCI_MSG_DM_VERSION
+ */
+struct ti_sci_msg_dm_resp_version {
+ struct ti_sci_msg_hdr hdr;
+ u16 version;
+ u8 sub_version;
+ u8 patch_version;
+ u8 abi_major;
+ u8 abi_minor;
+ char rm_pm_hal_version[12];
+ char sci_server_version[26];
+} __packed;
+
+/**
+ * struct ti_sci_query_fw_caps_resp - Response for a message
+ * @hdr: Generic header
+ * @fw_caps: 64-bit value representing the FW/SOC capabilities.
+ *
+ * Response to a message with message type TI_SCI_MSG_QUERY_FW_CAPS
+ */
+struct ti_sci_query_fw_caps_resp {
+ struct ti_sci_msg_hdr hdr;
+ u64 fw_caps;
+} __packed;
+
+/**
* struct ti_sci_msg_req_reboot - Reboot the SoC
* @hdr: Generic Header
* @domain: Domain to be reset, 0 for full SoC reboot.