blob: fed7ecfb9291f31a24125eeb50e5610d3d2f209e [file] [log] [blame]
Simon Glass937bb472019-12-06 21:41:57 -07001// 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_platdata *pplat = dev_get_parent_platdata(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,
Simon Glass8a2b47f2020-12-03 16:55:17 -070059 .priv_auto = sizeof(struct sandbox_adder_priv),
Simon Glass937bb472019-12-06 21:41:57 -070060};