MLK-16820-2 staging: typec: tcpci: add sink_disable flag for source only power
authorLi Jun <jun.li@nxp.com>
Thu, 23 Nov 2017 13:44:36 +0000 (21:44 +0800)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 20:55:46 +0000 (15:55 -0500)
As we need to use DRP config for data role, but the power role is source only,
so introduce a property sink-disable to avoid sink vbus command.

Signed-off-by: Li Jun <jun.li@nxp.com>
Acked-by: Peter Chen <peter.chen@nxp.com>
drivers/staging/typec/tcpci.c

index 6cca961..589beeb 100644 (file)
@@ -41,6 +41,7 @@ struct tcpci {
 
        bool controls_vbus;
        bool drive_vbus;
+       bool sink_disable;
        struct gpio_desc *ss_sel_gpio;
 
        struct tcpc_dev tcpc;
@@ -408,7 +409,7 @@ static int tcpci_set_vbus(struct tcpc_dev *tcpc, bool source, bool sink)
                tcpci->drive_vbus = true;
        }
 
-       if (sink) {
+       if (sink && !tcpci->sink_disable) {
                ret = regmap_write(tcpci->regmap, TCPC_COMMAND,
                                   TCPC_CMD_SINK_VBUS);
                if (ret < 0)
@@ -704,6 +705,13 @@ static int tcpci_parse_config(struct tcpci *tcpci)
                                                &tcfg->operating_snk_mw))
                goto snk_setting_wrong;
 
+       /*
+        * In case DRP only for data role, power role is source only
+        * we can use this property to disable power sink.
+        */
+       if (device_property_read_bool(tcpci->dev, "sink-disable"))
+               tcpci->sink_disable = true;
+
        return 0;
 
 snk_setting_wrong: