ZTE zx297520v3 USB support
Subsystems (6)
Stefan Dösinger
maintainercover ZTE zx297520v3 USB support
Hi,
This series expands the device tree and drivers for the zx297520v3 board enough to enable the DWC2 USB controller found on this board. This series depends on the zx29clk MFD driver that has been accepted into the MFD tree, but not yet merged into linux-next.
The individual patches contain a description of what they do and the rationale for design decisions. Here is a quick overview:
Patch 1: DT bindings for the node containing the necessary power controls Patch 2: Add the socsys node to the MFD driver
Patch 3: The power domain driver
Patch 4: A minimal USB PHY driver
Patch 5, 6: Link it together in the DTS
Dependencies: 1-4-5 depend on each other at build / DTS validation time. 2, 3, 4 are build time independent but need their previous patches to be enabled at runtime.
The MAINTAINERS additions are going to cause issues though. Once the patches have been reviewed I can either take them out or create an immutable branch.
The open questions:
1) How much documentation is appropriate in the binding .yaml?
I want to document the identified registers *somewhere*, and since the yaml lives in Documentation/ I put it there. I do understand though if the Linux kernel doesn't want to be a backup SoC datasheet.
2) Power domain vs reset:
The pm domain controller has a reset, isolation and power register for each of the 5 (maybe more) devices it controls. My binding links them together into #power-domain-cells.
To start up the GSM controller, its driver will have to assert and deassert the reset. The GSM controller (Derived from an Infineon PMB8877) has a self-arming watchdog and after 2.5 ms it stops responding. With the power domain it is somewhat awkward:
devm_pm_runtime_set_active_enabled()pm_runtime_get_noresume()pm_runtime_put_sync_suspend()pm_runtime_resume_and_get()
And hope nothing else is holding the device and that runtime PM is actually compiled into the kernel.
Life would be easier if I expose the GSM reset bits as #reset-cells. Otoh, I'd prefer not to do that for USB, as USB already has 3 different reset controls already and adding another is awkward. I could of course also hide the USB reset and expose the GSM resets.
For now I postponed the issue and don't add GSM related controls to the bindings at all.
---
Stefan Dösinger (6):
dt-bindings: soc: zte: Document zx297520v3 socsys controller
mfd: zx297520v3: Add socsys to the mfd host driver
pmdomain: zte: Add a zx297520v3 power domain driver
phy: zte: Add a zx29 USB PHY driver.
ARM: dts: zte: Declare nodes to enable the board's dwc2 controller
ARM: dts: zte: Declare the HSIC controller node
.../bindings/soc/zte/zte,zx297520v3-socsys.yaml | 100 +++++++ MAINTAINERS | 3 + arch/arm/boot/dts/zte/zx297520v3.dtsi | 42 +++ drivers/mfd/zte-zx297520v3-crm.c | 12 + drivers/phy/Kconfig | 11 + drivers/phy/Makefile | 1 + drivers/phy/phy-zx29-usb.c | 183 +++++++++++++ drivers/pmdomain/Kconfig | 1 + drivers/pmdomain/Makefile | 1 + drivers/pmdomain/zte/Kconfig | 15 ++ drivers/pmdomain/zte/Makefile | 2 + drivers/pmdomain/zte/zx297520v3-pm-domain.c | 286 +++++++++++++++++++++ include/dt-bindings/power/zte,zx297520v3-socsys.h | 11 + include/dt-bindings/reset/zte,zx297520v3-reset.h | 2 + 14 files changed, 670 insertions(+)
---
base-commit: d785d132202e8e8e93335ebf74ad5b29fca0951f
change-id: 20261117-zx29usb-c3a90ab59354
prerequisite-change-id: 20261108-zx29clk-3b073b9d22d6:v14
prerequisite-patch-id: 3ea4ed11578625d6aadf59c5b542e788882eab2f
Best regards,
Signature · 1 line
Stefan Dösinger <[email protected]>
Stefan Dösinger
maintainerPATCH 1/6 dt-bindings: soc: zte: Document zx297520v3 socsys controller
The best way to sum up this controller is probably "misc". ZTE probably put everything they didn't bother to put in its own mmio area here. Documentation in ZTE's sources is very sparse and even the blobs only touch a handful of registers.
The controller contains power controls, resets, DMA multiplexing, auxiliary USB phy controls, i2s controls, the proprietary DSP boot address and many others.
For power controls I could confirm that the USB/HSIC and a GSM-related controls work. There are 5 bits mentioned in ZTE's kernel though and there is a second register that is used in a very similar fashion by the LTE blob.
For the Ethernet PHY reset register there are 5 settable bits, but only one of them produces an understood effect. I am using reset-cells=1 because it is likely some of the other bits have an actual meaning.
---
ZTE uses the name "SOC_SYS" in their downstream kernel. I am not particularly thrilled by that name, but couldn't come up with a better one yet. I am open to suggestions
I do not want to commit to exposing the GSM related bits as power domains just yet, so no handle for them is defined in this binding. They are inside the RST/ISO/PWR registers just like their USB counterpart, but the PWR bit does nothing and the client driver will have to assert and deassert the reset to wake up the hardware. This is easier to do with a reset controller than a power domain. The ISO bit kinda works though, so I can't just pretend they are standalone resets.
The hardware behind the GSM bits has a self-arming watchdog. After 2.5ms it puts itself into a broken state and can only be recovered by asserting and deasserting the reset in socsys. Like almost everything on this board it is enabled on boot, so the client driver needs to assert and deassert the reset before touching it.
How much documentation is appropriate in the binding .yaml? I want to document the identified registers *somewhere*, and since the yaml lives in Documentation/ I put it there. I do understand though if the Linux kernel doesn't want to be a backup SoC datasheet.
--- .../bindings/soc/zte/zte,zx297520v3-socsys.yaml | 100 +++++++++++++++++++++ MAINTAINERS | 1 + include/dt-bindings/power/zte,zx297520v3-socsys.h | 11 +++ include/dt-bindings/reset/zte,zx297520v3-reset.h | 2 + 4 files changed, 114 insertions(+)
Documentation/devicetree/bindings/soc/zte/zte,zx297520v3-socsys.yaml new file +100 -0
@@ -0,0 +1,100 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/soc/zte/zte,zx297520v3-socsys.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: ZTE zx297520v3 SoC miscellaneous system controller + +maintainers: + - Stefan Dösinger <[email protected]> + +description: | + This controller contains registers controlling numerous components of the + zx297520v3 board. It is poorly documented by sources available from ZTE. + Information about it has mostly been deduced by experimental testing. + + The device contains power controls for USB and at least parts of the GSM/LTE + stack, a reset control for the Ethernet PHY, DMA multiplexing, I2S controls + and additional (beyond power) USB PHY and controller flags. To round it out it + also contains a flag to bring up the SoC's Cortex A53 CPU in arm64 instead of + arm32 mode. + + The "include/dt-bindings/reset/zte,zx297520v3-reset.h" header contains reset + defines for this device. "dt-bindings/power/zte,zx297520v3-socsys.h" contains + the power domain defines. + + The following registers are mentioned in ZTE's kernel and U-Boot code dumps: + 0x0: + Bit 23: Boot ROM and sram2 remap + 0x20: + Bit 13: A USB control "USB PHY COMMONONN", but without noticeable effect + 0x40: + A mailbox system to read DDR mode registers + 0x60: + I2S configuration + 0x10c, 0x110, 0x114: + Power domain controls: RST (Reset), ISO (Bus isolation) and POWERON. ZTE + names devices "RAM", "DSP", "EDCP", "USB" and "HSIC". + 0x120: + DMA channel multiplexing + 0x150: + Ethernet PHY reset + + The following registers are used in ZTE's power management and LTE blobs: + 0x14: + Likely the ZSP rproc entrypoint + 0x180, 0x184, 0x188: + Likely more power domain controls for LTE hardware + + The following have been deduced by testing: + 0x20: + USB PHY and DWC2 controller controls: + Bit 0: Force PHY into USB 1 mode + Bit 1: Unknown + Bit 2: DWC2 controller endianness + Bit 3: DWC2 DMA endianness + Bits 7:4: PHY clock adjustments + Bits 9:8: PHY electrical configuration. Setting them both to 1 allows + operating in host mode. + 0x24: + More USB controls of unknown nature + 0x2c: + HSIC controls mirroring the USB controls in 0x20 + 0xbc: + A53 mode controls. Setting bit 0 enables arm64 mode, others have no observable effect + +properties: + compatible: + items: + - const: zte,zx297520v3-socsys + - const: syscon + + reg: + maxItems: 1 + + "#power-domain-cells": + const: 1 + + "#reset-cells": + const: 1 + +required: + - compatible + - reg + - "#power-domain-cells" + - "#reset-cells" + +additionalProperties: false + +examples: + - | + #include <dt-bindings/power/zte,zx297520v3-socsys.h> + #include <dt-bindings/reset/zte,zx297520v3-reset.h> + + syscon@140000 { + compatible = "zte,zx297520v3-socsys", "syscon"; + reg = <0x00140000 0x400>; + #power-domain-cells = <1>; + #reset-cells = <1>; + };
MAINTAINERS +1 -0
@@ -4033,6 +4033,7 @@ F: Documentation/devicetree/bindings/arm/zte.yaml F: Documentation/devicetree/bindings/clock/zte,zx297520v3-lspcrm.yaml F: Documentation/devicetree/bindings/clock/zte,zx297520v3-matrixcrm.yaml F: Documentation/devicetree/bindings/clock/zte,zx297520v3-topcrm.yaml +F: Documentation/devicetree/bindings/soc/zte/zte,zx297520v3-socsys.yaml F: arch/arm/boot/dts/zte/ F: arch/arm/mach-zte/ F: drivers/clk/zte/
include/dt-bindings/power/zte,zx297520v3-socsys.h new file +11 -0
@@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */ +/* +* Copyright (C) Stefan Dösinger +*/ + +#ifndef __DT_BINDINGS_POWER_ZTE_ZX297520V3_SOCSYS_H +#define __DT_BINDINGS_POWER_ZTE_ZX297520V3_SOCSYS_H + +#define ZX297520V3_PD_USB 0 + +#endif /* __DT_BINDINGS_POWER_ZTE_ZX297520V3_SOCSYS_H */
include/dt-bindings/reset/zte,zx297520v3-reset.h +2 -0
@@ -59,4 +59,6 @@#define ZX297520V3_TIMER_L11_RESET 16#define ZX297520V3_TDM_RESET 17 +#define ZX297520V3_ETH_PHY_RESET 0 +#endif /* __DT_BINDINGS_RESET_ZX297520V3_H */
Signature · 1 line
2.56.1
[email protected]
AI reviewRe: [PATCH 1/6] dt-bindings: soc: zte: Document zx297520v3 socsys controller
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Low] dt-bindings: soc: zte: missing MAINTAINERS entry for power binding header --
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Low] dt-bindings: soc: zte: missing MAINTAINERS entry for power binding header
--
commit 4865a5ea2f1de7886db40030f6e9d98eb90cad89
Author: Stefan Dösinger <[email protected]>
dt-bindings: soc: zte: Document zx297520v3 socsys controller
This commit adds the Device Tree binding schema, power domain header, and Ethernet PHY reset constant for the ZTE zx297520v3 socsys miscellaneous system controller.
MAINTAINERS F: Documentation/devicetree/bindings/arm/zte.yaml · line 4039
Quoted 12 lines
MAINTAINERS +1
-0@@ -4033,6 +4033,7 @@ F: Documentation/devicetree/bindings/arm/zte.yaml F: Documentation/devicetree/bindings/clock/zte,zx297520v3-lspcrm.yaml F: Documentation/devicetree/bindings/clock/zte,zx297520v3-matrixcrm.yaml F: Documentation/devicetree/bindings/clock/zte,zx297520v3-topcrm.yaml +F: Documentation/devicetree/bindings/soc/zte/zte,zx297520v3-socsys.yaml F: arch/arm/boot/dts/zte/ F: arch/arm/mach-zte/ F: drivers/clk/zte/
[Severity: Low]
Should this section also list the new include/dt-bindings/power/zte,zx297520v3-socsys.h header added in this patch alongside the existing include/dt-bindings/* entries?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Stefan Dösinger
maintainerPATCH 2/6 mfd: zx297520v3: Add socsys to the mfd host driver
In reply to Stefan DösingerThis patch adds the parts of the zx297520v3 socsys controller, that can be exposed via established driver APIs to the MFD host driver, so that drivers in the respective subsystems can consume them. For now these are a reset controller for Ethernet and maybe more, and a power domain controller for USB, GSM and possibly a cryptographic engine.
---
This series does not contain a driver for the reset child, as implementing Ethernet is beyond the scope of the series and needs other prerequisites (namely pincontrol).
--- drivers/mfd/zte-zx297520v3-crm.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/mfd/zte-zx297520v3-crm.c +12 -0
@@ -23,6 +23,7 @@ enum zx_device_type {TYPE_TOPCRM ,TYPE_MATRIXCRM ,TYPE_LSPCRM , + TYPE_SOCSYS, }; static const struct mfd_cell zx297520v3_topcrm_cells[] = {
@@ -42,6 +43,11 @@ static const struct mfd_cell zx297520v3_lspcrm_cells[] = { MFD_CELL_NAME("zx297520v3-lspreset"), }; +static const struct mfd_cell zx297520v3_socsys_cells[] = { +MFD_CELL_NAME ("zx297520v3-socsys-reset" ), +MFD_CELL_NAME ("zx297520v3-socsys-power" ), +}; +static int zx297520v3_crm_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev;
@@ -77,6 +83,11 @@ static int zx297520v3_crm_probe(struct platform_device *pdev) "Failed to deassert reset control\n");break ; +case TYPE_SOCSYS : + cells = zx297520v3_socsys_cells; + num_cells =ARRAY_SIZE (zx297520v3_socsys_cells); +break ; +default :return -ENODEV ; }
@@ -88,6 +99,7 @@ static const struct of_device_id of_match_zx297520v3_crm[] = { { .compatible = "zte,zx297520v3-topcrm", .data = (void *)TYPE_TOPCRM }, { .compatible = "zte,zx297520v3-matrixcrm", .data = (void *)TYPE_MATRIXCRM }, { .compatible = "zte,zx297520v3-lspcrm", .data = (void *)TYPE_LSPCRM }, + { .compatible = "zte,zx297520v3-socsys", .data = (void *)TYPE_SOCSYS }, { } };MODULE_DEVICE_TABLE (of, of_match_zx297520v3_crm);
Signature · 1 line
2.56.1
Stefan Dösinger
maintainerPATCH 3/6 pmdomain: zte: Add a zx297520v3 power domain driver
In reply to Stefan DösingerThis controller has bits for USB, HSIC, EDCP (a cryptographic engine) and GSM. Not all of them work the way one might expect (see comments in the code), but they are there and can be set.
---
For now this driver can only enable and disable the USB controller. I expect more LTE related power switches will be added later, but I don't want to commit to how I expose GSM and EDCP in the bindings just yet.
--- MAINTAINERS | 1 + drivers/pmdomain/Kconfig | 1 + drivers/pmdomain/Makefile | 1 + drivers/pmdomain/zte/Kconfig | 15 ++ drivers/pmdomain/zte/Makefile | 2 + drivers/pmdomain/zte/zx297520v3-pm-domain.c | 286 ++++++++++++++++++++++++++++ 6 files changed, 306 insertions(+)
MAINTAINERS +1 -0
@@ -4038,6 +4038,7 @@ F: arch/arm/boot/dts/zte/ F: arch/arm/mach-zte/ F: drivers/clk/zte/ F: drivers/mfd/zte-zx297520v3-crm.c +F: drivers/pmdomain/zte/ F: include/dt-bindings/clock/zte,zx297520v3-clk.h F: include/dt-bindings/phy/zte,zx297520v3-topcrm.h F: include/dt-bindings/reset/zte,zx297520v3-reset.h
drivers/pmdomain/Kconfig +1 -0
@@ -21,5 +21,6 @@ source "drivers/pmdomain/tegra/Kconfig" source "drivers/pmdomain/thead/Kconfig" source "drivers/pmdomain/ti/Kconfig" source "drivers/pmdomain/xilinx/Kconfig" +source "drivers/pmdomain/zte/Kconfig" endmenu
drivers/pmdomain/Makefile +1 -0
@@ -19,4 +19,5 @@ obj-y += tegra/ obj-y += thead/ obj-y += ti/ obj-y += xilinx/ +obj-y += zte/ obj-y += core.o governor.o
drivers/pmdomain/zte/Kconfig new file +15 -0
@@ -0,0 +1,15 @@ +# SPDX-License-Identifier: GPL-2.0-only + +config ZTE_ZX297520V3_PM_DOMAIN + tristate "ZTE zx297520v3 pm domain" + depends on HAS_IOMEM + depends on PM + depends on MFD_ZTE_ZX297520V3_CRM || COMPILE_TEST + default SOC_ZX297520V3 + select PM_GENERIC_DOMAINS + select MFD_SYSCON + help + Say y to enable the power domain driver for ZTE zx297520v3 boards. + This driver is necessary to enable the USB hardware found on this + board. Say y or m if you are building a kernel for a zx297520v3 based + device and plan to use its USB capabilities.
drivers/pmdomain/zte/Makefile new file +2 -0
@@ -0,0 +1,2 @@ +# SPDX-License-Identifier: GPL-2.0-only +obj-$(CONFIG_ZTE_ZX297520V3_PM_DOMAIN) += zx297520v3-pm-domain.o
drivers/pmdomain/zte/zx297520v3-pm-domain.c new file +286 -0
286 lines not on this page · raw message
Signature · 1 line
2.56.1
[email protected]
AI reviewRe: [PATCH 3/6] pmdomain: zte: Add a zx297520v3 power domain driver
Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [High] pmdomain: zte: child-to-parent device link deadlock in zx29_pd_probe() - [High] pmdomain: zte: wrong…
Thank you for your contribution! Sashiko AI review found 2 potential issues to consider:
- [High] pmdomain: zte: child-to-parent device link deadlock in zx29_pd_probe()
- [High] pmdomain: zte: wrong supplier device in zx29_pd_attach_dev() device link
--
commit 65d36c75a56ee45de3b21629f8434fb30bf2339b
Author: Stefan Dösinger <[email protected]>
pmdomain: zte: Add a zx297520v3 power domain driver
This commit adds a power domain driver for the ZTE zx297520v3 SoC to control the power, reset, and bus isolation registers for the USB controller.
Quoted 5 lines
drivers/pmdomain/zte/zx297520v3-pm-domain.c new file +0
-0
[ ... ]
drivers/pmdomain/zte/zx297520v3-pm-domain.c line 156
Quoted 11 lines
drivers/pmdomain/zte/zx297520v3-pm-domain.c new file +11
-0+static int zx29_pd_attach_dev (struct generic_pm_domain *domain,struct device *dev) +{ +/* The DT link to the consumer targets the (MFD) parent, which doesn't prevent unbinding the +* this driver or removing the module. Either would leave the consumer with a dangling +* reference. +*/ +if (!device_link_add (dev, &domain->dev,DL_FLAG_AUTOREMOVE_CONSUMER )) +return -ENOMEM ; + +return 0 ; +}
[Severity: High]
Should the device link supplier here be the zx297520v3-socsys-power platform device (&pdev->dev) rather than &domain->dev?
&domain->dev is the internal genpd provider device deleted by of_genpd_del_provider(). Because no consumer link targets &pdev->dev, unbinding this driver starts devres teardown while consumers are still bound and only unbinds them inside zx29_pd_release_provider() -> of_genpd_del_provider() -> device_del(&gpd->dev) under gpd_list_lock and of_genpd_mutex.
That inverts the normal lock order against a probing consumer that already holds device_lock(consumer) while calling dev_pm_domain_attach() -> genpd_dev_pm_attach():
CPU0 CPU1
---- ----lock(&consumer->mutex)
lock(&gpd_list_lock) lock(&of_genpd_mutex)lock(&gpd_list_lock)
lock(&consumer->mutex)
*** DEADLOCK ***
CPU0: really_probe(consumer) -> ... -> genpd_get_from_provider()
CPU1: zx29_pd_release_provider() -> of_genpd_del_provider() ->
device_del(&gpd->dev) -> ... -> device_links_unbind_consumers()
In addition, if a consumer attaches via genpd_dev_pm_attach_by_id() or genpd_dev_pm_attach_by_name(), dev is a driverless virtual device on genpd_bus_type, so its link to &domain->dev stays in DL_STATE_AVAILABLE:device_links_unbind_consumers() never detaches it, device_links_driver_cleanup() hits WARN_ON(), and pm_genpd_remove() fails with -EBUSY right before devres frees zx29_pd, leaving a freed generic_pm_domain on gpd_list.
[ ... ]
Quoted 2 lines
drivers/pmdomain/zte/zx297520v3-pm-domain.c new file +2
-0+static int zx29_pd_probe (struct platform_device *pdev) +{
[ ... ]
drivers/pmdomain/zte/zx297520v3-pm-domain.c line 265
Quoted 10 lines
drivers/pmdomain/zte/zx297520v3-pm-domain.c new file +10
-0+ res =of_genpd_add_provider_onecell (of_node, zx29_pd_data); +if (res) +return dev_err_probe (dev, res,"Cannot register power domains\n" ); + +device_link_add (dev, dev->parent,DL_FLAG_AUTOREMOVE_CONSUMER ); + +dev_dbg (dev,"zx297520v3 power domain initialized.\n" ); + +return devm_add_action_or_reset (dev, zx29_pd_release_provider, of_node); +}
[Severity: High]
Can adding a managed device link from dev to dev->parent deadlock when zx297520v3_crm_probe() registers its MFD children after late_initcall (for example on module load or driver rebind)?
zx297520v3_crm_probe() calls devm_mfd_add_devices() while really_probe() holds device_lock(dev->parent). Because of_genpd_add_provider_onecell() sets genpd_sync_state on dev->parent, finishing dev's probe queues sync_state on dev->parent and tries to lock dev->parent again on the same thread:
really_probe(dev->parent)
device_lock(dev->parent)
zx297520v3_crm_probe()
devm_mfd_add_devices()
...
really_probe(dev)
zx29_pd_probe()
of_genpd_add_provider_onecell(dev->parent->of_node, ...)
device_link_add(dev, dev->parent, DL_FLAG_AUTOREMOVE_CONSUMER)
driver_bound(dev)
device_links_driver_bound(dev)
device_links_flush_sync_list(..., dev)
device_lock(dev->parent) <-- self-deadlockSince dev is a child device registered via devm_mfd_add_devices() on dev->parent, the driver core already orders suspend/resume and removes dev when dev->parent unbinds without this link.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
Stefan Dösinger
maintainerRe: [PATCH 3/6] pmdomain: zte: Add a zx297520v3 power domain driver
Am Freitag, 20. November 2026, 22:51:31 Ostafrikanische Zeit schrieb sashiko- [email protected]:
Quoted 4 lines
Thank you for your contribution! Sashiko AI review found 2 potential issues to consider:
- [High] pmdomain: zte: child-to-parent device link deadlock inzx29_pd_probe()
This looks correct - the particular line shouldn't be there, it was a leftover from earlier attempts to handle device unbind.
Quoted 2 lines
- [High] pmdomain: zte: wrong supplier device in
zx29_pd_attach_dev()device link
This one is likely correct, but I'll have to do more reading to be sure
Stefan Dösinger
maintainerPATCH 4/6 phy: zte: Add a zx29 USB PHY driver.
In reply to Stefan DösingerThis driver's responsibility is the correct reset sequencing of the USB and HSIC PHYs. Before the ready flag is set in topcrm+0x84, the dwc2 controller mmio space reads zeroes. Waiting for them is therefore necessary to avoid race conditions on boot.
---
Possible future features are host mode support and adjusting the USB PHY to mpll over/underclocking. But both are unlikely to have productive use on this platform. None of the zx29 boards I have seen so far can provide power on VBUS.
The PHY driver reuses the topcrm node for the MFD child device because the PHY subsystem enforces that the device either matches the of_node or is a parent of the of_node (__of_phy_provider_register). Krzysztof rejected a PHY child node [0] for the purpose of satisfying the check.
One issue - and that's possibly the reason for the PHY subsystem's behavior - is that nothing prevents the phy driver from being unbound because the DT producer-consumer relationship targets the MFD parent. I have set suppress_bind_attrs = true, but that feels ugly and only solves half the problem. The module can still be unloaded without first releasing the USB consumer.
0:
https://lore.kernel.org/linux-arm-kernel/20260717-uncovered-feathered-groundhog-eab16e@quoll/
--- MAINTAINERS | 1 + drivers/phy/Kconfig | 11 +++ drivers/phy/Makefile | 1 + drivers/phy/phy-zx29-usb.c | 183 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 196 insertions(+)
MAINTAINERS +1 -0
@@ -4038,6 +4038,7 @@ F: arch/arm/boot/dts/zte/ F: arch/arm/mach-zte/ F: drivers/clk/zte/ F: drivers/mfd/zte-zx297520v3-crm.c +F: drivers/phy/phy-zx29-usb.c F: drivers/pmdomain/zte/ F: include/dt-bindings/clock/zte,zx297520v3-clk.h F: include/dt-bindings/phy/zte,zx297520v3-topcrm.h
drivers/phy/Kconfig +11 -0
@@ -169,6 +169,17 @@ config PHY_XGENE help This option enables support for APM X-Gene SoC multi-purpose PHY. +config PHY_ZTE_ZX29_USB + tristate "ZTE zx29 USB phy" + depends on MFD_SYSCON && OF && (ARCH_ZTE || COMPILE_TEST) + select GENERIC_PHY + help + This option enables support for ZTE zx29 USB PHYs. You will need this + if you have a ZTE zx29 board and want to use its external USB + connector for data transfer. This driver is not required purely for + providing power to the board. If M is selected, the module will be + called phy-zx29-usb. + source "drivers/phy/allwinner/Kconfig" source "drivers/phy/amlogic/Kconfig" source "drivers/phy/apple/Kconfig"
drivers/phy/Makefile +1 -0
@@ -19,6 +19,7 @@ obj-$(CONFIG_PHY_NXP_TJA1145) += phy-nxp-tja1145.o obj-$(CONFIG_PHY_PISTACHIO_USB) += phy-pistachio-usb.o obj-$(CONFIG_PHY_SNPS_EUSB2) += phy-snps-eusb2.o obj-$(CONFIG_PHY_XGENE) += phy-xgene.o +obj-$(CONFIG_PHY_ZTE_ZX29_USB) += phy-zx29-usb.o obj-$(CONFIG_GENERIC_PHY) += allwinner/ \ amlogic/ \
drivers/phy/phy-zx29-usb.c new file +183 -0
183 lines not on this page · raw message
Signature · 1 line
2.56.1
[email protected]
AI reviewRe: [PATCH 4/6] phy: zte: Add a zx29 USB PHY driver.
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] phy: zte: OF node refcount leak in phy_zx29_probe() via wrong helper --
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Medium] phy: zte: OF node refcount leak in phy_zx29_probe() via wrong helper
--
commit 15ae50d59e0e993615e70ce4fb99a2131fc91c46
Author: Stefan Dösinger <[email protected]>
phy: zte: Add a zx29 USB PHY driver.
This commit adds a PHY driver for the ZTE zx29 USB and HSIC PHYs to handle reset sequencing and ready status polling in the topcrm syscon.
Quoted 5 lines
drivers/phy/phy-zx29-usb.c new file +0
-0
[ ... ]
drivers/phy/phy-zx29-usb.c line 134
Quoted 8 lines
drivers/phy/phy-zx29-usb.c new file +8
-0+static int phy_zx29_probe (struct platform_device *pdev) +{ +struct phy_provider *phy_provider; +struct device *dev = &pdev->dev; +struct phy_zx29_drv_priv *priv; +unsigned int i; + +device_set_of_node_from_dev (dev, dev->parent);
[Severity: Medium]
Should this call platform_device_set_of_node_from_dev(pdev, dev->parent) instead of device_set_of_node_from_dev()?
device_set_of_node_from_dev() takes a reference on dev->parent->of_node and sets dev->of_node, but leaves pdev->dev.fwnode NULL. When the platform device is released, platform_device_release() drops pa->pdev.dev.fwnode rather than dev->of_node, leaking the OF node reference.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
Stefan Dösinger
maintainerPATCH 5/6 ARM: dts: zte: Declare nodes to enable the board's dwc2 controller
In reply to Stefan DösingerThis adds the socsys syscon that provides the power control for the controller and the dwc2 controller itself.
On all boards I have seen so far the USB connector can only operate in peripheral mode - including one device that actually has a USB A connector. DWC2 and the PHY can be programmed into host mode, but there is no VBUS power supply.
--- arch/arm/boot/dts/zte/zx297520v3.dtsi | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
arch/arm/boot/dts/zte/zx297520v3.dtsi +23 -0
@@ -5,6 +5,8 @@ #include <dt-bindings/clock/zte,zx297520v3-clk.h> #include <dt-bindings/interrupt-controller/arm-gic.h> +#include <dt-bindings/phy/zte,zx297520v3-topcrm.h> +#include <dt-bindings/power/zte,zx297520v3-socsys.h> #include <dt-bindings/reset/zte,zx297520v3-reset.h> / {
@@ -111,6 +113,13 @@ reboot { }; }; + socsys: syscon@140000 { + compatible = "zte,zx297520v3-socsys", "syscon"; + reg = <0x00140000 0x400>; + #power-domain-cells = <1>; + #reset-cells = <1>; + }; + matrixcrm: clock-controller@1306000 { compatible = "zte,zx297520v3-matrixcrm"; reg = <0x01306000 0x400>;
@@ -176,5 +185,19 @@ uart2: serial@140d000 { status = "disabled"; }; + + usb@1500000 { + compatible = "snps,dwc2"; + reg = <0x01500000 0x40000>; + interrupts = <GIC_SPI 41 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&topcrm ZX297520V3_USB_WCLK>, <&topcrm ZX297520V3_USB_PCLK>; + clock-names = "otg", "utmi"; + dr_mode = "peripheral"; + resets = <&topcrm ZX297520V3_USB_RESET>; + reset-names = "dwc2"; + power-domains = <&socsys ZX297520V3_PD_USB>; + phys = <&topcrm ZX297520V3_USB_PHY>; + phy-names = "usb2-phy"; + }; }; };
Signature · 1 line
2.56.1
Stefan Dösinger
maintainerPATCH 6/6 ARM: dts: zte: Declare the HSIC controller node
In reply to Stefan DösingerThis is for documentation purposes. I have not seen any board yet that actually connects anything to it. On newer boards it seems to be removed entirely.
--- arch/arm/boot/dts/zte/zx297520v3.dtsi | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
arch/arm/boot/dts/zte/zx297520v3.dtsi +19 -0
@@ -199,5 +199,24 @@ usb@1500000 { phys = <&topcrm ZX297520V3_USB_PHY>; phy-names = "usb2-phy"; }; + + /* The HSIC controller exists primarily on older hardware, but I haven't seen any + * device that is actually connected to it on any board. + */ + usb@1600000 { + compatible = "snps,dwc2"; + reg = <0x01600000 0x40000>; + interrupts = <GIC_SPI 44 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&topcrm ZX297520V3_HSIC_WCLK>, <&topcrm ZX297520V3_HSIC_PCLK>; + clock-names = "otg", "utmi"; + dr_mode = "host"; + resets = <&topcrm ZX297520V3_HSIC_RESET>; + reset-names = "dwc2"; + power-domains = <&socsys ZX297520V3_PD_USB>; + phys = <&topcrm ZX297520V3_HSIC_PHY>; + phy-names = "usb2-phy"; + + status = "disabled"; + }; }; };
Signature · 1 line
2.56.1
[email protected]
AI reviewSashiko has finished reviewing this 6-patch series:
Sashiko has finished reviewing this 6-patch series:
- Patches 2, 5, and 6: no issues found.
- Patch 1 ("dt-bindings: soc: zte: Document zx297520v3 socsys co..."): 1 potential issue (1 Low)
- Patch 3 ("pmdomain: zte: Add a zx297520v3 power domain driver"): 2 potential issues (2 High)
- Patch 4 ("phy: zte: Add a zx29 USB PHY driver."): 1 potential issue (1 Medium)
Detailed reviews have been sent as separate replies to patches 1, 3, and 4.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]