Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4230719pxb; Mon, 1 Feb 2021 16:34:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJzuyZyv39mBm0OwiL/wXWb7l0+pSOI5A2lMf8LxQcBB20pGIGVFQKADuVLdQkZ74C6DRWjN X-Received: by 2002:a17:906:b001:: with SMTP id v1mr19267559ejy.217.1612226071080; Mon, 01 Feb 2021 16:34:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612226071; cv=none; d=google.com; s=arc-20160816; b=zSiUbvhSNGVWAhtDz0LOVhA08PZO9BHE9Z8OwRJNossawrnQ0+SbPd33JJ2fr5kgW+ hlgRQQn7hxzjACZ5Nz34F5ko2Sr4HRu3td04GTz170YNsmDNdeMYhKL8+GnxQChCqkt7 QaMOreCmEG57GjHJ6zNA6Fuv4P1Zekr5oI57OqE9Hj+yLq7mzwHGcVnom4TjcIjv9p7l GE76T+PpFuy3SwdVVS/jSGMikkWklvgwBJE8eeBx2No+6KTPIQdExA2JIH82CYUeP3sf qTgEmj18XaRgaeQy1ZmbYWak81TTOPzr7C8gKJA08j0oBDiDvgEFl1kax7TO7oZHWpG0 Nvpg== 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=0uh+WToPVrT5nNi8VVC2Dny5IL46Dl8JAHJqCqtV+0E=; b=rg+9BV7YuD9cpIQe+mQixDk6utVqketDufZZAcSOJ05XvPpF1RMBEtRDEV3kL73XmK mupAp3c9W55Esk/EtWx7DTxh+yQTkLSZTkn22ZqrIASIgbifHuQN16CHsAfilqGc3wrQ 2yTO9LVtCBvAV2+moIIdHR6I+Qx8tIXTOB7xVBux+8h5fApyHk4Pu6EPLRqKdE7cRi4J QG2BgMuES4BbUKqSBLnVFnN20yG4qra1K5LtH0fMcRnGlZfq8YvW37+L8Ego5wGXuxXa z4LMsnVIbacdXxSK2AHDe6RAaNRktf7prewsm0PpczxfY6AZOr3igR+x2bm4wfBTdZvW Oipw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=SFTMdNMB; 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 a16si11828349ejk.500.2021.02.01.16.34.06; Mon, 01 Feb 2021 16:34:31 -0800 (PST) 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=SFTMdNMB; 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 S231433AbhBBAc2 (ORCPT + 99 others); Mon, 1 Feb 2021 19:32:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230088AbhBBAc1 (ORCPT ); Mon, 1 Feb 2021 19:32:27 -0500 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 E9C14C061786 for ; Mon, 1 Feb 2021 16:31:10 -0800 (PST) Received: by mail-yb1-xb4a.google.com with SMTP id 203so21793721ybz.2 for ; Mon, 01 Feb 2021 16:31:10 -0800 (PST) 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=0uh+WToPVrT5nNi8VVC2Dny5IL46Dl8JAHJqCqtV+0E=; b=SFTMdNMBaucckx4ugeVWqiTaqglAACSOnYW1A8/Ez40FvYEsGsO0865cf6SOLLRZMl cmExytKpiIUQTLdGyeq+PUR8+HohaxLo62ySgm8hUBnNJJ8mgLdsddWbKPXMRA+E67eG SaWVdQsXlr1DGAk5sISAxgbEgxZjQztEiPSMkFTiBzFTDoH2i9guief7sffShnkAG7u8 TMoF4o4nYGOdaEdrTSTHI+h1rUtOxgpNU4MHtE1VjEcJTKOHLug3obBT6AYxiwSd4G7y gfT8tiVCijoHyEFRRycKzh7fSI9c+1FoSLpezB91zdOv5mTJXXTjZyfZ7t5IGvyV49I9 5M9A== 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=0uh+WToPVrT5nNi8VVC2Dny5IL46Dl8JAHJqCqtV+0E=; b=qRJ9fU6YKhE2olqx7vAtx21nT35v3rxECoeCqx8n+JSWWRGFmPvM/CYmqJKnn4dQ0L +SGWBl40zgQijavghncC2bvVnqlFyxl/KogBUzZ6ZJUhuuh1xnCsyPg0AuDTrcMe6dMH AKWXOcjHZe1HWRBst4xSPd49P31viqijE/ECBA/tLEvq5jJNTQUEnZJlNDIFGoGgJyYT LgVSUeuIu97UOBV6LuruaOWAX2d3RUqH4BoW8JcAEjiqHz0G8usKpDWQppMGFc8QUE/O Y3mIOZD2+bQ7Kqv6+NHwXrZBU88zAeqTuVR3k67Dtdv6RtNMg3ZZGchmuxgII0glEXkS Y1Sg== X-Gm-Message-State: AOAM532sziBX6in/ROWAonpAitCu2btmca74B3IUx6BaD8RbUYqCV8l7 HO05CBOANpw7zCqmJLIV8x+p2n8BJuo= Sender: "badhri via sendgmr" X-Received: from badhri.mtv.corp.google.com ([2620:15c:211:201:d56c:119f:44fb:5da4]) (user=badhri job=sendgmr) by 2002:a25:cd01:: with SMTP id d1mr11984442ybf.125.1612225870209; Mon, 01 Feb 2021 16:31:10 -0800 (PST) Date: Mon, 1 Feb 2021 16:31:01 -0800 In-Reply-To: <20210202003101.221145-1-badhri@google.com> Message-Id: <20210202003101.221145-3-badhri@google.com> Mime-Version: 1.0 References: <20210202003101.221145-1-badhri@google.com> X-Mailer: git-send-email 2.30.0.365.g02bc693789-goog Subject: [PATCH v2 3/3] usb: typec: tcpci_maxim: Enable data path when partner is USB Comm capable From: Badhri Jagan Sridharan To: Guenter Roeck , Heikki Krogerus , Greg Kroah-Hartman , Kyle Tso Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Badhri Jagan Sridharan Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Configure USB switches when partner is USB Communication capable. The is enabled USB data communication over D+/D- pins. Signed-off-by: Badhri Jagan Sridharan --- drivers/usb/typec/tcpm/tcpci_maxim.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/usb/typec/tcpm/tcpci_maxim.c b/drivers/usb/typec/tcpm/tcpci_maxim.c index f1674a611033..041a1c393594 100644 --- a/drivers/usb/typec/tcpm/tcpci_maxim.c +++ b/drivers/usb/typec/tcpm/tcpci_maxim.c @@ -19,6 +19,9 @@ #define PD_ACTIVITY_TIMEOUT_MS 10000 #define TCPC_VENDOR_ALERT 0x80 +#define TCPC_VENDOR_USBSW_CTRL 0x93 +#define TCPC_VENDOR_USBSW_CTRL_ENABLE_USB_DATA 0x9 +#define TCPC_VENDOR_USBSW_CTRL_DISABLE_USB_DATA 0 #define TCPC_RECEIVE_BUFFER_COUNT_OFFSET 0 #define TCPC_RECEIVE_BUFFER_FRAME_TYPE_OFFSET 1 @@ -274,6 +277,21 @@ static void process_tx(struct max_tcpci_chip *chip, u16 status) max_tcpci_init_regs(chip); } +/* Enable USB switches when partner is USB communications capable */ +static void max_tcpci_set_partner_usb_comm_capable(struct tcpci *tcpci, struct tcpci_data *data, + bool capable) +{ + struct max_tcpci_chip *chip = tdata_to_max_tcpci(data); + int ret; + + ret = max_tcpci_write8(chip, TCPC_VENDOR_USBSW_CTRL, capable ? + TCPC_VENDOR_USBSW_CTRL_ENABLE_USB_DATA : + TCPC_VENDOR_USBSW_CTRL_DISABLE_USB_DATA); + + if (ret < 0) + dev_err(chip->dev, "Failed to enable USB switches"); +} + static irqreturn_t _max_tcpci_irq(struct max_tcpci_chip *chip, u16 status) { u16 mask; @@ -453,6 +471,7 @@ static int max_tcpci_probe(struct i2c_client *client, const struct i2c_device_id chip->data.frs_sourcing_vbus = max_tcpci_frs_sourcing_vbus; chip->data.auto_discharge_disconnect = true; chip->data.vbus_vsafe0v = true; + chip->data.set_partner_usb_comm_capable = max_tcpci_set_partner_usb_comm_capable; max_tcpci_init_regs(chip); chip->tcpci = tcpci_register_port(chip->dev, &chip->data); -- 2.30.0.365.g02bc693789-goog