diff mbox series

[U-Boot,02/13] mailbox: allow subnode for mbox regs

Message ID 916fdafa5a736a57066de4de733b1ab9d8621fb6.1569591296.git.michal.simek@xilinx.com
State New
Delegated to: Michal Simek
Headers show
Series arm64: zynqmp: Clean communication with PMUFW | expand

Commit Message

Michal Simek Sept. 27, 2019, 1:34 p.m. UTC
From: Ibai Erkiaga <ibai.erkiaga-elorza@xilinx.com>

The following patch allows the mailbox node in DT to host subnodes with
mailbox definitions. If the client phandle to the mailbox is not the
mailbox driver node, just checks parents as well.

Signed-off-by: Ibai Erkiaga <ibai.erkiaga-elorza@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

 drivers/mailbox/mailbox-uclass.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/mailbox/mailbox-uclass.c b/drivers/mailbox/mailbox-uclass.c
index 809f26b20258..9fdb6279e4f3 100644
--- a/drivers/mailbox/mailbox-uclass.c
+++ b/drivers/mailbox/mailbox-uclass.c
@@ -49,7 +49,16 @@  int mbox_get_by_index(struct udevice *dev, int index, struct mbox_chan *chan)
 	if (ret) {
 		debug("%s: uclass_get_device_by_of_offset failed: %d\n",
 		      __func__, ret);
-		return ret;
+
+		/* Test with parent node */
+		ret = uclass_get_device_by_ofnode(UCLASS_MAILBOX,
+						  ofnode_get_parent(args.node),
+						  &dev_mbox);
+		if (ret) {
+			debug("%s: mbox node from parent failed: %d\n",
+			      __func__, ret);
+			return ret;
+		};
 	}
 	ops = mbox_dev_ops(dev_mbox);