Skip to content

Commit c20d3fa

Browse files
gastmaieralexandrebelloni
authored andcommitted
i3c: master: cdns: Use i3c_writel_fifo() and i3c_readl_fifo()
Use common inline i3c_writel_fifo()/i3c_readl_fifo() methods to simplify code since the FIFO of controller is a 32bit width. Signed-off-by: Jorge Marques <[email protected]> Reviewed-by: Frank Li <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexandre Belloni <[email protected]>
1 parent 733b439 commit c20d3fa

File tree

1 file changed

+5
-20
lines changed

1 file changed

+5
-20
lines changed

drivers/i3c/master/i3c-master-cdns.c

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
#include <linux/spinlock.h>
2424
#include <linux/workqueue.h>
2525

26+
#include "../internals.h"
27+
2628
#define DEV_ID 0x0
2729
#define DEV_ID_I3C_MASTER 0x5034
2830

@@ -427,25 +429,13 @@ to_cdns_i3c_master(struct i3c_master_controller *master)
427429
static void cdns_i3c_master_wr_to_tx_fifo(struct cdns_i3c_master *master,
428430
const u8 *bytes, int nbytes)
429431
{
430-
writesl(master->regs + TX_FIFO, bytes, nbytes / 4);
431-
if (nbytes & 3) {
432-
u32 tmp = 0;
433-
434-
memcpy(&tmp, bytes + (nbytes & ~3), nbytes & 3);
435-
writesl(master->regs + TX_FIFO, &tmp, 1);
436-
}
432+
i3c_writel_fifo(master->regs + TX_FIFO, bytes, nbytes);
437433
}
438434

439435
static void cdns_i3c_master_rd_from_rx_fifo(struct cdns_i3c_master *master,
440436
u8 *bytes, int nbytes)
441437
{
442-
readsl(master->regs + RX_FIFO, bytes, nbytes / 4);
443-
if (nbytes & 3) {
444-
u32 tmp;
445-
446-
readsl(master->regs + RX_FIFO, &tmp, 1);
447-
memcpy(bytes + (nbytes & ~3), &tmp, nbytes & 3);
448-
}
438+
i3c_readl_fifo(master->regs + RX_FIFO, bytes, nbytes);
449439
}
450440

451441
static bool cdns_i3c_master_supports_ccc_cmd(struct i3c_master_controller *m,
@@ -1330,12 +1320,7 @@ static void cdns_i3c_master_handle_ibi(struct cdns_i3c_master *master,
13301320
buf = slot->data;
13311321

13321322
nbytes = IBIR_XFER_BYTES(ibir);
1333-
readsl(master->regs + IBI_DATA_FIFO, buf, nbytes / 4);
1334-
if (nbytes % 3) {
1335-
u32 tmp = __raw_readl(master->regs + IBI_DATA_FIFO);
1336-
1337-
memcpy(buf + (nbytes & ~3), &tmp, nbytes & 3);
1338-
}
1323+
i3c_readl_fifo(master->regs + IBI_DATA_FIFO, buf, nbytes);
13391324

13401325
slot->len = min_t(unsigned int, IBIR_XFER_BYTES(ibir),
13411326
dev->ibi->max_payload_len);

0 commit comments

Comments
 (0)