Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp111242imm; Wed, 12 Sep 2018 19:12:24 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaQH+p+nfOg9sdCpX8M1fpd1NrONMba9JC4NhQ/CPO6ZIXexyftGaFdSoYnMB+Z4tv+oOYJ X-Received: by 2002:a65:62d8:: with SMTP id m24-v6mr4875468pgv.307.1536804744236; Wed, 12 Sep 2018 19:12:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536804744; cv=none; d=google.com; s=arc-20160816; b=GpDb96ywm+Dz7BXewaVVPFF4pMuN+0ddIiuRNIdafJiw4GX7B3OP10ki/1cBy4taPy BYt7B+AenCWpqqVp2z6qAqNyHVJjOFOCJZ5eZQNMbF8qU6IaBR4tBxfqRLhUht10bhQJ ktJY5M4k6Ao8fKoQ893BhncppveJXAQJ07SD5fhjLGv7ci7AQonDWlGd/NarnhYRYUW5 4/AM7kNqFs9UfJIdtf/9ZO6xYVRXJiIr8DMqUBDyaxIqMUl5Bsmb1V15mtfx8nAOSaV2 rCZOYHNal59Sf20NDuzB1sbX/UDeSDFBfEJQpoRVBgkBjDM7q7XVBrxjRiOg6K9liWtS uudw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=Y+lqFgjfBWDSIKd36fnHL64GSJToWjw4TcaXPRFwfII=; b=vYuJbsvBZtqEyHnEuj10mVLxMAtCvedBPgBPAN6p1Pq7VipNs+8F2TNpTWMgUAK00W uJqw2WPQil0RHz49WtEEOPfc6ca6MWMnY6oeyf2+VGW8sFE91nd2rJIeE/ZaSC3txaqD PT/tKuDBRB0BvNp1ZsNabXgFzAimtagKpBRVvgXyEzVYx+5a2SYAA7PdPUBY9mZxvoja T9lOIiQGFuxzpsrf+USUrmu3tX0GSPwCQ6K3OnKvAOydXzweJ7BqMAB7adnGtIz03byq OkaiTYtkE03ySma9S2RZ4YO7AEUQzxb44WmAbAH5d6ewGYy7GkXl5bI5H4UH3/m2VloA BSkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="Jh7s/VHB"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s195-v6si2921840pgs.492.2018.09.12.19.12.09; Wed, 12 Sep 2018 19:12:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="Jh7s/VHB"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726970AbeIMHSl (ORCPT + 99 others); Thu, 13 Sep 2018 03:18:41 -0400 Received: from mail-pl1-f202.google.com ([209.85.214.202]:36600 "EHLO mail-pl1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726838AbeIMHSl (ORCPT ); Thu, 13 Sep 2018 03:18:41 -0400 Received: by mail-pl1-f202.google.com with SMTP id w18-v6so1910927plp.3 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=O8Ch7+8HRYJaNmE34fjYOJ0n9DSYMQu2tbkmVLZPZE8a9zbAYiU62APNS+bNJ8Gnco wI/uaPNWTM+jWhtUhx192MsTmVUvAe/9SJscIW1/TXxNB905z63BDzMbG19b5ZQHB9N+ Mnnjf5deR7KxhMxqFgv9sSkv/IvXhhAczeI4pwpph9qYFF/GDTb7jjd9MSBURNV3M4Cl TWvOdD0b879xlHMGw3v6Hubwmm324OBMXejF/1hLCYDPOUkOKouhY/r4OHYUCRRTAusX Osk8dAoi/EuU511rVHDU2yRj0oIVppRDdPOKGL5VigeAv3rotzSQmRS6XzZ5RtT1mFLS Z7lQ== X-Gm-Message-State: APzg51BWpK1NJLRyOlp9WKUl/Y573943L5ygIELIdI0Mq5g7OrcCWzZo YDUJmxcqoUDFb3qQX27xbfVNoD/RdMo= 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; }; -- 2.19.0.397.gdd90340f6a-goog