Skip to content

Commit 4edd97f

Browse files
committed
Merge branch 'switch-phy-leds'
Christian Marangi says: ==================== net: Add basic LED support for switch/phy This is a continue of [1]. It was decided to take a more gradual approach to implement LEDs support for switch and phy starting with basic support and then implementing the hw control part when we have all the prereq done. This series implements only the brightness_set() and blink_set() ops. An example of switch implementation is done with qca8k. For PHY a more generic approach is used with implementing the LED support in PHY core and with the user (in this case marvell) adding all the required functions. Currently we set the default-state as "keep" to not change the default configuration of the declared LEDs since almost every switch have a default configuration. [1] https://lore.kernel.org/lkml/20230216013230.22978-1-ansuelsmth@gmail.com/ Changes in new series v7: - Drop ethernet-leds schema and add unevaluatedProperties to ethernet-controller and ethernet-phy schema - Drop function-enumerator binding from schema example and DT - Set devname_mandatory for qca8k leds and assign better name to LEDs using the format {slave_mii_bus id}:0{port number}:{color}:{function} - Add Documentation patch for Correct LEDs naming from Andrew - Changes in Andrew patch: - net: phy: Add a binding for PHY LEDs - Convert index from u32 to u8 - net: phy: phy_device: Call into the PHY driver to set LED brightness - Fixup kernel doc - Convert index from u32 to u8 - net: phy: marvell: Add software control of the LEDs - Convert index from u32 to u8 - net: phy: phy_device: Call into the PHY driver to set LED blinking - Kernel doc fix - Convert index from u32 to u8 - net: phy: marvell: Implement led_blink_set() - Convert index from u32 to u8 Changes in new series v6: - Add leds-ethernet.yaml to document reg in led node - Update ethernet-controller and ethernet-phy to follow new leds-ethernet schema - Fix comments in qca8k-leds.c (at least -> at most) (wrong GENMASK for led phy 0 and 4) - Add review and ack tag from Pavel Machek - Changes in Andrew patch: - leds: Provide stubs for when CLASS_LED & NEW_LEDS are disabled - Change LED_CLASS to NEW_LEDS for led_init_default_state_get() - net: phy: Add a binding for PHY LEDs - Add dependency on LED_CLASS - Drop review tag from Michal Kubiak (patch modified) Changes in new series v5: - Rebase everything on top of net-next/main - Add more info on LED probe fail for qca8k - Drop some additional raw number and move to define in qca8k header - Add additional info on LED mapping on qca8k regs - Checks port number in qca8k switch port parse - Changes in Andrew patch: - Add additional patch for stubs when CLASS_LED disabled - Drop CLASS_LED dependency for PHYLIB (to fix kbot errors reported) Changes in new series v4: - Changes in Andrew patch: - net: phy: Add a binding for PHY LEDs: - Rename phy_led: led_list to list - Rename phy_device: led_list to leds - Remove phy_leds_remove() since devm_ should do what is needed - Fixup documentation for struct phy_led - Fail probe on LED errors - net: phy: phy_device: Call into the PHY driver to set LED brightness - Moved phy_led::phydev from previous patch to here since it is first used here. - net: phy: marvell: Implement led_blink_set() - Use int instead of unsigned - net: phy: marvell: Add software control of the LEDs - Use int instead of unsigned - Add depends on LED_CLASS for qca8k Kconfig - Fix Makefile for qca8k as suggested - Move qca8k_setup_led_ctrl to separate header - Move Documentation from dsa-port to ethernet-controller - Drop trailing . from Andrew patch fro consistency Changes in new series v3: - Move QCA8K_LEDS Kconfig option from tristate to bool - Use new helper led_init_default_state_get for default-state in qca8k - Drop cled_qca8k_brightness_get() as there isn't a good way to describe the mode the led is currently in - Rework qca8k_led_brightness_get() to return true only when LED is set to always ON Changes in new series v2: - Add LEDs node for rb3011 - Fix rb3011 switch node unevaluated properties while running make dtbs_check - Fix a copypaste error in qca8k-leds.c for port 4 required shift - Drop phy-handle usage for qca8k and use qca8k_port_to_phy() - Add review tag from Andrew - Add Christian Marangi SOB in each Andrew patch - Add extra description for dsa-port stressing that PHY have no access and LED are controlled by the related MAC - Add missing additionalProperties for dsa-port.yaml and ethernet-phy.yaml Changes from the old v8 series: - Drop linux,default-trigger set to netdev. - Dropped every hw control related patch and implement only blink_set and brightness_set - Add default-state to "keep" for each LED node example ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 1584418 + c693ea2 commit 4edd97f

17 files changed

Lines changed: 884 additions & 24 deletions

File tree

Documentation/devicetree/bindings/net/dsa/qca8k.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ description:
1818
PHY it is connected to. In this config, an internal mdio-bus is registered and
1919
the MDIO master is used for communication. Mixed external and internal
2020
mdio-bus configurations are not supported by the hardware.
21+
Each phy has at most 3 LEDs connected and can be declared
22+
using the standard LEDs structure.
2123

2224
properties:
2325
compatible:
@@ -117,6 +119,7 @@ unevaluatedProperties: false
117119
examples:
118120
- |
119121
#include <dt-bindings/gpio/gpio.h>
122+
#include <dt-bindings/leds/common.h>
120123
121124
mdio {
122125
#address-cells = <1>;
@@ -226,6 +229,25 @@ examples:
226229
label = "lan1";
227230
phy-mode = "internal";
228231
phy-handle = <&internal_phy_port1>;
232+
233+
leds {
234+
#address-cells = <1>;
235+
#size-cells = <0>;
236+
237+
led@0 {
238+
reg = <0>;
239+
color = <LED_COLOR_ID_WHITE>;
240+
function = LED_FUNCTION_LAN;
241+
default-state = "keep";
242+
};
243+
244+
led@1 {
245+
reg = <1>;
246+
color = <LED_COLOR_ID_AMBER>;
247+
function = LED_FUNCTION_LAN;
248+
default-state = "keep";
249+
};
250+
};
229251
};
230252
231253
port@2 {

Documentation/devicetree/bindings/net/ethernet-controller.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,41 @@ properties:
222222
required:
223223
- speed
224224

225+
leds:
226+
description:
227+
Describes the LEDs associated by Ethernet Controller.
228+
These LEDs are not integrated in the PHY and PHY doesn't have any
229+
control on them. Ethernet Controller regs are used to control
230+
these defined LEDs.
231+
232+
type: object
233+
234+
properties:
235+
'#address-cells':
236+
const: 1
237+
238+
'#size-cells':
239+
const: 0
240+
241+
patternProperties:
242+
'^led@[a-f0-9]+$':
243+
$ref: /schemas/leds/common.yaml#
244+
245+
properties:
246+
reg:
247+
maxItems: 1
248+
description:
249+
This define the LED index in the PHY or the MAC. It's really
250+
driver dependent and required for ports that define multiple
251+
LED for the same port.
252+
253+
required:
254+
- reg
255+
256+
unevaluatedProperties: false
257+
258+
additionalProperties: false
259+
225260
dependencies:
226261
pcs-handle-names: [pcs-handle]
227262

Documentation/devicetree/bindings/net/ethernet-phy.yaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,13 +197,44 @@ properties:
197197
PHY's that have configurable TX internal delays. If this property is
198198
present then the PHY applies the TX delay.
199199
200+
leds:
201+
type: object
202+
203+
properties:
204+
'#address-cells':
205+
const: 1
206+
207+
'#size-cells':
208+
const: 0
209+
210+
patternProperties:
211+
'^led@[a-f0-9]+$':
212+
$ref: /schemas/leds/common.yaml#
213+
214+
properties:
215+
reg:
216+
maxItems: 1
217+
description:
218+
This define the LED index in the PHY or the MAC. It's really
219+
driver dependent and required for ports that define multiple
220+
LED for the same port.
221+
222+
required:
223+
- reg
224+
225+
unevaluatedProperties: false
226+
227+
additionalProperties: false
228+
200229
required:
201230
- reg
202231

203232
additionalProperties: true
204233

205234
examples:
206235
- |
236+
#include <dt-bindings/leds/common.h>
237+
207238
ethernet {
208239
#address-cells = <1>;
209240
#size-cells = <0>;
@@ -219,5 +250,17 @@ examples:
219250
reset-gpios = <&gpio1 4 1>;
220251
reset-assert-us = <1000>;
221252
reset-deassert-us = <2000>;
253+
254+
leds {
255+
#address-cells = <1>;
256+
#size-cells = <0>;
257+
258+
led@0 {
259+
reg = <0>;
260+
color = <LED_COLOR_ID_WHITE>;
261+
function = LED_FUNCTION_LAN;
262+
default-state = "keep";
263+
};
264+
};
222265
};
223266
};

Documentation/leds/well-known-leds.txt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,33 @@ Good: "platform:*:charging" (allwinner sun50i)
7070
* Screen
7171

7272
Good: ":backlight" (Motorola Droid 4)
73+
74+
* Ethernet LEDs
75+
76+
Currently two types of Network LEDs are support, those controlled by
77+
the PHY and those by the MAC. In theory both can be present at the
78+
same time for one Linux netdev, hence the names need to differ between
79+
MAC and PHY.
80+
81+
Do not use the netdev name, such as eth0, enp1s0. These are not stable
82+
and are not unique. They also don't differentiate between MAC and PHY.
83+
84+
** MAC LEDs
85+
86+
Good: f1070000.ethernet:white:WAN
87+
Good: mdio_mux-0.1:00:green:left
88+
Good: 0000:02:00.0:yellow:top
89+
90+
The first part must uniquely name the MAC controller. Then follows the
91+
colour. WAN/LAN should be used for a single LED. If there are
92+
multiple LEDs, use left/right, or top/bottom to indicate their
93+
position on the RJ45 socket.
94+
95+
** PHY LEDs
96+
97+
Good: f1072004.mdio-mii:00: white:WAN
98+
Good: !mdio-mux!mdio@2!switch@0!mdio:01:green:right
99+
Good: r8169-0-200:00:yellow:bottom
100+
101+
The first part must uniquely name the PHY. This often means uniquely
102+
identifying the MDIO bus controller, and the address on the bus.

arch/arm/boot/dts/armada-370-rd.dts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
/dts-v1/;
2121
#include <dt-bindings/input/input.h>
2222
#include <dt-bindings/interrupt-controller/irq.h>
23+
#include <dt-bindings/leds/common.h>
2324
#include <dt-bindings/gpio/gpio.h>
2425
#include "armada-370.dtsi"
2526

@@ -135,6 +136,17 @@
135136
pinctrl-names = "default";
136137
phy0: ethernet-phy@0 {
137138
reg = <0>;
139+
leds {
140+
#address-cells = <1>;
141+
#size-cells = <0>;
142+
143+
led@0 {
144+
reg = <0>;
145+
color = <LED_COLOR_ID_WHITE>;
146+
function = LED_FUNCTION_WAN;
147+
default-state = "keep";
148+
};
149+
};
138150
};
139151

140152
switch: switch@10 {

arch/arm/boot/dts/qcom-ipq8064-rb3011.dts

Lines changed: 120 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@
3838

3939
switch0: switch@10 {
4040
compatible = "qca,qca8337";
41-
#address-cells = <1>;
42-
#size-cells = <0>;
4341

4442
dsa,member = <0 0>;
4543

@@ -67,26 +65,86 @@
6765
port@1 {
6866
reg = <1>;
6967
label = "sw1";
68+
69+
leds {
70+
#address-cells = <1>;
71+
#size-cells = <0>;
72+
73+
led@0 {
74+
reg = <0>;
75+
color = <LED_COLOR_ID_GREEN>;
76+
function = LED_FUNCTION_LAN;
77+
default-state = "keep";
78+
};
79+
};
7080
};
7181

7282
port@2 {
7383
reg = <2>;
7484
label = "sw2";
85+
86+
leds {
87+
#address-cells = <1>;
88+
#size-cells = <0>;
89+
90+
led@0 {
91+
reg = <0>;
92+
color = <LED_COLOR_ID_GREEN>;
93+
function = LED_FUNCTION_LAN;
94+
default-state = "keep";
95+
};
96+
};
7597
};
7698

7799
port@3 {
78100
reg = <3>;
79101
label = "sw3";
102+
103+
leds {
104+
#address-cells = <1>;
105+
#size-cells = <0>;
106+
107+
led@0 {
108+
reg = <0>;
109+
color = <LED_COLOR_ID_GREEN>;
110+
function = LED_FUNCTION_LAN;
111+
default-state = "keep";
112+
};
113+
};
80114
};
81115

82116
port@4 {
83117
reg = <4>;
84118
label = "sw4";
119+
120+
leds {
121+
#address-cells = <1>;
122+
#size-cells = <0>;
123+
124+
led@0 {
125+
reg = <0>;
126+
color = <LED_COLOR_ID_GREEN>;
127+
function = LED_FUNCTION_LAN;
128+
default-state = "keep";
129+
};
130+
};
85131
};
86132

87133
port@5 {
88134
reg = <5>;
89135
label = "sw5";
136+
137+
leds {
138+
#address-cells = <1>;
139+
#size-cells = <0>;
140+
141+
led@0 {
142+
reg = <0>;
143+
color = <LED_COLOR_ID_GREEN>;
144+
function = LED_FUNCTION_LAN;
145+
default-state = "keep";
146+
};
147+
};
90148
};
91149
};
92150
};
@@ -105,8 +163,6 @@
105163

106164
switch1: switch@14 {
107165
compatible = "qca,qca8337";
108-
#address-cells = <1>;
109-
#size-cells = <0>;
110166

111167
dsa,member = <1 0>;
112168

@@ -134,26 +190,86 @@
134190
port@1 {
135191
reg = <1>;
136192
label = "sw6";
193+
194+
leds {
195+
#address-cells = <1>;
196+
#size-cells = <0>;
197+
198+
led@0 {
199+
reg = <0>;
200+
color = <LED_COLOR_ID_GREEN>;
201+
function = LED_FUNCTION_LAN;
202+
default-state = "keep";
203+
};
204+
};
137205
};
138206

139207
port@2 {
140208
reg = <2>;
141209
label = "sw7";
210+
211+
leds {
212+
#address-cells = <1>;
213+
#size-cells = <0>;
214+
215+
led@0 {
216+
reg = <0>;
217+
color = <LED_COLOR_ID_GREEN>;
218+
function = LED_FUNCTION_LAN;
219+
default-state = "keep";
220+
};
221+
};
142222
};
143223

144224
port@3 {
145225
reg = <3>;
146226
label = "sw8";
227+
228+
leds {
229+
#address-cells = <1>;
230+
#size-cells = <0>;
231+
232+
led@0 {
233+
reg = <0>;
234+
color = <LED_COLOR_ID_GREEN>;
235+
function = LED_FUNCTION_LAN;
236+
default-state = "keep";
237+
};
238+
};
147239
};
148240

149241
port@4 {
150242
reg = <4>;
151243
label = "sw9";
244+
245+
leds {
246+
#address-cells = <1>;
247+
#size-cells = <0>;
248+
249+
led@0 {
250+
reg = <0>;
251+
color = <LED_COLOR_ID_GREEN>;
252+
function = LED_FUNCTION_LAN;
253+
default-state = "keep";
254+
};
255+
};
152256
};
153257

154258
port@5 {
155259
reg = <5>;
156260
label = "sw10";
261+
262+
leds {
263+
#address-cells = <1>;
264+
#size-cells = <0>;
265+
266+
led@0 {
267+
reg = <0>;
268+
color = <LED_COLOR_ID_GREEN>;
269+
function = LED_FUNCTION_LAN;
270+
default-state = "keep";
271+
};
272+
};
157273
};
158274
};
159275
};

0 commit comments

Comments
 (0)