Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753431AbdHPDaw (ORCPT ); Tue, 15 Aug 2017 23:30:52 -0400 Received: from bh-25.webhostbox.net ([208.91.199.152]:46198 "EHLO bh-25.webhostbox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752174AbdHPDav (ORCPT ); Tue, 15 Aug 2017 23:30:51 -0400 Subject: Re: [PATCH 2/2] staging: typec: tcpm: explicit_contract is always established To: Badhri Jagan Sridharan , Greg Kroah-Hartman Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org References: <20170815232339.26701-1-Badhri@google.com> From: Guenter Roeck Message-ID: <6ce9f766-3dcf-a489-2418-fb7ebe11b54a@roeck-us.net> Date: Tue, 15 Aug 2017 20:30:49 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20170815232339.26701-1-Badhri@google.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Authenticated_sender: linux@roeck-us.net X-OutGoing-Spam-Status: No, score=-1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - bh-25.webhostbox.net X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - roeck-us.net X-Get-Message-Sender-Via: bh-25.webhostbox.net: authenticated_id: linux@roeck-us.net X-Authenticated-Sender: bh-25.webhostbox.net: linux@roeck-us.net X-Source: X-Source-Args: X-Source-Dir: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2134 Lines: 58 On 08/15/2017 04:23 PM, Badhri Jagan Sridharan wrote: > While in SNK_READY state, the explicit_contract seems to be > set to true irrespective of whether an explicit contract > was established for the current connection. TCPM also seems > to report the pwr_opmode as TYPEC_PWR_MODE_PD always once > the port gets into SNK_READY state. This isn't completely > true as port gets into the SNK_READY state for non-pd > type-c ports as well. > > This patch sets the explicit_contract flag only when > the PS_READY message is received and the vbus has been > detected by the port controller. > > Signed-off-by: Badhri Jagan Sridharan Reviewed-by: Guenter Roeck > --- > drivers/staging/typec/tcpm.c | 11 +++++++---- > 1 file changed, 7 insertions(+), 4 deletions(-) > > diff --git a/drivers/staging/typec/tcpm.c b/drivers/staging/typec/tcpm.c > index a24e6bbb909c..3e12cf101311 100644 > --- a/drivers/staging/typec/tcpm.c > +++ b/drivers/staging/typec/tcpm.c > @@ -1367,6 +1367,7 @@ static void tcpm_pd_ctrl_request(struct tcpm_port *port, > tcpm_set_current_limit(port, > port->current_limit, > port->supply_voltage); > + port->explicit_contract = true; > tcpm_set_state(port, SNK_READY, 0); > } else { > /* > @@ -2458,10 +2459,11 @@ static void run_state_machine(struct tcpm_port *port) > break; > case SNK_READY: > port->try_snk_count = 0; > - port->explicit_contract = true; > - typec_set_pwr_opmode(port->typec_port, TYPEC_PWR_MODE_PD); > - port->pwr_opmode = TYPEC_PWR_MODE_PD; > - > + if (port->explicit_contract) { > + typec_set_pwr_opmode(port->typec_port, > + TYPEC_PWR_MODE_PD); > + port->pwr_opmode = TYPEC_PWR_MODE_PD; > + } > tcpm_typec_connect(port); > > tcpm_check_send_discover(port); > @@ -2951,6 +2953,7 @@ static void _tcpm_pd_vbus_on(struct tcpm_port *port) > port->vbus_present = true; > switch (port->state) { > case SNK_TRANSITION_SINK_VBUS: > + port->explicit_contract = true; > tcpm_set_state(port, SNK_READY, 0); > break; > case SNK_DISCOVERY: >