Skip to contentSkip to conversation

Allow disabling KSZ switch refclock

PATCH Applied Robert Hancock 3 participants 6 messages Jan 27, 2022 – Jan 28, 2022

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

v4 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 v3:
-rework some code for simplicity

Changes since v2:
-check for conflicting options in DT, added note in bindings doc

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       | 6 ++++++
 drivers/net/dsa/microchip/ksz9477.c                      | 9 ++++++---
 drivers/net/dsa/microchip/ksz_common.c                   | 6 ++++++
 drivers/net/dsa/microchip/ksz_common.h                   | 1 +
 4 files changed, 19 insertions(+), 3 deletions(-)
Signature · 1 line
2.31.1
#1 lore raw

PATCH v4 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.

---
 .../devicetree/bindings/net/dsa/microchip,ksz.yaml          | 6 ++++++
 1 file changed, 6 insertions(+)
Documentation/devicetree/bindings/net/dsa/microchip,ksz.yaml +6 -0
index 84985f53bffd..184152087b60 100644
@@ -42,6 +42,12 @@ 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. Do not mix with
+      microchip,synclko-125.
+
 required:
   - compatible
   - reg
Signature · 1 line
2.31.1
Reviewed-by on v4 1/2
#2 lore raw

Re: [PATCH net-next v4 1/2] net: dsa: microchip: Document property to disable reference clock

Quoted 6 lines · Robert Hancock

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.

Signature · 1 line
Florian
#3 lore raw

PATCH v4 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    | 9 ++++++---
 drivers/net/dsa/microchip/ksz_common.c | 6 ++++++
 drivers/net/dsa/microchip/ksz_common.h | 1 +
 3 files changed, 13 insertions(+), 3 deletions(-)
drivers/net/dsa/microchip/ksz9477.c +6 -3
index 353b5f981740..a85d990896b0 100644
@@ -222,9 +222,12 @@ static int ksz9477_reset_switch(struct ksz_device *dev)
 			   (BROADCAST_STORM_VALUE *
 			   BROADCAST_STORM_PROT_RATE) / 100);
 
-	if (dev->synclko_125)
-		ksz_write8(dev, REG_SW_GLOBAL_OUTPUT_CTRL__1,
-			   SW_ENABLE_REFCLKO | SW_REFCLKO_IS_125MHZ);
+	data8 = SW_ENABLE_REFCLKO;
+	if (dev->synclko_disable)
+		data8 = 0;
+	else if (dev->synclko_125)
+		data8 = SW_ENABLE_REFCLKO | SW_REFCLKO_IS_125MHZ;
+	ksz_write8(dev, REG_SW_GLOBAL_OUTPUT_CTRL__1, data8);
 
 	return 0;
 }
drivers/net/dsa/microchip/ksz_common.c +6 -0
index 55dbda04ea62..7e33ec73f803 100644
@@ -434,6 +434,12 @@ 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");
+		if (dev->synclko_125 && dev->synclko_disable) {
+			dev_err(dev->dev, "inconsistent synclko settings\n");
+			return -EINVAL;
+		}
 	}
 
 	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
#5 lore raw
In reply to Robert Hancock
This series was applied to netdev/net-next.git (master) by David S. Miller <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (master) by David S. Miller <[email protected]>:

Quoted 8 lines · On Thu, 27 Jan 2022 10:41:54 -0600 you wrote:

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 v3:
-rework some code for simplicity

[...]

Here is the summary with links:
- [net-next,v4,1/2] net: dsa: microchip: Document property to disable reference clock
https://git.kernel.org/netdev/net-next/c/eccfecfe587b
- [net-next,v4,2/2] net: dsa: microchip: Add property to disable reference clock

    https://git.kernel.org/netdev/net-next/c/48bf8b8a04c9

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html