Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3689249pxb; Mon, 1 Feb 2021 01:56:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJxG3WiUCk6GokOCi4OPUuWKrtsK7RyKHrnqvUxy2ndgBvuxcZWVc5rYw6Dc3l8wfPjof6F2 X-Received: by 2002:a05:6402:1546:: with SMTP id p6mr18134588edx.66.1612173404157; Mon, 01 Feb 2021 01:56:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612173404; cv=none; d=google.com; s=arc-20160816; b=LFSEGDCVkg48NorB+WPhdo0wSrfaQcASc1an0snkN5A1bW7TTS+z1DydF7LmmTMNYw banzTj6bz9lwNiAQMNhBDx/sk7k1DGww9Da/6AOrIKJf3w/QkmZGX8grzx3NHmvW5DYI Dhbwq++s/NLSskRyyD4tYLONwN7+3JsXoPNBsbdkN54zQ0M98851ksHyZxjPozHKv7ea RMWZfmCZ5iOYgPgYrGnv0wR7szwMJNC1iug21+TLvb+B6HxjH9Hu7iHNIysp2yPA3tSj 4dtT5yp/FOXHKj+tclcG6pAlIqZ/YdhVnt3VjJJhWX9jYpAQjBwEfkLmE1eJ1X3/HcYG nYPg== 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=zapoLgC22vw4n7q1D/LGbw/OQCOXgrVOKbJfNgYcw9DORzINl4pARZMTFCCstjCdQa Wqt/RJRrWHnItsR8/Ch0Ffaftomyszxm9yfSRXf0SyT5QTSUyCGhzTiuFiSP+Guqy/LG ZpAh+ZgiFTEAqD5L/hqE3Zr94aLiKNKMPGAdP7EoIo5jGBPmQsZ7lzvo92XeHyT0ivCa eDQffj+shYXjynLglc2sclkiuaRVHVYbw3ipegjxzRV131QkS4iJhwcca+rIgcFFwgU3 eKLqcUN8ezM1PQOCr/UqxOho9NkFZteFaBPo68UC/h4hO/irIGHXBE7iMVbDRuj7l+WZ v5NQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=JZbMiUyw; 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 v5si11323553edc.346.2021.02.01.01.56.19; Mon, 01 Feb 2021 01:56:44 -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=JZbMiUyw; 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 S232996AbhBAJyl (ORCPT + 99 others); Mon, 1 Feb 2021 04:54:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232992AbhBAJyg (ORCPT ); Mon, 1 Feb 2021 04:54:36 -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 2C0BEC0613ED for ; Mon, 1 Feb 2021 01:53:19 -0800 (PST) Received: by mail-yb1-xb4a.google.com with SMTP id m7so3917922ybm.19 for ; Mon, 01 Feb 2021 01:53:19 -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=JZbMiUywIbtml14aZF5DenFmX8cTfKrnKqlNI3+SQRq+h0S5fF1pWJJNPhvWLEghUs HpeMrYrcFc9aiGhPxytd/CuWAkbV4Y1cUbQ34f7G/BkXprgGOZhNEXf61aFkyWwDqCiX gT1uNnD5uQjTsoKQ4pmx4uI5JiwYFkPyzGQmCH+B2Lca+qhjoXZFnp+cA8BcnFwpIfrl /gsjkXyHugeU0Q+vrgRu11mUCUuHeB1mBAQ35uMd9GPar+GG5YiVrkAts0k6vM8SmRdI BXdJTOdSkXXeF/e5dvNS6h9ci/0CPRMIqhVEQ82qKnFfcvHRRRgFfSh5j3LlAXfULsom uLqA== 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=rYGQVGlXSS1yDJspeLrWWJmXccvQr142tBdkGgMcKRUv/cs73eelputEQmFoxmFsjd QSfngyQAgdZ7u1T8JFWDogOplAgwG5aDWlKHgX4G9uppUlZ5ivvjHSr5U6tzXKblRvpy J6W/R4yDMQQNpVUE4ryd7fr7iNNTOembmYWv/1zNoE3CgT6BM8mzENxyys6TOlkY72nI JKyK8YpAN0ROKIzBTB5PCK8RSjrDgIqlQGHSJckZxJPhp0j/yi09+3rWDxFhlj2MlF3k Kx/qgbYKyvjE/wTBkAtMsIvNefAXtDuolYfVjDRL+tYIg7I/bbi/1p/do9E/7FYbfnXc IJTw== X-Gm-Message-State: AOAM530afDjHw8vaZ+kceTvw3pJhpxvJcAdEOfB2JyXfUsYX4C1uhoIn AyauXHldg+ypnrwbXnGZcYvFH+VQtvw= Sender: "badhri via sendgmr" X-Received: from badhri.mtv.corp.google.com ([2620:15c:211:201:f292:1cff:fee0:66cf]) (user=badhri job=sendgmr) by 2002:a25:ac94:: with SMTP id x20mr12304706ybi.411.1612173198434; Mon, 01 Feb 2021 01:53:18 -0800 (PST) Date: Mon, 1 Feb 2021 01:53:09 -0800 In-Reply-To: <20210201095309.39486-1-badhri@google.com> Message-Id: <20210201095309.39486-3-badhri@google.com> Mime-Version: 1.0 References: <20210201095309.39486-1-badhri@google.com> X-Mailer: git-send-email 2.30.0.365.g02bc693789-goog Subject: [PATCH v1 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