Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Stephen Warren | 62f2c90 | 2016-05-16 17:41:37 -0600 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2016, NVIDIA CORPORATION. |
Stephen Warren | 62f2c90 | 2016-05-16 17:41:37 -0600 | [diff] [blame] | 4 | */ |
| 5 | |
Stephen Warren | 62f2c90 | 2016-05-16 17:41:37 -0600 | [diff] [blame] | 6 | #include <dm.h> |
Stephen Warren | 3cdf676 | 2016-06-17 09:43:56 -0600 | [diff] [blame] | 7 | #include <mailbox.h> |
Simon Glass | 9bc1564 | 2020-02-03 07:36:16 -0700 | [diff] [blame] | 8 | #include <malloc.h> |
Stephen Warren | 62f2c90 | 2016-05-16 17:41:37 -0600 | [diff] [blame] | 9 | #include <asm/io.h> |
| 10 | |
| 11 | struct sandbox_mbox_test { |
| 12 | struct mbox_chan chan; |
| 13 | }; |
| 14 | |
| 15 | int 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 | |
| 22 | int 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 | |
| 29 | int 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 | |
| 36 | int 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 | |
| 43 | static const struct udevice_id sandbox_mbox_test_ids[] = { |
| 44 | { .compatible = "sandbox,mbox-test" }, |
| 45 | { } |
| 46 | }; |
| 47 | |
| 48 | U_BOOT_DRIVER(sandbox_mbox_test) = { |
| 49 | .name = "sandbox_mbox_test", |
| 50 | .id = UCLASS_MISC, |
| 51 | .of_match = sandbox_mbox_test_ids, |
Simon Glass | 8a2b47f | 2020-12-03 16:55:17 -0700 | [diff] [blame] | 52 | .priv_auto = sizeof(struct sandbox_mbox_test), |
Stephen Warren | 62f2c90 | 2016-05-16 17:41:37 -0600 | [diff] [blame] | 53 | }; |