public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: Vinod Koul <vkoul@kernel.org>
To: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	Kishon Vijay Abraham I <kishon@ti.com>,
	Masahiro Yamada <yamada.masahiro@socionext.com>,
	Rob Herring <robh+dt@kernel.org>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v2 2/2] phy: socionext: Add UniPhier AHCI PHY driver support
Date: Mon, 13 Jul 2020 10:35:27 +0530	[thread overview]
Message-ID: <20200713050527.GR34333@vkoul-mobl> (raw)
In-Reply-To: <1593507574-10007-3-git-send-email-hayashi.kunihiko@socionext.com>

On 30-06-20, 17:59, Kunihiko Hayashi wrote:

> +++ b/drivers/phy/socionext/phy-uniphier-ahci.c
> @@ -0,0 +1,335 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * phy-uniphier-ahci.c - PHY driver for UniPhier AHCI controller
> + * Copyright 2016-2018, Socionext Inc.

we are in 2020 now!

> +static int uniphier_ahciphy_pxs2_power_on(struct uniphier_ahciphy_priv *priv)
> +{
> +	int ret;
> +	u32 val;
> +
> +	/* enable reference clock for PHY */
> +	val = readl(priv->base + CKCTRL);
> +	val |= CKCTRL_REF_SSP_EN;
> +	writel(val, priv->base + CKCTRL);
> +
> +	/* release port reset */
> +	val = readl(priv->base + CKCTRL);
> +	val &= ~CKCTRL_P0_RESET;
> +	writel(val, priv->base + CKCTRL);
> +
> +	/* wait until PLL is ready */
> +	if (priv->data->is_ready_high)
> +		ret = readl_poll_timeout(priv->base + CKCTRL, val,
> +					 (val & CKCTRL_P0_READY), 200, 400);
> +	else
> +		ret = readl_poll_timeout(priv->base + CKCTRL, val,
> +					 !(val & CKCTRL_P0_READY), 200, 400);
> +	if (ret) {
> +		dev_err(priv->dev, "Failed to check whether PHY PLL is ready\n");
> +		goto out_disable_clock;
> +	}
> +
> +	return 0;
> +
> +out_disable_clock:
> +	/* assert port reset */
> +	val = readl(priv->base + CKCTRL);
> +	val |= CKCTRL_P0_RESET;
> +	writel(val, priv->base + CKCTRL);
> +
> +	/* disable reference clock for PHY */
> +	val = readl(priv->base + CKCTRL);
> +	val &= ~CKCTRL_REF_SSP_EN;
> +	writel(val, priv->base + CKCTRL);

this seems to be repeated patter, why not add a modifyl() helper here..

> +static int uniphier_ahciphy_pxs3_init(struct uniphier_ahciphy_priv *priv)
> +{
> +	int i;
> +	u32 val;
> +
> +	/* setup port parameter */
> +	val = readl(priv->base + TXCTRL0);
> +	val &= ~TXCTRL0_AMP_G3_MASK;
> +	val |= FIELD_PREP(TXCTRL0_AMP_G3_MASK, 0x73);
> +	val &= ~TXCTRL0_AMP_G2_MASK;
> +	val |= FIELD_PREP(TXCTRL0_AMP_G2_MASK, 0x46);
> +	val &= ~TXCTRL0_AMP_G1_MASK;
> +	val |= FIELD_PREP(TXCTRL0_AMP_G1_MASK, 0x42);
> +	writel(val, priv->base + TXCTRL0);
> +
> +	val = readl(priv->base + TXCTRL1);
> +	val &= ~TXCTRL1_DEEMPH_G3_MASK;
> +	val |= FIELD_PREP(TXCTRL1_DEEMPH_G3_MASK, 0x23);
> +	val &= ~TXCTRL1_DEEMPH_G2_MASK;
> +	val |= FIELD_PREP(TXCTRL1_DEEMPH_G2_MASK, 0x05);
> +	val &= ~TXCTRL1_DEEMPH_G1_MASK;
> +	val |= FIELD_PREP(TXCTRL1_DEEMPH_G1_MASK, 0x05);
> +
> +	val = readl(priv->base + RXCTRL);
> +	val &= ~RXCTRL_LOS_LVL_MASK;
> +	val |= FIELD_PREP(RXCTRL_LOS_LVL_MASK, 0x9);
> +	val &= ~RXCTRL_LOS_BIAS_MASK;
> +	val |= FIELD_PREP(RXCTRL_LOS_BIAS_MASK, 0x2);
> +	val &= ~RXCTRL_RX_EQ_MASK;
> +	val |= FIELD_PREP(RXCTRL_RX_EQ_MASK, 0x1);
> +
> +	/* dummy read 25 times */

why?

> +static int uniphier_ahciphy_init(struct phy *phy)
> +{
> +	struct uniphier_ahciphy_priv *priv = phy_get_drvdata(phy);
> +	int ret;
> +
> +	ret = clk_prepare_enable(priv->clk_parent);
> +	if (ret)
> +		return ret;
> +
> +	ret = reset_control_deassert(priv->rst_parent);
> +	if (ret)
> +		goto out_clk_disable;
> +
> +	if (priv->data->init) {
> +		ret = priv->data->init(priv);
> +		if (ret)
> +			goto out_rst_assert;
> +	}
> +
> +	return ret;

return 0?

> +static const struct uniphier_ahciphy_soc_data uniphier_pxs2_data = {
> +	.init = NULL,

Isn't this superfluous ?
-- 
~Vinod

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2020-07-13  5:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-30  8:59 [PATCH v2 0/2] Add new UniPhier AHCI PHY driver Kunihiko Hayashi
2020-06-30  8:59 ` [PATCH v2 1/2] dt-bindings: phy: Add UniPhier AHCI PHY description Kunihiko Hayashi
2020-07-13  4:59   ` Vinod Koul
2020-07-14  2:40   ` Rob Herring
2020-06-30  8:59 ` [PATCH v2 2/2] phy: socionext: Add UniPhier AHCI PHY driver support Kunihiko Hayashi
2020-07-13  5:05   ` Vinod Koul [this message]
2020-07-14  9:10     ` Kunihiko Hayashi

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=20200713050527.GR34333@vkoul-mobl \
    --to=vkoul@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=hayashi.kunihiko@socionext.com \
    --cc=kishon@ti.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=yamada.masahiro@socionext.com \
    /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