Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp3319836rwb; Fri, 30 Sep 2022 01:37:10 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7UlKGeLRHCnTOhWRoxTxUNwxsyWtHBgVQ7HKVXtqfCc49z9BbzyQ/v/JgDkZAICO3z1HLa X-Received: by 2002:aa7:d944:0:b0:458:7e3f:abc2 with SMTP id l4-20020aa7d944000000b004587e3fabc2mr1986649eds.22.1664527030311; Fri, 30 Sep 2022 01:37:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664527030; cv=none; d=google.com; s=arc-20160816; b=YPIqFDOQzvo5kLh2MYdMdjvZVend85IRHgvRq109+TnJwDuxavOF9LQyTGPnKjvA3D bfaL3YjLEFN8nNRMVc+4PUUO8vCF7etxpDm756e/dk9rur32ZFk3lzbajk/ZBuik5GZb kS3P+2qgPhGpr/yz+UP/lVPzfzPctxgWV5yNRMmQ8zzVBEouO1I9Y2GnjMsRsbTXz0Xu +MCwehQ881sjME0gQkaMclM6fvLA0C1QBgV60uDgOWc5h3wxfmxkcD2vjzR+NcvnxQDA 6pSLiBzdW0KunFfT0mRPMFh/bEP9h3Uazry/m6l8omZPUbsvAtVFeV7YpJfgvqBAzu36 sA/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :content-language:references:cc:to:subject:from:user-agent :mime-version:date:message-id; bh=MTyQe2uyd/nN6KIvtX8tC3TmRoWNFePtxNEoBogNp6k=; b=Mh0z5s1edrNgrJ6XMNvrw21M42ia/AoojLQ8cEk2nTFv9fu0TTEWqZYl7rddZbmc2K FUyYNopDLbBPmqC83bMgAOptUe8mIpgC8cyZR44Lvwu1PZH+TZWWi3yGU5ZLoe7+m//d c0X4LL2sG6B0Gz5+o08VFw70iBboEEIUoS/IkYyaiu9t88+/wNQuH45XeWLcSlCkWyWi LvChVl4qzF4zV8BA1BbHKQjD93SGtzsZihWQx9Hc7t4Z5VkBd+L8/7R4TUMZC5VtYbjA REAX3Mkpem/ckQjHe8V1NtBt5CkuDHiynHsyEqUHrdpNmwqm7aETLfumAAIMjQOfSi+r LB7g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id oz43-20020a1709077dab00b00741a17b9d20si1296225ejc.536.2022.09.30.01.36.45; Fri, 30 Sep 2022 01:37:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229547AbiI3I3Z (ORCPT + 99 others); Fri, 30 Sep 2022 04:29:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231175AbiI3I3W (ORCPT ); Fri, 30 Sep 2022 04:29:22 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A792417F565 for ; Fri, 30 Sep 2022 01:29:21 -0700 (PDT) Received: from ptz.office.stw.pengutronix.de ([2a0a:edc0:0:900:1d::77] helo=[127.0.0.1]) by metis.ext.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1oeBON-0006P2-Jj; Fri, 30 Sep 2022 10:29:07 +0200 Message-ID: <0017a1b1-f932-7bb3-7d00-a139bd4cc98d@pengutronix.de> Date: Fri, 30 Sep 2022 09:28:57 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.12.0 From: Ahmad Fatoum Subject: Re: [PATCH v10 3/4] phy: freescale: imx8m-pcie: Refine i.MX8MM PCIe PHY driver To: Richard Zhu , vkoul@kernel.org, p.zabel@pengutronix.de, l.stach@pengutronix.de, bhelgaas@google.com, lorenzo.pieralisi@arm.com, robh@kernel.org, shawnguo@kernel.org, alexander.stein@ew.tq-group.com, marex@denx.de, richard.leitner@linux.dev Cc: devicetree@vger.kernel.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-imx@nxp.com, kernel@pengutronix.de, linux-phy@lists.infradead.org, linux-arm-kernel@lists.infradead.org References: <1664440622-18556-1-git-send-email-hongxing.zhu@nxp.com> <1664440622-18556-4-git-send-email-hongxing.zhu@nxp.com> Content-Language: en-US In-Reply-To: <1664440622-18556-4-git-send-email-hongxing.zhu@nxp.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 2a0a:edc0:0:900:1d::77 X-SA-Exim-Mail-From: a.fatoum@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 29.09.22 09:37, Richard Zhu wrote: > To make it more flexible and easy to expand. Refine i.MX8MM PCIe PHY > driver. > - Use gpr compatible string to avoid the codes duplications when add > another platform PCIe PHY support. > - Re-orange the codes to let it more flexible and easy to expand. Re-arrange > No functions changes basicly. No functional change. > > Signed-off-by: Richard Zhu > Signed-off-by: Lucas Stach > Tested-by: Marek Vasut > Tested-by: Richard Leitner > Tested-by: Alexander Stein > Reviewed-by: Lucas Stach > --- > drivers/phy/freescale/phy-fsl-imx8m-pcie.c | 106 +++++++++++++-------- > 1 file changed, 66 insertions(+), 40 deletions(-) > > diff --git a/drivers/phy/freescale/phy-fsl-imx8m-pcie.c b/drivers/phy/freescale/phy-fsl-imx8m-pcie.c > index 2377ed307b53..59b46a4ae069 100644 > --- a/drivers/phy/freescale/phy-fsl-imx8m-pcie.c > +++ b/drivers/phy/freescale/phy-fsl-imx8m-pcie.c > @@ -11,6 +11,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -45,6 +46,15 @@ > #define IMX8MM_GPR_PCIE_SSC_EN BIT(16) > #define IMX8MM_GPR_PCIE_AUX_EN_OVERRIDE BIT(9) > > +enum imx8_pcie_phy_type { > + IMX8MM, > +}; > + > +struct imx8_pcie_phy_drvdata { > + enum imx8_pcie_phy_type variant; Better do indentation on the member name. > + const char *gpr; > +}; > + > struct imx8_pcie_phy { > void __iomem *base; > struct clk *clk; > @@ -55,6 +65,7 @@ struct imx8_pcie_phy { > u32 tx_deemph_gen1; > u32 tx_deemph_gen2; > bool clkreq_unused; > + const struct imx8_pcie_phy_drvdata *drvdata; > }; > > static int imx8_pcie_phy_init(struct phy *phy) > @@ -66,31 +77,17 @@ static int imx8_pcie_phy_init(struct phy *phy) > reset_control_assert(imx8_phy->reset); > > pad_mode = imx8_phy->refclk_pad_mode; > - /* Set AUX_EN_OVERRIDE 1'b0, when the CLKREQ# isn't hooked */ > - regmap_update_bits(imx8_phy->iomuxc_gpr, IOMUXC_GPR14, > - IMX8MM_GPR_PCIE_AUX_EN_OVERRIDE, > - imx8_phy->clkreq_unused ? > - 0 : IMX8MM_GPR_PCIE_AUX_EN_OVERRIDE); > - regmap_update_bits(imx8_phy->iomuxc_gpr, IOMUXC_GPR14, > - IMX8MM_GPR_PCIE_AUX_EN, > - IMX8MM_GPR_PCIE_AUX_EN); > - regmap_update_bits(imx8_phy->iomuxc_gpr, IOMUXC_GPR14, > - IMX8MM_GPR_PCIE_POWER_OFF, 0); > - regmap_update_bits(imx8_phy->iomuxc_gpr, IOMUXC_GPR14, > - IMX8MM_GPR_PCIE_SSC_EN, 0); > - > - regmap_update_bits(imx8_phy->iomuxc_gpr, IOMUXC_GPR14, > - IMX8MM_GPR_PCIE_REF_CLK_SEL, > - pad_mode == IMX8_PCIE_REFCLK_PAD_INPUT ? > - IMX8MM_GPR_PCIE_REF_CLK_EXT : > - IMX8MM_GPR_PCIE_REF_CLK_PLL); > - usleep_range(100, 200); > - > - /* Do the PHY common block reset */ > - regmap_update_bits(imx8_phy->iomuxc_gpr, IOMUXC_GPR14, > - IMX8MM_GPR_PCIE_CMN_RST, > - IMX8MM_GPR_PCIE_CMN_RST); > - usleep_range(200, 500); > + switch (imx8_phy->drvdata->variant) { > + case IMX8MM: > + /* Tune PHY de-emphasis setting to pass PCIe compliance. */ > + if (imx8_phy->tx_deemph_gen1) > + writel(imx8_phy->tx_deemph_gen1, > + imx8_phy->base + PCIE_PHY_TRSV_REG5); > + if (imx8_phy->tx_deemph_gen2) > + writel(imx8_phy->tx_deemph_gen2, > + imx8_phy->base + PCIE_PHY_TRSV_REG6); > + break; > + } If you say no functional change intended, I'd expect that register writes happen in the same sequence. It might be ok, that you do this tuning here, but I think it warrants a mention in the commit message why it's ok. Looks good otherwise. With nitpicks addressed: Reviewed-by: Ahmad Fatoum -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |