Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp4154732pxb; Mon, 27 Sep 2021 10:30:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwnwmSp4vqDtva53bC54OA1clAGreMpTVPLty8AUUD7wjf321SrZTCkQ+9K2SoSD+74SkuM X-Received: by 2002:a17:902:9f87:b0:13d:fc14:f6c3 with SMTP id g7-20020a1709029f8700b0013dfc14f6c3mr980813plq.55.1632763813282; Mon, 27 Sep 2021 10:30:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632763813; cv=none; d=google.com; s=arc-20160816; b=j+naDLupxDWYzmz79b0nN8Q/VVxct2b/w3bthwj7MeAsMH6ElGqP4k1XK7hVFp5Xo4 uSrHQEsz+bIuzwwEChIYjVjPAigW9nGX3DL9bGXODzdMzDe/OjUwf19/WdjGRSC6Nntn DBub6gmKcnGPPu+ArkA8oMO4QYphC9dSeJwQvBqXif8bQmDl9fDAm8CBmsH13uvg3W8Z iBe5XQyQvfmqOmcyeYXvr06huQ/MbZ2atqJQXYCb5xdRTfEm5rX254yCPlzlxpTG0j16 uOOwqlopY9HvvlQzMY5ZqjHJoC53PG0oK187gXiGhCxb3R80bLX7ayjwmQQSPJ4CQQDM EefA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature; bh=e1aoIVYfnRUgfqpcWntY8WUt/fmMXdbNNFkPf2T5YXo=; b=FTa2EQfgMybZ/7wY/jwwAihHwHEJ/MJFPKHSbJRXQ/UqXIDxIKG5qVjIY05YEdIYv3 YcRJezFzOIsrjMjQoSA3ZUhGCvH1FEi/jrby7c1hkvEEB6+277IdxS6XcLBSw2BjnISb i72lKRiWMostgLmYwF9Ejw7UmB4gKub357NYR33NDyNxv4aq3TyJ1P3xt3tnX6bVNsNU UWIQ4bRGJ9ANQYLPWDbX22l0CUHwu0NEbSbZHvr2vYHucHP/IBea9PVIWJsaDkn/Aiig BqxbKSUDVjp5VLVONTl+FdmvG7FbH6lBOkdlYpH/p9MREaqXJWNxJIOBcKk8ELDepXfU xy5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=P5L1Zpil; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j1si20298083plr.208.2021.09.27.10.29.59; Mon, 27 Sep 2021 10:30:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=P5L1Zpil; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237163AbhI0Rav (ORCPT + 99 others); Mon, 27 Sep 2021 13:30:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:41016 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238019AbhI0R0P (ORCPT ); Mon, 27 Sep 2021 13:26:15 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 82FB160E08; Mon, 27 Sep 2021 17:16:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1632762995; bh=fiFXcjAyr/xbXvMc5MGt+1jLB423H4t84TnDpKWaMik=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=P5L1ZpilVa8FWpVdXv+LcxwmF4pAThXyw9LbPnxzSqk34x5HsQKMngUyiQ6TV/WDw 0oL3V+UbXcrKOqk+62vEypWryPX4oSQHXNp/Vd2rgq+YbZTMXTZS8Se9KY2uE/OXEW ACAcBD1Bc5J8lA/55oY/22TRuUTw13vfwd9ZjSw/w/7FsFxWyr26X8kQvwBtqugDZw up79h8bkFPqU234Zjsg9ccWWJ3QlXSJk42E7LErMoQgT39J3jDtB+gxCV5xHMHkUdR Z4/BtEkEVeHXSthBOyKwSYPSxa3SYrh210IZlDnvuw/BjJWSlJKKPeMkJLKjGCI8oW Kc5CurkAwpOdg== Date: Mon, 27 Sep 2021 12:16:34 -0500 From: Bjorn Helgaas To: Matthias Schiffer Cc: Richard Zhu , Lucas Stach , Shawn Guo , Sascha Hauer , Lorenzo Pieralisi , Rob Herring , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , Bjorn Helgaas , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Markus Niebel Subject: Re: [RFC] PCI: imx6: add support for internal oscillator on i.MX7D Message-ID: <20210927171634.GA658570@bhelgaas> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <81c77a29362433fc5629ada442f0489046ce1051.1632319151.git.matthias.schiffer@ew.tq-group.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 24, 2021 at 10:05:15AM +0200, Matthias Schiffer wrote: > Adds support for a DT property fsl,internal-osc to select the internal > oscillator for the PCIe PHY. If you repost this, please update the subject to match the conventions (use "git log --oneline drivers/pci/controller/dwc/pci-imx6.c" and note capitalization). > Signed-off-by: Matthias Schiffer > Cc: Markus Niebel > --- > > Okay, so while this patch is nice and short, I'm note sure if it's a good > solution, hence I submit it as an RFC. It is roughly based on code from > older linux-imx versions [1] - although it seems this feature was never > supported on i.MX7D even by linux-imx (possibly because of compliance > issues with the internal clock, however I haven't found a definitive > erratum backing this), but only on other SoC like i.MX6QP. > > The device tree binding docs of the driver are somewhat lacking, but > looking at [1] it seems that an external reference clock takes the place of > the "pcie_bus" clock - various pieces of the driver skip enabling/disabling > this clock when an external clock is configured. > > From this I've come to the conclusion that the clock settings in > imx7d.dtsi do not really make sense: The pcie_bus clock is configured to > PLL_ENET_MAIN_100M_CLK, but this seems wrong for both internal and > external reference clocks: > > - For the internal clock, the correct clock should be PCIE_PHY_ROOT_CLK > according to the reference manual > - The external clocks, this should refer to an actual external clock, or > possibly a fixed-clock node > > I would be great if someone with more insight into this could chime in > and tell me if my reasoning here is correct or not. > > Unfortunately I only have our MBa7x at my disposal for further > experimentation. This board does not have an external reference clock for > the PCIe PHY, so I cannot test the behaviour for settings that use an > external clock. Without this patch (and adding the new flag to the MBa7x > DTS), the boot will hang while waiting for the PCIe link to come up. > > So, for the actual question (given that my thoughts above make any sense): > How do we want to implement this? > > 1. A simple boolean flag, like this patch provides > 2. Allow Device Trees not to specify a "pcie_bus" clock at all, meaning > it should use the internal clock > 3. Special handling when the "pcie_bus" clock is configured to > PCIE_PHY_ROOT_CLK - is such a thing even possible, or is this > breaking the clock driver's abstraction too much? > 4. Something more involved, with a proper clock sel as the source for > "pcie_bus" > > Solution 4. seems difficult to implement nicely, as the PCIe driver > also fiddles with IMX7D_GPR12_PCIE_PHY_REFCLK_SEL for power management: > the clock selection is switched back to the internal clock in > imx6_pcie_clk_disable(), which also disables its source PCIE_PHY_ROOT_CLK, > effectively gating the clock. > > Regards, > Matthias > > > [1] https://source.codeaurora.org/external/imx/linux-imx/tree/drivers/pci/host/pci-imx6.c?h=imx_4.1.15_2.0.0_ga > > drivers/pci/controller/dwc/pci-imx6.c | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c > index 80fc98acf097..021499b9ee7c 100644 > --- a/drivers/pci/controller/dwc/pci-imx6.c > +++ b/drivers/pci/controller/dwc/pci-imx6.c > @@ -83,6 +83,7 @@ struct imx6_pcie { > struct regulator *vpcie; > struct regulator *vph; > void __iomem *phy_base; > + bool internal_osc; Prefer bitfield ("unsigned int internal_osc:1") over bool in structs. > /* power domain for pcie */ > struct device *pd_pcie; > @@ -637,7 +638,9 @@ static void imx6_pcie_init_phy(struct imx6_pcie *imx6_pcie) > break; > case IMX7D: > regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, > - IMX7D_GPR12_PCIE_PHY_REFCLK_SEL, 0); > + IMX7D_GPR12_PCIE_PHY_REFCLK_SEL, > + imx6_pcie->internal_osc ? > + IMX7D_GPR12_PCIE_PHY_REFCLK_SEL : 0); > break; > case IMX6SX: > regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, > @@ -1130,6 +1133,9 @@ static int imx6_pcie_probe(struct platform_device *pdev) > &imx6_pcie->tx_swing_low)) > imx6_pcie->tx_swing_low = 127; > > + if (of_property_read_bool(node, "fsl,internal-osc")) > + imx6_pcie->internal_osc = true; > + > /* Limit link speed */ > pci->link_gen = 1; > ret = of_property_read_u32(node, "fsl,max-link-speed", &pci->link_gen); > -- > 2.17.1 >