Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp1039838pxu; Thu, 8 Oct 2020 01:25:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzljPBuk7kXbYhHn49Lcs8bUM4yTadhjoqW72/r3v88E6XFoX4j6hX89wn7VLoz9Tu88Wc3 X-Received: by 2002:aa7:d1cc:: with SMTP id g12mr7836046edp.195.1602145523592; Thu, 08 Oct 2020 01:25:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602145523; cv=none; d=google.com; s=arc-20160816; b=rhyYBOaNM/ArhEKa890xYwknZFRhMaALFO27Vywy9v0mtVyI/DsGiiMrJK3n06/PSL 8WQzqkDL+RX3FnIMjlypYZP89LCcrLJIVvKzEn3h6/ufcOJSkhAI25SGmt9k77TW8OYh DRhe37qADqnaQxCwJi0QCX8vu9HT5LWGvYbptmdnvoNE/5GLfT/CjiTxH+Lr2XeccnnL 5sXv1xbs3GqOfjm+/VRBlYGlcBsXMwM9RIPyNeRFB2ZOeD0/2I45kIIBFP8KuH/+iyk2 cK29if8423h7mlt/TvJX9REPKwpfCsN7VKMputnG7K6xAWd8+uT/iITPBRl0JNCnBRqp VBBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:sender:dkim-signature; bh=U+7VAuX+6NzBlNSRK3/qbo0mKYXrvm3847FJpD+uNy8=; b=P5XFB7xHaM13H6ijw6lJ+G6cT5wHfhCJBLE8eCTYuTpc6HCuT328ghs5spQEleggvg 07oBvOjHjEEz6RxmOTtGcm7Ia4dAlZ/GokEWSpvPhhOVhHXnOIvPGl6jPTXeGbw+X3xo qE5aMYrMlugvL5bJiEPx/UME65N8vIzmRP4yNMgdJ6iYrh7I6R1HNA0VLcA2ZDhdOTIl 6B5Io3x8kc62jT7wp4G+/OTXcdE+ERWSd62I1TmOFYj81NaGmBNCdiwz6RVl2wRGyK8E Y+0GtJZxfeAK6weCJ9Dt3gQqOlMLsJfSRp8VWRzlH0DSYF8YhlsXqVNUArUDbpmtUA1X Y9ZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=dQCwYaSw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id f25si3827448ejh.440.2020.10.08.01.24.55; Thu, 08 Oct 2020 01:25:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=dQCwYaSw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1728919AbgJHGQ7 (ORCPT + 99 others); Thu, 8 Oct 2020 02:16:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728412AbgJHGQj (ORCPT ); Thu, 8 Oct 2020 02:16:39 -0400 Received: from mail-pl1-x64a.google.com (mail-pl1-x64a.google.com [IPv6:2607:f8b0:4864:20::64a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7827C0613D2 for ; Wed, 7 Oct 2020 23:16:25 -0700 (PDT) Received: by mail-pl1-x64a.google.com with SMTP id u16so2822169plq.18 for ; Wed, 07 Oct 2020 23:16:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=U+7VAuX+6NzBlNSRK3/qbo0mKYXrvm3847FJpD+uNy8=; b=dQCwYaSwe7s2rwAuCm8wl5BjFAMR41J9778DmKbkwQ2duUvQ+nZFy7s7uVfmewQT7c M3ypo/V4MyLSbrbsN3rgnwDY91G4T/gnVf7uG5kJ1y2uGl1NP+1Dm599LSGXA+EDDYfA 76n6csYDJGD6zAhuURrvnitoOtwAGJ1Lw43ahlxi7e/Nm5mtXaMT5Iv+aiomhltQIoaV PUJ/EaFdy5N6wrXqKPdcd2YrKTCEQRswzPNZDHvFm400bvJU2sARuf3bS4IJncsSYuh3 xaGdmpy1a6TerpnrAwGuwP2+0e642AKdZCcLn9ptxR6nenakUhlatfWMuvJ8UB8gwbP8 oFNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=U+7VAuX+6NzBlNSRK3/qbo0mKYXrvm3847FJpD+uNy8=; b=GisLpy9KavuekWRCDkiq1ZCJhIxvCtHKby3IcdYGfFw4NqHmPM0GRdGKP3jrsjc9A7 c00BmsrWR7vTVZrUd9CKRb9NQODD2glJPvcPZwRdLbyAWWfHmYVup6ah1am0mJU38OkO eExSWFq9SBvqQf5ZhDVhlqxDk6+KvsEFeiS48/5HOpGcXTHY1FJfruo0AE2C55c0hVaj he038vOekAg17IEHR/5gkN0o4Y1LFSktmKwctiDuCx/v6rbcr7fHqvFDCPXz5Ey/WLlQ i7+dUXMNKE+FIEptgH3Ns6UJOVuJcz5oAoN6gEtdkGjVyI+sHlLKF0bobjC208JErrnc cY5Q== X-Gm-Message-State: AOAM531bRGvFYUPzqoTEIyEAB/O8pV0KWxe4ZWX/iI8SHgGMDtHqrRtp 0STZFi1dEYYex9rwGo7BFuCVYiIeUt0= Sender: "badhri via sendgmr" X-Received: from badhri.mtv.corp.google.com ([2620:15c:211:1:f292:1cff:fee0:66cf]) (user=badhri job=sendgmr) by 2002:aa7:9592:0:b029:13e:d13d:a054 with SMTP id z18-20020aa795920000b029013ed13da054mr6175887pfj.26.1602137785394; Wed, 07 Oct 2020 23:16:25 -0700 (PDT) Date: Wed, 7 Oct 2020 23:15:52 -0700 In-Reply-To: <20201008061556.1402293-1-badhri@google.com> Message-Id: <20201008061556.1402293-12-badhri@google.com> Mime-Version: 1.0 References: <20201008061556.1402293-1-badhri@google.com> X-Mailer: git-send-email 2.28.0.806.g8561365e88-goog Subject: [PATCH v10 11/15] usb: typec: tcpci_max77759: Fix vbus stuck on upon diconnecting sink From: Badhri Jagan Sridharan To: Guenter Roeck , Heikki Krogerus , Greg Kroah-Hartman , Rob Herring , Lee Jones , Mark Brown , Maxime Ripard , Alexandre Belloni , Thierry Reding , Prashant Malani , Badhri Jagan Sridharan Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, Amelie Delaunay Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Occasionally, POWER_STATUS.sourcing_vbus takes a while to clear after writing to MAX_BUCK_BOOST_OP register. This causes vbus to turn back on while disconnecting the sink. Overcome this issue by writing into MAX_BUCK_BOOST_OP during frs while sourcing vbu, instead of always into the register whenever POWER_STATUS.sourcing_vbus is set. Signed-off-by: Badhri Jagan Sridharan --- v9 is the first version of this patch. Added to fix occasional bug of vbus turning back on when disconnecting the FRS accessory after disconnect. No changes since v9. --- drivers/usb/typec/tcpm/tcpci_maxim.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/usb/typec/tcpm/tcpci_maxim.c b/drivers/usb/typec/tcpm/tcpci_maxim.c index 723d7dd38f75..43dcad95e897 100644 --- a/drivers/usb/typec/tcpm/tcpci_maxim.c +++ b/drivers/usb/typec/tcpm/tcpci_maxim.c @@ -238,23 +238,22 @@ static void process_power_status(struct max_tcpci_chip *chip) if (ret < 0) return; - if (pwr_status == 0xff) { + if (pwr_status == 0xff) max_tcpci_init_regs(chip); - } else if (pwr_status & TCPC_POWER_STATUS_SOURCING_VBUS) { + else if (pwr_status & TCPC_POWER_STATUS_SOURCING_VBUS) tcpm_sourcing_vbus(chip->port); - /* - * Alawys re-enable boost here. - * In normal case, when say an headset is attached, TCPM would - * have instructed to TCPC to enable boost, so the call is a - * no-op. - * But for Fast Role Swap case, Boost turns on autonomously without - * AP intervention, but, needs AP to enable source mode explicitly - * for AP to regain control. - */ - max_tcpci_set_vbus(chip->tcpci, &chip->data, true, false); - } else { + else tcpm_vbus_change(chip->port); - } +} + +static void max_tcpci_frs_sourcing_vbus(struct tcpci *tcpci, struct tcpci_data *tdata) +{ + /* + * For Fast Role Swap case, Boost turns on autonomously without + * AP intervention, but, needs AP to enable source mode explicitly + * for AP to regain control. + */ + max_tcpci_set_vbus(tcpci, tdata, true, false); } static void process_tx(struct max_tcpci_chip *chip, u16 status) @@ -441,6 +440,7 @@ static int max_tcpci_probe(struct i2c_client *client, const struct i2c_device_id chip->data.start_drp_toggling = max_tcpci_start_toggling; chip->data.TX_BUF_BYTE_x_hidden = true; chip->data.init = tcpci_init; + chip->data.frs_sourcing_vbus = max_tcpci_frs_sourcing_vbus; max_tcpci_init_regs(chip); chip->tcpci = tcpci_register_port(chip->dev, &chip->data); -- 2.28.0.806.g8561365e88-goog