diff --git a/package/boot/uboot-bcm53xx/Makefile b/package/boot/uboot-bcm53xx/Makefile new file mode 100644 index 0000000000..ab80b9608a --- /dev/null +++ b/package/boot/uboot-bcm53xx/Makefile @@ -0,0 +1,37 @@ +include $(TOPDIR)/rules.mk + +PKG_VERSION:=2023.04 +PKG_HASH:=e31cac91545ff41b71cec5d8c22afd695645cd6e2a442ccdacacd60534069341 +PKG_RELEASE:=$(AUTORELEASE) + +include $(INCLUDE_DIR)/u-boot.mk +include $(INCLUDE_DIR)/package.mk + +define U-Boot/Default + BUILD_TARGET:=bcm53xx + BUILD_SUBTARGET:=generic + UBOOT_CONFIG:=bcmns + UBOOT_BOARD:=$(1) +endef + +define U-Boot/dir-885l + NAME:=D-Link DIR-885L + BUILD_DEVICES:=dlink_dir-885l +endef + +define U-Boot/dir-890l + NAME:=D-Link DIR-890L + BUILD_DEVICES:=dlink_dir-890l +endef + +UBOOT_TARGETS := dir-885l dir-890l + +define Build/InstallDev + $(INSTALL_DIR) $(STAGING_DIR_IMAGE) + $(CP) $(PKG_BUILD_DIR)/$(UBOOT_IMAGE) $(STAGING_DIR_IMAGE)/$(BUILD_DEVICES)-u-boot.bin +endef + +define Package/u-boot/install/default +endef + +$(eval $(call BuildPackage/U-Boot)) diff --git a/package/boot/uboot-bcm53xx/patches/0001-nand-brcmnand-add-iproc-support.patch b/package/boot/uboot-bcm53xx/patches/0001-nand-brcmnand-add-iproc-support.patch new file mode 100644 index 0000000000..fe6f4d944a --- /dev/null +++ b/package/boot/uboot-bcm53xx/patches/0001-nand-brcmnand-add-iproc-support.patch @@ -0,0 +1,199 @@ +From 854dc4b790ce1291326d52b8405ebe771bff2edd Mon Sep 17 00:00:00 2001 +From: Linus Walleij +Date: Wed, 8 Mar 2023 22:42:31 +0100 +Subject: [PATCH 1/5] nand: brcmnand: add iproc support + +Add support for the iproc Broadcom NAND controller, +used in Northstar SoCs for example. Based on the Linux +driver. + +Cc: Philippe Reynes +Cc: Dario Binacchi +Reviewed-by: Michael Trimarchi +Signed-off-by: Linus Walleij +Acked-by: William Zhang +Link: https://lore.kernel.org/all/20230308214231.378013-1-linus.walleij@linaro.org/ +Signed-off-by: Dario Binacchi +--- + drivers/mtd/nand/raw/Kconfig | 7 + + drivers/mtd/nand/raw/brcmnand/Makefile | 1 + + drivers/mtd/nand/raw/brcmnand/iproc_nand.c | 148 +++++++++++++++++++++ + 3 files changed, 156 insertions(+) + create mode 100644 drivers/mtd/nand/raw/brcmnand/iproc_nand.c + +--- a/drivers/mtd/nand/raw/Kconfig ++++ b/drivers/mtd/nand/raw/Kconfig +@@ -156,6 +156,13 @@ config NAND_BRCMNAND_63158 + help + Enable support for broadcom nand driver on bcm63158. + ++config NAND_BRCMNAND_IPROC ++ bool "Support Broadcom NAND controller on the iproc family" ++ depends on NAND_BRCMNAND ++ help ++ Enable support for broadcom nand driver on the Broadcom ++ iproc family such as Northstar (BCM5301x, BCM4708...) ++ + config NAND_DAVINCI + bool "Support TI Davinci NAND controller" + select SYS_NAND_SELF_INIT if TARGET_DA850EVM +--- a/drivers/mtd/nand/raw/brcmnand/Makefile ++++ b/drivers/mtd/nand/raw/brcmnand/Makefile +@@ -6,5 +6,6 @@ obj-$(CONFIG_NAND_BRCMNAND_6753) += bcm6 + obj-$(CONFIG_NAND_BRCMNAND_68360) += bcm68360_nand.o + obj-$(CONFIG_NAND_BRCMNAND_6838) += bcm6838_nand.o + obj-$(CONFIG_NAND_BRCMNAND_6858) += bcm6858_nand.o ++obj-$(CONFIG_NAND_BRCMNAND_IPROC) += iproc_nand.o + obj-$(CONFIG_NAND_BRCMNAND) += brcmnand.o + obj-$(CONFIG_NAND_BRCMNAND) += brcmnand_compat.o +--- /dev/null ++++ b/drivers/mtd/nand/raw/brcmnand/iproc_nand.c +@@ -0,0 +1,148 @@ ++// SPDX-License-Identifier: GPL-2.0 ++/* ++ * Code borrowed from the Linux driver ++ * Copyright (C) 2015 Broadcom Corporation ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include "brcmnand.h" ++ ++struct iproc_nand_soc { ++ struct brcmnand_soc soc; ++ void __iomem *idm_base; ++ void __iomem *ext_base; ++}; ++ ++#define IPROC_NAND_CTLR_READY_OFFSET 0x10 ++#define IPROC_NAND_CTLR_READY BIT(0) ++ ++#define IPROC_NAND_IO_CTRL_OFFSET 0x00 ++#define IPROC_NAND_APB_LE_MODE BIT(24) ++#define IPROC_NAND_INT_CTRL_READ_ENABLE BIT(6) ++ ++static bool iproc_nand_intc_ack(struct brcmnand_soc *soc) ++{ ++ struct iproc_nand_soc *priv = ++ container_of(soc, struct iproc_nand_soc, soc); ++ void __iomem *mmio = priv->ext_base + IPROC_NAND_CTLR_READY_OFFSET; ++ u32 val = brcmnand_readl(mmio); ++ ++ if (val & IPROC_NAND_CTLR_READY) { ++ brcmnand_writel(IPROC_NAND_CTLR_READY, mmio); ++ return true; ++ } ++ ++ return false; ++} ++ ++static void iproc_nand_intc_set(struct brcmnand_soc *soc, bool en) ++{ ++ struct iproc_nand_soc *priv = ++ container_of(soc, struct iproc_nand_soc, soc); ++ void __iomem *mmio = priv->idm_base + IPROC_NAND_IO_CTRL_OFFSET; ++ u32 val = brcmnand_readl(mmio); ++ ++ if (en) ++ val |= IPROC_NAND_INT_CTRL_READ_ENABLE; ++ else ++ val &= ~IPROC_NAND_INT_CTRL_READ_ENABLE; ++ ++ brcmnand_writel(val, mmio); ++} ++ ++static void iproc_nand_apb_access(struct brcmnand_soc *soc, bool prepare, ++ bool is_param) ++{ ++ struct iproc_nand_soc *priv = ++ container_of(soc, struct iproc_nand_soc, soc); ++ void __iomem *mmio = priv->idm_base + IPROC_NAND_IO_CTRL_OFFSET; ++ u32 val; ++ ++ val = brcmnand_readl(mmio); ++ ++ /* ++ * In the case of BE or when dealing with NAND data, always configure ++ * the APB bus to LE mode before accessing the FIFO and back to BE mode ++ * after the access is done ++ */ ++ if (IS_ENABLED(CONFIG_SYS_BIG_ENDIAN) || !is_param) { ++ if (prepare) ++ val |= IPROC_NAND_APB_LE_MODE; ++ else ++ val &= ~IPROC_NAND_APB_LE_MODE; ++ } else { /* when in LE accessing the parameter page, keep APB in BE */ ++ val &= ~IPROC_NAND_APB_LE_MODE; ++ } ++ ++ brcmnand_writel(val, mmio); ++} ++ ++static int iproc_nand_probe(struct udevice *dev) ++{ ++ struct udevice *pdev = dev; ++ struct iproc_nand_soc *priv = dev_get_priv(dev); ++ struct brcmnand_soc *soc; ++ struct resource res; ++ int ret; ++ ++ soc = &priv->soc; ++ ++ ret = dev_read_resource_byname(pdev, "iproc-idm", &res); ++ if (ret) ++ return ret; ++ ++ priv->idm_base = devm_ioremap(dev, res.start, resource_size(&res)); ++ if (IS_ERR(priv->idm_base)) ++ return PTR_ERR(priv->idm_base); ++ ++ ret = dev_read_resource_byname(pdev, "iproc-ext", &res); ++ if (ret) ++ return ret; ++ ++ priv->ext_base = devm_ioremap(dev, res.start, resource_size(&res)); ++ if (IS_ERR(priv->ext_base)) ++ return PTR_ERR(priv->ext_base); ++ ++ soc->ctlrdy_ack = iproc_nand_intc_ack; ++ soc->ctlrdy_set_enabled = iproc_nand_intc_set; ++ soc->prepare_data_bus = iproc_nand_apb_access; ++ ++ return brcmnand_probe(pdev, soc); ++} ++ ++static const struct udevice_id iproc_nand_dt_ids[] = { ++ { ++ .compatible = "brcm,nand-iproc", ++ }, ++ { /* sentinel */ } ++}; ++ ++U_BOOT_DRIVER(iproc_nand) = { ++ .name = "iproc-nand", ++ .id = UCLASS_MTD, ++ .of_match = iproc_nand_dt_ids, ++ .probe = iproc_nand_probe, ++ .priv_auto = sizeof(struct iproc_nand_soc), ++}; ++ ++void board_nand_init(void) ++{ ++ struct udevice *dev; ++ int ret; ++ ++ ret = uclass_get_device_by_driver(UCLASS_MTD, ++ DM_DRIVER_GET(iproc_nand), &dev); ++ if (ret && ret != -ENODEV) ++ pr_err("Failed to initialize %s. (error %d)\n", dev->name, ++ ret); ++} diff --git a/package/boot/uboot-bcm53xx/patches/0002-mtd-rawnand-nand_base-Handle-algorithm-selection.patch b/package/boot/uboot-bcm53xx/patches/0002-mtd-rawnand-nand_base-Handle-algorithm-selection.patch new file mode 100644 index 0000000000..eb2a5ec703 --- /dev/null +++ b/package/boot/uboot-bcm53xx/patches/0002-mtd-rawnand-nand_base-Handle-algorithm-selection.patch @@ -0,0 +1,80 @@ +From d75483f8892f3a0dfb8f5aa4147e72c02c8b034c Mon Sep 17 00:00:00 2001 +From: Linus Walleij +Date: Fri, 7 Apr 2023 15:40:05 +0200 +Subject: [PATCH 2/5] mtd: rawnand: nand_base: Handle algorithm selection + +For BRCMNAND with 1-bit BCH ECC (BCH-1) such as used on the +D-Link DIR-885L and DIR-890L routers, we need to explicitly +select the ECC like this in the device tree: + + nand-ecc-algo = "bch"; + nand-ecc-strength = <1>; + nand-ecc-step-size = <512>; + +This is handled by the Linux kernel but U-Boot core does +not respect this. Fix it up by parsing the algorithm and +preserve the behaviour using this property to select +software BCH as far as possible. + +Reviewed-by: Michael Trimarchi +Acked-by: William Zhang +Signed-off-by: Linus Walleij +Tested-by: Tom Rini [am335x_evm] +Link: https://lore.kernel.org/all/20230407134008.1939717-3-linus.walleij@linaro.org/ +Signed-off-by: Dario Binacchi +--- + drivers/mtd/nand/raw/nand_base.c | 29 +++++++++++++++++++++++++---- + 1 file changed, 25 insertions(+), 4 deletions(-) + +--- a/drivers/mtd/nand/raw/nand_base.c ++++ b/drivers/mtd/nand/raw/nand_base.c +@@ -4487,6 +4487,7 @@ EXPORT_SYMBOL(nand_detect); + static int nand_dt_init(struct mtd_info *mtd, struct nand_chip *chip, ofnode node) + { + int ret, ecc_mode = -1, ecc_strength, ecc_step; ++ int ecc_algo = NAND_ECC_UNKNOWN; + const char *str; + + ret = ofnode_read_s32_default(node, "nand-bus-width", -1); +@@ -4512,10 +4513,22 @@ static int nand_dt_init(struct mtd_info + ecc_mode = NAND_ECC_SOFT_BCH; + } + +- if (ecc_mode == NAND_ECC_SOFT) { +- str = ofnode_read_string(node, "nand-ecc-algo"); +- if (str && !strcmp(str, "bch")) +- ecc_mode = NAND_ECC_SOFT_BCH; ++ str = ofnode_read_string(node, "nand-ecc-algo"); ++ if (str) { ++ /* ++ * If we are in NAND_ECC_SOFT mode, just alter the ++ * soft mode to BCH here. No change of algorithm. ++ */ ++ if (ecc_mode == NAND_ECC_SOFT) { ++ if (!strcmp(str, "bch")) ++ ecc_mode = NAND_ECC_SOFT_BCH; ++ } else { ++ if (!strcmp(str, "bch")) { ++ ecc_algo = NAND_ECC_BCH; ++ } else if (!strcmp(str, "hamming")) { ++ ecc_algo = NAND_ECC_HAMMING; ++ } ++ } + } + + ecc_strength = ofnode_read_s32_default(node, +@@ -4529,6 +4542,14 @@ static int nand_dt_init(struct mtd_info + return -EINVAL; + } + ++ /* ++ * Chip drivers may have assigned default algorithms here, ++ * onlt override it if we have found something explicitly ++ * specified in the device tree. ++ */ ++ if (ecc_algo != NAND_ECC_UNKNOWN) ++ chip->ecc.algo = ecc_algo; ++ + if (ecc_mode >= 0) + chip->ecc.mode = ecc_mode; + diff --git a/package/boot/uboot-bcm53xx/patches/0003-arm-dts-Import-device-tree-for-Broadcom-Northstar.patch b/package/boot/uboot-bcm53xx/patches/0003-arm-dts-Import-device-tree-for-Broadcom-Northstar.patch new file mode 100644 index 0000000000..6a4eef77f8 --- /dev/null +++ b/package/boot/uboot-bcm53xx/patches/0003-arm-dts-Import-device-tree-for-Broadcom-Northstar.patch @@ -0,0 +1,659 @@ +From 3d6098a662b7ff5b80c4b75c54fcd1b2baf9f150 Mon Sep 17 00:00:00 2001 +From: Linus Walleij +Date: Mon, 24 Apr 2023 09:38:28 +0200 +Subject: [PATCH 3/5] arm: dts: Import device tree for Broadcom Northstar +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This brings in the main SoC device tree used by the +Broadcom Northstar chipset, i.e. BCM4709x and BCM5301x. +This is taken from the v6.3 Linux kernel. + +Cc: Rafał Miłecki +Signed-off-by: Linus Walleij +--- + arch/arm/dts/bcm5301x.dtsi | 581 ++++++++++++++++++++++++++++ + include/dt-bindings/clock/bcm-nsp.h | 51 +++ + 2 files changed, 632 insertions(+) + create mode 100644 arch/arm/dts/bcm5301x.dtsi + create mode 100644 include/dt-bindings/clock/bcm-nsp.h + +--- /dev/null ++++ b/arch/arm/dts/bcm5301x.dtsi +@@ -0,0 +1,581 @@ ++/* ++ * Broadcom BCM470X / BCM5301X ARM platform code. ++ * Generic DTS part for all BCM53010, BCM53011, BCM53012, BCM53014, BCM53015, ++ * BCM53016, BCM53017, BCM53018, BCM4707, BCM4708 and BCM4709 SoCs ++ * ++ * Copyright 2013-2014 Hauke Mehrtens ++ * ++ * Licensed under the GNU/GPL. See COPYING for details. ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++ ++/ { ++ #address-cells = <1>; ++ #size-cells = <1>; ++ interrupt-parent = <&gic>; ++ ++ chipcommon-a-bus@18000000 { ++ compatible = "simple-bus"; ++ ranges = <0x00000000 0x18000000 0x00001000>; ++ #address-cells = <1>; ++ #size-cells = <1>; ++ ++ uart0: serial@300 { ++ compatible = "ns16550"; ++ reg = <0x0300 0x100>; ++ interrupts = ; ++ clocks = <&iprocslow>; ++ status = "disabled"; ++ }; ++ ++ uart1: serial@400 { ++ compatible = "ns16550"; ++ reg = <0x0400 0x100>; ++ interrupts = ; ++ clocks = <&iprocslow>; ++ pinctrl-names = "default"; ++ pinctrl-0 = <&pinmux_uart1>; ++ status = "disabled"; ++ }; ++ }; ++ ++ mpcore-bus@19000000 { ++ compatible = "simple-bus"; ++ ranges = <0x00000000 0x19000000 0x00023000>; ++ #address-cells = <1>; ++ #size-cells = <1>; ++ ++ a9pll: arm_clk@0 { ++ #clock-cells = <0>; ++ compatible = "brcm,nsp-armpll"; ++ clocks = <&osc>; ++ reg = <0x00000 0x1000>; ++ }; ++ ++ scu@20000 { ++ compatible = "arm,cortex-a9-scu"; ++ reg = <0x20000 0x100>; ++ }; ++ ++ timer@20200 { ++ compatible = "arm,cortex-a9-global-timer"; ++ reg = <0x20200 0x100>; ++ interrupts = ; ++ clocks = <&periph_clk>; ++ }; ++ ++ timer@20600 { ++ compatible = "arm,cortex-a9-twd-timer"; ++ reg = <0x20600 0x20>; ++ interrupts = ; ++ clocks = <&periph_clk>; ++ }; ++ ++ watchdog@20620 { ++ compatible = "arm,cortex-a9-twd-wdt"; ++ reg = <0x20620 0x20>; ++ interrupts = ; ++ clocks = <&periph_clk>; ++ }; ++ ++ gic: interrupt-controller@21000 { ++ compatible = "arm,cortex-a9-gic"; ++ #interrupt-cells = <3>; ++ #address-cells = <0>; ++ interrupt-controller; ++ reg = <0x21000 0x1000>, ++ <0x20100 0x100>; ++ }; ++ ++ L2: cache-controller@22000 { ++ compatible = "arm,pl310-cache"; ++ reg = <0x22000 0x1000>; ++ cache-unified; ++ arm,shared-override; ++ prefetch-data = <1>; ++ prefetch-instr = <1>; ++ cache-level = <2>; ++ }; ++ }; ++ ++ pmu { ++ compatible = "arm,cortex-a9-pmu"; ++ interrupts = ++ , ++ ; ++ }; ++ ++ clocks { ++ #address-cells = <1>; ++ #size-cells = <1>; ++ ranges; ++ ++ osc: oscillator { ++ #clock-cells = <0>; ++ compatible = "fixed-clock"; ++ clock-frequency = <25000000>; ++ }; ++ ++ iprocmed: iprocmed { ++ #clock-cells = <0>; ++ compatible = "fixed-factor-clock"; ++ clocks = <&genpll BCM_NSP_GENPLL_IPROCFAST_CLK>; ++ clock-div = <2>; ++ clock-mult = <1>; ++ }; ++ ++ iprocslow: iprocslow { ++ #clock-cells = <0>; ++ compatible = "fixed-factor-clock"; ++ clocks = <&genpll BCM_NSP_GENPLL_IPROCFAST_CLK>; ++ clock-div = <4>; ++ clock-mult = <1>; ++ }; ++ ++ periph_clk: periph_clk { ++ #clock-cells = <0>; ++ compatible = "fixed-factor-clock"; ++ clocks = <&a9pll>; ++ clock-div = <2>; ++ clock-mult = <1>; ++ }; ++ }; ++ ++ axi@18000000 { ++ compatible = "brcm,bus-axi"; ++ reg = <0x18000000 0x1000>; ++ ranges = <0x00000000 0x18000000 0x00100000>; ++ #address-cells = <1>; ++ #size-cells = <1>; ++ ++ #interrupt-cells = <1>; ++ interrupt-map-mask = <0x000fffff 0xffff>; ++ interrupt-map = ++ /* ChipCommon */ ++ <0x00000000 0 &gic GIC_SPI 85 IRQ_TYPE_LEVEL_HIGH>, ++ ++ /* Switch Register Access Block */ ++ <0x00007000 0 &gic GIC_SPI 95 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00007000 1 &gic GIC_SPI 96 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00007000 2 &gic GIC_SPI 97 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00007000 3 &gic GIC_SPI 98 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00007000 4 &gic GIC_SPI 99 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00007000 5 &gic GIC_SPI 100 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00007000 6 &gic GIC_SPI 101 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00007000 7 &gic GIC_SPI 102 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00007000 8 &gic GIC_SPI 103 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00007000 9 &gic GIC_SPI 104 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00007000 10 &gic GIC_SPI 105 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00007000 11 &gic GIC_SPI 106 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00007000 12 &gic GIC_SPI 107 IRQ_TYPE_LEVEL_HIGH>, ++ ++ /* PCIe Controller 0 */ ++ <0x00012000 0 &gic GIC_SPI 126 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00012000 1 &gic GIC_SPI 127 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00012000 2 &gic GIC_SPI 128 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00012000 3 &gic GIC_SPI 129 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00012000 4 &gic GIC_SPI 130 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00012000 5 &gic GIC_SPI 131 IRQ_TYPE_LEVEL_HIGH>, ++ ++ /* PCIe Controller 1 */ ++ <0x00013000 0 &gic GIC_SPI 132 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00013000 1 &gic GIC_SPI 133 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00013000 2 &gic GIC_SPI 134 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00013000 3 &gic GIC_SPI 135 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00013000 4 &gic GIC_SPI 136 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00013000 5 &gic GIC_SPI 137 IRQ_TYPE_LEVEL_HIGH>, ++ ++ /* PCIe Controller 2 */ ++ <0x00014000 0 &gic GIC_SPI 138 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00014000 1 &gic GIC_SPI 138 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00014000 2 &gic GIC_SPI 140 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00014000 3 &gic GIC_SPI 141 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00014000 4 &gic GIC_SPI 142 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00014000 5 &gic GIC_SPI 143 IRQ_TYPE_LEVEL_HIGH>, ++ ++ /* USB 2.0 Controller */ ++ <0x00021000 0 &gic GIC_SPI 79 IRQ_TYPE_LEVEL_HIGH>, ++ ++ /* USB 3.0 Controller */ ++ <0x00023000 0 &gic GIC_SPI 80 IRQ_TYPE_LEVEL_HIGH>, ++ ++ /* Ethernet Controller 0 */ ++ <0x00024000 0 &gic GIC_SPI 147 IRQ_TYPE_LEVEL_HIGH>, ++ ++ /* Ethernet Controller 1 */ ++ <0x00025000 0 &gic GIC_SPI 148 IRQ_TYPE_LEVEL_HIGH>, ++ ++ /* Ethernet Controller 2 */ ++ <0x00026000 0 &gic GIC_SPI 149 IRQ_TYPE_LEVEL_HIGH>, ++ ++ /* Ethernet Controller 3 */ ++ <0x00027000 0 &gic GIC_SPI 150 IRQ_TYPE_LEVEL_HIGH>, ++ ++ /* NAND Controller */ ++ <0x00028000 0 &gic GIC_SPI 64 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00028000 1 &gic GIC_SPI 65 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00028000 2 &gic GIC_SPI 66 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00028000 3 &gic GIC_SPI 67 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00028000 4 &gic GIC_SPI 68 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00028000 5 &gic GIC_SPI 69 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00028000 6 &gic GIC_SPI 70 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00028000 7 &gic GIC_SPI 71 IRQ_TYPE_LEVEL_HIGH>; ++ ++ chipcommon: chipcommon@0 { ++ reg = <0x00000000 0x1000>; ++ ++ gpio-controller; ++ #gpio-cells = <2>; ++ interrupt-controller; ++ #interrupt-cells = <2>; ++ }; ++ ++ pcie0: pcie@12000 { ++ reg = <0x00012000 0x1000>; ++ }; ++ ++ pcie1: pcie@13000 { ++ reg = <0x00013000 0x1000>; ++ }; ++ ++ pcie2: pcie@14000 { ++ reg = <0x00014000 0x1000>; ++ }; ++ ++ usb2: usb2@21000 { ++ reg = <0x00021000 0x1000>; ++ ++ #address-cells = <1>; ++ #size-cells = <1>; ++ ranges; ++ ++ interrupt-parent = <&gic>; ++ ++ ehci: usb@21000 { ++ #usb-cells = <0>; ++ ++ compatible = "generic-ehci"; ++ reg = <0x00021000 0x1000>; ++ interrupts = ; ++ phys = <&usb2_phy>; ++ ++ #address-cells = <1>; ++ #size-cells = <0>; ++ ++ ehci_port1: port@1 { ++ reg = <1>; ++ #trigger-source-cells = <0>; ++ }; ++ ++ ehci_port2: port@2 { ++ reg = <2>; ++ #trigger-source-cells = <0>; ++ }; ++ }; ++ ++ ohci: usb@22000 { ++ #usb-cells = <0>; ++ ++ compatible = "generic-ohci"; ++ reg = <0x00022000 0x1000>; ++ interrupts = ; ++ ++ #address-cells = <1>; ++ #size-cells = <0>; ++ ++ ohci_port1: port@1 { ++ reg = <1>; ++ #trigger-source-cells = <0>; ++ }; ++ ++ ohci_port2: port@2 { ++ reg = <2>; ++ #trigger-source-cells = <0>; ++ }; ++ }; ++ }; ++ ++ usb3: usb3@23000 { ++ reg = <0x00023000 0x1000>; ++ ++ #address-cells = <1>; ++ #size-cells = <1>; ++ ranges; ++ ++ interrupt-parent = <&gic>; ++ ++ xhci: usb@23000 { ++ #usb-cells = <0>; ++ ++ compatible = "generic-xhci"; ++ reg = <0x00023000 0x1000>; ++ interrupts = ; ++ phys = <&usb3_phy>; ++ phy-names = "usb"; ++ ++ #address-cells = <1>; ++ #size-cells = <0>; ++ ++ xhci_port1: port@1 { ++ reg = <1>; ++ #trigger-source-cells = <0>; ++ }; ++ }; ++ }; ++ ++ gmac0: ethernet@24000 { ++ reg = <0x24000 0x800>; ++ }; ++ ++ gmac1: ethernet@25000 { ++ reg = <0x25000 0x800>; ++ }; ++ ++ gmac2: ethernet@26000 { ++ reg = <0x26000 0x800>; ++ }; ++ ++ gmac3: ethernet@27000 { ++ reg = <0x27000 0x800>; ++ }; ++ }; ++ ++ pwm: pwm@18002000 { ++ compatible = "brcm,iproc-pwm"; ++ reg = <0x18002000 0x28>; ++ clocks = <&osc>; ++ #pwm-cells = <3>; ++ status = "disabled"; ++ }; ++ ++ mdio: mdio@18003000 { ++ compatible = "brcm,iproc-mdio"; ++ reg = <0x18003000 0x8>; ++ #size-cells = <0>; ++ #address-cells = <1>; ++ }; ++ ++ mdio-mux@18003000 { ++ compatible = "mdio-mux-mmioreg", "mdio-mux"; ++ mdio-parent-bus = <&mdio>; ++ #address-cells = <1>; ++ #size-cells = <0>; ++ reg = <0x18003000 0x4>; ++ mux-mask = <0x200>; ++ ++ mdio@0 { ++ reg = <0x0>; ++ #address-cells = <1>; ++ #size-cells = <0>; ++ ++ usb3_phy: usb3-phy@10 { ++ compatible = "brcm,ns-ax-usb3-phy"; ++ reg = <0x10>; ++ usb3-dmp-syscon = <&usb3_dmp>; ++ #phy-cells = <0>; ++ status = "disabled"; ++ }; ++ }; ++ }; ++ ++ usb3_dmp: syscon@18105000 { ++ reg = <0x18105000 0x1000>; ++ }; ++ ++ uart2: serial@18008000 { ++ compatible = "ns16550a"; ++ reg = <0x18008000 0x20>; ++ clocks = <&iprocslow>; ++ interrupts = ; ++ reg-shift = <2>; ++ status = "disabled"; ++ }; ++ ++ i2c0: i2c@18009000 { ++ compatible = "brcm,iproc-i2c"; ++ reg = <0x18009000 0x50>; ++ interrupts = ; ++ #address-cells = <1>; ++ #size-cells = <0>; ++ clock-frequency = <100000>; ++ status = "disabled"; ++ }; ++ ++ dmu-bus@1800c000 { ++ compatible = "simple-bus"; ++ ranges = <0 0x1800c000 0x1000>; ++ #address-cells = <1>; ++ #size-cells = <1>; ++ ++ cru-bus@100 { ++ compatible = "brcm,ns-cru", "simple-mfd"; ++ reg = <0x100 0x1a4>; ++ ranges; ++ #address-cells = <1>; ++ #size-cells = <1>; ++ ++ lcpll0: clock-controller@100 { ++ #clock-cells = <1>; ++ compatible = "brcm,nsp-lcpll0"; ++ reg = <0x100 0x14>; ++ clocks = <&osc>; ++ clock-output-names = "lcpll0", "pcie_phy", ++ "sdio", "ddr_phy"; ++ }; ++ ++ genpll: clock-controller@140 { ++ #clock-cells = <1>; ++ compatible = "brcm,nsp-genpll"; ++ reg = <0x140 0x24>; ++ clocks = <&osc>; ++ clock-output-names = "genpll", "phy", ++ "ethernetclk", ++ "usbclk", "iprocfast", ++ "sata1", "sata2"; ++ }; ++ ++ usb2_phy: phy@164 { ++ compatible = "brcm,ns-usb2-phy"; ++ reg = <0x164 0x4>; ++ brcm,syscon-clkset = <&cru_clkset>; ++ clocks = <&genpll BCM_NSP_GENPLL_USB_PHY_REF_CLK>; ++ clock-names = "phy-ref-clk"; ++ #phy-cells = <0>; ++ }; ++ ++ cru_clkset: syscon@180 { ++ compatible = "brcm,cru-clkset", "syscon"; ++ reg = <0x180 0x4>; ++ }; ++ ++ pinctrl: pinctrl@1c0 { ++ compatible = "brcm,bcm4708-pinmux"; ++ reg = <0x1c0 0x24>; ++ reg-names = "cru_gpio_control"; ++ ++ spi-pins { ++ groups = "spi_grp"; ++ function = "spi"; ++ }; ++ ++ pinmux_i2c: i2c-pins { ++ groups = "i2c_grp"; ++ function = "i2c"; ++ }; ++ ++ pinmux_pwm: pwm-pins { ++ groups = "pwm0_grp", "pwm1_grp", ++ "pwm2_grp", "pwm3_grp"; ++ function = "pwm"; ++ }; ++ ++ pinmux_uart1: uart1-pins { ++ groups = "uart1_grp"; ++ function = "uart1"; ++ }; ++ }; ++ ++ thermal: thermal@2c0 { ++ compatible = "brcm,ns-thermal"; ++ reg = <0x2c0 0x10>; ++ #thermal-sensor-cells = <0>; ++ }; ++ }; ++ }; ++ ++ srab: ethernet-switch@18007000 { ++ compatible = "brcm,bcm53011-srab", "brcm,bcm5301x-srab"; ++ reg = <0x18007000 0x1000>; ++ ++ status = "disabled"; ++ ++ /* ports are defined in board DTS */ ++ ports { ++ #address-cells = <1>; ++ #size-cells = <0>; ++ }; ++ }; ++ ++ rng: rng@18004000 { ++ compatible = "brcm,bcm5301x-rng"; ++ reg = <0x18004000 0x14>; ++ }; ++ ++ nand_controller: nand-controller@18028000 { ++ compatible = "brcm,nand-iproc", "brcm,brcmnand-v6.1", "brcm,brcmnand"; ++ reg = <0x18028000 0x600>, <0x1811a408 0x600>, <0x18028f00 0x20>; ++ reg-names = "nand", "iproc-idm", "iproc-ext"; ++ interrupts = ; ++ ++ #address-cells = <1>; ++ #size-cells = <0>; ++ ++ brcm,nand-has-wp; ++ }; ++ ++ spi@18029200 { ++ compatible = "brcm,spi-nsp-qspi", "brcm,spi-bcm-qspi"; ++ reg = <0x18029200 0x184>, ++ <0x18029000 0x124>, ++ <0x1811b408 0x004>, ++ <0x180293a0 0x01c>; ++ reg-names = "mspi", "bspi", "intr_regs", "intr_status_reg"; ++ interrupts = , ++ , ++ , ++ , ++ , ++ , ++ ; ++ interrupt-names = "mspi_done", ++ "mspi_halted", ++ "spi_lr_fullness_reached", ++ "spi_lr_session_aborted", ++ "spi_lr_impatient", ++ "spi_lr_session_done", ++ "spi_lr_overread"; ++ clocks = <&iprocmed>; ++ clock-names = "iprocmed"; ++ num-cs = <2>; ++ #address-cells = <1>; ++ #size-cells = <0>; ++ ++ spi_nor: flash@0 { ++ compatible = "jedec,spi-nor"; ++ reg = <0>; ++ spi-max-frequency = <20000000>; ++ status = "disabled"; ++ ++ partitions { ++ compatible = "brcm,bcm947xx-cfe-partitions"; ++ }; ++ }; ++ }; ++ ++ thermal-zones { ++ cpu_thermal: cpu-thermal { ++ polling-delay-passive = <0>; ++ polling-delay = <1000>; ++ coefficients = <(-556) 418000>; ++ thermal-sensors = <&thermal>; ++ ++ trips { ++ cpu-crit { ++ temperature = <125000>; ++ hysteresis = <0>; ++ type = "critical"; ++ }; ++ }; ++ ++ cooling-maps { ++ }; ++ }; ++ }; ++}; +--- /dev/null ++++ b/include/dt-bindings/clock/bcm-nsp.h +@@ -0,0 +1,51 @@ ++/* ++ * BSD LICENSE ++ * ++ * Copyright(c) 2015 Broadcom Corporation. All rights reserved. ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * * Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * * Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * * Neither the name of Broadcom Corporation nor the names of its ++ * contributors may be used to endorse or promote products derived ++ * from this software without specific prior written permission. ++ * ++ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ++ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ++ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ++ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ++ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ++ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ++ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ++ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ++ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ++ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ++ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ */ ++ ++#ifndef _CLOCK_BCM_NSP_H ++#define _CLOCK_BCM_NSP_H ++ ++/* GENPLL clock channel ID */ ++#define BCM_NSP_GENPLL 0 ++#define BCM_NSP_GENPLL_PHY_CLK 1 ++#define BCM_NSP_GENPLL_ENET_SW_CLK 2 ++#define BCM_NSP_GENPLL_USB_PHY_REF_CLK 3 ++#define BCM_NSP_GENPLL_IPROCFAST_CLK 4 ++#define BCM_NSP_GENPLL_SATA1_CLK 5 ++#define BCM_NSP_GENPLL_SATA2_CLK 6 ++ ++/* LCPLL0 clock channel ID */ ++#define BCM_NSP_LCPLL0 0 ++#define BCM_NSP_LCPLL0_PCIE_PHY_REF_CLK 1 ++#define BCM_NSP_LCPLL0_SDIO_CLK 2 ++#define BCM_NSP_LCPLL0_DDR_PHY_CLK 3 ++ ++#endif /* _CLOCK_BCM_NSP_H */ diff --git a/package/boot/uboot-bcm53xx/patches/0004-arm-Add-support-for-the-Broadcom-Northstar-SoCs.patch b/package/boot/uboot-bcm53xx/patches/0004-arm-Add-support-for-the-Broadcom-Northstar-SoCs.patch new file mode 100644 index 0000000000..92eaa46e51 --- /dev/null +++ b/package/boot/uboot-bcm53xx/patches/0004-arm-Add-support-for-the-Broadcom-Northstar-SoCs.patch @@ -0,0 +1,66 @@ +From b81ea0a64b01ae42e8b41d2a8b9a3fabffe97489 Mon Sep 17 00:00:00 2001 +From: Linus Walleij +Date: Mon, 24 Apr 2023 09:38:29 +0200 +Subject: [PATCH 4/5] arm: Add support for the Broadcom Northstar SoCs +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The original Northstar is an ARM SoC series that comprise +BCM4709x and BCM5301x and uses a dual-core Cortex A9, the +global timer and a few other things. + +This series should not be confused with North Star Plus +(NSP) which is partly supported by U-Boot already. + +The SoC is well supported by the Linux kernel and OpenWrt +as it is used in many routers. + +Since we currently don't need any chip-specific quirks +and can get the system up from just the device tree, a +mach-* directory doesn't even need to be added, just +some small Kconfig fragments. + +Cc: Rafał Miłecki +Signed-off-by: Linus Walleij +--- + arch/arm/Kconfig | 21 ++++++++++++++++++++- + 1 file changed, 20 insertions(+), 1 deletion(-) + +--- a/arch/arm/Kconfig ++++ b/arch/arm/Kconfig +@@ -357,7 +357,7 @@ config SYS_ARM_ARCH + + choice + prompt "Select the ARM data write cache policy" +- default SYS_ARM_CACHE_WRITETHROUGH if TARGET_BCMCYGNUS || RZA1 ++ default SYS_ARM_CACHE_WRITETHROUGH if TARGET_BCMCYGNUS || TARGET_BCMNS || RZA1 + default SYS_ARM_CACHE_WRITEBACK + + config SYS_ARM_CACHE_WRITEBACK +@@ -670,6 +670,25 @@ config TARGET_BCMCYGNUS + imply HASH_VERIFY + imply NETDEVICES + ++config TARGET_BCMNS ++ bool "Support Broadcom Northstar" ++ select CPU_V7A ++ select DM ++ select DM_GPIO ++ select DM_SERIAL ++ select OF_CONTROL ++ select TIMER ++ select SYS_NS16550 ++ select ARM_GLOBAL_TIMER ++ imply SYS_THUMB_BUILD ++ imply MTD_RAW_NAND ++ imply NAND_BRCMNAND ++ imply NAND_BRCMNAND_IPROC ++ help ++ Support for Broadcom Northstar SoCs. NS is a dual-core 32-bit ++ ARMv7 Cortex-A9 SoC family including BCM4708, BCM47094, ++ BCM5301x etc. ++ + config TARGET_BCMNS2 + bool "Support Broadcom Northstar2" + select ARM64 diff --git a/package/boot/uboot-bcm53xx/patches/0005-board-Add-new-Broadcom-Northstar-board.patch b/package/boot/uboot-bcm53xx/patches/0005-board-Add-new-Broadcom-Northstar-board.patch new file mode 100644 index 0000000000..158718133d --- /dev/null +++ b/package/boot/uboot-bcm53xx/patches/0005-board-Add-new-Broadcom-Northstar-board.patch @@ -0,0 +1,372 @@ +From 652a6fa45b6c9d52dd9685fc12ad662e54a9092e Mon Sep 17 00:00:00 2001 +From: Linus Walleij +Date: Mon, 24 Apr 2023 09:38:30 +0200 +Subject: [PATCH 5/5] board: Add new Broadcom Northstar board +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This adds a simple Northstar "BRCMNS" board to be used with +the BCM4708x and BCM5301x chips. + +The main intention is to use this with the D-Link DIR-890L +and DIR-885L routers for loading the kernel into RAM from +NAND memory using the BCH-1 ECC and using the separately +submitted SEAMA load command, so we are currently not adding +support for things such as networking. + +The DTS file is a multiplatform NorthStar board, designed to +be usable with several NorthStar designs by avoiding any +particulars not related to the operation of U-Boot. + +If other board need other ECC for example, they need to +create a separate DTS file and augment the code, but I don't +know if any other users will turn up. + +Cc: Rafał Miłecki +Signed-off-by: Linus Walleij +--- + arch/arm/Kconfig | 1 + + arch/arm/dts/Makefile | 2 ++ + arch/arm/dts/ns-board.dts | 57 ++++++++++++++++++++++++++++++ + board/broadcom/bcmns/Kconfig | 12 +++++++ + board/broadcom/bcmns/MAINTAINERS | 6 ++++ + board/broadcom/bcmns/Makefile | 2 ++ + board/broadcom/bcmns/ns.c | 60 ++++++++++++++++++++++++++++++++ + configs/bcmns_defconfig | 41 ++++++++++++++++++++++ + doc/board/broadcom/index.rst | 1 + + doc/board/broadcom/northstar.rst | 44 +++++++++++++++++++++++ + include/configs/bcmns.h | 49 ++++++++++++++++++++++++++ + 11 files changed, 275 insertions(+) + create mode 100644 arch/arm/dts/ns-board.dts + create mode 100644 board/broadcom/bcmns/Kconfig + create mode 100644 board/broadcom/bcmns/MAINTAINERS + create mode 100644 board/broadcom/bcmns/Makefile + create mode 100644 board/broadcom/bcmns/ns.c + create mode 100644 configs/bcmns_defconfig + create mode 100644 doc/board/broadcom/northstar.rst + create mode 100644 include/configs/bcmns.h + +--- a/arch/arm/Kconfig ++++ b/arch/arm/Kconfig +@@ -2286,6 +2286,7 @@ source "board/Marvell/octeontx2/Kconfig" + source "board/armltd/vexpress/Kconfig" + source "board/armltd/vexpress64/Kconfig" + source "board/cortina/presidio-asic/Kconfig" ++source "board/broadcom/bcmns/Kconfig" + source "board/broadcom/bcmns3/Kconfig" + source "board/cavium/thunderx/Kconfig" + source "board/eets/pdu001/Kconfig" +--- a/arch/arm/dts/Makefile ++++ b/arch/arm/dts/Makefile +@@ -1185,6 +1185,8 @@ dtb-$(CONFIG_ARCH_BCM283X) += \ + bcm2837-rpi-cm3-io3.dtb \ + bcm2711-rpi-4-b.dtb + ++dtb-$(CONFIG_TARGET_BCMNS) += ns-board.dtb ++ + dtb-$(CONFIG_TARGET_BCMNS3) += ns3-board.dtb + + dtb-$(CONFIG_ARCH_BCMSTB) += bcm7xxx.dtb +--- /dev/null ++++ b/arch/arm/dts/ns-board.dts +@@ -0,0 +1,57 @@ ++// SPDX-License-Identifier: GPL-2.0+ ++ ++/dts-v1/; ++ ++#include "bcm5301x.dtsi" ++ ++/ { ++ /* ++ * The Northstar does not have a proper fallback compatible, but ++ * these basic chips will suffice. ++ */ ++ model = "Northstar model"; ++ compatible = "brcm,bcm47094", "brcm,bcm4708"; ++ #address-cells = <1>; ++ #size-cells = <1>; ++ interrupt-parent = <&gic>; ++ ++ memory { ++ device_type = "memory"; ++ reg = <0x00000000 0x08000000>, ++ <0x88000000 0x08000000>; ++ }; ++ ++ aliases { ++ serial0 = &uart0; ++ }; ++ ++ chosen { ++ stdout-path = "serial0:115200n8"; ++ }; ++ ++ nand-controller@18028000 { ++ nandcs: nand@0 { ++ compatible = "brcm,nandcs"; ++ reg = <0>; ++ #address-cells = <1>; ++ #size-cells = <1>; ++ ++ /* ++ * Same as using the bcm5301x-nand-cs0-bch1.dtsi ++ * include from the Linux kernel. ++ */ ++ nand-ecc-algo = "bch"; ++ nand-ecc-strength = <1>; ++ nand-ecc-step-size = <512>; ++ ++ partitions { ++ compatible = "brcm,bcm947xx-cfe-partitions"; ++ }; ++ }; ++ }; ++}; ++ ++&uart0 { ++ clock-frequency = <125000000>; ++ status = "okay"; ++}; +--- /dev/null ++++ b/board/broadcom/bcmns/Kconfig +@@ -0,0 +1,12 @@ ++if TARGET_BCMNS ++ ++config SYS_BOARD ++ default "bcmns" ++ ++config SYS_VENDOR ++ default "broadcom" ++ ++config SYS_CONFIG_NAME ++ default "bcmns" ++ ++endif +--- /dev/null ++++ b/board/broadcom/bcmns/MAINTAINERS +@@ -0,0 +1,6 @@ ++BCMNS BOARD ++M: Linus Walleij ++S: Maintained ++F: board/broadcom/bcmnsp/ ++F: configs/bcmnsp_defconfig ++F: include/configs/bcmnsp.h +--- /dev/null ++++ b/board/broadcom/bcmns/Makefile +@@ -0,0 +1,2 @@ ++# SPDX-License-Identifier: GPL-2.0-or-later ++obj-y := ns.o +--- /dev/null ++++ b/board/broadcom/bcmns/ns.c +@@ -0,0 +1,60 @@ ++// SPDX-License-Identifier: GPL-2.0+ ++/* ++ * Broadcom Northstar generic board set-up code ++ * Copyright (C) 2023 Linus Walleij ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++DECLARE_GLOBAL_DATA_PTR; ++ ++int dram_init(void) ++{ ++ return fdtdec_setup_mem_size_base(); ++} ++ ++int dram_init_banksize(void) ++{ ++ return fdtdec_setup_memory_banksize(); ++} ++ ++int board_late_init(void) ++{ ++ /* LEDs etc can be initialized here */ ++ return 0; ++} ++ ++int board_init(void) ++{ ++ return 0; ++} ++ ++void reset_cpu(void) ++{ ++} ++ ++int print_cpuinfo(void) ++{ ++ printf("BCMNS Northstar SoC\n"); ++ return 0; ++} ++ ++int misc_init_r(void) ++{ ++ return 0; ++} ++ ++int ft_board_setup(void *fdt, struct bd_info *bd) ++{ ++ printf("Northstar board setup: DTB at 0x%08lx\n", (ulong)fdt); ++ return 0; ++} ++ +--- /dev/null ++++ b/configs/bcmns_defconfig +@@ -0,0 +1,41 @@ ++CONFIG_ARM=y ++CONFIG_TARGET_BCMNS=y ++CONFIG_TEXT_BASE=0x00008000 ++CONFIG_SYS_MALLOC_LEN=0x2000000 ++CONFIG_SYS_MALLOC_F_LEN=0x8000 ++CONFIG_NR_DRAM_BANKS=2 ++CONFIG_DEFAULT_DEVICE_TREE="ns-board" ++CONFIG_IDENT_STRING="Broadcom Northstar" ++CONFIG_SYS_LOAD_ADDR=0x00008000 ++CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y ++CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x00100000 ++# CONFIG_BOOTSTD is not set ++CONFIG_AUTOBOOT_KEYED=y ++CONFIG_AUTOBOOT_PROMPT="Boot Northstar system in %d seconds\n" ++CONFIG_BOOTDELAY=1 ++CONFIG_USE_BOOTCOMMAND=y ++CONFIG_BOOTCOMMAND="run bootcmd_dlink_dir8xxl" ++CONFIG_SYS_PROMPT="northstar> " ++CONFIG_ENV_VARS_UBOOT_CONFIG=y ++CONFIG_OF_BOARD_SETUP=y ++CONFIG_OF_STDOUT_VIA_ALIAS=y ++CONFIG_DISPLAY_BOARDINFO_LATE=y ++CONFIG_HUSH_PARSER=y ++CONFIG_SYS_MAXARGS=64 ++CONFIG_CMD_SEAMA=y ++CONFIG_CMD_BOOTZ=y ++CONFIG_CMD_CACHE=y ++CONFIG_OF_EMBED=y ++CONFIG_USE_HOSTNAME=y ++CONFIG_HOSTNAME="NS" ++CONFIG_CLK=y ++CONFIG_MTD=y ++CONFIG_DM_MTD=y ++CONFIG_MTD_RAW_NAND=y ++CONFIG_NAND_BRCMNAND=y ++CONFIG_SYS_NAND_ONFI_DETECTION=y ++CONFIG_CMD_NAND=y ++CONFIG_DM_SERIAL=y ++CONFIG_SYS_NS16550=y ++# CONFIG_NET is not set ++# CONFIG_EFI_LOADER is not set +--- a/doc/board/broadcom/index.rst ++++ b/doc/board/broadcom/index.rst +@@ -9,3 +9,4 @@ Broadcom + + bcm7xxx + raspberrypi ++ northstar +--- /dev/null ++++ b/doc/board/broadcom/northstar.rst +@@ -0,0 +1,44 @@ ++.. SPDX-License-Identifier: GPL-2.0+ ++.. Copyright (C) 2023 Linus Walleij ++ ++Broadcom Northstar Boards ++========================= ++ ++This document describes how to use U-Boot on the Broadcom Northstar ++boards, comprised of the Cortex A9 ARM-based BCM470x and BCM5301x SoCs. These ++were introduced in 2012-2013 and some of them are also called StrataGX. ++ ++Northstar is part of the iProc SoC family. ++ ++A good overview of these boards can be found in Jon Mason's presentation ++"Enabling New Hardware in U-Boot" where the difference between Northstar ++and Northstar Plus and Northstar 2 (Aarch64) is addressed. ++ ++The ROM in the Northstar SoC will typically look into NOR flash memory ++for a boot loader, and the way this works is undocumented. It should be ++possible to execute U-Boot as the first binary from the NOR flash but ++this usage path is unexplored. Please add information if you know more. ++ ++D-Link Boards ++------------- ++ ++When we use U-Boot with D-Link routers, the NOR flash has a boot loader ++and web server that can re-flash the bigger NAND flash memory for object ++code in the SEAMA format, so on these platforms U-Boot is converted into ++a SEAMA binary and installed in the SoC using the flash tool resident in ++the NOR flash. Details can be found in the OpenWrt project codebase. ++ ++Configure ++--------- ++ ++.. code-block:: console ++ ++ $ make CROSS_COMPILE=${CROSS_COMPILE} bcmns_defconfig ++ ++Build ++----- ++ ++.. code-block:: console ++ ++ $ make CROSS_COMPILE=${CROSS_COMPILE} ++ $ ${CROSS_COMPILE}strip u-boot +--- /dev/null ++++ b/include/configs/bcmns.h +@@ -0,0 +1,49 @@ ++/* SPDX-License-Identifier: GPL-2.0+ */ ++ ++#ifndef __BCM_NS_H ++#define __BCM_NS_H ++ ++#include ++ ++/* Physical Memory Map */ ++#define V2M_BASE 0x00000000 ++#define PHYS_SDRAM_1 V2M_BASE ++ ++#define CFG_SYS_SDRAM_BASE PHYS_SDRAM_1 ++ ++/* Called "periph_clk" in Linux, used by the global timer */ ++#define CFG_SYS_HZ_CLOCK 500000000 ++ ++/* Called "iprocslow" in Linux */ ++#define CFG_SYS_NS16550_CLK 125000000 ++ ++/* console configuration */ ++#define CONSOLE_ARGS "console_args=console=ttyS0,115200n8\0" ++#define MAX_CPUS "max_cpus=maxcpus=2\0" ++#define EXTRA_ARGS "extra_args=earlycon=uart8250,mmio32,0x18000300\0" ++ ++#define BASE_ARGS "${console_args} ${extra_args} ${pcie_args}" \ ++ " ${max_cpus} ${log_level} ${reserved_mem}" ++#define SETBOOTARGS "setbootargs=setenv bootargs " BASE_ARGS "\0" ++ ++#define KERNEL_LOADADDR_CFG \ ++ "loadaddr=0x01000000\0" \ ++ "dtb_loadaddr=0x02000000\0" ++ ++/* ++ * Hardcoded for the only boards we support, if you add more ++ * boards, add a more clever bootcmd! ++ */ ++#define NS_BOOTCMD "bootcmd_dlink_dir8xxl=seama 0x00fe0000; go 0x01000000" ++ ++#define ARCH_ENV_SETTINGS \ ++ CONSOLE_ARGS \ ++ MAX_CPUS \ ++ EXTRA_ARGS \ ++ KERNEL_LOADADDR_CFG \ ++ NS_BOOTCMD ++ ++#define CFG_EXTRA_ENV_SETTINGS \ ++ ARCH_ENV_SETTINGS ++ ++#endif /* __BCM_NS_H */ diff --git a/package/boot/uboot-envtools/files/mediatek_filogic b/package/boot/uboot-envtools/files/mediatek_filogic index 535c702c2a..32eb9a76a5 100644 --- a/package/boot/uboot-envtools/files/mediatek_filogic +++ b/package/boot/uboot-envtools/files/mediatek_filogic @@ -53,7 +53,7 @@ mercusys,mr90x-v1) ubootenv_add_uci_config "$envdev" "0x0" "0x20000" "0x20000" "1" ;; netgear,wax220) - ubootenv_add_uci_config "/dev/mtd5" "0x0" "0x20000" "0x20000" + ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x20000" "0x20000" ;; xiaomi,mi-router-wr30u-112m-nmbm|\ xiaomi,mi-router-wr30u-stock|\ diff --git a/package/kernel/mac80211/patches/rt2x00/998-wifi-rt2x00-rework-MT7620-PA-LNA-RF-calibration.patch b/package/kernel/mac80211/patches/rt2x00/998-wifi-rt2x00-rework-MT7620-PA-LNA-RF-calibration.patch index 7fdad63976..5f6f5140d9 100644 --- a/package/kernel/mac80211/patches/rt2x00/998-wifi-rt2x00-rework-MT7620-PA-LNA-RF-calibration.patch +++ b/package/kernel/mac80211/patches/rt2x00/998-wifi-rt2x00-rework-MT7620-PA-LNA-RF-calibration.patch @@ -3,8 +3,6 @@ Date: Tue, 25 Jul 2023 20:05:06 +0800 Subject: [PATCH] wifi: rt2x00: rework MT7620 PA/LNA RF calibration 1. Move MT7620 PA/LNA calibration code to dedicated functions. - Calibration stage 1 is executed before configuring channels and - stage 2 is executed after configuring channels. 2. For external PA/LNA devices, restore RF and BBP registers before R-Calibration. 3. Do Rx DCOC calibration again before RXIQ calibration. @@ -21,23 +19,13 @@ Subject: [PATCH] wifi: rt2x00: rework MT7620 PA/LNA RF calibration Signed-off-by: Shiji Yang --- - .../net/wireless/ralink/rt2x00/rt2800lib.c | 318 +++++++++++------- + .../net/wireless/ralink/rt2x00/rt2800lib.c | 306 ++++++++++-------- drivers/net/wireless/ralink/rt2x00/rt2x00.h | 6 + - 2 files changed, 194 insertions(+), 130 deletions(-) + 2 files changed, 182 insertions(+), 130 deletions(-) --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -@@ -62,6 +62,9 @@ MODULE_PARM_DESC(watchdog, "Enable watch - rt2800_regbusy_read((__dev), H2M_MAILBOX_CSR, \ - H2M_MAILBOX_CSR_OWNER, (__reg)) - -+static void rt6352_init_palna_stage1(struct rt2x00_dev *rt2x00dev); -+static void rt6352_init_palna_stage2(struct rt2x00_dev *rt2x00dev); -+ - static inline bool rt2800_is_305x_soc(struct rt2x00_dev *rt2x00dev) - { - /* check for rt2872 on SoC */ -@@ -3881,14 +3884,6 @@ static void rt2800_config_channel_rf7620 +@@ -3881,14 +3881,6 @@ static void rt2800_config_channel_rf7620 rfcsr |= tx_agc_fc; rt2800_rfcsr_write_bank(rt2x00dev, 7, 59, rfcsr); } @@ -52,17 +40,7 @@ Signed-off-by: Shiji Yang } static void rt2800_config_alc_rt6352(struct rt2x00_dev *rt2x00dev, -@@ -4151,6 +4146,9 @@ static void rt2800_config_channel(struct - rt2800_txpower_to_dev(rt2x00dev, rf->channel, - info->default_power3); - -+ if (rt2x00_rt(rt2x00dev, RT6352)) -+ rt6352_init_palna_stage1(rt2x00dev); -+ - switch (rt2x00dev->chip.rt) { - case RT3883: - rt3883_bbp_adjust(rt2x00dev, rf); -@@ -4457,89 +4455,65 @@ static void rt2800_config_channel(struct +@@ -4457,89 +4449,63 @@ static void rt2800_config_channel(struct usleep_range(1000, 1500); } @@ -193,12 +171,10 @@ Signed-off-by: Shiji Yang + * Otherwise it's difficult to pass the WHQL. + */ + usleep_range(1000, 1500); -+ -+ rt6352_init_palna_stage2(rt2x00dev); } bbp = rt2800_bbp_read(rt2x00dev, 4); -@@ -5649,43 +5623,6 @@ void rt2800_vco_calibration(struct rt2x0 +@@ -5649,43 +5615,6 @@ void rt2800_vco_calibration(struct rt2x0 } } rt2800_register_write(rt2x00dev, TX_PIN_CFG, tx_pin); @@ -242,7 +218,7 @@ Signed-off-by: Shiji Yang } EXPORT_SYMBOL_GPL(rt2800_vco_calibration); -@@ -8650,7 +8587,7 @@ static void rt2800_r_calibration(struct +@@ -8650,7 +8579,7 @@ static void rt2800_r_calibration(struct rt2x00_warn(rt2x00dev, "Wait MAC Tx Status to MAX !!!\n"); maccfg = rt2800_register_read(rt2x00dev, MAC_SYS_CTRL); @@ -251,7 +227,7 @@ Signed-off-by: Shiji Yang rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, maccfg); if (unlikely(rt2800_wait_bbp_rf_ready(rt2x00dev, MAC_STATUS_CFG_BBP_RF_BUSY_RX))) -@@ -10688,30 +10625,151 @@ static void rt2800_init_rfcsr_6352(struc +@@ -10688,30 +10617,143 @@ static void rt2800_init_rfcsr_6352(struc rt2800_rfcsr_write_dccal(rt2x00dev, 5, 0x00); rt2800_rfcsr_write_dccal(rt2x00dev, 17, 0x7C); } @@ -266,7 +242,7 @@ Signed-off-by: Shiji Yang - rt2800_loft_iq_calibration(rt2x00dev); - rt2800_rxiq_calibration(rt2x00dev); - rt6352_enable_pa_pin(rt2x00dev, 1); -+static void rt6352_init_ext_palna(struct rt2x00_dev *rt2x00dev) ++static void rt2800_init_palna_rt6352(struct rt2x00_dev *rt2x00dev) +{ + u32 reg; + @@ -282,14 +258,14 @@ Signed-off-by: Shiji Yang - if (rt2x00_has_cap_external_lna_bg(rt2x00dev)) { + if (rt2800_hw_get_chippkg(rt2x00dev) == 1 && -+ rt2x00_has_cap_external_lna_bg(rt2x00dev)) { ++ rt2x00_has_cap_external_lna_bg(rt2x00dev)) { rt2800_rfcsr_write_chanreg(rt2x00dev, 14, 0x66); rt2800_rfcsr_write_chanreg(rt2x00dev, 17, 0x20); rt2800_rfcsr_write_chanreg(rt2x00dev, 18, 0x42); + } + + if (rt2800_hw_get_chippkg(rt2x00dev) == 1 && -+ rt2x00_has_cap_external_pa(rt2x00dev)) { ++ rt2x00_has_cap_external_pa(rt2x00dev)) { + rt2800_rfcsr_write_chanreg(rt2x00dev, 43, 0x73); + rt2800_rfcsr_write_chanreg(rt2x00dev, 44, 0x73); + rt2800_rfcsr_write_chanreg(rt2x00dev, 45, 0x73); @@ -308,12 +284,11 @@ Signed-off-by: Shiji Yang + } + + if (rt2800_hw_get_chippkg(rt2x00dev) == 1 && -+ rt2x00_has_cap_external_pa(rt2x00dev)) { ++ rt2x00_has_cap_external_pa(rt2x00dev)) + rt2800_rfcsr_write_dccal(rt2x00dev, 05, 0x00); -+ } + + if (rt2800_hw_get_chippkg(rt2x00dev) == 1 && -+ rt2x00_has_cap_external_lna_bg(rt2x00dev)) { ++ rt2x00_has_cap_external_lna_bg(rt2x00dev)) { rt2800_bbp_write(rt2x00dev, 75, 0x68); rt2800_bbp_write(rt2x00dev, 76, 0x4C); rt2800_bbp_write(rt2x00dev, 79, 0x1C); @@ -326,14 +301,14 @@ Signed-off-by: Shiji Yang + } + + if (rt2800_hw_get_chippkg(rt2x00dev) == 1 && -+ rt2x00_has_cap_external_pa(rt2x00dev)) { ++ rt2x00_has_cap_external_pa(rt2x00dev)) { + rt2800_register_write(rt2x00dev, TX0_RF_GAIN_CORRECT, 0x36303636); + rt2800_register_write(rt2x00dev, TX0_RF_GAIN_ATTEN, 0x6C6C6B6C); + rt2800_register_write(rt2x00dev, TX1_RF_GAIN_ATTEN, 0x6C6C6B6C); + } +} + -+static void rt6352_restore_rf_bbp(struct rt2x00_dev *rt2x00dev) ++static void rt2800_restore_rf_bbp_rt6352(struct rt2x00_dev *rt2x00dev) +{ + if (rt2x00_has_cap_external_pa(rt2x00dev)) { + rt2800_register_write(rt2x00dev, RF_CONTROL3, 0x0); @@ -341,15 +316,14 @@ Signed-off-by: Shiji Yang + } + + if (rt2800_hw_get_chippkg(rt2x00dev) == 1 && -+ rt2x00_has_cap_external_lna_bg(rt2x00dev)) { ++ rt2x00_has_cap_external_lna_bg(rt2x00dev)) { + rt2800_rfcsr_write_chanreg(rt2x00dev, 14, 0x16); + rt2800_rfcsr_write_chanreg(rt2x00dev, 17, 0x23); + rt2800_rfcsr_write_chanreg(rt2x00dev, 18, 0x02); + } + + if (rt2800_hw_get_chippkg(rt2x00dev) == 1 && -+ rt2x00_has_cap_external_pa(rt2x00dev)) -+ { ++ rt2x00_has_cap_external_pa(rt2x00dev)) { + rt2800_rfcsr_write_chanreg(rt2x00dev, 43, 0xD3); + rt2800_rfcsr_write_chanreg(rt2x00dev, 44, 0xB3); + rt2800_rfcsr_write_chanreg(rt2x00dev, 45, 0xD5); @@ -368,7 +342,7 @@ Signed-off-by: Shiji Yang + } + + if (rt2800_hw_get_chippkg(rt2x00dev) == 1 && -+ rt2x00_has_cap_external_lna_bg(rt2x00dev)) { ++ rt2x00_has_cap_external_lna_bg(rt2x00dev)) { + rt2800_bbp_write(rt2x00dev, 75, 0x60); + rt2800_bbp_write(rt2x00dev, 76, 0x44); + rt2800_bbp_write(rt2x00dev, 79, 0x1C); @@ -376,29 +350,23 @@ Signed-off-by: Shiji Yang + rt2800_bbp_write(rt2x00dev, 82, 0xB6); + } + -+ if (rt2800_hw_get_chippkg(rt2x00dev) == 1 -+ && rt2x00_has_cap_external_pa(rt2x00dev)) { ++ if (rt2800_hw_get_chippkg(rt2x00dev) == 1 && ++ rt2x00_has_cap_external_pa(rt2x00dev)) { + rt2800_register_write(rt2x00dev, TX0_RF_GAIN_CORRECT, 0x3630363A); + rt2800_register_write(rt2x00dev, TX0_RF_GAIN_ATTEN, 0x6C6C666C); + rt2800_register_write(rt2x00dev, TX1_RF_GAIN_ATTEN, 0x6C6C666C); + } +} + -+/* MT7620 PA/LNA initialization before switching channels */ -+static void rt6352_init_palna_stage1(struct rt2x00_dev *rt2x00dev) ++static void rt2800_calibration_rt6352(struct rt2x00_dev *rt2x00dev) +{ + if (rt2x00_has_cap_external_pa(rt2x00dev) || -+ rt2x00_has_cap_external_lna_bg(rt2x00dev)) { ++ rt2x00_has_cap_external_lna_bg(rt2x00dev)) { + rt6352_enable_pa_pin(rt2x00dev, 0); -+ rt6352_restore_rf_bbp(rt2x00dev); ++ rt2800_restore_rf_bbp_rt6352(rt2x00dev); + } + + rt2800_r_calibration(rt2x00dev); -+} -+ -+/* MT7620 PA/LNA initialization after switching channels */ -+static void rt6352_init_palna_stage2(struct rt2x00_dev *rt2x00dev) -+{ + rt2800_rf_self_txdc_cal(rt2x00dev); + rt2800_rxdcoc_calibration(rt2x00dev); + rt2800_bw_filter_calibration(rt2x00dev, true); @@ -410,13 +378,24 @@ Signed-off-by: Shiji Yang + rt2800_rxdcoc_calibration(rt2x00dev); + rt2800_rxiq_calibration(rt2x00dev); + -+ if(rt2x00_has_cap_external_pa(rt2x00dev) || -+ rt2x00_has_cap_external_lna_bg(rt2x00dev)) { ++ if (rt2x00_has_cap_external_pa(rt2x00dev) || ++ rt2x00_has_cap_external_lna_bg(rt2x00dev)) { + rt6352_enable_pa_pin(rt2x00dev, 1); -+ rt6352_init_ext_palna(rt2x00dev); ++ rt2800_init_palna_rt6352(rt2x00dev); } } +@@ -10804,6 +10846,10 @@ int rt2800_enable_radio(struct rt2x00_de + rt2800_init_bbp(rt2x00dev); + rt2800_init_rfcsr(rt2x00dev); + ++ /* Do calibration and init PA/LNA for RT6352 */ ++ if (rt2x00_rt(rt2x00dev, RT6352)) ++ rt2800_calibration_rt6352(rt2x00dev); ++ + if (rt2x00_is_usb(rt2x00dev) && + (rt2x00_rt(rt2x00dev, RT3070) || + rt2x00_rt(rt2x00dev, RT3071) || --- a/drivers/net/wireless/ralink/rt2x00/rt2x00.h +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00.h @@ -1277,6 +1277,12 @@ rt2x00_has_cap_external_lna_bg(struct rt diff --git a/package/network/services/hostapd/files/hostapd.sh b/package/network/services/hostapd/files/hostapd.sh index a0eaa295de..a9d26a8bed 100644 --- a/package/network/services/hostapd/files/hostapd.sh +++ b/package/network/services/hostapd/files/hostapd.sh @@ -869,8 +869,9 @@ hostapd_set_bss_options() { [ "$bss_transition" -eq "1" ] && append bss_conf "bss_transition=1" "$N" [ "$mbo" -eq 1 ] && append bss_conf "mbo=1" "$N" - json_get_vars ieee80211k rrm_neighbor_report rrm_beacon_report + json_get_vars ieee80211k rrm_neighbor_report rrm_beacon_report rnr set_default ieee80211k 0 + set_default rnr 0 if [ "$ieee80211k" -eq "1" ]; then set_default rrm_neighbor_report 1 set_default rrm_beacon_report 1 @@ -881,6 +882,7 @@ hostapd_set_bss_options() { [ "$rrm_neighbor_report" -eq "1" ] && append bss_conf "rrm_neighbor_report=1" "$N" [ "$rrm_beacon_report" -eq "1" ] && append bss_conf "rrm_beacon_report=1" "$N" + [ "$rnr" -eq "1" ] && append bss_conf "rnr=1" "$N" json_get_vars ftm_responder stationary_ap lci civic set_default ftm_responder 0 diff --git a/target/linux/mediatek/dts/mt7981b-zyxel-nwa50ax-pro.dts b/target/linux/mediatek/dts/mt7981b-zyxel-nwa50ax-pro.dts index 6ca7ba040a..6b50dde4e2 100644 --- a/target/linux/mediatek/dts/mt7981b-zyxel-nwa50ax-pro.dts +++ b/target/linux/mediatek/dts/mt7981b-zyxel-nwa50ax-pro.dts @@ -84,6 +84,9 @@ phy0: ethernet-phy@5 { reg = <5>; compatible = "ethernet-phy-ieee802.3-c45"; + + /* LED0: Amber ; LED1: nc ; LED2: nc ; LED3: Green */ + mxl,led-config = <0x3b0 0x0 0x0 0x3c0>; }; }; diff --git a/target/linux/mediatek/dts/mt7986b-netgear-wax220.dts b/target/linux/mediatek/dts/mt7986b-netgear-wax220.dts index ac2a4b0824..09fdf67786 100644 --- a/target/linux/mediatek/dts/mt7986b-netgear-wax220.dts +++ b/target/linux/mediatek/dts/mt7986b-netgear-wax220.dts @@ -8,10 +8,8 @@ #include "mt7986b.dtsi" / { - #address-cells = <0x2>; - #size-cells = <0x2>; model = "Netgear WAX220"; - compatible = "netgear,wax220", "mediatek,mt7986b-spim-snand-rfb"; + compatible = "netgear,wax220", "mediatek,mt7986b"; aliases { serial0 = &uart0; @@ -106,8 +104,6 @@ }; &mdio { - #address-cells = <1>; - #size-cells = <0>; phy6: ethernet-phy@6 { reg = <6>; reset-assert-us = <100000>; @@ -120,7 +116,6 @@ }; }; - &pio { spi_flash_pins: spi-flash-pins-33-to-38 { mux { @@ -145,13 +140,13 @@ groups = "wf_2g", "wf_5g"; }; conf { - pins = "WF0_HB1", "WF0_HB2", "WF0_HB3", "WF0_HB4", - "WF0_HB0", "WF0_HB0_B", "WF0_HB5", "WF0_HB6", - "WF0_HB7", "WF0_HB8", "WF0_HB9", "WF0_HB10", - "WF0_TOP_CLK", "WF0_TOP_DATA", "WF1_HB1", - "WF1_HB2", "WF1_HB3", "WF1_HB4", "WF1_HB0", - "WF1_HB5", "WF1_HB6", "WF1_HB7", "WF1_HB8", - "WF1_TOP_CLK", "WF1_TOP_DATA"; + pins = "WF0_HB1", "WF0_HB2", "WF0_HB3", "WF0_HB4", + "WF0_HB0", "WF0_HB0_B", "WF0_HB5", "WF0_HB6", + "WF0_HB7", "WF0_HB8", "WF0_HB9", "WF0_HB10", + "WF0_TOP_CLK", "WF0_TOP_DATA", "WF1_HB1", + "WF1_HB2", "WF1_HB3", "WF1_HB4", "WF1_HB0", + "WF1_HB5", "WF1_HB6", "WF1_HB7", "WF1_HB8", + "WF1_TOP_CLK", "WF1_TOP_DATA"; drive-strength = <4>; }; }; @@ -163,9 +158,9 @@ }; conf { pins = "WF0_HB1", "WF0_HB2", "WF0_HB3", "WF0_HB4", - "WF0_HB0", "WF0_HB0_B", "WF0_HB5", "WF0_HB6", - "WF0_HB7", "WF0_HB8", "WF0_HB9", "WF0_HB10", - "WF0_TOP_CLK", "WF0_TOP_DATA"; + "WF0_HB0", "WF0_HB0_B", "WF0_HB5", "WF0_HB6", + "WF0_HB7", "WF0_HB8", "WF0_HB9", "WF0_HB10", + "WF0_TOP_CLK", "WF0_TOP_DATA"; drive-strength = <4>; }; }; @@ -196,29 +191,10 @@ #size-cells = <0x1>; compatible = "fixed-partitions"; - partition@5fc0000 { - label = "Traffic"; - reg = <0x5fc0000 0x200000>; - }; - - partition@63c0000 { - label = "NTGRcryptD"; - reg = <0x63c0000 0x500000>; - }; - - partition@580000 { - label = "ubi"; - reg = <0x580000 0x5140000>; - }; - - factory: partition@180000 { - label = "Factory"; - reg = <0x180000 0x200000>; - }; - - partition@69c0000 { - label = "User_data"; - reg = <0x69c0000 0x640000>; + partition@0 { + label = "BL2"; + read-only; + reg = <0x0 0x100000>; }; partition@100000 { @@ -226,30 +202,9 @@ reg = <0x100000 0x80000>; }; - partition@68c0000 { - label = "LOG"; - reg = <0x68c0000 0x100000>; - }; - - partition@5ac0000 { - label = "POT"; - reg = <0x5ac0000 0x100000>; - }; - - partition@0 { - label = "BL2"; - read-only; - reg = <0x0 0x100000>; - }; - - partition@5bc0000 { - label = "Language"; - reg = <0x5bc0000 0x400000>; - }; - - partition@61c0000 { - label = "Cert"; - reg = <0x61c0000 0x100000>; + factory: partition@180000 { + label = "Factory"; + reg = <0x180000 0x200000>; }; partition@380000 { @@ -257,15 +212,55 @@ reg = <0x380000 0x200000>; }; + partition@580000 { + label = "ubi"; + reg = <0x580000 0x5140000>; + }; + partition@56c0000 { label = "RAE"; reg = <0x56c0000 0x400000>; }; + partition@5ac0000 { + label = "POT"; + reg = <0x5ac0000 0x100000>; + }; + + partition@5bc0000 { + label = "Language"; + reg = <0x5bc0000 0x400000>; + }; + + partition@5fc0000 { + label = "Traffic"; + reg = <0x5fc0000 0x200000>; + }; + + partition@61c0000 { + label = "Cert"; + reg = <0x61c0000 0x100000>; + }; + partition@62c0000 { label = "NTGRcryptK"; reg = <0x62c0000 0x100000>; }; + + partition@63c0000 { + label = "NTGRcryptD"; + reg = <0x63c0000 0x500000>; + }; + + partition@68c0000 { + label = "LOG"; + reg = <0x68c0000 0x100000>; + }; + + partition@69c0000 { + label = "User_data"; + reg = <0x69c0000 0x640000>; + }; }; }; diff --git a/target/linux/mediatek/filogic/base-files/lib/preinit/75_rootfs_prepare b/target/linux/mediatek/filogic/base-files/lib/preinit/75_rootfs_prepare new file mode 100644 index 0000000000..0a32073e0b --- /dev/null +++ b/target/linux/mediatek/filogic/base-files/lib/preinit/75_rootfs_prepare @@ -0,0 +1,35 @@ +# SPDX-License-Identifier: GPL-2.0-or-later OR BSD-2-Clause + +rootfs_create() { + local blocks + + blocks=$(cat /sys/class/ubi/ubi0/avail_eraseblocks) + [ -z "$blocks" ] && { + echo "Failed to read amount of available erase blocks" >&2 + return + } + + # Delete after getting available blocks: Make sure enough space is + # left to recreate these volumes. + ubirmvol /dev/ubi0 -N kernel_backup + ubirmvol /dev/ubi0 -N rootfs_backup + + # Use 90% of remaining flash size for "rootfs_data" + ubimkvol /dev/ubi0 -n 20 -N rootfs_data --lebs $((blocks / 100 * 90)) + mknod -m 0600 /dev/ubi0_20 c 250 21 +} + +rootfs_prepare() { + case $(board_name) in + netgear,wax220) + if ! ubinfo /dev/ubi0 -N rootfs_data &>/dev/null; then + echo "Creating \"rootfs_data\" UBI volume" + rootfs_create + fi + ;; + *) + ;; + esac +} + +boot_hook_add preinit_main rootfs_prepare diff --git a/target/linux/mediatek/image/filogic.mk b/target/linux/mediatek/image/filogic.mk index f469f61620..10e599966a 100644 --- a/target/linux/mediatek/image/filogic.mk +++ b/target/linux/mediatek/image/filogic.mk @@ -104,7 +104,7 @@ define Device/acer_predator-w6 DEVICE_DTS := mt7986a-acer-predator-w6 DEVICE_DTS_DIR := ../dts DEVICE_DTS_LOADADDR := 0x47000000 - DEVICE_PACKAGES := kmod-usb3 kmod-mt7986-firmware kmod-mt7916-firmware mt7986-wo-firmware + DEVICE_PACKAGES := kmod-usb3 kmod-mt7986-firmware kmod-mt7916-firmware mt7986-wo-firmware e2fsprogs f2fsck mkf2fs IMAGES := sysupgrade.bin KERNEL := kernel-bin | lzma | fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb KERNEL_INITRAMFS := kernel-bin | lzma | \ @@ -322,18 +322,20 @@ endef TARGET_DEVICES += livinet_zr-3020-ubootmod define Device/netgear_wax220 - DEVICE_VENDOR := Netgear + DEVICE_VENDOR := NETGEAR DEVICE_MODEL := WAX220 DEVICE_DTS := mt7986b-netgear-wax220 DEVICE_DTS_DIR := ../dts + NETGEAR_ENC_MODEL := WAX220 + NETGEAR_ENC_REGION := US DEVICE_PACKAGES := kmod-mt7986-firmware mt7986-wo-firmware - IMAGES := sysupgrade.bin - KERNEL_IN_UBI := 1 - KERNEL := kernel-bin | lzma | \ - fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb - KERNEL_INITRAMFS := kernel-bin | lzma | \ - fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb with-initrd | pad-to 64k + KERNEL_INITRAMFS_SUFFIX := -recovery.itb + IMAGE_SIZE := 32768k IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata + IMAGES += factory.img + # Padding to 10M seems to be required by OEM web interface + IMAGE/factory.img := sysupgrade-tar | \ + pad-to 10M | check-size | netgear-encrypted-factory endef TARGET_DEVICES += netgear_wax220