blob: faca8fcc441c97c1c6718117c96b13812e134ca9 [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>
Simon Glass336d4612020-02-03 07:36:16 -07009#include <malloc.h>
Stephen Warren8961b522016-05-16 17:41:37 -060010#include <asm/io.h>
11
12struct sandbox_mbox_test {
13 struct mbox_chan chan;
14};
15
16int sandbox_mbox_test_get(struct udevice *dev)
17{
18 struct sandbox_mbox_test *sbmt = dev_get_priv(dev);
19
20 return mbox_get_by_name(dev, "test", &sbmt->chan);
21}
22
23int sandbox_mbox_test_send(struct udevice *dev, uint32_t msg)
24{
25 struct sandbox_mbox_test *sbmt = dev_get_priv(dev);
26
27 return mbox_send(&sbmt->chan, &msg);
28}
29
30int sandbox_mbox_test_recv(struct udevice *dev, uint32_t *msg)
31{
32 struct sandbox_mbox_test *sbmt = dev_get_priv(dev);
33
34 return mbox_recv(&sbmt->chan, msg, 100);
35}
36
37int sandbox_mbox_test_free(struct udevice *dev)
38{
39 struct sandbox_mbox_test *sbmt = dev_get_priv(dev);
40
41 return mbox_free(&sbmt->chan);
42}
43
44static const struct udevice_id sandbox_mbox_test_ids[] = {
45 { .compatible = "sandbox,mbox-test" },
46 { }
47};
48
49U_BOOT_DRIVER(sandbox_mbox_test) = {
50 .name = "sandbox_mbox_test",
51 .id = UCLASS_MISC,
52 .of_match = sandbox_mbox_test_ids,
53 .priv_auto_alloc_size = sizeof(struct sandbox_mbox_test),
54};