From 44f07bf4bc7deba96595371ef2af35d4f23c990e Mon Sep 17 00:00:00 2001 From: Frank Wang Date: Fri, 24 Dec 2021 17:45:04 +0800 Subject: [PATCH] usb: typec: fusb302: do reset if the power was off in suspend For power consumption saving, the power of fusb302 may be off in PM suspend, so we must reset the tcpm port first in PM resume process to ensure the devices can attach again. Signed-off-by: Frank Wang Change-Id: Id2cde954663c2f8e01cf19f90066dd1b942a216e --- drivers/usb/typec/tcpm/fusb302.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/usb/typec/tcpm/fusb302.c b/drivers/usb/typec/tcpm/fusb302.c index ff82b6ae6850..887644b39617 100644 --- a/drivers/usb/typec/tcpm/fusb302.c +++ b/drivers/usb/typec/tcpm/fusb302.c @@ -1802,6 +1802,17 @@ static int fusb302_pm_resume(struct device *dev) { struct fusb302_chip *chip = dev->driver_data; unsigned long flags; + u8 pwr; + int ret = 0; + + /* + * When the power of fusb302 is lost or i2c read failed in PM S/R + * process, we must reset the tcpm port first to ensure the devices + * can attach again. + */ + ret = fusb302_i2c_read(chip, FUSB_REG_POWER, &pwr); + if (pwr != FUSB_REG_POWER_PWR_ALL || ret < 0) + tcpm_tcpc_reset(chip->tcpm_port); spin_lock_irqsave(&chip->irq_lock, flags); if (chip->irq_while_suspended) {