mirror of
				https://source.denx.de/u-boot/u-boot.git
				synced 2025-10-31 00:11:51 +01:00 
			
		
		
		
	Rename mailbox*.h to match the naming convention requested during review of the new reset subsystem. Signed-off-by: Stephen Warren <swarren@nvidia.com> Acked-by: Simon Glass <sjg@chromium.org>
		
			
				
	
	
		
			105 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			105 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2016, NVIDIA CORPORATION.
 | |
|  *
 | |
|  * SPDX-License-Identifier: GPL-2.0
 | |
|  */
 | |
| 
 | |
| #include <common.h>
 | |
| #include <dm.h>
 | |
| #include <mailbox-uclass.h>
 | |
| #include <asm/io.h>
 | |
| #include <asm/mbox.h>
 | |
| 
 | |
| #define SANDBOX_MBOX_CHANNELS 2
 | |
| 
 | |
| struct sandbox_mbox_chan {
 | |
| 	bool rx_msg_valid;
 | |
| 	uint32_t rx_msg;
 | |
| };
 | |
| 
 | |
| struct sandbox_mbox {
 | |
| 	struct sandbox_mbox_chan chans[SANDBOX_MBOX_CHANNELS];
 | |
| };
 | |
| 
 | |
| static int sandbox_mbox_request(struct mbox_chan *chan)
 | |
| {
 | |
| 	debug("%s(chan=%p)\n", __func__, chan);
 | |
| 
 | |
| 	if (chan->id >= SANDBOX_MBOX_CHANNELS)
 | |
| 		return -EINVAL;
 | |
| 
 | |
| 	return 0;
 | |
| }
 | |
| 
 | |
| static int sandbox_mbox_free(struct mbox_chan *chan)
 | |
| {
 | |
| 	debug("%s(chan=%p)\n", __func__, chan);
 | |
| 
 | |
| 	return 0;
 | |
| }
 | |
| 
 | |
| static int sandbox_mbox_send(struct mbox_chan *chan, const void *data)
 | |
| {
 | |
| 	struct sandbox_mbox *sbm = dev_get_priv(chan->dev);
 | |
| 	const uint32_t *pmsg = data;
 | |
| 
 | |
| 	debug("%s(chan=%p, data=%p)\n", __func__, chan, data);
 | |
| 
 | |
| 	sbm->chans[chan->id].rx_msg = *pmsg ^ SANDBOX_MBOX_PING_XOR;
 | |
| 	sbm->chans[chan->id].rx_msg_valid = true;
 | |
| 
 | |
| 	return 0;
 | |
| }
 | |
| 
 | |
| static int sandbox_mbox_recv(struct mbox_chan *chan, void *data)
 | |
| {
 | |
| 	struct sandbox_mbox *sbm = dev_get_priv(chan->dev);
 | |
| 	uint32_t *pmsg = data;
 | |
| 
 | |
| 	debug("%s(chan=%p, data=%p)\n", __func__, chan, data);
 | |
| 
 | |
| 	if (!sbm->chans[chan->id].rx_msg_valid)
 | |
| 		return -ENODATA;
 | |
| 
 | |
| 	*pmsg = sbm->chans[chan->id].rx_msg;
 | |
| 	sbm->chans[chan->id].rx_msg_valid = false;
 | |
| 
 | |
| 	return 0;
 | |
| }
 | |
| 
 | |
| static int sandbox_mbox_bind(struct udevice *dev)
 | |
| {
 | |
| 	debug("%s(dev=%p)\n", __func__, dev);
 | |
| 
 | |
| 	return 0;
 | |
| }
 | |
| 
 | |
| static int sandbox_mbox_probe(struct udevice *dev)
 | |
| {
 | |
| 	debug("%s(dev=%p)\n", __func__, dev);
 | |
| 
 | |
| 	return 0;
 | |
| }
 | |
| 
 | |
| static const struct udevice_id sandbox_mbox_ids[] = {
 | |
| 	{ .compatible = "sandbox,mbox" },
 | |
| 	{ }
 | |
| };
 | |
| 
 | |
| struct mbox_ops sandbox_mbox_mbox_ops = {
 | |
| 	.request = sandbox_mbox_request,
 | |
| 	.free = sandbox_mbox_free,
 | |
| 	.send = sandbox_mbox_send,
 | |
| 	.recv = sandbox_mbox_recv,
 | |
| };
 | |
| 
 | |
| U_BOOT_DRIVER(sandbox_mbox) = {
 | |
| 	.name = "sandbox_mbox",
 | |
| 	.id = UCLASS_MAILBOX,
 | |
| 	.of_match = sandbox_mbox_ids,
 | |
| 	.bind = sandbox_mbox_bind,
 | |
| 	.probe = sandbox_mbox_probe,
 | |
| 	.priv_auto_alloc_size = sizeof(struct sandbox_mbox),
 | |
| 	.ops = &sandbox_mbox_mbox_ops,
 | |
| };
 |