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 --- a/drivers/net/mtk_eth.c
22 +++ b/drivers/net/mtk_eth.c
23 @@ -159,9 +159,10 @@ struct mtk_eth_priv {
25 void __iomem *fe_base;
26 void __iomem *gmac_base;
27 - void __iomem *ethsys_base;
28 void __iomem *sgmii_base;
30 + struct regmap *ethsys_regmap;
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,
39 - clrsetbits_le32(priv->ethsys_base + reg, clr, set);
42 + regmap_read(priv->ethsys_regmap, reg, &val);
45 + regmap_write(priv->ethsys_regmap, reg, val);
48 /* Direct MDIO clause 22/45 access via SoC */
49 @@ -1427,15 +1433,9 @@ static int mtk_eth_of_to_plat(struct ude
53 - regmap = syscon_node_to_regmap(args.node);
55 - return PTR_ERR(regmap);
57 - priv->ethsys_base = regmap_get_range(regmap, 0);
58 - if (!priv->ethsys_base) {
59 - dev_err(dev, "Unable to find ethsys\n");
62 + priv->ethsys_regmap = syscon_node_to_regmap(args.node);
63 + if (IS_ERR(priv->ethsys_regmap))
64 + return PTR_ERR(priv->ethsys_regmap);
66 /* Reset controllers */
67 ret = reset_get_by_name(dev, "fe", &priv->rst_fe);