* [PATCH net-next 0/3] net: dsa: lan9303: add LED mode configuration
@ 2026-11-26 14:13 Paul Louvel
2026-11-26 14:13 ` [PATCH net-next 1/3] dt-bindings: net: dsa: lan9303: add Microchip LAN9354 compatible Paul Louvel
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Paul Louvel @ 2026-11-26 14:13 UTC (permalink / raw)
To: Andrew Lunn, Vladimir Oltean, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Frank Li, Jerry Ray
Cc: netdev, devicetree, linux-kernel, Bo Mellberg, Pascal Eberhard,
Thomas Petazzoni, Miquel Raynal, Paul Louvel
Hello,
The LAN9303 and LAN9354 has 6 different LEDs, 3 LEDs are used per
external port.
On some boards the LED straps double as configuration straps for other
functions, such as the PHY address or the EEPROM size, so the desired
LED mode cannot be strapped and has to be programmed by the driver.
This series add the ability to program the LEDs function via the
vendor-defined property 'smsc,led-mode' at setup.
The first commit document the compatible LAN9354 that is missing in the
bindings. The binding was converted to YAML, but the compatible property
was never added [1].
[1]: https://lore.kernel.org/all/Yw0R7u1qV9tLSCnu@lunn.ch/
Thanks.
Signed-off-by: Paul Louvel <paul.louvel@bootlin.com>
---
Paul Louvel (3):
dt-bindings: net: dsa: lan9303: add Microchip LAN9354 compatible
dt-bindings: net: dsa: lan9303: add smsc,led-mode property
net: dsa: lan9303: add LED mode configuration
.../devicetree/bindings/net/dsa/smsc,lan9303.yaml | 35 ++++++++--
drivers/net/dsa/lan9303-core.c | 74 +++++++++++++++++++++-
include/linux/dsa/lan9303.h | 8 +++
3 files changed, 111 insertions(+), 6 deletions(-)
---
base-commit: 3dd8c790a7b7027abdd568e36db5e82ffaea7c77
change-id: 20261125-lan9303-leds-aa7c7871b4fd
Best regards,
--
Paul Louvel, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH net-next 1/3] dt-bindings: net: dsa: lan9303: add Microchip LAN9354 compatible
2026-11-26 14:13 [PATCH net-next 0/3] net: dsa: lan9303: add LED mode configuration Paul Louvel
@ 2026-11-26 14:13 ` Paul Louvel
2026-11-26 14:13 ` [PATCH net-next 2/3] dt-bindings: net: dsa: lan9303: add smsc,led-mode property Paul Louvel
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Paul Louvel @ 2026-11-26 14:13 UTC (permalink / raw)
To: Andrew Lunn, Vladimir Oltean, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Frank Li, Jerry Ray
Cc: netdev, devicetree, linux-kernel, Bo Mellberg, Pascal Eberhard,
Thomas Petazzoni, Miquel Raynal, Paul Louvel
The driver has matched "microchip,lan9354-mdio" since commit 13248b975038
("net: dsa: LAN9303: Add basic support for LAN9354"), but the binding only
documents the two SMSC compatibles. A board using the LAN9354 therefore
fails dtbs_check even though the driver binds.
Add the compatible to the enum and mention the LAN9354 in the title and
description.
Signed-off-by: Paul Louvel (Schneider Electric) <paul.louvel@bootlin.com>
---
Documentation/devicetree/bindings/net/dsa/smsc,lan9303.yaml | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/Documentation/devicetree/bindings/net/dsa/smsc,lan9303.yaml b/Documentation/devicetree/bindings/net/dsa/smsc,lan9303.yaml
index 42f8473538a0..95abf043a118 100644
--- a/Documentation/devicetree/bindings/net/dsa/smsc,lan9303.yaml
+++ b/Documentation/devicetree/bindings/net/dsa/smsc,lan9303.yaml
@@ -4,15 +4,16 @@
$id: http://devicetree.org/schemas/net/dsa/smsc,lan9303.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
-title: SMSC/MicroChip LAN9303 three port ethernet switch
+title: SMSC/MicroChip LAN9303/LAN9354 three port ethernet switch
maintainers:
- Frank Li <Frank.Li@nxp.com>
description:
- The LAN9303 is a three port ethernet switch with integrated PHYs for the
- two external ports. The third port is an RMII/MII interface to a host
- processor. The device can be managed via I2C or MDIO.
+ The LAN9303 and LAN9354 are three port ethernet switches with integrated
+ PHYs for the two external ports. The third port is an RMII/MII interface
+ to a host processor. The LAN9303 can be managed via I2C or MDIO. The
+ LAN9354 is supported in MDIO mode.
Note - always use 'reg = <0/1/2>;' for the three DSA ports, even if the
device is configured to use 1/2/3 instead. This hardware configuration
@@ -23,6 +24,7 @@ properties:
enum:
- smsc,lan9303-i2c
- smsc,lan9303-mdio
+ - microchip,lan9354-mdio
reg:
maxItems: 1
--
2.56.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH net-next 2/3] dt-bindings: net: dsa: lan9303: add smsc,led-mode property
2026-11-26 14:13 [PATCH net-next 0/3] net: dsa: lan9303: add LED mode configuration Paul Louvel
2026-11-26 14:13 ` [PATCH net-next 1/3] dt-bindings: net: dsa: lan9303: add Microchip LAN9354 compatible Paul Louvel
@ 2026-11-26 14:13 ` Paul Louvel
2026-11-26 14:13 ` [PATCH net-next 3/3] net: dsa: lan9303: add LED mode configuration Paul Louvel
2026-11-26 14:52 ` [PATCH net-next 0/3] " Andrew Lunn
3 siblings, 0 replies; 6+ messages in thread
From: Paul Louvel @ 2026-11-26 14:13 UTC (permalink / raw)
To: Andrew Lunn, Vladimir Oltean, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Frank Li, Jerry Ray
Cc: netdev, devicetree, linux-kernel, Bo Mellberg, Pascal Eberhard,
Thomas Petazzoni, Miquel Raynal, Paul Louvel
The LAN9303 and LAN9354 select the function of all six LED pins with a
single LED_FUN field. On some boards the LED straps double as
configuration straps for other functions, such as the PHY address or the
EEPROM size, so the desired LED mode cannot be strapped.
Document an optional "smsc,led-mode" property. The value 110b is
reserved on the LAN9354.
Signed-off-by: Paul Louvel (Schneider Electric) <paul.louvel@bootlin.com>
---
.../devicetree/bindings/net/dsa/smsc,lan9303.yaml | 25 ++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/Documentation/devicetree/bindings/net/dsa/smsc,lan9303.yaml b/Documentation/devicetree/bindings/net/dsa/smsc,lan9303.yaml
index 95abf043a118..f044589b643d 100644
--- a/Documentation/devicetree/bindings/net/dsa/smsc,lan9303.yaml
+++ b/Documentation/devicetree/bindings/net/dsa/smsc,lan9303.yaml
@@ -40,6 +40,18 @@ properties:
default: 200
$ref: /schemas/types.yaml#/definitions/uint32
+ smsc,led-mode:
+ description: |
+ LED function mode.
+
+ This value will apply a predefined configuration to all six LED pins of
+ both external ports. See the "LED Operation" section of the datasheet.
+
+ When the property is absent, the value sampled from the configuration
+ straps is kept.
+ $ref: /schemas/types.yaml#/definitions/uint32
+ minimum: 0
+
required:
- compatible
- reg
@@ -48,6 +60,19 @@ unevaluatedProperties: false
allOf:
- $ref: dsa.yaml#
+ - if:
+ properties:
+ compatible:
+ contains:
+ const: microchip,lan9354-mdio
+ then:
+ properties:
+ smsc,led-mode:
+ enum: [0, 1, 2, 3, 4, 5, 7]
+ else:
+ properties:
+ smsc,led-mode:
+ maximum: 3
examples:
- |
--
2.56.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH net-next 3/3] net: dsa: lan9303: add LED mode configuration
2026-11-26 14:13 [PATCH net-next 0/3] net: dsa: lan9303: add LED mode configuration Paul Louvel
2026-11-26 14:13 ` [PATCH net-next 1/3] dt-bindings: net: dsa: lan9303: add Microchip LAN9354 compatible Paul Louvel
2026-11-26 14:13 ` [PATCH net-next 2/3] dt-bindings: net: dsa: lan9303: add smsc,led-mode property Paul Louvel
@ 2026-11-26 14:13 ` Paul Louvel
2026-11-26 15:04 ` Andrew Lunn
2026-11-26 14:52 ` [PATCH net-next 0/3] " Andrew Lunn
3 siblings, 1 reply; 6+ messages in thread
From: Paul Louvel @ 2026-11-26 14:13 UTC (permalink / raw)
To: Andrew Lunn, Vladimir Oltean, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Frank Li, Jerry Ray
Cc: netdev, devicetree, linux-kernel, Bo Mellberg, Pascal Eberhard,
Thomas Petazzoni, Miquel Raynal, Paul Louvel
The LED function of the LAN9303 and LAN9354 is selected by a single
LED_FUN field that applies to all six LED pins of the two external
ports.
On some boards the LED straps double as configuration straps for other
functions, such as the PHY address or the EEPROM size, so the desired
LED mode cannot be strapped and has to be programmed by the driver.
The LED subsystem is not used here: it models each LED independently,
while this hardware has one function field for all LEDs.
Read the optional "smsc,led-mode", and configure the device accordingly.
Signed-off-by: Paul Louvel (Schneider Electric) <paul.louvel@bootlin.com>
---
drivers/net/dsa/lan9303-core.c | 74 ++++++++++++++++++++++++++++++++++++++++--
include/linux/dsa/lan9303.h | 8 +++++
2 files changed, 80 insertions(+), 2 deletions(-)
diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c
index 8eeb8953ff24..6a9ade873e42 100644
--- a/drivers/net/dsa/lan9303-core.c
+++ b/drivers/net/dsa/lan9303-core.c
@@ -10,6 +10,7 @@
#include <linux/mutex.h>
#include <linux/mii.h>
#include <linux/of.h>
+#include <linux/property.h>
#include <linux/phy.h>
#include <linux/if_bridge.h>
#include <linux/if_vlan.h>
@@ -63,6 +64,13 @@
#define LAN9303_SWITCH_CSR_CMD_BUSY BIT(31)
#define LAN9303_SWITCH_CSR_CMD_RW BIT(30)
#define LAN9303_SWITCH_CSR_CMD_LANES (BIT(19) | BIT(18) | BIT(17) | BIT(16))
+#define LAN9303_LED_CFG 0x6f
+# define LAN9303_LED_CFG_LED_FUN_MAX_VAL 0x7
+# define LAN9303_LED_CFG_LED_FUN_SHIFT 8
+# define LAN9303_LED_CFG_LED_FUN_MASK GENMASK(9, 8)
+# define LAN9303_LED_CFG_LED_MODES GENMASK(3, 0)
+# define LAN9354_LED_CFG_LED_FUN_MASK GENMASK(10, 8)
+# define LAN9354_LED_CFG_LED_MODES (GENMASK(5, 0) | BIT(7))
#define LAN9303_VIRT_PHY_BASE 0x70
#define LAN9303_VIRT_SPECIAL_CTRL 0x77
#define LAN9303_VIRT_SPECIAL_TURBO BIT(10) /*Turbo MII Enable*/
@@ -240,6 +248,16 @@ static unsigned int flow_ctl_reg[] = {
LAN9303_MANUAL_FC_2
};
+static const struct lan9303_led_info lan9303_led_info = {
+ .fun_mask = LAN9303_LED_CFG_LED_FUN_MASK,
+ .avail_modes = LAN9303_LED_CFG_LED_MODES,
+};
+
+static const struct lan9303_led_info lan9354_led_info = {
+ .fun_mask = LAN9354_LED_CFG_LED_FUN_MASK,
+ .avail_modes = LAN9354_LED_CFG_LED_MODES,
+};
+
static int lan9303_read(struct regmap *regmap, unsigned int offset, u32 *reg)
{
int ret, i;
@@ -778,6 +796,20 @@ static int lan9303_enable_processing_port(struct lan9303 *chip,
LAN9303_MAC_TX_CFG_X_TX_ENABLE);
}
+static int lan9303_setup_leds(struct lan9303 *chip)
+{
+ unsigned int val;
+
+ if (chip->led_sel_mode >= 0) {
+ val = chip->led_sel_mode << LAN9303_LED_CFG_LED_FUN_SHIFT;
+
+ return regmap_update_bits(chip->regmap, LAN9303_LED_CFG, chip->led_info->fun_mask,
+ val);
+ }
+
+ return 0;
+}
+
/* forward special tagged packets from port 0 to port 1 *or* port 2 */
static int lan9303_setup_tagging(struct lan9303 *chip)
{
@@ -902,8 +934,14 @@ static int lan9303_check_device(struct lan9303 *chip)
return ret;
}
- if (((reg >> 16) != LAN9303_CHIP_ID) &&
- ((reg >> 16) != LAN9354_CHIP_ID)) {
+ switch (reg >> 16) {
+ case LAN9303_CHIP_ID:
+ chip->led_info = &lan9303_led_info;
+ break;
+ case LAN9354_CHIP_ID:
+ chip->led_info = &lan9354_led_info;
+ break;
+ default:
dev_err(chip->dev, "unexpected device found: LAN%4.4X\n",
reg >> 16);
return -ENODEV;
@@ -932,6 +970,30 @@ static int lan9303_check_device(struct lan9303 *chip)
return 0;
}
+static int lan9303_parse_dt(struct lan9303 *chip)
+{
+ u32 led_mode;
+ int ret;
+
+ if (!device_property_present(chip->dev, "smsc,led-mode")) {
+ chip->led_sel_mode = -1;
+ } else {
+ ret = device_property_read_u32(chip->dev, "smsc,led-mode", &led_mode);
+ if (ret)
+ return ret;
+
+ if (led_mode > LAN9303_LED_CFG_LED_FUN_MAX_VAL ||
+ !(chip->led_info->avail_modes & BIT(led_mode))) {
+ dev_err(chip->dev, "invalid led mode %u\n", led_mode);
+ return -EINVAL;
+ }
+
+ chip->led_sel_mode = led_mode;
+ }
+
+ return 0;
+}
+
/* ---------------------------- DSA -----------------------------------*/
static enum dsa_tag_protocol lan9303_get_tag_protocol(struct dsa_switch *ds,
@@ -964,6 +1026,10 @@ static int lan9303_setup(struct dsa_switch *ds)
regmap_write(chip->regmap, LAN9303_VIRT_SPECIAL_CTRL, reg);
}
+ ret = lan9303_setup_leds(chip);
+ if (ret)
+ dev_err(chip->dev, "failed to setup leds %d\n", ret);
+
ret = lan9303_setup_tagging(chip);
if (ret)
dev_err(chip->dev, "failed to setup port tagging %d\n", ret);
@@ -1477,6 +1543,10 @@ int lan9303_probe(struct lan9303 *chip, struct device_node *np)
if (ret)
return ret;
+ ret = lan9303_parse_dt(chip);
+ if (ret)
+ return ret;
+
ret = lan9303_register_switch(chip);
if (ret) {
dev_dbg(chip->dev, "Failed to register switch: %d\n", ret);
diff --git a/include/linux/dsa/lan9303.h b/include/linux/dsa/lan9303.h
index 3ce7cbcc37a3..f0111ad7fb7f 100644
--- a/include/linux/dsa/lan9303.h
+++ b/include/linux/dsa/lan9303.h
@@ -17,6 +17,11 @@ struct lan9303_alr_cache_entry {
u8 stp_override; /* non zero if set LAN9303_ALR_DAT1_AGE_OVERRID */
};
+struct lan9303_led_info {
+ u32 fun_mask;
+ u32 avail_modes;
+};
+
struct lan9303 {
struct device *dev;
struct regmap *regmap;
@@ -30,6 +35,9 @@ struct lan9303 {
const struct lan9303_phy_ops *ops;
bool is_bridged; /* true if port 1 and 2 are bridged */
+ const struct lan9303_led_info *led_info;
+ int led_sel_mode;
+
/* remember LAN9303_SWE_PORT_STATE while not bridged */
u32 swe_port_state;
/* LAN9303 do not offer reading specific ALR entry. Cache all
--
2.56.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net-next 0/3] net: dsa: lan9303: add LED mode configuration
2026-11-26 14:13 [PATCH net-next 0/3] net: dsa: lan9303: add LED mode configuration Paul Louvel
` (2 preceding siblings ...)
2026-11-26 14:13 ` [PATCH net-next 3/3] net: dsa: lan9303: add LED mode configuration Paul Louvel
@ 2026-11-26 14:52 ` Andrew Lunn
3 siblings, 0 replies; 6+ messages in thread
From: Andrew Lunn @ 2026-11-26 14:52 UTC (permalink / raw)
To: Paul Louvel
Cc: Vladimir Oltean, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Frank Li, Jerry Ray, netdev, devicetree, linux-kernel,
Bo Mellberg, Pascal Eberhard, Thomas Petazzoni, Miquel Raynal
> This series add the ability to program the LEDs function via the
> vendor-defined property 'smsc,led-mode' at setup.
Sorry, but NACK.
Please use /sys/class/leds, with the ledtrigger-netdev, and offloading
to the hardware.
Andrew
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net-next 3/3] net: dsa: lan9303: add LED mode configuration
2026-11-26 14:13 ` [PATCH net-next 3/3] net: dsa: lan9303: add LED mode configuration Paul Louvel
@ 2026-11-26 15:04 ` Andrew Lunn
0 siblings, 0 replies; 6+ messages in thread
From: Andrew Lunn @ 2026-11-26 15:04 UTC (permalink / raw)
To: Paul Louvel
Cc: Vladimir Oltean, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Frank Li, Jerry Ray, netdev, devicetree, linux-kernel,
Bo Mellberg, Pascal Eberhard, Thomas Petazzoni, Miquel Raynal
On Thu, Nov 26, 2026 at 03:13:45PM +0100, Paul Louvel wrote:
> The LED function of the LAN9303 and LAN9354 is selected by a single
> LED_FUN field that applies to all six LED pins of the two external
> ports.
>
> On some boards the LED straps double as configuration straps for other
> functions, such as the PHY address or the EEPROM size, so the desired
> LED mode cannot be strapped and has to be programmed by the driver.
>
> The LED subsystem is not used here: it models each LED independently,
> while this hardware has one function field for all LEDs.
Ah. This should of been in the cover letter...
[Goes and looks at the data sheet]
https://ww1.microchip.com/downloads/aemDocuments/documents/OTH/ProductDocuments/DataSheets/00002308A.pdf
So you have the choice of using the pin as a GPIO. So you can
implement pure on/off. That gives you the minimum you need for
/sys/class/leds.
TABLE 12-1: LED OPERATION AS A FUNCTION OF LED_FUN[1:0]
The functions are rather scattered all over the place, but i don't see
a blocker to supporting hardware offload. It will be messy, yes, but
possible.
We have been pushing back on vendor properties for LEDs for a number
of years, so i don't really want to add one now.
Andrew
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-11-26 15:05 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-26 14:13 [PATCH net-next 0/3] net: dsa: lan9303: add LED mode configuration Paul Louvel
2026-11-26 14:13 ` [PATCH net-next 1/3] dt-bindings: net: dsa: lan9303: add Microchip LAN9354 compatible Paul Louvel
2026-11-26 14:13 ` [PATCH net-next 2/3] dt-bindings: net: dsa: lan9303: add smsc,led-mode property Paul Louvel
2026-11-26 14:13 ` [PATCH net-next 3/3] net: dsa: lan9303: add LED mode configuration Paul Louvel
2026-11-26 15:04 ` Andrew Lunn
2026-11-26 14:52 ` [PATCH net-next 0/3] " Andrew Lunn
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®