From: Vinod Koul <vkoul@kernel.org>
To: Josua Mayer <josua@solid-run.com>
Cc: Kishon Vijay Abraham I <kishon@kernel.org>,
Andrew Lunn <andrew@lunn.ch>,
Gregory Clement <gregory.clement@bootlin.com>,
Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Russell King <linux@armlinux.org.uk>,
Konstantin Porotchkin <kostap@marvell.com>,
Yazan Shhady <yazan.shhady@solid-run.com>,
"linux-phy@lists.infradead.org" <linux-phy@lists.infradead.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>
Subject: Re: [PATCH RFC v3 5/6] phy: mvebu-cp110-utmi: add support for armada-380 utmi phys
Date: Thu, 25 Jul 2024 16:33:29 +0530 [thread overview]
Message-ID: <ZqIxAf2yPL32HLaP@matsya> (raw)
In-Reply-To: <f4835ad8-08c1-49f0-ae85-4f870ad90a8e@solid-run.com>
On 25-07-24, 08:38, Josua Mayer wrote:
> Am 25.07.24 um 08:43 schrieb Vinod Koul:
> > On 20-07-24, 16:19, Josua Mayer wrote:
> >> +struct mvebu_cp110_utmi_port;
> > why forward declare and not move the structs instead?
> Seemed like the smaller change / more readable as diff.
> I can move the struct instead!
Yes and that can be preparatory as well :-)
> >
> >> reg &= ~(PLL_REFDIV_MASK | PLL_FBDIV_MASK | PLL_SEL_LPFR_MASK);
> >> reg |= (PLL_REFDIV_VAL << PLL_REFDIV_OFFSET) |
> >> (PLL_FBDIV_VAL << PLL_FBDIV_OFFSET);
> >> - writel(reg, PORT_REGS(port) + UTMI_PLL_CTRL_REG);
> >> + writel(reg, port->regs + UTMI_PLL_CTRL_REG);
> >>
> >> /* Impedance Calibration Threshold Setting */
> >> - reg = readl(PORT_REGS(port) + UTMI_CAL_CTRL_REG);
> >> + reg = readl(port->regs + UTMI_CAL_CTRL_REG);
> >> reg &= ~IMPCAL_VTH_MASK;
> >> reg |= IMPCAL_VTH_VAL << IMPCAL_VTH_OFFSET;
> >> - writel(reg, PORT_REGS(port) + UTMI_CAL_CTRL_REG);
> >> + writel(reg, port->regs + UTMI_CAL_CTRL_REG);
> >>
> >> /* Set LS TX driver strength coarse control */
> >> - reg = readl(PORT_REGS(port) + UTMI_TX_CH_CTRL_REG);
> >> + reg = readl(port->regs + UTMI_TX_CH_CTRL_REG);
> >> reg &= ~TX_AMP_MASK;
> >> reg |= TX_AMP_VAL << TX_AMP_OFFSET;
> >> - writel(reg, PORT_REGS(port) + UTMI_TX_CH_CTRL_REG);
> >> + writel(reg, port->regs + UTMI_TX_CH_CTRL_REG);
> >>
> >> /* Disable SQ and enable analog squelch detect */
> >> - reg = readl(PORT_REGS(port) + UTMI_RX_CH_CTRL0_REG);
> >> + reg = readl(port->regs + UTMI_RX_CH_CTRL0_REG);
> >> reg &= ~SQ_DET_EN;
> >> reg |= SQ_ANA_DTC_SEL;
> >> - writel(reg, PORT_REGS(port) + UTMI_RX_CH_CTRL0_REG);
> >> + writel(reg, port->regs + UTMI_RX_CH_CTRL0_REG);
> >>
> >> /*
> >> * Set External squelch calibration number and
> >> * enable the External squelch calibration
> >> */
> >> - reg = readl(PORT_REGS(port) + UTMI_RX_CH_CTRL1_REG);
> >> + reg = readl(port->regs + UTMI_RX_CH_CTRL1_REG);
> >> reg &= ~SQ_AMP_CAL_MASK;
> >> reg |= (SQ_AMP_CAL_VAL << SQ_AMP_CAL_OFFSET) | SQ_AMP_CAL_EN;
> >> - writel(reg, PORT_REGS(port) + UTMI_RX_CH_CTRL1_REG);
> >> + writel(reg, port->regs + UTMI_RX_CH_CTRL1_REG);
> >>
> >> /*
> >> * Set Control VDAT Reference Voltage - 0.325V and
> >> * Control VSRC Reference Voltage - 0.6V
> >> */
> >> - reg = readl(PORT_REGS(port) + UTMI_CHGDTC_CTRL_REG);
> >> + reg = readl(port->regs + UTMI_CHGDTC_CTRL_REG);
> >> reg &= ~(VDAT_MASK | VSRC_MASK);
> >> reg |= (VDAT_VAL << VDAT_OFFSET) | (VSRC_VAL << VSRC_OFFSET);
> >> - writel(reg, PORT_REGS(port) + UTMI_CHGDTC_CTRL_REG);
> >> + writel(reg, port->regs + UTMI_CHGDTC_CTRL_REG);
> >> }
> >>
> >> static int mvebu_cp110_utmi_phy_power_off(struct phy *phy)
> >> @@ -166,22 +178,38 @@ static int mvebu_cp110_utmi_phy_power_off(struct phy *phy)
> >> struct mvebu_cp110_utmi_port *port = phy_get_drvdata(phy);
> >> struct mvebu_cp110_utmi *utmi = port->priv;
> >> int i;
> >> + int reg;
> >>
> >> /* Power down UTMI PHY port */
> >> - regmap_clear_bits(utmi->syscon, SYSCON_UTMI_CFG_REG(port->id),
> >> - UTMI_PHY_CFG_PU_MASK);
> >> + if (!IS_ERR(port->regs_cfg)) {
> >> + reg = readl(port->regs_cfg);
> >> + reg &= ~(UTMI_PHY_CFG_PU_MASK);
> >> + writel(reg, port->regs_cfg);
> >> + } else
> >> + regmap_clear_bits(utmi->syscon, SYSCON_UTMI_CFG_REG(port->id),
> >> + UTMI_PHY_CFG_PU_MASK);
> > why are we doing both raw register read/write and regmap ops... that
> > does not sound correct to me
> Indeed.
>
> The next question would be why for Armada 8K / CP110 syscon was chosen.
> From what I could find the registers accessed by utmi driver
> are not accessed by other drivers.
>
> I am adding raw register access as an alternative,
>
> to keep supporting old device-tree specifying syscon handle.
>
> I considered writing helper functions for the if-not-error-syscon-else-raw,
> but between set_bits, clear_bits, global and per-port regs
> would have ended up with too many.
Aha, please add the comment so we know why it was done like this few
years later
--
~Vinod
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
next prev parent reply other threads:[~2024-07-25 11:04 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-20 14:19 [PATCH RFC v3 0/6] phy: mvebu-cp110-utmi: add support for armada-380 utmi phys Josua Mayer
2024-07-20 14:19 ` [PATCH RFC v3 1/6] arm: dts: marvell: armada-388-clearfog: enable third usb on m.2/mpcie Josua Mayer
2024-07-20 14:19 ` [PATCH RFC v3 2/6] arm: dts: marvell: armada-388-clearfog-base: add rfkill for m.2 Josua Mayer
2024-07-20 14:19 ` [PATCH RFC v3 3/6] dt-bindings: phy: cp110-utmi-phy: add compatible string for armada-38x Josua Mayer
2024-07-21 9:31 ` Krzysztof Kozlowski
2024-07-22 15:05 ` Josua Mayer
2024-07-22 15:14 ` Josua Mayer
2024-07-22 15:17 ` Krzysztof Kozlowski
2024-07-22 15:31 ` Josua Mayer
2024-07-22 15:45 ` Krzysztof Kozlowski
2024-07-22 15:49 ` Josua Mayer
2024-07-20 14:19 ` [PATCH RFC v3 4/6] arm: dts: marvell: armada-38x: add description for usb phys Josua Mayer
2024-07-20 14:19 ` [PATCH RFC v3 5/6] phy: mvebu-cp110-utmi: add support for armada-380 utmi phys Josua Mayer
2024-07-25 6:43 ` Vinod Koul
2024-07-25 8:38 ` Josua Mayer
2024-07-25 11:03 ` Vinod Koul [this message]
2024-07-20 14:19 ` [PATCH RFC v3 6/6] arm: dts: marvell: armada-388-clearfog: add description for usb phys Josua Mayer
2024-07-23 2:57 ` [PATCH RFC v3 0/6] phy: mvebu-cp110-utmi: add support for armada-380 utmi phys Rob Herring (Arm)
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=ZqIxAf2yPL32HLaP@matsya \
--to=vkoul@kernel.org \
--cc=andrew@lunn.ch \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=gregory.clement@bootlin.com \
--cc=josua@solid-run.com \
--cc=kishon@kernel.org \
--cc=kostap@marvell.com \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-phy@lists.infradead.org \
--cc=linux@armlinux.org.uk \
--cc=robh@kernel.org \
--cc=sebastian.hesselbarth@gmail.com \
--cc=yazan.shhady@solid-run.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;
as well as URLs for NNTP newsgroup(s).