Skip to content

Commit 0c738b7

Browse files
michalsieroncarlescufi
authored andcommitted
ethernet: eth_liteeth: Use LiteX HAL
Use LiteX HAL functions instead of `sys_read*` or `sys_write*` functions. They use them inside, but choose which one to use according to configured CSR data width. Signed-off-by: Michal Sieron <[email protected]>
1 parent b9c836b commit 0c738b7

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

drivers/ethernet/eth_liteeth.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -93,20 +93,20 @@ static int eth_tx(const struct device *dev, struct net_pkt *pkt)
9393
len = net_pkt_get_len(pkt);
9494
net_pkt_read(pkt, context->tx_buf[context->txslot], len);
9595

96-
sys_write8(context->txslot, LITEETH_TX_SLOT);
97-
sys_write8(len >> 8, LITEETH_TX_LENGTH);
98-
sys_write8(len & 0xFF, LITEETH_TX_LENGTH + 4);
96+
litex_write8(context->txslot, LITEETH_TX_SLOT);
97+
litex_write8(len >> 8, LITEETH_TX_LENGTH);
98+
litex_write8(len & 0xFF, LITEETH_TX_LENGTH + 4);
9999

100100
/* wait for the device to be ready to transmit */
101-
while (sys_read8(LITEETH_TX_READY) == 0) {
101+
while (litex_read8(LITEETH_TX_READY) == 0) {
102102
if (attempts++ == MAX_TX_FAILURE) {
103103
goto error;
104104
}
105105
k_sleep(K_MSEC(1));
106106
}
107107

108108
/* start transmitting */
109-
sys_write8(1, LITEETH_TX_START);
109+
litex_write8(1, LITEETH_TX_START);
110110

111111
/* change slot */
112112
context->txslot = (context->txslot + 1) % 2;
@@ -134,11 +134,11 @@ static void eth_rx(const struct device *port)
134134
/* get frame's length */
135135
for (int i = 0; i < 4; i++) {
136136
len <<= 8;
137-
len |= sys_read8(LITEETH_RX_LENGTH + i * 0x4);
137+
len |= litex_read8(LITEETH_RX_LENGTH + i * 0x4);
138138
}
139139

140140
/* which slot is the frame in */
141-
context->rxslot = sys_read8(LITEETH_RX_SLOT);
141+
context->rxslot = litex_read8(LITEETH_RX_SLOT);
142142

143143
/* obtain rx buffer */
144144
pkt = net_pkt_rx_alloc_with_buffer(context->iface, len, AF_UNSPEC, 0,
@@ -169,19 +169,19 @@ static void eth_rx(const struct device *port)
169169
static void eth_irq_handler(const struct device *port)
170170
{
171171
/* check sram reader events (tx) */
172-
if (sys_read8(LITEETH_TX_EV_PENDING) & LITEETH_EV_TX) {
172+
if (litex_read8(LITEETH_TX_EV_PENDING) & LITEETH_EV_TX) {
173173
/* TX event is not enabled nor used by this driver; ack just
174174
* in case if some rogue TX event appeared
175175
*/
176-
sys_write8(LITEETH_EV_TX, LITEETH_TX_EV_PENDING);
176+
litex_write8(LITEETH_EV_TX, LITEETH_TX_EV_PENDING);
177177
}
178178

179179
/* check sram writer events (rx) */
180-
if (sys_read8(LITEETH_RX_EV_PENDING) & LITEETH_EV_RX) {
180+
if (litex_read8(LITEETH_RX_EV_PENDING) & LITEETH_EV_RX) {
181181
eth_rx(port);
182182

183183
/* ack writer irq */
184-
sys_write8(LITEETH_EV_RX, LITEETH_RX_EV_PENDING);
184+
litex_write8(LITEETH_EV_RX, LITEETH_RX_EV_PENDING);
185185
}
186186
}
187187

@@ -226,8 +226,8 @@ static void eth_iface_init(struct net_if *iface)
226226
}
227227

228228
/* clear pending events */
229-
sys_write8(LITEETH_EV_TX, LITEETH_TX_EV_PENDING);
230-
sys_write8(LITEETH_EV_RX, LITEETH_RX_EV_PENDING);
229+
litex_write8(LITEETH_EV_TX, LITEETH_TX_EV_PENDING);
230+
litex_write8(LITEETH_EV_RX, LITEETH_RX_EV_PENDING);
231231

232232
/* setup tx slots */
233233
context->txslot = 0;
@@ -264,7 +264,7 @@ static void eth_irq_config(void)
264264
IRQ_CONNECT(LITEETH_IRQ, LITEETH_IRQ_PRIORITY, eth_irq_handler,
265265
DEVICE_DT_INST_GET(0), 0);
266266
irq_enable(LITEETH_IRQ);
267-
sys_write8(1, LITEETH_RX_EV_ENABLE);
267+
litex_write8(1, LITEETH_RX_EV_ENABLE);
268268
}
269269

270270
#endif /* CONFIG_ETH_LITEETH_0 */

0 commit comments

Comments
 (0)