Skip to content

Commit 90c0a37

Browse files
jonasjelonekrobimarko
authored andcommitted
realtek: pcs: switch SerDes polarity to {rx,tx}-polarity
With the recent backport of the common PHY properties infrastructure (phy-common-props and the phy_get_manual_{rx,tx}_polarity() helpers) to OpenWrt, the generic `{rx,tx}-polarity` device tree properties are now usable for the Realtek PCS driver. Switch the driver and all affected boards from the local vendor-specific `realtek,pnswap-{rx,tx}` booleans to the common properties. Add a `config_polarity` SerDes op (implemented by RTL930x and RTL931x; RTL838x/RTL839x polarity support not yet added) and a generic wrapper that resolves the requested polarity via phy_get_manual_{rx,tx}_polarity() and dispatches to the op. Variants without the op silently accept the default polarity but warn when a non-default polarity is requested, since that cannot be honored. Move the polarity programming out of the variant setup_serdes callbacks into rtpcs_pcs_config, so it runs before setup_serdes. This matches the ordering used by the vendor SDK, which configures polarity first. Update all board DTS files that previously used `realtek,pnswap-{rx,tx}` to the new `{rx,tx}-polarity = <PHY_POL_INVERT>` property, and select PHY_COMMON_PROPS from Kconfig. Each SerDes now retains its DT node for later polarity lookup. Use for_each_child_of_node_scoped for the iterator, and register a devm_add_action_or_reset for each stored reference so it is released on unbind or probe failure. Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com> Link: openwrt/openwrt#23044 Signed-off-by: Robert Marko <robimarko@gmail.com>
1 parent 3271071 commit 90c0a37

7 files changed

Lines changed: 120 additions & 70 deletions

File tree

target/linux/realtek/dts/rtl9311_linksys_lgs352c.dts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#include "rtl931x.dtsi"
55
#include "rtl93xx_linksys_lgs3xxc_nand_common.dtsi"
66

7+
#include <dt-bindings/phy/phy.h>
8+
79
/ {
810
compatible = "linksys,lgs352c", "realtek,rtl9311-soc";
911
model = "Linksys LGS352C";
@@ -238,17 +240,17 @@
238240
};
239241

240242
&serdes8 {
241-
realtek,pnswap-tx;
243+
tx-polarity = <PHY_POL_INVERT>;
242244
};
243245

244246
&serdes9 {
245-
realtek,pnswap-tx;
247+
tx-polarity = <PHY_POL_INVERT>;
246248
};
247249

248250
&serdes10 {
249-
realtek,pnswap-tx;
251+
tx-polarity = <PHY_POL_INVERT>;
250252
};
251253

252254
&serdes11 {
253-
realtek,pnswap-tx;
255+
tx-polarity = <PHY_POL_INVERT>;
254256
};

target/linux/realtek/dts/rtl9313_xikestor_sks8300-12x-v1.dts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <dt-bindings/input/input.h>
66
#include <dt-bindings/gpio/gpio.h>
77
#include <dt-bindings/leds/common.h>
8+
#include <dt-bindings/phy/phy.h>
89

910
/ {
1011
compatible = "xikestor,sks8300-12x-v1", "realtek,rtl9313-soc";
@@ -488,50 +489,50 @@
488489
};
489490

490491
&serdes2 {
491-
realtek,pnswap-tx;
492+
tx-polarity = <PHY_POL_INVERT>;
492493
};
493494

494495
&serdes3 {
495-
realtek,pnswap-tx;
496+
tx-polarity = <PHY_POL_INVERT>;
496497
};
497498

498499
&serdes4 {
499-
realtek,pnswap-tx;
500+
tx-polarity = <PHY_POL_INVERT>;
500501
};
501502

502503
&serdes5 {
503-
realtek,pnswap-tx;
504+
tx-polarity = <PHY_POL_INVERT>;
504505
};
505506

506507
&serdes6 {
507-
realtek,pnswap-tx;
508+
tx-polarity = <PHY_POL_INVERT>;
508509
};
509510

510511
&serdes7 {
511-
realtek,pnswap-tx;
512+
tx-polarity = <PHY_POL_INVERT>;
512513
};
513514

514515
&serdes8 {
515-
realtek,pnswap-tx;
516+
tx-polarity = <PHY_POL_INVERT>;
516517
};
517518

518519
&serdes9 {
519-
realtek,pnswap-tx;
520+
tx-polarity = <PHY_POL_INVERT>;
520521
};
521522

522523
&serdes10 {
523-
realtek,pnswap-tx;
524+
tx-polarity = <PHY_POL_INVERT>;
524525
};
525526

526527
&serdes11 {
527-
realtek,pnswap-tx;
528+
tx-polarity = <PHY_POL_INVERT>;
528529
};
529530

530531
&serdes12 {
531-
realtek,pnswap-tx;
532+
tx-polarity = <PHY_POL_INVERT>;
532533
};
533534

534535
&serdes13 {
535-
realtek,pnswap-tx;
536+
tx-polarity = <PHY_POL_INVERT>;
536537
};
537538

target/linux/realtek/dts/rtl9313_zyxel_xs1930-10.dts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <dt-bindings/gpio/gpio.h>
88
#include <dt-bindings/leds/common.h>
99
#include <dt-bindings/mux/mux.h>
10+
#include <dt-bindings/phy/phy.h>
1011

1112
/ {
1213
compatible = "zyxel,xs1930-10", "realtek,rtl9313-soc";
@@ -220,29 +221,29 @@
220221
};
221222

222223
&serdes6 {
223-
realtek,pnswap-rx;
224-
realtek,pnswap-tx;
224+
rx-polarity = <PHY_POL_INVERT>;
225+
tx-polarity = <PHY_POL_INVERT>;
225226
};
226227

227228
&serdes7 {
228-
realtek,pnswap-rx;
229-
realtek,pnswap-tx;
229+
rx-polarity = <PHY_POL_INVERT>;
230+
tx-polarity = <PHY_POL_INVERT>;
230231
};
231232

232233
&serdes8 {
233-
realtek,pnswap-rx;
234-
realtek,pnswap-tx;
234+
rx-polarity = <PHY_POL_INVERT>;
235+
tx-polarity = <PHY_POL_INVERT>;
235236
};
236237

237238
&serdes9 {
238-
realtek,pnswap-rx;
239-
realtek,pnswap-tx;
239+
rx-polarity = <PHY_POL_INVERT>;
240+
tx-polarity = <PHY_POL_INVERT>;
240241
};
241242

242243
&serdes12 {
243-
realtek,pnswap-tx;
244+
tx-polarity = <PHY_POL_INVERT>;
244245
};
245246

246247
&serdes13 {
247-
realtek,pnswap-tx;
248+
tx-polarity = <PHY_POL_INVERT>;
248249
};

target/linux/realtek/dts/rtl9313_zyxel_xs1930-12f.dts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <dt-bindings/gpio/gpio.h>
88
#include <dt-bindings/leds/common.h>
99
#include <dt-bindings/mux/mux.h>
10+
#include <dt-bindings/phy/phy.h>
1011

1112
/ {
1213
compatible = "zyxel,xs1930-12f", "realtek,rtl9313-soc";
@@ -303,42 +304,42 @@
303304
};
304305

305306
&serdes2 {
306-
realtek,pnswap-tx;
307+
tx-polarity = <PHY_POL_INVERT>;
307308
};
308309

309310
&serdes3 {
310-
realtek,pnswap-tx;
311+
tx-polarity = <PHY_POL_INVERT>;
311312
};
312313

313314
&serdes4 {
314-
realtek,pnswap-tx;
315+
tx-polarity = <PHY_POL_INVERT>;
315316
};
316317

317318
&serdes5 {
318-
realtek,pnswap-tx;
319+
tx-polarity = <PHY_POL_INVERT>;
319320
};
320321

321322
&serdes6 {
322-
realtek,pnswap-tx;
323+
tx-polarity = <PHY_POL_INVERT>;
323324
};
324325

325326
&serdes7 {
326-
realtek,pnswap-tx;
327+
tx-polarity = <PHY_POL_INVERT>;
327328
};
328329

329330
&serdes8 {
330-
realtek,pnswap-tx;
331+
tx-polarity = <PHY_POL_INVERT>;
331332
};
332333

333334
&serdes9 {
334-
realtek,pnswap-tx;
335+
tx-polarity = <PHY_POL_INVERT>;
335336
};
336337

337338
&serdes10 {
338-
realtek,pnswap-tx;
339+
tx-polarity = <PHY_POL_INVERT>;
339340
};
340341

341342
&serdes11 {
342-
realtek,pnswap-tx;
343+
tx-polarity = <PHY_POL_INVERT>;
343344
};
344345

target/linux/realtek/dts/rtl9313_zyxel_xs1930-12hp.dts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <dt-bindings/gpio/gpio.h>
88
#include <dt-bindings/leds/common.h>
99
#include <dt-bindings/mux/mux.h>
10+
#include <dt-bindings/phy/phy.h>
1011

1112
/ {
1213
compatible = "zyxel,xs1930-12hp", "realtek,rtl9313-soc";
@@ -266,37 +267,37 @@
266267
};
267268

268269
&serdes6 {
269-
realtek,pnswap-rx;
270-
realtek,pnswap-tx;
270+
rx-polarity = <PHY_POL_INVERT>;
271+
tx-polarity = <PHY_POL_INVERT>;
271272
};
272273

273274
&serdes7 {
274-
realtek,pnswap-rx;
275-
realtek,pnswap-tx;
275+
rx-polarity = <PHY_POL_INVERT>;
276+
tx-polarity = <PHY_POL_INVERT>;
276277
};
277278

278279
&serdes8 {
279-
realtek,pnswap-rx;
280-
realtek,pnswap-tx;
280+
rx-polarity = <PHY_POL_INVERT>;
281+
tx-polarity = <PHY_POL_INVERT>;
281282
};
282283

283284
&serdes9 {
284-
realtek,pnswap-rx;
285-
realtek,pnswap-tx;
285+
rx-polarity = <PHY_POL_INVERT>;
286+
tx-polarity = <PHY_POL_INVERT>;
286287
};
287288

288289
&serdes10 {
289-
realtek,pnswap-tx;
290+
tx-polarity = <PHY_POL_INVERT>;
290291
};
291292

292293
&serdes11 {
293-
realtek,pnswap-tx;
294+
tx-polarity = <PHY_POL_INVERT>;
294295
};
295296

296297
&serdes12 {
297-
realtek,pnswap-tx;
298+
tx-polarity = <PHY_POL_INVERT>;
298299
};
299300

300301
&serdes13 {
301-
realtek,pnswap-tx;
302+
tx-polarity = <PHY_POL_INVERT>;
302303
};

0 commit comments

Comments
 (0)