Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp2885560rdb; Tue, 12 Sep 2023 15:39:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHaKH0UsrH7edQAYj8YTGzTDn+tc1f8UtmBkQfqYp6Qp4Q5WdOnuBvovs1tho1s/vlvtbQZ X-Received: by 2002:a05:6a21:3289:b0:137:3eba:b81f with SMTP id yt9-20020a056a21328900b001373ebab81fmr714560pzb.3.1694558355589; Tue, 12 Sep 2023 15:39:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694558355; cv=none; d=google.com; s=arc-20160816; b=nN0huwa1AIrOb8LeT91aZjx3Og4EU1kUxfGrBFeXvNlguo4x7i1kwxFq+S7C41Akaq wGu6yQWEHdSj/hSjxxKW1H+ry88dmU5iqNhtQ40+qaNFaqdNe13WZPf3I1vwHbbTyAVt utT9rIiy0tUfXd//0rVk8msgQl7KqMUz6JLa+Z641i6hVFyfdLL1fFLfgjYGhSklLJPh 4+lO19dbR7HJ9wwF6Y5S4BYa6qEgcQREcnhBtY67vkRLMQgsgd5xl1VYgqx3q0y0naZz Jvt4DDlxVWUikY4AxmVSgblF9HG5ln+X6JecYXPibN9hT/wWAK6NIqMafTV5uQn7yr8b s7fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=1tnjpp/lycfe/g1+o8xfnP0NivTMeUFx/cpAoWuFE18=; fh=bPuS8kv1zy5CVUeMzykNHPIC+/fQVv9gvFz4mBHb6oA=; b=pI5e475nUZcSdGxhAvOlllXXWE6AuGa3vTklBkLK+v9asZBAjf54rGd8WTmV9P1oa1 P58to+Q6oYujS5bDaJOsJDswk2pM7kHN6Xx0dKSaGTgJfl2dOrDAbl+uJ5XJG2wdckbZ TodP0Fy1+YLzgrRvDiYskuSOi9WQ/gsUK+g0Gg8zINwFLOoiem95wl3y3H4yysjE+vEr mF48O4fAre1f4OAf78mlUUbEU1easTaX0TnrD2lojGb8LRQBDCx3S0sqyXWheaO16a7J USHZbhlagoTbIcJyplz83yJSpNZpgJjp6q8B0vaTG/269oxNXZ7+PHsaOsNqsFQ6RRdq RsEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=EwTpPQX3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id q7-20020a17090a7a8700b0026fc4f2c6d0si209403pjf.147.2023.09.12.15.39.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 15:39:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=EwTpPQX3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id C548D833C644; Mon, 11 Sep 2023 21:43:19 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.8 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239478AbjILCkC (ORCPT + 99 others); Mon, 11 Sep 2023 22:40:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239421AbjILCjo (ORCPT ); Mon, 11 Sep 2023 22:39:44 -0400 Received: from mail-qk1-x736.google.com (mail-qk1-x736.google.com [IPv6:2607:f8b0:4864:20::736]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82F0B120D79 for ; Mon, 11 Sep 2023 18:17:48 -0700 (PDT) Received: by mail-qk1-x736.google.com with SMTP id af79cd13be357-76f18e09716so300459485a.2 for ; Mon, 11 Sep 2023 18:17:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1694481467; x=1695086267; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=1tnjpp/lycfe/g1+o8xfnP0NivTMeUFx/cpAoWuFE18=; b=EwTpPQX3oQ0mVyRHCa2uU/x7V5aozk6OidlBiGybLOAjUsaXKCfpGSsityqkPsPbk4 Kdc6ZcP9z5K52m2cb9pxKhv48eQBoCo7hgvrQRojSGhUvkxtbJEgxaOPI5c+g7dG59J2 gJ5gxnR7xQDqv/QuVZ4fdQJ6dFbR12bUVifII= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694481467; x=1695086267; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1tnjpp/lycfe/g1+o8xfnP0NivTMeUFx/cpAoWuFE18=; b=k08RKFsxv1xoAjC9YXzZigrtyVwXL+e/q/HMHZx5cEiybDxY0nWL3nPRvpaOs/nD4b K0rKfpa/hI/gJXDLKQ/BdPZAZL6aipbedI+IxlRux76kQIgeAKjwUf3A/fjFW7uLjyBo ng7DaaITRwr7UonxBpGdinNE0u8e64cqVkAfkZcsYHVkYauGAfnsu+qx+nEzgumuOxGG MhBfQigXwcTa3xWchh0EXQbeCivkQmxckEXbqLMwB5dgR1QRtnMXq0/rirnAzc5Fz9VB 4X1JDKnkSOWUMr4h+lzwtFBmPcu+LJZ+FyPv6lBcmYQ3qL8DVf0LOw1v4Jh2pXNsxiTm +xFw== X-Gm-Message-State: AOJu0YxNqakJjnlgcGtVvM2SDU17ZAd6URfniXxBuBtLpEqdaoJ73Ueo sLS0qb9Jz9/F+0p7+VkuYZycsNUBpYvBcFmXX8z2/g== X-Received: by 2002:a0c:f508:0:b0:641:8e1a:d23b with SMTP id j8-20020a0cf508000000b006418e1ad23bmr11266928qvm.31.1694481467597; Mon, 11 Sep 2023 18:17:47 -0700 (PDT) MIME-Version: 1.0 References: <20230912005752.1532888-1-utkarsh.h.patel@intel.com> <20230912005752.1532888-4-utkarsh.h.patel@intel.com> In-Reply-To: <20230912005752.1532888-4-utkarsh.h.patel@intel.com> From: Prashant Malani Date: Mon, 11 Sep 2023 18:17:35 -0700 Message-ID: Subject: Re: [PATCH v3 3/4] platform/chrome: cros_ec_typec: Add Displayport Alternatemode 2.1 Support To: Utkarsh Patel Cc: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, heikki.krogerus@linux.intel.com, chrome-platform@lists.linux.dev, andriy.shevchenko@linux.intel.com, bleung@chromium.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 11 Sep 2023 21:43:20 -0700 (PDT) Hi Utkarsh, On Mon, Sep 11, 2023 at 5:58=E2=80=AFPM Utkarsh Patel wrote: > > Displayport Alternatemode 2.1 requires cable capabilities such as cable > signalling, cable type, DPAM version which then will be used by mux > driver for displayport configuration. These capabilities can be derived > from the Cable VDO. > Added a helper macro to get the Type C cable speed when provided the > cable VDO. > > Signed-off-by: Utkarsh Patel Thank you for addressing the comments. This LGTM; I have one minor suggesti= on, but I'll leave it to USB maintainers for the final call on that comment, so= : Acked-by: Prashant Malani > --- > Changes in v3: > - Removed use of variable cable_seepd. > - Added helper macro of pd_vdo.h in this patch as cros_ec_typec is the us= er. > > Changes in v2: > - Remvoed feature flag specifice to DP2.1. > - Remvoed seperate function for DP2.1. > - Removed use of EC host coammnd to get cable details. > - TBT cable VDO is used to get cable details. > - Using VDO_CABLE_SPEED macro to get passive cable speed. > > drivers/platform/chrome/cros_ec_typec.c | 28 +++++++++++++++++++++++++ > include/linux/usb/pd_vdo.h | 1 + > 2 files changed, 29 insertions(+) > > diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/c= hrome/cros_ec_typec.c > index d0b4d3fc40ed..cca913400b39 100644 > --- a/drivers/platform/chrome/cros_ec_typec.c > +++ b/drivers/platform/chrome/cros_ec_typec.c > @@ -492,6 +492,8 @@ static int cros_typec_enable_dp(struct cros_typec_dat= a *typec, > { > struct cros_typec_port *port =3D typec->ports[port_num]; > struct typec_displayport_data dp_data; > + u32 cable_tbt_vdo; > + u32 cable_dp_vdo; > int ret; > > if (typec->pd_ctrl_ver < 2) { > @@ -524,6 +526,32 @@ static int cros_typec_enable_dp(struct cros_typec_da= ta *typec, > port->state.data =3D &dp_data; > port->state.mode =3D TYPEC_MODAL_STATE(ffs(pd_ctrl->dp_mode)); > > + /* Get cable VDO for cables with DPSID to check DPAM2.1 is suppor= ted */ > + cable_dp_vdo =3D cros_typec_get_cable_vdo(port, USB_TYPEC_DP_SID)= ; > + > + /** > + * Get cable VDO for thunderbolt cables and cables with DPSID but= does not > + * support DPAM2.1. > + */ > + cable_tbt_vdo =3D cros_typec_get_cable_vdo(port, USB_TYPEC_TBT_SI= D); > + > + if (cable_dp_vdo & DP_CAP_DPAM_VERSION) { > + dp_data.conf |=3D cable_dp_vdo; > + } else if (cable_tbt_vdo) { > + dp_data.conf |=3D TBT_CABLE_SPEED(cable_tbt_vdo) << DP_C= ONF_SIGNALLING_SHIFT; > + > + /* Cable Type */ > + if (cable_tbt_vdo & TBT_CABLE_OPTICAL) > + dp_data.conf |=3D DP_CONF_CABLE_TYPE_OPTICAL << D= P_CONF_CABLE_TYPE_SHIFT; > + else if (cable_tbt_vdo & TBT_CABLE_RETIMER) > + dp_data.conf |=3D DP_CONF_CABLE_TYPE_RE_TIMER << = DP_CONF_CABLE_TYPE_SHIFT; > + else if (cable_tbt_vdo & TBT_CABLE_ACTIVE_PASSIVE) > + dp_data.conf |=3D DP_CONF_CABLE_TYPE_RE_DRIVER <<= DP_CONF_CABLE_TYPE_SHIFT; > + } else if (PD_IDH_PTYPE(port->c_identity.id_header) =3D=3D IDH_PT= YPE_PCABLE) { > + dp_data.conf |=3D VDO_TYPEC_CABLE_SPEED(port->c_identity.= vdo[0]) << > + DP_CONF_SIGNALLING_SHIFT; > + } > + > ret =3D cros_typec_retimer_set(port->retimer, port->state); > if (!ret) > ret =3D typec_mux_set(port->mux, &port->state); > diff --git a/include/linux/usb/pd_vdo.h b/include/linux/usb/pd_vdo.h > index b057250704e8..3a747938cdab 100644 > --- a/include/linux/usb/pd_vdo.h > +++ b/include/linux/usb/pd_vdo.h > @@ -376,6 +376,7 @@ > | ((vbm) & 0x3) << 9 | (sbu) << 8 | (sbut) << 7 | ((cur) & 0x3) = << 5 \ > | (vbt) << 4 | (sopp) << 3 | ((spd) & 0x7)) > > +#define VDO_TYPEC_CABLE_SPEED(vdo) ((vdo) & 0x7) I would suggest putting this header modification in a separate patch; if for some reason we have to revert the Chrome part of the change, then we won't rip this part out too (some other driver down the road may use the macro and would break if it were to be removed). But I'll leave it to Heikki to determine whether that is preferred. Thanks, -Prashant