Simon Glass | 937bb47 | 2019-12-06 21:41:57 -0700 | [diff] [blame] | 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 | |
Simon Glass | 937bb47 | 2019-12-06 21:41:57 -0700 | [diff] [blame] | 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 | |
| 20 | int sandbox_adder_read(struct udevice *dev, ulong address, void *data, |
| 21 | enum axi_size_t size) |
| 22 | { |
Simon Glass | b75b15b | 2020-12-03 16:55:23 -0700 | [diff] [blame] | 23 | struct p2sb_child_plat *pplat = dev_get_parent_plat(dev); |
Simon Glass | 937bb47 | 2019-12-06 21:41:57 -0700 | [diff] [blame] | 24 | u32 *val = data; |
| 25 | |
| 26 | *val = pplat->pid << 24 | address; |
| 27 | |
| 28 | return 0; |
| 29 | } |
| 30 | |
| 31 | int sandbox_adder_write(struct udevice *dev, ulong address, void *data, |
| 32 | enum axi_size_t size) |
| 33 | { |
| 34 | return 0; |
| 35 | } |
| 36 | |
| 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, |
Simon Glass | 8a2b47f | 2020-12-03 16:55:17 -0700 | [diff] [blame] | 58 | .priv_auto = sizeof(struct sandbox_adder_priv), |
Simon Glass | 937bb47 | 2019-12-06 21:41:57 -0700 | [diff] [blame] | 59 | }; |