163ffb68c37271680a49f9c81e81b82a98fff7d4
[openwrt/staging/neocturne.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 --- a/drivers/net/mtk_eth.c
22 +++ b/drivers/net/mtk_eth.c
23 @@ -159,9 +159,10 @@ struct mtk_eth_priv {
24
25 void __iomem *fe_base;
26 void __iomem *gmac_base;
27 - void __iomem *ethsys_base;
28 void __iomem *sgmii_base;
29
30 + struct regmap *ethsys_regmap;
31 +
32 struct mii_dev *mdio_bus;
33 int (*mii_read)(struct mtk_eth_priv *priv, u8 phy, u8 reg);
34 int (*mii_write)(struct mtk_eth_priv *priv, u8 phy, u8 reg, u16 val);
35 @@ -233,7 +234,12 @@ static void mtk_gmac_rmw(struct mtk_eth_
36 static void mtk_ethsys_rmw(struct mtk_eth_priv *priv, u32 reg, u32 clr,
37 u32 set)
38 {
39 - clrsetbits_le32(priv->ethsys_base + reg, clr, set);
40 + uint val;
41 +
42 + regmap_read(priv->ethsys_regmap, reg, &val);
43 + val &= ~clr;
44 + val |= set;
45 + regmap_write(priv->ethsys_regmap, reg, val);
46 }
47
48 /* Direct MDIO clause 22/45 access via SoC */
49 @@ -1427,15 +1433,9 @@ static int mtk_eth_of_to_plat(struct ude
50 if (ret)
51 return ret;
52
53 - regmap = syscon_node_to_regmap(args.node);
54 - if (IS_ERR(regmap))
55 - return PTR_ERR(regmap);
56 -
57 - priv->ethsys_base = regmap_get_range(regmap, 0);
58 - if (!priv->ethsys_base) {
59 - dev_err(dev, "Unable to find ethsys\n");
60 - return -ENODEV;
61 - }
62 + priv->ethsys_regmap = syscon_node_to_regmap(args.node);
63 + if (IS_ERR(priv->ethsys_regmap))
64 + return PTR_ERR(priv->ethsys_regmap);
65
66 /* Reset controllers */
67 ret = reset_get_by_name(dev, "fe", &priv->rst_fe);