From patchwork Wed May 27 13:33:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Benedikt-Alexander_Mokro=C3=9F?= X-Patchwork-Id: 1298923 X-Patchwork-Delegate: jagannadh.teki@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=bamkrs.de Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=bamkrs.de header.i=@bamkrs.de header.a=rsa-sha256 header.s=strato-dkim-0002 header.b=oHD6y2Dg; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49XBcF2rz4z9sPF for ; Wed, 27 May 2020 23:33:32 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E349A81D75; Wed, 27 May 2020 15:33:24 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=bamkrs.de 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=bamkrs.de header.i=@bamkrs.de header.b="oHD6y2Dg"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 621DC81A26; Wed, 27 May 2020 15:33:20 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mo6-p00-ob.smtp.rzone.de (mo6-p00-ob.smtp.rzone.de [IPv6:2a01:238:20a:202:5300::4]) (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 5AFD781A26 for ; Wed, 27 May 2020 15:33:16 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=bamkrs.de Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=u-boot@bamkrs.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1590586396; s=strato-dkim-0002; d=bamkrs.de; h=Date:Message-ID:Subject:From:To:X-RZG-CLASS-ID:X-RZG-AUTH:From: Subject:Sender; bh=4/oxghdxnUSlWT/hBs4XiRee0/9Pz3S/08CJK/Yd/v0=; b=oHD6y2Dg16Ic8hy1wSagPSkOxuQaunFSsT4fuRO/0eKLLJ9Efp9n9wHaAKcW2X2Gr4 u8Bcwkot6P7KVHqr9hFvZw1rtIU2kx91HJVRknpG92fIlC4q3jPI3llESOelisKmvwMV scsdqZ6ZKrIv3Tdt5IVhOOB3RmAkvaCx5WdjCfwRUvP/5mlgbASJY6A7BAGP4I+BixDa lgxmwiQXx6Rx0qwTzRxeT0XledOPUbopxuuAGrN/Dmd/MLLmJ8oWLyiLev9griDr/xdh 9S3eCL+QA3mXuFIE8cirXjRCwRpPTIyydrF0xi4hlmXE4b3EUz/lqR1/lSv97X82GSfV /rFA== X-RZG-AUTH: ":L20Qdkipd/NtQfa67vW/eJfuQpomyW4cBm3G2ZWMm0e+aME9udSL7FwAirwWgNfi+hnaBWxN1T8uNipfmeVxz7XGl0KnFVfw1Q==" X-RZG-CLASS-ID: mo00 Received: from [IPv6:2a02:b98:0:20f:51aa:b659:9ee4:9410] by smtp.strato.de (RZmta 46.7.0 AUTH) with ESMTPSA id 208d27w4RDXGMhi (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate) for ; Wed, 27 May 2020 15:33:16 +0200 (CEST) To: u-boot@lists.denx.de From: =?utf-8?q?Benedikt-Alexander_Mokro=C3=9F?= Subject: [PATCH 1/2] sun8i-emac: sun8i-v3s compatibility for sun8i-emac Message-ID: <29e6d58a-613a-aeae-2d37-fa055b670ba2@bamkrs.de> Date: Wed, 27 May 2020 15:33:16 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 Content-Language: en-US X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 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.102.2 at phobos.denx.de X-Virus-Status: Clean This patch expands the sun8i-emac driver to support the V3s. For this the CLK and RST gates for EMAC and EPHY were added in clk_v3s.c. Signed-off-by: Benedikt-Alexander Mokroß --- drivers/clk/sunxi/clk_v3s.c | 10 ++++++++-- drivers/net/sun8i_emac.c | 19 +++++++++++++------ 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/drivers/clk/sunxi/clk_v3s.c b/drivers/clk/sunxi/clk_v3s.c index b79446cc4f..bf870f3ded 100644 --- a/drivers/clk/sunxi/clk_v3s.c +++ b/drivers/clk/sunxi/clk_v3s.c @@ -17,6 +17,7 @@ static struct ccu_clk_gate v3s_gates[] = { [CLK_BUS_MMC0] = GATE(0x060, BIT(8)), [CLK_BUS_MMC1] = GATE(0x060, BIT(9)), [CLK_BUS_MMC2] = GATE(0x060, BIT(10)), + [CLK_BUS_EMAC] = GATE(0x060, BIT(17)), [CLK_BUS_SPI0] = GATE(0x060, BIT(20)), [CLK_BUS_OTG] = GATE(0x060, BIT(24)), @@ -24,9 +25,11 @@ static struct ccu_clk_gate v3s_gates[] = { [CLK_BUS_UART1] = GATE(0x06c, BIT(17)), [CLK_BUS_UART2] = GATE(0x06c, BIT(18)), - [CLK_SPI0] = GATE(0x0a0, BIT(31)), + [CLK_BUS_EPHY] = GATE(0x070, BIT(0)), - [CLK_USB_PHY0] = GATE(0x0cc, BIT(8)), + [CLK_SPI0] = GATE(0x0a0, BIT(31)), + + [CLK_USB_PHY0] = GATE(0x0cc, BIT(8)), }; static struct ccu_reset v3s_resets[] = { @@ -35,12 +38,15 @@ static struct ccu_reset v3s_resets[] = { [RST_BUS_MMC0] = RESET(0x2c0, BIT(8)), [RST_BUS_MMC1] = RESET(0x2c0, BIT(9)), [RST_BUS_MMC2] = RESET(0x2c0, BIT(10)), + [RST_BUS_EMAC] = RESET(0x2c0, BIT(17)), [RST_BUS_SPI0] = RESET(0x2c0, BIT(20)), [RST_BUS_OTG] = RESET(0x2c0, BIT(24)), [RST_BUS_UART0] = RESET(0x2d8, BIT(16)), [RST_BUS_UART1] = RESET(0x2d8, BIT(17)), [RST_BUS_UART2] = RESET(0x2d8, BIT(18)), + + [RST_BUS_EPHY] = RESET(0x2c8, BIT(2)), }; static const struct ccu_desc v3s_ccu_desc = { diff --git a/drivers/net/sun8i_emac.c b/drivers/net/sun8i_emac.c index 99e24c6348..f69b8be957 100644 --- a/drivers/net/sun8i_emac.c +++ b/drivers/net/sun8i_emac.c @@ -56,9 +56,11 @@ #define RX_TOTAL_BUFSIZE (CONFIG_ETH_BUFSIZE * CONFIG_RX_DESCR_NUM) #define H3_EPHY_DEFAULT_VALUE 0x58000 +#define V3S_EPHY_DEFAULT_VALUE 0x38000 #define H3_EPHY_DEFAULT_MASK GENMASK(31, 15) #define H3_EPHY_ADDR_SHIFT 20 #define REG_PHY_ADDR_MASK GENMASK(4, 0) +#define H3_EPHY_CLK_SEL BIT(18) /* 1: 24MHz, 0: 25MHz */ #define H3_EPHY_LED_POL BIT(17) /* 1: active low, 0: active high */ #define H3_EPHY_SHUTDOWN BIT(16) /* 1: shutdown, 0: power up */ #define H3_EPHY_SELECT BIT(15) /* 1: internal PHY, 0: external PHY */ @@ -111,6 +113,7 @@ enum emac_variant { H3_EMAC, A64_EMAC, R40_GMAC, + V3S_EMAC, }; struct emac_dma_desc { @@ -278,10 +281,11 @@ static int sun8i_emac_set_syscon_ephy(struct emac_eth_dev *priv, u32 *reg) * needs to be configured and powered up before use */ *reg &= ~H3_EPHY_DEFAULT_MASK; - *reg |= H3_EPHY_DEFAULT_VALUE; + *reg |= ((priv->variant == V3S_EMAC) ? V3S_EPHY_DEFAULT_VALUE : H3_EPHY_DEFAULT_VALUE); *reg |= priv->phyaddr << H3_EPHY_ADDR_SHIFT; *reg &= ~H3_EPHY_SHUTDOWN; *reg |= H3_EPHY_SELECT; + *reg |= H3_EPHY_CLK_SEL; } else /* This is to select External Gigabit PHY on * the boards with H3 SoC. @@ -310,14 +314,14 @@ static int sun8i_emac_set_syscon(struct sun8i_eth_pdata *pdata, reg = readl(priv->sysctl_reg + 0x30); - if (priv->variant == H3_EMAC) { + if (priv->variant == H3_EMAC || priv->variant == V3S_EMAC) { ret = sun8i_emac_set_syscon_ephy(priv, ®); if (ret) return ret; } reg &= ~(SC_ETCS_MASK | SC_EPIT); - if (priv->variant == H3_EMAC || priv->variant == A64_EMAC) + if (priv->variant == H3_EMAC || priv->variant == V3S_EMAC || priv->variant == A64_EMAC) reg &= ~SC_RMII_EN; switch (priv->interface) { @@ -837,7 +841,7 @@ static int sun8i_emac_eth_probe(struct udevice *dev) sun8i_mdio_init(dev->name, dev); priv->bus = miiphy_get_dev_by_name(dev->name); - + return sun8i_phy_init(priv, dev); } @@ -981,7 +985,7 @@ static int sun8i_emac_eth_ofdata_to_platdata(struct udevice *dev) return -EINVAL; } - if (priv->variant == H3_EMAC) { + if (priv->variant == H3_EMAC || priv->variant == V3S_EMAC) { ret = sun8i_get_ephy_nodes(priv); if (ret) return ret; @@ -1025,13 +1029,16 @@ static int sun8i_emac_eth_ofdata_to_platdata(struct udevice *dev) } static const struct udevice_id sun8i_emac_eth_ids[] = { - {.compatible = "allwinner,sun8i-h3-emac", .data = (uintptr_t)H3_EMAC }, + {.compatible = "allwinner,sun8i-h3-emac", + .data = (uintptr_t)H3_EMAC }, {.compatible = "allwinner,sun50i-a64-emac", .data = (uintptr_t)A64_EMAC }, {.compatible = "allwinner,sun8i-a83t-emac", .data = (uintptr_t)A83T_EMAC }, {.compatible = "allwinner,sun8i-r40-gmac", .data = (uintptr_t)R40_GMAC }, + {.compatible = "allwinner,sun8i-v3s-emac", + .data = (uintptr_t)V3S_EMAC }, { } }; From patchwork Wed May 27 13:33:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Benedikt-Alexander_Mokro=C3=9F?= X-Patchwork-Id: 1298924 X-Patchwork-Delegate: jagannadh.teki@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=bamkrs.de Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=bamkrs.de header.i=@bamkrs.de header.a=rsa-sha256 header.s=strato-dkim-0002 header.b=GJHUt2aA; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49XBcS0Z3yz9sSs for ; Wed, 27 May 2020 23:33:43 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0C2AF81D25; Wed, 27 May 2020 15:33:31 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=bamkrs.de 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=bamkrs.de header.i=@bamkrs.de header.b="GJHUt2aA"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 17AB581D7A; Wed, 27 May 2020 15:33:25 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mo6-p00-ob.smtp.rzone.de (mo6-p00-ob.smtp.rzone.de [IPv6:2a01:238:20a:202:5300::7]) (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 6673081D55 for ; Wed, 27 May 2020 15:33:20 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=bamkrs.de Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=u-boot@bamkrs.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1590586400; s=strato-dkim-0002; d=bamkrs.de; h=Date:Message-ID:Subject:From:To:X-RZG-CLASS-ID:X-RZG-AUTH:From: Subject:Sender; bh=KlNzAijlD44WHqv2eqtejp4o7TypxNtDkoSBqThSqf4=; b=GJHUt2aAuvTDGAz/MfuI716uZ7BaHCo2bTJCOhit+Zwq6FfTgGrpn2mMAYx6dCko7/ w9/7NsDiZYihHbfhYZd22VXOzRnzUwkwEoY0k4AmMhTZmu9K2DFki1DiCJKMqGiCCc3E Qmyjuklbgy04ZTaGPm4WZIkqqnl4cc8tjTymYiJvmKqFGKlCAo5R/+FZQtok0PE/dP3g eIGKIF72R82PazuiXgj6ugx2Ts7Ay5rQxrUdOW0UNJPC8wUyy3s8MOZ9f0ojXCrfaE8h 5Vy4qX5FA6cVbBOW12AXV7LIHUKG756JV2xr0MgrhqKSgrHv4GpjgMAZAM79nlSoW2jc vPAg== X-RZG-AUTH: ":L20Qdkipd/NtQfa67vW/eJfuQpomyW4cBm3G2ZWMm0e+aME9udSL7FwAirwWgNfi+hnaBWxN1T8uNipfmeVxz7XGl0KnFVfw1Q==" X-RZG-CLASS-ID: mo00 Received: from [IPv6:2a02:b98:0:20f:51aa:b659:9ee4:9410] by smtp.strato.de (RZmta 46.7.0 AUTH) with ESMTPSA id 208d27w4RDXJMhm (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate) for ; Wed, 27 May 2020 15:33:19 +0200 (CEST) To: u-boot@lists.denx.de From: =?utf-8?q?Benedikt-Alexander_Mokro=C3=9F?= Subject: [PATCH 2/2] sun8i-emac: Added sun8i-v3s-emac example to sun8i-v3s.dtsi Message-ID: <6ffbd48d-a8f4-4247-817c-4fe25a8099ab@bamkrs.de> Date: Wed, 27 May 2020 15:33:19 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 Content-Language: en-US X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 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.102.2 at phobos.denx.de X-Virus-Status: Clean This optional patch adds the needed device-tree node to sun8i-v3s.dtsi to enable ethernet for sun8i-v3s boards. Signed-off-by: Benedikt-Alexander Mokroß --- arch/arm/dts/sun8i-v3s.dtsi | 48 +++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/arch/arm/dts/sun8i-v3s.dtsi b/arch/arm/dts/sun8i-v3s.dtsi index ebefc0fefe..e6c090465a 100644 --- a/arch/arm/dts/sun8i-v3s.dtsi +++ b/arch/arm/dts/sun8i-v3s.dtsi @@ -280,5 +280,53 @@ #interrupt-cells = <3>; interrupts = ; }; + + emac: ethernet@1c30000 { + compatible = "allwinner,sun8i-v3s-emac"; + syscon = <&syscon>; + reg = <0x01c30000 0x104>; + interrupts = ; + interrupt-names = "macirq"; + resets = <&ccu RST_BUS_EMAC>; + reset-names = "stmmaceth"; + clocks = <&ccu CLK_BUS_EMAC>; + clock-names = "stmmaceth"; + #address-cells = <1>; + #size-cells = <0>; + phy-handle = <&int_mii_phy>; + phy = <&int_mii_phy>; + phy-mode = "mii"; + allwinner,leds-active-low; + status = "disabled"; + + mdio: mdio { + #address-cells = <1>; + #size-cells = <0>; + compatible = "snps,dwmac-mdio"; + }; + + mdio-mux { + compatible = "allwinner,sun8i-h3-mdio-mux"; + #address-cells = <1>; + #size-cells = <0>; + + mdio-parent-bus = <&mdio>; + + int_mdio: mdio@1 { + compatible = "allwinner,sun8i-h3-mdio-internal"; + reg = <1>; + #address-cells = <1>; + #size-cells = <0>; + + int_mii_phy: ethernet-phy@1 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <1>; + clocks = <&ccu CLK_BUS_EPHY>; + resets = <&ccu RST_BUS_EPHY>; + phy-is-integrated; + }; + }; + }; + }; }; };