1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Sandbox adder for p2sb testing
4  *
5  * Copyright 2019 Google LLC
6  */
7 
8 #define LOG_CATEGORY UCLASS_MISC
9 
10 #include <axi.h>
11 #include <dm.h>
12 #include <misc.h>
13 #include <p2sb.h>
14 #include <asm/io.h>
15 
16 struct sandbox_adder_priv {
17 	ulong base;
18 };
19 
sandbox_adder_read(struct udevice * dev,ulong address,void * data,enum axi_size_t size)20 int sandbox_adder_read(struct udevice *dev, ulong address, void *data,
21 		       enum axi_size_t size)
22 {
23 	struct p2sb_child_plat *pplat = dev_get_parent_plat(dev);
24 	u32 *val = data;
25 
26 	*val = pplat->pid << 24 | address;
27 
28 	return 0;
29 }
30 
sandbox_adder_write(struct udevice * dev,ulong address,void * data,enum axi_size_t size)31 int sandbox_adder_write(struct udevice *dev, ulong address, void *data,
32 			enum axi_size_t size)
33 {
34 	return 0;
35 }
36 
sandbox_adder_probe(struct udevice * dev)37 static int sandbox_adder_probe(struct udevice *dev)
38 {
39 	return 0;
40 }
41 
42 static struct axi_ops sandbox_adder_ops = {
43 	.read	= sandbox_adder_read,
44 	.write	= sandbox_adder_write,
45 };
46 
47 static const struct udevice_id sandbox_adder_ids[] = {
48 	{ .compatible = "sandbox,adder" },
49 	{ }
50 };
51 
52 U_BOOT_DRIVER(adder_sandbox) = {
53 	.name = "sandbox_adder",
54 	.id = UCLASS_AXI,
55 	.of_match = sandbox_adder_ids,
56 	.probe = sandbox_adder_probe,
57 	.ops = &sandbox_adder_ops,
58 	.priv_auto	= sizeof(struct sandbox_adder_priv),
59 };
60