From patchwork Thu Sep 13 02:11:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Badhri Jagan Sridharan X-Patchwork-Id: 10598637 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C7C5014DB for ; Thu, 13 Sep 2018 02:11:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B761E2ADDA for ; Thu, 13 Sep 2018 02:11:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AAE372ADDC; Thu, 13 Sep 2018 02:11:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 55E3A2ADDA for ; Thu, 13 Sep 2018 02:11:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727010AbeIMHSm (ORCPT ); Thu, 13 Sep 2018 03:18:42 -0400 Received: from mail-pf1-f202.google.com ([209.85.210.202]:36940 "EHLO mail-pf1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726399AbeIMHSl (ORCPT ); Thu, 13 Sep 2018 03:18:41 -0400 Received: by mail-pf1-f202.google.com with SMTP id v9-v6so2031474pff.4 for ; Wed, 12 Sep 2018 19:11:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=Y+lqFgjfBWDSIKd36fnHL64GSJToWjw4TcaXPRFwfII=; b=Jh7s/VHB/3fScArZlz4IAzg0G2CTcknzXe0bNweFwHE3u06Me2j0C/Z6/v/8Zb0ccT 4E0o7lCs7m4oJ0VI/sbKb4LHNCcU25yNLLUNcEzdDb+DNbMvXnrclsMxqfzf4G3JgfMH 3Ipme7mCAjYW/Fvbv58FzOvPpa3A+oLP5q0ZAzc9J/4HfwGD8Sc/62gctt6WOrGojlRr 3cr6k0e7WjSgBWwNlAlvFw7sw3FsiUB1+ghlw74w7PieCtdiBY2sdWc6F6SGKDjvZRo6 PcxQ0xMBchOuIoGNNHlpdzrXEapKGaC/lWUc2ECuF/Mlqbu/1uAPLlszR8NCX2CNgxK7 y6Yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=Y+lqFgjfBWDSIKd36fnHL64GSJToWjw4TcaXPRFwfII=; b=BfBLG/GshdtSBMzAHV70Bw4ovLUgd+LOKgdYgB8zpoyMNOeB6W/xCnuK4waWtySaty JpyikpXX4aoZ5sQFFn7A/NnN0yf0Q+VtoeZw4b2KfSVCPcPUmDzkDarLS5YMbMTZnDQ6 hzhI7D5kY8WpnZ9DY94koNbgT6hVBVhqoAf2NAHS64yBt+mkcQufCEuubjphD7bmjRO4 1inaJXLNkIELdXyNj1vB9ogdM/nOBh7Jj8gIPmMjLW8DY0zRi6DoAQOG3jFGro4pEkTk tZ6sgWRpwOjAW8aX9vGJkjXxrzckezxsj0BRLi2VYPsgU+yFArgqRL3SQZ022UsihM0u PnUA== X-Gm-Message-State: APzg51AZ8NXsWhXRdufFnDjwFeEGwcSMmHiOTHqd5Jh7noE3HclUN6Ts F5duletXz9ZRFQbTUr8cLipxnB0fIDQ= X-Google-Smtp-Source: ANB0VdZAF3tAU/tOZbSxcJbJ+CG6vp5WeQRCip29nnoD/TGkhanxrjCQ0Rky0A7MyCNLchDTW/Ko8coK/ys= X-Received: by 2002:a63:445e:: with SMTP id t30-v6mr307974pgk.102.1536804685008; Wed, 12 Sep 2018 19:11:25 -0700 (PDT) Date: Wed, 12 Sep 2018 19:11:13 -0700 In-Reply-To: <20180913021113.18150-1-badhri@google.com> Message-Id: <20180913021113.18150-2-badhri@google.com> Mime-Version: 1.0 References: <20180913021113.18150-1-badhri@google.com> X-Mailer: git-send-email 2.19.0.397.gdd90340f6a-goog Subject: [PATCH 2/2] typec: tcpm: Add option to maintain current limit at Vsafe5V From: Badhri Jagan Sridharan To: Heikki Krogerus , Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Badhri Jagan Sridharan , Badhri Jagan Sridharan Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP During hard reset, TCPM turns off the charging path. The spec provides an option for Sink to either drop to vSafe5V or vSafe0V. From USB_PD_R3_0 2.6.2 Sink Operation .. Serious errors are handled by Hard Reset Signaling issued by either Port Partner. A Hard Reset: resets protocol as for a Soft Reset but also returns the power supply to USB Default Operation (vSafe0V or vSafe5V output) in order to protect the Sink. Add a config option to tcpc_dev and let the device specific driver decide what needs to be done. Signed-off-by: Badhri Jagan Sridharan --- drivers/usb/typec/tcpm.c | 7 ++++++- include/linux/usb/tcpm.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c index a4e0c027a2a9..350d1a7c4543 100644 --- a/drivers/usb/typec/tcpm.c +++ b/drivers/usb/typec/tcpm.c @@ -3269,7 +3269,12 @@ static void run_state_machine(struct tcpm_port *port) case SNK_HARD_RESET_SINK_OFF: memset(&port->pps_data, 0, sizeof(port->pps_data)); tcpm_set_vconn(port, false); - tcpm_set_charge(port, false); + if (port->tcpc->config->vsafe_5v_hard_reset) + tcpm_set_current_limit(port, + tcpm_get_current_limit(port), + 5000); + else + tcpm_set_charge(port, false); if (port->tcpc->config->self_powered) tcpm_set_roles(port, true, TYPEC_SINK, TYPEC_DEVICE); diff --git a/include/linux/usb/tcpm.h b/include/linux/usb/tcpm.h index 50c74a77db55..c6e3ccecba70 100644 --- a/include/linux/usb/tcpm.h +++ b/include/linux/usb/tcpm.h @@ -90,6 +90,7 @@ struct tcpc_config { enum typec_role default_role; bool try_role_hw; /* try.{src,snk} implemented in hardware */ bool self_powered; /* port belongs to a self powered device */ + bool vsafe_5v_hard_reset; /* Maintain VSAFE5V during hard reset */ const struct typec_altmode_desc *alt_modes; };