On 1/26/2022 4:33 PM, Robert Hancock wrote:
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.
Signed-off-by: Robert Hancock <robert.hancock@xxxxxxxxxx>
This looks good, I would just have done the hunk below a bit differently:
---
drivers/net/dsa/microchip/ksz9477.c | 7 ++++++-
drivers/net/dsa/microchip/ksz_common.c | 6 ++++++
drivers/net/dsa/microchip/ksz_common.h | 1 +
3 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c
index 353b5f981740..33d52050cd68 100644
--- a/drivers/net/dsa/microchip/ksz9477.c
+++ b/drivers/net/dsa/microchip/ksz9477.c
@@ -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);
Since you write to the same register in all of these branches, why not
do this:
u32 tmp = SW_ENABLE_REFCLKO;
if (dev->synclko_disable)
tmp = 0
else if (dev->synclko_125)
tmp = SW_ENABLE_REFCLKO | SW_REFCLKO_IS_125MHZ;
ksz_write8(dev, REG_SW_GLOBAL_OUTPUT_CTRL__1, tmp);
even though the compiler may just do that for you under the hood.
--
Florian