From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (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 A7FC06F31E for ; Sun, 19 Jan 2025 07:02:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737270176; cv=none; b=hcaySzJzzyG7e4Zj4iZz2x7O2BRvgmejmzJ403MPHqh9FOOKZ+UeZ5X3Xgc5nh7pmS0AwJ3PpH9euLI0bBcDxPZoRs+bQG9YbYVQ4KXSfJV1VSt7giCBcPRQOugMko12AQpc/WK/0NUKD63FiP8vpCWRFhJEe+A5l8NWrW60ROs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737270176; c=relaxed/simple; bh=9Uyh20Bo/JCrzKWgQJoe3V6rjzekT4NllWMa1CNe8Dc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=mx6ICw15kz+QfwzM3mnXEKa/ZCavY7CtXDKCoeUZjnUhn8YGDFg+tlmD5a7Rs/zrgKFod9jtPXuG73DHX4nhJUgT9usGaNH451tRl0JzExBls4khU5acWshjr27vPJCO/rjRoKBop3suga949Hu9CFOQlRQwBQxhXS9eokyJmwQ= 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=m4xguhQA; arc=none smtp.client-ip=209.85.214.169 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="m4xguhQA" Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-2166360285dso66987885ad.1 for ; Sat, 18 Jan 2025 23:02:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1737270174; x=1737874974; 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=vMJ3GX6dkOYZdUXVc1wm3huqORVLg1qLuaKka3o+Bqk=; b=m4xguhQA6zslWXCZ5CAn+/vmjYGO3NoYP0VoMkFvompl8Lau2cJ4gmWpTXhMGyVSv7 vsBFlgUejqWLwKdhcSrGggJ4XCDC9O1Ng3aci/ZLtqulrOvK7QR6e50ezOxo42hImoTs SirAHKYEEokNYVLadGULUGttsMDvvqCkaV3ul9LBaVVpQsBAHyTkhnQS8Rt1+KfIItB6 KnYjpOReHHKbJJd5iQp8EnmxGBibKtExd3pBEk8WUg1zP1lK6HPKc5gtdixOxTOA5oJU II1QaRGhBQLwLztPpob1TMWZd9Y7bBYj6SOIs9shmrEyQ5OkzixGyL1rJ+5WC0O4p5Hq d6LQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737270174; x=1737874974; 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=vMJ3GX6dkOYZdUXVc1wm3huqORVLg1qLuaKka3o+Bqk=; b=jG3m1vobr4KZ0lswcETPd6+Sns1noTudvrPCJ//JKqPpwcxB6m+GpVMTFCKCPN6VV2 YJrW9XAAwwTdbL9XL7jOCLXWVHwPx2eiavZHy4qKHP8p2ugTbLRxsOHUhFPWzE49eujL JKiq4Xf98rxt5FXbSaLLgT6jfz1zQ3woAJjX+xOu0E18nQccShxuWvYDFaAjqhaSZ0La gmua88GmzTZfR22bbmuHf66d50VHQJ/xdheBHJkaRxckeZZkm85flkFM/C5viJAsK5tW EmRdVbf03xVyZtU/ZMqt32iKVFn8KiFBLrpjHFqqND+sFMar7RB7Z9tdqGppVyjlRzau 2Gnw== X-Forwarded-Encrypted: i=1; AJvYcCWF91/3nAYWMncPInErPUxMbVUCYU3e3MrLv3U54VY+vPxNGP8b5dl8MZD6WvAwYWCNF+ILSNsej6WBK/M=@vger.kernel.org X-Gm-Message-State: AOJu0Yyw3fSowkT9cCqMwPZwoTwYU8A0oaCCYarNyhCzzW8gMgRp7Khk f7sVK4wiFsmDu+irU80hATemgWafUz8WDPAXMgRvskrJB+D+Gu14zRYU3D4Cww== X-Gm-Gg: ASbGncuBE9wS+YNu3WDX0rQqLn8Nth1iElSUf6bYmo+8i+p5JvmyOtmCsFkJ7AP+gGt 2HzyCloQnIrTKIAxuk4Vy5tbxzML/TVNaHWcgDITVkz69J2aGmSPJxWI19aUENOBrkA5nnIKtWq tUuZ5oaucm2vDw7sJ2M2VRttZVWyuyMa3I5Z2ldr2MRbyh+ul7XVT+d6/3PbmEsIgZjqAoD15yU EOBVP3jNGbVfD8rVRC0/RxSPBCpV6T05nNquiC9iym0c+4kCojGc4U9bq/Wz8Up3WxejwkkKX7R oJWOcA== X-Google-Smtp-Source: AGHT+IEeTs48whwEN7rNg39TN9hpGQKSWq0W/VdR6tyAMeUyYliEEBAyt6ics9gbcWZ/8208wLwfuw== X-Received: by 2002:a17:903:22cb:b0:21b:d105:26a5 with SMTP id d9443c01a7336-21c355becd3mr125597245ad.38.1737270173884; Sat, 18 Jan 2025 23:02:53 -0800 (PST) Received: from thinkpad ([120.56.195.253]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21c2d3dd93esm40763455ad.164.2025.01.18.23.02.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Jan 2025 23:02:53 -0800 (PST) Date: Sun, 19 Jan 2025 12:32:46 +0530 From: Manivannan Sadhasivam To: Richard Zhu Cc: l.stach@pengutronix.de, bhelgaas@google.com, lpieralisi@kernel.org, kw@linux.com, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, shawnguo@kernel.org, frank.li@nxp.com, s.hauer@pengutronix.de, festevam@gmail.com, imx@lists.linux.dev, kernel@pengutronix.de, linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v7 02/10] PCI: imx6: Add ref clock for i.MX95 PCIe Message-ID: <20250119070246.yfxogn4vv3jqfvzb@thinkpad> References: <20241126075702.4099164-1-hongxing.zhu@nxp.com> <20241126075702.4099164-3-hongxing.zhu@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: <20241126075702.4099164-3-hongxing.zhu@nxp.com> On Tue, Nov 26, 2024 at 03:56:54PM +0800, Richard Zhu wrote: > Add "ref" clock to enable reference clock. To avoid breaking DT > backwards compatibility, i.MX95 REF clock might be optional. Use > devm_clk_get_optional() to fetch i.MX95 PCIe optional clocks in driver. > > If use external clock, ref clock should point to external reference. > > If use internal clock, CREF_EN in LAST_TO_REG controls reference output, > which implement in drivers/clk/imx/clk-imx95-blk-ctl.c. > > Signed-off-by: Richard Zhu > Reviewed-by: Frank Li > --- > drivers/pci/controller/dwc/pci-imx6.c | 16 +++++++++++----- > 1 file changed, 11 insertions(+), 5 deletions(-) > > diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c > index 385f6323e3ca..f7e928e0a018 100644 > --- a/drivers/pci/controller/dwc/pci-imx6.c > +++ b/drivers/pci/controller/dwc/pci-imx6.c > @@ -103,6 +103,7 @@ struct imx_pcie_drvdata { > const char *gpr; > const char * const *clk_names; > const u32 clks_cnt; > + const u32 clks_optional_cnt; > const u32 ltssm_off; > const u32 ltssm_mask; > const u32 mode_off[IMX_PCIE_MAX_INSTANCES]; > @@ -1306,9 +1307,8 @@ static int imx_pcie_probe(struct platform_device *pdev) > struct device_node *np; > struct resource *dbi_base; > struct device_node *node = dev->of_node; > - int ret; > + int i, ret, req_cnt; > u16 val; > - int i; > > imx_pcie = devm_kzalloc(dev, sizeof(*imx_pcie), GFP_KERNEL); > if (!imx_pcie) > @@ -1358,9 +1358,13 @@ static int imx_pcie_probe(struct platform_device *pdev) > imx_pcie->clks[i].id = imx_pcie->drvdata->clk_names[i]; > > /* Fetch clocks */ > - ret = devm_clk_bulk_get(dev, imx_pcie->drvdata->clks_cnt, imx_pcie->clks); > + req_cnt = imx_pcie->drvdata->clks_cnt - imx_pcie->drvdata->clks_optional_cnt; > + ret = devm_clk_bulk_get(dev, req_cnt, imx_pcie->clks); > if (ret) > return ret; > + imx_pcie->clks[req_cnt].clk = devm_clk_get_optional(dev, "ref"); > + if (IS_ERR(imx_pcie->clks[req_cnt].clk)) > + return PTR_ERR(imx_pcie->clks[req_cnt].clk); I think you should just switch to devm_clk_bulk_get_all() instead of getting the clks separately. As I told previously, the DT binding should ensure that correct clocks for the platforms are defined in DT and the driver has no business in validating it. Driver should trust the DT instead (unless there is a valid reason to not do so). > > if (imx_check_flag(imx_pcie, IMX_PCIE_FLAG_HAS_PHYDRV)) { > imx_pcie->phy = devm_phy_get(dev, "pcie-phy"); > @@ -1509,6 +1513,7 @@ static const char * const imx8mm_clks[] = {"pcie_bus", "pcie", "pcie_aux"}; > static const char * const imx8mq_clks[] = {"pcie_bus", "pcie", "pcie_phy", "pcie_aux"}; > static const char * const imx6sx_clks[] = {"pcie_bus", "pcie", "pcie_phy", "pcie_inbound_axi"}; > static const char * const imx8q_clks[] = {"mstr", "slv", "dbi"}; > +static const char * const imx95_clks[] = {"pcie_bus", "pcie", "pcie_phy", "pcie_aux", "ref"}; And these static clock defines will go away too. - Mani -- மணிவண்ணன் சதாசிவம்