lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241209-netdev-net-next-ksz8_led-mode-v1-1-c7b52c2ebf1b@ifm.com>
Date: Mon, 9 Dec 2024 18:58:51 +0100
From: Fedor Ross <fedor.ross@....com>
To: Woojung Huh <woojung.huh@...rochip.com>, <UNGLinuxDriver@...rochip.com>,
        Andrew Lunn <andrew@...n.ch>, Vladimir Oltean <olteanv@...il.com>,
        "David S.
 Miller" <davem@...emloft.net>,
        Eric Dumazet <edumazet@...gle.com>,
        "Jakub
 Kicinski" <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
        Rob Herring
	<robh@...nel.org>,
        Krzysztof Kozlowski <krzk+dt@...nel.org>,
        Conor Dooley
	<conor+dt@...nel.org>, Marek Vasut <marex@...x.de>
CC: <netdev@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
        Woojung Huh
	<Woojung.Huh@...rochip.com>, <devicetree@...r.kernel.org>,
        Tristram Ha
	<tristram.ha@...rochip.com>,
        Fedor Ross <fedor.ross@....com>
Subject: [PATCH net-next 1/2] net: dsa: microchip: Add of config for LED
 mode for ksz87xx and ksz88x3

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@....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 --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


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ