From: Damien Le Moal <dlemoal@kernel.org>
To: Richard Zhu <hongxing.zhu@nxp.com>,
tj@kernel.org, cassel@kernel.org, robh@kernel.org,
krzk+dt@kernel.org, conor+dt@kernel.org, shawnguo@kernel.org,
s.hauer@pengutronix.de, festevam@gmail.com
Cc: linux-ide@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, imx@lists.linux.dev,
kernel@pengutronix.de
Subject: Re: [PATCH v1 2/4] ata: ahci_imx: Clean up code by using i.MX8Q HSIO PHY driver
Date: Thu, 11 Jul 2024 19:22:23 +0900 [thread overview]
Message-ID: <e6b1c275-9a56-4b1b-becd-89a01cfb51c5@kernel.org> (raw)
In-Reply-To: <1720685518-20190-3-git-send-email-hongxing.zhu@nxp.com>
On 7/11/24 17:11, Richard Zhu wrote:
> Clean up code by using PHY interface.
>
> Signed-off-by: Richard Zhu <hongxing.zhu@nxp.com>
> ---
> + ret = phy_init(imxpriv->cali_phy0);
> + if (ret) {
> + dev_err(dev, "cali PHY init failed\n");
> return ret;
> }
> - ret = clk_prepare_enable(imxpriv->phy_pclk1);
> - if (ret < 0) {
> - dev_err(dev, "can't enable phy_pclk1.\n");
> - goto disable_phy_pclk0;
> + ret = phy_power_on(imxpriv->cali_phy0);
> + if (ret) {
> + dev_err(dev, "cali PHY power on failed\n");
> + goto err_cali_phy0_power_on;
Very confusing lable name. "goto err_phy_exit;" would be better.
> }
> - ret = clk_prepare_enable(imxpriv->epcs_tx_clk);
> - if (ret < 0) {
> - dev_err(dev, "can't enable epcs_tx_clk.\n");
> - goto disable_phy_pclk1;
> + ret = phy_init(imxpriv->cali_phy1);
> + if (ret) {
> + dev_err(dev, "cali PHY1 init failed\n");
> + goto err_cali_phy1_init;
Same here. The usual thing to do is to have a label name descriptive of what is
going to be done at the label definition, so phy1 power off in this case. That
also corresponds to undoing the previous operation, which makes reading the code
and checking it less confusing.
> }
> - ret = clk_prepare_enable(imxpriv->epcs_rx_clk);
> - if (ret < 0) {
> - dev_err(dev, "can't enable epcs_rx_clk.\n");
> - goto disable_epcs_tx_clk;
> + ret = phy_power_on(imxpriv->cali_phy1);
> + if (ret) {
> + dev_err(dev, "cali PHY1 power on failed\n");
> + goto err_cali_phy1_power_on;
same here.
> }
> - ret = clk_prepare_enable(imxpriv->phy_apbclk);
> - if (ret < 0) {
> - dev_err(dev, "can't enable phy_apbclk.\n");
> - goto disable_epcs_rx_clk;
> + ret = phy_init(imxpriv->sata_phy);
> + if (ret) {
> + dev_err(dev, "sata PHY init failed\n");
> + goto err_sata_phy_init;
And here too. And many other labels after that.
[...]
> - imxpriv->phy_apbclk = devm_clk_get(dev, "phy_apbclk");
> - if (IS_ERR(imxpriv->phy_apbclk)) {
> - dev_err(dev, "can't get phy_apbclk clock.\n");
> - return PTR_ERR(imxpriv->phy_apbclk);
> + if (!(dev->bus_dma_limit)) {
> + dev->bus_dma_limit = DMA_BIT_MASK(32);
> + dev_dbg(dev, "imx8qm sata only supports 32bit dma.\n");
I do not think this is a useful debug message.
> }
>
> - /* Fetch GPIO, then enable the external OSC */
> - imxpriv->clkreq_gpiod = devm_gpiod_get_optional(dev, "clkreq",
> - GPIOD_OUT_LOW | GPIOD_FLAGS_BIT_NONEXCLUSIVE);
> - if (IS_ERR(imxpriv->clkreq_gpiod))
> - return PTR_ERR(imxpriv->clkreq_gpiod);
> - if (imxpriv->clkreq_gpiod)
> - gpiod_set_consumer_name(imxpriv->clkreq_gpiod, "SATA CLKREQ");
> -
> + imxpriv->sata_phy = devm_phy_get(dev, "sata-phy");
> + if (IS_ERR(imxpriv->sata_phy))
> + return dev_err_probe(dev, PTR_ERR(imxpriv->sata_phy),
> + "failed to get sata_phy\n");
> +
> + imxpriv->cali_phy0 = devm_phy_get(dev, "cali-phy0");
> + if (IS_ERR(imxpriv->cali_phy0))
> + return dev_err_probe(dev, PTR_ERR(imxpriv->cali_phy0),
> + "failed to get cali_phy0\n");
> + imxpriv->cali_phy1 = devm_phy_get(dev, "cali-phy1");
> + if (IS_ERR(imxpriv->cali_phy1))
> + return dev_err_probe(dev, PTR_ERR(imxpriv->cali_phy1),
> + "failed to get cali_phy1\n");
> return 0;
> }
>
> @@ -1077,12 +877,6 @@ static int imx_ahci_probe(struct platform_device *pdev)
> return PTR_ERR(imxpriv->sata_ref_clk);
> }
>
> - imxpriv->ahb_clk = devm_clk_get(dev, "ahb");
> - if (IS_ERR(imxpriv->ahb_clk)) {
> - dev_err(dev, "can't get ahb clock.\n");
s/can't/Failed to/
and drop the period.
> - return PTR_ERR(imxpriv->ahb_clk);
> - }
> -
> if (imxpriv->type == AHCI_IMX6Q || imxpriv->type == AHCI_IMX6QP) {
> u32 reg_value;
>
> @@ -1142,11 +936,8 @@ static int imx_ahci_probe(struct platform_device *pdev)
> goto disable_clk;
>
> /*
> - * Configure the HWINIT bits of the HOST_CAP and HOST_PORTS_IMPL,
> - * and IP vendor specific register IMX_TIMER1MS.
> - * Configure CAP_SSS (support stagered spin up).
> - * Implement the port0.
> - * Get the ahb clock rate, and configure the TIMER1MS register.
> + * Configure the HWINIT bits of the HOST_CAP and HOST_PORTS_IMPL.
> + * Set CAP_SSS (support stagered spin up) and Implement the port0.
> */
> reg_val = readl(hpriv->mmio + HOST_CAP);
> if (!(reg_val & HOST_CAP_SSS)) {
> @@ -1159,8 +950,19 @@ static int imx_ahci_probe(struct platform_device *pdev)
> writel(reg_val, hpriv->mmio + HOST_PORTS_IMPL);
> }
>
> - reg_val = clk_get_rate(imxpriv->ahb_clk) / 1000;
> - writel(reg_val, hpriv->mmio + IMX_TIMER1MS);
> + if (imxpriv->type != AHCI_IMX8QM) {
> + /*
> + * Get AHB clock rate and configure the vendor specified
> + * TIMER1MS register on i.MX53, i.MX6Q and i.MX6QP only.
> + */
> + imxpriv->ahb_clk = devm_clk_get(dev, "ahb");
> + if (IS_ERR(imxpriv->ahb_clk)) {
> + dev_err(dev, "can't get ahb clock.\n");
Same here.
> + goto disable_sata;
> + }
> + reg_val = clk_get_rate(imxpriv->ahb_clk) / 1000;
> + writel(reg_val, hpriv->mmio + IMX_TIMER1MS);
> + }
>
> ret = ahci_platform_init_host(pdev, hpriv, &ahci_imx_port_info,
> &ahci_platform_sht);
--
Damien Le Moal
Western Digital Research
next prev parent reply other threads:[~2024-07-11 10:22 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-11 8:11 [PATCH v1 0/4] Refine i.MX8QM SATA based on generic PHY callbacks Richard Zhu
2024-07-11 8:11 ` [PATCH v1 1/4] dt-bindings: ata: Add i.MX8QM AHCI compatible string Richard Zhu
2024-07-11 22:26 ` Rob Herring (Arm)
2024-07-11 8:11 ` [PATCH v1 2/4] ata: ahci_imx: Clean up code by using i.MX8Q HSIO PHY driver Richard Zhu
2024-07-11 10:22 ` Damien Le Moal [this message]
2024-07-11 10:24 ` Damien Le Moal
2024-07-11 8:11 ` [PATCH v1 3/4] ata: ahci_imx: Enlarge RX water mark for i.MX8QM SATA Richard Zhu
2024-07-11 10:08 ` Damien Le Moal
2024-07-12 3:22 ` Hongxing Zhu
2024-07-11 8:11 ` [PATCH v1 4/4] ata: ahci_imx: Correct the email address Richard Zhu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e6b1c275-9a56-4b1b-becd-89a01cfb51c5@kernel.org \
--to=dlemoal@kernel.org \
--cc=cassel@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=festevam@gmail.com \
--cc=hongxing.zhu@nxp.com \
--cc=imx@lists.linux.dev \
--cc=kernel@pengutronix.de \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-ide@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robh@kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox