ab5c2a712ef65248867cb540f9031f3e5b13408c
[openwrt/staging/wigyori.git] /
1 From 955cc76d8074df943d59d559895007f91de8eed5 Mon Sep 17 00:00:00 2001
2 From: Weijie Gao <weijie.gao@mediatek.com>
3 Date: Fri, 20 May 2022 11:23:37 +0800
4 Subject: [PATCH 18/25] net: mediatek: use regmap api to modify ethsys
5 registers
6
7 The address returned by regmap_get_range() is not remapped. Directly r/w
8 to this address is ok for ARM platforms since it's idential to the virtual
9 address.
10
11 But for MIPS platform only virtual address should be used for access.
12 To solve this issue, the regmap api regmap_read/regmap_write should be used
13 since they will remap address before accessing.
14
15 Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
16 Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
17 ---
18 drivers/net/mtk_eth.c | 22 +++++++++++-----------
19 1 file changed, 11 insertions(+), 11 deletions(-)
20
21 diff --git a/drivers/net/mtk_eth.c b/drivers/net/mtk_eth.c
22 index caa83b7cec..ac1e8abd71 100644
23 --- a/drivers/net/mtk_eth.c
24 +++ b/drivers/net/mtk_eth.c
25 @@ -159,9 +159,10 @@ struct mtk_eth_priv {
26
27 void __iomem *fe_base;
28 void __iomem *gmac_base;
29 - void __iomem *ethsys_base;
30 void __iomem *sgmii_base;
31
32 + struct regmap *ethsys_regmap;
33 +
34 struct mii_dev *mdio_bus;
35 int (*mii_read)(struct mtk_eth_priv *priv, u8 phy, u8 reg);
36 int (*mii_write)(struct mtk_eth_priv *priv, u8 phy, u8 reg, u16 val);
37 @@ -233,7 +234,12 @@ static void mtk_gmac_rmw(struct mtk_eth_priv *priv, u32 reg, u32 clr, u32 set)
38 static void mtk_ethsys_rmw(struct mtk_eth_priv *priv, u32 reg, u32 clr,
39 u32 set)
40 {
41 - clrsetbits_le32(priv->ethsys_base + reg, clr, set);
42 + uint val;
43 +
44 + regmap_read(priv->ethsys_regmap, reg, &val);
45 + val &= ~clr;
46 + val |= set;
47 + regmap_write(priv->ethsys_regmap, reg, val);
48 }
49
50 /* Direct MDIO clause 22/45 access via SoC */
51 @@ -1427,15 +1433,9 @@ static int mtk_eth_of_to_plat(struct udevice *dev)
52 if (ret)
53 return ret;
54
55 - regmap = syscon_node_to_regmap(args.node);
56 - if (IS_ERR(regmap))
57 - return PTR_ERR(regmap);
58 -
59 - priv->ethsys_base = regmap_get_range(regmap, 0);
60 - if (!priv->ethsys_base) {
61 - dev_err(dev, "Unable to find ethsys\n");
62 - return -ENODEV;
63 - }
64 + priv->ethsys_regmap = syscon_node_to_regmap(args.node);
65 + if (IS_ERR(priv->ethsys_regmap))
66 + return PTR_ERR(priv->ethsys_regmap);
67
68 /* Reset controllers */
69 ret = reset_get_by_name(dev, "fe", &priv->rst_fe);
70 --
71 2.36.1
72