1 /* SPDX-License-Identifier: GPL-2.0+ */
4 * Mario Six, Guntermann & Drunck GmbH, mario.six@gdsys.cc
7 #ifndef __GDSYS_IOEP_H_
8 #define __GDSYS_IOEP_H_
11 * struct io_generic_packet - header structure for GDSYS IOEP packets
12 * @target_address: Target protocol address of the packet.
13 * @source_address: Source protocol address of the packet.
14 * @packet_type: Packet type.
15 * @bc: Block counter (filled in by FPGA).
16 * @packet_length: Length of the packet's payload bytes.
18 struct io_generic_packet {
24 } __attribute__((__packed__));
27 * struct gdsys_ioep_regs - Registers of a IOEP device
28 * @transmit_data: Register that receives data to be sent
29 * @tx_control: TX control register
30 * @receive_data: Register filled with the received data
31 * @rx_tx_status: RX/TX status register
32 * @device_address: Register for setting/reading the device's address
33 * @target_address: Register for setting/reading the remote endpoint's address
34 * @int_enable: Interrupt/Interrupt enable register
36 struct gdsys_ioep_regs {
47 * gdsys_ioep_set() - Convenience macro to write registers of a IOEP device
48 * @map: Register map to write the value in
49 * @member: Name of the member in the gdsys_ioep_regs structure to write
50 * @val: Value to write to the register
52 #define gdsys_ioep_set(map, member, val) \
53 regmap_set(map, struct gdsys_ioep_regs, member, val)
56 * gdsys_ioep_get() - Convenience macro to read registers of a IOEP device
57 * @map: Register map to read the value from
58 * @member: Name of the member in the gdsys_ioep_regs structure to read
59 * @valp: Pointer to buffer to read the register value into
61 #define gdsys_ioep_get(map, member, valp) \
62 regmap_get(map, struct gdsys_ioep_regs, member, valp)
65 * enum rx_tx_status_values - Enum to describe the fields of the rx_tx_status
67 * @STATE_TX_PACKET_BUILDING: The device is currently building a packet
68 * (and accepting data for it)
69 * @STATE_TX_TRANSMITTING: A packet is currenly being transmitted
70 * @STATE_TX_BUFFER_FULL: The TX buffer is full
71 * @STATE_TX_ERR: A TX error occurred
72 * @STATE_RECEIVE_TIMEOUT: A receive timeout occurred
73 * @STATE_PROC_RX_STORE_TIMEOUT: A RX store timeout for a processor packet
75 * @STATE_PROC_RX_RECEIVE_TIMEOUT: A RX receive timeout for a processor packet
77 * @STATE_RX_DIST_ERR: A error occurred in the distribution block
78 * @STATE_RX_LENGTH_ERR: A length invalid error occurred
79 * @STATE_RX_FRAME_CTR_ERR: A frame count error occurred (two
80 * non-increasing frame count numbers
82 * @STATE_RX_FCS_ERR: A CRC error occurred
83 * @STATE_RX_PACKET_DROPPED: A RX packet has been dropped
84 * @STATE_RX_DATA_LAST: The data to be read is the final data of the
86 * @STATE_RX_DATA_FIRST: The data to be read is the first data of the
88 * @STATE_RX_DATA_AVAILABLE: RX data is available to be read
90 enum rx_tx_status_values {
91 STATE_TX_PACKET_BUILDING = BIT(0),
92 STATE_TX_TRANSMITTING = BIT(1),
93 STATE_TX_BUFFER_FULL = BIT(2),
94 STATE_TX_ERR = BIT(3),
95 STATE_RECEIVE_TIMEOUT = BIT(4),
96 STATE_PROC_RX_STORE_TIMEOUT = BIT(5),
97 STATE_PROC_RX_RECEIVE_TIMEOUT = BIT(6),
98 STATE_RX_DIST_ERR = BIT(7),
99 STATE_RX_LENGTH_ERR = BIT(8),
100 STATE_RX_FRAME_CTR_ERR = BIT(9),
101 STATE_RX_FCS_ERR = BIT(10),
102 STATE_RX_PACKET_DROPPED = BIT(11),
103 STATE_RX_DATA_LAST = BIT(12),
104 STATE_RX_DATA_FIRST = BIT(13),
105 STATE_RX_DATA_AVAILABLE = BIT(15),
109 * enum tx_control_values - Enum to describe the fields of the tx_control
111 * @CTRL_PROC_RECEIVE_ENABLE: Enable packet reception for the processor
112 * @CTRL_FLUSH_TRANSMIT_BUFFER: Flush the transmit buffer (and send packet data)
114 enum tx_control_values {
115 CTRL_PROC_RECEIVE_ENABLE = BIT(12),
116 CTRL_FLUSH_TRANSMIT_BUFFER = BIT(15),
120 * enum int_enable_values - Enum to describe the fields of the int_enable
122 * @IRQ_CPU_TRANSMITBUFFER_FREE_STATUS: The transmit buffer is free (packet
123 * data can be transmitted to the
125 * @IRQ_CPU_PACKET_TRANSMITTED_EVENT: A packet has been transmitted
126 * @IRQ_NEW_CPU_PACKET_RECEIVED_EVENT: A new packet has been received
127 * @IRQ_CPU_RECEIVE_DATA_AVAILABLE_STATUS: RX packet data are available to be
130 enum int_enable_values {
131 IRQ_CPU_TRANSMITBUFFER_FREE_STATUS = BIT(5),
132 IRQ_CPU_PACKET_TRANSMITTED_EVENT = BIT(6),
133 IRQ_NEW_CPU_PACKET_RECEIVED_EVENT = BIT(7),
134 IRQ_CPU_RECEIVE_DATA_AVAILABLE_STATUS = BIT(8),
137 #endif /* __GDSYS_IOEP_H_ */