Skip to content

Commit 61c5ff6

Browse files
Tomaz Zamanigorpecovnik
authored andcommitted
gateway-dk: move SFP LED refs from SFP nodes to sfp_led_controller
The sff,sfp DT binding has additionalProperties: false, so our custom leds property on SFP nodes violates the schema. Move LED-to-SFP association into per-port child nodes of the sfp_led_controller. DTS: sfp_led_controller now has port@0/port@1 sub-nodes, each with sfp phandle and leds list. SFP nodes no longer carry leds property. Driver: sfp_led_probe() iterates child nodes instead of sfp-ports phandle array. sfp_led_register_port() receives the port child node, parses the sfp phandle from it, and reads LEDs from the child node instead of from the SFP node.
1 parent 3645693 commit 61c5ff6

2 files changed

Lines changed: 43 additions & 32 deletions

File tree

packages/bsp/gateway-dk/sfp-led.c

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,19 @@
3434
* sfp0: sfp-0 {
3535
* compatible = "sff,sfp";
3636
* i2c-bus = <&sfp0_i2c>;
37-
* leds = <&led_sfp0_link>, <&led_sfp0_activity>;
3837
* };
3938
*
4039
* sfp-led-controller {
4140
* compatible = "mono,sfp-led";
42-
* sfp-ports = <&sfp0>, <&sfp1>;
41+
*
42+
* port@0 {
43+
* sfp = <&sfp0>;
44+
* leds = <&led_sfp0_link>, <&led_sfp0_activity>;
45+
* };
46+
* port@1 {
47+
* sfp = <&sfp1>;
48+
* leds = <&led_sfp1_link>, <&led_sfp1_activity>;
49+
* };
4350
* };
4451
*
4552
* // MAC node must reference SFP for netdev association
@@ -483,14 +490,21 @@ static void sfp_led_poll_work_handler(struct work_struct *work)
483490
}
484491

485492
static int sfp_led_register_port(struct sfp_led_priv *priv,
486-
struct device_node *sfp_np, int index)
493+
struct device_node *port_np, int index)
487494
{
488495
struct sfp_led_port *port = &priv->ports[index];
489-
struct device_node *i2c_np;
496+
struct device_node *sfp_np, *i2c_np;
497+
498+
/* Parse SFP node from port child node */
499+
sfp_np = of_parse_phandle(port_np, "sfp", 0);
500+
if (!sfp_np) {
501+
dev_err(priv->dev, "port %d: missing sfp phandle\n", index);
502+
return -ENODEV;
503+
}
490504

491505
port->priv = priv;
492506
port->sfp_np = sfp_np;
493-
of_node_get(sfp_np);
507+
/* sfp_np has ref from of_parse_phandle — don't add of_node_get */
494508

495509
/* Get I2C adapter for module detection */
496510
i2c_np = of_parse_phandle(sfp_np, "i2c-bus", 0);
@@ -510,15 +524,15 @@ static int sfp_led_register_port(struct sfp_led_priv *priv,
510524
return ret ? ret : -ENODEV;
511525
}
512526

513-
/* Get LEDs */
514-
port->link_led = of_led_get(sfp_np, 0);
527+
/* Get LEDs from port child node */
528+
port->link_led = of_led_get(port_np, 0);
515529
if (IS_ERR(port->link_led)) {
516530
dev_dbg(priv->dev, "port %d: link LED not in DT: %ld\n",
517531
index, PTR_ERR(port->link_led));
518532
port->link_led = NULL;
519533
}
520534

521-
port->activity_led = of_led_get(sfp_np, 1);
535+
port->activity_led = of_led_get(port_np, 1);
522536
if (IS_ERR(port->activity_led)) {
523537
dev_dbg(priv->dev, "port %d: activity LED not in DT: %ld\n",
524538
index, PTR_ERR(port->activity_led));
@@ -589,7 +603,7 @@ static void sfp_led_cleanup_port(struct sfp_led_port *port)
589603
static int sfp_led_probe(struct platform_device *pdev)
590604
{
591605
struct sfp_led_priv *priv;
592-
struct device_node *np;
606+
struct device_node *child;
593607
int count, i, registered = 0;
594608

595609
priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
@@ -599,9 +613,9 @@ static int sfp_led_probe(struct platform_device *pdev)
599613
priv->dev = &pdev->dev;
600614
platform_set_drvdata(pdev, priv);
601615

602-
count = of_count_phandle_with_args(pdev->dev.of_node, "sfp-ports", NULL);
603-
if (count <= 0) {
604-
dev_err(&pdev->dev, "no sfp-ports specified\n");
616+
count = of_get_child_count(pdev->dev.of_node);
617+
if (count == 0) {
618+
dev_err(&pdev->dev, "no port child nodes specified\n");
605619
return -ENODEV;
606620
}
607621

@@ -612,17 +626,11 @@ static int sfp_led_probe(struct platform_device *pdev)
612626

613627
priv->num_ports = count;
614628

615-
for (i = 0; i < count; i++) {
616-
np = of_parse_phandle(pdev->dev.of_node, "sfp-ports", i);
617-
if (!np) {
618-
dev_warn(&pdev->dev, "failed to parse sfp-ports[%d]\n", i);
619-
continue;
620-
}
621-
622-
if (sfp_led_register_port(priv, np, i) == 0)
629+
i = 0;
630+
for_each_child_of_node(pdev->dev.of_node, child) {
631+
if (sfp_led_register_port(priv, child, i) == 0)
623632
registered++;
624-
625-
of_node_put(np);
633+
i++;
626634
}
627635

628636
if (registered == 0) {

patch/kernel/archive/ls1046a-6.12/002-arm64-dts-Add-Mono-Gateway-DK-device-tree.patch

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ diff --git a/arch/arm64/boot/dts/freescale/mono-gateway-dk.dts b/arch/arm64/boot
2929
new file mode 100644
3030
--- /dev/null
3131
+++ b/arch/arm64/boot/dts/freescale/mono-gateway-dk.dts
32-
@@ -0,0 +1,1027 @@
32+
@@ -0,0 +1,1030 @@
3333
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
3434
+/*
3535
+ * Device Tree file for Mono Gateway DK (NXP LS1046A).
@@ -104,7 +104,6 @@ new file mode 100644
104104
+ mod-def0-gpios = <&gpio2 12 GPIO_ACTIVE_LOW>;
105105
+ los-gpios = <&gpio2 11 GPIO_ACTIVE_HIGH>;
106106
+ maximum-power-milliwatt = <3000>;
107-
+ leds = <&led_sfp0_link>, <&led_sfp0_activity>;
108107
+ };
109108
+
110109
+ /* SFP 2 */
@@ -115,13 +114,22 @@ new file mode 100644
115114
+ mod-def0-gpios = <&gpio2 10 GPIO_ACTIVE_LOW>;
116115
+ los-gpios = <&gpio2 9 GPIO_ACTIVE_HIGH>;
117116
+ maximum-power-milliwatt = <3000>;
118-
+ leds = <&led_sfp1_link>, <&led_sfp1_activity>;
119117
+ };
120118
+
121-
+ /* SFP LED Controller */
119+
+ /* SFP LED Controller — LEDs are on the controller node, not SFP nodes
120+
+ * (sff,sfp binding has additionalProperties: false) */
122121
+ sfp_led_controller: sfp-led-controller {
123122
+ compatible = "mono,sfp-led";
124-
+ sfp-ports = <&sfp_xfi0>, <&sfp_xfi1>;
123+
+
124+
+ port@0 {
125+
+ sfp = <&sfp_xfi0>;
126+
+ leds = <&led_sfp0_link>, <&led_sfp0_activity>;
127+
+ };
128+
+
129+
+ port@1 {
130+
+ sfp = <&sfp_xfi1>;
131+
+ leds = <&led_sfp1_link>, <&led_sfp1_activity>;
132+
+ };
125133
+ };
126134
+
127135
+ /* Boot memory regions for SDK DPAA driver */
@@ -605,11 +613,6 @@ new file mode 100644
605613
+ #address-cells = <1>;
606614
+ #size-cells = <1>;
607615
+
608-
+ partition@flash {
609-
+ label = "flash";
610-
+ reg = <0x0 0x4000000>;
611-
+ };
612-
+
613616
+ partition@0 {
614617
+ label = "rcw-bl2";
615618
+ reg = <0x0 0x100000>;

0 commit comments

Comments
 (0)