mfd: fusb302: fix connect adapter failed when reboot with adapter
authorZhou weixin <zwx@rock-chips.com>
Wed, 4 Jan 2017 02:28:59 +0000 (10:28 +0800)
committerHuang, Tao <huangtao@rock-chips.com>
Mon, 9 Jan 2017 07:54:54 +0000 (15:54 +0800)
The fusb PD should be reset to sync adapter PD signal after fusb
sent hard reset cmd.

Change-Id: Iad5f27cf4c017639c24000e73dc831a36dbb55ec
Signed-off-by: Zhou weixin <zwx@rock-chips.com>
drivers/mfd/fusb302.c

index 3201a17fa53d7d92525315b59005f4a22cc013f9..96b3344b4bdf605f95b47f71f825e9b77c14a8d9 100644 (file)
@@ -715,6 +715,7 @@ static void tcpc_alert(struct fusb30x_chip *chip, int *evt)
 {
        int interrupt, interrupta, interruptb;
        u32 val;
+       static int retry;
 
        regmap_read(chip->regmap, FUSB_REG_INTERRUPT, &interrupt);
        regmap_read(chip->regmap, FUSB_REG_INTERRUPTA, &interrupta);
@@ -774,9 +775,21 @@ static void tcpc_alert(struct fusb30x_chip *chip, int *evt)
        }
 
        if (interrupta & INTERRUPTA_HARDSENT) {
-               chip->tx_state = tx_success;
-               chip->timer_state = T_DISABLED;
-               *evt |= EVENT_TX;
+               /*
+                * The fusb PD should be reset once to sync adapter PD
+                * signal after fusb sent hard reset cmd.This is not PD
+                * device if reset failed.
+                */
+               if (!retry) {
+                       retry = 1;
+                       fusb302_pd_reset(chip);
+                       pd_execute_hard_reset(chip);
+               } else {
+                       retry = 0;
+                       chip->tx_state = tx_success;
+                       chip->timer_state = T_DISABLED;
+                       *evt |= EVENT_TX;
+               }
        }
 }