Skip to content

Commit 9911be1

Browse files
Devyn LiuAndi Shyti
authored andcommitted
i2c: hisi: Add clearing tx aempty interrupt operation
The driver receives the tx fifo almost empty(aempty) interrupt and reads the tx_aempty_int_mstat to start a round of data transfer. The operation of clearing the TX aempty interrupt after completing a write cycle is added to ensure that the FIFO is truly at almost empty status when an aempty interrupt is received. The threshold for fifo almost empty interrupt is defined as 1. Signed-off-by: Devyn Liu <[email protected]> Reviewed-by: Yicong Yang <[email protected]> Reviewed-by: Andi Shyti <[email protected]> Signed-off-by: Andi Shyti <[email protected]>
1 parent 5c01572 commit 9911be1

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

drivers/i2c/busses/i2c-hisi.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@
5757
#define HISI_I2C_FS_SPK_LEN_CNT GENMASK(7, 0)
5858
#define HISI_I2C_HS_SPK_LEN 0x003c
5959
#define HISI_I2C_HS_SPK_LEN_CNT GENMASK(7, 0)
60+
#define HISI_I2C_TX_INT_CLR 0x0040
61+
#define HISI_I2C_TX_AEMPTY_INT BIT(0)
6062
#define HISI_I2C_INT_MSTAT 0x0044
6163
#define HISI_I2C_INT_CLR 0x0048
6264
#define HISI_I2C_INT_MASK 0x004C
@@ -124,6 +126,11 @@ static void hisi_i2c_clear_int(struct hisi_i2c_controller *ctlr, u32 mask)
124126
writel_relaxed(mask, ctlr->iobase + HISI_I2C_INT_CLR);
125127
}
126128

129+
static void hisi_i2c_clear_tx_int(struct hisi_i2c_controller *ctlr, u32 mask)
130+
{
131+
writel_relaxed(mask, ctlr->iobase + HISI_I2C_TX_INT_CLR);
132+
}
133+
127134
static void hisi_i2c_handle_errors(struct hisi_i2c_controller *ctlr)
128135
{
129136
u32 int_err = ctlr->xfer_err, reg;
@@ -168,6 +175,7 @@ static int hisi_i2c_start_xfer(struct hisi_i2c_controller *ctlr)
168175
writel(reg, ctlr->iobase + HISI_I2C_FIFO_CTRL);
169176

170177
hisi_i2c_clear_int(ctlr, HISI_I2C_INT_ALL);
178+
hisi_i2c_clear_tx_int(ctlr, HISI_I2C_TX_AEMPTY_INT);
171179
hisi_i2c_enable_int(ctlr, HISI_I2C_INT_ALL);
172180

173181
return 0;
@@ -323,6 +331,8 @@ static void hisi_i2c_xfer_msg(struct hisi_i2c_controller *ctlr)
323331
*/
324332
if (ctlr->msg_tx_idx == ctlr->msg_num)
325333
hisi_i2c_disable_int(ctlr, HISI_I2C_INT_TX_EMPTY);
334+
335+
hisi_i2c_clear_tx_int(ctlr, HISI_I2C_TX_AEMPTY_INT);
326336
}
327337

328338
static irqreturn_t hisi_i2c_irq(int irq, void *context)
@@ -363,6 +373,7 @@ static irqreturn_t hisi_i2c_irq(int irq, void *context)
363373
if (int_stat & HISI_I2C_INT_TRANS_CPLT) {
364374
hisi_i2c_disable_int(ctlr, HISI_I2C_INT_ALL);
365375
hisi_i2c_clear_int(ctlr, HISI_I2C_INT_ALL);
376+
hisi_i2c_clear_tx_int(ctlr, HISI_I2C_TX_AEMPTY_INT);
366377
complete(ctlr->completion);
367378
}
368379

0 commit comments

Comments
 (0)