Skip to content

realtek: add Realtek PSE MCU driver - #23222

Merged
openwrt-bot merged 5 commits into
openwrt:mainfrom
jonasjelonek:realtek/pse-driver
Jul 14, 2026
Merged

openwrt-bot merged 5 commits into
openwrt:mainfrom
jonasjelonek:realtek/pse-driver

Conversation

@jonasjelonek

@jonasjelonek jonasjelonek commented May 4, 2026 •

Copy link
Copy Markdown
Member

My WIP attempt for a driver that makes use of PSE-PD framework and may allow us to drop realtek-poe and poemgr for Realtek switches, making PoE on those devices better available.

FWIW, this works as-is on Zyxel XMG1915-10EP (PoE MCU attached via UART) and Zyxel XGS1930-28HP (PoE MCU attached via I2C). Ports can be enabled/disabled, power limit can be set, state is properly available in ethtool. Supports both Realtek dialect and Broadcom dialect.

Feedback is welcome, especially from driver architects and PSE/PoE experts

@jonasjelonek
jonasjelonek force-pushed the realtek/pse-driver branch from 76ffcde to ed6f9a2 Compare May 4, 2026 21:02
@github-actions github-actions Bot added kernel pull request/issue with Linux kernel related changes target/realtek pull request/issue for realtek target labels May 5, 2026
@RaylynnKnight

Copy link
Copy Markdown
Contributor

I would suggest you contact Bootlin engineer Köry Maincent to see if he would be interested in reviewing for you as he was responsible for the development and upstreaming of the original PoE support in 2023 and 2024.

@openwrt-ai openwrt-ai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed both new commits. Inline comments cover three definite build/runtime bugs (pse->mutex in the UART probe, if (!r) in rtl_pse_port_get_pw_limit_ranges, req.payload[] reads in rtl_pse_mcu_get_ext_config), a config mismatch (the new symbols are =y while the commit message and the deferred-probe pending patch assume modules), plus framing / ranging / indentation observations.

Commit checks

  • f3ec28b "WIP generic: pse-pd: add pending patches for module-based PSE drivers" — body matches diff.
  • ed6f9a2 "WIP realtek: add PSE driver for Realtek PoE MCUs" — message says "enable the new symbols as modules in rtl930x/config-6.18", but the diff sets CONFIG_PSE_REALTEK{,_I2C,_UART}=y (built-in). Either flip to =m or correct the message.

Generated by Claude Code

@openwrt-ai openwrt-ai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commit checks

  • ed6f9a25 "WIP realtek: add PSE driver for Realtek PoE MCUs" — commit message says "enable the new symbols as modules in rtl930x/config-6.18", but the diff enables them built-in (CONFIG_PSE_REALTEK=y, CONFIG_PSE_REALTEK_I2C=y, CONFIG_PSE_REALTEK_UART=y). Either flip to =m or update the wording. (See inline comment on the config hunk.)

To address review feedback, force-push fixes to this branch. Don't close and open a new PR — that loses the review history and the bot starts from scratch.


Generated by Claude Code

@jonasjelonek
jonasjelonek force-pushed the realtek/pse-driver branch 2 times, most recently from 2e4a548 to 98ee694 Compare May 5, 2026 19:43
@jonasjelonek

Copy link
Copy Markdown
Member Author

Changes compared to previous version:

  • Per-SKU DT compatibles (realtek,rtl8238b/8239/8239c) with chip-info instances exported from core (device_id, max_mW_per_port, pw_read_lsb_mW, pw_set_cmd, pw_set_lsb_mW); transports share RTL_PSE_OF_MATCH_ENTRIES macro for their local of_device_id[]. No transport-specific compatible anymore.
  • Per-port state: struct rtl_pse_port { pse, idx, max_mW }, __counted_by(nr_ports) array, populated from MCU port count + per-PI max-power-milliwatt DT overrides, clamped against chip->max_mW_per_port.
  • Port-ref refactor: every port-scoped helper takes struct rtl_pse_port *; single rtl_pse_port_from_pcdev bridge resolves (pcdev, id) once and bounds-checks.
  • Transport ops table: anonymous struct replaced with named struct rtl_pse_transport_ops; each transport ships a static const ops table.
  • Probe hardening: devm_mutex_init + guard(mutex) centralized in core; -EPROBE_DEFER on MCU timeout; conditional set_global_state(true) when MCU booted disabled; banner includes num_of_pses; pcdev.nr_lines driven by MCU report.
  • Header reshuffle: parsed-response structs moved into core; header is strictly cross-module ABI.
  • Power-limit per-chip data (hw bring-up): set_pw_limit is purely data-driven on chip->pw_set_cmd + chip->pw_set_lsb_mW; get_pw_limit uses chip->pw_read_lsb_mW. RTL8238B (AT) → 0x13 at 200 mW/LSB; RTL8239/8239C (BT) → 0x14 at 400 mW/LSB. Matches realtek-poe / poemgr conventions
    one-opcode-per-silicon.
  • Cleanups: dropped redundant zero-inits, kcalloc(1)→kzalloc, port-echo verify in port_query, get_pw_status simplified (REQUESTING→SEARCHING), of_property_→fwnode_property_, partial-failure comment in set_pw_limit
  • probe info line cleanup

(summarized by Claude)

@jonasjelonek
jonasjelonek requested a review from openwrt-ai May 14, 2026 13:07
@carlosz1986

Copy link
Copy Markdown
Contributor

thx for the great work @jonasjelonek :-)
I think we should try to bring this upstream later.

For the hs104 Oleksij suggested to merge it as well ...

I have a similar device and will give it a try soon!

@jonasjelonek

Copy link
Copy Markdown
Member Author

thx for the great work @jonasjelonek :-) I think we should try to bring this upstream later.

Sure, but later. This isn't mature enough and I do not have the patience going through 500 review rounds upstream possibly changing the driver architecture every 5th time. I'd rather develop that downstream until it's good enough for upstream.

For the hs104 Oleksij suggested to merge it as well ...

great, I'd like to see this LED stuff too and am happy to implement it in this driver as well then. How about the other patch from you I included here, is that on it's way upstream already?

@carlosz1986

carlosz1986 commented May 15, 2026 •

Copy link
Copy Markdown
Contributor

thx for the great work @jonasjelonek :-) I think we should try to bring this upstream later.

Sure, but later. This isn't mature enough and I do not have the patience going through 500 review rounds upstream possibly changing the driver architecture every 5th time. I'd rather develop that downstream until it's good enough for upstream.

For the hs104 Oleksij suggested to merge it as well ...

great, I'd like to see this LED stuff too and am happy to implement it in this driver as well then. How about the other patch from you I included here, is that on it's way upstream already?

Jeah the 500 review rounds I also faced:D

LED piece - is that what you meant? https://lore.kernel.org/all/[email protected]/
I am on it...

For target/linux/generic/pending-6.18/897-net-pse-pd-fix-pairset-return-value-check.patch I don't recall from the top of my head...

and the other piece defer is here
https://lore.kernel.org/all/[email protected]/

@jonasjelonek

jonasjelonek commented May 15, 2026 •

Copy link
Copy Markdown
Member Author

The LED stuff yes, and that loading of PSE can be deferred. I needed that too to make my stuff work.

The 897 patch is mine, I probably need to send that upstream.

EDIT: Submitted at https://lore.kernel.org/netdev/[email protected]/T/#u

@openwrt-ai openwrt-ai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed at 711dd949. The previous round's 22 findings are addressed (header guard, req/resp swap, indentation, undefined identifiers, =y/=m mismatch wording). Two new framework-integration issues are flagged inline: pse-pis is missing the mandatory #address-cells/#size-cells cells, and pcdev.pis_prio_max / pcdev.supp_budget_eval_strategies are unset so pi_set_prio is unreachable from ethtool.


Generated by Claude Code

@jonasjelonek

Copy link
Copy Markdown
Member Author

Changes in latest round:

  • Driver sources moved from realtek/files-6.18/ to generic/files/ (driver isn't really Realtek-SoC-specific)
  • Patch renumbered/moved: realtek/patches-6.18/815-* → generic/pending-6.18/898-net-pse-pd-add-realtek-pse-driver.patch
  • added DT binding schemas: Documentation/devicetree/bindings/net/pse-pd/{realtek,rtl823x.yaml,brcm,bcm59xxx.yaml}
  • Switched from kernel-builtin to kmod packaging: 3 new KernelPackage entries (kmod-pse-realtek{,-i2c,-uart}) in pse-pd.mk
  • Subtarget configs: dropped builtin PSE_* / SERIAL_DEV_* symbols; added CONFIG_REGULATOR{,_FIXED_VOLTAGE}=y to satisfy @REGULATOR_SUPPORT
  • File/module rename: rtl-pse-* → realtek-pse-* (sources, .ko, .name, AUTOLOAD, FILES, includes, MODULE_DESCRIPTION)
  • Title/description harmonized everywhere
  • C identifiers tightened: rtl_pse_* → rtpse_*, struct rtpse → rtpse_ctrl, rtpse_msg → rtpse_mcu_msg, header guard updated
  • Extracted rtpse_discover() from rtpse_register()
  • Added balanced regulator enable/disable via devm_add_action_or_reset
  • Dropped unused rtpse_mcu_msg union → plain u8 seq_num
  • Dropped unused rtpse_port_status.sts4..sts8
  • Wired up previously-uninitialised chip_addr from resp.payload[5]
  • Replaced literal 0x2 with RTPSE_PORT_PW_LIMIT_TYPE_USER
  • Added i2c_device_id table; dropped unused i2c_set_clientdata
  • File-top architecture comment in realtek-pse-core.c
  • added to-be-tested dialect support and support for BCM59xxx PSE chips
  • added XS1930-12HP support as another working example

(summarized by Claude)

@jonasjelonek jonasjelonek changed the title [WIP] realtek: add PSE driver for RTL823x PoE controllers [WIP] generic: add PSE driver for MCU-fronted RTL823x/BCM59xxx PoE controllers May 20, 2026
@jonasjelonek

Copy link
Copy Markdown
Member Author

@bmork could you give this a test? Just note quite some stuff has changed since the state you did your PoC changes on top of. Most of the DTS change can be used + selecting kmod-realtek-pse-{uart,i2c} in DEVICE_PACKAGES.

@bmork

bmork commented May 20, 2026 •

Copy link
Copy Markdown
Contributor

could you give this a test?

Will do. There are a couple of minor issues you might want to figure out the best solution for while I'm building:

  1. The kernel modules depend on @REGULATOR_SUPPORT, so that symbol must be selected. It's only enabled for the rtl930x and rtl931x subtargets. I added "regulator" to FEATURES in target/linux/realtek/Makefile, but that might be overkill?
  2. CONFIG_REGULATOR_SUPPORT enables the CONFIG_RAVE_SP_CORE symbol, which is only defined in target/linux/realtek/rtl930x/config-6.18. Must be added to rtl838x etc configs as well. Or maybe moved to generic? Looks like it's defined in a number of different targets

EDIT: I see that you've added CONFIG_REGULATOR=y and CONFIG_REGULATOR_FIXED_VOLTAGE=y to the config for rtl930x and rtl931x, so I assume that's correct for the other subtargets too. You might want to express the dependency on the latter in the module makefile as well. I missed it at first, successfully building empty kmod packages...

@openwrt-ai openwrt-ai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed after the force-push — the branch was rebased and the series substantially restructured, so this is a fresh review of all 5 commits. The previous round's findings (header guard, req/resp swap, indentation, undefined identifiers, =y/=m, pis_prio_max/supp_budget_eval_strategies, missing #address-cells/#size-cells on XMG1915-10EP) are all addressed. Inline comments cover the same pse-pis cells bug reintroduced on the new XS1930-12HP DTS, a node-naming deviation from the binding, and the missing patch header on 898-....

Commit checks

  • 49205d01d "realtek: use rtl-pse kernel driver for PoE on XMG1915-10EP" — message refers to the driver as rtl-pse, but it was renamed to realtek-pse and the diff selects kmod-pse-realtek-uart. Update the wording to match.
  • 373a1c298 "realtek: add PoE support for XS1930-12HP" — body says "using the rtl-pse-i2c driver"; the module/kmod is realtek-pse-i2c / kmod-pse-realtek-i2c (which the diff correctly selects). Stale name in the message.

Generated by Claude Code

@bmork

bmork commented May 20, 2026 •

Copy link
Copy Markdown
Contributor

Not entirely successful, I'm afraid:

[   22.134806] kmodloader: loading kernel modules from /etc/modules.d/*
[   22.259069] realtek-pse-uart serial0-0: ST Micro ST32F100 MCU, BCM59121 (id 0xe121), 8 ports across 1 PSE chip(s)
[   22.270765] Unhandled kernel unaligned access[#1]:
[   22.276171] CPU: 0 UID: 0 PID: 197 Comm: kworker/u4:5 Tainted: G           O        6.18.31 #0 NONE 
[   22.286400] Tainted: [O]=OOT_MODULE
[   22.290310] Hardware name: Zyxel GS1900-10HP A1 Switch
[   22.296060] Workqueue: async async_run_entry_fn
[   22.301203] $ 0   : 00000000 00000001 81ff0000 00000000
[   22.307107] $ 4   : ffffffed 000000b4 81bc5d48 81bc5b00
[   22.313013] $ 8   : 00000000 ffffefff 00000001 ffffffea
[   22.318917] $12   : 000000b4 81bc5ac4 000000b4 00000870
[   22.324821] $16   : 81febe80 80a60000 00000000 00000000
[   22.330727] $20   : 00000009 81eac414 00000005 fffffef7
[   22.336632] $24   : 00000000 80a705e0                  
[   22.342536] $28   : 81bc4000 81bc5cf0 81803400 81b2f49c
[   22.348441] Hi    : 00000000
[   22.351670] Lo    : 00000000
[   22.354900] epc   : 804ce3a4 regulator_enable+0x10/0x54
[   22.360788] ra    : 81b2f49c rtpse_register+0xe8/0xc4c [realtek_pse_core]
[   22.368410] Status: 10107c03 KERNEL EXL IE 
[   22.373134] Cause : 50808010 (ExcCode 04)
[   22.377621] BadVA : 00000045
[   22.380851] PrId  : 00019070 (MIPS 4KEc)
[   22.385243] Modules linked in: realtek_pse_uart realtek_pse_core mdio_netlink(O) gpio_button_hotplug(O)
[   22.395793] Process kworker/u4:5 (pid: 197, threadinfo=4514db63, task=fe5ad6ab, tls=00000000)
[   22.405352] Stack : 2bffaa00 00000001 010000d6 5e5be026 81fd7000 81febe80 80a60000 81fd7000
[   22.414784]         00000000 81febe80 80a60000 81b2f49c 00120f17 16040000 00000000 00000000
[   22.424217]         00000004 0800e121 16000004 00031c7f 15010000 0011131a 00120f17 16040000
[   22.433651]         00000000 5e5be026 00004b00 818ca200 81febe80 81fd7000 00000000 81ff62c8
[   22.443085]         00000000 8050a2ec 818ca248 81fd7000 80c70000 00004b00 818ca200 818ca200
[   22.452518]         ...
[   22.455282] Call Trace:
[   22.458028] [<804ce3a4>] regulator_enable+0x10/0x54
[   22.463533] [<81b2f49c>] rtpse_register+0xe8/0xc4c [realtek_pse_core]
[   22.470776] [<81ff62c8>] __this_module+0x1f248/0x1f290 [realtek_pse_uart]
[   22.479511] 
[   22.481209] Code: afbf002c  afb00024  afb10028 <8c910058> 00808025  27a50010  0c132300  02202025  0c13385f 
[   22.492224] 
[   22.494164] ---[ end trace 0000000000000000 ]---
[   22.499499] Kernel panic - not syncing: Fatal exception

I believe I see the problem. Have to build to confirm. But I didn't configure any poe_supply regulator, only replaced the old gpio-hog with enable-gpios- Problem is that you do

pse->poe_supply = devm_regulator_get_optional(pse->dev, "power");

ignoring the -ENODEV. But pse->poe_supply is not NULL anymore.... And then you do

	if (pse->poe_supply) {
		ret = regulator_enable(pse->poe_supply);

Yup, confirmed. Works fine after adding

diff --git a/target/linux/generic/files/drivers/net/pse-pd/realtek-pse-core.c b/target/linux/generic/files/drivers/net/pse-pd/realtek-pse-core.c
index 19da841125f3..01e5f7e7fe7b 100644
--- a/target/linux/generic/files/drivers/net/pse-pd/realtek-pse-core.c
+++ b/target/linux/generic/files/drivers/net/pse-pd/realtek-pse-core.c
@@ -776,6 +776,7 @@ int rtpse_register(struct rtpse_ctrl *pse)
                ret = PTR_ERR(pse->poe_supply);
                if (ret != -ENODEV)
                        return dev_err_probe(pse->dev, ret, "failed to get PoE supply\n");
+               pse->poe_supply = NULL;
        }
 
        enable_gpio = devm_gpiod_get_optional(pse->dev, "enable", GPIOD_OUT_HIGH);

@github-actions github-actions Bot added the core packages pull request/issue for core (in-tree) packages label May 20, 2026
@jonasjelonek

Copy link
Copy Markdown
Member Author

ahh I see, thanks. Overlooked that, and didn't spotted because my device needs the regulator.

@bmork

bmork commented May 20, 2026

Copy link
Copy Markdown
Contributor

Sorry about all the fragmented feedback. Force pushed all my modifications on top of your branch to
https://github.com/bmork/openwrt/tree/realtek/pse-driver
so you can pick from there if you want.

Don't know if we can enable this for more of the rtl838x Zyxels without testing? I played it safe with only the GS1900-10HP for now. But then we have to move the poe gpio-hog into the other GS1900 dts files.

And thanks a lot for doing all this!

@jonasjelonek

jonasjelonek commented May 20, 2026 •

Copy link
Copy Markdown
Member Author

Valuable feedback anyway.

I included the REGULATOR stuff as KCONFIG in the packages right now, therefore no need to specify it in every subtarget. But RAVE_SP_CORE needs to go in generic kernel config for that. Any idea if that might be an issue? Otherwise I can just pick your commit for that. Scratch that, doesn't seem to work as expected.

I think we can switch the devices step-by-step, testing if people have the devices and otherwise going "just change and see if someone complains".

@jonasjelonek
jonasjelonek force-pushed the realtek/pse-driver branch 2 times, most recently from 5146d58 to 679213f Compare May 20, 2026 16:12
Add a patch which modifies the Realtek PSE MCU driver backport to add a
sysfs control to control detection mode per port. Some older,
bad-designed devices aren't detected properly in standard mode on some
switches, though vendor firmware powers them properly. Testing shows
that enabling the detection of legacy PDs by allowing wider resistance,
more input capacitance and using a wider detection window, solves this
issue.

The legacy detection can be activated by writing 1 to
portN/detection_legacy in the device's sysfs, e.g.

  echo 1 > /sys/bus/i2c/devices/3-0020/port0/detection_legacy

This patch is kept downstream for now, upstreaming will be attempted
though it is likely that upstream prefers a generic pse-pd approach.

Link: openwrt#23222
Signed-off-by: Jonas Jelonek <[email protected]>
Instead of relying on the userspace implementation, make this device the
first user of the new realtek-pse kernel driver (kmod-pse-realtek-mcu-uart)
based on the PSE-PD framework to interface PoE functionality of that
switch. Control of PoE functionality happens via ethtool / netifd now.
Drop selecting realtek-poe for this device.

This doesn't include any support for PoE-related LEDs.

Link: openwrt#23222
Signed-off-by: Jonas Jelonek <[email protected]>
Add support for PoE functionality using the realtek-pse-mcu driver
(kmod-pse-realtek-mcu-i2c) interfacing the on-board PoE MCU and RTL8239
PSE chips.

This doesn't include any support for PoE-related LEDs.

Link: openwrt#23222
Signed-off-by: Jonas Jelonek <[email protected]>
@openwrt-bot
openwrt-bot merged commit e9aa5be into openwrt:main Jul 14, 2026
5 checks passed
@jonasjelonek

Copy link
Copy Markdown
Member Author

For the record, the driver as-is is close to being upstreamed.
https://lore.kernel.org/netdev/[email protected]/

vincenzosuraci pushed a commit to vincenzosuraci/openwrt that referenced this pull request Jul 15, 2026
Add a backport patch and pending patches needed by upcoming PSE drivers
which are built as modules and probed after the MAC/PHY.

The net effect for module-built PSE controllers: attachment to PHYs
happens via the lifecycle notifier rather than via probe-time
-EPROBE_DEFER coupling, so the MDIO/DSA probe no longer sees any
PSE-originated -EPROBE_DEFER and the probe-retry storm is gone.

Link: openwrt#23222
Signed-off-by: Jonas Jelonek <[email protected]>
vincenzosuraci pushed a commit to vincenzosuraci/openwrt that referenced this pull request Jul 15, 2026
Add pending patches which add a PSE driver for the PSE setup found on
most of Realtek-based switches. An MCU with a Realtek-defined firmware
and protocol fronts one or more PSE chips (from Realtek or Broadcom) as
a management controller.

The driver provides both I2C/SMBus and UART communication, which varies
among our supported switches. There is no need for complicated userspace
handling anymore, the PSE setup is defined in the device tree and
interfaced in userspace via ethtool, netlink and netifd support.

Those patches have progressed far enough upstream, the bindings are
reviewed. Thus, we can keep this intermediate version downstream to open
it up earlier for usage. Only little changes are expected til the final
version lands.

Link: openwrt#23222
Signed-off-by: Jonas Jelonek <[email protected]>
vincenzosuraci pushed a commit to vincenzosuraci/openwrt that referenced this pull request Jul 15, 2026
Add a patch which modifies the Realtek PSE MCU driver backport to add a
sysfs control to control detection mode per port. Some older,
bad-designed devices aren't detected properly in standard mode on some
switches, though vendor firmware powers them properly. Testing shows
that enabling the detection of legacy PDs by allowing wider resistance,
more input capacitance and using a wider detection window, solves this
issue.

The legacy detection can be activated by writing 1 to
portN/detection_legacy in the device's sysfs, e.g.

  echo 1 > /sys/bus/i2c/devices/3-0020/port0/detection_legacy

This patch is kept downstream for now, upstreaming will be attempted
though it is likely that upstream prefers a generic pse-pd approach.

Link: openwrt#23222
Signed-off-by: Jonas Jelonek <[email protected]>
vincenzosuraci pushed a commit to vincenzosuraci/openwrt that referenced this pull request Jul 15, 2026
Instead of relying on the userspace implementation, make this device the
first user of the new realtek-pse kernel driver (kmod-pse-realtek-mcu-uart)
based on the PSE-PD framework to interface PoE functionality of that
switch. Control of PoE functionality happens via ethtool / netifd now.
Drop selecting realtek-poe for this device.

This doesn't include any support for PoE-related LEDs.

Link: openwrt#23222
Signed-off-by: Jonas Jelonek <[email protected]>
vincenzosuraci pushed a commit to vincenzosuraci/openwrt that referenced this pull request Jul 15, 2026
Add support for PoE functionality using the realtek-pse-mcu driver
(kmod-pse-realtek-mcu-i2c) interfacing the on-board PoE MCU and RTL8239
PSE chips.

This doesn't include any support for PoE-related LEDs.

Link: openwrt#23222
Signed-off-by: Jonas Jelonek <[email protected]>
@svanheule

Copy link
Copy Markdown
Member

Sorry to bump this PR, but I was wondering how the pse-controller's power-supply relates to the PI's vpwr-supply, as defined by the generic pse-pi binding.

For context, I am trying to add a fixed-regulator node on the Netgear GS110TPP that defines the external PSU's power limitation of 130W. Doing so results in the following kernel log:

regulator regulator.2: supply vpwr not found, using dummy regulator

The regulator tree then shows the PSE-PI regulators to be using the dummy regulator instead of "ext-psu", as I had intended/expected:

# cat /sys/kernel/debug/regulator/regulator_summary 
 regulator                      use open bypass  opmode voltage current     min     max
---------------------------------------------------------------------------------------
 regulator-dummy                 10   10      0 unknown     0mV     0mA     0mV     0mV 
    spi0.0-vcc                    1                                 0mA     0mV     0mV
    pse-serial0-0_pi0             1    1      0 unknown     0mV     0mA     0mV     0mV 
       serial0-0-pse-serial0-0_pi0   1                                 0mA     0mV     0mV
    pse-serial0-0_pi1             1    1      0 unknown 53300mV   562mA     0mV     0mV 
       serial0-0-pse-serial0-0_pi1   1                                 0mA     0mV     0mV
    pse-serial0-0_pi2             1    1      0 unknown 53557mV   560mA     0mV     0mV 
       serial0-0-pse-serial0-0_pi2   1                                 0mA     0mV     0mV
    pse-serial0-0_pi3             1    1      0 unknown     0mV     0mA     0mV     0mV 
       serial0-0-pse-serial0-0_pi3   1                                 0mA     0mV     0mV
    pse-serial0-0_pi4             1    1      0 unknown     0mV     0mA     0mV     0mV 
       serial0-0-pse-serial0-0_pi4   1                                 0mA     0mV     0mV
    pse-serial0-0_pi5             1    1      0 unknown     0mV     0mA     0mV     0mV 
       serial0-0-pse-serial0-0_pi5   1                                 0mA     0mV     0mV
    pse-serial0-0_pi6             1    1      0 unknown     0mV     0mA     0mV     0mV 
       serial0-0-pse-serial0-0_pi6   1                                 0mA     0mV     0mV
    pse-serial0-0_pi7             1    1      0 unknown 53364mV   561mA     0mV     0mV 
       serial0-0-pse-serial0-0_pi7   1                                 0mA     0mV     0mV
 ext-psu                          2    1      0 unknown 54000mV     0mA 54000mV 54000mV 
    serial0-0-power               1                                 0mA     0mV     0mV

Is this expected behaviour? Or should I instead be referring every pse-pi node to ext-psu individually?

Looking a bit deeper, AFAICT this driver doesn't support setting the system's power budget. So not sure if what I'm trying to achieve is possible at the moment. Then this just relies on a pre-set global power budget? A state configured by a driver operating the system before? What's preventing this from overdrawing the device's power budget (which can have physical consequences)?

@openwrt

openwrt Bot commented Jul 21, 2026 •

Copy link
Copy Markdown

Formality Check: Suggestions Available

We completed the verification flow. Please review the formatting overview logs below.

⚠️ STYLISTIC WARNINGS & SUGGESTIONS

Commit 96ecf8d - generic: pse-pd: add patches for module-based PSE drivers:

  • ⚠️ - Embedded patch file 'target/linux/generic/pending-6.18/896-01-net-pse-pd-add-notifier-chain-for-controller-lifecyc.patch' violates standard guidelines. Missing required Git header parameters ('From Mon Sep 17 00:00:00 2001' / 'From:' / 'Date:' / 'Subject:') to ensure 'git am' application compatibility
  • ⚠️ - Embedded patch file 'target/linux/generic/pending-6.18/896-02-net-pse-pd-fire-lifecycle-events-on-controller-regis.patch' violates standard guidelines. Missing required Git header parameters ('From Mon Sep 17 00:00:00 2001' / 'From:' / 'Date:' / 'Subject:') to ensure 'git am' application compatibility
  • ⚠️ - Embedded patch file 'target/linux/generic/pending-6.18/896-03-net-phy-own-phydev-psec-via-PSE-notifier-and-remove-.patch' violates standard guidelines. Missing required Git header parameters ('From Mon Sep 17 00:00:00 2001' / 'From:' / 'Date:' / 'Subject:') to ensure 'git am' application compatibility
  • ⚠️ - Embedded patch file 'target/linux/ramips/patches-6.18/720-NET-no-auto-carrier-off-support.patch' violates standard guidelines. Missing required Git header parameters ('From Mon Sep 17 00:00:00 2001' / 'From:' / 'Date:' / 'Subject:') to ensure 'git am' application compatibility

Package Release Audit:

  • ⚠️ Package package/kernel/linux content changed without a PKG_RELEASE or version bump. Please increment PKG_RELEASE by 1 (or bump PKG_VERSION/PKG_SOURCE_DATE and reset PKG_RELEASE to 1) so users receive the update.
  • Do not increment release for minor changes. Cosmetic edits (e.g., typos in comments, copyright updates, formatting/whitespace), changing the package maintainer (PKG_MAINTAINER), or updating source download info (PKG_SOURCE_URL / PKG_HASH) do not require incrementing PKG_RELEASE.

Something broken? Consider reporting an issue.
Running version f3161d5 deployed on 2026-07-22 02:15:51 CEST

@jonasjelonek

jonasjelonek commented Jul 21, 2026 •

Copy link
Copy Markdown
Member Author

Sorry to bump this PR, but I was wondering how the pse-controller's power-supply relates to the PI's vpwr-supply, as defined by the generic pse-pi binding.

The power-supply I use is a global one for the whole PoE system of a switch. It basically came up on some switches when I noticed that there is a GPIO that gates PoE functionality. I had to choose between using another enable-gpio which actually enables/disables all ports, or this regulator setup. Since I didn't know how this was really done on boards, I chose to abstract it as "there is something that gates power on the whole PoE system". I might be wrong with this but lets see in the future.

Is this expected behaviour? Or should I instead be referring every pse-pi node to ext-psu individually?

Not sure, would each pse-pi then assume it has 130W as budget for itself?

Looking a bit deeper, AFAICT this driver doesn't support setting the system's power budget. So not sure if what I'm trying to achieve is possible at the moment. Then this just relies on a pre-set global power budget? A state configured by a driver operating the system before? What's preventing this from overdrawing the device's power budget (which can have physical consequences)?

It doesn't support this yet. However, I don't see a danger right now. All switches I've worked on so far had their advertised overall power somehow in the MCU configuration. The value that you can read with one of the commands there always matched the advertised PoE power budget. Nevertheless, this is still a gap that I'm aware of. I just don't know yet how to model that within the driver since I'm not that familiar with the regulator subsystem yet. Maybe have the overall regulator (supplied via power-supply) carry the PoE budget of the system, and set this accordingly then? Is that possible?

Similarly, there is still a gap that a per-port cap as given by a switch vendor isn't modelled right now. For now, only the chip maximum is the limit but some vendors reduce it for several ports, for several reasons.

@svanheule

Copy link
Copy Markdown
Member

Sorry to bump this PR, but I was wondering how the pse-controller's power-supply relates to the PI's vpwr-supply, as defined by the generic pse-pi binding.

The power-supply I use is a global one for the whole PoE system of a switch. It basically came up on some switches when I noticed that there is a GPIO that gates PoE functionality. I had to choose between using another enable-gpio which actually enables/disables all ports, or this regulator setup. Since I didn't know how this was really done on boards, I chose to abstract it as "there is something that gates power on the whole PoE system". I might be wrong with this but lets see in the future.

If you pass that via the pse-pi node's vpwr-supply property, each individual node being enabled would request (and thus enable if needed) the power supply. No need to bind it to the parent device AFAICT.

Setting vpwr-suppy to the ext-psu node gives me:

 regulator-dummy                  3    2      0 unknown     0mV     0mA     0mV     0mV 
    serial0-0-power               1                                 0mA     0mV     0mV
    spi0.0-vcc                    1                                 0mA     0mV     0mV
 ext-psu                          9    9      0 unknown 54000mV     0mA 54000mV 54000mV 
    pse-serial0-0_pi0             1    1      0 unknown     0mV     0mA     0mV     0mV 
       serial0-0-pse-serial0-0_pi0   1                                 0mA     0mV     0mV
    pse-serial0-0_pi1             1    1      0 unknown 53300mV   562mA     0mV     0mV 
       serial0-0-pse-serial0-0_pi1   1                                 0mA     0mV     0mV
    pse-serial0-0_pi2             1    1      0 unknown 53557mV   560mA     0mV     0mV 
       serial0-0-pse-serial0-0_pi2   1                                 0mA     0mV     0mV
    pse-serial0-0_pi3             1    1      0 unknown     0mV     0mA     0mV     0mV 
       serial0-0-pse-serial0-0_pi3   1                                 0mA     0mV     0mV
    pse-serial0-0_pi4             1    1      0 unknown     0mV     0mA     0mV     0mV 
       serial0-0-pse-serial0-0_pi4   1                                 0mA     0mV     0mV
    pse-serial0-0_pi5             1    1      0 unknown     0mV     0mA     0mV     0mV 
       serial0-0-pse-serial0-0_pi5   1                                 0mA     0mV     0mV
    pse-serial0-0_pi6             1    1      0 unknown     0mV     0mA     0mV     0mV 
       serial0-0-pse-serial0-0_pi6   1                                 0mA     0mV     0mV
    pse-serial0-0_pi7             1    1      0 unknown 53429mV   561mA     0mV     0mV 
       serial0-0-pse-serial0-0_pi7   1                                 0mA     0mV     0mV

Is this expected behaviour? Or should I instead be referring every pse-pi node to ext-psu individually?

Not sure, would each pse-pi then assume it has 130W as budget for itself?

I didn't look into the pse-core details yet, so maybe that's not even in there.

Looking a bit deeper, AFAICT this driver doesn't support setting the system's power budget. So not sure if what I'm trying to achieve is possible at the moment. Then this just relies on a pre-set global power budget? A state configured by a driver operating the system before? What's preventing this from overdrawing the device's power budget (which can have physical consequences)?

It doesn't support this yet. However, I don't see a danger right now. All switches I've worked on so far had their advertised overall power somehow in the MCU configuration. The value that you can read with one of the commands there always matched the advertised PoE power budget. Nevertheless, this is still a gap that I'm aware of. I just don't know yet how to model that within the driver since I'm not that familiar with the regulator subsystem yet. Maybe have the overall regulator (supplied via power-supply) carry the PoE budget of the system, and set this accordingly then? Is that possible?

For the device, you could loop over all child pse-pi nodes to collect the unique power supplies and then add up (if there's multiple) their power limits to obtain the device power limit. The question then is: what to do with that information? You could be cautious and just log a driver warning in case the device power has not been defined, or if it differs from the reported power limit. In case of no defined limits, the driver could default to the maximum power per port.

Similarly, there is still a gap that a per-port cap as given by a switch vendor isn't modelled right now. For now, only the chip maximum is the limit but some vendors reduce it for several ports, for several reasons.

This is more something to take up with upstream, but since the pse-pi is modelled as a regulator, (some of) the regulator binding properties could apply. Thinking of regulator-power-budget-milliwatt of course, but also regulator-uv-*, regulator-ov-*, etc.

@jonasjelonek

jonasjelonek commented Jul 21, 2026 •

Copy link
Copy Markdown
Member Author

Thanks for the hints.

I'll have a look, maybe it was indeed the wrong way to solve this issue. Though it's IMO more intuitive to bind the supply to the PSE controller instead of the single PIs, given how most of our switches look like. Then doing some looping, adding up, etc. in the driver feels somewhat odd.

EDIT: Looking at PSE-PD core it kinda makes sense though.
EDIT2: PSE-PD core seems to fully manage this when using vpwr-supply. In other words, it might get difficult when trying to use that without building up parallel infrastructure. Referencing the supply on controller level then would be the easier way.
EDIT3: Upstream microchip pd692xx seems to work similar, having a controller-level supply reference and from that, setting the systems power budget. I'll adapt and include this in a follow-up series.

@svanheule

Copy link
Copy Markdown
Member

I've sent a mail on the netdev list too, as I felt this was becoming a discussion on the driver and binding and belonged more upstream. I've only noticed your edits here now (no mail notifications for edits), so I think we are aligned?

The pd692xx binding indeed models a very similar hardware structure, so that could be a good way to evolve going forward. If you don't want to update the binding right now, before being merged upstream, the driver should (in theory) always be able to deal with old "incomplete" devicetrees too. But I guess that more or less just means being able to deal with missing vpwr-supply properties or not having a "manager" node?

@jonasjelonek

Copy link
Copy Markdown
Member Author

so I think we are aligned?

Seems like, yes.

The pd692xx binding indeed models a very similar hardware structure, so that could be a good way to evolve going forward. If you don't want to update the binding right now, before being merged upstream, the driver should (in theory) always be able to deal with old "incomplete" devicetrees too. But I guess that more or less just means being able to deal with missing vpwr-supply properties or not having a "manager" node?

I would like to get it right before being merged, dealing with that bad stuff later will just cause issues.

@abajk abajk mentioned this pull request Aug 19, 2026
1 task done
@abajk

abajk commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

@jonasjelonek FYI git bisect points to this PR as the cause of the hangs during boot on kernel 6.18 on lantiq/xway[1]. I still need to dig deeper to find the cause. Any ideas? :)

  1. lantiq: switch to 6.18 #24650 (comment)

@jonasjelonek

Copy link
Copy Markdown
Member Author

@abajk I had a similar issue with an earlier version of the patches added to generic here, but only in a very specific case. Effect was that a RTNL deadlock occured, however this was fixed in the here-merged version.

I had a look at your dmesg logs, it seems like the Qualcomm Atheros Ethernet driver is the one being probed right at that point where the hang occurs. Please check in this direction, maybe point an AI to your issue, the driver and the patches.

@abajk

abajk commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

I had a look at your dmesg logs, it seems like the Qualcomm Atheros Ethernet driver is the one being probed right at that point where the hang occurs. Please check in this direction, maybe point an AI to your issue, the driver and the patches.

Interestingly, this problem doesn't appear on the AVM 5490. The differences between the two platforms are the gswip DSA switch + AR8033 PHY instead of the ETOP MAC and AR8035 PHY.

Lienol pushed a commit to Lienol/openwrt that referenced this pull request Aug 20, 2026
Add a backport patch and pending patches needed by upcoming PSE drivers
which are built as modules and probed after the MAC/PHY.

The net effect for module-built PSE controllers: attachment to PHYs
happens via the lifecycle notifier rather than via probe-time
-EPROBE_DEFER coupling, so the MDIO/DSA probe no longer sees any
PSE-originated -EPROBE_DEFER and the probe-retry storm is gone.

Link: openwrt/openwrt#23222
Signed-off-by: Jonas Jelonek <[email protected]>
Vladdrako pushed a commit to Vladdrako/openwrt that referenced this pull request Aug 22, 2026
Add a backport patch and pending patches needed by upcoming PSE drivers
which are built as modules and probed after the MAC/PHY.

The net effect for module-built PSE controllers: attachment to PHYs
happens via the lifecycle notifier rather than via probe-time
-EPROBE_DEFER coupling, so the MDIO/DSA probe no longer sees any
PSE-originated -EPROBE_DEFER and the probe-retry storm is gone.

Link: openwrt#23222
Signed-off-by: Jonas Jelonek <[email protected]>
Vladdrako pushed a commit to Vladdrako/openwrt that referenced this pull request Aug 22, 2026
Add pending patches which add a PSE driver for the PSE setup found on
most of Realtek-based switches. An MCU with a Realtek-defined firmware
and protocol fronts one or more PSE chips (from Realtek or Broadcom) as
a management controller.

The driver provides both I2C/SMBus and UART communication, which varies
among our supported switches. There is no need for complicated userspace
handling anymore, the PSE setup is defined in the device tree and
interfaced in userspace via ethtool, netlink and netifd support.

Those patches have progressed far enough upstream, the bindings are
reviewed. Thus, we can keep this intermediate version downstream to open
it up earlier for usage. Only little changes are expected til the final
version lands.

Link: openwrt#23222
Signed-off-by: Jonas Jelonek <[email protected]>
Vladdrako pushed a commit to Vladdrako/openwrt that referenced this pull request Aug 22, 2026
Add a patch which modifies the Realtek PSE MCU driver backport to add a
sysfs control to control detection mode per port. Some older,
bad-designed devices aren't detected properly in standard mode on some
switches, though vendor firmware powers them properly. Testing shows
that enabling the detection of legacy PDs by allowing wider resistance,
more input capacitance and using a wider detection window, solves this
issue.

The legacy detection can be activated by writing 1 to
portN/detection_legacy in the device's sysfs, e.g.

  echo 1 > /sys/bus/i2c/devices/3-0020/port0/detection_legacy

This patch is kept downstream for now, upstreaming will be attempted
though it is likely that upstream prefers a generic pse-pd approach.

Link: openwrt#23222
Signed-off-by: Jonas Jelonek <[email protected]>
Vladdrako pushed a commit to Vladdrako/openwrt that referenced this pull request Aug 22, 2026
Instead of relying on the userspace implementation, make this device the
first user of the new realtek-pse kernel driver (kmod-pse-realtek-mcu-uart)
based on the PSE-PD framework to interface PoE functionality of that
switch. Control of PoE functionality happens via ethtool / netifd now.
Drop selecting realtek-poe for this device.

This doesn't include any support for PoE-related LEDs.

Link: openwrt#23222
Signed-off-by: Jonas Jelonek <[email protected]>
Vladdrako pushed a commit to Vladdrako/openwrt that referenced this pull request Aug 22, 2026
Add support for PoE functionality using the realtek-pse-mcu driver
(kmod-pse-realtek-mcu-i2c) interfacing the on-board PoE MCU and RTL8239
PSE chips.

This doesn't include any support for PoE-related LEDs.

Link: openwrt#23222
Signed-off-by: Jonas Jelonek <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core packages pull request/issue for core (in-tree) packages kernel pull request/issue with Linux kernel related changes target/airoha pull request/issue for airoha target target/ramips pull request/issue for ramips target target/realtek pull request/issue for realtek target target/starfive pull request/issue for starfive target

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants