Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753882AbdHQTMN (ORCPT ); Thu, 17 Aug 2017 15:12:13 -0400 Received: from mail-pg0-f42.google.com ([74.125.83.42]:37232 "EHLO mail-pg0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753747AbdHQTMI (ORCPT ); Thu, 17 Aug 2017 15:12:08 -0400 From: Badhri Jagan Sridharan X-Google-Original-From: Badhri Jagan Sridharan To: Guenter Roeck , Greg Kroah-Hartman Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, Badhri Jagan Sridharan Subject: [PATCH] staging: typec: tcpm: explicit_contract is always established Date: Thu, 17 Aug 2017 12:11:21 -0700 Message-Id: <20170817191121.32087-1-Badhri@google.com> X-Mailer: git-send-email 2.14.1.480.gb18f417b89-goog Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1926 Lines: 54 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 --- drivers/staging/typec/tcpm.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/staging/typec/tcpm.c b/drivers/staging/typec/tcpm.c index 903261e80bd4..7b5ba27dd935 100644 --- a/drivers/staging/typec/tcpm.c +++ b/drivers/staging/typec/tcpm.c @@ -1373,6 +1373,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 { /* @@ -2467,9 +2468,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_swap_complete(port, 0); tcpm_typec_connect(port); @@ -2958,6 +2961,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: -- 2.14.1.480.gb18f417b89-goog