Skip to contentSkip to conversation

Allow disabling KSZ switch refclock

PATCH Superseded Robert Hancock 2 participants 4 messages Jan 25, 2022

Subsystems (5)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 cover Allow disabling KSZ switch refclock

The reference clock output from the KSZ9477 and related Microchip switch devices is not required on all board designs. Add a device tree property to disable it for power and EMI reasons.

Changes since v1:
-added Acked-by on patch 1, rebase to net-next

Robert Hancock (2):
net: dsa: microchip: Document property to disable reference clock
net: dsa: microchip: Add property to disable reference clock

 .../devicetree/bindings/net/dsa/microchip,ksz.yaml         | 5 +++++
 drivers/net/dsa/microchip/ksz9477.c                        | 7 ++++++-
 drivers/net/dsa/microchip/ksz_common.c                     | 2 ++
 drivers/net/dsa/microchip/ksz_common.h                     | 1 +
 4 files changed, 14 insertions(+), 1 deletion(-)
Signature · 1 line
2.31.1
#1 lore raw

PATCH v2 1/2 net: dsa: microchip: Document property to disable reference clock

Document the new microchip,synclko-disable property which can be specified to disable the reference clock output from the device if not required by the board design.

---
 Documentation/devicetree/bindings/net/dsa/microchip,ksz.yaml | 5 +++++
 1 file changed, 5 insertions(+)
Documentation/devicetree/bindings/net/dsa/microchip,ksz.yaml +5 -0
index 84985f53bffd..7cc22ab1787c 100644
@@ -42,6 +42,11 @@ properties:
     description:
       Set if the output SYNCLKO frequency should be set to 125MHz instead of 25MHz.
 
+  microchip,synclko-disable:
+    $ref: /schemas/types.yaml#/definitions/flag
+    description:
+      Set if the output SYNCLKO clock should be disabled.
+
 required:
   - compatible
   - reg
Signature · 1 line
2.31.1
#2 lore raw

PATCH v2 2/2 net: dsa: microchip: Add property to disable reference clock

In reply to Robert Hancock

Add a new microchip,synclko-disable property which can be specified to disable the reference clock output from the device if not required by the board design.

---
 drivers/net/dsa/microchip/ksz9477.c    | 7 ++++++-
 drivers/net/dsa/microchip/ksz_common.c | 2 ++
 drivers/net/dsa/microchip/ksz_common.h | 1 +
 3 files changed, 9 insertions(+), 1 deletion(-)
drivers/net/dsa/microchip/ksz9477.c +6 -1
index 353b5f981740..33d52050cd68 100644
@@ -222,9 +222,14 @@ static int ksz9477_reset_switch(struct ksz_device *dev)
 			   (BROADCAST_STORM_VALUE *
 			   BROADCAST_STORM_PROT_RATE) / 100);
 
-	if (dev->synclko_125)
+	if (dev->synclko_disable)
+		ksz_write8(dev, REG_SW_GLOBAL_OUTPUT_CTRL__1, 0);
+	else if (dev->synclko_125)
 		ksz_write8(dev, REG_SW_GLOBAL_OUTPUT_CTRL__1,
 			   SW_ENABLE_REFCLKO | SW_REFCLKO_IS_125MHZ);
+	else
+		ksz_write8(dev, REG_SW_GLOBAL_OUTPUT_CTRL__1,
+			   SW_ENABLE_REFCLKO);
 
 	return 0;
 }
drivers/net/dsa/microchip/ksz_common.c +2 -0
index 55dbda04ea62..0a524f1f227a 100644
@@ -434,6 +434,8 @@ int ksz_switch_register(struct ksz_device *dev,
 			}
 		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,
+							     "microchip,synclko-disable");
 	}
 
 	ret = dsa_register_switch(dev->ds);
drivers/net/dsa/microchip/ksz_common.h +1 -0
index df8ae59c8525..3db63f62f0a1 100644
@@ -75,6 +75,7 @@ struct ksz_device {
 	u32 regs_size;
 	bool phy_errata_9477;
 	bool synclko_125;
+	bool synclko_disable;
 
 	struct vlan_table *vlan_cache;
 
Signature · 1 line
2.31.1
maintainer
#3 lore raw

Re: [PATCH net-next v2 2/2] net: dsa: microchip: Add property to disable reference clock

drivers/net/dsa/microchip/ksz_common.c int ksz_switch_register(struct ksz_device *dev, · line 438

Quoted 4 lines
drivers/net/dsa/microchip/ksz_common.c +2 -0
 		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,
+							     "microchip,synclko-disable");

It seems like microchip,synclko-125 and microchip,synclko-disable are mutually exclusive? Please add an -EINVAL if both a present.

This should also be mentioned in the binding document.

Thanks
Andrew