[PATCH] i3c: dw: Fix IBI intr signal programming

Aniket
2024-06-06T12:48:33Z

IBI_SIR_REQ_REJECT register is not present if the IP
has IC_HAS_IBI_DATA = 1 set. So don't rely on this
register to program IBI intr signals.
Instead use a simple counter to do the job. The counter
is protected by spinlock.

Signed-off-by: Aniket <aniketmaurya@google.com>
---
drivers/i3c/master/dw-i3c-master.c | 4 ++--
drivers/i3c/master/dw-i3c-master.h | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/i3c/master/dw-i3c-master.c b/drivers/i3c/master/dw-i3c-master.c
index 0ec00e644bd4..08f3ef000206 100644
--- a/drivers/i3c/master/dw-i3c-master.c
+++ b/drivers/i3c/master/dw-i3c-master.c
@@ -1177,13 +1177,13 @@ static void dw_i3c_master_set_sir_enabled(struct dw_i3c_master *master,

reg = readl(master->regs + IBI_SIR_REQ_REJECT);
if (enable) {
- global = reg == 0xffffffff;
+ global = !master->sir_en_cnt++;
reg &= ~BIT(idx);
} else {
bool hj_rejected = !!(readl(master->regs + DEVICE_CTRL) & DEV_CTRL_HOT_JOIN_NACK);

reg |= BIT(idx);
- global = (reg == 0xffffffff) && hj_rejected;
+ global = (!--master->sir_en_cnt) && hj_rejected;
}
writel(reg, master->regs + IBI_SIR_REQ_REJECT);

diff --git a/drivers/i3c/master/dw-i3c-master.h b/drivers/i3c/master/dw-i3c-master.h
index 4ab94aa72252..44a5f045f007 100644
--- a/drivers/i3c/master/dw-i3c-master.h
+++ b/drivers/i3c/master/dw-i3c-master.h
@@ -39,7 +39,7 @@ struct dw_i3c_master {
char version[5];
char type[5];
bool ibi_capable;
-
+ u8 sir_en_cnt;
/*
* Per-device hardware data, used to manage the device address table
* (DAT)
--
2.45.1.467.gbab1589fc0-goog