]> Git Repo - J-u-boot.git/blobdiff - drivers/mailbox/mailbox-uclass.c
Merge tag 'u-boot-atmel-2021.10-a' of https://source.denx.de/u-boot/custodians/u...
[J-u-boot.git] / drivers / mailbox / mailbox-uclass.c
index d053db031dd939c1db942008e33bac5f774d4337..c972d8460891d03abd4aaaa666f033cfe330a39f 100644 (file)
@@ -1,13 +1,15 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2016, NVIDIA CORPORATION.
- *
- * SPDX-License-Identifier: GPL-2.0
  */
 
 #include <common.h>
 #include <dm.h>
+#include <log.h>
 #include <mailbox.h>
 #include <mailbox-uclass.h>
+#include <malloc.h>
+#include <time.h>
 
 static inline struct mbox_ops *mbox_dev_ops(struct udevice *dev)
 {
@@ -50,7 +52,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);
 
@@ -64,7 +75,8 @@ int mbox_get_by_index(struct udevice *dev, int index, struct mbox_chan *chan)
                return ret;
        }
 
-       ret = ops->request(chan);
+       if (ops->request)
+               ret = ops->request(chan);
        if (ret) {
                debug("ops->request() failed: %d\n", ret);
                return ret;
@@ -95,7 +107,10 @@ int mbox_free(struct mbox_chan *chan)
 
        debug("%s(chan=%p)\n", __func__, chan);
 
-       return ops->free(chan);
+       if (ops->rfree)
+               return ops->rfree(chan);
+
+       return 0;
 }
 
 int mbox_send(struct mbox_chan *chan, const void *data)
This page took 0.022675 seconds and 4 git commands to generate.