[net-next,v2,5/6] net: dsa: microchip: use wakeup-source DT property to enable PME output
Commit Message
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(+)
Comments
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 <florian.fainelli@broadcom.com>
@@ -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;
}
@@ -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);
@@ -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;