From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4EDABC433EF for ; Mon, 16 May 2022 00:25:50 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9542384099; Mon, 16 May 2022 02:25:47 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="YyP+HycO"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 306318410D; Mon, 16 May 2022 02:25:46 +0200 (CEST) Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 2CD6484073 for ; Mon, 16 May 2022 02:25:43 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=rfried.dev@gmail.com Received: by mail-wm1-x336.google.com with SMTP id n6so101090wms.0 for ; Sun, 15 May 2022 17:25:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=8G74zV/AseVlMhbDtQUn5I5MSZ9oqI4xtfhgyypiweU=; b=YyP+HycOtC8lCVWN3nRrCJoF6HeR0PaWenrsmjm7c4S6n2sOvJpMKYrvJmjCGZGkeh gJ7mLUCtbTbgLngYcvKcBkoQZTN11FCmquMOoVTFX4/x8ew/0Uh3gMWtecudm7nmsxfo uSSDyX70vQEK775V5m5PAPqB4d+HYRFzYbK6nO0I4mAGzobn1StJ8KdR4mampqoLWNB2 D1hYmPWVxo5D6GQSF91hfCYmlNbU69zsQ2HuOqLYJ7V0tWb6ps/6iMkS7x/0uMTZviid a1lwJ19FB24GqPug8EYDvYR7FrtyDy6aniaNUIQS7Hs2CZhvaS+sqi4MDUtoHnA5a5J8 ktaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=8G74zV/AseVlMhbDtQUn5I5MSZ9oqI4xtfhgyypiweU=; b=ex3+dmv0Y8fCgkQMqNg4p7RjW2XPADgaB7Nf/y18s33Qdc4U/KlqljybHR3RIByJXL ml57XGhWVBRoKHg7P/k0424eFhTyNeNBxNgLpEXBRdu1puQinCIwIHiLUr0pRM5O3Rmu y+J68LUjC99mgip+DP6IPyeDx8nkyXpH5KdO1nF5Vx+de+cZu7ivWbpT7eOpYnkDLAjr moMjTwKL1tsQo2WqN2T6Yu2nFuBvbB2x6C7QH1wDKPFsZbARhuWRyEzDCmkybFjx3yA/ bWHmAf/ntHWW49UThJh/1445MwPg39riK6zRI/FIKFbs+TsPjhRzs89LdqWqmaBM23Yc uJRg== X-Gm-Message-State: AOAM532nhgrphIp8dT8OyUz4GZWdws4uCCOS1FJ1T82xQA78qpc/OGFu 6X/aBZuTd+P+ZvDCcQuLplPAR7BnynG33yyapDhe9zGyOBnnTw== X-Google-Smtp-Source: ABdhPJx7q0hucAXU9iTbAlUCEGrmCQ6H7oeXyO0UOHef3ZD3eGYdrNpirpKGXybb8AqbNL0vuNE1r6BEG3G1k7zu8xE= X-Received: by 2002:a05:600c:1e17:b0:394:547c:e5a6 with SMTP id ay23-20020a05600c1e1700b00394547ce5a6mr14420103wmb.203.1652660742793; Sun, 15 May 2022 17:25:42 -0700 (PDT) MIME-Version: 1.0 References: <7f0cb130883529441fd75bc8cb9303366d238dce.1652183768.git.weijie.gao@mediatek.com> In-Reply-To: <7f0cb130883529441fd75bc8cb9303366d238dce.1652183768.git.weijie.gao@mediatek.com> From: Ramon Fried Date: Mon, 16 May 2022 03:25:30 +0300 Message-ID: Subject: Re: [PATCH v4 18/25] net: mediatek: use regmap api to modify ethsys registers To: Weijie Gao Cc: U-Boot Mailing List , GSS_MTK_Uboot_upstream , Joe Hershberger Content-Type: text/plain; charset="UTF-8" X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean On Tue, May 10, 2022 at 3:20 PM Weijie Gao wrote: > > 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. > > Signed-off-by: Weijie Gao > --- > 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 > Reviewed-by: Ramon Fried