blob: 59fb0b2e4584c24816f21f464cea4d14cde0071f [file] [log] [blame]
Mario Six573b1b92018-08-09 14:51:16 +02001/* SPDX-License-Identifier: GPL-2.0+ */
2/*
Mario Sixf95104d2018-08-09 14:51:18 +02003 * (C) Copyright 2017, 2018
4 * Mario Six, Guntermann & Drunck GmbH, mario.six@gdsys.cc
Mario Six573b1b92018-08-09 14:51:16 +02005 */
6
7#ifndef _AXI_H_
8#define _AXI_H_
9
Simon Glass3ba929a2020-10-30 21:38:53 -060010struct udevice;
11
Mario Sixf95104d2018-08-09 14:51:18 +020012/**
13 * enum axi_size_t - Determine size of AXI transfer
14 * @AXI_SIZE_8: AXI sransfer is 8-bit wide
15 * @AXI_SIZE_16: AXI sransfer is 16-bit wide
16 * @AXI_SIZE_32: AXI sransfer is 32-bit wide
17 */
Mario Six573b1b92018-08-09 14:51:16 +020018enum axi_size_t {
19 AXI_SIZE_8,
20 AXI_SIZE_16,
21 AXI_SIZE_32,
22};
23
Mario Six573b1b92018-08-09 14:51:16 +020024struct axi_ops {
25 /**
26 * read() - Read a single value from a specified address on a AXI bus
Mario Six573b1b92018-08-09 14:51:16 +020027 * @dev: AXI bus to read from.
28 * @address: The address to read from.
29 * @data: Pointer to a variable that takes the data value read
30 * from the address on the AXI bus.
31 * @size: The size of the data to be read.
Mario Sixf95104d2018-08-09 14:51:18 +020032 *
33 * Return: 0 if OK, -ve on error.
Mario Six573b1b92018-08-09 14:51:16 +020034 */
35 int (*read)(struct udevice *dev, ulong address, void *data,
36 enum axi_size_t size);
37
38 /**
39 * write() - Write a single value to a specified address on a AXI bus
Mario Six573b1b92018-08-09 14:51:16 +020040 * @dev: AXI bus to write to.
41 * @address: The address to write to.
42 * @data: Pointer to the data value to be written to the address
43 * on the AXI bus.
44 * @size: The size of the data to write.
Mario Sixf95104d2018-08-09 14:51:18 +020045 *
46 * Return 0 if OK, -ve on error.
Mario Six573b1b92018-08-09 14:51:16 +020047 */
48 int (*write)(struct udevice *dev, ulong address, void *data,
49 enum axi_size_t size);
50};
51
52#define axi_get_ops(dev) ((struct axi_ops *)(dev)->driver->ops)
53
54/**
55 * axi_read() - Read a single value from a specified address on a AXI bus
Mario Six573b1b92018-08-09 14:51:16 +020056 * @dev: AXI bus to read from.
57 * @address: The address to read from.
58 * @data: Pointer to a variable that takes the data value read from the
59 * address on the AXI bus.
60 * @size: The size of the data to write.
Mario Sixf95104d2018-08-09 14:51:18 +020061 *
62 * Return: 0 if OK, -ve on error.
Mario Six573b1b92018-08-09 14:51:16 +020063 */
64int axi_read(struct udevice *dev, ulong address, void *data,
65 enum axi_size_t size);
66
67/**
68 * axi_write() - Write a single value to a specified address on a AXI bus
Mario Six573b1b92018-08-09 14:51:16 +020069 * @dev: AXI bus to write to.
70 * @address: The address to write to.
71 * @data: Pointer to the data value to be written to the address on the
72 * AXI bus.
73 * @size: The size of the data to write.
Mario Sixf95104d2018-08-09 14:51:18 +020074 *
75 * Return: 0 if OK, -ve on error.
Mario Six573b1b92018-08-09 14:51:16 +020076 */
77int axi_write(struct udevice *dev, ulong address, void *data,
78 enum axi_size_t size);
Mario Sixf95104d2018-08-09 14:51:18 +020079
80struct axi_emul_ops {
81 /**
82 * read() - Read a single value from a specified address on a AXI bus
83 * @dev: AXI bus to read from.
84 * @address: The address to read from.
85 * @data: Pointer to a variable that takes the data value read
86 * from the address on the AXI bus.
87 * @size: The size of the data to be read.
88 *
89 * Return: 0 if OK, -ve on error.
90 */
91 int (*read)(struct udevice *dev, ulong address, void *data,
92 enum axi_size_t size);
93
94 /**
95 * write() - Write a single value to a specified address on a AXI bus
96 * @dev: AXI bus to write to.
97 * @address: The address to write to.
98 * @data: Pointer to the data value to be written to the address
99 * on the AXI bus.
100 * @size: The size of the data to write.
101 *
102 * Return: 0 if OK, -ve on error.
103 */
104 int (*write)(struct udevice *dev, ulong address, void *data,
105 enum axi_size_t size);
106
107 /**
108 * get_store() - Get address of internal storage of a emulated AXI
109 * device
110 * @dev: Emulated AXI device to get the pointer of the internal
111 * storage for.
112 * @storep: Pointer to the internal storage of the emulated AXI
113 * device.
114 *
115 * Return: 0 if OK, -ve on error.
116 */
117 int (*get_store)(struct udevice *dev, u8 **storep);
118};
119
Mario Six573b1b92018-08-09 14:51:16 +0200120#endif