mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-30 18:47:06 +00:00
fb2c6e9d4d
Removed because they are upstream: generic/backport-5.15/704-15-v5.19-net-mtk_eth_soc-move-MAC_MCR-setting-to-mac_finish.patch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=linux-5.15.y&id=c5c0760adc260d55265c086b9efb350ea6dda38b generic/pending-5.15/735-net-mediatek-mtk_eth_soc-release-MAC_MCR_FORCE_LINK-.patch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=linux-5.15.y&id=448cc8b5f743985f6d1d98aa4efb386fef4c3bf2 generic/pending-5.15/736-net-ethernet-mtk_eth_soc-fix-PPE-hanging-issue.patch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=linux-5.15.y&id=9fcadd125044007351905d40c405fadc2d3bb6d6 Add new configuration symbols for tegra target. Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
77 lines
2.5 KiB
Diff
77 lines
2.5 KiB
Diff
From c0a440031d4314d1023c1b87f43a4233634eebdb Mon Sep 17 00:00:00 2001
|
|
From: Daniel Golle <daniel@makrotopia.org>
|
|
Date: Sun, 19 Mar 2023 12:57:15 +0000
|
|
Subject: [PATCH] net: ethernet: mtk_eth_soc: set MDIO bus clock frequency
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
Set MDIO bus clock frequency and allow setting a custom maximum
|
|
frequency from device tree.
|
|
|
|
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
|
|
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
|
|
Tested-by: Bjørn Mork <bjorn@mork.no>
|
|
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
|
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|
---
|
|
drivers/net/ethernet/mediatek/mtk_eth_soc.c | 21 +++++++++++++++++++++
|
|
drivers/net/ethernet/mediatek/mtk_eth_soc.h | 7 +++++++
|
|
2 files changed, 28 insertions(+)
|
|
|
|
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
|
|
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
|
|
@@ -701,8 +701,10 @@ static const struct phylink_mac_ops mtk_
|
|
|
|
static int mtk_mdio_init(struct mtk_eth *eth)
|
|
{
|
|
+ unsigned int max_clk = 2500000, divider;
|
|
struct device_node *mii_np;
|
|
int ret;
|
|
+ u32 val;
|
|
|
|
mii_np = of_get_child_by_name(eth->dev->of_node, "mdio-bus");
|
|
if (!mii_np) {
|
|
@@ -728,6 +730,25 @@ static int mtk_mdio_init(struct mtk_eth
|
|
eth->mii_bus->parent = eth->dev;
|
|
|
|
snprintf(eth->mii_bus->id, MII_BUS_ID_SIZE, "%pOFn", mii_np);
|
|
+
|
|
+ if (!of_property_read_u32(mii_np, "clock-frequency", &val)) {
|
|
+ if (val > MDC_MAX_FREQ || val < MDC_MAX_FREQ / MDC_MAX_DIVIDER) {
|
|
+ dev_err(eth->dev, "MDIO clock frequency out of range");
|
|
+ ret = -EINVAL;
|
|
+ goto err_put_node;
|
|
+ }
|
|
+ max_clk = val;
|
|
+ }
|
|
+ divider = min_t(unsigned int, DIV_ROUND_UP(MDC_MAX_FREQ, max_clk), 63);
|
|
+
|
|
+ /* Configure MDC Divider */
|
|
+ val = mtk_r32(eth, MTK_PPSC);
|
|
+ val &= ~PPSC_MDC_CFG;
|
|
+ val |= FIELD_PREP(PPSC_MDC_CFG, divider) | PPSC_MDC_TURBO;
|
|
+ mtk_w32(eth, val, MTK_PPSC);
|
|
+
|
|
+ dev_dbg(eth->dev, "MDC is running on %d Hz\n", MDC_MAX_FREQ / divider);
|
|
+
|
|
ret = of_mdiobus_register(eth->mii_bus, mii_np);
|
|
|
|
err_put_node:
|
|
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h
|
|
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
|
|
@@ -363,6 +363,13 @@
|
|
#define RX_DMA_VTAG_V2 BIT(0)
|
|
#define RX_DMA_L4_VALID_V2 BIT(2)
|
|
|
|
+/* PHY Polling and SMI Master Control registers */
|
|
+#define MTK_PPSC 0x10000
|
|
+#define PPSC_MDC_CFG GENMASK(29, 24)
|
|
+#define PPSC_MDC_TURBO BIT(20)
|
|
+#define MDC_MAX_FREQ 25000000
|
|
+#define MDC_MAX_DIVIDER 63
|
|
+
|
|
/* PHY Indirect Access Control registers */
|
|
#define MTK_PHY_IAC 0x10004
|
|
#define PHY_IAC_ACCESS BIT(31)
|