blob: a2cfde2f62d6ee23f32a2c20844f1abce4bdf98d [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0
Stephen Warren62f2c902016-05-16 17:41:37 -06002/*
3 * Copyright (c) 2016, NVIDIA CORPORATION.
Stephen Warren62f2c902016-05-16 17:41:37 -06004 */
5
Stephen Warren62f2c902016-05-16 17:41:37 -06006#include <dm.h>
Stephen Warren3cdf6762016-06-17 09:43:56 -06007#include <mailbox.h>
Simon Glass9bc15642020-02-03 07:36:16 -07008#include <malloc.h>
Stephen Warren62f2c902016-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,
Simon Glass8a2b47f2020-12-03 16:55:17 -070052 .priv_auto = sizeof(struct sandbox_mbox_test),
Stephen Warren62f2c902016-05-16 17:41:37 -060053};