mfd: fusb302: add usb super speed property support.
authorwenping.zhang <wenping.zhang@rock-chips.com>
Thu, 29 Sep 2016 09:48:50 +0000 (17:48 +0800)
committerHuang, Tao <huangtao@rock-chips.com>
Mon, 10 Oct 2016 12:16:45 +0000 (20:16 +0800)
The meaning of the property value is as below:
The value of the property EXTCON_PROP_USB_SS is 0: USB1.0 or USB2.0
The value of the property EXTCON_PROP_USB_SS is 1: USB3.0

we change the logic of fusb302 notification , if dp sink device is connected, dfp is set to 1,
and use pin assignment value to define if sink device support usb3.0.

Change-Id: Ib7afaf9b754b4585b0ef211dd246059b8ab72904
Signed-off-by: wenping.zhang <wenping.zhang@rock-chips.com>
drivers/mfd/fusb302.c

index 3baaa6c21f65667f0e8e2369b4c06e76bb0f6b66..7bf2a65aa99f9c661fb9db17c37aefc714539060 100644 (file)
@@ -140,7 +140,7 @@ void fusb_irq_enable(struct fusb30x_chip *chip)
 
 static void platform_fusb_notify(struct fusb30x_chip *chip)
 {
-       bool plugged = 0, flip = 0, dfp = 0, ufp = 0, dp = 0;
+       bool plugged = 0, flip = 0, dfp = 0, ufp = 0, dp = 0, usb_ss = 0;
        union extcon_property_value property;
 
        if (chip->notify.is_cc_connected)
@@ -160,13 +160,17 @@ static void platform_fusb_notify(struct fusb30x_chip *chip)
                       (chip->notify.orientation - 1) : 0;
                dp = chip->notify.is_enter_mode;
 
-               if (dp)
-                       dfp = (chip->notify.pin_assignment_def &
+               if (dp) {
+                       dfp = 1;
+                       usb_ss = (chip->notify.pin_assignment_def &
                                (PIN_MAP_B | PIN_MAP_D | PIN_MAP_F)) ? 1 : 0;
-               else if (chip->notify.data_role)
+               } else if (chip->notify.data_role) {
                        dfp = 1;
-               else if (plugged)
+                       usb_ss = 1;
+               } else if (plugged) {
                        ufp = 1;
+                       usb_ss = 1;
+               }
 
                property.intval = flip;
                extcon_set_property(chip->extcon, EXTCON_USB,
@@ -175,6 +179,14 @@ static void platform_fusb_notify(struct fusb30x_chip *chip)
                                    EXTCON_PROP_USB_TYPEC_POLARITY, property);
                extcon_set_property(chip->extcon, EXTCON_DISP_DP,
                                    EXTCON_PROP_USB_TYPEC_POLARITY, property);
+
+               property.intval = usb_ss;
+               extcon_set_property(chip->extcon, EXTCON_USB,
+                                   EXTCON_PROP_USB_SS, property);
+               extcon_set_property(chip->extcon, EXTCON_USB_HOST,
+                                   EXTCON_PROP_USB_SS, property);
+               extcon_set_property(chip->extcon, EXTCON_DISP_DP,
+                                   EXTCON_PROP_USB_SS, property);
                extcon_set_state(chip->extcon, EXTCON_USB, ufp);
                extcon_set_state(chip->extcon, EXTCON_USB_HOST, dfp);
                extcon_set_state(chip->extcon, EXTCON_DISP_DP, dp);
@@ -2279,6 +2291,33 @@ static int fusb30x_probe(struct i2c_client *client,
                return ret;
        }
 
+       ret = extcon_set_property_capability(chip->extcon, EXTCON_USB,
+                                            EXTCON_PROP_USB_SS);
+       if (ret) {
+               dev_err(&client->dev,
+                       "failed to set USB USB_SS property capability: %d\n",
+                       ret);
+               return ret;
+       }
+
+       ret = extcon_set_property_capability(chip->extcon, EXTCON_USB_HOST,
+                                            EXTCON_PROP_USB_SS);
+       if (ret) {
+               dev_err(&client->dev,
+                       "failed to set USB_HOST USB_SS property capability: %d\n",
+                       ret);
+               return ret;
+       }
+
+       ret = extcon_set_property_capability(chip->extcon, EXTCON_DISP_DP,
+                                            EXTCON_PROP_USB_SS);
+       if (ret) {
+               dev_err(&client->dev,
+                       "failed to set DISP_DP USB_SS property capability: %d\n",
+                       ret);
+               return ret;
+       }
+
        i2c_set_clientdata(client, chip);
 
        spin_lock_init(&chip->irq_lock);