blob: ba1bb1cf957bd0245b4aef80b5cd01228b86d9ee [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0
Stephen Warren8961b522016-05-16 17:41:37 -06002/*
3 * Copyright (c) 2016, NVIDIA CORPORATION.
Stephen Warren8961b522016-05-16 17:41:37 -06004 */
5
6#include <common.h>
7#include <dm.h>
Stephen Warren769d52e2016-06-17 09:43:56 -06008#include <mailbox.h>
Stephen Warren8961b522016-05-16 17:41:37 -06009#include <asm/io.h>
10
11struct sandbox_mbox_test {
12 struct mbox_chan chan;
13};
14
15int sandbox_mbox_test_get(struct udevice *dev)
16{
17 struct sandbox_mbox_test *sbmt = dev_get_priv(dev);
18
19 return mbox_get_by_name(dev, "test", &sbmt->chan);
20}
21
22int sandbox_mbox_test_send(struct udevice *dev, uint32_t msg)
23{
24 struct sandbox_mbox_test *sbmt = dev_get_priv(dev);
25
26 return mbox_send(&sbmt->chan, &msg);
27}
28
29int sandbox_mbox_test_recv(struct udevice *dev, uint32_t *msg)
30{
31 struct sandbox_mbox_test *sbmt = dev_get_priv(dev);
32
33 return mbox_recv(&sbmt->chan, msg, 100);
34}
35
36int sandbox_mbox_test_free(struct udevice *dev)
37{
38 struct sandbox_mbox_test *sbmt = dev_get_priv(dev);
39
40 return mbox_free(&sbmt->chan);
41}
42
43static const struct udevice_id sandbox_mbox_test_ids[] = {
44 { .compatible = "sandbox,mbox-test" },
45 { }
46};
47
48U_BOOT_DRIVER(sandbox_mbox_test) = {
49 .name = "sandbox_mbox_test",
50 .id = UCLASS_MISC,
51 .of_match = sandbox_mbox_test_ids,
52 .priv_auto_alloc_size = sizeof(struct sandbox_mbox_test),
53};