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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxx>
---
 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 --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;

-- 
2.34.1





[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux