clk: rockchip: rk3288: fix up the clk register for hclk_vio
[firefly-linux-kernel-4.4.55.git] / drivers / mfd / fusb302.c
index 3201a17fa53d7d92525315b59005f4a22cc013f9..53b236b1dc0dd5d148210f3dc8af05a8bf3aaa43 100644 (file)
@@ -11,7 +11,6 @@
 
 #include <linux/delay.h>
 #include <linux/extcon.h>
-#include <linux/freezer.h>
 #include <linux/gpio.h>
 #include <linux/interrupt.h>
 #include <linux/module.h>
@@ -249,32 +248,6 @@ static void platform_fusb_notify(struct fusb30x_chip *chip)
                        usb_ss = 1;
                }
 
-               if (chip->notify.power_role == 0 &&
-                   chip->notify.is_pd_connected &&
-                   chip->pd_output_vol > 0 && chip->pd_output_cur > 0) {
-                       extcon_set_state(chip->extcon, EXTCON_CHG_USB_FAST,
-                                        true);
-                       property.intval =
-                               (chip->pd_output_cur << 15 |
-                                chip->pd_output_vol);
-                       extcon_set_property(chip->extcon, EXTCON_CHG_USB_FAST,
-                                           EXTCON_PROP_USB_TYPEC_POLARITY,
-                                           property);
-                       extcon_sync(chip->extcon, EXTCON_CHG_USB_FAST);
-               }
-
-#ifdef CONFIG_FREEZER
-               /*
-                * If system enter PM suspend, we need to wait until
-                * PM resume all of devices completion, then the flag
-                * pm_freezing will be set to false, and we can send
-                * notifier to USB/DP module safety, it make sure that
-                * USB/DP can enable power domain successfully.
-                */
-               while (pm_freezing)
-                       usleep_range(10000, 11000);
-#endif
-
                property.intval = flip;
                extcon_set_property(chip->extcon, EXTCON_USB,
                                    EXTCON_PROP_USB_TYPEC_POLARITY, property);
@@ -296,6 +269,18 @@ static void platform_fusb_notify(struct fusb30x_chip *chip)
                extcon_sync(chip->extcon, EXTCON_USB);
                extcon_sync(chip->extcon, EXTCON_USB_HOST);
                extcon_sync(chip->extcon, EXTCON_DISP_DP);
+               if (chip->notify.power_role == 0 &&
+                   chip->notify.is_pd_connected &&
+                   chip->pd_output_vol > 0 && chip->pd_output_cur > 0) {
+                       extcon_set_state(chip->extcon, EXTCON_CHG_USB_FAST, true);
+                       property.intval =
+                               (chip->pd_output_cur << 15 |
+                                chip->pd_output_vol);
+                       extcon_set_property(chip->extcon, EXTCON_CHG_USB_FAST,
+                                           EXTCON_PROP_USB_TYPEC_POLARITY,
+                                           property);
+                       extcon_sync(chip->extcon, EXTCON_CHG_USB_FAST);
+               }
        }
 }
 
@@ -715,6 +700,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 +760,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;
+               }
        }
 }