Received: by 2002:a05:7412:98c1:b0:fa:551:50a7 with SMTP id kc1csp962534rdb; Sat, 6 Jan 2024 19:04:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IHefSnjSDsmoBKlZuaL5HW4dgKTwW7fNAggO057uoIoqr0hsAWHDMZYK26lhQJiM7Yi6Od0 X-Received: by 2002:a05:6808:171b:b0:3bc:35d2:2ad7 with SMTP id bc27-20020a056808171b00b003bc35d22ad7mr1884841oib.70.1704596684370; Sat, 06 Jan 2024 19:04:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704596684; cv=none; d=google.com; s=arc-20160816; b=Pol33GtPmn1P0/qOcLsDK1THyzKPtUIrTuFK8SYrAGS8UFNRjoHbnZe2f9meCpnsIT SNspLsGTgmAbIeg4o0TIzLMUOaT77C8Vhk5kkriFI8dOzGpisuSmsG1aDrYhX8wQ+KcE Iiya+N9VBd6AJnNBQrBCsSlRPgFgd/HqhGjTNJ8WLcGqoBdKfIkX3u+IExzoW15nahws GjIbYqPfP4slrgANdceHg7+OIwY1iz/GpNbEFneyam7uS5SsM35OUFOW+2v9s3gD5uaF ZWs0bH3tPadZxCFandionK3r4yjQ6f+Fa7WfSKRSz6XlsoIAKHPtmMaS/UEPNNjuSEFL xj1w== ARC-Message-Signature: i=1; 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=7sp8lR8fVruy7aXHQIvUQeGshhQgsSFVGSZnezGwNmY=; fh=RV+5nlnE/mfkEDo+RaR4UWqJM0xfpxots2QhFlTS3j8=; b=Eu5Ek9cpINis4hf6myQpM8IcgJHgH1gxIvK8QumwS6nVXmkX0r6WvcrxVHC4YKsGJu 3bDyyb6wy5LyTIeZLeenxLxCAa+s/hyW0GTTUUQb/mX59KmEF2ILOk6VEM542ojOq4QY 4jrXrj0sgvvZMOy70mI1a3fqhGC/9PsUCqwdi/997wyAo82ftosK0mOo1LNvLWyJP6XD l84ldW8ULB4RJ6HM9wgdIa6vnuGm/ccsTS7aQXM2LkYDy4UFb1AQRhaZPNPwljXyFIoQ SoedTR4RUd3iIx1SvOR+aJizvDIz+UXVTmoIhSLIUQB1tXD1w4OugfXiAHA/my+IDhYh WxKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=trsqn+69; spf=pass (google.com: domain of linux-kernel+bounces-18769-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18769-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 gu24-20020a056a004e5800b006d9bb8e2bbdsi3853189pfb.391.2024.01.06.19.04.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Jan 2024 19:04:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-18769-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=trsqn+69; spf=pass (google.com: domain of linux-kernel+bounces-18769-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18769-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 12A46B21B2A for ; Sun, 7 Jan 2024 03:04:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8B7AF10A30; Sun, 7 Jan 2024 03:04:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="trsqn+69" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-io1-f41.google.com (mail-io1-f41.google.com [209.85.166.41]) (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 97FBF11197 for ; Sun, 7 Jan 2024 03:04:26 +0000 (UTC) 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-io1-f41.google.com with SMTP id ca18e2360f4ac-7ba9f24acf8so57396239f.2 for ; Sat, 06 Jan 2024 19:04:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704596665; x=1705201465; 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=7sp8lR8fVruy7aXHQIvUQeGshhQgsSFVGSZnezGwNmY=; b=trsqn+69/KBjyv6kERwrkPT0Gwa34PZhazAJhGY/OKP2mmsVMb6TYsCNfkCugxV2EV 8KaCDs0yBB/2s6ax5zqVhYEEq83kQ1R7o2o+t6qBTi01qi8Fz81Nu0sB5UHmiPQbnvIQ IkRDq9M60ZkyMw5/Ts4YMxILB5eAZ1Lx6zUcN+gfEIK1CocABD/7oYsLrc51R4vH2LJC pO1Hndme0VJxQf868mzVKio1PbVT/aNHLmzgsfkTO3NQs8Ys0KPNNCCyYNmfsnZ/ZI3L 8ZpYm1svvF4U3O4KSZ6WKoSQfE0Z7uE1M4lCN58vAdD96VJjkqlkP4v9DG8nbu4YLYrL pCzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704596665; x=1705201465; 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=7sp8lR8fVruy7aXHQIvUQeGshhQgsSFVGSZnezGwNmY=; b=WlWKmZ9uznmZCE0RVP25JTD7K0vmx1DrubLW+oF2s0eWk7IxexXkIv20QF2ycSIA9T UKa+sGGPwsyHq91KTC/gNnhqEp9ODTcLPRorOYEERqi2/I7AHkVNuPzd03Ch+bdBNoz4 i2WU/Ikep5uMsLAVm+LXTdKLTS/yADbjoM71qQugvJHLDzTFgo7gj8TERYnSeX6lauDg eVLQWVZKDkY78DPPuooqC55tIyx27MH23MWpGiE/DKC1p74GW7R7bEAOcfEfqN6Y/jV5 cXpmZ2CYJTv2Kqiix5arQeUdieqBlzpmgLbT5FLBB/q7PhTJjbkQ+tJAURTMxfBZsDt0 egGA== X-Gm-Message-State: AOJu0Yz//Ig/Vkaj7lim1bdJD58HQi09/UIOsyMjeC/GnkpPrhU5jcrB qQZ5SygQD4A8zaEUoHRAW4/QK4AZu9Fy X-Received: by 2002:a05:6e02:32c3:b0:35f:ff8c:7a31 with SMTP id bl3-20020a056e0232c300b0035fff8c7a31mr3406835ilb.65.1704596665631; Sat, 06 Jan 2024 19:04:25 -0800 (PST) Received: from thinkpad ([103.197.115.97]) by smtp.gmail.com with ESMTPSA id w22-20020a1709029a9600b001d35223d0besm3675636plp.251.2024.01.06.19.04.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Jan 2024 19:04:25 -0800 (PST) Date: Sun, 7 Jan 2024 08:34:18 +0530 From: Manivannan Sadhasivam To: Frank Li Cc: krzysztof.kozlowski@linaro.org, bhelgaas@google.com, conor+dt@kernel.org, devicetree@vger.kernel.org, festevam@gmail.com, helgaas@kernel.org, hongxing.zhu@nxp.com, imx@lists.linux.dev, kernel@pengutronix.de, krzysztof.kozlowski+dt@linaro.org, kw@linux.com, l.stach@pengutronix.de, linux-arm-kernel@lists.infradead.org, linux-imx@nxp.com, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, lpieralisi@kernel.org, robh@kernel.org, s.hauer@pengutronix.de, shawnguo@kernel.org Subject: Re: [PATCH v7 02/16] PCI: imx6: Simplify phy handling by using by using IMX6_PCIE_FLAG_HAS_PHY Message-ID: <20240107030418.GB3416@thinkpad> References: <20231227182727.1747435-1-Frank.Li@nxp.com> <20231227182727.1747435-3-Frank.Li@nxp.com> <20240106153323.GE2512@thinkpad> 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: On Sat, Jan 06, 2024 at 11:50:28AM -0500, Frank Li wrote: > On Sat, Jan 06, 2024 at 09:03:23PM +0530, Manivannan Sadhasivam wrote: > > On Wed, Dec 27, 2023 at 01:27:13PM -0500, Frank Li wrote: > > > Refactors the phy handling logic in the imx6 PCI driver by adding > > > IMX6_PCIE_FLAG_HAS_PHY bitmask define for drvdata::flags. > > > > > > The drvdata::flags and a bitmask ensures a cleaner and more scalable > > > switch-case structure for handling phy. > > > > > > Signed-off-by: Frank Li > > > --- > > > > > > Notes: > > > Change from v4 to v5: > > > - none, Keep IMX6_PCIE_FLAG_HAS_PHY to indicate dts mismatch when platform > > > require phy suppport. > > > > > > Change from v1 to v3: > > > - none > > > > > > drivers/pci/controller/dwc/pci-imx6.c | 23 ++++++++++++++++------- > > > 1 file changed, 16 insertions(+), 7 deletions(-) > > > > > > diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c > > > index 50d9faaa17f71..4d620249f3d52 100644 > > > --- a/drivers/pci/controller/dwc/pci-imx6.c > > > +++ b/drivers/pci/controller/dwc/pci-imx6.c > > > @@ -60,6 +60,9 @@ enum imx6_pcie_variants { > > > #define IMX6_PCIE_FLAG_IMX6_PHY BIT(0) > > > #define IMX6_PCIE_FLAG_IMX6_SPEED_CHANGE BIT(1) > > > #define IMX6_PCIE_FLAG_SUPPORTS_SUSPEND BIT(2) > > > +#define IMX6_PCIE_FLAG_HAS_PHY BIT(3) > > > > Every PCIe setup requires PHY for its operation. Perhaps you are referring to > > external PHY? If so, please rename this to IMX6_PCIE_FLAG_HAS_EXT_PHY. > > Actually, it means use phy driver. How about using IMX6_PCIE_HAS_PHYDRV? > Ah, ok. Yes, this makes sense. - Mani > > > > > + > > > +#define imx6_check_flag(pci, val) (pci->drvdata->flags & val) > > > > > > #define IMX6_PCIE_MAX_CLKS 6 > > > > > > @@ -1277,6 +1280,13 @@ static int imx6_pcie_probe(struct platform_device *pdev) > > > if (ret) > > > return ret; > > > > > > + if (imx6_check_flag(imx6_pcie, IMX6_PCIE_FLAG_HAS_PHY)) { > > > > IMO, we would not need these kind of checks in the driver if the DT binding is > > properly validated using schema. But folks always want to validate "broken DT" > > in the drivers :( > > > > But I'm fine with this check for now since not everyone agree with above. > > > > - Mani > > > > > + imx6_pcie->phy = devm_phy_get(dev, "pcie-phy"); > > > + if (IS_ERR(imx6_pcie->phy)) > > > + return dev_err_probe(dev, PTR_ERR(imx6_pcie->phy), > > > + "failed to get pcie phy\n"); > > > + } > > > + > > > switch (imx6_pcie->drvdata->variant) { > > > case IMX7D: > > > if (dbi_base->start == IMX8MQ_PCIE2_BASE_ADDR) > > > @@ -1306,11 +1316,6 @@ static int imx6_pcie_probe(struct platform_device *pdev) > > > return dev_err_probe(dev, PTR_ERR(imx6_pcie->apps_reset), > > > "failed to get pcie apps reset control\n"); > > > > > > - imx6_pcie->phy = devm_phy_get(dev, "pcie-phy"); > > > - if (IS_ERR(imx6_pcie->phy)) > > > - return dev_err_probe(dev, PTR_ERR(imx6_pcie->phy), > > > - "failed to get pcie phy\n"); > > > - > > > break; > > > default: > > > break; > > > @@ -1444,13 +1449,15 @@ static const struct imx6_pcie_drvdata drvdata[] = { > > > }, > > > [IMX8MM] = { > > > .variant = IMX8MM, > > > - .flags = IMX6_PCIE_FLAG_SUPPORTS_SUSPEND, > > > + .flags = IMX6_PCIE_FLAG_SUPPORTS_SUSPEND | > > > + IMX6_PCIE_FLAG_HAS_PHY, > > > .gpr = "fsl,imx8mm-iomuxc-gpr", > > > .clk_names = {"pcie_bus", "pcie", "pcie_aux"}, > > > }, > > > [IMX8MP] = { > > > .variant = IMX8MP, > > > - .flags = IMX6_PCIE_FLAG_SUPPORTS_SUSPEND, > > > + .flags = IMX6_PCIE_FLAG_SUPPORTS_SUSPEND | > > > + IMX6_PCIE_FLAG_HAS_PHY, > > > .gpr = "fsl,imx8mp-iomuxc-gpr", > > > .clk_names = {"pcie_bus", "pcie", "pcie_aux"}, > > > }, > > > @@ -1462,12 +1469,14 @@ static const struct imx6_pcie_drvdata drvdata[] = { > > > }, > > > [IMX8MM_EP] = { > > > .variant = IMX8MM_EP, > > > + .flags = IMX6_PCIE_FLAG_HAS_PHY, > > > .mode = DW_PCIE_EP_TYPE, > > > .gpr = "fsl,imx8mm-iomuxc-gpr", > > > .clk_names = {"pcie_bus", "pcie", "pcie_aux"}, > > > }, > > > [IMX8MP_EP] = { > > > .variant = IMX8MP_EP, > > > + .flags = IMX6_PCIE_FLAG_HAS_PHY, > > > .mode = DW_PCIE_EP_TYPE, > > > .gpr = "fsl,imx8mp-iomuxc-gpr", > > > .clk_names = {"pcie_bus", "pcie", "pcie_aux"}, > > > -- > > > 2.34.1 > > > > > > > -- > > மணிவண்ணன் சதாசிவம் -- மணிவண்ணன் சதாசிவம்