Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp3928903pxu; Tue, 20 Oct 2020 04:24:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwf6O2rXlRx0X9Q8Gf7EExjO00Z8FijJcKzYk8ald+E3E0sLG4t5Mkc3MMHS/AqhsIwD6C2 X-Received: by 2002:a17:906:cc4d:: with SMTP id mm13mr2648929ejb.330.1603193053986; Tue, 20 Oct 2020 04:24:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603193053; cv=none; d=google.com; s=arc-20160816; b=vdJ3+oqbKB3BamPMIG3mWQzuWkqAE/EY0I/I5jzm1Lfpx35dj748KlQOc3kASwcj6Q zwDALpcjEoGdt/t2i/Kbf0TrOfVh0gdA82244WVUMMe9/utfWcOeO2VccTXafxNm7J5D lvg/j8rRNYrl7fowJQHFlcT885oRz/BH78dT+3L3i7QzXgPyyTdbdbjoG7lMIOqM/+IX Ss7MmkY14zj+yLaOZNV7ETORxCN7aZZTio66yEBIDoO2/fBI+ngCN32+S9WqKi7hXs/5 +M0KXrkg6iRJ1LvMdFQrUdEUykyQO4y/jvpAdGBpMk3LEhizrcKpYIM2p/M3IypxrCuY 6bdA== 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=JHtRR3qQUbK6QyoBC6NKYxLDcobd0wicECGYDz6ynPE=; b=C/V84lS6AWkI+jJvCVkPYItiLMTd+HMjDFK5FAB6IOytOpSLE9GazGyHaZDWyvesp1 Hdmn/4VIUtGaYXrVn6BWXvZS/8zLnyvToFEUf2b6O3271hmVMolD7gEwsErH4Aa27/z2 bbNm7b/n9kmQOTlfZpEEdMoJD3L9UxNo78IjjKpI9kwJ6ppSXMHdVUSfURG4IyfEWCse 6OxJKA/HNt38w2rJLHQbU+93lorE/BbcKg3ES9V7kAXgJErh1HkzcAiOxKPSkZPfKjl4 uX6QOxdlgxgEDmWTH9E2G9qymrrNEMPo8Fv5N28wi1nS6pFqygVjKPTbccLeiDMsRsVK vHhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=rq9AdQaN; 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 dk1si952676ejb.556.2020.10.20.04.23.51; Tue, 20 Oct 2020 04:24:13 -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=rq9AdQaN; 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 S2405728AbgJTJgr (ORCPT + 99 others); Tue, 20 Oct 2020 05:36:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2392937AbgJTJgp (ORCPT ); Tue, 20 Oct 2020 05:36:45 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01A2BC0613D4 for ; Tue, 20 Oct 2020 02:36:45 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id b25so1516709ybj.2 for ; Tue, 20 Oct 2020 02:36:44 -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=JHtRR3qQUbK6QyoBC6NKYxLDcobd0wicECGYDz6ynPE=; b=rq9AdQaNwruAzMfHKSzMpPVC7WcstN4tx30jbBH58psfSyNYWtO/EuZMXe+hRBMPC4 Lo54FHzG4y0b32HA22tzPkNbFGAM29q3+GvtPh/zJmkT8veDAEMwmX9QNY8vJUOlsaAb kQuZTMQTF73RYGiQDgbaAJF82IB1I4KTywf5Hl4d3HhSeWuBgvs+8XHzpJIoA0lWgbX0 SHPI1XWvOD6EzszVqUSNifCB1P0AGhQLiTtLXAJnTlgDUaBuR/OwK+WV24+GQL2EAowm VLkxtJCua1AB2k70DWIRlFB41d0tjNUarnJHH1/TLfuJDHiWMhnF3+CsaRmncFCJ+Hfh TZsA== 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=JHtRR3qQUbK6QyoBC6NKYxLDcobd0wicECGYDz6ynPE=; b=HM4Mc1tP2SQvRrmteTpmNc5ilDxR73rP2UNDhwLWfOMuwuCb37joP2aUhGJDw4nRH2 cUJDLTmZWX5FJ2LgB3u18gBpPFWWSejO2kXPX8mSsETASAFhQasx7gnJj/f6WP3nWLQ2 GY3LSEyY5CPzyAmKpkx4RZq+c0kTfdx7iWjRhebFTf8Q3lfhiHo3GVNSdZx7syv+axHK HkjfmhCDLECvrcvgBaz6ZncL87118gczCnrcuU0nWbuE3MIjmdkIfPRGIBFGk5MsWLGo uITIhz77Vgo53nkRVJi36glL72CoiQb2u7BrQVJZENHCdNxWzeJn2vSQ6ZqcOwRVgZUI txwg== X-Gm-Message-State: AOAM532BkCMNVS3SI2UuqRiEUMYVQIo6JMTkzVZSnHiQA1iFi4HIQ0qA 7LwuKjG2xCxJTKY6n0GKz3KgKX1ictE= 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:a25:558b:: with SMTP id j133mr2906472ybb.224.1603186604161; Tue, 20 Oct 2020 02:36:44 -0700 (PDT) Date: Tue, 20 Oct 2020 02:36:23 -0700 In-Reply-To: <20201020093627.256885-1-badhri@google.com> Message-Id: <20201020093627.256885-7-badhri@google.com> Mime-Version: 1.0 References: <20201020093627.256885-1-badhri@google.com> X-Mailer: git-send-email 2.29.0.rc1.297.gfa9743e501-goog Subject: [PATCH v11 06/10] usb: typec: tcpci: frs sourcing vbus callback 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 Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org During FRS hardware autonomously starts to source vbus. Provide callback to perform chip specific operations. Signed-off-by: Badhri Jagan Sridharan Reviewed-by: Heikki Krogerus --- v9 is the first version of this patch in the series. Added to fix occasional bug of vbus turning back on when disconnecting the FRS accessory after disconnect. No changes since v9. Changes since v10: Added Reviewed-by: Heikki Krogerus --- drivers/usb/typec/tcpm/tcpci.c | 9 +++++++++ drivers/usb/typec/tcpm/tcpci.h | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/drivers/usb/typec/tcpm/tcpci.c b/drivers/usb/typec/tcpm/tcpci.c index f9f0af64da5f..f91688e43991 100644 --- a/drivers/usb/typec/tcpm/tcpci.c +++ b/drivers/usb/typec/tcpm/tcpci.c @@ -284,6 +284,14 @@ static int tcpci_enable_frs(struct tcpc_dev *dev, bool enable) return ret; } +static void tcpci_frs_sourcing_vbus(struct tcpc_dev *dev) +{ + struct tcpci *tcpci = tcpc_to_tcpci(dev); + + if (tcpci->data->frs_sourcing_vbus) + tcpci->data->frs_sourcing_vbus(tcpci, tcpci->data); +} + static int tcpci_set_bist_data(struct tcpc_dev *tcpc, bool enable) { struct tcpci *tcpci = tcpc_to_tcpci(tcpc); @@ -628,6 +636,7 @@ struct tcpci *tcpci_register_port(struct device *dev, struct tcpci_data *data) tcpci->tcpc.pd_transmit = tcpci_pd_transmit; tcpci->tcpc.set_bist_data = tcpci_set_bist_data; tcpci->tcpc.enable_frs = tcpci_enable_frs; + tcpci->tcpc.frs_sourcing_vbus = tcpci_frs_sourcing_vbus; err = tcpci_parse_config(tcpci); if (err < 0) diff --git a/drivers/usb/typec/tcpm/tcpci.h b/drivers/usb/typec/tcpm/tcpci.h index 5ef07a56d67a..b418fe11b527 100644 --- a/drivers/usb/typec/tcpm/tcpci.h +++ b/drivers/usb/typec/tcpm/tcpci.h @@ -143,6 +143,9 @@ /* * @TX_BUF_BYTE_x_hidden * optional; Set when TX_BUF_BYTE_x can only be accessed through I2C_WRITE_BYTE_COUNT. + * @frs_sourcing_vbus: + * Optional; Callback to perform chip specific operations when FRS + * is sourcing vbus. */ struct tcpci; struct tcpci_data { @@ -154,6 +157,7 @@ struct tcpci_data { int (*start_drp_toggling)(struct tcpci *tcpci, struct tcpci_data *data, enum typec_cc_status cc); int (*set_vbus)(struct tcpci *tcpci, struct tcpci_data *data, bool source, bool sink); + void (*frs_sourcing_vbus)(struct tcpci *tcpci, struct tcpci_data *data); }; struct tcpci *tcpci_register_port(struct device *dev, struct tcpci_data *data); -- 2.29.0.rc1.297.gfa9743e501-goog