mfd: fusb302: change to host when connect type-c to standard-a cable
authorMeng Dongyang <daniel.meng@rock-chips.com>
Mon, 15 Aug 2016 04:25:57 +0000 (12:25 +0800)
committerHuang, Tao <huangtao@rock-chips.com>
Wed, 24 Aug 2016 08:03:55 +0000 (16:03 +0800)
When connected with type-c to standard-a cable, inno phy will
generate an interrupt before setting the state of typec to host,
which result in detecting of battery charger. This patch change
the state to host before interrupt happen.

Change-Id: I6a2e15c264bd6729c3b8d23af23ad15145559b20
Signed-off-by: Meng Dongyang <daniel.meng@rock-chips.com>
drivers/mfd/fusb302.c

index e4bcd93982b8891c4851ff27087f0fec0858a828..2defbdea20b3fe5ada58d708e32f8803bfc09c18 100644 (file)
@@ -1277,9 +1277,6 @@ static void fusb_state_attach_wait_source(struct fusb30x_chip *chip, int evt)
 
                if ((chip->cc1 == cc1) && (chip->cc2 == cc2)) {
                        chip->debounce_cnt++;
-                       tcpm_set_polarity(chip, !(chip->cc_state & 0x01));
-                       platform_set_vbus_lvl_enable(chip, 1, 0);
-                       tcpm_set_vconn(chip, 1);
                } else {
                        chip->cc1 = cc1;
                        chip->cc2 = cc2;
@@ -1306,6 +1303,11 @@ static void fusb_state_attach_wait_source(struct fusb30x_chip *chip, int evt)
 
 static void fusb_state_attached_source(struct fusb30x_chip *chip, int evt)
 {
+       tcpm_set_polarity(chip, !(chip->cc_state & 0x01));
+       extcon_set_state(chip->extcon, EXTCON_USB_HOST, 1);
+       platform_set_vbus_lvl_enable(chip, 1, 0);
+       tcpm_set_vconn(chip, 1);
+
        chip->notify.is_cc_connected = 1;
        if (chip->cc_state & 0x01)
                chip->cc_polarity = 0;