Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp926936ybh; Wed, 15 Jul 2020 20:42:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwJv+C5xze4JvK4n/BdzFlgxQv1K7MrKalJs7l9DWsU/X6MB4BktW2+VCyqt44hQmZHL6hZ X-Received: by 2002:a17:906:c453:: with SMTP id ck19mr1877250ejb.185.1594870941653; Wed, 15 Jul 2020 20:42:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594870941; cv=none; d=google.com; s=arc-20160816; b=RWlYDZUI7uTHlqQROO9XvJozQQR+JVk/FaqvBNRtOd2WrXxcJAQ5xLXPahl90V0onp UctGbEn6qMbmF8avPDwI0HnCC1FFpJDYsF1eTLEV4DLcBWLbFQI+zwydS4E+XWZdZo9C F3scwSsn8zFIuTlgfHKvKOU6tc5mjZ+DUdlyWyalAkzZCZTSb2YdDq3YOa/WjpqBsp/8 VvZk6qq4vw2/SX5GXJEo8OrvdHvUnsrKX+6/WQyyXHDSZldqveyF7VzKOtMvBzV2xL81 4VcUo27Lb15FpOfhzJ9Jcg8d59v+tA02wyVEsRsz4LVRwnnhhEY/Mf3COSKGdrbfvklb irFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=RqXiuX4xTk+c+m3/+/qauF2hZhj8i+Z6YtZCdH2Snc8=; b=DTphSM70tNheEcj+rx+DELXVRrnbxRj7toj0zgugYXwxwxCgO7/d+hs0jQPerbCbu7 vc78cbfFnZX/KN3XQ8ZYKrQrpjZlkjkOdh080dZzw8PiYU3fYlYLS/DD9xAvdHA8JihE RBRq3p5jW1GL3jWc00ecnW2ekIbrSfkSHcaRDAA5GSDwlGkh1reOZtohY4LSZN2yXkVp UwfyAJUA7hjOvxrjpLoo6b93eqi6oiGzqAC55qywts+9+d/aF3G04XOeHtXcn3VETfK9 pTKBVG4nC18ZGs8oyivhuJ7N06fZpsQV5b1UpBY/RZDhXmrvrS2ZxcqM5buZtXquPxZW 9ihA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=SP5OdA53; 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 s21si2302852edy.104.2020.07.15.20.41.59; Wed, 15 Jul 2020 20:42:21 -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=SP5OdA53; 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 S1728293AbgGPDlm (ORCPT + 99 others); Wed, 15 Jul 2020 23:41:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728290AbgGPDli (ORCPT ); Wed, 15 Jul 2020 23:41:38 -0400 Received: from mail-qv1-xf4a.google.com (mail-qv1-xf4a.google.com [IPv6:2607:f8b0:4864:20::f4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5A4EC08C5DE for ; Wed, 15 Jul 2020 20:41:37 -0700 (PDT) Received: by mail-qv1-xf4a.google.com with SMTP id x37so2638670qvf.4 for ; Wed, 15 Jul 2020 20:41:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=RqXiuX4xTk+c+m3/+/qauF2hZhj8i+Z6YtZCdH2Snc8=; b=SP5OdA53xpO2g879UlHzND9x16PSS2YeWd6k1DiG2SEtDMCq+XiIiaQv3lp4dwcxBb GZgChSNNBaBvlmpPwQqfqdSSp96ht7M2qACj2PWt47uaITvzqZ5Oxv5bYTIUR61DjsgF hPt+lTMLfRM2gkOb9M19KbD4CtWSnbj8QyBskUezCC0jRJxz1QbRR+I/HDHlQT2ZZOYx zfvf9eJK2R8FCYbGlmaLNoioILOyvAC8Ftk3NOORSLnIpsGjs2gE+e7DeE5xR3Z9s/oE xlDsQ/4UyKXy4/CAcNXQSHZUOrxmXleX8jXCxl4GDsrmAumGqsEFeGvgMVYaQDKeXwtr NjWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=RqXiuX4xTk+c+m3/+/qauF2hZhj8i+Z6YtZCdH2Snc8=; b=TitasjVj4Nr1eMF/WnvkcROcAOExm//IXIsT/Z2V+MnJzn+1M+1iTelxoF3Axm+84T q5gI1OfUOLLlJIIiwmQ2j4H7NkOQ4sZ5IYTAotuV8gJ+nr8Yc4C4zSPKQf53p5fpMPwH uCKQdIEpqvMW8RYyduWHrAR2Z2c/yLmtlS/XNHkj17wUHk4dNnKzDg7nk57NSxCTL87j drQ15rX5IqzRovJdLj1I8ljdRAE7bxn7NUWRUJ4FVlpViScwwu4M3c1M1Ld1B831CImD Y6fvM6PUDpx1EjYuH+7K0gHyd2UrswUuufD5wI7dWlZu/o6YuXUqPuKWOA2Y1OoHczyq 1OZw== X-Gm-Message-State: AOAM530LYFH2n0AJdhRLK6sJqM950zL8kh69bF9+c8xr5GBalU4Dd/Y9 cYxNEB/n7xAmFq/zkd39W/ds1F3+mM0= X-Received: by 2002:ad4:57c4:: with SMTP id y4mr2377290qvx.230.1594870897051; Wed, 15 Jul 2020 20:41:37 -0700 (PDT) Date: Wed, 15 Jul 2020 20:41:27 -0700 In-Reply-To: <20200716034128.1251728-1-badhri@google.com> Message-Id: <20200716034128.1251728-2-badhri@google.com> Mime-Version: 1.0 References: <20200716034128.1251728-1-badhri@google.com> X-Mailer: git-send-email 2.27.0.389.gc38d7665816-goog Subject: [PATCH 2/3 v3] usb: typec: tcpci: Support BIST test data mode for compliance. From: Badhri Jagan Sridharan To: Guenter Roeck , Heikki Krogerus , reg Kroah-Hartman Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Badhri Jagan Sridharan Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting from TCPCI spec: "Setting this bit to 1 is intended to be used only when a USB compliance tester is using USB BIST Test Data to test the PHY layer of the TCPC. The TCPM should clear this bit when a disconnect is detected. 0: Normal Operation. Incoming messages enabled by RECEIVE_DETECT passed to TCPM via Alert. 1: BIST Test Mode. Incoming messages enabled by RECEIVE_DETECT result in GoodCRC response but may not be passed to the TCPM via Alert." Signed-off-by: Badhri Jagan Sridharan Reviewed-by: Guenter Roeck --- Changes since V1:(Guenter's suggestions) - Split the change into two: TCPM and TCPCI - Move BIST log to TCPM log - Alignment and column count changes Changes since V2:(Guenter's suggestions) - Re-ordered patchset - Included Reviewed-by tag --- drivers/usb/typec/tcpm/tcpci.c | 9 +++++++++ drivers/usb/typec/tcpm/tcpci.h | 1 + 2 files changed, 10 insertions(+) diff --git a/drivers/usb/typec/tcpm/tcpci.c b/drivers/usb/typec/tcpm/tcpci.c index 753645bb25273a..f57d91fd0e0924 100644 --- a/drivers/usb/typec/tcpm/tcpci.c +++ b/drivers/usb/typec/tcpm/tcpci.c @@ -227,6 +227,14 @@ static int tcpci_set_vconn(struct tcpc_dev *tcpc, bool enable) enable ? TCPC_POWER_CTRL_VCONN_ENABLE : 0); } +static int tcpci_set_bist_data(struct tcpc_dev *tcpc, bool enable) +{ + struct tcpci *tcpci = tcpc_to_tcpci(tcpc); + + return regmap_update_bits(tcpci->regmap, TCPC_TCPC_CTRL, TCPC_TCPC_CTRL_BIST_TM, + enable ? TCPC_TCPC_CTRL_BIST_TM : 0); +} + static int tcpci_set_roles(struct tcpc_dev *tcpc, bool attached, enum typec_role role, enum typec_data_role data) { @@ -530,6 +538,7 @@ struct tcpci *tcpci_register_port(struct device *dev, struct tcpci_data *data) tcpci->tcpc.set_pd_rx = tcpci_set_pd_rx; tcpci->tcpc.set_roles = tcpci_set_roles; tcpci->tcpc.pd_transmit = tcpci_pd_transmit; + tcpci->tcpc.set_bist_data = tcpci_set_bist_data; 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 303ebde265465c..11c36d086c8608 100644 --- a/drivers/usb/typec/tcpm/tcpci.h +++ b/drivers/usb/typec/tcpm/tcpci.h @@ -36,6 +36,7 @@ #define TCPC_TCPC_CTRL 0x19 #define TCPC_TCPC_CTRL_ORIENTATION BIT(0) +#define TCPC_TCPC_CTRL_BIST_TM BIT(1) #define TCPC_ROLE_CTRL 0x1a #define TCPC_ROLE_CTRL_DRP BIT(6) -- 2.27.0.389.gc38d7665816-goog