Skip to content

Commit 039b236

Browse files
Shyam Sundar S Kalexandrebelloni
authored andcommitted
i3c: mipi-i3c-hci: Read HC_CONTROL_PIO_MODE only after i3c hci v1.1
The HC_CONTROL_PIO_MODE bit was introduced in the HC_CONTROL register starting from version 1.1. Therefore, checking the HC_CONTROL_PIO_MODE bit on hardware that adheres to older specification revisions (i.e., versions earlier than 1.1) is incorrect. To address this, add an additional check to read the HCI version before attempting to read the HC_CONTROL_PIO_MODE status. Signed-off-by: Shyam Sundar S K <[email protected]> Reviewed-by: Jarkko Nikula <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexandre Belloni <[email protected]>
1 parent 8d2e56e commit 039b236

File tree

1 file changed

+6
-3
lines changed
  • drivers/i3c/master/mipi-i3c-hci

1 file changed

+6
-3
lines changed

drivers/i3c/master/mipi-i3c-hci/core.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -630,8 +630,8 @@ static irqreturn_t i3c_hci_irq_handler(int irq, void *dev_id)
630630

631631
static int i3c_hci_init(struct i3c_hci *hci)
632632
{
633+
bool size_in_dwords, mode_selector;
633634
u32 regval, offset;
634-
bool size_in_dwords;
635635
int ret;
636636

637637
/* Validate HCI hardware version */
@@ -753,10 +753,13 @@ static int i3c_hci_init(struct i3c_hci *hci)
753753
return -EINVAL;
754754
}
755755

756+
mode_selector = hci->version_major > 1 ||
757+
(hci->version_major == 1 && hci->version_minor > 0);
758+
756759
/* Try activating DMA operations first */
757760
if (hci->RHS_regs) {
758761
reg_clear(HC_CONTROL, HC_CONTROL_PIO_MODE);
759-
if (reg_read(HC_CONTROL) & HC_CONTROL_PIO_MODE) {
762+
if (mode_selector && (reg_read(HC_CONTROL) & HC_CONTROL_PIO_MODE)) {
760763
dev_err(&hci->master.dev, "PIO mode is stuck\n");
761764
ret = -EIO;
762765
} else {
@@ -768,7 +771,7 @@ static int i3c_hci_init(struct i3c_hci *hci)
768771
/* If no DMA, try PIO */
769772
if (!hci->io && hci->PIO_regs) {
770773
reg_set(HC_CONTROL, HC_CONTROL_PIO_MODE);
771-
if (!(reg_read(HC_CONTROL) & HC_CONTROL_PIO_MODE)) {
774+
if (mode_selector && !(reg_read(HC_CONTROL) & HC_CONTROL_PIO_MODE)) {
772775
dev_err(&hci->master.dev, "DMA mode is stuck\n");
773776
ret = -EIO;
774777
} else {

0 commit comments

Comments
 (0)