mailbox: allow subnode for mbox regs
authorIbai Erkiaga <ibai.erkiaga-elorza@xilinx.com>
Fri, 27 Sep 2019 10:36:55 +0000 (11:36 +0100)
committerMichal Simek <michal.simek@xilinx.com>
Tue, 8 Oct 2019 07:55:11 +0000 (09:55 +0200)
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

index 809f26b2025864d4102bb6fb4c13b8acde29cc9e..9fdb6279e4f3839222bb1d9f55c02db187c2edc0 100644 (file)
@@ -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);