Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp4780202rwe; Tue, 30 Aug 2022 17:21:04 -0700 (PDT) X-Google-Smtp-Source: AA6agR4sw/JHm+bYOWilGI3WOmhoUSjkH/vFPHSTzuVLXTuJAcODB5yM2ELDYEZ9fkZwokQc/tPY X-Received: by 2002:a17:902:7481:b0:173:cfae:a7f0 with SMTP id h1-20020a170902748100b00173cfaea7f0mr23067183pll.27.1661905263986; Tue, 30 Aug 2022 17:21:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661905263; cv=none; d=google.com; s=arc-20160816; b=rtQblExrbhZ/DQoFROvHh9PYD7e17Xo5ooqnk6vHeMHOUNWt4sYg6LhJZBAzVElqJT 87btFbvec0LjBKujG0yJRFPS5+KDfhKKKBpS1GiSYq+U/MJ0pJadu+5REYFl48/i0EPI xy0ELyynY3WGgPinOrOyxnaSb8T12HxYl1miNYMgR1nScyoj0/AO5+o3iP10ZETAk0E1 fC1slHj8ghAralgW20fanPHM6RsRn92eaW4e5h/ee1zW8UzysDQuyIKMhdHeR5BgXtET lskrC8BAHwzcFE0TXJAQFPeddwZSNS9/0wnnZKninRS5hwOVD7neQ7puqrgHmf2fQ7h+ 51dQ== 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:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=RLmxwVwtne7Ris2nr8dSsVg7os+UaP8tQY3U04GCx/Q=; b=jvcb0ZfbOWlKrwGviBM3yqzNfjEJ4rkTCA3kWCIOMunmH2EWpqZtmeAgGKnN/B8Kkn ImBZqO3KQNZpJZx2hjR6LMyC5GhBpKTPNPEl3JiTIgAjl6Mn6/TMCO4S+mKGpFlVoH0s pqUyKEMtQ0L4YjMFH1Zt+TQQPTIBLoEKRcndgYvYE+vhJc+hstPSx31NX6vioTUGReyL HupuFQKWO4aGsp9VMrGegQWwiyeoy2PoH51JbB0RdazXSReU0e/M5WeXAMxH8dmw9zGb dE2HNIn9bo7fDBptUMfpN+mhqVYwOvdGfJ5tMesKhsrh9hIzoGDUinJd4KYcHq0tYgR7 Q7Rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=NJoxFv51; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s34-20020a17090a69a500b001fb7350cd1dsi372264pjj.14.2022.08.30.17.20.53; Tue, 30 Aug 2022 17:21:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=NJoxFv51; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S231236AbiHaAQS (ORCPT + 99 others); Tue, 30 Aug 2022 20:16:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229740AbiHaAQK (ORCPT ); Tue, 30 Aug 2022 20:16:10 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1CF7E956A3 for ; Tue, 30 Aug 2022 17:16:09 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-3328a211611so189888727b3.5 for ; Tue, 30 Aug 2022 17:16:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc; bh=RLmxwVwtne7Ris2nr8dSsVg7os+UaP8tQY3U04GCx/Q=; b=NJoxFv51S9HcIE88Xfk0z9ARm+YW3lBgF/itE8xbqEcD4h+I/HI9qHdqiHvI8nszbL OO7wA8VQA5+reAeskw4TV+lpn2/nwsnTESgC8Qsa4DkIBvp5yqMYi/8cSJ1xLagHg7VI 7wxwZ0qodBJ4LMh8htf4g0tHvoRYC7r1VZ9zYWgqHchA6qID2L49q1+pfK9REWZ+NViu el22XRXpiRfohPKeQnr5bBUoFZ7g6pr5q4dV56BF1TRVit3s6Ic42vYLec4NvXtErfo4 7PmEDEhK1I8HEaYvpClp2CleXCHZX1K17Ri12db+VrcWo3FNX435UiXW/J2gr3mzkDax FiTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc; bh=RLmxwVwtne7Ris2nr8dSsVg7os+UaP8tQY3U04GCx/Q=; b=fD1QNpzAJuLXYgVCqfmUz8pOTLdpnNKHkSb7xnwDgB1GFRhZcrH4yuGHQwh+fEEElR aB7czsGpI2L9YJY2lWAw8FH8EcpuEF2ZYIUAdKrwgIrtvSH9w7r+GJPVpiudboHPNnT+ /hugfhGzT/FhixGkAIjAstQPqz1G98FaaQ3CJNtAgQhN6ZgQPT//I0imZt9k+Ed7vBAX zZYIcPVpML7Hn5TbvqJTJjiowIKn5Suf8OcB7Uls0NCQWcrDLAwjfz3r8UNIGJFjivbu ao/a3b8jIQym1wQTBjdgugfU+9MJP6Feh5SjIAxzqWkIsMqPOyQ0mtZLLigrIEmI9mQj J0Ug== X-Gm-Message-State: ACgBeo2afNfJjuXOlIPQB6zC5f8SvE6cHNkUIYHkjN4ajksAgOWF3tv1 nGeJuLBgeiKKLBMa69FplasJHAqJ9lU= X-Received: from badhri.mtv.corp.google.com ([2620:15c:211:201:377b:cea5:463f:f0c9]) (user=badhri job=sendgmr) by 2002:a81:6703:0:b0:340:a52f:67a1 with SMTP id b3-20020a816703000000b00340a52f67a1mr16926357ywc.31.1661904968432; Tue, 30 Aug 2022 17:16:08 -0700 (PDT) Date: Tue, 30 Aug 2022 17:15:54 -0700 In-Reply-To: <20220831001555.285081-1-badhri@google.com> Mime-Version: 1.0 References: <20220831001555.285081-1-badhri@google.com> X-Mailer: git-send-email 2.37.2.672.g94769d06f0-goog Message-ID: <20220831001555.285081-2-badhri@google.com> Subject: [PATCH v2 2/3] usb: typec: tcpci: Add callback for evaluating contaminant presence From: Badhri Jagan Sridharan To: Guenter Roeck , Heikki Krogerus , Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Kyle Tso , Badhri Jagan Sridharan Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This change adds callback to evaluate presence of contaminant in the TCPCI layer. Signed-off-by: Badhri Jagan Sridharan --- drivers/usb/typec/tcpm/tcpci.c | 9 +++++++++ include/linux/usb/tcpci.h | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/drivers/usb/typec/tcpm/tcpci.c b/drivers/usb/typec/tcpm/tcpci.c index 50674ecf430d..53f6fad61781 100644 --- a/drivers/usb/typec/tcpm/tcpci.c +++ b/drivers/usb/typec/tcpm/tcpci.c @@ -403,6 +403,14 @@ static void tcpci_frs_sourcing_vbus(struct tcpc_dev *dev) tcpci->data->frs_sourcing_vbus(tcpci, tcpci->data); } +static void tcpci_check_contaminant(struct tcpc_dev *dev, bool disconnect_while_debouncing) +{ + struct tcpci *tcpci = tcpc_to_tcpci(dev); + + if (tcpci->data->check_contaminant) + tcpci->data->check_contaminant(tcpci, tcpci->data, disconnect_while_debouncing); +} + static int tcpci_set_bist_data(struct tcpc_dev *tcpc, bool enable) { struct tcpci *tcpci = tcpc_to_tcpci(tcpc); @@ -777,6 +785,7 @@ struct tcpci *tcpci_register_port(struct device *dev, struct tcpci_data *data) tcpci->tcpc.enable_frs = tcpci_enable_frs; tcpci->tcpc.frs_sourcing_vbus = tcpci_frs_sourcing_vbus; tcpci->tcpc.set_partner_usb_comm_capable = tcpci_set_partner_usb_comm_capable; + tcpci->tcpc.check_contaminant = tcpci_check_contaminant; if (tcpci->data->auto_discharge_disconnect) { tcpci->tcpc.enable_auto_vbus_discharge = tcpci_enable_auto_vbus_discharge; diff --git a/include/linux/usb/tcpci.h b/include/linux/usb/tcpci.h index 17657451c762..250b34ccbf9c 100644 --- a/include/linux/usb/tcpci.h +++ b/include/linux/usb/tcpci.h @@ -188,6 +188,11 @@ struct tcpci; * Optional; The USB Communications Capable bit indicates if port * partner is capable of communication over the USB data lines * (e.g. D+/- or SS Tx/Rx). Called to notify the status of the bit. + * @check_contaminant: + * Optional;The callback is called when CC pins report open status + * at the end of the deboumce period or when the port is still + * toggling. Chip level drivers are expected to check for contaminant + * and call tcpm_clean_port when the port is clean. */ struct tcpci_data { struct regmap *regmap; @@ -204,6 +209,8 @@ struct tcpci_data { void (*frs_sourcing_vbus)(struct tcpci *tcpci, struct tcpci_data *data); void (*set_partner_usb_comm_capable)(struct tcpci *tcpci, struct tcpci_data *data, bool capable); + void (*check_contaminant)(struct tcpci *tcpci, struct tcpci_data *data, + bool disconnect_while_debouncing); }; struct tcpci *tcpci_register_port(struct device *dev, struct tcpci_data *data); -- 2.37.2.672.g94769d06f0-goog