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