diff mbox series

[net-next,1/2] net: dsa: microchip: Add of config for LED mode for ksz87xx and ksz88x3

Message ID 20241209-netdev-net-next-ksz8_led-mode-v1-1-c7b52c2ebf1b@ifm.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series net: dsa: microchip: Add of config for LED mode for ksz87xx and ksz88x3 | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 8 of 8 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 1 this patch: 1
netdev/checkpatch warning WARNING: line length of 87 exceeds 80 columns WARNING: line length of 94 exceeds 80 columns
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 1 this patch: 1
netdev/source_inline success Was 0 now: 0

Commit Message

Fedor Ross Dec. 9, 2024, 5:58 p.m. UTC
Add support for the led-mode property for the following PHYs which have
a single LED mode configuration value.

KSZ8765, KSZ8794 and KSZ8795 use register 0x0b bits 5,4 to control the
LED configuration.

KSZ8863 and KSZ8873 use register 0xc3 bits 5,4 to control the LED
configuration.

Signed-off-by: Fedor Ross <fedor.ross@ifm.com>
---
 drivers/net/dsa/microchip/ksz8.c       | 9 +++++++++
 drivers/net/dsa/microchip/ksz8_reg.h   | 1 +
 drivers/net/dsa/microchip/ksz_common.c | 2 ++
 drivers/net/dsa/microchip/ksz_common.h | 1 +
 4 files changed, 13 insertions(+)
diff mbox series

Patch

diff --git a/drivers/net/dsa/microchip/ksz8.c b/drivers/net/dsa/microchip/ksz8.c
index da7110d675583dfb7c9be876d5ec5d12cddcf9b4..6bac134b1ccd9cadf6f878d0e0e73f17ed23b45a 100644
--- a/drivers/net/dsa/microchip/ksz8.c
+++ b/drivers/net/dsa/microchip/ksz8.c
@@ -1898,6 +1898,15 @@  int ksz8_setup(struct dsa_switch *ds)
 	regmap_update_bits(ksz_regmap_8(dev), REG_SW_CTRL_1,
 			   SW_AGGR_BACKOFF, SW_AGGR_BACKOFF);
 
+	/* Configure LED mode */
+	if (dev->led_mode > 3)
+		dev_warn(dev->dev, "Invalid LED mode %d, supported modes 0..3.\n",
+			 dev->led_mode);
+	else if (!ksz_is_8895_family(dev))
+		ksz_cfg(dev,
+			ksz_is_ksz88x3(dev) ? REG_SW_PWR_MGMT_LED_MODE : REG_SW_CTRL_9,
+			dev->led_mode << 4, true);
+
 	/*
 	 * Make sure unicast VLAN boundary is set as default and
 	 * enable no excessive collision drop.
diff --git a/drivers/net/dsa/microchip/ksz8_reg.h b/drivers/net/dsa/microchip/ksz8_reg.h
index 329688603a582b7f9dddc774327036edb54435f7..d04ae01c29b398414739e425d2c401ccbcfdac32 100644
--- a/drivers/net/dsa/microchip/ksz8_reg.h
+++ b/drivers/net/dsa/microchip/ksz8_reg.h
@@ -589,6 +589,7 @@ 
 /* 88x3 specific */
 
 #define REG_SW_INSERT_SRC_PVID		0xC2
+#define REG_SW_PWR_MGMT_LED_MODE	0xC3
 
 /* PME */
 
diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c
index 920443ee8ffd02380da64cd9e14e867d6210e890..22eb882c7335001aa545c1abe65f25f4586e2d7f 100644
--- a/drivers/net/dsa/microchip/ksz_common.c
+++ b/drivers/net/dsa/microchip/ksz_common.c
@@ -5090,6 +5090,8 @@  int ksz_switch_register(struct ksz_device *dev)
 			}
 			of_node_put(ports);
 		}
+		of_property_read_u32(dev->dev->of_node, "microchip,led-mode", &dev->led_mode);
+
 		dev->synclko_125 = of_property_read_bool(dev->dev->of_node,
 							 "microchip,synclko-125");
 		dev->synclko_disable = of_property_read_bool(dev->dev->of_node,
diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h
index b3bb75ca0796d208f232455677d338209bdaa97d..906f62b9cdb3677c3f8ece468d6ae93a3031db6d 100644
--- a/drivers/net/dsa/microchip/ksz_common.h
+++ b/drivers/net/dsa/microchip/ksz_common.h
@@ -175,6 +175,7 @@  struct ksz_device {
 	u32 chip_id;
 	u8 chip_rev;
 	int cpu_port;			/* port connected to CPU */
+	unsigned int led_mode;
 	int phy_port_cnt;
 	phy_interface_t compat_interface;
 	bool synclko_125;