U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Yixun Lan <dlan@kernel.org>
To: Dave Klotz <DaveWK225@protonmail.com>
Cc: Marek Vasut <marek.vasut+usb@mailbox.org>,
	u-boot@lists.u-boot-project.org,
	Quentin Schulz <quentin.schulz@cherry.de>,
	Tom Rini <trini@konsulko.com>,
	u-boot-spacemit@groups.io
Subject: Re: [PATCH v2 1/2] phy: spacemit: add K1 USB 2.0 PHY driver
Date: Mon, 12 Oct 2026 12:17:29 +0000	[thread overview]
Message-ID: <20261012121729-GKH26088@kernel.org> (raw)
In-Reply-To: <20261012090434-GKF26088@kernel.org>

Hi Dave,

On 09:04 Mon 12 Oct     , Yixun Lan wrote:
> Hi Dave,
> 
> On 12:32 Tue 06 Oct     , Dave Klotz wrote:
> > The UTMI PHY at c0a30000 ("spacemit,k1-usb2-phy") feeds the K1's DWC3
> > USB 3 controller. Port the Linux driver: enable the PHY clock, program
> > the PLL divider for the 24 MHz reference, wait for the PLL, then release
> > the PHY's resets and enable its clocks, the HS TX clock and the
> > automatic host-disconnect clear.
> > 
> ..
> > The divider has to be written before the PLL is polled. On the OrangePi
> Right, the upstream kernel driver also did this way
> 
> > R2S under FreeBSD, a driver that polled first and never wrote it left
> > the PLL stopped: the clock enables did not latch (0x60ef read back as
> Sorry, I've not fully understood here, "polled first and never write"..
> Could you elaborate more on this?
> 
> > 0x60e9), the PHY gave the controller no UTMI clock and the xHCI reset
> > (USBCMD.HCRST) never completed. Warn if the enables do not latch.
> Will comment at code below
> 
> > 
> > Also apply the vendor's HS DAC current setting (+15 %), which the
> > FreeBSD driver that runs the R2S port does.
> > 
> Any actual problem without above settings? I'm just curious,
> as upstream code miss this part
> 
> > Signed-off-by: Dave Klotz <DaveWK225@protonmail.com>
> > ---
> >  MAINTAINERS                        |   1 +
> >  drivers/phy/spacemit/Kconfig       |   9 ++
> >  drivers/phy/spacemit/Makefile      |   1 +
> >  drivers/phy/spacemit/phy-k1-usb2.c | 173 +++++++++++++++++++++++++++++
> >  4 files changed, 184 insertions(+)
> >  create mode 100644 drivers/phy/spacemit/phy-k1-usb2.c
> > 
> > +
..
> > +	/* Release the PHY's internal resets and enable its clocks */
> > +	writel(PHY_INIT_MODE_BITS | PHY_CLK_ENABLE_BITS | PHY_DEASSERT_RST_BITS,
> > +	       base + PHY_RST_MODE_CTRL);
> ..
> > +	val = readl(base + PHY_RST_MODE_CTRL);
> > +	if ((val & PHY_CLK_ENABLE_BITS) != PHY_CLK_ENABLE_BITS)
> > +		dev_warn(phy->dev, "clock enables did not latch (%#x)\n", val);
> So read back and check.. if this situation is happening, a warning
> message won't save life.
> 
> But, I need to check if the "enable bits" actually reflect the clock
> enabling status from the hardware perspective.. but even leave that alone,
> I think using a poll() instead of a readl() is a more proper way to go?
> usually it will take few time for the hardware to settle down..
> 
I've asked SpacemiT internal to check, and got this info:

Setting "enable bits" will take effect immediately, it doesn't reflect
the clock status, so this "readl() & check" isn't useful, drop it

If you still see problem, then probably need investigate other way..

> > +
> > +	writel(PHY_HSTXP_RSTN | PHY_CLK_HSTXP_EN | PHY_HSTXP_MODE,
> > +	       base + PHY_HSTXP_HW_CTRL);
> > +
> > +	clrsetbits_le32(base + PHY_ANALOG_REG14_13, PHY_HSDAC_ISEL,
> > +			FIELD_PREP(PHY_HSDAC_ISEL, PHY_HSDAC_ISEL_15_INC) |
> > +			PHY_HSDAC_IREG_EN);
> > +
> > +	/* Auto-clear the HS host disconnect state on reconnect */
> > +	setbits_le32(base + PHY_TX_HOST_CTRL, PHY_HST_DISC_AUTO_CLR);
> > +
> > +	return 0;
> > +}

-- 
Yixun Lan (dlan)

  reply	other threads:[~2026-10-12 12:17 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-06  4:28 [PATCH 0/2] usb: add K1 USB2 PHY and generic DWC3 support Dave Klotz
2026-10-06  4:28 ` [PATCH 1/2] phy: spacemit: add K1 USB 2.0 PHY driver Dave Klotz
2026-10-06  4:28 ` [PATCH 2/2] usb: dwc3: generic: add SpacemiT K1 support Dave Klotz
2026-10-06  5:15   ` Marek Vasut
2026-10-06 12:31 ` [PATCH v2 0/2] usb: add K1 USB2 PHY and generic DWC3 support Dave Klotz
2026-10-06 12:32   ` [PATCH v2 1/2] phy: spacemit: add K1 USB 2.0 PHY driver Dave Klotz
2026-10-12  9:04     ` Yixun Lan
2026-10-12 12:17       ` Yixun Lan [this message]
2026-10-12  9:37     ` Yixun Lan
2026-10-06 12:32   ` [PATCH v2 2/2] usb: dwc3: generic: add SpacemiT K1 support Dave Klotz
2026-10-12  9:38     ` Marek Vasut
2026-10-12 12:27     ` Yixun Lan
2026-10-14 19:59       ` Dave Klotz
2026-10-14 19:59   ` [PATCH v3 0/3] usb: add K1 USB2 PHY and generic DWC3 support Dave Klotz
2026-10-14 20:00     ` [PATCH v3 1/3] phy: spacemit: add K1 USB 2.0 PHY driver Dave Klotz
2026-10-14 20:00     ` [PATCH v3 2/3] usb: dwc3: generic: add SpacemiT K1 and K3 support Dave Klotz
2026-10-14 20:00     ` [PATCH v3 3/3] configs: spacemit_k1: enable USB host Dave Klotz

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=20261012121729-GKH26088@kernel.org \
    --to=dlan@kernel.org \
    --cc=DaveWK225@protonmail.com \
    --cc=marek.vasut+usb@mailbox.org \
    --cc=quentin.schulz@cherry.de \
    --cc=trini@konsulko.com \
    --cc=u-boot-spacemit@groups.io \
    --cc=u-boot@lists.u-boot-project.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