blob: 133a06ee27198ec1897fe832796751d25a88ff95 [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
Tom Rinidec7ea02024-05-20 13:35:03 -060010#include <linux/types.h>
11
Simon Glass3ba929a2020-10-30 21:38:53 -060012struct udevice;
13
Mario Sixf95104d2018-08-09 14:51:18 +020014/**
15 * enum axi_size_t - Determine size of AXI transfer
16 * @AXI_SIZE_8: AXI sransfer is 8-bit wide
17 * @AXI_SIZE_16: AXI sransfer is 16-bit wide
18 * @AXI_SIZE_32: AXI sransfer is 32-bit wide
19 */
Mario Six573b1b92018-08-09 14:51:16 +020020enum axi_size_t {
21 AXI_SIZE_8,
22 AXI_SIZE_16,
23 AXI_SIZE_32,
24};
25
Mario Six573b1b92018-08-09 14:51:16 +020026struct axi_ops {
27 /**
28 * read() - Read a single value from a specified address on a AXI bus
Mario Six573b1b92018-08-09 14:51:16 +020029 * @dev: AXI bus to read from.
30 * @address: The address to read from.
31 * @data: Pointer to a variable that takes the data value read
32 * from the address on the AXI bus.
33 * @size: The size of the data to be read.
Mario Sixf95104d2018-08-09 14:51:18 +020034 *
35 * Return: 0 if OK, -ve on error.
Mario Six573b1b92018-08-09 14:51:16 +020036 */
37 int (*read)(struct udevice *dev, ulong address, void *data,
38 enum axi_size_t size);
39
40 /**
41 * write() - Write a single value to a specified address on a AXI bus
Mario Six573b1b92018-08-09 14:51:16 +020042 * @dev: AXI bus to write to.
43 * @address: The address to write to.
44 * @data: Pointer to the data value to be written to the address
45 * on the AXI bus.
46 * @size: The size of the data to write.
Mario Sixf95104d2018-08-09 14:51:18 +020047 *
48 * Return 0 if OK, -ve on error.
Mario Six573b1b92018-08-09 14:51:16 +020049 */
50 int (*write)(struct udevice *dev, ulong address, void *data,
51 enum axi_size_t size);
52};
53
54#define axi_get_ops(dev) ((struct axi_ops *)(dev)->driver->ops)
55
56/**
57 * axi_read() - Read a single value from a specified address on a AXI bus
Mario Six573b1b92018-08-09 14:51:16 +020058 * @dev: AXI bus to read from.
59 * @address: The address to read from.
60 * @data: Pointer to a variable that takes the data value read from the
61 * address on the AXI bus.
62 * @size: The size of the data to write.
Mario Sixf95104d2018-08-09 14:51:18 +020063 *
64 * Return: 0 if OK, -ve on error.
Mario Six573b1b92018-08-09 14:51:16 +020065 */
66int axi_read(struct udevice *dev, ulong address, void *data,
67 enum axi_size_t size);
68
69/**
70 * axi_write() - Write a single value to a specified address on a AXI bus
Mario Six573b1b92018-08-09 14:51:16 +020071 * @dev: AXI bus to write to.
72 * @address: The address to write to.
73 * @data: Pointer to the data value to be written to the address on the
74 * AXI bus.
75 * @size: The size of the data to write.
Mario Sixf95104d2018-08-09 14:51:18 +020076 *
77 * Return: 0 if OK, -ve on error.
Mario Six573b1b92018-08-09 14:51:16 +020078 */
79int axi_write(struct udevice *dev, ulong address, void *data,
80 enum axi_size_t size);
Mario Sixf95104d2018-08-09 14:51:18 +020081
82struct axi_emul_ops {
83 /**
84 * read() - Read a single value from a specified address on a AXI bus
85 * @dev: AXI bus to read from.
86 * @address: The address to read from.
87 * @data: Pointer to a variable that takes the data value read
88 * from the address on the AXI bus.
89 * @size: The size of the data to be read.
90 *
91 * Return: 0 if OK, -ve on error.
92 */
93 int (*read)(struct udevice *dev, ulong address, void *data,
94 enum axi_size_t size);
95
96 /**
97 * write() - Write a single value to a specified address on a AXI bus
98 * @dev: AXI bus to write to.
99 * @address: The address to write to.
100 * @data: Pointer to the data value to be written to the address
101 * on the AXI bus.
102 * @size: The size of the data to write.
103 *
104 * Return: 0 if OK, -ve on error.
105 */
106 int (*write)(struct udevice *dev, ulong address, void *data,
107 enum axi_size_t size);
108
109 /**
110 * get_store() - Get address of internal storage of a emulated AXI
111 * device
112 * @dev: Emulated AXI device to get the pointer of the internal
113 * storage for.
114 * @storep: Pointer to the internal storage of the emulated AXI
115 * device.
116 *
117 * Return: 0 if OK, -ve on error.
118 */
119 int (*get_store)(struct udevice *dev, u8 **storep);
120};
121
Mario Six573b1b92018-08-09 14:51:16 +0200122#endif