Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Adrian Hunter and committed by
Alexandre Belloni
57a2f976 8afa0dd8

+29 -12
+29 -12
drivers/i3c/master/mipi-i3c-hci/core.c
··· 585 585 return result; 586 586 } 587 587 588 + static int i3c_hci_software_reset(struct i3c_hci *hci) 589 + { 590 + u32 regval; 591 + int ret; 592 + 593 + /* 594 + * SOFT_RST must be clear before we write to it. 595 + * Then we must wait until it clears again. 596 + */ 597 + ret = readx_poll_timeout(reg_read, RESET_CONTROL, regval, 598 + !(regval & SOFT_RST), 0, 10 * USEC_PER_MSEC); 599 + if (ret) { 600 + dev_err(&hci->master.dev, "%s: Software reset stuck\n", __func__); 601 + return ret; 602 + } 603 + 604 + reg_write(RESET_CONTROL, SOFT_RST); 605 + 606 + ret = readx_poll_timeout(reg_read, RESET_CONTROL, regval, 607 + !(regval & SOFT_RST), 0, 10 * USEC_PER_MSEC); 608 + if (ret) { 609 + dev_err(&hci->master.dev, "%s: Software reset failed\n", __func__); 610 + return ret; 611 + } 612 + 613 + return 0; 614 + } 615 + 588 616 static int i3c_hci_init(struct i3c_hci *hci) 589 617 { 590 618 bool size_in_dwords, mode_selector; ··· 682 654 if (ret) 683 655 return ret; 684 656 685 - /* 686 - * Now let's reset the hardware. 687 - * SOFT_RST must be clear before we write to it. 688 - * Then we must wait until it clears again. 689 - */ 690 - ret = readx_poll_timeout(reg_read, RESET_CONTROL, regval, 691 - !(regval & SOFT_RST), 1, 10000); 692 - if (ret) 693 - return -ENXIO; 694 - reg_write(RESET_CONTROL, SOFT_RST); 695 - ret = readx_poll_timeout(reg_read, RESET_CONTROL, regval, 696 - !(regval & SOFT_RST), 1, 10000); 657 + ret = i3c_hci_software_reset(hci); 697 658 if (ret) 698 659 return -ENXIO; 699 660