blob: 3e40692cdfda4595caf74bf72195ad03b7a04f9c [file] [log] [blame]
Mario Sixa63e54a2018-08-09 14:51:16 +02001/* SPDX-License-Identifier: GPL-2.0+ */
2/*
Mario Six9a8bcab2018-08-09 14:51:18 +02003 * (C) Copyright 2017, 2018
4 * Mario Six, Guntermann & Drunck GmbH, mario.six@gdsys.cc
Mario Sixa63e54a2018-08-09 14:51:16 +02005 */
6
7#ifndef _AXI_H_
8#define _AXI_H_
9
Mario Six9a8bcab2018-08-09 14:51:18 +020010/**
11 * enum axi_size_t - Determine size of AXI transfer
12 * @AXI_SIZE_8: AXI sransfer is 8-bit wide
13 * @AXI_SIZE_16: AXI sransfer is 16-bit wide
14 * @AXI_SIZE_32: AXI sransfer is 32-bit wide
15 */
Mario Sixa63e54a2018-08-09 14:51:16 +020016enum axi_size_t {
17 AXI_SIZE_8,
18 AXI_SIZE_16,
19 AXI_SIZE_32,
20};
21
Mario Sixa63e54a2018-08-09 14:51:16 +020022struct axi_ops {
23 /**
24 * read() - Read a single value from a specified address on a AXI bus
Mario Sixa63e54a2018-08-09 14:51:16 +020025 * @dev: AXI bus to read from.
26 * @address: The address to read from.
27 * @data: Pointer to a variable that takes the data value read
28 * from the address on the AXI bus.
29 * @size: The size of the data to be read.
Mario Six9a8bcab2018-08-09 14:51:18 +020030 *
31 * Return: 0 if OK, -ve on error.
Mario Sixa63e54a2018-08-09 14:51:16 +020032 */
33 int (*read)(struct udevice *dev, ulong address, void *data,
34 enum axi_size_t size);
35
36 /**
37 * write() - Write a single value to a specified address on a AXI bus
Mario Sixa63e54a2018-08-09 14:51:16 +020038 * @dev: AXI bus to write to.
39 * @address: The address to write to.
40 * @data: Pointer to the data value to be written to the address
41 * on the AXI bus.
42 * @size: The size of the data to write.
Mario Six9a8bcab2018-08-09 14:51:18 +020043 *
44 * Return 0 if OK, -ve on error.
Mario Sixa63e54a2018-08-09 14:51:16 +020045 */
46 int (*write)(struct udevice *dev, ulong address, void *data,
47 enum axi_size_t size);
48};
49
50#define axi_get_ops(dev) ((struct axi_ops *)(dev)->driver->ops)
51
52/**
53 * axi_read() - Read a single value from a specified address on a AXI bus
Mario Sixa63e54a2018-08-09 14:51:16 +020054 * @dev: AXI bus to read from.
55 * @address: The address to read from.
56 * @data: Pointer to a variable that takes the data value read from the
57 * address on the AXI bus.
58 * @size: The size of the data to write.
Mario Six9a8bcab2018-08-09 14:51:18 +020059 *
60 * Return: 0 if OK, -ve on error.
Mario Sixa63e54a2018-08-09 14:51:16 +020061 */
62int axi_read(struct udevice *dev, ulong address, void *data,
63 enum axi_size_t size);
64
65/**
66 * axi_write() - Write a single value to a specified address on a AXI bus
Mario Sixa63e54a2018-08-09 14:51:16 +020067 * @dev: AXI bus to write to.
68 * @address: The address to write to.
69 * @data: Pointer to the data value to be written to the address on the
70 * AXI bus.
71 * @size: The size of the data to write.
Mario Six9a8bcab2018-08-09 14:51:18 +020072 *
73 * Return: 0 if OK, -ve on error.
Mario Sixa63e54a2018-08-09 14:51:16 +020074 */
75int axi_write(struct udevice *dev, ulong address, void *data,
76 enum axi_size_t size);
Mario Six9a8bcab2018-08-09 14:51:18 +020077
78struct axi_emul_ops {
79 /**
80 * read() - Read a single value from a specified address on a AXI bus
81 * @dev: AXI bus to read from.
82 * @address: The address to read from.
83 * @data: Pointer to a variable that takes the data value read
84 * from the address on the AXI bus.
85 * @size: The size of the data to be read.
86 *
87 * Return: 0 if OK, -ve on error.
88 */
89 int (*read)(struct udevice *dev, ulong address, void *data,
90 enum axi_size_t size);
91
92 /**
93 * write() - Write a single value to a specified address on a AXI bus
94 * @dev: AXI bus to write to.
95 * @address: The address to write to.
96 * @data: Pointer to the data value to be written to the address
97 * on the AXI bus.
98 * @size: The size of the data to write.
99 *
100 * Return: 0 if OK, -ve on error.
101 */
102 int (*write)(struct udevice *dev, ulong address, void *data,
103 enum axi_size_t size);
104
105 /**
106 * get_store() - Get address of internal storage of a emulated AXI
107 * device
108 * @dev: Emulated AXI device to get the pointer of the internal
109 * storage for.
110 * @storep: Pointer to the internal storage of the emulated AXI
111 * device.
112 *
113 * Return: 0 if OK, -ve on error.
114 */
115 int (*get_store)(struct udevice *dev, u8 **storep);
116};
117
Mario Sixa63e54a2018-08-09 14:51:16 +0200118#endif