blob: de1c635758209d70f6dd693a9fb27e24e168f32f [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
Simon Glass937bb472019-12-06 21:41:57 -070010#include <axi.h>
11#include <dm.h>
12#include <misc.h>
13#include <p2sb.h>
14#include <asm/io.h>
15
16struct sandbox_adder_priv {
17 ulong base;
18};
19
20int sandbox_adder_read(struct udevice *dev, ulong address, void *data,
21 enum axi_size_t size)
22{
Simon Glassb75b15b2020-12-03 16:55:23 -070023 struct p2sb_child_plat *pplat = dev_get_parent_plat(dev);
Simon Glass937bb472019-12-06 21:41:57 -070024 u32 *val = data;
25
26 *val = pplat->pid << 24 | address;
27
28 return 0;
29}
30
31int sandbox_adder_write(struct udevice *dev, ulong address, void *data,
32 enum axi_size_t size)
33{
34 return 0;
35}
36
37static int sandbox_adder_probe(struct udevice *dev)
38{
39 return 0;
40}
41
42static struct axi_ops sandbox_adder_ops = {
43 .read = sandbox_adder_read,
44 .write = sandbox_adder_write,
45};
46
47static const struct udevice_id sandbox_adder_ids[] = {
48 { .compatible = "sandbox,adder" },
49 { }
50};
51
52U_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,
Simon Glass8a2b47f2020-12-03 16:55:17 -070058 .priv_auto = sizeof(struct sandbox_adder_priv),
Simon Glass937bb472019-12-06 21:41:57 -070059};