+// 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)
{
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);
return ret;
}
- ret = ops->request(chan);
+ if (ops->request)
+ ret = ops->request(chan);
if (ret) {
debug("ops->request() failed: %d\n", ret);
return ret;
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)