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 D12ABC43334 for ; Fri, 15 Jul 2022 05:21:40 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9582E84179; Fri, 15 Jul 2022 07:21:19 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=sholland.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=sholland.org header.i=@sholland.org header.b="BfL/OPUp"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="nQMT2ILO"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9CFDB84148; Fri, 15 Jul 2022 07:21:09 +0200 (CEST) Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id C9EAF84152 for ; Fri, 15 Jul 2022 07:21:03 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=sholland.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=samuel@sholland.org Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 193495C00B0; Fri, 15 Jul 2022 01:21:03 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Fri, 15 Jul 2022 01:21:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= cc:cc:content-transfer-encoding:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm1; t=1657862463; x=1657948863; bh=40 PPjucjrx2w6tSDvXa3O0XAglG30+b3dGC9HZM6AqE=; b=BfL/OPUpGOldifuo7v IVYJQ42TPDEl92X/pEGM5WBr8F3+Sc1csFMNEkNrt4CjbW94dEiEXKSYFHGnFCWC xa+xOGtRqjv53LGeiRwjhPhBmwI+K2T2fJc0BnXcrUKpsV1bC10+te6caEv4UanG LpUNfuBuCA8MwYeaPqvYJeprB2wEqHqCPAwu6FTPOoySPb0b7lAI0yfxeeC1rrID mWki51Iil8Yz3yKiON+bk2IPQ9thkJF0lcrABl4j3CbasK22X5/UGvciPqUucB3d F0zMnVdJo8veOXnmn7omsuYVDUVljD82gXpph2HYGX+bm9R3TI4nUoPuCid8edzG R80Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; t=1657862463; x=1657948863; bh=40PPjucjrx2w6 tSDvXa3O0XAglG30+b3dGC9HZM6AqE=; b=nQMT2ILOTuJusPO5urLZP6hkzHnke ARaAsTKOWteodHXiI1m0TtMDxP7dSIgYVP1BqCLlTxqc4yxjL3bUebEPUK4em9bQ lRrrVuvRCpCxxz40/waMMsjnyOAxSmEEzIJyVKsUGB+8AwaJ3YUgTl5Rfvgw4mML TbgIzLHlnR05qlOjzQgKQWfORJHmuMtY3qsfoniyqCr4A28IltdSwDVfyoA1aSLC 3rAZFuUmap7XanhjbzcGxNrTHzKxA2dxGOYtoJfGbxz4EVtZF/kYzkL/1Jf2vA0t ThVRXgOWIm+eTAOInKFTqlCSDxA/5Y8sZ9nRxk1lcOfDLxcsO6MQDrHVg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrudektddgledvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepufgrmhhu vghlucfjohhllhgrnhguuceoshgrmhhuvghlsehshhholhhlrghnugdrohhrgheqnecugg ftrfgrthhtvghrnhepudekteeuudehtdelteevgfduvddvjefhfedulefgudevgeeghefg udefiedtveetnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrh homhepshgrmhhuvghlsehshhholhhlrghnugdrohhrgh X-ME-Proxy: Feedback-ID: i0ad843c9:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 15 Jul 2022 01:21:02 -0400 (EDT) From: Samuel Holland To: u-boot@lists.denx.de, Jagan Teki , Andre Przywara Cc: Samuel Holland , Joe Hershberger , Ramon Fried Subject: [PATCH 3/3] net: sun8i-emac: Use common syscon setup for R40 Date: Fri, 15 Jul 2022 00:20:58 -0500 Message-Id: <20220715052058.28405-4-samuel@sholland.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220715052058.28405-1-samuel@sholland.org> References: <20220715052058.28405-1-samuel@sholland.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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.6 at phobos.denx.de X-Virus-Status: Clean While R40 puts the EMAC syscon register at a different address from other variants, the relevant portion of the register's layout is the same. Factor out the register offset so the same code can be shared by all variants. This matches what the Linux driver does. This change provides two benefits beyond the simplification: - R40 boards now respect the RX delays from the devicetree - This resolves a warning on architectures where readl/writel expect the address to have a pointer type, not phys_addr_t. Signed-off-by: Samuel Holland --- drivers/net/sun8i_emac.c | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/drivers/net/sun8i_emac.c b/drivers/net/sun8i_emac.c index 9cca8fa4e0a1..75ecb58e1e45 100644 --- a/drivers/net/sun8i_emac.c +++ b/drivers/net/sun8i_emac.c @@ -162,7 +162,7 @@ struct emac_eth_dev { enum emac_variant variant; void *mac_reg; - phys_addr_t sysctl_reg; + void *sysctl_reg; struct phy_device *phydev; struct mii_dev *bus; struct clk tx_clk; @@ -317,18 +317,7 @@ static int sun8i_emac_set_syscon(struct sun8i_eth_pdata *pdata, { u32 reg; - if (priv->variant == R40_GMAC) { - /* Select RGMII for R40 */ - reg = readl(priv->sysctl_reg + 0x164); - reg |= SC_ETCS_INT_GMII | - SC_EPIT | - (CONFIG_GMAC_TX_DELAY << SC_ETXDC_OFFSET); - - writel(reg, priv->sysctl_reg + 0x164); - return 0; - } - - reg = readl(priv->sysctl_reg + 0x30); + reg = readl(priv->sysctl_reg); reg = sun8i_emac_set_syscon_ephy(priv, reg); @@ -369,7 +358,7 @@ static int sun8i_emac_set_syscon(struct sun8i_eth_pdata *pdata, reg |= ((pdata->rx_delay_ps / 100) << SC_ERXDC_OFFSET) & SC_ERXDC_MASK; - writel(reg, priv->sysctl_reg + 0x30); + writel(reg, priv->sysctl_reg); return 0; } @@ -792,6 +781,7 @@ static int sun8i_emac_eth_of_to_plat(struct udevice *dev) struct sun8i_eth_pdata *sun8i_pdata = dev_get_plat(dev); struct eth_pdata *pdata = &sun8i_pdata->eth_pdata; struct emac_eth_dev *priv = dev_get_priv(dev); + phys_addr_t syscon_base; const fdt32_t *reg; int node = dev_of_offset(dev); int offset = 0; @@ -837,13 +827,18 @@ static int sun8i_emac_eth_of_to_plat(struct udevice *dev) __func__); return -EINVAL; } - priv->sysctl_reg = fdt_translate_address((void *)gd->fdt_blob, - offset, reg); - if (priv->sysctl_reg == FDT_ADDR_T_NONE) { + + syscon_base = fdt_translate_address((void *)gd->fdt_blob, offset, reg); + if (syscon_base == FDT_ADDR_T_NONE) { debug("%s: Cannot find syscon base address\n", __func__); return -EINVAL; } + if (priv->variant == R40_GMAC) + priv->sysctl_reg = (void *)syscon_base + 0x164; + else + priv->sysctl_reg = (void *)syscon_base + 0x30; + pdata->phy_interface = -1; priv->phyaddr = -1; priv->use_internal_phy = false; -- 2.35.1