diff options
author | David S. Miller <davem@davemloft.net> | 2023-12-07 10:22:09 +0000 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2023-12-07 10:22:09 +0000 |
commit | d5449d59f10eb74a55947b95436172f8739cc57c (patch) | |
tree | bcc6036450d3a1612e9d1afaaa70be34693634c0 /drivers/net/dsa | |
parent | b8dbbbc535a95acd66035cf75872cd7524c0b12f (diff) | |
parent | 9f19a4ebc80af64bddda1cbfb9bf574b689222c0 (diff) | |
download | linux-d5449d59f10eb74a55947b95436172f8739cc57c.tar.gz linux-d5449d59f10eb74a55947b95436172f8739cc57c.tar.bz2 linux-d5449d59f10eb74a55947b95436172f8739cc57c.zip |
Merge branch 'dsa-microchip-rmii-reference'
Ante Knezic says:
====================
net: dsa: microchip: enable setting rmii reference
KSZ88X3 devices can select between internal and external RMII reference clock.
This patch series introduces new device tree property for setting reference
clock to internal.
---
V5:
- move rmii-clk-internal to be a port device tree property.
V4:
- remove rmii_clk_internal from ksz_device, as its not needed any more
- move rmii clk config as well as ksz8795_cpu_interface_select to
ksz8_config_cpu_port
V3:
- move ksz_cfg from global switch config to port config as suggested by Vladimir
Oltean
- reverse patch order as suggested by Vladimir Oltean
- adapt dt schema as suggested by Conor Dooley
V2:
- don't rely on default register settings - enforce set/clear property as
suggested by Andrew Lunn
- enforce dt schema as suggested by Conor Dooley
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/dsa')
-rw-r--r-- | drivers/net/dsa/microchip/ksz8795.c | 29 | ||||
-rw-r--r-- | drivers/net/dsa/microchip/ksz8795_reg.h | 3 |
2 files changed, 26 insertions, 6 deletions
diff --git a/drivers/net/dsa/microchip/ksz8795.c b/drivers/net/dsa/microchip/ksz8795.c index ec1ddfcf7473..61b71bcfe396 100644 --- a/drivers/net/dsa/microchip/ksz8795.c +++ b/drivers/net/dsa/microchip/ksz8795.c @@ -1358,6 +1358,9 @@ static void ksz8795_cpu_interface_select(struct ksz_device *dev, int port) { struct ksz_port *p = &dev->ports[port]; + if (!ksz_is_ksz87xx(dev)) + return; + if (!p->interface && dev->compat_interface) { dev_warn(dev->dev, "Using legacy switch \"phy-mode\" property, because it is missing on port %d node. " @@ -1391,18 +1394,29 @@ void ksz8_port_setup(struct ksz_device *dev, int port, bool cpu_port) /* enable 802.1p priority */ ksz_port_cfg(dev, port, P_PRIO_CTRL, PORT_802_1P_ENABLE, true); - if (cpu_port) { - if (!ksz_is_ksz88x3(dev)) - ksz8795_cpu_interface_select(dev, port); - + if (cpu_port) member = dsa_user_ports(ds); - } else { + else member = BIT(dsa_upstream_port(ds, port)); - } ksz8_cfg_port_member(dev, port, member); } +static void ksz88x3_config_rmii_clk(struct ksz_device *dev) +{ + struct dsa_port *cpu_dp = dsa_to_port(dev->ds, dev->cpu_port); + bool rmii_clk_internal; + + if (!ksz_is_ksz88x3(dev)) + return; + + rmii_clk_internal = of_property_read_bool(cpu_dp->dn, + "microchip,rmii-clk-internal"); + + ksz_cfg(dev, KSZ88X3_REG_FVID_AND_HOST_MODE, + KSZ88X3_PORT3_RMII_CLK_INTERNAL, rmii_clk_internal); +} + void ksz8_config_cpu_port(struct dsa_switch *ds) { struct ksz_device *dev = ds->priv; @@ -1419,6 +1433,9 @@ void ksz8_config_cpu_port(struct dsa_switch *ds) ksz8_port_setup(dev, dev->cpu_port, true); + ksz8795_cpu_interface_select(dev, dev->cpu_port); + ksz88x3_config_rmii_clk(dev); + for (i = 0; i < dev->phy_port_cnt; i++) { ksz_port_stp_state_set(ds, i, BR_STATE_DISABLED); } diff --git a/drivers/net/dsa/microchip/ksz8795_reg.h b/drivers/net/dsa/microchip/ksz8795_reg.h index 3c9dae53e4d8..beca974e0171 100644 --- a/drivers/net/dsa/microchip/ksz8795_reg.h +++ b/drivers/net/dsa/microchip/ksz8795_reg.h @@ -22,6 +22,9 @@ #define KSZ8863_GLOBAL_SOFTWARE_RESET BIT(4) #define KSZ8863_PCS_RESET BIT(0) +#define KSZ88X3_REG_FVID_AND_HOST_MODE 0xC6 +#define KSZ88X3_PORT3_RMII_CLK_INTERNAL BIT(3) + #define REG_SW_CTRL_0 0x02 #define SW_NEW_BACKOFF BIT(7) |