From patchwork Mon Sep 11 15:28:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13379423 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 15ACD1170E; Mon, 11 Sep 2023 15:28:46 +0000 (UTC) Received: from pandora.armlinux.org.uk (unknown [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75789E4; Mon, 11 Sep 2023 08:28:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:Reply-To:Content-ID :Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To: Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=P6DsgJ0EF8GDgyic7GQZdDjnAhVZ69mVqqsinIQxsnI=; b=xZu3Ajjq2TSvy0DyIJCfkWSo3k 7br7UoFE1XZmxm0LZPslxVl5WlKtO0zNzP8jZUZn4Jefzkq3tqRdEM3PpdZu1+SAuegInzBDn5/k3 7BUf2CFw9jyeSA8B88ekRLYE81o94jBtRcEkiM8rvUA5CwDrXBNS9vJ0QNwHFK6SqBM35GtTDPlW3 t1oiqyAHxta6r1R41wrx/OaqBetCbZJz3VVS1vQ4Z71jCVNokwNI2qQPImYz2+59N6Yla55ST+0zm yFhg6D8WE2nUMcNzufxbPZhl5dcwbfg3iMXn/DldsWreh2uFhJf1pte5RrR3lXzS2swfMsAT0kgac HHpFES6Q==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:57004 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1qfiq7-0008Bi-1y; Mon, 11 Sep 2023 16:28:39 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1qfiq8-007TOe-9F; Mon, 11 Sep 2023 16:28:40 +0100 From: "Russell King (Oracle)" To: Alexandre Torgue , Jose Abreu Cc: Alexei Starovoitov , bpf@vger.kernel.org, Daniel Borkmann , "David S. Miller" , Emil Renner Berthing , Eric Dumazet , Fabio Estevam , Jakub Kicinski , Jesper Dangaard Brouer , John Fastabend , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, Maxime Coquelin , netdev@vger.kernel.org, NXP Linux Team , Paolo Abeni , Pengutronix Kernel Team , Samin Guo , Sascha Hauer , Shawn Guo Subject: [PATCH net-next 1/6] net: stmmac: add platform library Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Mon, 11 Sep 2023 16:28:40 +0100 X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED,RDNS_NONE, SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org 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) --- 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 +#include + +#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