From: Vinod Koul <vkoul@kernel.org>
To: Yulin Lu <luyulin@eswincomputing.com>
Cc: neil.armstrong@linaro.org, robh@kernel.org, krzk+dt@kernel.org,
conor+dt@kernel.org, p.zabel@pengutronix.de,
linux-phy@lists.infradead.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, ningyu@eswincomputing.com,
zhengyu@eswincomputing.com, linmin@eswincomputing.com,
huangyifeng@eswincomputing.com, fenglin@eswincomputing.com,
lianghujun@eswincomputing.com
Subject: Re: Re: [PATCH v7 2/2] phy: eswin: Create eswin directory and add EIC7700 SATA PHY driver
Date: Sun, 18 Jan 2026 19:06:03 +0530 [thread overview]
Message-ID: <aWzhw65QEoLj2XE7@vaman> (raw)
In-Reply-To: <133c22d5.2674.19bc5ff735f.Coremail.luyulin@eswincomputing.com>
On 16-01-26, 16:50, Yulin Lu wrote:
> > > +static int eic7700_sata_phy_init(struct phy *phy)
> > > +{
> > > + struct eic7700_sata_phy *sata_phy = phy_get_drvdata(phy);
> > > + u32 val;
> > > + int ret;
> > > +
> > > + ret = clk_prepare_enable(sata_phy->clk);
> > > + if (ret)
> > > + return ret;
> > > +
> > > + regmap_write(sata_phy->regmap, SATA_REF_CTRL1, SATA_CLK_RST_SOURCE_PHY);
> > > +
> > > + val = FIELD_PREP(SATA_P0_PHY_TX_AMPLITUDE_GEN1_MASK, 0x42) |
> > > + FIELD_PREP(SATA_P0_PHY_TX_AMPLITUDE_GEN2_MASK, 0x46) |
> > > + FIELD_PREP(SATA_P0_PHY_TX_AMPLITUDE_GEN3_MASK, 0x73);
> > > + regmap_write(sata_phy->regmap, SATA_PHY_CTRL0, val);
> > > +
> > > + val = FIELD_PREP(SATA_P0_PHY_TX_PREEMPH_GEN1_MASK, 0x5) |
> > > + FIELD_PREP(SATA_P0_PHY_TX_PREEMPH_GEN2_MASK, 0x5) |
> > > + FIELD_PREP(SATA_P0_PHY_TX_PREEMPH_GEN3_MASK, 0x8);
> >
> > Where are the magic values you are writing coming from..?
> >
>
> Hi Vinod,
>
> These values set the TX preemphasis and amplitude parameters for the SATA PHY.
> The actual numbers come from eye‑diagram tuning results on different hardware
> development boards.
> The current code reflects the settings for the Sifive HiFive Premier P550 board.
> In the next patch I plan to move these into the devicetree (DTS).
> Would that be acceptable?
So this would change wrt each board the device is...? Maybe DT should be
better choice. Please check with DT folks on the approach
>
> > > + regmap_write(sata_phy->regmap, SATA_PHY_CTRL1, val);
> > > +
> > > + val = FIELD_PREP(SATA_LOS_LEVEL_MASK, 0x9) |
> > > + FIELD_PREP(SATA_LOS_BIAS_MASK, 0x2);
> > > + regmap_write(sata_phy->regmap, SATA_LOS_IDEN, val);
> > > +
> > > + val = SATA_M_CSYSREQ | SATA_S_CSYSREQ;
> > > + regmap_write(sata_phy->regmap, SATA_AXI_LP_CTRL, val);
> > > +
> > > + val = SATA_REF_REPEATCLK_EN | SATA_REF_USE_PAD;
> > > + regmap_write(sata_phy->regmap, SATA_REF_CTRL, val);
> > > +
> > > + val = FIELD_PREP(SATA_MPLL_MULTIPLIER_MASK, 0x3c);
> > > + regmap_write(sata_phy->regmap, SATA_MPLL_CTRL, val);
> > > +
> > > + usleep_range(15, 20);
> > > +
> > > + ret = reset_control_deassert(sata_phy->rst);
> > > + if (ret)
> > > + goto disable_clk;
> > > +
> > > + ret = wait_for_phy_ready(sata_phy->regmap, SATA_P0_PHY_STAT,
> > > + SATA_P0_PHY_READY, 1);
> > > + if (ret < 0) {
> > > + dev_err(&sata_phy->phy->dev, "PHY READY check failed\n");
> > > + goto disable_clk;
> > > + }
> > > +
> > > + return 0;
> > > +
> > > +disable_clk:
> > > + clk_disable_unprepare(sata_phy->clk);
> > > + return ret;
> > > +}
> > > +
> > > +static int eic7700_sata_phy_exit(struct phy *phy)
> > > +{
> > > + struct eic7700_sata_phy *sata_phy = phy_get_drvdata(phy);
> > > + int ret;
> > > +
> > > + ret = reset_control_assert(sata_phy->rst);
> > > + if (ret)
> > > + return ret;
> > > +
> > > + clk_disable_unprepare(sata_phy->clk);
> > > +
> > > + return 0;
> > > +}
> > > +
> > > +static const struct phy_ops eic7700_sata_phy_ops = {
> > > + .init = eic7700_sata_phy_init,
> > > + .exit = eic7700_sata_phy_exit,
> > > + .owner = THIS_MODULE,
> > > +};
> > > +
> > > +static int eic7700_sata_phy_probe(struct platform_device *pdev)
> > > +{
> > > + struct eic7700_sata_phy *sata_phy;
> > > + struct phy_provider *phy_provider;
> > > + struct device *dev = &pdev->dev;
> > > + struct resource *res;
> > > + void __iomem *regs;
> > > +
> > > + sata_phy = devm_kzalloc(dev, sizeof(*sata_phy), GFP_KERNEL);
> > > + if (!sata_phy)
> > > + return -ENOMEM;
> > > +
> > > + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > > + if (!res)
> > > + return -ENOENT;
> > > +
> > > + regs = devm_ioremap(dev, res->start, resource_size(res));
> > > + if (IS_ERR(regs))
> > > + return PTR_ERR(regs);
> >
> > devm_platform_get_and_ioremap_resource() please
> >
>
> As explained in my “v6 → v5” changes in the cover‑letter:
> “Map the I/O resource with platform_get_resource and devm_ioremap
> instead of the devm_platform_ioremap_resource API,
> because the address region of the SATA‑PHY falls into the region of
> the HSP clock & reset that has already been obtained by the HSP
> clock‑and‑reset driver.”
> The HSP clock-and-reset driver uses devm_platform_get_and_ioremap_resource(),
> meaning this region has already been requested.
> The HSP clock-and-reset driver is also currently being upstreamed.
Worth adding a comment here for that
--
~Vinod
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
WARNING: multiple messages have this Message-ID (diff)
From: Vinod Koul <vkoul@kernel.org>
To: Yulin Lu <luyulin@eswincomputing.com>
Cc: neil.armstrong@linaro.org, robh@kernel.org, krzk+dt@kernel.org,
conor+dt@kernel.org, p.zabel@pengutronix.de,
linux-phy@lists.infradead.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, ningyu@eswincomputing.com,
zhengyu@eswincomputing.com, linmin@eswincomputing.com,
huangyifeng@eswincomputing.com, fenglin@eswincomputing.com,
lianghujun@eswincomputing.com
Subject: Re: Re: [PATCH v7 2/2] phy: eswin: Create eswin directory and add EIC7700 SATA PHY driver
Date: Sun, 18 Jan 2026 19:06:03 +0530 [thread overview]
Message-ID: <aWzhw65QEoLj2XE7@vaman> (raw)
In-Reply-To: <133c22d5.2674.19bc5ff735f.Coremail.luyulin@eswincomputing.com>
On 16-01-26, 16:50, Yulin Lu wrote:
> > > +static int eic7700_sata_phy_init(struct phy *phy)
> > > +{
> > > + struct eic7700_sata_phy *sata_phy = phy_get_drvdata(phy);
> > > + u32 val;
> > > + int ret;
> > > +
> > > + ret = clk_prepare_enable(sata_phy->clk);
> > > + if (ret)
> > > + return ret;
> > > +
> > > + regmap_write(sata_phy->regmap, SATA_REF_CTRL1, SATA_CLK_RST_SOURCE_PHY);
> > > +
> > > + val = FIELD_PREP(SATA_P0_PHY_TX_AMPLITUDE_GEN1_MASK, 0x42) |
> > > + FIELD_PREP(SATA_P0_PHY_TX_AMPLITUDE_GEN2_MASK, 0x46) |
> > > + FIELD_PREP(SATA_P0_PHY_TX_AMPLITUDE_GEN3_MASK, 0x73);
> > > + regmap_write(sata_phy->regmap, SATA_PHY_CTRL0, val);
> > > +
> > > + val = FIELD_PREP(SATA_P0_PHY_TX_PREEMPH_GEN1_MASK, 0x5) |
> > > + FIELD_PREP(SATA_P0_PHY_TX_PREEMPH_GEN2_MASK, 0x5) |
> > > + FIELD_PREP(SATA_P0_PHY_TX_PREEMPH_GEN3_MASK, 0x8);
> >
> > Where are the magic values you are writing coming from..?
> >
>
> Hi Vinod,
>
> These values set the TX preemphasis and amplitude parameters for the SATA PHY.
> The actual numbers come from eye‑diagram tuning results on different hardware
> development boards.
> The current code reflects the settings for the Sifive HiFive Premier P550 board.
> In the next patch I plan to move these into the devicetree (DTS).
> Would that be acceptable?
So this would change wrt each board the device is...? Maybe DT should be
better choice. Please check with DT folks on the approach
>
> > > + regmap_write(sata_phy->regmap, SATA_PHY_CTRL1, val);
> > > +
> > > + val = FIELD_PREP(SATA_LOS_LEVEL_MASK, 0x9) |
> > > + FIELD_PREP(SATA_LOS_BIAS_MASK, 0x2);
> > > + regmap_write(sata_phy->regmap, SATA_LOS_IDEN, val);
> > > +
> > > + val = SATA_M_CSYSREQ | SATA_S_CSYSREQ;
> > > + regmap_write(sata_phy->regmap, SATA_AXI_LP_CTRL, val);
> > > +
> > > + val = SATA_REF_REPEATCLK_EN | SATA_REF_USE_PAD;
> > > + regmap_write(sata_phy->regmap, SATA_REF_CTRL, val);
> > > +
> > > + val = FIELD_PREP(SATA_MPLL_MULTIPLIER_MASK, 0x3c);
> > > + regmap_write(sata_phy->regmap, SATA_MPLL_CTRL, val);
> > > +
> > > + usleep_range(15, 20);
> > > +
> > > + ret = reset_control_deassert(sata_phy->rst);
> > > + if (ret)
> > > + goto disable_clk;
> > > +
> > > + ret = wait_for_phy_ready(sata_phy->regmap, SATA_P0_PHY_STAT,
> > > + SATA_P0_PHY_READY, 1);
> > > + if (ret < 0) {
> > > + dev_err(&sata_phy->phy->dev, "PHY READY check failed\n");
> > > + goto disable_clk;
> > > + }
> > > +
> > > + return 0;
> > > +
> > > +disable_clk:
> > > + clk_disable_unprepare(sata_phy->clk);
> > > + return ret;
> > > +}
> > > +
> > > +static int eic7700_sata_phy_exit(struct phy *phy)
> > > +{
> > > + struct eic7700_sata_phy *sata_phy = phy_get_drvdata(phy);
> > > + int ret;
> > > +
> > > + ret = reset_control_assert(sata_phy->rst);
> > > + if (ret)
> > > + return ret;
> > > +
> > > + clk_disable_unprepare(sata_phy->clk);
> > > +
> > > + return 0;
> > > +}
> > > +
> > > +static const struct phy_ops eic7700_sata_phy_ops = {
> > > + .init = eic7700_sata_phy_init,
> > > + .exit = eic7700_sata_phy_exit,
> > > + .owner = THIS_MODULE,
> > > +};
> > > +
> > > +static int eic7700_sata_phy_probe(struct platform_device *pdev)
> > > +{
> > > + struct eic7700_sata_phy *sata_phy;
> > > + struct phy_provider *phy_provider;
> > > + struct device *dev = &pdev->dev;
> > > + struct resource *res;
> > > + void __iomem *regs;
> > > +
> > > + sata_phy = devm_kzalloc(dev, sizeof(*sata_phy), GFP_KERNEL);
> > > + if (!sata_phy)
> > > + return -ENOMEM;
> > > +
> > > + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > > + if (!res)
> > > + return -ENOENT;
> > > +
> > > + regs = devm_ioremap(dev, res->start, resource_size(res));
> > > + if (IS_ERR(regs))
> > > + return PTR_ERR(regs);
> >
> > devm_platform_get_and_ioremap_resource() please
> >
>
> As explained in my “v6 → v5” changes in the cover‑letter:
> “Map the I/O resource with platform_get_resource and devm_ioremap
> instead of the devm_platform_ioremap_resource API,
> because the address region of the SATA‑PHY falls into the region of
> the HSP clock & reset that has already been obtained by the HSP
> clock‑and‑reset driver.”
> The HSP clock-and-reset driver uses devm_platform_get_and_ioremap_resource(),
> meaning this region has already been requested.
> The HSP clock-and-reset driver is also currently being upstreamed.
Worth adding a comment here for that
--
~Vinod
next prev parent reply other threads:[~2026-01-18 13:36 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-06 6:29 [PATCH v7 0/2] Add driver support for Eswin EIC7700 SoC SATA PHY Yulin Lu
2026-01-06 6:29 ` Yulin Lu
2026-01-06 6:31 ` [PATCH v7 1/2] dt-bindings: phy: eswin: Document the " Yulin Lu
2026-01-06 6:31 ` Yulin Lu
2026-01-06 6:33 ` [PATCH v7 2/2] phy: eswin: Create eswin directory and add EIC7700 SATA PHY driver Yulin Lu
2026-01-06 6:33 ` Yulin Lu
2026-01-14 12:11 ` Vinod Koul
2026-01-14 12:11 ` Vinod Koul
2026-01-16 8:50 ` Yulin Lu
2026-01-16 8:50 ` Yulin Lu
2026-01-18 13:36 ` Vinod Koul [this message]
2026-01-18 13:36 ` Vinod Koul
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=aWzhw65QEoLj2XE7@vaman \
--to=vkoul@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=fenglin@eswincomputing.com \
--cc=huangyifeng@eswincomputing.com \
--cc=krzk+dt@kernel.org \
--cc=lianghujun@eswincomputing.com \
--cc=linmin@eswincomputing.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-phy@lists.infradead.org \
--cc=luyulin@eswincomputing.com \
--cc=neil.armstrong@linaro.org \
--cc=ningyu@eswincomputing.com \
--cc=p.zabel@pengutronix.de \
--cc=robh@kernel.org \
--cc=zhengyu@eswincomputing.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.