#include <common.h>
#include <cpu_func.h>
#include <dm.h>
+#include <dm/device_compat.h>
#include <dm/lists.h>
#include <log.h>
#include <zynqmp_firmware.h>
static int zynqmp_power_probe(struct udevice *dev)
{
+ struct udevice *ipi_dev;
+ ofnode ipi_node;
int ret;
debug("%s, (dev=%p)\n", __func__, dev);
+ /*
+ * Probe all IPI parent node driver. It is important to have IPI
+ * devices available when requested by mbox_get_by* API.
+ * If IPI device isn't available, then mailbox request fails and
+ * that causes system boot failure.
+ * To avoid this make sure all IPI parent drivers are probed here,
+ * and IPI parent driver binds each child node to mailbox driver.
+ * This way mbox_get_by_* API will have correct mailbox device
+ * driver probed.
+ */
+ ofnode_for_each_compatible_node(ipi_node, "xlnx,zynqmp-ipi-mailbox") {
+ ret = uclass_get_device_by_ofnode(UCLASS_NOP, ipi_node, &ipi_dev);
+ if (ret) {
+ dev_err(dev, "failed to get IPI device from node %s\n",
+ ofnode_get_name(ipi_node));
+ return ret;
+ }
+ }
+
ret = mbox_get_by_name(dev, "tx", &zynqmp_power.tx_chan);
if (ret) {
debug("%s: Cannot find tx mailbox\n", __func__);
#include <dm.h>
#include <mailbox-uclass.h>
#include <dm/device_compat.h>
+#include <dm/lists.h>
#include <dm/of_access.h>
#include <linux/arm-smccc.h>
#include <linux/ioport.h>
return ret;
};
-static int zynqmp_ipi_probe(struct udevice *dev)
+static int zynqmp_ipi_dest_probe(struct udevice *dev)
{
struct zynqmp_ipi *zynqmp = dev_get_priv(dev);
struct resource res;
debug("%s(dev=%p)\n", __func__, dev);
+ node = dev_ofnode(dev);
+
if (IS_ENABLED(CONFIG_SPL_BUILD) || of_machine_is_compatible("xlnx,zynqmp"))
zynqmp->el3_supported = true;
- /* Get subnode where the regs are defined */
- /* Note IPI mailbox node needs to be the first one in DT */
- node = ofnode_first_subnode(dev_ofnode(dev));
-
- ret = dev_read_u32(dev, "xlnx,ipi-id", &zynqmp->local_id);
+ ret = dev_read_u32(dev->parent, "xlnx,ipi-id", &zynqmp->local_id);
if (ret) {
dev_err(dev, "can't get local ipi id\n");
return ret;
};
zynqmp->local_req_regs = devm_ioremap(dev, res.start,
(res.start - res.end));
+ if (!zynqmp->local_req_regs)
+ return -EINVAL;
if (ofnode_read_resource_byname(node, "local_response_region", &res)) {
dev_err(dev, "No reg property for local_response_region\n");
};
zynqmp->local_res_regs = devm_ioremap(dev, res.start,
(res.start - res.end));
+ if (!zynqmp->local_res_regs)
+ return -EINVAL;
if (ofnode_read_resource_byname(node, "remote_request_region", &res)) {
dev_err(dev, "No reg property for remote_request_region\n");
};
zynqmp->remote_req_regs = devm_ioremap(dev, res.start,
(res.start - res.end));
+ if (!zynqmp->remote_req_regs)
+ return -EINVAL;
if (ofnode_read_resource_byname(node, "remote_response_region", &res)) {
dev_err(dev, "No reg property for remote_response_region\n");
};
zynqmp->remote_res_regs = devm_ioremap(dev, res.start,
(res.start - res.end));
+ if (!zynqmp->remote_res_regs)
+ return -EINVAL;
return 0;
};
-static const struct udevice_id zynqmp_ipi_ids[] = {
- { .compatible = "xlnx,zynqmp-ipi-mailbox" },
- { }
+static int zynqmp_ipi_probe(struct udevice *dev)
+{
+ struct udevice *cdev;
+ ofnode cnode;
+ int ret;
+
+ debug("%s(dev=%p)\n", __func__, dev);
+
+ dev_for_each_subnode(cnode, dev) {
+ ret = device_bind_driver_to_node(dev, "zynqmp_ipi_dest",
+ ofnode_get_name(cnode),
+ cnode, &cdev);
+ if (ret)
+ return ret;
+ }
+
+ return 0;
};
-struct mbox_ops zynqmp_ipi_mbox_ops = {
+struct mbox_ops zynqmp_ipi_dest_mbox_ops = {
.send = zynqmp_ipi_send,
.recv = zynqmp_ipi_recv,
};
+static const struct udevice_id zynqmp_ipi_dest_ids[] = {
+ { .compatible = "xlnx,zynqmp-ipi-dest-mailbox" },
+ { }
+};
+
+U_BOOT_DRIVER(zynqmp_ipi_dest) = {
+ .name = "zynqmp_ipi_dest",
+ .id = UCLASS_MAILBOX,
+ .of_match = zynqmp_ipi_dest_ids,
+ .probe = zynqmp_ipi_dest_probe,
+ .priv_auto = sizeof(struct zynqmp_ipi),
+ .ops = &zynqmp_ipi_dest_mbox_ops,
+};
+
+static const struct udevice_id zynqmp_ipi_ids[] = {
+ { .compatible = "xlnx,zynqmp-ipi-mailbox" },
+ { }
+};
+
U_BOOT_DRIVER(zynqmp_ipi) = {
.name = "zynqmp_ipi",
- .id = UCLASS_MAILBOX,
+ .id = UCLASS_NOP,
.of_match = zynqmp_ipi_ids,
.probe = zynqmp_ipi_probe,
- .priv_auto = sizeof(struct zynqmp_ipi),
- .ops = &zynqmp_ipi_mbox_ops,
+ .flags = DM_FLAG_PROBE_AFTER_BIND,
};