Skip to content

Commit 4dd12e9

Browse files
stanleychuysalexandrebelloni
authored andcommitted
i3c: master: svc: Fix npcm845 invalid slvstart event
I3C HW may generate an invalid SlvStart event when emitting a STOP. If it is a true SlvStart, the MSTATUS state is SLVREQ. Check the MSTATUS state to ignore the false event. Reviewed-by: Frank Li <[email protected]> Signed-off-by: Stanley Chu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexandre Belloni <[email protected]>
1 parent 4008a74 commit 4dd12e9

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

drivers/i3c/master/svc-i3c-master.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
#define SVC_I3C_MSTATUS 0x088
5959
#define SVC_I3C_MSTATUS_STATE(x) FIELD_GET(GENMASK(2, 0), (x))
6060
#define SVC_I3C_MSTATUS_STATE_DAA(x) (SVC_I3C_MSTATUS_STATE(x) == 5)
61+
#define SVC_I3C_MSTATUS_STATE_SLVREQ(x) (SVC_I3C_MSTATUS_STATE(x) == 1)
6162
#define SVC_I3C_MSTATUS_STATE_IDLE(x) (SVC_I3C_MSTATUS_STATE(x) == 0)
6263
#define SVC_I3C_MSTATUS_BETWEEN(x) FIELD_GET(BIT(4), (x))
6364
#define SVC_I3C_MSTATUS_NACKED(x) FIELD_GET(BIT(5), (x))
@@ -143,6 +144,12 @@
143144
* Fill the FIFO in advance to prevent FIFO from becoming empty.
144145
*/
145146
#define SVC_I3C_QUIRK_FIFO_EMPTY BIT(0)
147+
/*
148+
* SVC_I3C_QUIRK_FLASE_SLVSTART:
149+
* I3C HW may generate an invalid SlvStart event when emitting a STOP.
150+
* If it is a true SlvStart, the MSTATUS state is SLVREQ.
151+
*/
152+
#define SVC_I3C_QUIRK_FALSE_SLVSTART BIT(1)
146153

147154
struct svc_i3c_cmd {
148155
u8 addr;
@@ -586,6 +593,11 @@ static irqreturn_t svc_i3c_master_irq_handler(int irq, void *dev_id)
586593
/* Clear the interrupt status */
587594
writel(SVC_I3C_MINT_SLVSTART, master->regs + SVC_I3C_MSTATUS);
588595

596+
/* Ignore the false event */
597+
if (svc_has_quirk(master, SVC_I3C_QUIRK_FALSE_SLVSTART) &&
598+
!SVC_I3C_MSTATUS_STATE_SLVREQ(active))
599+
return IRQ_HANDLED;
600+
589601
svc_i3c_master_disable_interrupts(master);
590602

591603
/* Handle the interrupt in a non atomic context */
@@ -2020,7 +2032,8 @@ static const struct dev_pm_ops svc_i3c_pm_ops = {
20202032
};
20212033

20222034
static const struct svc_i3c_drvdata npcm845_drvdata = {
2023-
.quirks = SVC_I3C_QUIRK_FIFO_EMPTY,
2035+
.quirks = SVC_I3C_QUIRK_FIFO_EMPTY |
2036+
SVC_I3C_QUIRK_FALSE_SLVSTART,
20242037
};
20252038

20262039
static const struct svc_i3c_drvdata svc_default_drvdata = {};

0 commit comments

Comments
 (0)