Linux-PHY Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] phy: spacemit: fix and enable the K1 USB 2.0 PHY
@ 2026-08-25  6:50 Bruno Banelli
  2026-08-25  6:50 ` [PATCH v2 1/2] phy: spacemit: fix K1 USB 2.0 PHY Kconfig dependencies Bruno Banelli
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Bruno Banelli @ 2026-08-25  6:50 UTC (permalink / raw)
  To: Vinod Koul
  Cc: Neil Armstrong, Yixun Lan, Ze Huang, Alex Elder, linux-phy,
	linux-riscv, spacemit, linux-kernel, Bruno Banelli

v1 was a single patch adding "default ARCH_SPACEMIT" to
PHY_SPACEMIT_K1_USB2.  Automated review pointed out two pre-existing
Kconfig problems in the same entry, and that change makes them easier
to hit: enabling the symbol by default means configurations that would
previously have left it off will now build the driver.

So fix the dependencies first, then enable it by default.

Both were verified against the driver source: phy-k1-usb2.c calls
devm_platform_ioremap_resource() and devm_regmap_init_mmio(), while the
Kconfig entry has neither "depends on HAS_IOMEM" nor
"select REGMAP_MMIO".  PHY_SPACEMIT_K1_PCIE, directly above it in the
same file, already has the HAS_IOMEM dependency.

Tested on a Milk-V Jupiter (SpacemiT M1) running mainline 7.2: without
patch 2/2 a "make defconfig" kernel has no USB at all, because
dwc3-generic-plat cannot get its PHY.

v1: https://lore.kernel.org/linux-riscv/20260825052158.66367-1-bbanelli@gmail.com/

Changes in v2:
 - new patch 1/2 adding "depends on HAS_IOMEM" and "select REGMAP_MMIO",
   with a Fixes: tag
 - no change to the patch now numbered 2/2

Bruno Banelli (2):
  phy: spacemit: fix K1 USB 2.0 PHY Kconfig dependencies
  phy: spacemit: enable K1 USB 2.0 PHY by default on ARCH_SPACEMIT

 drivers/phy/spacemit/Kconfig | 3 +++
 1 file changed, 3 insertions(+)


base-commit: 66498c75b4f8017f62d720d9b59675bdf3abce91
-- 
2.43.0


-- 
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2 1/2] phy: spacemit: fix K1 USB 2.0 PHY Kconfig dependencies
  2026-08-25  6:50 [PATCH v2 0/2] phy: spacemit: fix and enable the K1 USB 2.0 PHY Bruno Banelli
@ 2026-08-25  6:50 ` Bruno Banelli
  2026-08-25  6:50 ` [PATCH v2 2/2] phy: spacemit: enable K1 USB 2.0 PHY by default on ARCH_SPACEMIT Bruno Banelli
  2026-08-25 23:07 ` [PATCH v2 0/2] phy: spacemit: fix and enable the K1 USB 2.0 PHY Yixun Lan
  2 siblings, 0 replies; 5+ messages in thread
From: Bruno Banelli @ 2026-08-25  6:50 UTC (permalink / raw)
  To: Vinod Koul
  Cc: Neil Armstrong, Yixun Lan, Ze Huang, Alex Elder, linux-phy,
	linux-riscv, spacemit, linux-kernel, Bruno Banelli

phy-k1-usb2.c maps its registers with devm_platform_ioremap_resource()
and wraps them with devm_regmap_init_mmio(), but PHY_SPACEMIT_K1_USB2
neither depends on HAS_IOMEM nor selects REGMAP_MMIO.

REGMAP_MMIO has no prompt and can only be enabled by select, so a
configuration that leaves it off fails to link.  In practice the symbol
is usually pulled in indirectly, which is why this has gone unnoticed.

PHY_SPACEMIT_K1_PCIE, directly above it in the same file, already has
the HAS_IOMEM dependency; without it PHY_SPACEMIT_K1_USB2 can be built
under COMPILE_TEST on architectures that provide no I/O memory.

Fixes: fe4bc1a08638 ("phy: spacemit: support K1 USB2.0 PHY controller")
Signed-off-by: Bruno Banelli <bbanelli@gmail.com>
---
 drivers/phy/spacemit/Kconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/phy/spacemit/Kconfig b/drivers/phy/spacemit/Kconfig
index 5fdf18fce..cd7ae48d8 100644
--- a/drivers/phy/spacemit/Kconfig
+++ b/drivers/phy/spacemit/Kconfig
@@ -18,8 +18,10 @@ config PHY_SPACEMIT_K1_USB2
 	tristate "SpacemiT K1 USB 2.0 PHY support"
 	depends on (ARCH_SPACEMIT || COMPILE_TEST) && OF
 	depends on COMMON_CLK
+	depends on HAS_IOMEM
 	depends on USB_COMMON
 	select GENERIC_PHY
+	select REGMAP_MMIO
 	help
 	  Enable this to support K1 USB 2.0 PHY driver. This driver takes care of
 	  enabling and clock setup and will be used by K1 udc/ehci/otg/xhci driver.
-- 
2.43.0


-- 
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 2/2] phy: spacemit: enable K1 USB 2.0 PHY by default on ARCH_SPACEMIT
  2026-08-25  6:50 [PATCH v2 0/2] phy: spacemit: fix and enable the K1 USB 2.0 PHY Bruno Banelli
  2026-08-25  6:50 ` [PATCH v2 1/2] phy: spacemit: fix K1 USB 2.0 PHY Kconfig dependencies Bruno Banelli
@ 2026-08-25  6:50 ` Bruno Banelli
  2026-08-25  7:03   ` sashiko-bot
  2026-08-25 23:07 ` [PATCH v2 0/2] phy: spacemit: fix and enable the K1 USB 2.0 PHY Yixun Lan
  2 siblings, 1 reply; 5+ messages in thread
From: Bruno Banelli @ 2026-08-25  6:50 UTC (permalink / raw)
  To: Vinod Koul
  Cc: Neil Armstrong, Yixun Lan, Ze Huang, Alex Elder, linux-phy,
	linux-riscv, spacemit, linux-kernel, Bruno Banelli

PHY_SPACEMIT_K1_PCIE has "default ARCH_SPACEMIT", but
PHY_SPACEMIT_K1_USB2, directly below it in the same file, does not.
Since the symbol is also absent from arch/riscv/configs/defconfig, a
plain "make defconfig" build for a SpacemiT K1 board ends up with the
USB 2.0 PHY driver disabled.

dwc3-generic-plat needs that PHY, so the result is a kernel with no
working USB at all on boards such as the Milk-V Jupiter, where all four
USB 3.0 type-A ports hang off the single dwc3 controller.

Give it the same default as its sibling.

Signed-off-by: Bruno Banelli <bbanelli@gmail.com>
---
 drivers/phy/spacemit/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/phy/spacemit/Kconfig b/drivers/phy/spacemit/Kconfig
index cd7ae48d8..b5f36621b 100644
--- a/drivers/phy/spacemit/Kconfig
+++ b/drivers/phy/spacemit/Kconfig
@@ -22,6 +22,7 @@ config PHY_SPACEMIT_K1_USB2
 	depends on USB_COMMON
 	select GENERIC_PHY
 	select REGMAP_MMIO
+	default ARCH_SPACEMIT
 	help
 	  Enable this to support K1 USB 2.0 PHY driver. This driver takes care of
 	  enabling and clock setup and will be used by K1 udc/ehci/otg/xhci driver.
-- 
2.43.0


-- 
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 2/2] phy: spacemit: enable K1 USB 2.0 PHY by default on ARCH_SPACEMIT
  2026-08-25  6:50 ` [PATCH v2 2/2] phy: spacemit: enable K1 USB 2.0 PHY by default on ARCH_SPACEMIT Bruno Banelli
@ 2026-08-25  7:03   ` sashiko-bot
  0 siblings, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-08-25  7:03 UTC (permalink / raw)
  To: Bruno Banelli; +Cc: olteanv, neil.armstrong, linux-phy, vkoul

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:

Pre-existing issues:
- [High] Missing `select MFD_SYSCON` or `depends on MFD_SYSCON` for PHY_SPACEMIT_K1_PCIE
- [Medium] Incomplete fix: PHY_SPACEMIT_K3_COMBO_PHY is missing `default ARCH_SPACEMIT`
- [Medium] PHY_SPACEMIT_K3_COMBO_PHY is missing `depends on HAS_IOMEM`
--

--- Patch [2]: [PATCH v2 2/2] phy: spacemit: enable K1 USB 2.0 PHY by default on ARCH_SPACEMIT ---
commit 24c737090e69ed7db66ac129f68b1a45eb92ca1e
Author: Bruno Banelli <bbanelli@gmail.com>

phy: spacemit: enable K1 USB 2.0 PHY by default on ARCH_SPACEMIT

This commit adds a default ARCH_SPACEMIT to the PHY_SPACEMIT_K1_USB2 Kconfig
entry. This resolves an issue where the USB 2.0 PHY driver was disabled by
default on SpacemiT K1 boards, preventing USB from working.

> diff --git a/drivers/phy/spacemit/Kconfig b/drivers/phy/spacemit/Kconfig
> index cd7ae48d8ea2f..b5f36621b2075 100644
> --- a/drivers/phy/spacemit/Kconfig
> +++ b/drivers/phy/spacemit/Kconfig
> @@ -22,6 +22,7 @@ config PHY_SPACEMIT_K1_USB2
>  	depends on USB_COMMON
>  	select GENERIC_PHY
>  	select REGMAP_MMIO
> +	default ARCH_SPACEMIT

[Severity: High]
This is a pre-existing issue, but I noticed PHY_SPACEMIT_K1_PCIE is missing
a dependency on MFD_SYSCON:

drivers/phy/spacemit/Kconfig:PHY_SPACEMIT_K1_PCIE {
    config PHY_SPACEMIT_K1_PCIE
        tristate "PCIe and combo PHY driver for the SpacemiT K1 SoC"
        depends on ARCH_SPACEMIT || COMPILE_TEST
        ...
}

If MFD_SYSCON is not enabled, the kernel will still build successfully,
but at runtime the driver probe will silently fail returning -ENOTSUPP:

drivers/phy/spacemit/phy-k1-pcie.c:k1_pcie_combo_phy_probe() {
    ...
    regmap = syscon_regmap_lookup_by_phandle(dev_of_node(dev), SYSCON_APMU);
    ...
}

Does this config need to select or depend on MFD_SYSCON to prevent this?


[Severity: Medium]
This is a pre-existing issue, but PHY_SPACEMIT_K3_COMBO_PHY seems to be
missing the same default configuration being added here:

drivers/phy/spacemit/Kconfig:PHY_SPACEMIT_K3_COMBO_PHY {
    config PHY_SPACEMIT_K3_COMBO_PHY
        tristate "SpacemiT K3 USB3/PCIe PHY support"
        depends on (ARCH_SPACEMIT || COMPILE_TEST) && OF
        ...
}

Since the K3 combo PHY driver manages USB3/PCIe on SpacemiT SoCs, could
this missing default lead to similar broken USB behavior on K3 boards?
Would it make sense to add default ARCH_SPACEMIT there as well?


[Severity: Medium]
This is a pre-existing issue, but PHY_SPACEMIT_K3_COMBO_PHY also appears
to be missing a dependency on HAS_IOMEM:

drivers/phy/spacemit/Kconfig:PHY_SPACEMIT_K3_COMBO_PHY {
    config PHY_SPACEMIT_K3_COMBO_PHY
        tristate "SpacemiT K3 USB3/PCIe PHY support"
        depends on (ARCH_SPACEMIT || COMPILE_TEST) && OF
        depends on COMMON_CLK
        select PHY_SPACEMIT_K3_COMMON_OPS
}

The PHY_SPACEMIT_K3_COMBO_PHY driver uses devm_platform_ioremap_resource(),
which operates on MMIO memory. Could omitting the HAS_IOMEM dependency
lead to build or probe failures under COMPILE_TEST?

>  	help
>  	  Enable this to support K1 USB 2.0 PHY driver. This driver takes care of
>  	  enabling and clock setup and will be used by K1 udc/ehci/otg/xhci driver.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260825065007.69353-1-bbanelli@gmail.com?part=2

-- 
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 0/2] phy: spacemit: fix and enable the K1 USB 2.0 PHY
  2026-08-25  6:50 [PATCH v2 0/2] phy: spacemit: fix and enable the K1 USB 2.0 PHY Bruno Banelli
  2026-08-25  6:50 ` [PATCH v2 1/2] phy: spacemit: fix K1 USB 2.0 PHY Kconfig dependencies Bruno Banelli
  2026-08-25  6:50 ` [PATCH v2 2/2] phy: spacemit: enable K1 USB 2.0 PHY by default on ARCH_SPACEMIT Bruno Banelli
@ 2026-08-25 23:07 ` Yixun Lan
  2 siblings, 0 replies; 5+ messages in thread
From: Yixun Lan @ 2026-08-25 23:07 UTC (permalink / raw)
  To: Bruno Banelli
  Cc: Vinod Koul, Neil Armstrong, Ze Huang, Alex Elder, linux-phy,
	linux-riscv, spacemit, linux-kernel

Hi Bruno,

On 08:50 Tue 25 Aug     , Bruno Banelli wrote:
> v1 was a single patch adding "default ARCH_SPACEMIT" to
> PHY_SPACEMIT_K1_USB2.  Automated review pointed out two pre-existing
> Kconfig problems in the same entry, and that change makes them easier
> to hit: enabling the symbol by default means configurations that would
> previously have left it off will now build the driver.
> 
> So fix the dependencies first, then enable it by default.
> 
> Both were verified against the driver source: phy-k1-usb2.c calls
> devm_platform_ioremap_resource() and devm_regmap_init_mmio(), while the
> Kconfig entry has neither "depends on HAS_IOMEM" nor
> "select REGMAP_MMIO".  PHY_SPACEMIT_K1_PCIE, directly above it in the
> same file, already has the HAS_IOMEM dependency.
> 
> Tested on a Milk-V Jupiter (SpacemiT M1) running mainline 7.2: without
> patch 2/2 a "make defconfig" kernel has no USB at all, because
> dwc3-generic-plat cannot get its PHY.
> 
> v1: https://lore.kernel.org/linux-riscv/20260825052158.66367-1-bbanelli@gmail.com/
> 
> Changes in v2:
>  - new patch 1/2 adding "depends on HAS_IOMEM" and "select REGMAP_MMIO",
>    with a Fixes: tag
>  - no change to the patch now numbered 2/2
> 
Thanks for this v2
Reviewed-by: Yixun Lan <dlan@kernel.org>

-- 
Yixun Lan (dlan)

-- 
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-08-25 23:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-25  6:50 [PATCH v2 0/2] phy: spacemit: fix and enable the K1 USB 2.0 PHY Bruno Banelli
2026-08-25  6:50 ` [PATCH v2 1/2] phy: spacemit: fix K1 USB 2.0 PHY Kconfig dependencies Bruno Banelli
2026-08-25  6:50 ` [PATCH v2 2/2] phy: spacemit: enable K1 USB 2.0 PHY by default on ARCH_SPACEMIT Bruno Banelli
2026-08-25  7:03   ` sashiko-bot
2026-08-25 23:07 ` [PATCH v2 0/2] phy: spacemit: fix and enable the K1 USB 2.0 PHY Yixun Lan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox