From: Romain Gantois <romain.gantois@bootlin.com> To: "Russell King" <linux@armlinux.org.uk>, "Andrew Lunn" <andrew@lunn.ch>, "Heiner Kallweit" <hkallweit1@gmail.com>, "David S. Miller" <davem@davemloft.net>, "Eric Dumazet" <edumazet@google.com>, "Jakub Kicinski" <kuba@kernel.org>, "Paolo Abeni" <pabeni@redhat.com>, "Alexandre Torgue" <alexandre.torgue@foss.st.com>, "Jose Abreu" <joabreu@synopsys.com>, "Maxime Coquelin" <mcoquelin.stm32@gmail.com>, "Clément Léger" <clement.leger@bootlin.com> Cc: Maxime Chevallier <maxime.chevallier@bootlin.com>, Miquel Raynal <miquel.raynal@bootlin.com>, Thomas Petazzoni <thomas.petazzoni@bootlin.com>, netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-renesas-soc@vger.kernel.org, Romain Gantois <romain.gantois@bootlin.com> Subject: [PATCH net-next v4 7/7] net: pcs: rzn1-miic: Init RX clock early if MAC requires it Date: Wed, 21 Feb 2024 14:04:24 +0100 [thread overview] Message-ID: <20240221-rxc_bugfix-v4-7-4883ee1cc7b1@bootlin.com> (raw) In-Reply-To: <20240221-rxc_bugfix-v4-0-4883ee1cc7b1@bootlin.com> The GMAC1 controller in the RZN1 IP requires the RX MII clock signal to be started before it initializes its own hardware, thus before it calls phylink_start. Implement the pcs_pre_init() callback so that the RX clock signal can be enabled early if necessary. Reported-by: Clément Léger <clement.leger@bootlin.com> Link: https://lore.kernel.org/linux-arm-kernel/20230116103926.276869-4-clement.leger@bootlin.com/ Signed-off-by: Romain Gantois <romain.gantois@bootlin.com> --- drivers/net/pcs/pcs-rzn1-miic.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/net/pcs/pcs-rzn1-miic.c b/drivers/net/pcs/pcs-rzn1-miic.c index d93f84fbb1fd..8a683c76a0f2 100644 --- a/drivers/net/pcs/pcs-rzn1-miic.c +++ b/drivers/net/pcs/pcs-rzn1-miic.c @@ -279,10 +279,38 @@ static int miic_validate(struct phylink_pcs *pcs, unsigned long *supported, return -EINVAL; } +static int miic_pre_init(struct phylink_pcs *pcs) +{ + struct miic_port *miic_port = phylink_pcs_to_miic_port(pcs); + struct miic *miic = miic_port->miic; + u32 val, mask; + + /* Start RX clock if required */ + if (pcs->rxc_always_on) { + /* In MII through mode, the clock signals will be driven by the + * external PHY, which might not be initialized yet. Set RMII + * as default mode to ensure that a reference clock signal is + * generated. + */ + miic_port->interface = PHY_INTERFACE_MODE_RMII; + + val = FIELD_PREP(MIIC_CONVCTRL_CONV_MODE, CONV_MODE_RMII) | + FIELD_PREP(MIIC_CONVCTRL_CONV_SPEED, CONV_MODE_100MBPS); + mask = MIIC_CONVCTRL_CONV_MODE | MIIC_CONVCTRL_CONV_SPEED; + + miic_reg_rmw(miic, MIIC_CONVCTRL(miic_port->port), mask, val); + + miic_converter_enable(miic, miic_port->port, 1); + } + + return 0; +} + static const struct phylink_pcs_ops miic_phylink_ops = { .pcs_validate = miic_validate, .pcs_config = miic_config, .pcs_link_up = miic_link_up, + .pcs_pre_init = miic_pre_init, }; struct phylink_pcs *miic_create(struct device *dev, struct device_node *np) -- 2.43.0
WARNING: multiple messages have this Message-ID (diff)
From: Romain Gantois <romain.gantois@bootlin.com> To: "Russell King" <linux@armlinux.org.uk>, "Andrew Lunn" <andrew@lunn.ch>, "Heiner Kallweit" <hkallweit1@gmail.com>, "David S. Miller" <davem@davemloft.net>, "Eric Dumazet" <edumazet@google.com>, "Jakub Kicinski" <kuba@kernel.org>, "Paolo Abeni" <pabeni@redhat.com>, "Alexandre Torgue" <alexandre.torgue@foss.st.com>, "Jose Abreu" <joabreu@synopsys.com>, "Maxime Coquelin" <mcoquelin.stm32@gmail.com>, "Clément Léger" <clement.leger@bootlin.com> Cc: Maxime Chevallier <maxime.chevallier@bootlin.com>, Miquel Raynal <miquel.raynal@bootlin.com>, Thomas Petazzoni <thomas.petazzoni@bootlin.com>, netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-renesas-soc@vger.kernel.org, Romain Gantois <romain.gantois@bootlin.com> Subject: [PATCH net-next v4 7/7] net: pcs: rzn1-miic: Init RX clock early if MAC requires it Date: Wed, 21 Feb 2024 14:04:24 +0100 [thread overview] Message-ID: <20240221-rxc_bugfix-v4-7-4883ee1cc7b1@bootlin.com> (raw) In-Reply-To: <20240221-rxc_bugfix-v4-0-4883ee1cc7b1@bootlin.com> The GMAC1 controller in the RZN1 IP requires the RX MII clock signal to be started before it initializes its own hardware, thus before it calls phylink_start. Implement the pcs_pre_init() callback so that the RX clock signal can be enabled early if necessary. Reported-by: Clément Léger <clement.leger@bootlin.com> Link: https://lore.kernel.org/linux-arm-kernel/20230116103926.276869-4-clement.leger@bootlin.com/ Signed-off-by: Romain Gantois <romain.gantois@bootlin.com> --- drivers/net/pcs/pcs-rzn1-miic.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/net/pcs/pcs-rzn1-miic.c b/drivers/net/pcs/pcs-rzn1-miic.c index d93f84fbb1fd..8a683c76a0f2 100644 --- a/drivers/net/pcs/pcs-rzn1-miic.c +++ b/drivers/net/pcs/pcs-rzn1-miic.c @@ -279,10 +279,38 @@ static int miic_validate(struct phylink_pcs *pcs, unsigned long *supported, return -EINVAL; } +static int miic_pre_init(struct phylink_pcs *pcs) +{ + struct miic_port *miic_port = phylink_pcs_to_miic_port(pcs); + struct miic *miic = miic_port->miic; + u32 val, mask; + + /* Start RX clock if required */ + if (pcs->rxc_always_on) { + /* In MII through mode, the clock signals will be driven by the + * external PHY, which might not be initialized yet. Set RMII + * as default mode to ensure that a reference clock signal is + * generated. + */ + miic_port->interface = PHY_INTERFACE_MODE_RMII; + + val = FIELD_PREP(MIIC_CONVCTRL_CONV_MODE, CONV_MODE_RMII) | + FIELD_PREP(MIIC_CONVCTRL_CONV_SPEED, CONV_MODE_100MBPS); + mask = MIIC_CONVCTRL_CONV_MODE | MIIC_CONVCTRL_CONV_SPEED; + + miic_reg_rmw(miic, MIIC_CONVCTRL(miic_port->port), mask, val); + + miic_converter_enable(miic, miic_port->port, 1); + } + + return 0; +} + static const struct phylink_pcs_ops miic_phylink_ops = { .pcs_validate = miic_validate, .pcs_config = miic_config, .pcs_link_up = miic_link_up, + .pcs_pre_init = miic_pre_init, }; struct phylink_pcs *miic_create(struct device *dev, struct device_node *np) -- 2.43.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2024-02-21 13:04 UTC|newest] Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-02-21 13:04 [PATCH net-next v4 0/7] Fix missing PHY-to-MAC RX clock Romain Gantois 2024-02-21 13:04 ` Romain Gantois 2024-02-21 13:04 ` [PATCH net-next v4 1/7] net: phylink: add PHY_F_RXC_ALWAYS_ON to PHY dev flags Romain Gantois 2024-02-21 13:04 ` Romain Gantois 2024-02-21 13:04 ` [PATCH net-next v4 2/7] net: phylink: add rxc_always_on flag to phylink_pcs Romain Gantois 2024-02-21 13:04 ` Romain Gantois 2024-02-21 19:07 ` Simon Horman 2024-02-21 19:07 ` Simon Horman 2024-02-22 8:31 ` Romain Gantois 2024-02-22 8:31 ` Romain Gantois 2024-02-21 13:04 ` [PATCH net-next v4 3/7] net: stmmac: don't rely on lynx_pcs presence to check for a PHY Romain Gantois 2024-02-21 13:04 ` Romain Gantois 2024-02-21 13:04 ` [PATCH net-next v4 4/7] net: stmmac: Support a generic PCS field in mac_device_info Romain Gantois 2024-02-21 13:04 ` Romain Gantois 2024-02-21 13:04 ` [PATCH net-next v4 5/7] net: stmmac: Signal to PHY/PCS drivers to keep RX clock on Romain Gantois 2024-02-21 13:04 ` Romain Gantois 2024-02-21 19:14 ` Jakub Kicinski 2024-02-21 19:14 ` Jakub Kicinski 2024-02-21 13:04 ` [PATCH net-next v4 6/7] net: phy: qcom: at803x: Avoid hibernating if MAC requires RX clock Romain Gantois 2024-02-21 13:04 ` Romain Gantois 2024-02-21 13:04 ` Romain Gantois [this message] 2024-02-21 13:04 ` [PATCH net-next v4 7/7] net: pcs: rzn1-miic: Init RX clock early if MAC requires it Romain Gantois
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20240221-rxc_bugfix-v4-7-4883ee1cc7b1@bootlin.com \ --to=romain.gantois@bootlin.com \ --cc=alexandre.torgue@foss.st.com \ --cc=andrew@lunn.ch \ --cc=clement.leger@bootlin.com \ --cc=davem@davemloft.net \ --cc=edumazet@google.com \ --cc=hkallweit1@gmail.com \ --cc=joabreu@synopsys.com \ --cc=kuba@kernel.org \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-renesas-soc@vger.kernel.org \ --cc=linux-stm32@st-md-mailman.stormreply.com \ --cc=linux@armlinux.org.uk \ --cc=maxime.chevallier@bootlin.com \ --cc=mcoquelin.stm32@gmail.com \ --cc=miquel.raynal@bootlin.com \ --cc=netdev@vger.kernel.org \ --cc=pabeni@redhat.com \ --cc=thomas.petazzoni@bootlin.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.