linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 1/6] net: stmmac: add platform library
@ 2023-09-11 15:28 Russell King (Oracle)
  2023-09-12  7:59 ` Jose Abreu
  0 siblings, 1 reply; 15+ 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

Add a platform library of helper functions for common traits in the
platform drivers. Currently, this is setting the tx clock.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 drivers/net/ethernet/stmicro/stmmac/Makefile  |  2 +-
 .../ethernet/stmicro/stmmac/stmmac_plat_lib.c | 29 +++++++++++++++++++
 .../ethernet/stmicro/stmmac/stmmac_plat_lib.h |  8 +++++
 3 files changed, 38 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/ethernet/stmicro/stmmac/stmmac_plat_lib.c
 create mode 100644 drivers/net/ethernet/stmicro/stmmac/stmmac_plat_lib.h

diff --git a/drivers/net/ethernet/stmicro/stmmac/Makefile b/drivers/net/ethernet/stmicro/stmmac/Makefile
index 5b57aee19267..ba2cbfa0c9d1 100644
--- a/drivers/net/ethernet/stmicro/stmmac/Makefile
+++ b/drivers/net/ethernet/stmicro/stmmac/Makefile
@@ -6,7 +6,7 @@ stmmac-objs:= stmmac_main.o stmmac_ethtool.o stmmac_mdio.o ring_mode.o	\
 	      mmc_core.o stmmac_hwtstamp.o stmmac_ptp.o dwmac4_descs.o	\
 	      dwmac4_dma.o dwmac4_lib.o dwmac4_core.o dwmac5.o hwif.o \
 	      stmmac_tc.o dwxgmac2_core.o dwxgmac2_dma.o dwxgmac2_descs.o \
-	      stmmac_xdp.o \
+	      stmmac_xdp.o stmmac_plat_lib.o \
 	      $(stmmac-y)
 
 stmmac-$(CONFIG_STMMAC_SELFTESTS) += stmmac_selftests.o
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_plat_lib.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_plat_lib.c
new file mode 100644
index 000000000000..abb9f512bb0e
--- /dev/null
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_plat_lib.c
@@ -0,0 +1,29 @@
+#include <linux/stmmac.h>
+#include <linux/clk.h>
+
+#include "stmmac_plat_lib.h"
+
+int dwmac_set_tx_clk_gmii(struct clk *tx_clk, int speed)
+{
+	unsigned long rate;
+
+	switch (speed) {
+	case SPEED_1000:
+		rate = 125000000;
+		break;
+
+	case SPEED_100:
+		rate = 25000000;
+		break;
+
+	case SPEED_10:
+		rate = 2500000;
+		break;
+
+	default:
+		return -ENOTSUPP;
+	}
+
+	return clk_set_rate(tx_clk, rate);
+}
+EXPORT_SYMBOL_GPL(dwmac_set_tx_clk_gmii);
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_plat_lib.h b/drivers/net/ethernet/stmicro/stmmac/stmmac_plat_lib.h
new file mode 100644
index 000000000000..926fdce379b3
--- /dev/null
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_plat_lib.h
@@ -0,0 +1,8 @@
+#ifndef STMMAC_PLAT_LIB_H
+#define STMMAC_PLAT_LIB_H
+
+struct clk;
+
+int dwmac_set_tx_clk_gmii(struct clk *tx_clk, int speed);
+
+#endif
-- 
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] 15+ 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 1/6] net: stmmac: add platform library Russell King (Oracle)
  0 siblings, 1 reply; 15+ 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] 15+ messages in thread

end of thread, other threads:[~2023-09-14 12:02 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-11 15:28 [PATCH net-next 1/6] net: stmmac: add platform library Russell King (Oracle)
2023-09-12  7:59 ` Jose Abreu
2023-09-12  9:32   ` Serge Semin
2023-09-12 17:08     ` Russell King (Oracle)
2023-09-13  0:56       ` Serge Semin
2023-09-13 14:14         ` Russell King (Oracle)
2023-09-13 14:21           ` Russell King (Oracle)
2023-09-14 10:42             ` Serge Semin
2023-09-14 10:48               ` Russell King (Oracle)
2023-09-14 12:01                 ` Serge Semin
  -- 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 1/6] net: stmmac: add platform library Russell King (Oracle)
2023-09-12 10:18   ` Paolo Abeni
2023-09-12 14:52   ` Simon Horman
2023-09-12 22:20     ` Russell King (Oracle)
2023-09-14 11:24       ` Simon Horman

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).