u-boot.lists.denx.de archive mirror
 help / color / mirror / Atom feed
From: Weijie Gao <weijie.gao@mediatek.com>
To: <u-boot@lists.denx.de>
Cc: GSS_MTK_Uboot_upstream <GSS_MTK_Uboot_upstream@mediatek.com>,
	Joe Hershberger <joe.hershberger@ni.com>,
	Ramon Fried <rfried.dev@gmail.com>,
	Weijie Gao <weijie.gao@mediatek.com>
Subject: [PATCH v6 18/25] net: mediatek: use regmap api to modify ethsys registers
Date: Fri, 20 May 2022 11:23:37 +0800	[thread overview]
Message-ID: <854fe6eb802351ab40fe31decde2d3ebfd0df2b8.1653015383.git.weijie.gao@mediatek.com> (raw)
In-Reply-To: <cover.1653015383.git.weijie.gao@mediatek.com>

The address returned by regmap_get_range() is not remapped. Directly r/w
to this address is ok for ARM platforms since it's idential to the virtual
address.

But for MIPS platform only virtual address should be used for access.
To solve this issue, the regmap api regmap_read/regmap_write should be used
since they will remap address before accessing.

Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
---
v6 changes: none
v5 changes: none
v4 changes: new
---
 drivers/net/mtk_eth.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/net/mtk_eth.c b/drivers/net/mtk_eth.c
index caa83b7cec..ac1e8abd71 100644
--- a/drivers/net/mtk_eth.c
+++ b/drivers/net/mtk_eth.c
@@ -159,9 +159,10 @@ struct mtk_eth_priv {
 
 	void __iomem *fe_base;
 	void __iomem *gmac_base;
-	void __iomem *ethsys_base;
 	void __iomem *sgmii_base;
 
+	struct regmap *ethsys_regmap;
+
 	struct mii_dev *mdio_bus;
 	int (*mii_read)(struct mtk_eth_priv *priv, u8 phy, u8 reg);
 	int (*mii_write)(struct mtk_eth_priv *priv, u8 phy, u8 reg, u16 val);
@@ -233,7 +234,12 @@ static void mtk_gmac_rmw(struct mtk_eth_priv *priv, u32 reg, u32 clr, u32 set)
 static void mtk_ethsys_rmw(struct mtk_eth_priv *priv, u32 reg, u32 clr,
 			   u32 set)
 {
-	clrsetbits_le32(priv->ethsys_base + reg, clr, set);
+	uint val;
+
+	regmap_read(priv->ethsys_regmap, reg, &val);
+	val &= ~clr;
+	val |= set;
+	regmap_write(priv->ethsys_regmap, reg, val);
 }
 
 /* Direct MDIO clause 22/45 access via SoC */
@@ -1427,15 +1433,9 @@ static int mtk_eth_of_to_plat(struct udevice *dev)
 	if (ret)
 		return ret;
 
-	regmap = syscon_node_to_regmap(args.node);
-	if (IS_ERR(regmap))
-		return PTR_ERR(regmap);
-
-	priv->ethsys_base = regmap_get_range(regmap, 0);
-	if (!priv->ethsys_base) {
-		dev_err(dev, "Unable to find ethsys\n");
-		return -ENODEV;
-	}
+	priv->ethsys_regmap = syscon_node_to_regmap(args.node);
+	if (IS_ERR(priv->ethsys_regmap))
+		return PTR_ERR(priv->ethsys_regmap);
 
 	/* Reset controllers */
 	ret = reset_get_by_name(dev, "fe", &priv->rst_fe);
-- 
2.17.1


  parent reply	other threads:[~2022-05-20  3:25 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-20  3:21 [PATCH v6 00/25] Add support for MediaTek MT7621 SoC - v6 Weijie Gao
2022-05-20  3:21 ` [PATCH v6 01/25] mips: add asm/mipsmtregs.h for MIPS multi-threading Weijie Gao
2022-05-20  3:21 ` [PATCH v6 02/25] mips: add more definitions for asm/cm.h Weijie Gao
2022-05-20  3:21 ` [PATCH v6 03/25] mips: add __image_copy_len for SPL linker script Weijie Gao
2022-05-20  3:21 ` [PATCH v6 04/25] mips: add support for noncached_alloc() Weijie Gao
2022-05-20  3:22 ` [PATCH v6 05/25] mips: mtmips: add support for MediaTek MT7621 SoC Weijie Gao
2022-05-20  3:22 ` [PATCH v6 06/25] mips: mtmips: add two reference boards for mt7621 Weijie Gao
2022-05-20  3:22 ` [PATCH v6 07/25] doc: mediatek: add documentation for mt7621 reference boards Weijie Gao
2022-05-20  3:22 ` [PATCH v6 08/25] clk: mtmips: add clock driver for MediaTek MT7621 SoC Weijie Gao
2022-05-20  3:22 ` [PATCH v6 09/25] reset: mtmips: add reset controller support " Weijie Gao
2022-05-20  3:22 ` [PATCH v6 10/25] pinctrl: mtmips: add " Weijie Gao
2022-05-20  3:22 ` [PATCH v6 11/25] usb: xhci-mtk: " Weijie Gao
2022-05-20  3:23 ` [PATCH v6 12/25] phy: mtk-tphy: " Weijie Gao
2022-05-20  3:23 ` [PATCH v6 13/25] spi: " Weijie Gao
2022-05-20  3:23 ` [PATCH v6 14/25] gpio: " Weijie Gao
2022-05-20  3:23 ` [PATCH v6 15/25] watchdog: " Weijie Gao
2022-05-20  3:23 ` [PATCH v6 16/25] mmc: mediatek: " Weijie Gao
2022-05-20  3:23 ` [PATCH v6 17/25] net: mediatek: remap iobase address Weijie Gao
2022-05-20  3:23 ` Weijie Gao [this message]
2022-05-20  3:23 ` [PATCH v6 19/25] net: mediatek: add support for MediaTek MT7621 SoC Weijie Gao
2022-05-20  3:23 ` [PATCH v6 20/25] nand: raw: " Weijie Gao
2022-05-20  3:23 ` [PATCH v6 21/25] spl: allow using nand base without standard nand driver Weijie Gao
2022-05-20  3:23 ` [PATCH v6 22/25] spl: spl_legacy: fix the use of SPL_COPY_PAYLOAD_ONLY Weijie Gao
2022-05-20  3:24 ` [PATCH v6 23/25] spl: nand: support loading legacy image with payload compressed Weijie Gao
2022-05-20  3:24 ` [PATCH v6 24/25] tools: mtk_image: add support for MT7621 NAND images Weijie Gao
2022-05-20  3:24 ` [PATCH v6 25/25] MAINTAINERS: update maintainer for MediaTek MIPS platform Weijie Gao
2022-07-06 22:11 ` [PATCH v6 00/25] Add support for MediaTek MT7621 SoC - v6 Daniel Schwierzeck
2022-07-07  0:47   ` 回复: " Weijie Gao (高惟杰)
2022-07-07  9:24     ` Martin Bonner
2022-07-08  6:54       ` Weijie Gao
2022-07-08 13:26 ` Daniel Schwierzeck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=854fe6eb802351ab40fe31decde2d3ebfd0df2b8.1653015383.git.weijie.gao@mediatek.com \
    --to=weijie.gao@mediatek.com \
    --cc=GSS_MTK_Uboot_upstream@mediatek.com \
    --cc=joe.hershberger@ni.com \
    --cc=rfried.dev@gmail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).