2023-07-21 13:58:51

by Oleksij Rempel

[permalink] [raw]
Subject: [PATCH net-next v2 5/6] net: dsa: microchip: use wakeup-source DT property to enable PME output

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 <[email protected]>
---
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 e3143b95a8ec9..69909241b1f44 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)
/* enable global MIB counter freeze function */
ksz_cfg(dev, REG_SW_MAC_CTRL_6, SW_MIB_COUNTER_FREEZE, true);

+ 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 6adc2c6537a31..a7b298838932c 100644
--- a/drivers/net/dsa/microchip/ksz_common.c
+++ b/drivers/net/dsa/microchip/ksz_common.c
@@ -3715,6 +3715,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 6dca488fbc5f2..589f8b582a415 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



2023-07-22 14:58:16

by Florian Fainelli

[permalink] [raw]
Subject: Re: [PATCH net-next v2 5/6] net: dsa: microchip: use wakeup-source DT property to enable PME output



On 7/21/2023 6:55 AM, Oleksij Rempel wrote:
> 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.

There is a word missing in the above sentence between "System
Controller" and "can't be", and I believe the word is "that".

> So, add support for this property and enable
> PME switch output if this property is present.

A property that "enables" something means that you are using Device Tree
as a way to encode some sort of policy, maybe this is just the wording
here and what you would want to say is that describing the node with a
'wakeup-source' property indicates that the device is wake-up capable,
regardless of the presence/absence of an interrupt parent?

With the commit message reworded:

Reviewed-by: Florian Fainelli <[email protected]>
--
Florian