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
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
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.
15 Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
16 Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
18 drivers/net/mtk_eth.c | 22 +++++++++++-----------
19 1 file changed, 11 insertions(+), 11 deletions(-)
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 {
27 void __iomem *fe_base;
28 void __iomem *gmac_base;
29 - void __iomem *ethsys_base;
30 void __iomem *sgmii_base;
32 + struct regmap *ethsys_regmap;
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,
41 - clrsetbits_le32(priv->ethsys_base + reg, clr, set);
44 + regmap_read(priv->ethsys_regmap, reg, &val);
47 + regmap_write(priv->ethsys_regmap, reg, val);
50 /* Direct MDIO clause 22/45 access via SoC */
51 @@ -1427,15 +1433,9 @@ static int mtk_eth_of_to_plat(struct udevice *dev)
55 - regmap = syscon_node_to_regmap(args.node);
57 - return PTR_ERR(regmap);
59 - priv->ethsys_base = regmap_get_range(regmap, 0);
60 - if (!priv->ethsys_base) {
61 - dev_err(dev, "Unable to find ethsys\n");
64 + priv->ethsys_regmap = syscon_node_to_regmap(args.node);
65 + if (IS_ERR(priv->ethsys_regmap))
66 + return PTR_ERR(priv->ethsys_regmap);
68 /* Reset controllers */
69 ret = reset_get_by_name(dev, "fe", &priv->rst_fe);