From fb9ed23c22d770a688092a082cfc459854749bd2 Mon Sep 17 00:00:00 2001 From: Tony Dinh Date: Sun, 30 Jan 2022 15:02:30 -0800 Subject: [PATCH 1/7] arm: kirkwood: Dreamplug : Use Marvell uclass mvgbe and PHY driver for Ethernet MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Globalscale Technologies Dreamplug board has the network chip Marvell 88E1116R. Use uclass mvgbe and the compatible driver M88E1310 driver to bring up Ethernet. - 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. - Add board_eth_init() to use uclass mvgbe to bring up both network port 0 and 1. And remove ad-hoc code. - Enable CONFIG_PHY_MARVELL to properly configure the network. - Add myself as maintainer (this board seems to be orphaned, could not contact Jason Cooper using current email). - Miscellaneous changes: Move constants to .c file and remove header file board/Marvell/dreamplug/dreamplug.h, cleanup comments. Signed-off-by: Tony Dinh Reviewed-by: Stefan Roese Reviewed-by: Pali Rohár --- board/Marvell/dreamplug/MAINTAINERS | 1 + board/Marvell/dreamplug/dreamplug.c | 94 +++++------------------------ board/Marvell/dreamplug/dreamplug.h | 25 -------- configs/dreamplug_defconfig | 1 + include/configs/dreamplug.h | 20 ++---- 5 files changed, 21 insertions(+), 120 deletions(-) delete mode 100644 board/Marvell/dreamplug/dreamplug.h diff --git a/board/Marvell/dreamplug/MAINTAINERS b/board/Marvell/dreamplug/MAINTAINERS index 2561ba8134..6bad3ea78b 100644 --- a/board/Marvell/dreamplug/MAINTAINERS +++ b/board/Marvell/dreamplug/MAINTAINERS @@ -1,4 +1,5 @@ DREAMPLUG BOARD +M: Tony Dinh M: Jason Cooper S: Maintained F: board/Marvell/dreamplug/ diff --git a/board/Marvell/dreamplug/dreamplug.c b/board/Marvell/dreamplug/dreamplug.c index 7ba14021b2..d15faa1cb7 100644 --- a/board/Marvell/dreamplug/dreamplug.c +++ b/board/Marvell/dreamplug/dreamplug.c @@ -1,8 +1,7 @@ // SPDX-License-Identifier: GPL-2.0+ /* - * Copyright (C) 2021 Tony Dinh - * (C) Copyright 2011 - * Jason Cooper + * Copyright (C) 2021-2022 Tony Dinh + * Copyright (C) 2011 Jason Cooper * * Based on work by: * Marvell Semiconductor @@ -11,16 +10,19 @@ #include #include -#include -#include +#include #include #include #include #include -#include "dreamplug.h" DECLARE_GLOBAL_DATA_PTR; +#define DREAMPLUG_OE_LOW (~(0)) +#define DREAMPLUG_OE_HIGH (~(0)) +#define DREAMPLUG_OE_VAL_LOW 0 +#define DREAMPLUG_OE_VAL_HIGH (0xf << 16) /* 4 LED Pins high */ + int board_early_init_f(void) { /* @@ -90,83 +92,15 @@ 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) { - /* adress of boot parameters */ + /* address of boot parameters */ gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100; return 0; } - -static int fdt_get_phy_addr(const char *path) -{ - const void *fdt = gd->fdt_blob; - const u32 *reg; - const u32 *val; - int node, phandle, addr; - - /* Find the node by its full path */ - node = fdt_path_offset(fdt, path); - if (node >= 0) { - /* Look up phy-handle */ - val = fdt_getprop(fdt, node, "phy-handle", NULL); - if (val) { - phandle = fdt32_to_cpu(*val); - if (!phandle) - return -1; - /* Follow it to its node */ - node = fdt_node_offset_by_phandle(fdt, phandle); - if (node) { - /* Look up reg */ - reg = fdt_getprop(fdt, node, "reg", NULL); - if (reg) { - addr = fdt32_to_cpu(*reg); - return addr; - } - } - } - } - return -1; -} - -#ifdef CONFIG_RESET_PHY_R -void mv_phy_88e1116_init(const char *name, const char *path) -{ - u16 reg; - int phyaddr; - - if (miiphy_set_current_dev(name)) - return; - - phyaddr = fdt_get_phy_addr(path); - if (phyaddr < 0) - return; - - /* - * Enable RGMII delay on Tx and Rx for CPU port - * Ref: sec 4.7.2 of chip datasheet - */ - miiphy_write(name, phyaddr, MV88E1116_PGADR_REG, 2); - miiphy_read(name, phyaddr, MV88E1116_MAC_CTRL2_REG, ®); - reg |= (MV88E1116_RGMII_RXTM_CTRL | MV88E1116_RGMII_TXTM_CTRL); - miiphy_write(name, phyaddr, MV88E1116_MAC_CTRL2_REG, reg); - miiphy_write(name, phyaddr, MV88E1116_PGADR_REG, 0); - - /* reset the phy */ - miiphy_reset(name, phyaddr); - - printf("88E1116 Initialized on %s\n", name); -} - -void reset_phy(void) -{ - char *eth0_name = "ethernet-controller@72000"; - char *eth0_path = "/ocp@f1000000/ethernet-controller@72000/ethernet0-port@0"; - char *eth1_name = "ethernet-controller@76000"; - char *eth1_path = "/ocp@f1000000/ethernet-controller@76000/ethernet1-port@0"; - - /* configure and initialize both PHY's */ - mv_phy_88e1116_init(eth0_name, eth0_path); - mv_phy_88e1116_init(eth1_name, eth1_path); -} -#endif /* CONFIG_RESET_PHY_R */ diff --git a/board/Marvell/dreamplug/dreamplug.h b/board/Marvell/dreamplug/dreamplug.h deleted file mode 100644 index 6f62238985..0000000000 --- a/board/Marvell/dreamplug/dreamplug.h +++ /dev/null @@ -1,25 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ -/* - * (C) Copyright 2011 - * Jason Cooper - * - * Based on work by: - * Marvell Semiconductor - * Written-by: Siddarth Gore - */ - -#ifndef __DREAMPLUG_H -#define __DREAMPLUG_H - -#define DREAMPLUG_OE_LOW (~(0)) -#define DREAMPLUG_OE_HIGH (~(0)) -#define DREAMPLUG_OE_VAL_LOW 0 -#define DREAMPLUG_OE_VAL_HIGH (0xf << 16) /* 4 LED Pins high */ - -/* PHY related */ -#define MV88E1116_MAC_CTRL2_REG 21 -#define MV88E1116_PGADR_REG 22 -#define MV88E1116_RGMII_TXTM_CTRL (1 << 4) -#define MV88E1116_RGMII_RXTM_CTRL (1 << 5) - -#endif /* __DREAMPLUG_H */ diff --git a/configs/dreamplug_defconfig b/configs/dreamplug_defconfig index 2d2b7f5ad3..72ab6956ee 100644 --- a/configs/dreamplug_defconfig +++ b/configs/dreamplug_defconfig @@ -50,6 +50,7 @@ CONFIG_SYS_ATA_ALT_OFFSET=0x100 CONFIG_MTD=y CONFIG_DM_SPI_FLASH=y CONFIG_SPI_FLASH_MACRONIX=y +CONFIG_PHY_MARVELL=y CONFIG_DM_ETH=y CONFIG_MVGBE=y CONFIG_MII=y diff --git a/include/configs/dreamplug.h b/include/configs/dreamplug.h index 0b3ee131ae..fd12a39187 100644 --- a/include/configs/dreamplug.h +++ b/include/configs/dreamplug.h @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0+ */ /* - * (C) Copyright 2011 - * Jason Cooper + * (C) Copyright 2022 Tony Dinh + * (C) Copyright 2011 Jason Cooper * * Based on work by: * Marvell Semiconductor @@ -13,15 +13,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 */ @@ -36,16 +27,15 @@ /* * Ethernet Driver configuration */ -#ifdef CONFIG_CMD_NET #define CONFIG_MVGBE_PORTS {1, 1} /* enable both ports */ #define CONFIG_PHY_BASE_ADR 0 -#endif /* CONFIG_CMD_NET */ +#ifdef CONFIG_RESET_PHY_R +#undef CONFIG_RESET_PHY_R /* remove legacy reset_phy() */ +#endif /* * SATA Driver configuration */ -#ifdef CONFIG_SATA #define CONFIG_LBA48 -#endif /* CONFIG_SATA */ #endif /* _CONFIG_DREAMPLUG_H */ From f99a169c19149fd005783c37c815518fb5ac9bdf Mon Sep 17 00:00:00 2001 From: Tony Dinh Date: Tue, 1 Feb 2022 21:59:27 -0800 Subject: [PATCH 2/7] arm: kirkwood: iConnect : Add Ethernet support - 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. - Add board_eth_init(), CONFIG_DM_ETH, and CONFIG_PHY_MARVELL to bring up Ethernet. - Miscellaneous changes: Move constants to .c file and remove header file board/iomega/iconnect/iconnect.h. Add CONFIG_HUSH_PARSER, use BIT macro, and cleanup comments. Signed-off-by: Tony Dinh Reviewed-by: Stefan Roese --- board/iomega/iconnect/iconnect.c | 17 ++++++++++++++--- board/iomega/iconnect/iconnect.h | 24 ------------------------ configs/iconnect_defconfig | 6 +++++- include/configs/iconnect.h | 21 +++++++-------------- 4 files changed, 26 insertions(+), 42 deletions(-) delete mode 100644 board/iomega/iconnect/iconnect.h diff --git a/board/iomega/iconnect/iconnect.c b/board/iomega/iconnect/iconnect.c index 9e123aab00..0387160200 100644 --- a/board/iomega/iconnect/iconnect.c +++ b/board/iomega/iconnect/iconnect.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0+ /* + * Copyright (C) 2022 Tony Dinh * Copyright (C) 2009-2012 * Wojciech Dubowik * Luka Perkov @@ -7,15 +8,20 @@ #include #include -#include +#include #include #include #include #include -#include "iconnect.h" +#include DECLARE_GLOBAL_DATA_PTR; +#define ICONNECT_OE_LOW (~BIT(7)) +#define ICONNECT_OE_HIGH (~BIT(10)) +#define ICONNECT_OE_VAL_LOW (0) +#define ICONNECT_OE_VAL_HIGH BIT(10) + int board_early_init_f(void) { /* @@ -85,9 +91,14 @@ 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) { - /* adress of boot parameters */ + /* address of boot parameters */ gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100; return 0; diff --git a/board/iomega/iconnect/iconnect.h b/board/iomega/iconnect/iconnect.h deleted file mode 100644 index 4f0be71918..0000000000 --- a/board/iomega/iconnect/iconnect.h +++ /dev/null @@ -1,24 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ -/* - * Copyright (C) 2009-2012 - * Wojciech Dubowik - * Luka Perkov - */ - -#ifndef __ICONNECT_H -#define __ICONNECT_H - -#define ICONNECT_OE_LOW (~(1 << 7)) -#define ICONNECT_OE_HIGH (~(1 << 10)) -#define ICONNECT_OE_VAL_LOW (0) -#define ICONNECT_OE_VAL_HIGH (1 << 10) - -/* 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 /* __ICONNECT_H */ diff --git a/configs/iconnect_defconfig b/configs/iconnect_defconfig index 1c9c77a292..336fae270a 100644 --- a/configs/iconnect_defconfig +++ b/configs/iconnect_defconfig @@ -20,7 +20,8 @@ CONFIG_BOOTCOMMAND="setenv bootargs ${console} ${mtdparts} ${bootargs_root}; ubi CONFIG_USE_PREBOOT=y # CONFIG_DISPLAY_BOARDINFO is not set CONFIG_BOARD_LATE_INIT=y -CONFIG_SYS_PROMPT="iconnect => " +CONFIG_HUSH_PARSER=y +CONFIG_SYS_PROMPT="iConnect> " # CONFIG_CMD_FLASH is not set CONFIG_CMD_NAND=y CONFIG_CMD_PCI=y @@ -39,11 +40,14 @@ CONFIG_OF_CONTROL=y CONFIG_ENV_OVERWRITE=y CONFIG_ENV_IS_IN_NAND=y CONFIG_SYS_RELOC_GD_ENV_ADDR=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_PCI=y diff --git a/include/configs/iconnect.h b/include/configs/iconnect.h index f1aad1efde..44a4b4409f 100644 --- a/include/configs/iconnect.h +++ b/include/configs/iconnect.h @@ -1,5 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0+ */ /* + * Copyright (C) 2022 Tony Dinh * (C) Copyright 2009-2012 * Wojciech Dubowik * Luka Perkov @@ -10,32 +11,24 @@ #include "mv-common.h" -/* - * Environment variables configuration - */ - -/* - * Default environment variables - */ - #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" \ "bootargs_root=noinitrd ubi.mtd=2 root=ubi0:rootfs rootfstype=ubifs\0" /* * Ethernet driver configuration + * + * This board has PCIe Wifi card, so allow Ethernet to be disabled */ #ifdef CONFIG_CMD_NET #define CONFIG_MVGBE_PORTS {1, 0} /* enable port 0 only */ #define CONFIG_PHY_BASE_ADR 11 -#undef CONFIG_RESET_PHY_R +#ifdef CONFIG_RESET_PHY_R +#undef CONFIG_RESET_PHY_R /* remove legacy reset_phy() */ +#endif #endif /* CONFIG_CMD_NET */ -/* - * File system - */ - #endif /* _CONFIG_ICONNECT_H */ From de7514046ea5e66ecdfcffc59031e0561d5b3aa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pali=20Roh=C3=A1r?= Date: Thu, 3 Feb 2022 17:45:20 +0100 Subject: [PATCH 3/7] tools: kwboot: Fix detection of quit esc sequence MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Quit esc sequence may be also in the middle of the read buffer. Fix the detection for that case. Signed-off-by: Pali Rohár Reviewed-by: Stefan Roese --- tools/kwboot.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/tools/kwboot.c b/tools/kwboot.c index 2684f0e75a..7737188f0d 100644 --- a/tools/kwboot.c +++ b/tools/kwboot.c @@ -1183,10 +1183,10 @@ kwboot_xmodem(int tty, const void *_img, size_t size, int baudrate) static int kwboot_term_pipe(int in, int out, const char *quit, int *s) { + char buf[128]; ssize_t nin; - char _buf[128], *buf = _buf; - nin = read(in, buf, sizeof(_buf)); + nin = read(in, buf, sizeof(buf)); if (nin <= 0) return -1; @@ -1194,18 +1194,21 @@ kwboot_term_pipe(int in, int out, const char *quit, int *s) int i; for (i = 0; i < nin; i++) { - if (*buf == quit[*s]) { + if (buf[i] == quit[*s]) { (*s)++; - if (!quit[*s]) - return 0; - buf++; - nin--; + if (!quit[*s]) { + nin = i - *s; + break; + } } else { - if (kwboot_write(out, quit, *s) < 0) + if (*s > i && kwboot_write(out, quit, *s - i) < 0) return -1; *s = 0; } } + + if (i == nin) + nin -= *s; } if (kwboot_write(out, buf, nin) < 0) From ba4e6f8a5ef9650b47ec6b65dc875508c8916380 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pali=20Roh=C3=A1r?= Date: Thu, 3 Feb 2022 17:57:49 +0100 Subject: [PATCH 4/7] MAINTAINERS: Update list of Armada 385 and Armada 3720 drivers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Pali Rohár Reviewed-by: Stefan Roese --- MAINTAINERS | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 54985aef48..b6a4b5d04d 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -278,11 +278,20 @@ T: git https://source.denx.de/u-boot/custodians/u-boot-marvell.git F: arch/arm/mach-kirkwood/ F: arch/arm/mach-mvebu/ F: drivers/ata/ahci_mvebu.c +F: drivers/clk/mvebu/ F: drivers/ddr/marvell/ F: drivers/gpio/mvebu_gpio.c +F: drivers/i2c/mvtwsi.c +F: drivers/mmc/xenon_sdhci.c +F: drivers/phy/marvell/ +F: drivers/pinctrl/mvebu/ +F: drivers/rtc/armada38x.c F: drivers/spi/kirkwood_spi.c +F: drivers/spi/mvebu_a3700_spi.c F: drivers/pci/pcie_dw_mvebu.c +F: drivers/watchdog/armada-37xx-wdt.c F: drivers/watchdog/orion_wdt.c +F: include/configs/mv-common.h ARM MARVELL PCIE CONTROLLER DRIVERS M: Pali Rohár From c153576d8dfc80c651a7edb046adbaa1c1c17e42 Mon Sep 17 00:00:00 2001 From: Tony Dinh Date: Thu, 3 Feb 2022 14:32:29 -0800 Subject: [PATCH 5/7] arm: kirkwood: Dockstar : Add DM Ethernet 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 --- 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 */ From 9e6d71d2b55f156c907d073825359d6ae441d9cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pali=20Roh=C3=A1r?= Date: Mon, 7 Feb 2022 10:12:24 +0100 Subject: [PATCH 6/7] tools: kwboot: Allow to use -b without image path as the last getopt() option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently it is possible to call "kwboot -b -t /dev/ttyUSB0" but not to call "kwboot -b /dev/ttyUSB0". Fix it by not trying to process the last argv[], which is non-getopt() option (tty path) as the image path for -b. Fixes: c513fe47dca2 ("tools: kwboot: Allow to use option -b without image path") Reported-by: Marcel Ziswiler Signed-off-by: Pali Rohár Reviewed-by: Marcel Ziswiler Tested-by: Marcel Ziswiler --- tools/kwboot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/kwboot.c b/tools/kwboot.c index 7737188f0d..68c0ef1f1b 100644 --- a/tools/kwboot.c +++ b/tools/kwboot.c @@ -1770,7 +1770,7 @@ main(int argc, char **argv) bootmsg = kwboot_msg_boot; if (prev_optind == optind) goto usage; - if (argv[optind] && argv[optind][0] != '-') + if (optind < argc - 1 && argv[optind] && argv[optind][0] != '-') imgpath = argv[optind++]; break; From d2a44ceddc2bc603cf97c27c9d1491ffc1b58a48 Mon Sep 17 00:00:00 2001 From: Tony Dinh Date: Tue, 8 Feb 2022 18:56:22 -0800 Subject: [PATCH 7/7] arm: kirkwood: Pogoplug E02 : Convert Ethernet to Driver Model The Pogoplug E02 board has the network chip Marvell 88E1116R. Convert to Driver Model and use uclass mvgbe and the compatible driver M88E1118R to bring up Ethernet. - Add board_eth_init(), CONFIG_DM_ETH, and CONFIG_PHY_MARVELL to bring up Ethernet. - 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. - As the result of the migration to Driver Model, this u-boot image has grown substantially (about 100K, give or take). The old envs location at 0x60000 (384k) is no longer possible. Move it to 0xC0000 (768K). - Miscellaneous changes: Move constants to .c file and remove header file board/cloudengines/pogo_e02/pogo_e02.h, use CONFIG_SYS_THUMB_BUILD to keep u-boot image under 512K, use BIT macro, and cleanup comments. Signed-off-by: Tony Dinh Reviewed-by: Stefan Roese --- board/cloudengines/pogo_e02/pogo_e02.c | 51 +++++++------------------- board/cloudengines/pogo_e02/pogo_e02.h | 29 --------------- configs/pogo_e02_defconfig | 6 ++- include/configs/pogo_e02.h | 13 ++----- 4 files changed, 22 insertions(+), 77 deletions(-) delete mode 100644 board/cloudengines/pogo_e02/pogo_e02.h diff --git a/board/cloudengines/pogo_e02/pogo_e02.c b/board/cloudengines/pogo_e02/pogo_e02.c index 039fd6e3dd..59e1218b41 100644 --- a/board/cloudengines/pogo_e02/pogo_e02.c +++ b/board/cloudengines/pogo_e02/pogo_e02.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0+ /* + * Copyright (C) 2022 Tony Dinh * Copyright (C) 2012 * David Purdy * @@ -12,16 +13,21 @@ #include #include #include -#include -#include +#include #include #include #include #include -#include "pogo_e02.h" +#include DECLARE_GLOBAL_DATA_PTR; +/* GPIO configuration */ +#define POGO_E02_OE_LOW (~(0)) +#define POGO_E02_OE_HIGH (~(0)) +#define POGO_E02_OE_VAL_LOW BIT(29) +#define POGO_E02_OE_VAL_HIGH 0 + int board_early_init_f(void) { /* @@ -64,6 +70,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) { /* Boot parameters address */ @@ -71,37 +82,3 @@ int board_init(void) return 0; } - -#ifdef CONFIG_RESET_PHY_R -/* Configure and initialize 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", __func__); - 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); - - debug("88E1116 Initialized on %s\n", name); -} -#endif /* CONFIG_RESET_PHY_R */ diff --git a/board/cloudengines/pogo_e02/pogo_e02.h b/board/cloudengines/pogo_e02/pogo_e02.h deleted file mode 100644 index c8397b4d4f..0000000000 --- a/board/cloudengines/pogo_e02/pogo_e02.h +++ /dev/null @@ -1,29 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ -/* - * Copyright (C) 2012 - * David Purdy - * - * Based on Kirkwood support: - * (C) Copyright 2009 - * Marvell Semiconductor - * Written-by: Prafulla Wadaskar - */ - -#ifndef __POGO_E02_H -#define __POGO_E02_H - -/* GPIO configuration */ -#define POGO_E02_OE_LOW (~(0)) -#define POGO_E02_OE_HIGH (~(0)) -#define POGO_E02_OE_VAL_LOW (1 << 29) -#define POGO_E02_OE_VAL_HIGH 0 - -/* 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 /* __POGO_E02_H */ diff --git a/configs/pogo_e02_defconfig b/configs/pogo_e02_defconfig index 10f08a515d..7853cc7b24 100644 --- a/configs/pogo_e02_defconfig +++ b/configs/pogo_e02_defconfig @@ -2,13 +2,14 @@ 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/cloudengines/pogo_e02/kwbimage.cfg" CONFIG_SYS_TEXT_BASE=0x600000 CONFIG_NR_DRAM_BANKS=2 CONFIG_TARGET_POGO_E02=y CONFIG_ENV_SIZE=0x20000 -CONFIG_ENV_OFFSET=0x60000 +CONFIG_ENV_OFFSET=0xC0000 CONFIG_DEFAULT_DEVICE_TREE="kirkwood-pogo_e02" CONFIG_IDENT_STRING="\nPogo E02" # CONFIG_SYS_MALLOC_F is not set @@ -36,11 +37,14 @@ CONFIG_OF_CONTROL=y CONFIG_ENV_OVERWRITE=y CONFIG_ENV_IS_IN_NAND=y CONFIG_SYS_RELOC_GD_ENV_ADDR=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/pogo_e02.h b/include/configs/pogo_e02.h index 3e94125cb3..51c802f2b3 100644 --- a/include/configs/pogo_e02.h +++ b/include/configs/pogo_e02.h @@ -14,10 +14,6 @@ #include "mv-common.h" -/* - * Environment variables configurations - */ - /* * Default environment variables */ @@ -33,13 +29,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_POGO_E02_H */