Received: by 2002:a05:7208:c24f:b0:81:d631:dc8 with SMTP id w15csp400350rbd; Thu, 4 Apr 2024 12:38:58 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVG6J/uO2hWlVjp65JEkGgoQR6bgOMCidlrcQlPmK+FzW8fnLu7V7yRT2m4v74kCn1YDuLeEDeOQYRB07e88340y7wZfA35rUWjj/Gd3g== X-Google-Smtp-Source: AGHT+IHJ/pbeJGPFeDZJKZPirVwMT2Ix4QMaPFl5FHDoVpO6Yprom7Vslvp8SfH1BzsmRJoTXu1O X-Received: by 2002:a05:620a:1204:b0:78b:ddda:82b5 with SMTP id u4-20020a05620a120400b0078bddda82b5mr3687863qkj.50.1712259537917; Thu, 04 Apr 2024 12:38:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712259537; cv=pass; d=google.com; s=arc-20160816; b=NkeokZmMhh8WxqZ6ChdpMbjV0K3jsgJ/hyTmU0Sff8Sp+hzz/NqJ8HUelO7db0RHLH 2GmNo2WeFkM66py4VmZBjMWq5YJP45mUn3gDOXs4UODHHn+t8lhrbNbFTKXVgB1yLwMf GOtpwkaZeyiBZsKbmBWCyArKf3s1Cy0DFQJ+ij9e+KhWSd1ghlCLIS0J2ohjGUz1v4qV MjF2+KO9U/YAEMfk2AyKg/HBCzePFuOLr7HeB0ThYseOTZzeQtWgHxIEnXydxsQOjDke oqTjy2DkQLJA6aDMr2eZIXFPOSFwm8dvo5+jno3i+lGAHha7PMia7sGjjpps/SrhtiiV n2qQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=djH+4NcDYJPLyHRZa+Px0PXUtta/rV5wgF75CaZFmmg=; fh=3QidnjWBvzE2ozRXak662dcB2kafdarcB44gMgF6n5A=; b=Z1lqzrPuF4kNWUNIJjnT5mpj3jppk7udPv4q2utBh/u2a6qJ10QPvLrv9gFrYWY823 PDAtKQMZ8EzA3WV4qeTroIdAtmUHXCdJtWlH7jW2krNvgQfIzFFLEhPItrFXHNigT885 ElUpu//la3G9PA9WqFnF9qX52/5wHlubFlWnrNCcO1FXm2CyqW2MdOXojjvlWPvdV4/x tVrokweEQaYAZHeIUz5e4HEmu+dCdT4n2+DLBgYDdOeA1WAoFr/6IH/RHoWzkREr9v2F YM/xeUsAlCMxIzl2JaNI0FZmT8t6xasxBMng5Lj9gxLnNo6Kcqz7bnDtnAVQ4GZwpR4D Uu4g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=sntech.de dmarc=pass fromdomain=sntech.de); spf=pass (google.com: domain of linux-kernel+bounces-132047-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-132047-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=sntech.de Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id de18-20020a05620a371200b0078bbea0b744si54121qkb.621.2024.04.04.12.38.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 12:38:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-132047-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=sntech.de dmarc=pass fromdomain=sntech.de); spf=pass (google.com: domain of linux-kernel+bounces-132047-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-132047-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=sntech.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 9BEF91C237C7 for ; Thu, 4 Apr 2024 19:38:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8489E1311A3; Thu, 4 Apr 2024 19:38:51 +0000 (UTC) Received: from gloria.sntech.de (gloria.sntech.de [185.11.138.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7C1F56D1AB for ; Thu, 4 Apr 2024 19:38:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.11.138.130 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712259531; cv=none; b=ICaKtUMVasW2c27YRjD2dsnez8NRv0C7ReOwo2VzimZ9nhEgmIdIVhK9da8Uct4bMCF1cGo/Mm7Bp4e/N+po7LKVTUcXBGSo/JHNFgko8mwh+BfmXwC24glllhvW+QX5MWoJbISe7TmBX9M3kaWkofqGO8Xetn6m2d9Bn65hKvY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712259531; c=relaxed/simple; bh=OkgKMraGmojnn+a+fjRWstEELW1DW59wRiTp1ftO9RQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=tBF7QjBrUCcQ2v938f6cn0JpJX9XFSwT7bVj4b3VIL3U+uQuOq+hptPqT4DkJOlM5NaDs9QjRcdc8/hSvmKTpf7BElg5uvDuzkr6fQQtERjVj11dkxXQiFY9QVRJX5IYj5/hRNs0XIBnkWifj57UfmiMeYHv+0IaFgQFuqlm6Zw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sntech.de; spf=pass smtp.mailfrom=sntech.de; arc=none smtp.client-ip=185.11.138.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sntech.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sntech.de Received: from i53875aaf.versanet.de ([83.135.90.175] helo=phil.localnet) by gloria.sntech.de with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rsSv3-0005Tv-Jj; Thu, 04 Apr 2024 21:38:41 +0200 From: Heiko Stuebner To: Vinod Koul , Kishon Vijay Abraham I , Sebastian Reichel Cc: Shawn Lin , Michal Tomek , linux-phy@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, Sebastian Reichel Subject: Re: [PATCH 1/3] phy: rockchip-snps-pcie3: fix bifurcation on rk3588 Date: Thu, 04 Apr 2024 21:38:40 +0200 Message-ID: <2501840.irdbgypaU6@phil> In-Reply-To: <20240404-rk3588-pcie-bifurcation-fixes-v1-1-9907136eeafd@kernel.org> References: <20240404-rk3588-pcie-bifurcation-fixes-v1-0-9907136eeafd@kernel.org> <20240404-rk3588-pcie-bifurcation-fixes-v1-1-9907136eeafd@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Am Donnerstag, 4. April 2024, 19:11:26 CEST schrieb Sebastian Reichel: > From: Michal Tomek > > So far all RK3588 boards use fully aggregated PCIe. CM3588 is one > of the few boards using this feature and apparently it is broken. > > The PHY offers the following mapping options: > > port 0 lane 0 - always mapped to controller 0 (4L) > port 0 lane 1 - to controller 0 or 2 (1L0) > port 1 lane 0 - to controller 0 or 1 (2L) > port 1 lane 1 - to controller 0, 1 or 3 (1L1) > > The data-lanes DT property maps these as follows: > > 0 = no controller (unsupported by the HW) > 1 = 4L > 2 = 2L > 3 = 1L0 > 4 = 1L1 > > That allows the following configurations with first column being the > mainline data-lane mapping, second column being the downstream name, > third column being PCIE3PHY_GRF_CMN_CON0 and PHP_GRF_PCIESEL register > values and final column being the user visible lane setup: > > <1 1 1 1> = AGGREG = [4 0] = x4 (aggregation) > <1 1 2 2> = NANBNB = [0 0] = x2 x2 (no bif.) > <1 3 2 2> = NANBBI = [1 1] = x2 x1x1 (bif. of port 0) > <1 1 2 4> = NABINB = [2 2] = x1x1 x2 (bif. of port 1) > <1 3 2 4> = NABIBI = [3 3] = x1x1 x1x1 (bif. of both ports) > > The driver currently does not program PHP_GRF_PCIESEL correctly, which > is fixed by this patch. As a side-effect the new logic is much simpler > than the old logic. > > Fixes: 2e9bffc4f713 ("phy: rockchip: Support PCIe v3") > Signed-off-by: Michal Tomek > Signed-off-by: Sebastian Reichel > --- > drivers/phy/rockchip/phy-rockchip-snps-pcie3.c | 24 ++++++++---------------- > 1 file changed, 8 insertions(+), 16 deletions(-) > > diff --git a/drivers/phy/rockchip/phy-rockchip-snps-pcie3.c b/drivers/phy/rockchip/phy-rockchip-snps-pcie3.c > index 121e5961ce11..d5bcc9c42b28 100644 > --- a/drivers/phy/rockchip/phy-rockchip-snps-pcie3.c > +++ b/drivers/phy/rockchip/phy-rockchip-snps-pcie3.c > @@ -132,7 +132,7 @@ static const struct rockchip_p3phy_ops rk3568_ops = { > static int rockchip_p3phy_rk3588_init(struct rockchip_p3phy_priv *priv) > { > u32 reg = 0; > - u8 mode = 0; > + u8 mode = RK3588_LANE_AGGREGATION; /* default */ > int ret; > > /* Deassert PCIe PMA output clamp mode */ > @@ -140,28 +140,20 @@ static int rockchip_p3phy_rk3588_init(struct rockchip_p3phy_priv *priv) > > /* Set bifurcation if needed */ > for (int i = 0; i < priv->num_lanes; i++) { > - if (!priv->lanes[i]) > - mode |= (BIT(i) << 3); > - > if (priv->lanes[i] > 1) > - mode |= (BIT(i) >> 1); > - } > - > - if (!mode) > - reg = RK3588_LANE_AGGREGATION; > - else { > - if (mode & (BIT(0) | BIT(1))) > - reg |= RK3588_BIFURCATION_LANE_0_1; > - > - if (mode & (BIT(2) | BIT(3))) > - reg |= RK3588_BIFURCATION_LANE_2_3; > + mode &= ~RK3588_LANE_AGGREGATION; > + if (priv->lanes[i] == 3) > + mode |= RK3588_BIFURCATION_LANE_0_1; > + if (priv->lanes[i] == 4) > + mode |= RK3588_BIFURCATION_LANE_2_3; > } > > + reg = mode; > regmap_write(priv->phy_grf, RK3588_PCIE3PHY_GRF_CMN_CON0, (0x7<<16) | reg); nit: instead of doing reg=mode, why not use mode directly? i.e. (0x7<<16) | mode in the regmap_write call other than that Acked-by: Heiko Stuebner > > /* Set pcie1ln_sel in PHP_GRF_PCIESEL_CON */ > if (!IS_ERR(priv->pipe_grf)) { > - reg = (mode & (BIT(6) | BIT(7))) >> 6; > + reg = mode & 3; > if (reg) > regmap_write(priv->pipe_grf, PHP_GRF_PCIESEL_CON, > (reg << 16) | reg); > >