]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
i3c: mipi-i3c-hci: Allow core re-initialization for Runtime PM support
authorAdrian Hunter <adrian.hunter@intel.com>
Tue, 13 Jan 2026 07:26:58 +0000 (09:26 +0200)
committerAlexandre Belloni <alexandre.belloni@bootlin.com>
Wed, 14 Jan 2026 16:21:10 +0000 (17:21 +0100)
Prepare i3c_hci_reset_and_init() to support runtime resume.  Update it to
handle the case where the I/O mode has already been selected.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Link: https://patch.msgid.link/20260113072702.16268-18-adrian.hunter@intel.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
drivers/i3c/master/mipi-i3c-hci/core.c

index 8b8e3952d41d1da4db06f4497bf903b89eef09a8..fc0a47a369610f9a4fac2e21f1fd69dbb4916a2b 100644 (file)
@@ -681,27 +681,31 @@ static int i3c_hci_reset_and_init(struct i3c_hci *hci)
                }
        }
 
-       /* Try activating DMA operations first */
-       if (hci->RHS_regs) {
-               ret = i3c_hci_set_io_mode(hci, true);
-               if (!ret) {
-                       hci->io = &mipi_i3c_hci_dma;
-                       dev_dbg(&hci->master.dev, "Using DMA\n");
+       if (hci->io) {
+               ret = i3c_hci_set_io_mode(hci, hci->io == &mipi_i3c_hci_dma);
+       } else {
+               /* Try activating DMA operations first */
+               if (hci->RHS_regs) {
+                       ret = i3c_hci_set_io_mode(hci, true);
+                       if (!ret) {
+                               hci->io = &mipi_i3c_hci_dma;
+                               dev_dbg(&hci->master.dev, "Using DMA\n");
+                       }
                }
-       }
 
-       /* If no DMA, try PIO */
-       if (!hci->io && hci->PIO_regs) {
-               ret = i3c_hci_set_io_mode(hci, false);
-               if (!ret) {
-                       hci->io = &mipi_i3c_hci_pio;
-                       dev_dbg(&hci->master.dev, "Using PIO\n");
+               /* If no DMA, try PIO */
+               if (!hci->io && hci->PIO_regs) {
+                       ret = i3c_hci_set_io_mode(hci, false);
+                       if (!ret) {
+                               hci->io = &mipi_i3c_hci_pio;
+                               dev_dbg(&hci->master.dev, "Using PIO\n");
+                       }
                }
-       }
 
-       if (!hci->io) {
-               dev_err(&hci->master.dev, "neither DMA nor PIO can be used\n");
-               ret = ret ?: -EINVAL;
+               if (!hci->io) {
+                       dev_err(&hci->master.dev, "neither DMA nor PIO can be used\n");
+                       ret = ret ?: -EINVAL;
+               }
        }
        if (ret)
                return ret;