* [PATCH net-next 6/6] net: stmmac: qos-eth: use dwmac_set_tx_clk_gmii()
@ 2023-09-11 15:29 Russell King (Oracle)
0 siblings, 0 replies; 3+ messages in thread
From: Russell King (Oracle) @ 2023-09-11 15:29 UTC (permalink / raw)
To: Alexandre Torgue, Jose Abreu
Cc: Alexei Starovoitov, bpf, Daniel Borkmann, David S. Miller,
Emil Renner Berthing, Eric Dumazet, Fabio Estevam, Jakub Kicinski,
Jesper Dangaard Brouer, John Fastabend, linux-arm-kernel,
linux-stm32, Maxime Coquelin, netdev, NXP Linux Team, Paolo Abeni,
Pengutronix Kernel Team, Samin Guo, Sascha Hauer, Shawn Guo
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
.../stmicro/stmmac/dwmac-dwc-qos-eth.c | 37 ++++++-------------
1 file changed, 11 insertions(+), 26 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
index 61ebf36da13d..a8fae37b9858 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
@@ -22,6 +22,7 @@
#include <linux/stmmac.h>
#include "stmmac_platform.h"
+#include "stmmac_plat_lib.h"
#include "dwmac4.h"
struct tegra_eqos {
@@ -181,32 +182,10 @@ static void dwc_qos_remove(struct platform_device *pdev)
static void tegra_eqos_fix_speed(void *priv, unsigned int speed, unsigned int mode)
{
struct tegra_eqos *eqos = priv;
- unsigned long rate = 125000000;
- bool needs_calibration = false;
u32 value;
int err;
- switch (speed) {
- case SPEED_1000:
- needs_calibration = true;
- rate = 125000000;
- break;
-
- case SPEED_100:
- needs_calibration = true;
- rate = 25000000;
- break;
-
- case SPEED_10:
- rate = 2500000;
- break;
-
- default:
- dev_err(eqos->dev, "invalid speed %u\n", speed);
- break;
- }
-
- if (needs_calibration) {
+ if (speed == SPEED_1000 || speed == SPEED_100) {
/* calibrate */
value = readl(eqos->regs + SDMEMCOMPPADCTRL);
value |= SDMEMCOMPPADCTRL_PAD_E_INPUT_OR_E_PWRD;
@@ -246,9 +225,15 @@ static void tegra_eqos_fix_speed(void *priv, unsigned int speed, unsigned int mo
writel(value, eqos->regs + AUTO_CAL_CONFIG);
}
- err = clk_set_rate(eqos->clk_tx, rate);
- if (err < 0)
- dev_err(eqos->dev, "failed to set TX rate: %d\n", err);
+ err = dwmac_set_tx_clk_gmii(eqos->clk_tx, speed);
+ if (err == -ENOTSUPP) {
+ dev_err(eqos->dev, "invalid speed %dMbps\n", speed);
+ err = dwmac_set_tx_clk_gmii(eqos->clk_tx, SPEED_1000);
+ } else if (err) {
+ dev_err(eqos->dev,
+ "failed to set tx rate for speed %dMbps: %pe\n",
+ speed, ERR_PTR(err));
+ }
}
static int tegra_eqos_init(struct platform_device *pdev, void *priv)
--
2.30.2
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 3+ messages in thread* [PATCH net-next 0/6] net: stmmac: add and use library for setting clock
@ 2023-09-11 15:28 Russell King (Oracle)
2023-09-11 15:29 ` [PATCH net-next 6/6] net: stmmac: qos-eth: use dwmac_set_tx_clk_gmii() Russell King (Oracle)
0 siblings, 1 reply; 3+ messages in thread
From: Russell King (Oracle) @ 2023-09-11 15:28 UTC (permalink / raw)
To: Alexandre Torgue, Jose Abreu
Cc: Alexei Starovoitov, bpf, Daniel Borkmann, David S. Miller,
Emil Renner Berthing, Eric Dumazet, Fabio Estevam, Jakub Kicinski,
Jesper Dangaard Brouer, John Fastabend, linux-arm-kernel,
linux-stm32, Maxime Coquelin, netdev, NXP Linux Team, Paolo Abeni,
Pengutronix Kernel Team, Samin Guo, Sascha Hauer, Shawn Guo
Hi,
There is a common theme throughout several "bsps" in the stmmac driver
which all code up the same thing: for 10M, 100M and 1G, select the
appropriate 2.5MHz, 25MHz, or 125MHz clock.
Rather than having every BSP implement the same thing but slightly
differently, let's provide a single implementation which is passed
the struct clk and the speed, and have that do the speed to clock
rate decode.
Note: only build tested.
drivers/net/ethernet/stmicro/stmmac/Makefile | 2 +-
.../ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c | 37 ++++---------
drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c | 27 +++-------
.../net/ethernet/stmicro/stmmac/dwmac-intel-plat.c | 35 ++++---------
drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c | 61 ++++++----------------
.../net/ethernet/stmicro/stmmac/dwmac-starfive.c | 29 +++-------
.../net/ethernet/stmicro/stmmac/stmmac_plat_lib.c | 29 ++++++++++
.../net/ethernet/stmicro/stmmac/stmmac_plat_lib.h | 8 +++
8 files changed, 91 insertions(+), 137 deletions(-)
create mode 100644 drivers/net/ethernet/stmicro/stmmac/stmmac_plat_lib.c
create mode 100644 drivers/net/ethernet/stmicro/stmmac/stmmac_plat_lib.h
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH net-next 6/6] net: stmmac: qos-eth: use dwmac_set_tx_clk_gmii()
2023-09-11 15:28 [PATCH net-next 0/6] net: stmmac: add and use library for setting clock Russell King (Oracle)
@ 2023-09-11 15:29 ` Russell King (Oracle)
2023-09-14 12:13 ` Serge Semin
0 siblings, 1 reply; 3+ messages in thread
From: Russell King (Oracle) @ 2023-09-11 15:29 UTC (permalink / raw)
To: Alexandre Torgue, Jose Abreu
Cc: Alexei Starovoitov, bpf, Daniel Borkmann, David S. Miller,
Emil Renner Berthing, Eric Dumazet, Fabio Estevam, Jakub Kicinski,
Jesper Dangaard Brouer, John Fastabend, linux-arm-kernel,
linux-stm32, Maxime Coquelin, netdev, NXP Linux Team, Paolo Abeni,
Pengutronix Kernel Team, Samin Guo, Sascha Hauer, Shawn Guo
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
.../stmicro/stmmac/dwmac-dwc-qos-eth.c | 37 ++++++-------------
1 file changed, 11 insertions(+), 26 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
index 61ebf36da13d..a8fae37b9858 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
@@ -22,6 +22,7 @@
#include <linux/stmmac.h>
#include "stmmac_platform.h"
+#include "stmmac_plat_lib.h"
#include "dwmac4.h"
struct tegra_eqos {
@@ -181,32 +182,10 @@ static void dwc_qos_remove(struct platform_device *pdev)
static void tegra_eqos_fix_speed(void *priv, unsigned int speed, unsigned int mode)
{
struct tegra_eqos *eqos = priv;
- unsigned long rate = 125000000;
- bool needs_calibration = false;
u32 value;
int err;
- switch (speed) {
- case SPEED_1000:
- needs_calibration = true;
- rate = 125000000;
- break;
-
- case SPEED_100:
- needs_calibration = true;
- rate = 25000000;
- break;
-
- case SPEED_10:
- rate = 2500000;
- break;
-
- default:
- dev_err(eqos->dev, "invalid speed %u\n", speed);
- break;
- }
-
- if (needs_calibration) {
+ if (speed == SPEED_1000 || speed == SPEED_100) {
/* calibrate */
value = readl(eqos->regs + SDMEMCOMPPADCTRL);
value |= SDMEMCOMPPADCTRL_PAD_E_INPUT_OR_E_PWRD;
@@ -246,9 +225,15 @@ static void tegra_eqos_fix_speed(void *priv, unsigned int speed, unsigned int mo
writel(value, eqos->regs + AUTO_CAL_CONFIG);
}
- err = clk_set_rate(eqos->clk_tx, rate);
- if (err < 0)
- dev_err(eqos->dev, "failed to set TX rate: %d\n", err);
+ err = dwmac_set_tx_clk_gmii(eqos->clk_tx, speed);
+ if (err == -ENOTSUPP) {
+ dev_err(eqos->dev, "invalid speed %dMbps\n", speed);
+ err = dwmac_set_tx_clk_gmii(eqos->clk_tx, SPEED_1000);
+ } else if (err) {
+ dev_err(eqos->dev,
+ "failed to set tx rate for speed %dMbps: %pe\n",
+ speed, ERR_PTR(err));
+ }
}
static int tegra_eqos_init(struct platform_device *pdev, void *priv)
--
2.30.2
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH net-next 6/6] net: stmmac: qos-eth: use dwmac_set_tx_clk_gmii()
2023-09-11 15:29 ` [PATCH net-next 6/6] net: stmmac: qos-eth: use dwmac_set_tx_clk_gmii() Russell King (Oracle)
@ 2023-09-14 12:13 ` Serge Semin
0 siblings, 0 replies; 3+ messages in thread
From: Serge Semin @ 2023-09-14 12:13 UTC (permalink / raw)
To: Russell King (Oracle)
Cc: Alexandre Torgue, Jose Abreu, Alexei Starovoitov, bpf,
Daniel Borkmann, David S. Miller, Emil Renner Berthing,
Eric Dumazet, Fabio Estevam, Jakub Kicinski,
Jesper Dangaard Brouer, John Fastabend, linux-arm-kernel,
linux-stm32, Maxime Coquelin, netdev, NXP Linux Team, Paolo Abeni,
Pengutronix Kernel Team, Samin Guo, Sascha Hauer, Shawn Guo
On Mon, Sep 11, 2023 at 04:29:36PM +0100, Russell King (Oracle) wrote:
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
> ---
> .../stmicro/stmmac/dwmac-dwc-qos-eth.c | 37 ++++++-------------
> 1 file changed, 11 insertions(+), 26 deletions(-)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
> index 61ebf36da13d..a8fae37b9858 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
> @@ -22,6 +22,7 @@
> #include <linux/stmmac.h>
>
> #include "stmmac_platform.h"
> +#include "stmmac_plat_lib.h"
> #include "dwmac4.h"
>
> struct tegra_eqos {
> @@ -181,32 +182,10 @@ static void dwc_qos_remove(struct platform_device *pdev)
> static void tegra_eqos_fix_speed(void *priv, unsigned int speed, unsigned int mode)
> {
> struct tegra_eqos *eqos = priv;
> - unsigned long rate = 125000000;
> - bool needs_calibration = false;
> u32 value;
> int err;
>
> - switch (speed) {
> - case SPEED_1000:
> - needs_calibration = true;
> - rate = 125000000;
> - break;
> -
> - case SPEED_100:
> - needs_calibration = true;
> - rate = 25000000;
> - break;
> -
> - case SPEED_10:
> - rate = 2500000;
> - break;
> -
> - default:
> - dev_err(eqos->dev, "invalid speed %u\n", speed);
> - break;
> - }
> -
> - if (needs_calibration) {
> + if (speed == SPEED_1000 || speed == SPEED_100) {
> /* calibrate */
> value = readl(eqos->regs + SDMEMCOMPPADCTRL);
> value |= SDMEMCOMPPADCTRL_PAD_E_INPUT_OR_E_PWRD;
> @@ -246,9 +225,15 @@ static void tegra_eqos_fix_speed(void *priv, unsigned int speed, unsigned int mo
> writel(value, eqos->regs + AUTO_CAL_CONFIG);
> }
>
> - err = clk_set_rate(eqos->clk_tx, rate);
> - if (err < 0)
> - dev_err(eqos->dev, "failed to set TX rate: %d\n", err);
> + err = dwmac_set_tx_clk_gmii(eqos->clk_tx, speed);
> + if (err == -ENOTSUPP) {
> + dev_err(eqos->dev, "invalid speed %dMbps\n", speed);
%u?
> + err = dwmac_set_tx_clk_gmii(eqos->clk_tx, SPEED_1000);
> + } else if (err) {
> + dev_err(eqos->dev,
> + "failed to set tx rate for speed %dMbps: %pe\n",
ditto
-Serge(y)
> + speed, ERR_PTR(err));
> + }
> }
>
> static int tegra_eqos_init(struct platform_device *pdev, void *priv)
> --
> 2.30.2
>
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-09-14 12:13 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-11 15:29 [PATCH net-next 6/6] net: stmmac: qos-eth: use dwmac_set_tx_clk_gmii() Russell King (Oracle)
-- strict thread matches above, loose matches on Subject: below --
2023-09-11 15:28 [PATCH net-next 0/6] net: stmmac: add and use library for setting clock Russell King (Oracle)
2023-09-11 15:29 ` [PATCH net-next 6/6] net: stmmac: qos-eth: use dwmac_set_tx_clk_gmii() Russell King (Oracle)
2023-09-14 12:13 ` Serge Semin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).