All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next v1 0/6] net: dsa: microchip: provide Wake on LAN support
@ 2023-07-20 13:25 Oleksij Rempel
  2023-07-20 13:25 ` [PATCH net-next v1 1/6] dt-bindings: net: dsa: microchip: add wakeup-source property Oleksij Rempel
                   ` (6 more replies)
  0 siblings, 7 replies; 9+ messages in thread
From: Oleksij Rempel @ 2023-07-20 13:25 UTC (permalink / raw)
  To: David S. Miller, Andrew Lunn, Eric Dumazet, Florian Fainelli,
	Jakub Kicinski, Paolo Abeni, Vladimir Oltean, Woojung Huh,
	Arun Ramadoss, Conor Dooley, Krzysztof Kozlowski, Rob Herring
  Cc: Oleksij Rempel, kernel, linux-kernel, netdev, UNGLinuxDriver,
	Russell King (Oracle),
	devicetree

This series of patches provides Wake on LAN support for the KSZ9477
family of switches. It was tested on KSZ8565 Switch with PME pin
attached to an external PMIC.

The patch making WoL configuration persist on system shutdown will be
send separately, since it will potentially need more discussion.

Oleksij Rempel (6):
  dt-bindings: net: dsa: microchip: add wakeup-source property
  dt-bindings: net: dsa: microchip: add local-mac-address property
    support
  net: dsa: microchip: ksz9477: add Wake on LAN support
  net: dsa: microchip: ksz9477: add Wake on PHY event support
  net: dsa: microchip: use wakeup-source DT property to enable PME
    output
  net: dsa: microchip: ksz9477: make switch MAC address configurable

 .../bindings/net/dsa/microchip,ksz.yaml       |  3 +
 drivers/net/dsa/microchip/ksz9477.c           | 86 +++++++++++++++++++
 drivers/net/dsa/microchip/ksz9477.h           |  4 +
 drivers/net/dsa/microchip/ksz_common.c        | 51 +++++++++++
 drivers/net/dsa/microchip/ksz_common.h        |  3 +
 5 files changed, 147 insertions(+)

-- 
2.39.2


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH net-next v1 1/6] dt-bindings: net: dsa: microchip: add wakeup-source property
  2023-07-20 13:25 [PATCH net-next v1 0/6] net: dsa: microchip: provide Wake on LAN support Oleksij Rempel
@ 2023-07-20 13:25 ` Oleksij Rempel
  2023-07-20 13:25 ` [PATCH net-next v1 2/6] dt-bindings: net: dsa: microchip: add local-mac-address property support Oleksij Rempel
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Oleksij Rempel @ 2023-07-20 13:25 UTC (permalink / raw)
  To: David S. Miller, Andrew Lunn, Eric Dumazet, Florian Fainelli,
	Jakub Kicinski, Paolo Abeni, Vladimir Oltean, Woojung Huh,
	Arun Ramadoss, Conor Dooley, Krzysztof Kozlowski, Rob Herring
  Cc: Oleksij Rempel, kernel, linux-kernel, netdev, UNGLinuxDriver,
	Russell King (Oracle),
	devicetree

Add wakeup-source property to enable Wake on Lan functionality in the
switch.

Since PME wake pin is not always attached to the SoC, use wakeup-source
instead of wakeup-gpios

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 Documentation/devicetree/bindings/net/dsa/microchip,ksz.yaml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/dsa/microchip,ksz.yaml b/Documentation/devicetree/bindings/net/dsa/microchip,ksz.yaml
index e51be1ac03623..26385ba624245 100644
--- a/Documentation/devicetree/bindings/net/dsa/microchip,ksz.yaml
+++ b/Documentation/devicetree/bindings/net/dsa/microchip,ksz.yaml
@@ -49,6 +49,8 @@ properties:
       Set if the output SYNCLKO clock should be disabled. Do not mix with
       microchip,synclko-125.
 
+  wakeup-source: true
+
 required:
   - compatible
   - reg
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH net-next v1 2/6] dt-bindings: net: dsa: microchip: add local-mac-address property support
  2023-07-20 13:25 [PATCH net-next v1 0/6] net: dsa: microchip: provide Wake on LAN support Oleksij Rempel
  2023-07-20 13:25 ` [PATCH net-next v1 1/6] dt-bindings: net: dsa: microchip: add wakeup-source property Oleksij Rempel
@ 2023-07-20 13:25 ` Oleksij Rempel
  2023-07-20 13:25 ` [PATCH net-next v1 3/6] net: dsa: microchip: ksz9477: add Wake on LAN support Oleksij Rempel
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Oleksij Rempel @ 2023-07-20 13:25 UTC (permalink / raw)
  To: David S. Miller, Andrew Lunn, Eric Dumazet, Florian Fainelli,
	Jakub Kicinski, Paolo Abeni, Vladimir Oltean, Woojung Huh,
	Arun Ramadoss, Conor Dooley, Krzysztof Kozlowski, Rob Herring
  Cc: Oleksij Rempel, kernel, linux-kernel, netdev, UNGLinuxDriver,
	Russell King (Oracle),
	devicetree

All KSZ switches have configurable MAC address support which is used for
sending pause frames and for Wake on Magic Packet. So, allow local-mac-address
property in the root of the switch node.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 Documentation/devicetree/bindings/net/dsa/microchip,ksz.yaml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/net/dsa/microchip,ksz.yaml b/Documentation/devicetree/bindings/net/dsa/microchip,ksz.yaml
index 26385ba624245..fd9a10d0ba28c 100644
--- a/Documentation/devicetree/bindings/net/dsa/microchip,ksz.yaml
+++ b/Documentation/devicetree/bindings/net/dsa/microchip,ksz.yaml
@@ -50,6 +50,7 @@ properties:
       microchip,synclko-125.
 
   wakeup-source: true
+  local-mac-address: true
 
 required:
   - compatible
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH net-next v1 3/6] net: dsa: microchip: ksz9477: add Wake on LAN support
  2023-07-20 13:25 [PATCH net-next v1 0/6] net: dsa: microchip: provide Wake on LAN support Oleksij Rempel
  2023-07-20 13:25 ` [PATCH net-next v1 1/6] dt-bindings: net: dsa: microchip: add wakeup-source property Oleksij Rempel
  2023-07-20 13:25 ` [PATCH net-next v1 2/6] dt-bindings: net: dsa: microchip: add local-mac-address property support Oleksij Rempel
@ 2023-07-20 13:25 ` Oleksij Rempel
  2023-07-21  3:17   ` Jakub Kicinski
  2023-07-20 13:25 ` [PATCH net-next v1 4/6] net: dsa: microchip: ksz9477: add Wake on PHY event support Oleksij Rempel
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 9+ messages in thread
From: Oleksij Rempel @ 2023-07-20 13:25 UTC (permalink / raw)
  To: David S. Miller, Andrew Lunn, Eric Dumazet, Florian Fainelli,
	Jakub Kicinski, Paolo Abeni, Vladimir Oltean, Woojung Huh,
	Arun Ramadoss, Conor Dooley, Krzysztof Kozlowski, Rob Herring
  Cc: Oleksij Rempel, kernel, linux-kernel, netdev, UNGLinuxDriver,
	Russell King (Oracle),
	devicetree

Add WoL support for KSZ9477 family of switches. This code was tested on
KSZ8563 chip and supports only wake on Magic Packet for now.
Other parts needed for fully operational WoL support are in the followup
patches.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 drivers/net/dsa/microchip/ksz9477.c    | 71 ++++++++++++++++++++++++++
 drivers/net/dsa/microchip/ksz9477.h    |  4 ++
 drivers/net/dsa/microchip/ksz_common.c | 41 +++++++++++++++
 3 files changed, 116 insertions(+)

diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c
index ce5fb3ea26dfa..56c8fb9f0379a 100644
--- a/drivers/net/dsa/microchip/ksz9477.c
+++ b/drivers/net/dsa/microchip/ksz9477.c
@@ -56,6 +56,74 @@ int ksz9477_change_mtu(struct ksz_device *dev, int port, int mtu)
 				  REG_SW_MTU_MASK, frame_size);
 }
 
+static int ksz9477_handle_wake_reason(struct ksz_device *dev, int port)
+{
+	u8 pme_status;
+	int ret;
+
+	ret = ksz_pread8(dev, port, REG_PORT_PME_STATUS, &pme_status);
+	if (ret)
+		return ret;
+
+	if (pme_status)
+		dev_dbg(dev->dev, "Wake event on port %d due to: %s %s %s\n",
+			port,
+			pme_status & PME_WOL_MAGICPKT ? "\"Magic Packet\"" : "",
+			pme_status & PME_WOL_LINKUP ? "\"Link Up\"" : "",
+			pme_status & PME_WOL_ENERGY ? "\"Enery detect\"" : "");
+
+	return ksz_pwrite8(dev, port, REG_PORT_PME_STATUS, pme_status);
+}
+
+void ksz9477_get_wol(struct ksz_device *dev, int port,
+		     struct ethtool_wolinfo *wol)
+{
+	u8 pme_ctrl, pme_conf;
+	int ret;
+
+	ret = ksz_read8(dev, REG_SW_PME_CTRL, &pme_conf);
+	if (ret)
+		return;
+
+	if (!(pme_conf & PME_ENABLE))
+		return;
+
+	wol->supported = WAKE_MAGIC;
+
+	ret = ksz_pread8(dev, port, REG_PORT_PME_CTRL, &pme_ctrl);
+	if (ret)
+		return;
+
+	if (pme_ctrl & PME_WOL_MAGICPKT)
+		wol->wolopts |= WAKE_MAGIC;
+}
+
+int ksz9477_set_wol(struct ksz_device *dev, int port,
+		    struct ethtool_wolinfo *wol)
+{
+	u8 pme_conf, pme_ctrl = 0;
+	int ret;
+
+	if (wol->wolopts & ~WAKE_MAGIC)
+		return -EINVAL;
+
+	ret = ksz_read8(dev, REG_SW_PME_CTRL, &pme_conf);
+	if (ret)
+		return ret;
+
+	if (!(pme_conf & PME_ENABLE))
+		return -EOPNOTSUPP;
+
+	ret = ksz9477_handle_wake_reason(dev, port);
+	if (ret)
+		return ret;
+
+	if (wol->wolopts & WAKE_MAGIC)
+		pme_ctrl |= PME_WOL_MAGICPKT;
+
+	return ksz_pwrite8(dev, port, REG_PORT_PME_CTRL, pme_ctrl);
+}
+
 static int ksz9477_wait_vlan_ctrl_ready(struct ksz_device *dev)
 {
 	unsigned int val;
@@ -1004,6 +1072,9 @@ void ksz9477_port_setup(struct ksz_device *dev, int port, bool cpu_port)
 	/* clear pending interrupts */
 	if (dev->info->internal_phy[port])
 		ksz_pread16(dev, port, REG_PORT_PHY_INT_ENABLE, &data16);
+
+	/* clear pending wake flags */
+	ksz9477_handle_wake_reason(dev, port);
 }
 
 void ksz9477_config_cpu_port(struct dsa_switch *ds)
diff --git a/drivers/net/dsa/microchip/ksz9477.h b/drivers/net/dsa/microchip/ksz9477.h
index 27171482d0556..f972b6e7f1d12 100644
--- a/drivers/net/dsa/microchip/ksz9477.h
+++ b/drivers/net/dsa/microchip/ksz9477.h
@@ -58,6 +58,10 @@ int ksz9477_dsa_init(struct ksz_device *dev);
 int ksz9477_switch_init(struct ksz_device *dev);
 void ksz9477_switch_exit(struct ksz_device *dev);
 void ksz9477_port_queue_split(struct ksz_device *dev, int port);
+void ksz9477_get_wol(struct ksz_device *dev, int port,
+		     struct ethtool_wolinfo *wol);
+int ksz9477_set_wol(struct ksz_device *dev, int port,
+		    struct ethtool_wolinfo *wol);
 
 int ksz9477_port_acl_init(struct ksz_device *dev, int port);
 int ksz9477_cls_flower_add(struct dsa_switch *ds, int port,
diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c
index 87e363fb300fe..eb67bb520934d 100644
--- a/drivers/net/dsa/microchip/ksz_common.c
+++ b/drivers/net/dsa/microchip/ksz_common.c
@@ -2819,6 +2819,45 @@ static int ksz_cls_flower_del(struct dsa_switch *ds, int port,
 	return -EOPNOTSUPP;
 }
 
+static void ksz_get_wol(struct dsa_switch *ds, int port,
+			struct ethtool_wolinfo *wol)
+{
+	struct ksz_device *dev = ds->priv;
+
+	memset(wol, 0, sizeof(*wol));
+
+	switch (dev->chip_id) {
+	case KSZ8563_CHIP_ID:
+	case KSZ9477_CHIP_ID:
+	case KSZ9563_CHIP_ID:
+	case KSZ9567_CHIP_ID:
+	case KSZ9893_CHIP_ID:
+	case KSZ9896_CHIP_ID:
+	case KSZ9897_CHIP_ID:
+		ksz9477_get_wol(dev, port, wol);
+		return;
+	}
+}
+
+static int ksz_set_wol(struct dsa_switch *ds, int port,
+		       struct ethtool_wolinfo *wol)
+{
+	struct ksz_device *dev = ds->priv;
+
+	switch (dev->chip_id) {
+	case KSZ8563_CHIP_ID:
+	case KSZ9477_CHIP_ID:
+	case KSZ9563_CHIP_ID:
+	case KSZ9567_CHIP_ID:
+	case KSZ9893_CHIP_ID:
+	case KSZ9896_CHIP_ID:
+	case KSZ9897_CHIP_ID:
+		return ksz9477_set_wol(dev, port, wol);
+	}
+
+	return -EOPNOTSUPP;
+}
+
 static void ksz_set_xmii(struct ksz_device *dev, int port,
 			 phy_interface_t interface)
 {
@@ -3497,6 +3536,8 @@ static const struct dsa_switch_ops ksz_switch_ops = {
 	.set_mac_eee		= ksz_set_mac_eee,
 	.cls_flower_add		= ksz_cls_flower_add,
 	.cls_flower_del		= ksz_cls_flower_del,
+	.get_wol		= ksz_get_wol,
+	.set_wol		= ksz_set_wol,
 };
 
 struct ksz_device *ksz_switch_alloc(struct device *base, void *priv)
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH net-next v1 4/6] net: dsa: microchip: ksz9477: add Wake on PHY event support
  2023-07-20 13:25 [PATCH net-next v1 0/6] net: dsa: microchip: provide Wake on LAN support Oleksij Rempel
                   ` (2 preceding siblings ...)
  2023-07-20 13:25 ` [PATCH net-next v1 3/6] net: dsa: microchip: ksz9477: add Wake on LAN support Oleksij Rempel
@ 2023-07-20 13:25 ` Oleksij Rempel
  2023-07-20 13:25 ` [PATCH net-next v1 5/6] net: dsa: microchip: use wakeup-source DT property to enable PME output Oleksij Rempel
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Oleksij Rempel @ 2023-07-20 13:25 UTC (permalink / raw)
  To: David S. Miller, Andrew Lunn, Eric Dumazet, Florian Fainelli,
	Jakub Kicinski, Paolo Abeni, Vladimir Oltean, Woojung Huh,
	Arun Ramadoss, Conor Dooley, Krzysztof Kozlowski, Rob Herring
  Cc: Oleksij Rempel, kernel, linux-kernel, netdev, UNGLinuxDriver,
	Russell King (Oracle),
	devicetree

KSZ9477 family of switches supports multiple PHY events:
- wake on Link Up
- wake on Energy Detect.
Since current UAPI can't differentiate between this PHY events, map all of them
to WAKE_PHY.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 drivers/net/dsa/microchip/ksz9477.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c
index 56c8fb9f0379a..9a531db79f832 100644
--- a/drivers/net/dsa/microchip/ksz9477.c
+++ b/drivers/net/dsa/microchip/ksz9477.c
@@ -88,7 +88,7 @@ void ksz9477_get_wol(struct ksz_device *dev, int port,
 	if (!(pme_conf & PME_ENABLE))
 		return;
 
-	wol->supported = WAKE_MAGIC;
+	wol->supported = WAKE_PHY | WAKE_MAGIC;
 
 	ret = ksz_pread8(dev, port, REG_PORT_PME_CTRL, &pme_ctrl);
 	if (ret)
@@ -96,6 +96,8 @@ void ksz9477_get_wol(struct ksz_device *dev, int port,
 
 	if (pme_ctrl & PME_WOL_MAGICPKT)
 		wol->wolopts |= WAKE_MAGIC;
+	if (pme_ctrl & (PME_WOL_LINKUP | PME_WOL_ENERGY))
+		wol->wolopts |= WAKE_PHY;
 }
 
 int ksz9477_set_wol(struct ksz_device *dev, int port,
@@ -104,7 +106,7 @@ int ksz9477_set_wol(struct ksz_device *dev, int port,
 	u8 pme_conf, pme_ctrl = 0;
 	int ret;
 
-	if (wol->wolopts & ~WAKE_MAGIC)
+	if (wol->wolopts & ~(WAKE_PHY | WAKE_MAGIC))
 		return -EINVAL;
 
 	ret = ksz_read8(dev, REG_SW_PME_CTRL, &pme_conf);
@@ -120,6 +122,8 @@ int ksz9477_set_wol(struct ksz_device *dev, int port,
 
 	if (wol->wolopts & WAKE_MAGIC)
 		pme_ctrl |= PME_WOL_MAGICPKT;
+	if (wol->wolopts & WAKE_PHY)
+		pme_ctrl |= PME_WOL_LINKUP | PME_WOL_ENERGY;
 
 	return ksz_pwrite8(dev, port, REG_PORT_PME_CTRL, pme_ctrl);
 }
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH net-next v1 5/6] net: dsa: microchip: use wakeup-source DT property to enable PME output
  2023-07-20 13:25 [PATCH net-next v1 0/6] net: dsa: microchip: provide Wake on LAN support Oleksij Rempel
                   ` (3 preceding siblings ...)
  2023-07-20 13:25 ` [PATCH net-next v1 4/6] net: dsa: microchip: ksz9477: add Wake on PHY event support Oleksij Rempel
@ 2023-07-20 13:25 ` Oleksij Rempel
  2023-07-20 13:25 ` [PATCH net-next v1 6/6] net: dsa: microchip: ksz9477: make switch MAC address configurable Oleksij Rempel
  2023-07-20 17:14 ` [PATCH net-next v1 0/6] net: dsa: microchip: provide Wake on LAN support Conor Dooley
  6 siblings, 0 replies; 9+ messages in thread
From: Oleksij Rempel @ 2023-07-20 13:25 UTC (permalink / raw)
  To: David S. Miller, Andrew Lunn, Eric Dumazet, Florian Fainelli,
	Jakub Kicinski, Paolo Abeni, Vladimir Oltean, Woojung Huh,
	Arun Ramadoss, Conor Dooley, Krzysztof Kozlowski, Rob Herring
  Cc: Oleksij Rempel, kernel, linux-kernel, netdev, UNGLinuxDriver,
	Russell King (Oracle),
	devicetree

KSZ switches with WoL support signals wake event over PME pin. If this
pin is attached to some external PMIC or System Controller can't be
described as GPIO, the only way to describe it in the devicetree is to
use wakeup-source property. So, add support for this property and enable
PME switch output if this property is present.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 drivers/net/dsa/microchip/ksz9477.c    | 3 +++
 drivers/net/dsa/microchip/ksz_common.c | 3 +++
 drivers/net/dsa/microchip/ksz_common.h | 1 +
 3 files changed, 7 insertions(+)

diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c
index 9a531db79f832..1a3d7ae5970e2 100644
--- a/drivers/net/dsa/microchip/ksz9477.c
+++ b/drivers/net/dsa/microchip/ksz9477.c
@@ -1208,6 +1208,9 @@ int ksz9477_setup(struct dsa_switch *ds)
 			return ret;
 	}
 
+	if (dev->wakeup_source)
+		ksz_write8(dev, REG_SW_PME_CTRL, PME_ENABLE);
+
 	return 0;
 }
 
diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c
index eb67bb520934d..354cc5333675b 100644
--- a/drivers/net/dsa/microchip/ksz_common.c
+++ b/drivers/net/dsa/microchip/ksz_common.c
@@ -3717,6 +3717,9 @@ int ksz_switch_register(struct ksz_device *dev)
 			dev_err(dev->dev, "inconsistent synclko settings\n");
 			return -EINVAL;
 		}
+
+		dev->wakeup_source = of_property_read_bool(dev->dev->of_node,
+							   "wakeup-source");
 	}
 
 	ret = dsa_register_switch(dev->ds);
diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h
index 4ec53cf4b30be..b67bb9b4631ea 100644
--- a/drivers/net/dsa/microchip/ksz_common.h
+++ b/drivers/net/dsa/microchip/ksz_common.h
@@ -158,6 +158,7 @@ struct ksz_device {
 	phy_interface_t compat_interface;
 	bool synclko_125;
 	bool synclko_disable;
+	bool wakeup_source;
 
 	struct vlan_table *vlan_cache;
 
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH net-next v1 6/6] net: dsa: microchip: ksz9477: make switch MAC address configurable
  2023-07-20 13:25 [PATCH net-next v1 0/6] net: dsa: microchip: provide Wake on LAN support Oleksij Rempel
                   ` (4 preceding siblings ...)
  2023-07-20 13:25 ` [PATCH net-next v1 5/6] net: dsa: microchip: use wakeup-source DT property to enable PME output Oleksij Rempel
@ 2023-07-20 13:25 ` Oleksij Rempel
  2023-07-20 17:14 ` [PATCH net-next v1 0/6] net: dsa: microchip: provide Wake on LAN support Conor Dooley
  6 siblings, 0 replies; 9+ messages in thread
From: Oleksij Rempel @ 2023-07-20 13:25 UTC (permalink / raw)
  To: David S. Miller, Andrew Lunn, Eric Dumazet, Florian Fainelli,
	Jakub Kicinski, Paolo Abeni, Vladimir Oltean, Woojung Huh,
	Arun Ramadoss, Conor Dooley, Krzysztof Kozlowski, Rob Herring
  Cc: Oleksij Rempel, kernel, linux-kernel, netdev, UNGLinuxDriver,
	Russell King (Oracle),
	devicetree

The switch MAC address is used for sending pause frames and for Wake on Magic
Packet. So, make use of local-mac-address property in the switch node
root and configure it in the HW.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 drivers/net/dsa/microchip/ksz9477.c    | 8 ++++++++
 drivers/net/dsa/microchip/ksz_common.c | 7 +++++++
 drivers/net/dsa/microchip/ksz_common.h | 2 ++
 3 files changed, 17 insertions(+)

diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c
index 1a3d7ae5970e2..f3c59f5fd4dc2 100644
--- a/drivers/net/dsa/microchip/ksz9477.c
+++ b/drivers/net/dsa/microchip/ksz9477.c
@@ -1211,6 +1211,14 @@ int ksz9477_setup(struct dsa_switch *ds)
 	if (dev->wakeup_source)
 		ksz_write8(dev, REG_SW_PME_CTRL, PME_ENABLE);
 
+	if (is_valid_ether_addr(dev->mac_addr)) {
+		int i;
+
+		for (i = 0; i < ETH_ALEN; i++)
+			ksz_write8(dev, REG_SW_MAC_ADDR_0 + i,
+				   dev->mac_addr[i]);
+	}
+
 	return 0;
 }
 
diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c
index 354cc5333675b..b6ad1f2dddf3b 100644
--- a/drivers/net/dsa/microchip/ksz_common.c
+++ b/drivers/net/dsa/microchip/ksz_common.c
@@ -3686,6 +3686,8 @@ int ksz_switch_register(struct ksz_device *dev)
 	for (port_num = 0; port_num < dev->info->port_cnt; ++port_num)
 		dev->ports[port_num].interface = PHY_INTERFACE_MODE_NA;
 	if (dev->dev->of_node) {
+		const u8 *mac;
+
 		ret = of_get_phy_mode(dev->dev->of_node, &interface);
 		if (ret == 0)
 			dev->compat_interface = interface;
@@ -3720,6 +3722,11 @@ int ksz_switch_register(struct ksz_device *dev)
 
 		dev->wakeup_source = of_property_read_bool(dev->dev->of_node,
 							   "wakeup-source");
+
+		mac = of_get_property(dev->dev->of_node, "local-mac-address",
+				      NULL);
+		if (mac)
+			memcpy(dev->mac_addr, mac, ETH_ALEN);
 	}
 
 	ret = dsa_register_switch(dev->ds);
diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h
index b67bb9b4631ea..adedc95c60fac 100644
--- a/drivers/net/dsa/microchip/ksz_common.h
+++ b/drivers/net/dsa/microchip/ksz_common.h
@@ -171,6 +171,8 @@ struct ksz_device {
 	struct mutex lock_irq;		/* IRQ Access */
 	struct ksz_irq girq;
 	struct ksz_ptp_data ptp_data;
+
+	u8 mac_addr[ETH_ALEN];
 };
 
 /* List of supported models */
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH net-next v1 0/6] net: dsa: microchip: provide Wake on LAN support
  2023-07-20 13:25 [PATCH net-next v1 0/6] net: dsa: microchip: provide Wake on LAN support Oleksij Rempel
                   ` (5 preceding siblings ...)
  2023-07-20 13:25 ` [PATCH net-next v1 6/6] net: dsa: microchip: ksz9477: make switch MAC address configurable Oleksij Rempel
@ 2023-07-20 17:14 ` Conor Dooley
  6 siblings, 0 replies; 9+ messages in thread
From: Conor Dooley @ 2023-07-20 17:14 UTC (permalink / raw)
  To: Oleksij Rempel
  Cc: David S. Miller, Andrew Lunn, Eric Dumazet, Florian Fainelli,
	Jakub Kicinski, Paolo Abeni, Vladimir Oltean, Woojung Huh,
	Arun Ramadoss, Conor Dooley, Krzysztof Kozlowski, Rob Herring,
	kernel, linux-kernel, netdev, UNGLinuxDriver,
	Russell King (Oracle),
	devicetree

[-- Attachment #1: Type: text/plain, Size: 298 bytes --]

On Thu, Jul 20, 2023 at 03:25:50PM +0200, Oleksij Rempel wrote:

>   dt-bindings: net: dsa: microchip: add wakeup-source property
>   dt-bindings: net: dsa: microchip: add local-mac-address property
>     support

For these two,
Acked-by: Conor Dooley <conor.dooley@microchip.com>

Thanks,
Conor.


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH net-next v1 3/6] net: dsa: microchip: ksz9477: add Wake on LAN support
  2023-07-20 13:25 ` [PATCH net-next v1 3/6] net: dsa: microchip: ksz9477: add Wake on LAN support Oleksij Rempel
@ 2023-07-21  3:17   ` Jakub Kicinski
  0 siblings, 0 replies; 9+ messages in thread
From: Jakub Kicinski @ 2023-07-21  3:17 UTC (permalink / raw)
  To: Oleksij Rempel
  Cc: David S. Miller, Andrew Lunn, Eric Dumazet, Florian Fainelli,
	Paolo Abeni, Vladimir Oltean, Woojung Huh, Arun Ramadoss,
	Conor Dooley, Krzysztof Kozlowski, Rob Herring, kernel,
	linux-kernel, netdev, UNGLinuxDriver, Russell King (Oracle),
	devicetree

On Thu, 20 Jul 2023 15:25:53 +0200 Oleksij Rempel wrote:
> Add WoL support for KSZ9477 family of switches. This code was tested on
> KSZ8563 chip and supports only wake on Magic Packet for now.
> Other parts needed for fully operational WoL support are in the followup
> patches.

This one doesn't apply on net-next/main.
-- 
pw-bot: cr

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-07-21  3:18 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-20 13:25 [PATCH net-next v1 0/6] net: dsa: microchip: provide Wake on LAN support Oleksij Rempel
2023-07-20 13:25 ` [PATCH net-next v1 1/6] dt-bindings: net: dsa: microchip: add wakeup-source property Oleksij Rempel
2023-07-20 13:25 ` [PATCH net-next v1 2/6] dt-bindings: net: dsa: microchip: add local-mac-address property support Oleksij Rempel
2023-07-20 13:25 ` [PATCH net-next v1 3/6] net: dsa: microchip: ksz9477: add Wake on LAN support Oleksij Rempel
2023-07-21  3:17   ` Jakub Kicinski
2023-07-20 13:25 ` [PATCH net-next v1 4/6] net: dsa: microchip: ksz9477: add Wake on PHY event support Oleksij Rempel
2023-07-20 13:25 ` [PATCH net-next v1 5/6] net: dsa: microchip: use wakeup-source DT property to enable PME output Oleksij Rempel
2023-07-20 13:25 ` [PATCH net-next v1 6/6] net: dsa: microchip: ksz9477: make switch MAC address configurable Oleksij Rempel
2023-07-20 17:14 ` [PATCH net-next v1 0/6] net: dsa: microchip: provide Wake on LAN support Conor Dooley

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.