Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp339913lqa; Sat, 27 Apr 2024 04:51:27 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXuqQXAD5vAjfSYJfZVHBllbQlyCEq1rmcbA35W/65+5wif8KwQpTmgiyvNR1z8wvmeC8bI6fvDcNi09Vfuu6iKI8Xw7trdoH0lX6Pujg== X-Google-Smtp-Source: AGHT+IGEcJQEgpcdMgJheeA+U6XKR0494CZ6EfNcKwBng/OgxdEPGGeZp+I5F3suu42EGvKqTKZP X-Received: by 2002:a17:902:7594:b0:1e4:5b89:dbfe with SMTP id j20-20020a170902759400b001e45b89dbfemr5810703pll.25.1714218686962; Sat, 27 Apr 2024 04:51:26 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714218686; cv=pass; d=google.com; s=arc-20160816; b=WHpj3b1bl58Cdzy948fB2NTlQwfCXVX5WWvM1XZFbcV8eCeXo52Dl4spCZR4obhbA0 sntUANrL90ZyebKuHssLmE/EImg9rKIem7nLC3bf+eo+HD+VVWs7p88giY+U0njAuBx9 /K2cmHWLq7UdTKNhoKOdYwMZFQJAOEdNHc4EzmpWsccpTcG4VpdOsq1Wt+pcLGTMoTO2 ABiSFDJDieCdYXnIgVCSpt9iOcruKGuxIpJDXdWSmg91yfY6M6fQVyQlqaoWQhiMNTu8 zKpId9CrQFU1vphSn/mZiIDmYG/So8Cb3zTHJMWydvfdV5oMX0Uvjg8oxFPjWsSpw4t/ siGg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=HcfbaR8kZq8OLnUAT2pXDqoM8fNnWHLJf3IpXP9uecY=; fh=AgjBzh8oAsvO/Bev8HxDsw5rquz+yWJcDkkV2lKm4D4=; b=0NC5ZhYNA1wm+0HWj+hbuPJA3SUttmypisxLrhMs5GIRooBC3OZKgvwyNkp8e2aQ4Q qsMyDlf94OqM1NA/Omr9MA+duYmTZi6/7w2pKQZ2nKB7jSnoinU49vtA0jTmp67DHvSj i5JGPOK0hkMVdvOnjAuaCw8fU3gGms1itVXZ3SIWkdVzZO3znhXXjSDXG+EuaR+G6/j/ TjoD397H3McEaZpLXNevJnZWEwH3RGfM507D6QgwHOWf9j359/u+PVCaIYjwVrNOgLYa 9V77yiJJcYSOflzJ1QcOuq6T2WpDiWlMRpUmJ0zrpCqcXB4HaPh0PKV8/PeXmoTX3/DV Y59Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kLyEM9zr; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-161042-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-161042-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id n9-20020a170902e54900b001e79bbfe7f1si17009324plf.262.2024.04.27.04.51.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Apr 2024 04:51:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-161042-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kLyEM9zr; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-161042-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-161042-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id BCCF4B23801 for ; Sat, 27 Apr 2024 11:47:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4683A4D5A0; Sat, 27 Apr 2024 11:47:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="kLyEM9zr" Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CA5A84AECA for ; Sat, 27 Apr 2024 11:47:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714218469; cv=none; b=gy9FkIdXconNFy5r0D2yh3u9/P4lbpSD5sXWW3IfZslKymHhaBMMEZQ/ZaeXbVztLEyOtOGdrHfpYAfTjshdK6xDqzbxZGVqQEb0/Rg/OYrzWuwQC4OjoJ1ZXgP4QcfJqT7kC5cPHo3RYL1vZnaRAjcYa1CDXEXhGdGuKtL5S+s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714218469; c=relaxed/simple; bh=m64OPA49saGqYh5NGoDkpU02HfGnplA/FI6YB5a3TLM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=J8FmMg/xp/arVKNbd6LXU8dYBcI6N5ODs5OEDJZdqgGxwGY6X70ppWscolspkgyUbMK+MKcxwCWNF584RbMEQRAktnmkxgIphP/028OtJz7x0AlqMmtOL4zuc9Lj/IkzT8hTsA/X0x2kHiuAKh74I6qLqKDCjo8tTVJHvode8mc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=kLyEM9zr; arc=none smtp.client-ip=209.85.210.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-6ed627829e6so3608939b3a.1 for ; Sat, 27 Apr 2024 04:47:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714218467; x=1714823267; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=HcfbaR8kZq8OLnUAT2pXDqoM8fNnWHLJf3IpXP9uecY=; b=kLyEM9zrTI5eK+RrsFYCyZNfXnKslK8ea/a25GIFfydplVvzKyR0Md5/lP5ykk5oSN Jla/CYOtU4BRZGno2UpHQDiNlYhZlV6BywABDhxhycRQN1ho/RwspwP662vtNSeBLfN7 MtOdtSd9Kwmv0bn+MkrK4N6TAVoxN+JJaD72cOW532e/nzTSz8PBGN+bYJRnzYKuigq3 KbMAGZyKFeLq5EFtDWMpO97KFib46La12GRkhe1eOoZ0oywWmauBCz77xD/WwsqCLtMt 3fRrX7QsZ8z5R4AsVq/V3VUMTKZEB5WlUgLkw2JVc130GynaS7xDR8W/YgX1wtHEo/rj HeVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714218467; x=1714823267; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=HcfbaR8kZq8OLnUAT2pXDqoM8fNnWHLJf3IpXP9uecY=; b=FBJcd1ApDfsXXZbDrik2QkAYqpgEN0l7GY6xdtlynU6TyYilPePYm6UMbbRWuy+Qcb MHe/wHAOEAxMU910pPsG+ohc1+HGc3jiiZzaXWvdfW396lVFqUbNVZT0prqv0nmijyvB QL7LICP4CErm8QWp6/FSDuEnHJQvcWW6aWJSUEB7qOfnXbtGSeb5uwiYNOdkW+Nyxntt qSsF4wXvqMB5TujX0SeOjFasFI+WiqD0k20gZgj6PPNLEzK8tdDXDcClQXmJEue6GpE1 eoRKKTkxtMJdfyzx3pbyI1n18sjJJXFQxcdzIDNxi+adR6sVvzsB0EpU7cEnibOHTCRZ uewg== X-Forwarded-Encrypted: i=1; AJvYcCU3jj0X3Rr0vLRXCNc3NI+q7EU/RDaQewll4cI5PhlXAjRtULH5vQcyPzNpHvrpYl08M/uM4udeQIC9yUI3d2B/UnPuvVcbvj87mFJ0 X-Gm-Message-State: AOJu0YzwpgOxUBHoCM86X0fpvJsD6xygsOmjSCMVZOLgKN7OqtWbJuuO 8k43ib329aNbRMsPEscaFku/0v6ftd272QFfZi+rMpZ050g7fUfR2DudU+mMXg== X-Received: by 2002:a17:90a:5d0e:b0:2af:f382:158b with SMTP id s14-20020a17090a5d0e00b002aff382158bmr4524138pji.49.1714218466853; Sat, 27 Apr 2024 04:47:46 -0700 (PDT) Received: from thinkpad ([117.213.97.210]) by smtp.gmail.com with ESMTPSA id l9-20020a17090a070900b002a528a1f907sm19257945pjl.56.2024.04.27.04.47.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Apr 2024 04:47:46 -0700 (PDT) Date: Sat, 27 Apr 2024 17:17:36 +0530 From: Manivannan Sadhasivam To: Frank Li Cc: Richard Zhu , Lucas Stach , Lorenzo Pieralisi , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Philipp Zabel , Liam Girdwood , Mark Brown , Krzysztof Kozlowski , Conor Dooley , linux-pci@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, devicetree@vger.kernel.org Subject: Re: [PATCH v3 11/11] PCI: imx6: Add i.MX8Q PCIe support Message-ID: <20240427114736.GO1981@thinkpad> References: <20240402-pci2_upstream-v3-0-803414bdb430@nxp.com> <20240402-pci2_upstream-v3-11-803414bdb430@nxp.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20240402-pci2_upstream-v3-11-803414bdb430@nxp.com> On Tue, Apr 02, 2024 at 10:33:47AM -0400, Frank Li wrote: > From: Richard Zhu > > Add i.MX8Q (i.MX8QM, i.MX8QXP and i.MX8DXL) PCIe support. > Add some info like IP version, PCIe Gen, how different the code support comparted to previous SoCs etc... > Signed-off-by: Richard Zhu > Signed-off-by: Frank Li > --- > drivers/pci/controller/dwc/pcie-imx.c | 54 +++++++++++++++++++++++++++++++++++ > 1 file changed, 54 insertions(+) > > diff --git a/drivers/pci/controller/dwc/pcie-imx.c b/drivers/pci/controller/dwc/pcie-imx.c > index 378808262d16b..af7c79e869e70 100644 > --- a/drivers/pci/controller/dwc/pcie-imx.c > +++ b/drivers/pci/controller/dwc/pcie-imx.c > @@ -30,6 +30,7 @@ > #include > #include > #include > +#include > #include > #include > > @@ -81,6 +82,7 @@ enum imx_pcie_variants { > IMX8MQ, > IMX8MM, > IMX8MP, > + IMX8Q, > IMX95, > IMX8MQ_EP, > IMX8MM_EP, > @@ -96,6 +98,7 @@ enum imx_pcie_variants { > #define IMX_PCIE_FLAG_HAS_PHY_RESET BIT(5) > #define IMX_PCIE_FLAG_HAS_SERDES BIT(6) > #define IMX_PCIE_FLAG_SUPPORT_64BIT BIT(7) > +#define IMX_PCIE_FLAG_CPU_ADDR_FIXUP BIT(8) > > #define imx_check_flag(pci, val) (pci->drvdata->flags & val) > > @@ -132,6 +135,7 @@ struct imx_pcie { > struct regmap *iomuxc_gpr; > u16 msi_ctrl; > u32 controller_id; > + u32 local_addr; > struct reset_control *pciephy_reset; > struct reset_control *apps_reset; > struct reset_control *turnoff_reset; > @@ -402,6 +406,10 @@ static void imx_pcie_configure_type(struct imx_pcie *imx_pcie) > if (!drvdata->mode_mask[id]) > id = 0; > > + /* If mode_mask is 0, means use phy driver to set mode */ > + if (!drvdata->mode_mask[id]) > + return; There is already a check above for 0 mode_mask. Please consolidate. > + > mask = drvdata->mode_mask[id]; > val = mode << (ffs(mask) - 1); > > @@ -957,6 +965,7 @@ static void imx_pcie_ltssm_enable(struct device *dev) > struct imx_pcie *imx_pcie = dev_get_drvdata(dev); > const struct imx_pcie_drvdata *drvdata = imx_pcie->drvdata; > > + phy_set_speed(imx_pcie->phy, PCI_EXP_LNKCAP_SLS_2_5GB); > if (drvdata->ltssm_mask) > regmap_update_bits(imx_pcie->iomuxc_gpr, drvdata->ltssm_off, drvdata->ltssm_mask, > drvdata->ltssm_mask); > @@ -969,6 +978,7 @@ static void imx_pcie_ltssm_disable(struct device *dev) > struct imx_pcie *imx_pcie = dev_get_drvdata(dev); > const struct imx_pcie_drvdata *drvdata = imx_pcie->drvdata; > > + phy_set_speed(imx_pcie->phy, 0); > if (drvdata->ltssm_mask) > regmap_update_bits(imx_pcie->iomuxc_gpr, drvdata->ltssm_off, > drvdata->ltssm_mask, 0); > @@ -1104,6 +1114,12 @@ static int imx_pcie_host_init(struct dw_pcie_rp *pp) > goto err_clk_disable; > } > > + ret = phy_set_mode_ext(imx_pcie->phy, PHY_MODE_PCIE, PHY_MODE_PCIE_RC); > + if (ret) { > + dev_err(dev, "unable to set pcie PHY mode\n"); > + goto err_phy_off; > + } This is not i.MX8Q specific. Please add it in a separate patch. > + > ret = phy_power_on(imx_pcie->phy); > if (ret) { > dev_err(dev, "waiting for PHY ready timeout!\n"); > @@ -1154,6 +1170,28 @@ static void imx_pcie_host_exit(struct dw_pcie_rp *pp) > regulator_disable(imx_pcie->vpcie); > } > > +static u64 imx_pcie_cpu_addr_fixup(struct dw_pcie *pcie, u64 cpu_addr) > +{ > + struct imx_pcie *imx_pcie = to_imx_pcie(pcie); > + struct dw_pcie_ep *ep = &pcie->ep; > + struct dw_pcie_rp *pp = &pcie->pp; > + struct resource_entry *entry; > + unsigned int offset; > + > + if (!(imx_pcie->drvdata->flags & IMX_PCIE_FLAG_CPU_ADDR_FIXUP)) This flag should be documented in the commit message. > + return cpu_addr; > + > + if (imx_pcie->drvdata->mode == DW_PCIE_EP_TYPE) { > + offset = ep->phys_base; > + } else { > + entry = resource_list_first_type(&pp->bridge->windows, > + IORESOURCE_MEM); Check for NULL entry. > + offset = entry->res->start; > + } > + > + return (cpu_addr + imx_pcie->local_addr - offset); > +} > + > static const struct dw_pcie_host_ops imx_pcie_host_ops = { > .init = imx_pcie_host_init, > .deinit = imx_pcie_host_exit, > @@ -1162,6 +1200,7 @@ static const struct dw_pcie_host_ops imx_pcie_host_ops = { > static const struct dw_pcie_ops dw_pcie_ops = { > .start_link = imx_pcie_start_link, > .stop_link = imx_pcie_stop_link, > + .cpu_addr_fixup = imx_pcie_cpu_addr_fixup, > }; > > static void imx_pcie_ep_init(struct dw_pcie_ep *ep) > @@ -1481,6 +1520,12 @@ static int imx_pcie_probe(struct platform_device *pdev) > "Failed to get PCIEPHY reset control\n"); > } > > + if (imx_check_flag(imx_pcie, IMX_PCIE_FLAG_CPU_ADDR_FIXUP)) { > + ret = of_property_read_u32(node, "fsl,local-address", &imx_pcie->local_addr); > + if (ret) > + return dev_err_probe(dev, ret, "Failed to get local-address"); Is it OK to continue? - Mani -- மணிவண்ணன் சதாசிவம்