diff options
| author | Adrian Hunter <adrian.hunter@intel.com> | 2026-01-13 09:26:55 +0200 |
|---|---|---|
| committer | Alexandre Belloni <alexandre.belloni@bootlin.com> | 2026-01-14 17:21:10 +0100 |
| commit | 57a2f976ac18b909e43cca51a63be26cbd62ab88 (patch) | |
| tree | 5864d3dbf9a55f831c632a3a935d68d545c4d63c /drivers/i3c | |
| parent | 8afa0dd83b608a344b967dc1ef1b4f282662416d (diff) | |
i3c: mipi-i3c-hci: Factor out software reset into helper
Prepare for future reuse of the reset sequence in other contexts, such as
power management. Move the software reset logic from i3c_hci_init() into a
dedicated helper function, i3c_hci_software_reset().
Software reset should never fail. Print an error message if it does.
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Link: https://patch.msgid.link/20260113072702.16268-15-adrian.hunter@intel.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Diffstat (limited to 'drivers/i3c')
| -rw-r--r-- | drivers/i3c/master/mipi-i3c-hci/core.c | 41 |
1 files changed, 29 insertions, 12 deletions
diff --git a/drivers/i3c/master/mipi-i3c-hci/core.c b/drivers/i3c/master/mipi-i3c-hci/core.c index c4b249fde764..3b0609cb7da7 100644 --- a/drivers/i3c/master/mipi-i3c-hci/core.c +++ b/drivers/i3c/master/mipi-i3c-hci/core.c @@ -585,6 +585,34 @@ static irqreturn_t i3c_hci_irq_handler(int irq, void *dev_id) return result; } +static int i3c_hci_software_reset(struct i3c_hci *hci) +{ + u32 regval; + int ret; + + /* + * SOFT_RST must be clear before we write to it. + * Then we must wait until it clears again. + */ + ret = readx_poll_timeout(reg_read, RESET_CONTROL, regval, + !(regval & SOFT_RST), 0, 10 * USEC_PER_MSEC); + if (ret) { + dev_err(&hci->master.dev, "%s: Software reset stuck\n", __func__); + return ret; + } + + reg_write(RESET_CONTROL, SOFT_RST); + + ret = readx_poll_timeout(reg_read, RESET_CONTROL, regval, + !(regval & SOFT_RST), 0, 10 * USEC_PER_MSEC); + if (ret) { + dev_err(&hci->master.dev, "%s: Software reset failed\n", __func__); + return ret; + } + + return 0; +} + static int i3c_hci_init(struct i3c_hci *hci) { bool size_in_dwords, mode_selector; @@ -654,18 +682,7 @@ static int i3c_hci_init(struct i3c_hci *hci) if (ret) return ret; - /* - * Now let's reset the hardware. - * SOFT_RST must be clear before we write to it. - * Then we must wait until it clears again. - */ - ret = readx_poll_timeout(reg_read, RESET_CONTROL, regval, - !(regval & SOFT_RST), 1, 10000); - if (ret) - return -ENXIO; - reg_write(RESET_CONTROL, SOFT_RST); - ret = readx_poll_timeout(reg_read, RESET_CONTROL, regval, - !(regval & SOFT_RST), 1, 10000); + ret = i3c_hci_software_reset(hci); if (ret) return -ENXIO; |
