Working on the support for Zyxel XMG1915-10E

I just signed in with Github

Yeah, that's the only way at the moment, as far as I know. No wait time.

Okay, that was faster than expected. PoE mostly working now. It is interfaced with UART, so one needs to use realtek-poe package. It's using non-standard option so realtek-poe must be configured with:

config global
        option budget '130'
        option force_dialect 'realtek'
        option force_baudrate '115200'

And - what finally did the trick - GPIO4 needs to be HIGH to enable/power the PoE MCU. Having worked with several Zyxel devices now, they seem to love gating several subsystem with arbitrary GPIOs.

What is not working yet is - of course - any PoE LEDs. But from what I've seen we have nothing in OpenWrt, also not in those PoE tools, which can drive any PoE LEDs correctly.

With this working, I can make the PR soon to extend the support for XMG1915 series.

Sweet! Thanks!

Being totally annoyed by poemgr (for another Zyxel device) and realtek-poe (for this device), I stitched together a driver for RTL823x PSE chips which supports both I2C and UART, based on the PSE-PD framework. Basic functionality is implemented, ports can be enabled/disabled, power limit can be set, some basic stats (what PSE-PD supports) are read and reported.

I plan to make a draft PR for that, just to get some feedback on this. I prefer having a downstream driver at first which can mature faster instead of doing everything upstream (which might take an eternity).

I’ve looked into the PSE-PD framework and have been thinking that re-implementing the poemgr and realtek-poe in a proper PSE-PD driver was the way forward. I was struggling with understanding the framework well enough to figure out how to support the UART in addition to I2C. For that reason I would be very interested in seeing your PR!

Here you go ... still clumsy and WIP but works.

Doesn’t there need to be patches to the dts files for the devices intending to use this new driver also? Do you have a PR showing those changes also?

Sure but my devices I used to work on this aren't fully supported yet. When https://github.com/openwrt/openwrt/pull/23218 lands in, I can at least add an example for this.

But here how this diff looks like for the Zyxel XMG1915-10EP:

diff --git a/target/linux/realtek/dts/rtl9302_zyxel_xmg1915-10ep.dts b/target/linux/realtek/dts/rtl9302_zyxel_xmg1915-10ep.dts
index 6f1aac9bc7..99f971e2ab 100644
--- a/target/linux/realtek/dts/rtl9302_zyxel_xmg1915-10ep.dts
+++ b/target/linux/realtek/dts/rtl9302_zyxel_xmg1915-10ep.dts
@@ -24,4 +24,31 @@

 &uart1 {
        status = "okay";
+
+       pse: pse@0 {
+               compatible = "realtek,rtl8238-uart";
+               current-speed = <115200>;
+
+               enable-gpios = <&gpio0 4 GPIO_ACTIVE_HIGH>;
+
+               pse-pis {
+                       pse_pi0: pse-pi@0 { reg = <0>; #pse-cells = <0>; };
+                       pse_pi1: pse-pi@1 { reg = <1>; #pse-cells = <0>; };
+                       pse_pi2: pse-pi@2 { reg = <2>; #pse-cells = <0>; };
+                       pse_pi3: pse-pi@3 { reg = <3>; #pse-cells = <0>; };
+                       pse_pi4: pse-pi@4 { reg = <4>; #pse-cells = <0>; };
+                       pse_pi5: pse-pi@5 { reg = <5>; #pse-cells = <0>; };
+                       pse_pi6: pse-pi@6 { reg = <6>; #pse-cells = <0>; };
+                       pse_pi7: pse-pi@7 { reg = <7>; #pse-cells = <0>; };
+               };
+       };
 };
+
+&phy0 { pses = <&pse_pi0>; };
+&phy1 { pses = <&pse_pi1>; };
+&phy2 { pses = <&pse_pi2>; };
+&phy3 { pses = <&pse_pi3>; };
+&phy8 { pses = <&pse_pi4>; };
+&phy9 { pses = <&pse_pi5>; };
+&phy10 { pses = <&pse_pi6>; };
+&phy11 { pses = <&pse_pi7>; };

Nice!!!

had to do a PoC on one of my Zyxel GS1900-10HPs. Don't have time to clean up and do it properly right now. But it works:

root@OpenWrt:~# ethtool  --show-pse lan5
PSE attributes for lan5:
Clause 33 PSE Admin State: enabled
Clause 33 PSE Power Detection Status: delivering power
Clause 33 PSE Actual Power: 4700
Clause 33 PSE Available Power Limit: 15400
Clause 33 PSE Power Limit Ranges:
        range:
                min 0
                max 102000
Power domain index: 1

root@OpenWrt:~# ethtool  --set-pse lan5 c33-pse-admin-control disable
root@OpenWrt:~# [  426.252112] rtl83xx-switch 1b000000.switchcore:ethernet-switch lan5: Link is Down
[  426.260835] switch: port 5(lan5) entered disabled state
[  426.272016] rtl83xx-switch 1b000000.switchcore:ethernet-switch lan5: Link is Up - 1Gbps/Full - flow control rx/tx
[  426.283843] switch: port 5(lan5) entered blocking state
[  426.289921] switch: port 5(lan5) entered forwarding state
[  426.587142] rtl83xx-switch 1b000000.switchcore:ethernet-switch lan5: Link is Down
[  426.595867] switch: port 5(lan5) entered disabled state
 
root@OpenWrt:~# ethtool  --show-pse lan5
PSE attributes for lan5:
Clause 33 PSE Admin State: disabled
Clause 33 PSE Power Detection Status: disabled
Clause 33 PSE Available Power Limit: 15400
Clause 33 PSE Power Limit Ranges:
        range:
                min 0
                max 102000
Power domain index: 1

Code is a mess. Sorry. Not intended for use, just for entertainment

Great to see!

I thought about adding the dialect similarly but ultimately have no test device right now and moreover wasn't sure how upstream thinks about that. Any idea about that?

No idea. My guess is that they prefer clean code. And that might be difficult with any such "dialect" attempt