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 3B4EAC433EF for ; Fri, 4 Feb 2022 05:50:50 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B4D7C83A60; Fri, 4 Feb 2022 06:50:47 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1643953847; bh=kCOxVjnlI8C9i21tsp2F5fKuO5OWYtwob2N/yKSNdkg=; h=Date:Subject:To:Cc:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=UCklj05nFYjfPq4GXrKNbFvyWYE++UZXrgNopcuMoaWsGFiuYRn/HeEj8IFgUBeHl 0pqIMSp1RJBG3CtYasT3usJKXBHiybfp15TTLxlCywxRVg6iGfI/jQTgFyF2qiHtVn 0Jtq+EmJJ1xTPIAB6gBd+ASo++rg6u+njX2AaTaLCtG4+MHxua/NdpiVGqPF5S49bN B/Q4tJVfuJhU5K76wAIrtbxnyjSsADALcLekAzAkl7SXVPvlpWe8qquwkjcMEwWY27 1Jma+Y4OkuwYB5CzPcQ3vYQa1nEsRB2d6rgj198HDpocE4J4pIldVO34j4Nx8kpV9s orW7QF6hlJnTg== Received: by phobos.denx.de (Postfix, from userid 109) id A0EC883A61; Fri, 4 Feb 2022 06:50:46 +0100 (CET) Received: from mout-u-204.mailbox.org (mout-u-204.mailbox.org [IPv6:2001:67c:2050:1::465:204]) (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 3B6CD83A5C for ; Fri, 4 Feb 2022 06:50:43 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sr@denx.de Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:105:465:1:1:0]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-u-204.mailbox.org (Postfix) with ESMTPS id 4Jql4z1NDRz9sq0; Fri, 4 Feb 2022 06:50:43 +0100 (CET) Message-ID: <40ad7d19-9619-2b74-fbcd-56a2bded65e5@denx.de> Date: Fri, 4 Feb 2022 06:50:33 +0100 MIME-Version: 1.0 Subject: Re: [RESEND PATCH] arm: kirkwood: Dockstar : Add DM Ethernet Content-Language: en-US To: Tony Dinh , U-Boot Mailing List Cc: Tom Rini References: <20220203223229.11680-1-mibodhi@gmail.com> From: Stefan Roese In-Reply-To: <20220203223229.11680-1-mibodhi@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed 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.5 at phobos.denx.de X-Virus-Status: Clean On 2/3/22 23:32, Tony Dinh wrote: > The Dockstar board has the network chip Marvell 88E1116R. Convert to > Ethernet driver model, and use uclass mvgbe and the compatible driver > M88E1118R to bring up Ethernet. > > - Add CONFIG_DM_ETH and associated configs. > - Add board_eth_init() to use uclass mvgbe to bring up the network. > And remove ad-hoc code. > - Add CONFIG_PHY_MARVELL to properly configure the network. > - Currently, CONFIG_RESET_PHY_R symbol is used in > arch/arm/mach-kirkwood/include/mach/config.h for all Kirkwood > boards with mv8831116 PHY, with each board defines the function > reset_phy(). Undefine it for this board. > - Miscellaneous changes: Move constants to .c file and remove > header file board/Seagate/dockstar/dockstar.h, use > CONFIG_SYS_THUMB_BUILD to keep u-boot image > under 512K, add CONFIG_HUSH_PARSER, use BIT macro, and cleanup comments. > > - Note: This patch is a RESEND for a previous patch: > https://patchwork.ozlabs.org/project/uboot/patch/20210812051854.1340-2-mibodhi@gmail.com/ > > Signed-off-by: Tony Dinh Reviewed-by: Stefan Roese Thanks, Stefan > --- > > board/Seagate/dockstar/dockstar.c | 62 ++++++++++--------------------- > board/Seagate/dockstar/dockstar.h | 27 -------------- > configs/dockstar_defconfig | 5 +++ > include/configs/dockstar.h | 20 +++------- > 4 files changed, 30 insertions(+), 84 deletions(-) > delete mode 100644 board/Seagate/dockstar/dockstar.h > > diff --git a/board/Seagate/dockstar/dockstar.c b/board/Seagate/dockstar/dockstar.c > index fb69193158..d72e3ef24e 100644 > --- a/board/Seagate/dockstar/dockstar.c > +++ b/board/Seagate/dockstar/dockstar.c > @@ -1,5 +1,6 @@ > // SPDX-License-Identifier: GPL-2.0+ > /* > + * Copyright (C) 2022 Tony Dinh > * Copyright (C) 2010 Eric C. Cooper > * > * Based on sheevaplug.c originally written by > @@ -11,18 +12,22 @@ > #include > #include > #include > -#include > -#include > +#include > #include > #include > #include > #include > #include > #include > -#include "dockstar.h" > +#include > > DECLARE_GLOBAL_DATA_PTR; > > +#define DOCKSTAR_OE_LOW (~(0)) > +#define DOCKSTAR_OE_HIGH (~(0)) > +#define DOCKSTAR_OE_VAL_LOW BIT(29) /* USB_PWEN low */ > +#define DOCKSTAR_OE_VAL_HIGH BIT(17) /* LED pin high */ > + > int board_early_init_f(void) > { > /* > @@ -92,6 +97,11 @@ int board_early_init_f(void) > return 0; > } > > +int board_eth_init(struct bd_info *bis) > +{ > + return cpu_eth_init(bis); > +} > + > int board_init(void) > { > /* > @@ -105,53 +115,21 @@ int board_init(void) > return 0; > } > > -#ifdef CONFIG_RESET_PHY_R > -/* Configure and enable MV88E1116 PHY */ > -void reset_phy(void) > -{ > - u16 reg; > - u16 devadr; > - char *name = "egiga0"; > - > - if (miiphy_set_current_dev(name)) > - return; > - > - /* command to read PHY dev address */ > - if (miiphy_read(name, 0xEE, 0xEE, (u16 *) &devadr)) { > - printf("Err..%s could not read PHY dev address\n", > - __FUNCTION__); > - return; > - } > - > - /* > - * Enable RGMII delay on Tx and Rx for CPU port > - * Ref: sec 4.7.2 of chip datasheet > - */ > - miiphy_write(name, devadr, MV88E1116_PGADR_REG, 2); > - miiphy_read(name, devadr, MV88E1116_MAC_CTRL_REG, ®); > - reg |= (MV88E1116_RGMII_RXTM_CTRL | MV88E1116_RGMII_TXTM_CTRL); > - miiphy_write(name, devadr, MV88E1116_MAC_CTRL_REG, reg); > - miiphy_write(name, devadr, MV88E1116_PGADR_REG, 0); > - > - /* reset the phy */ > - miiphy_reset(name, devadr); > - > - printf("88E1116 Initialized on %s\n", name); > -} > -#endif /* CONFIG_RESET_PHY_R */ > - > #if CONFIG_IS_ENABLED(BOOTSTAGE) > -#define GREEN_LED (1 << 14) > -#define ORANGE_LED (1 << 15) > +#define GREEN_LED BIT(14) > +#define ORANGE_LED BIT(15) > #define BOTH_LEDS (GREEN_LED | ORANGE_LED) > #define NEITHER_LED 0 > > static void set_leds(u32 leds, u32 blinking) > { > struct kwgpio_registers *r = (struct kwgpio_registers *)MVEBU_GPIO1_BASE; > - u32 oe = readl(&r->oe) | BOTH_LEDS; > + u32 oe; > + u32 bl; > + > + oe = readl(&r->oe) | BOTH_LEDS; > writel(oe & ~leds, &r->oe); /* active low */ > - u32 bl = readl(&r->blink_en) & ~BOTH_LEDS; > + bl = readl(&r->blink_en) & ~BOTH_LEDS; > writel(bl | blinking, &r->blink_en); > } > > diff --git a/board/Seagate/dockstar/dockstar.h b/board/Seagate/dockstar/dockstar.h > deleted file mode 100644 > index cbb1644476..0000000000 > --- a/board/Seagate/dockstar/dockstar.h > +++ /dev/null > @@ -1,27 +0,0 @@ > -/* SPDX-License-Identifier: GPL-2.0+ */ > -/* > - * Copyright (C) 2010 Eric C. Cooper > - * > - * Based on sheevaplug.h originally written by > - * Prafulla Wadaskar > - * (C) Copyright 2009 > - * Marvell Semiconductor > - */ > - > -#ifndef __DOCKSTAR_H > -#define __DOCKSTAR_H > - > -#define DOCKSTAR_OE_LOW (~(0)) > -#define DOCKSTAR_OE_HIGH (~(0)) > -#define DOCKSTAR_OE_VAL_LOW (1 << 29) /* USB_PWEN low */ > -#define DOCKSTAR_OE_VAL_HIGH (1 << 17) /* LED pin high */ > - > -/* PHY related */ > -#define MV88E1116_LED_FCTRL_REG 10 > -#define MV88E1116_CPRSP_CR3_REG 21 > -#define MV88E1116_MAC_CTRL_REG 21 > -#define MV88E1116_PGADR_REG 22 > -#define MV88E1116_RGMII_TXTM_CTRL (1 << 4) > -#define MV88E1116_RGMII_RXTM_CTRL (1 << 5) > - > -#endif /* __DOCKSTAR_H */ > diff --git a/configs/dockstar_defconfig b/configs/dockstar_defconfig > index 6c89a9a6fb..cbc2bf6f80 100644 > --- a/configs/dockstar_defconfig > +++ b/configs/dockstar_defconfig > @@ -2,6 +2,7 @@ CONFIG_ARM=y > CONFIG_SKIP_LOWLEVEL_INIT=y > CONFIG_SYS_DCACHE_OFF=y > CONFIG_ARCH_CPU_INIT=y > +CONFIG_SYS_THUMB_BUILD=y > CONFIG_ARCH_KIRKWOOD=y > CONFIG_SYS_KWD_CONFIG="board/Seagate/dockstar/kwbimage.cfg" > CONFIG_SYS_TEXT_BASE=0x600000 > @@ -18,6 +19,7 @@ CONFIG_USE_BOOTCOMMAND=y > CONFIG_BOOTCOMMAND="setenv bootargs ${console} ${mtdparts} ${bootargs_root}; ubi part root; ubifsmount ubi:root; ubifsload 0x800000 ${kernel}; ubifsload 0x1100000 ${initrd}; bootm 0x800000 0x1100000" > CONFIG_USE_PREBOOT=y > # CONFIG_DISPLAY_BOARDINFO is not set > +CONFIG_HUSH_PARSER=y > CONFIG_SYS_PROMPT="DockStar> " > # CONFIG_CMD_FLASH is not set > CONFIG_CMD_NAND=y > @@ -36,11 +38,14 @@ CONFIG_ISO_PARTITION=y > CONFIG_OF_CONTROL=y > CONFIG_ENV_OVERWRITE=y > CONFIG_ENV_IS_IN_NAND=y > +CONFIG_NET_RANDOM_ETHADDR=y > CONFIG_NETCONSOLE=y > CONFIG_DM=y > # CONFIG_MMC is not set > CONFIG_MTD=y > CONFIG_MTD_RAW_NAND=y > +CONFIG_PHY_MARVELL=y > +CONFIG_DM_ETH=y > CONFIG_MVGBE=y > CONFIG_MII=y > CONFIG_SYS_NS16550=y > diff --git a/include/configs/dockstar.h b/include/configs/dockstar.h > index 0ad04eee1b..736c724736 100644 > --- a/include/configs/dockstar.h > +++ b/include/configs/dockstar.h > @@ -1,5 +1,6 @@ > /* SPDX-License-Identifier: GPL-2.0+ */ > /* > + * Copyright (C) 2022 Tony Dinh > * Copyright (C) 2010 Eric C. Cooper > * > * Based on sheevaplug.h originally written by > @@ -17,14 +18,6 @@ > */ > #include "mv-common.h" > > -/* > - * Environment variables configurations > - */ > -/* > - * max 4k env size is enough, but in case of nand > - * it has to be rounded to sector size > - */ > - > /* > * Default environment variables > */ > @@ -32,7 +25,7 @@ > #define CONFIG_EXTRA_ENV_SETTINGS \ > "console=console=ttyS0,115200\0" \ > "mtdids=nand0=orion_nand\0" \ > - "mtdparts="CONFIG_MTDPARTS_DEFAULT \ > + "mtdparts=" CONFIG_MTDPARTS_DEFAULT \ > "kernel=/boot/uImage\0" \ > "initrd=/boot/uInitrd\0" \ > "bootargs_root=ubi.mtd=1 root=ubi0:root rootfstype=ubifs ro\0" > @@ -40,13 +33,10 @@ > /* > * Ethernet Driver configuration > */ > -#ifdef CONFIG_CMD_NET > #define CONFIG_MVGBE_PORTS {1, 0} /* enable port 0 only */ > #define CONFIG_PHY_BASE_ADR 0 > -#endif /* CONFIG_CMD_NET */ > - > -/* > - * File system > - */ > +#ifdef CONFIG_RESET_PHY_R > +#undef CONFIG_RESET_PHY_R /* remove legacy reset_phy() */ > +#endif > > #endif /* _CONFIG_DOCKSTAR_H */ Viele Grüße, Stefan Roese -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de