Message ID | 893a3ad19b28c6bb1bf5ea18dee2fa5855f0c207.1697620929.git.ante.knezic@helmholz.de (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [net-next,v3,1/2] dt-bindings: net: microchip,ksz: document microchip,rmii-clk-internal | expand |
On Wed, Oct 18, 2023 at 11:24:14AM +0200, Ante Knezic wrote: > Microchip KSZ8863/KSZ8873 have the ability to select between internal > and external RMII reference clock. By default, reference clock > needs to be provided via REFCLKI_3 pin. If required, device can be > setup to provide RMII clock internally so that REFCLKI_3 pin can be > left unconnected. > Add a new "microchip,rmii-clk-internal" property which will set > RMII clock reference to internal. If property is not set, reference > clock needs to be provided externally. > > Signed-off-by: Ante Knezic <ante.knezic@helmholz.de> > --- > drivers/net/dsa/microchip/ksz8795.c | 10 +++++++++- > drivers/net/dsa/microchip/ksz8795_reg.h | 3 +++ > drivers/net/dsa/microchip/ksz_common.h | 1 + > 3 files changed, 13 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/dsa/microchip/ksz8795.c b/drivers/net/dsa/microchip/ksz8795.c > index 91aba470fb2f..b50ad9552c65 100644 > --- a/drivers/net/dsa/microchip/ksz8795.c > +++ b/drivers/net/dsa/microchip/ksz8795.c > @@ -1312,8 +1312,16 @@ void ksz8_port_setup(struct ksz_device *dev, int port, bool cpu_port) > ksz_port_cfg(dev, port, P_PRIO_CTRL, PORT_802_1P_ENABLE, true); > > if (cpu_port) { > - if (!ksz_is_ksz88x3(dev)) > + if (!ksz_is_ksz88x3(dev)) { > ksz8795_cpu_interface_select(dev, port); > + } else { > + dev->rmii_clk_internal = of_property_read_bool(dev->dev->of_node, > + "microchip,rmii-clk-internal"); > + > + ksz_cfg(dev, KSZ88X3_REG_FVID_AND_HOST_MODE, > + KSZ88X3_PORT3_RMII_CLK_INTERNAL, > + dev->rmii_clk_internal); > + } It looks like this is the only use of dev->rmii_clk_internal? So does it actually need to be a member of ksz_device? Andrew
On Wed, 18 Oct 2023 15:52:27 +0200, Andrew Lunn wrote: > It looks like this is the only use of dev->rmii_clk_internal? So does > it actually need to be a member of ksz_device? Yes, I guess you are right, sorry about that, it probably won't be used later on and should be removed from ksz_device. I will repost if the rest of the patch is ok?
On Wed, Oct 18, 2023 at 04:06:28PM +0200, Ante Knezic wrote: > On Wed, 18 Oct 2023 15:52:27 +0200, Andrew Lunn wrote: > > > It looks like this is the only use of dev->rmii_clk_internal? So does > > it actually need to be a member of ksz_device? > > Yes, I guess you are right, sorry about that, it probably won't be used later > on and should be removed from ksz_device. > I will repost if the rest of the patch is ok? The rest looks O.K. to me. Andrew --- pw-bot: cr
On Wed, Oct 18, 2023 at 11:24:14AM +0200, Ante Knezic wrote: > Microchip KSZ8863/KSZ8873 have the ability to select between internal > and external RMII reference clock. By default, reference clock > needs to be provided via REFCLKI_3 pin. If required, device can be > setup to provide RMII clock internally so that REFCLKI_3 pin can be > left unconnected. > Add a new "microchip,rmii-clk-internal" property which will set > RMII clock reference to internal. If property is not set, reference > clock needs to be provided externally. > > Signed-off-by: Ante Knezic <ante.knezic@helmholz.de> > --- > drivers/net/dsa/microchip/ksz8795.c | 10 +++++++++- > drivers/net/dsa/microchip/ksz8795_reg.h | 3 +++ > drivers/net/dsa/microchip/ksz_common.h | 1 + > 3 files changed, 13 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/dsa/microchip/ksz8795.c b/drivers/net/dsa/microchip/ksz8795.c > index 91aba470fb2f..b50ad9552c65 100644 > --- a/drivers/net/dsa/microchip/ksz8795.c > +++ b/drivers/net/dsa/microchip/ksz8795.c > @@ -1312,8 +1312,16 @@ void ksz8_port_setup(struct ksz_device *dev, int port, bool cpu_port) > ksz_port_cfg(dev, port, P_PRIO_CTRL, PORT_802_1P_ENABLE, true); > > if (cpu_port) { > - if (!ksz_is_ksz88x3(dev)) > + if (!ksz_is_ksz88x3(dev)) { > ksz8795_cpu_interface_select(dev, port); > + } else { > + dev->rmii_clk_internal = of_property_read_bool(dev->dev->of_node, > + "microchip,rmii-clk-internal"); > + > + ksz_cfg(dev, KSZ88X3_REG_FVID_AND_HOST_MODE, > + KSZ88X3_PORT3_RMII_CLK_INTERNAL, > + dev->rmii_clk_internal); Odd code placement, and it looks too crammed/shifted to the right due to indentation. The calling pattern is as follows: ksz8_port_setup() has 2 callers. One is from ds->ops->port_setup() -> ksz_port_setup() -> filters out everything except user ports -> dev->dev_ops->port_setup() -> ksz8_port_setup() and the other is from ds->ops->setup() // switch-wide -> dev->dev_ops->config_cpu_port() -> ksz8_config_cpu_port() -> ksz8_port_setup() So user ports and CPU ports meet at ksz8_port_setup() from different call paths, but I think it's strange to continue this coding pattern for port stuff that's not common between user ports and CPU ports. For that reason, the placement of the existing ksz8795_cpu_interface_select() is also weird, when it could have been directly placed under ksz8_config_cpu_port(), and it would have not confusingly shared a code path with user ports. Could you please add a dedicated ksz88x3_config_rmii_clk(), called directly from ksz8_config_cpu_port()? It can have this as first step: if (!ksz_is_ksz88x3(dev)) return 0; and then the rest of the code can have a single level of indentation, which would look much more natural. > + } > > member = dsa_user_ports(ds); > } else { >
On Thu, 19 Oct 2023 19:54:09 +0300, Vladimir Oltean wrote: > So user ports and CPU ports meet at ksz8_port_setup() from different > call paths, but I think it's strange to continue this coding pattern for > port stuff that's not common between user ports and CPU ports. For that > reason, the placement of the existing ksz8795_cpu_interface_select() is > also weird, when it could have been directly placed under > ksz8_config_cpu_port(), and it would have not confusingly shared a code > path with user ports. > > Could you please add a dedicated ksz88x3_config_rmii_clk(), called > directly from ksz8_config_cpu_port()? It can have this as first step: > > if (!ksz_is_ksz88x3(dev)) > return 0; > > and then the rest of the code can have a single level of indentation, > which would look much more natural. Ok, will do. I am guessing I should leave the existing ksz8795_cpu_interface_select() as it is?
On Fri, Oct 20, 2023 at 10:46:20AM +0200, Ante Knezic wrote: > Ok, will do. I am guessing I should leave the existing > ksz8795_cpu_interface_select() as it is? I would encourage moving it to the simpler call path as well, but ultimately this is up to you.
On Fri, Oct 20, 2023 at 12:27:29PM +0300, Vladimir Oltean wrote: > On Fri, Oct 20, 2023 at 10:46:20AM +0200, Ante Knezic wrote: > > Ok, will do. I am guessing I should leave the existing > > ksz8795_cpu_interface_select() as it is? > > I would encourage moving it to the simpler call path as well, but > ultimately this is up to you. Also, could you please put spaces in the commit prefix ("net: dsa: microchip: ")?
+Oleksij On Fri, Oct 20, 2023 at 01:00:53PM +0300, Vladimir Oltean wrote: > On Fri, Oct 20, 2023 at 12:27:29PM +0300, Vladimir Oltean wrote: > > On Fri, Oct 20, 2023 at 10:46:20AM +0200, Ante Knezic wrote: > > > Ok, will do. I am guessing I should leave the existing > > > ksz8795_cpu_interface_select() as it is? > > > > I would encourage moving it to the simpler call path as well, but > > ultimately this is up to you. > > Also, could you please put spaces in the commit prefix ("net: dsa: microchip: ")? One more thing. You two are working on separate things on the KSZ driver (Oleksij on https://patchwork.kernel.org/project/netdevbpf/cover/20231019122850.1199821-1-o.rempel@pengutronix.de/), and this creates conflicts in the DT schema and in ksz_common.h. For the most part, those are avoidable. Could you coordinate so that both of your next submissions do not conflict with each other? That means that each of your series can be applied independently of the other (Ante's first, or Oleksij's first). For example, the dt-schema properties do not seem alphabetically sorted (microchip,synclko-125 comes after reset-gpios), so putting wakeup-source after reset-gpios, and leaving microchip,rmii-clk-internal at the end, seems a viable strategy in avoiding that conflict. The conflict in ksz_common.h will be automatically avoided when rmii_clk_internal stops being stored in struct ksz_device.
diff --git a/drivers/net/dsa/microchip/ksz8795.c b/drivers/net/dsa/microchip/ksz8795.c index 91aba470fb2f..b50ad9552c65 100644 --- a/drivers/net/dsa/microchip/ksz8795.c +++ b/drivers/net/dsa/microchip/ksz8795.c @@ -1312,8 +1312,16 @@ void ksz8_port_setup(struct ksz_device *dev, int port, bool cpu_port) ksz_port_cfg(dev, port, P_PRIO_CTRL, PORT_802_1P_ENABLE, true); if (cpu_port) { - if (!ksz_is_ksz88x3(dev)) + if (!ksz_is_ksz88x3(dev)) { ksz8795_cpu_interface_select(dev, port); + } else { + dev->rmii_clk_internal = of_property_read_bool(dev->dev->of_node, + "microchip,rmii-clk-internal"); + + ksz_cfg(dev, KSZ88X3_REG_FVID_AND_HOST_MODE, + KSZ88X3_PORT3_RMII_CLK_INTERNAL, + dev->rmii_clk_internal); + } member = dsa_user_ports(ds); } else { 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) diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h index 8842efca0871..e5b0445fe2ca 100644 --- a/drivers/net/dsa/microchip/ksz_common.h +++ b/drivers/net/dsa/microchip/ksz_common.h @@ -163,6 +163,7 @@ struct ksz_device { phy_interface_t compat_interface; bool synclko_125; bool synclko_disable; + bool rmii_clk_internal; struct vlan_table *vlan_cache;
Microchip KSZ8863/KSZ8873 have the ability to select between internal and external RMII reference clock. By default, reference clock needs to be provided via REFCLKI_3 pin. If required, device can be setup to provide RMII clock internally so that REFCLKI_3 pin can be left unconnected. Add a new "microchip,rmii-clk-internal" property which will set RMII clock reference to internal. If property is not set, reference clock needs to be provided externally. Signed-off-by: Ante Knezic <ante.knezic@helmholz.de> --- drivers/net/dsa/microchip/ksz8795.c | 10 +++++++++- drivers/net/dsa/microchip/ksz8795_reg.h | 3 +++ drivers/net/dsa/microchip/ksz_common.h | 1 + 3 files changed, 13 insertions(+), 1 deletion(-)