From 20b3e77ba3e690453203587afa174bef43ee339b Mon Sep 17 00:00:00 2001 From: Jeff Kletsky Date: Tue, 14 May 2019 09:47:40 -0700 Subject: [PATCH 01/22] ath79: prepare NAND subtarget for upstream support of SPI NAND Linux 4.19 supplies the upstream spi-nand framework, permitting porting and support of boards with SPI NAND. * Adjusted nand/target.mk to provide FEATURES += squashfs nand * Updated config-default to provide current MTD and UBI support Defaults selected for: CONFIG_MTD_UBI_WL_THRESHOLD=4096 CONFIG_MTD_UBI_BEB_LIMIT=20 # CONFIG_MTD_UBI_FASTMAP is not set # CONFIG_MTD_UBI_GLUEBI is not set The bad-block reservation limit technically should be 21 for Paragon SPI NAND but most other devices in the class are 20 blocks per Gbit. In Linux 5.2 this is specified on a per-chip basis through NAND_MEMORG Contents adjusted to remove declarations provided at the target level by commit 08a134820f5 (Oct 23, 2019) ath79: enable PCI for whole target Signed-off-by: Jeff Kletsky Tested-by: Michal Cieslakiewicz --- target/linux/ath79/nand/config-default | 15 +++++++-------- target/linux/ath79/nand/target.mk | 7 ++++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/target/linux/ath79/nand/config-default b/target/linux/ath79/nand/config-default index 84e6748a20..4742ad52d0 100644 --- a/target/linux/ath79/nand/config-default +++ b/target/linux/ath79/nand/config-default @@ -1,18 +1,17 @@ -CONFIG_AT803X_PHY=y -CONFIG_BCH=y CONFIG_MTD_NAND=y CONFIG_MTD_NAND_AR934X=y -CONFIG_MTD_NAND_BCH=y +CONFIG_MTD_NAND_CORE=y CONFIG_MTD_NAND_ECC=y -CONFIG_MTD_NAND_ECC_BCH=y -CONFIG_MTD_SPINAND_MT29F=y -CONFIG_MTD_SPINAND_ONDIEECC=y +CONFIG_MTD_SPI_NAND=y CONFIG_MTD_UBI=y -CONFIG_MTD_UBI_BEB_LIMIT=20 CONFIG_MTD_UBI_BLOCK=y +CONFIG_MTD_UBI_WL_THRESHOLD=4096 +CONFIG_MTD_UBI_BEB_LIMIT=20 # CONFIG_MTD_UBI_FASTMAP is not set # CONFIG_MTD_UBI_GLUEBI is not set -CONFIG_MTD_UBI_WL_THRESHOLD=4096 +# CONFIG_PCI_AR71XX is not set +# CONFIG_PHY_AR7100_USB is not set +CONFIG_PHY_AR7200_USB=y CONFIG_UBIFS_FS=y CONFIG_UBIFS_FS_ADVANCED_COMPR=y CONFIG_UBIFS_FS_LZO=y diff --git a/target/linux/ath79/nand/target.mk b/target/linux/ath79/nand/target.mk index 91afe675c5..c565c9b2b8 100644 --- a/target/linux/ath79/nand/target.mk +++ b/target/linux/ath79/nand/target.mk @@ -1,9 +1,10 @@ BOARDNAME := Generic devices with NAND flash -FEATURES += squashfs nand rtc + +FEATURES += squashfs nand DEFAULT_PACKAGES += wpad-basic define Target/Description - Build firmware for Atheros AR71xx/AR913x based boards with - NAND flash, e.g. Netgear WNDR4300. + Firmware for boards using Qualcomm Atheros, MIPS-based SoCs + in the ar72xx and subsequent series, with support for NAND flash endef From 55e6c903ae20bd8e694f4626166766e59602f87c Mon Sep 17 00:00:00 2001 From: Jeff Kletsky Date: Sat, 1 Jun 2019 17:51:17 -0700 Subject: [PATCH 02/22] ath79: GL-AR300M: provide NAND support; increase to 4 MB kernel The GL.iNet GL-AR300M has been supported by the ar71xx and ath79 platforms with access to its 16 MB NOR flash, but not its 128 MB SPI NAND flash. This commit provides support for the NAND through the upstream SPI-NAND framework. Devices with both NOR and NAND flash can support independent firmware on each, with U-Boot able to boot from either. The OEM U-Boot will fall back to the NOR firmware after three "unsuccessful" boots. The family of GL-AR300M devices on the ath79 platform now includes: * glinet,gl-ar300m-lite "generic" target, NOR-only board * glinet,gl-ar300m-nand "nand" target * glinet,gl-ar300m-nor "nand" target (NAND-aware) NB: This commit increases the kernel size from 2 MB to 4 MB "Force-less" sysupgrade is presently supported from the current versions of following NOR-based firmwre images to the version of glinet,gl-ar300m-nor firmware produced by this commit: * gl-ar300m -- OEM v3 NOR ar71xx (openwrt-ar300m16-*.bin) * gl-ar300m -- OpenWrt 18.06 ar71xx * gl-ar300m -- OpenWrt 19.07 ar71xx Other upgrades to these images should be performed through U-Boot. The GL-AR300M OEM U-Boot allows upload and flashing of either NOR firmware (sysupgrade.bin) or NAND firmware (factory.img) through its HTTP-based GUI. Serial connectivity is not required. The glinet,gl-ar300m-nand and glinet,gl-ar300m-nor images generated after this commit should safely flash each other using sysupgrade. The boot counter is implemented by the OEM using u-boot-env. At this time, it does not appear that the switch on the side of the unit can be used to select NOR vs. NAND boot and the fail-over is only from NAND to NOR. To save flash wear, it is only reset when running the glinet,gl-ar300m-nand firmware. NAND-specific base-files are used to remove impact on existing generic and tiny targets. As there is now no "generic" build appropriate for the GL-AR300M16, (or for users of the GL-AR300M that do not need access to NAND) it will be introduced in a subsequent commit. Note: `mtd_get_mac_binary art 0x6` does not return the proper MAC and the GL.iNet source indicates that only the 0x0 offset is valid The ar71xx targets are unmodified. Signed-off-by: Jeff Kletsky --- .../dts/qca9531_glinet_gl-ar300m-lite.dts | 4 + .../dts/qca9531_glinet_gl-ar300m-nand.dts | 32 ++----- .../dts/qca9531_glinet_gl-ar300m-nor.dts | 5 ++ .../ath79/dts/qca9531_glinet_gl-ar300m.dtsi | 39 ++++++-- .../generic/base-files/etc/board.d/01_leds | 3 - target/linux/ath79/image/generic.mk | 6 -- target/linux/ath79/image/nand.mk | 32 +++++-- .../ath79/nand/base-files/etc/board.d/01_leds | 3 +- .../nand/base-files/etc/init.d/bootcount | 13 +++ .../nand/base-files/lib/upgrade/glinet.sh | 90 +++++++++++++++++++ .../nand/base-files/lib/upgrade/platform.sh | 12 +-- 11 files changed, 183 insertions(+), 56 deletions(-) create mode 100755 target/linux/ath79/nand/base-files/etc/init.d/bootcount create mode 100644 target/linux/ath79/nand/base-files/lib/upgrade/glinet.sh diff --git a/target/linux/ath79/dts/qca9531_glinet_gl-ar300m-lite.dts b/target/linux/ath79/dts/qca9531_glinet_gl-ar300m-lite.dts index 148d017540..ed00cdb585 100644 --- a/target/linux/ath79/dts/qca9531_glinet_gl-ar300m-lite.dts +++ b/target/linux/ath79/dts/qca9531_glinet_gl-ar300m-lite.dts @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + /dts-v1/; #include "qca9531_glinet_gl-ar300m.dtsi" @@ -7,6 +9,8 @@ model = "GL.iNet GL-AR300M-Lite"; }; +/delete-node/ &nand_flash; + // "Disable" unpopulated GMAC1 ð1 { diff --git a/target/linux/ath79/dts/qca9531_glinet_gl-ar300m-nand.dts b/target/linux/ath79/dts/qca9531_glinet_gl-ar300m-nand.dts index 26c30f2b72..00f9f5c82d 100644 --- a/target/linux/ath79/dts/qca9531_glinet_gl-ar300m-nand.dts +++ b/target/linux/ath79/dts/qca9531_glinet_gl-ar300m-nand.dts @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + /dts-v1/; #include "qca9531_glinet_gl-ar300m.dtsi" @@ -7,28 +9,10 @@ model = "GL.iNet GL-AR300M (NAND)"; }; -&spi { - num-cs = <1>; - - flash@1 { - compatible = "spinand,mt29f"; - reg = <1>; - spi-max-frequency = <25000000>; - - partitions { - compatible = "fixed-partitions"; - #address-cells = <1>; - #size-cells = <1>; - - partition@0 { - label = "kernel"; - reg = <0x000000 0x0200000>; - }; - - partition@1 { - label = "ubi"; - reg = <0x200000 0x7e00000>; - }; - }; - }; +&nand_kernel { + label = "kernel"; +}; + +&nand_ubi { + label = "ubi"; }; diff --git a/target/linux/ath79/dts/qca9531_glinet_gl-ar300m-nor.dts b/target/linux/ath79/dts/qca9531_glinet_gl-ar300m-nor.dts index 22e5ae4e74..34f48f5f61 100644 --- a/target/linux/ath79/dts/qca9531_glinet_gl-ar300m-nor.dts +++ b/target/linux/ath79/dts/qca9531_glinet_gl-ar300m-nor.dts @@ -6,3 +6,8 @@ compatible = "glinet,gl-ar300m-nor", "qca,qca9531"; model = "GL.iNet GL-AR300M (NOR)"; }; + +&nor_firmware { + compatible = "denx,uimage"; + label = "firmware"; +}; diff --git a/target/linux/ath79/dts/qca9531_glinet_gl-ar300m.dtsi b/target/linux/ath79/dts/qca9531_glinet_gl-ar300m.dtsi index 78961bf71b..72bc2a6466 100644 --- a/target/linux/ath79/dts/qca9531_glinet_gl-ar300m.dtsi +++ b/target/linux/ath79/dts/qca9531_glinet_gl-ar300m.dtsi @@ -42,7 +42,7 @@ leds { compatible = "gpio-leds"; - // Colors from non-Lite versions + // Colors for non-Lite versions led_status: status { label = "gl-ar300m:green:status"; @@ -75,10 +75,12 @@ &spi { status = "okay"; - num-cs = <0>; + + num-cs = <2>; + cs-gpios = <0>, <0>; flash@0 { - compatible = "winbond,w25q128", "jedec,spi-nor"; + compatible = "jedec,spi-nor"; reg = <0>; spi-max-frequency = <25000000>; @@ -93,24 +95,45 @@ read-only; }; - partition@1 { + partition@40000 { label = "u-boot-env"; reg = <0x040000 0x010000>; }; - partition@2 { - compatible = "denx,uimage"; - label = "firmware"; + nor_firmware: partition@50000 { + label = "nor_firmware"; reg = <0x050000 0xfa0000>; }; - art: partition@3 { + art: partition@ff0000 { label = "art"; reg = <0xff0000 0x010000>; read-only; }; }; }; + + nand_flash: flash@1 { + compatible = "spi-nand"; + reg = <1>; + spi-max-frequency = <25000000>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + nand_kernel: partition@0 { + label = "nand_kernel"; + reg = <0x000000 0x400000>; + }; + + nand_ubi: partition@400000 { + label = "nand_ubi"; + reg = <0x400000 0x7c00000>; + }; + }; + }; }; &uart { diff --git a/target/linux/ath79/generic/base-files/etc/board.d/01_leds b/target/linux/ath79/generic/base-files/etc/board.d/01_leds index de2c8e9197..4ab504654e 100755 --- a/target/linux/ath79/generic/base-files/etc/board.d/01_leds +++ b/target/linux/ath79/generic/base-files/etc/board.d/01_leds @@ -94,9 +94,6 @@ glinet,gl-ar150) ucidef_set_led_netdev "wan" "WAN" "$boardname:green:wan" "eth1" ucidef_set_led_switch "lan" "LAN" "$boardname:green:lan" "switch0" "0x02" ;; -glinet,gl-ar300m-nor) - ucidef_set_led_netdev "lan" "LAN" "gl-ar300m:green:lan" "eth0" - ;; glinet,gl-ar300m-lite) ucidef_set_led_netdev "lan" "LAN" "gl-ar300m-lite:green:lan" "eth0" ;; diff --git a/target/linux/ath79/image/generic.mk b/target/linux/ath79/image/generic.mk index 70631c20d0..011bb41262 100644 --- a/target/linux/ath79/image/generic.mk +++ b/target/linux/ath79/image/generic.mk @@ -562,12 +562,6 @@ define Device/glinet_gl-ar300m-lite endef TARGET_DEVICES += glinet_gl-ar300m-lite -define Device/glinet_gl-ar300m-nor - $(Device/glinet_gl-ar300m-common-nor) - DEVICE_MODEL := GL-AR300M -endef -TARGET_DEVICES += glinet_gl-ar300m-nor - define Device/glinet_gl-ar750 ATH_SOC := qca9531 DEVICE_VENDOR := GL.iNet diff --git a/target/linux/ath79/image/nand.mk b/target/linux/ath79/image/nand.mk index ef6b607002..f9961840f0 100644 --- a/target/linux/ath79/image/nand.mk +++ b/target/linux/ath79/image/nand.mk @@ -45,22 +45,36 @@ define Device/aerohive_hiveap-121 endef TARGET_DEVICES += aerohive_hiveap-121 -define Device/glinet_gl-ar300m-nand +define Device/glinet_gl-ar300m-common-nand ATH_SOC := qca9531 DEVICE_VENDOR := GL.iNet DEVICE_MODEL := GL-AR300M - DEVICE_VARIANT := NAND - DEVICE_PACKAGES := kmod-usb2 kmod-usb-storage kmod-usb-ledtrig-usbport - KERNEL_SIZE := 2048k - BLOCKSIZE := 128k + DEVICE_PACKAGES := kmod-usb2 + KERNEL_SIZE := 4096k + IMAGE_SIZE := 16000k PAGESIZE := 2048 - VID_HDR_OFFSET := 512 - IMAGES += factory.ubi - IMAGE/sysupgrade.bin := sysupgrade-tar - IMAGE/factory.ubi := append-kernel | pad-to $$$$(KERNEL_SIZE) | append-ubi + VID_HDR_OFFSET := 2048 +endef + +define Device/glinet_gl-ar300m-nand + $(Device/glinet_gl-ar300m-common-nand) + DEVICE_VARIANT := NAND + BLOCKSIZE := 128k + IMAGES += factory.img + IMAGE/factory.img := append-kernel | pad-to $$$$(KERNEL_SIZE) | append-ubi + IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata + SUPPORTED_DEVICES += glinet,gl-ar300m-nor endef TARGET_DEVICES += glinet_gl-ar300m-nand +define Device/glinet_gl-ar300m-nor + $(Device/glinet_gl-ar300m-common-nand) + DEVICE_VARIANT := NOR + BLOCKSIZE := 64k + SUPPORTED_DEVICES += glinet,gl-ar300m-nand gl-ar300m +endef +TARGET_DEVICES += glinet_gl-ar300m-nor + # fake rootfs is mandatory, pad-offset 129 equals (2 * uimage_header + 0xff) define Device/netgear_ath79_nand DEVICE_VENDOR := NETGEAR diff --git a/target/linux/ath79/nand/base-files/etc/board.d/01_leds b/target/linux/ath79/nand/base-files/etc/board.d/01_leds index f851b3d886..f58527d87e 100755 --- a/target/linux/ath79/nand/base-files/etc/board.d/01_leds +++ b/target/linux/ath79/nand/base-files/etc/board.d/01_leds @@ -8,7 +8,8 @@ board=$(board_name) boardname="${board##*,}" case "$board" in -glinet,gl-ar300m-nand) +glinet,gl-ar300m-nand|\ +glinet,gl-ar300m-nor) ucidef_set_led_netdev "lan" "LAN" "gl-ar300m:green:lan" "eth0" ;; netgear,wndr4300) diff --git a/target/linux/ath79/nand/base-files/etc/init.d/bootcount b/target/linux/ath79/nand/base-files/etc/init.d/bootcount new file mode 100755 index 0000000000..c82386b55f --- /dev/null +++ b/target/linux/ath79/nand/base-files/etc/init.d/bootcount @@ -0,0 +1,13 @@ +#!/bin/sh /etc/rc.common + +# SPDX-License-Identifier: GPL-2.0 + +START=99 + +boot() { + case $(board_name) in + glinet,gl-ar300m-nand) + fw_setenv bootcount 0 + ;; + esac +} diff --git a/target/linux/ath79/nand/base-files/lib/upgrade/glinet.sh b/target/linux/ath79/nand/base-files/lib/upgrade/glinet.sh new file mode 100644 index 0000000000..86729f8f2a --- /dev/null +++ b/target/linux/ath79/nand/base-files/lib/upgrade/glinet.sh @@ -0,0 +1,90 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Copyright (C) 2019 Jeff Kletsky +# + +glinet_using_boot_dev_switch() { + if [ "$(fw_printenv -n boot_dev 2>/dev/null)" = "on" ] ; then + >&2 echo "NOTE: boot_dev=on; use switch to control boot partition" + true + else + false + fi +} + +glinet_set_next_boot_nand() { + mkdir -p /var/lock + ! glinet_using_boot_dev_switch && \ + fw_setenv bootcount 0 && \ + >&2 echo "Next boot set for NAND" +} + +glinet_set_next_boot_nor() { + mkdir -p /var/lock + ! glinet_using_boot_dev_switch && \ + fw_setenv bootcount 3 && \ + >&2 echo "Next boot set for NOR" +} + +glinet_nand_nor_do_upgrade() { + set_next_boot_nand() { glinet_set_next_boot_nand; } + set_next_boot_nor() { glinet_set_next_boot_nor; } + nand_nor_do_upgrade "$1" +} + +nand_nor_do_upgrade() { + local upgrade_file="$1" + + local pn + local found="" + local err + + case "$(get_magic_long "$upgrade_file")" in + + "27051956") # U-Boot Image Magic + + for pn in "nor_${PART_NAME}" "$PART_NAME" ; do # firmware + if [ "$(find_mtd_index "$pn")" ] ; then + PART_NAME="$pn" + found="yes" + break + fi + done + if [ "$found" = "yes" ] ; then + >&2 echo "Running NOR upgrade" + default_do_upgrade "$upgrade_file" + # At this time, default_do_upgrade() exits on error + type set_next_boot_nor >/dev/null && set_next_boot_nor + else + >&2 echo "ERROR: UPGRADE FAILED: Unable to locate '$PART_NAME' or 'nor_${PART_NAME}'" + exit 1 + fi + ;; + + *) # otherwise a file that nand_do_upgrade can process + + for pn in "nand_${CI_KERNPART}" "$CI_KERNPART" ; do # kernel + if [ "$(find_mtd_index "$pn")" ] ; then + CI_KERNPART="$pn" + break + fi + done + for pn in "nand_${CI_UBIPART}" "$CI_UBIPART" ; do # ubi + if [ "$(find_mtd_index "$pn")" ] ; then + CI_UBIPART="$pn" + break + fi + done + for pn in "nand_${CI_ROOTPART}" "$CI_ROOTPART" ; do #rootfs + if [ "$(find_mtd_index "$pn")" ] ; then + CI_ROOTPART="$pn" + break + fi + done + >&2 echo "Running NAND upgrade" + # TODO: change order when NAND upgrade offers return + type set_next_boot_nand >/dev/null && set_next_boot_nand + nand_do_upgrade "$upgrade_file" + ;; + esac +} diff --git a/target/linux/ath79/nand/base-files/lib/upgrade/platform.sh b/target/linux/ath79/nand/base-files/lib/upgrade/platform.sh index 3956d5d73f..69105b1668 100644 --- a/target/linux/ath79/nand/base-files/lib/upgrade/platform.sh +++ b/target/linux/ath79/nand/base-files/lib/upgrade/platform.sh @@ -1,20 +1,22 @@ -# # Copyright (C) 2011 OpenWrt.org -# PART_NAME=firmware -REQUIRE_IMAGE_METADATA=1 +REQUIRE_IMAGE_METADATA=1 platform_check_image() { return 0 } +RAMFS_COPY_BIN='fw_printenv fw_setenv' +RAMFS_COPY_DATA='/etc/fw_env.config /var/lock/fw_printenv.lock' + platform_do_upgrade() { local board=$(board_name) case "$board" in - glinet,gl-ar300m-nand) - default_do_upgrade "$1" + glinet,gl-ar300m-nand|\ + glinet,gl-ar300m-nor) + glinet_nand_nor_do_upgrade "$1" ;; *) nand_do_upgrade "$1" From b591cabd3989b44cfaf15248af9e55a0300a9c0a Mon Sep 17 00:00:00 2001 From: Jeff Kletsky Date: Sun, 2 Jun 2019 06:43:00 -0700 Subject: [PATCH 03/22] ath79: add GL.iNet GL-AR300M16 as NOR-only board The GL.iNet GL-AR300M series of devices includes variants without NAND and only the 16 MB NOR flash. These include the GL-AR300M16 and the GL-AR300M-Lite (already with its own board name). This board-name addition provides disambiguation from the NAND-bearing GL-AR300M devices, both for OpenWrt code and for end users. Kernel and firmware support for NAND and UBI will add ~320 kB to the overall firmware size at this time. This NOR-only option continues to provide more compact firmware for both the GL-AR300M16 as well as those who wish to use it as an alternate or primary, NOR-resident firmware on the GL-AR300M. The ar71xx targets are unmodified. Installation ------------ Install through OEM U-Boot (HTTP-based) or `sysupgrade --force` when booted from NOR and running OEM or OpenWrt, NOR-based firmware. As one of the intentions is disambiguation from NAND-bearing units, users who have flashed this firmware onto a device with NAND would need to use U-Boot or `sysupgrade --force` to flash firmware that again supports NAND. There are no additional SUPPORTED_DEVICES as it is not possible to determine if a device does or does not have NAND based on either the OEM's or OpenWrt's board names prior to this patch. Signed-off-by: Jeff Kletsky --- package/boot/uboot-envtools/files/ath79 | 1 + .../linux/ath79/dts/qca9531_glinet_gl-ar300m16.dts | 12 ++++++++++++ .../ath79/generic/base-files/etc/board.d/01_leds | 3 +++ target/linux/ath79/image/generic.mk | 6 ++++++ 4 files changed, 22 insertions(+) create mode 100644 target/linux/ath79/dts/qca9531_glinet_gl-ar300m16.dts diff --git a/package/boot/uboot-envtools/files/ath79 b/package/boot/uboot-envtools/files/ath79 index fefbb48801..d34469cbf4 100644 --- a/package/boot/uboot-envtools/files/ath79 +++ b/package/boot/uboot-envtools/files/ath79 @@ -19,6 +19,7 @@ engenius,ecb1750|\ glinet,gl-ar300m-lite|\ glinet,gl-ar300m-nand|\ glinet,gl-ar300m-nor|\ +glinet,gl-ar300m16|\ librerouter,librerouter-v1|\ netgear,ex6400|\ netgear,ex7300|\ diff --git a/target/linux/ath79/dts/qca9531_glinet_gl-ar300m16.dts b/target/linux/ath79/dts/qca9531_glinet_gl-ar300m16.dts new file mode 100644 index 0000000000..ad491286ec --- /dev/null +++ b/target/linux/ath79/dts/qca9531_glinet_gl-ar300m16.dts @@ -0,0 +1,12 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +/dts-v1/; + +#include "qca9531_glinet_gl-ar300m.dtsi" + +/ { + compatible = "glinet,gl-ar300m16", "qca,qca9531"; + model = "GL.iNet GL-AR300M16"; +}; + +/delete-node/ &nand_flash; diff --git a/target/linux/ath79/generic/base-files/etc/board.d/01_leds b/target/linux/ath79/generic/base-files/etc/board.d/01_leds index 4ab504654e..d54e770240 100755 --- a/target/linux/ath79/generic/base-files/etc/board.d/01_leds +++ b/target/linux/ath79/generic/base-files/etc/board.d/01_leds @@ -97,6 +97,9 @@ glinet,gl-ar150) glinet,gl-ar300m-lite) ucidef_set_led_netdev "lan" "LAN" "gl-ar300m-lite:green:lan" "eth0" ;; +glinet,gl-ar300m16) + ucidef_set_led_netdev "lan" "LAN" "gl-ar300m:green:lan" "eth0" + ;; glinet,gl-x750) ucidef_set_led_netdev "wan" "WAN" "$boardname:green:wan" "eth1" ;; diff --git a/target/linux/ath79/image/generic.mk b/target/linux/ath79/image/generic.mk index 011bb41262..6fc51ec647 100644 --- a/target/linux/ath79/image/generic.mk +++ b/target/linux/ath79/image/generic.mk @@ -562,6 +562,12 @@ define Device/glinet_gl-ar300m-lite endef TARGET_DEVICES += glinet_gl-ar300m-lite +define Device/glinet_gl-ar300m16 + $(Device/glinet_gl-ar300m-common-nor) + DEVICE_MODEL := GL-AR300M16 +endef +TARGET_DEVICES += glinet_gl-ar300m16 + define Device/glinet_gl-ar750 ATH_SOC := qca9531 DEVICE_VENDOR := GL.iNet From b496a2294c6e663a2dcbf08d714443e758d1269d Mon Sep 17 00:00:00 2001 From: Jeff Kletsky Date: Sun, 2 Jun 2019 08:18:34 -0700 Subject: [PATCH 04/22] ath79: GL-AR750S: provide NAND support; increase kernel to 4 MB MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The GL.iNet GL-AR750S has been supported by the ar71xx and ath79 platforms with access to its 16 MB NOR flash, but not its 128 MB SPI NAND flash. This commit provides support for the NAND through the upstream SPI-NAND framework. At this time, the OEM U-Boot appears to only support loading the kernel from NOR. This configuration is preserved as this time, with the glinet,gl-ar750s-nand name reserved for a potential, future, NAND-only boot. The family of GL-AR750S devices on the ath79 platform now includes: * glinet,gl-ar750m-nor-nand "nand" target * glinet,gl-ar750m-nor "nand" target (NAND-aware) NB: This commit increases the kernel size from 2 MB to 4 MB "Force-less" sysupgrade is presently supported from the current versions of following NOR-based firmwre images to the version of glinet,gl-ar750s-nor firmware produced by this commit: * glinet,gl-ar750s -- OpenWrt 19.07 ar71xx * glinet,gl-ar750s -- OpenWrt 19.07 ath79 Users who have sucessfully upgraded to glinet,gl-ar750m-nor may then flash glinet,gl-ar750m-nor-nand with sysupgrade to transtion to the NAND-based variant. Other upgrades to these images, including directly to the NAND-based glinet,gl-ar750s-nor-nand firmware, can be accomplished through U-Boot. NB: See "ath79: restrict GL-AR750S kernel build-size to 2 MB" which enables flashing of NAND factory.img with the current GL-iNet U-Boot, "U-Boot 1.1.4-gcf378d80-dirty (Aug 16 2018 - 07:51:15)" The GL-AR750S OEM U-Boot allows upload and flashing of either NOR firmware (sysupgrade.bin) or NAND firmware (factory.img) through its HTTP-based GUI. Serial connectivity is not required. The glinet,gl-ar750s-nor and glinet,gl-ar750s-nor-nand images generated after this commit flash each other directly. This commit changes the control of the USB VBUS to gpio-hog from regulator-fixed introduced by commit 0f6b944c92. This reduces the compressed kernel size by ~14 kB, with no apparent loss of functionality. No other ath79-nand boards are using regulator-fixed at this time. Note: mtd_get_mac_binary art 0x5006 does not return the proper MAC and the GL.iNet source indicates that only the 0x0 offset is valid The ar71xx targets are unmodified. Cc: Alexander Wördekemper Signed-off-by: Jeff Kletsky --- package/boot/uboot-envtools/files/ath79 | 2 + .../dts/qca9563_glinet_gl-ar750s-nor-nand.dts | 18 +++ .../dts/qca9563_glinet_gl-ar750s-nor.dts | 18 +++ ...750s.dts => qca9563_glinet_gl-ar750s.dtsi} | 112 +++++++++++------- .../generic/base-files/etc/board.d/02_network | 4 - .../etc/hotplug.d/firmware/11-ath10k-caldata | 3 +- target/linux/ath79/image/generic.mk | 10 -- target/linux/ath79/image/nand.mk | 31 +++++ .../nand/base-files/etc/board.d/02_network | 5 + .../etc/hotplug.d/firmware/11-ath10k-caldata | 5 + .../nand/base-files/lib/upgrade/platform.sh | 4 + 11 files changed, 152 insertions(+), 60 deletions(-) create mode 100644 target/linux/ath79/dts/qca9563_glinet_gl-ar750s-nor-nand.dts create mode 100644 target/linux/ath79/dts/qca9563_glinet_gl-ar750s-nor.dts rename target/linux/ath79/dts/{qca9563_glinet_gl-ar750s.dts => qca9563_glinet_gl-ar750s.dtsi} (74%) diff --git a/package/boot/uboot-envtools/files/ath79 b/package/boot/uboot-envtools/files/ath79 index d34469cbf4..e31100877e 100644 --- a/package/boot/uboot-envtools/files/ath79 +++ b/package/boot/uboot-envtools/files/ath79 @@ -20,6 +20,8 @@ glinet,gl-ar300m-lite|\ glinet,gl-ar300m-nand|\ glinet,gl-ar300m-nor|\ glinet,gl-ar300m16|\ +glinet,gl-ar750s-nor|\ +glinet,gl-ar750s-nor-nand|\ librerouter,librerouter-v1|\ netgear,ex6400|\ netgear,ex7300|\ diff --git a/target/linux/ath79/dts/qca9563_glinet_gl-ar750s-nor-nand.dts b/target/linux/ath79/dts/qca9563_glinet_gl-ar750s-nor-nand.dts new file mode 100644 index 0000000000..92d1fb9ba2 --- /dev/null +++ b/target/linux/ath79/dts/qca9563_glinet_gl-ar750s-nor-nand.dts @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +/dts-v1/; + +#include "qca9563_glinet_gl-ar750s.dtsi" + +/ { + compatible = "glinet,gl-ar750s-nor-nand", "qca,qca9563"; + model = "GL.iNet GL-AR750S (NOR/NAND)"; +}; + +&nor_kernel { + label = "kernel"; +}; + +&nand_ubi { + label = "ubi"; +}; diff --git a/target/linux/ath79/dts/qca9563_glinet_gl-ar750s-nor.dts b/target/linux/ath79/dts/qca9563_glinet_gl-ar750s-nor.dts new file mode 100644 index 0000000000..bb33abd630 --- /dev/null +++ b/target/linux/ath79/dts/qca9563_glinet_gl-ar750s-nor.dts @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +/dts-v1/; + +#include "qca9563_glinet_gl-ar750s.dtsi" + +/ { + compatible = "glinet,gl-ar750s-nor", "qca,qca9563"; + model = "GL.iNet GL-AR750S (NOR)"; +}; + +/delete-node/ &nor_kernel; +/delete-node/ &nor_reserved; + +&nor_firmware { + compatible = "denx,uimage"; + label = "firmware"; +}; diff --git a/target/linux/ath79/dts/qca9563_glinet_gl-ar750s.dts b/target/linux/ath79/dts/qca9563_glinet_gl-ar750s.dtsi similarity index 74% rename from target/linux/ath79/dts/qca9563_glinet_gl-ar750s.dts rename to target/linux/ath79/dts/qca9563_glinet_gl-ar750s.dtsi index 3f9a091824..8250db55ad 100644 --- a/target/linux/ath79/dts/qca9563_glinet_gl-ar750s.dts +++ b/target/linux/ath79/dts/qca9563_glinet_gl-ar750s.dtsi @@ -1,4 +1,5 @@ // SPDX-License-Identifier: GPL-2.0-or-later OR MIT + /dts-v1/; #include @@ -19,6 +20,7 @@ led-failsafe = &led_power; led-running = &led_power; led-upgrade = &led_power; + label-mac-device = ð0; }; keys { @@ -50,13 +52,13 @@ default-state = "keep"; }; - wlan2g { + led_wlan2g: wlan2g { label = "gl-ar750s:green:wlan2g"; gpios = <&gpio 19 GPIO_ACTIVE_LOW>; linux,default-trigger = "phy1tpt"; }; - wlan5g { + led_wlan5g: wlan5g { label = "gl-ar750s:green:wlan5g"; gpios = <&gpio 20 GPIO_ACTIVE_HIGH>; linux,default-trigger = "phy0tpt"; @@ -69,32 +71,20 @@ sda-gpios = <&gpio 5 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>; scl-gpios = <&gpio 21 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>; }; - - usb_vbus: regulator-usb-vbus { - compatible = "regulator-fixed"; - - regulator-name = "USB_VBUS"; - - regulator-min-microvolt = <5000000>; - regulator-max-microvolt = <5000000>; - regulator-always-on; - - gpio = <&gpio 7 GPIO_ACTIVE_HIGH>; - enable-active-high; - }; }; &spi { status = "okay"; - num-cs = <0>; + num-cs = <2>; + cs-gpios = <0>, <0>; - flash@0 { + flash_nor: flash@0 { compatible = "jedec,spi-nor"; reg = <0>; spi-max-frequency = <25000000>; - partitions { + nor_partitions: partitions { compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; @@ -116,38 +106,55 @@ read-only; }; - partition@60000 { - compatible = "denx,uimage"; - label = "firmware"; + nor_firmware: partition@60000 { + label = "nor_firmware"; reg = <0x060000 0xfa0000>; }; + + nor_kernel: partition_alt@60000 { + label = "nor_kernel"; + reg = <0x060000 0x400000>; + }; + + nor_reserved: parition_alt@460000 { + label = "nor_reserved"; + reg = <0x460000 0xba0000>; + }; + }; + }; + + flash_nand: flash@1 { + compatible = "spi-nand"; + reg = <1>; + spi-max-frequency = <25000000>; + + nand_partitions: partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + nand_ubi: partition@0 { + label = "nand_ubi"; + reg = <0x000000 0x8000000>; + }; }; }; }; -&pcie { +ð0 { status = "okay"; + + phy-handle = <&phy0>; + mtd-mac-address = <&art 0x0>; }; -&uart { - status = "okay"; -}; - -&usb0 { - status = "okay"; - vbus-supply = <&usb_vbus>; -}; - -&usb_phy0 { - status = "okay"; -}; - -&usb1 { - status = "okay"; -}; - -&usb_phy1 { - status = "okay"; +&gpio { + usb_vbus { + gpio-hog; + gpios = <7 GPIO_ACTIVE_HIGH>; + output-high; + line-name = "usb-vbus"; + }; }; &mdio0 { @@ -165,11 +172,28 @@ }; }; -ð0 { +&pcie { status = "okay"; +}; - mtd-mac-address = <&art 0x0>; - phy-handle = <&phy0>; +&uart { + status = "okay"; +}; + +&usb0 { + status = "okay"; +}; + +&usb1 { + status = "okay"; +}; + +&usb_phy0 { + status = "okay"; +}; + +&usb_phy1 { + status = "okay"; }; &wmac { diff --git a/target/linux/ath79/generic/base-files/etc/board.d/02_network b/target/linux/ath79/generic/base-files/etc/board.d/02_network index 3a896b55b0..07f3c4e83c 100755 --- a/target/linux/ath79/generic/base-files/etc/board.d/02_network +++ b/target/linux/ath79/generic/base-files/etc/board.d/02_network @@ -144,10 +144,6 @@ ath79_setup_interfaces() ucidef_add_switch "switch0" \ "0@eth0" "1:lan" "2:lan" ;; - glinet,gl-ar750s) - ucidef_add_switch "switch0" \ - "0@eth0" "2:lan:2" "3:lan:1" "1:wan" - ;; iodata,etg3-r|\ iodata,wn-ac1167dgr|\ iodata,wn-ac1600dgr|\ diff --git a/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/11-ath10k-caldata index b2ec803a72..f128e8759f 100644 --- a/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/11-ath10k-caldata +++ b/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/11-ath10k-caldata @@ -46,8 +46,7 @@ case "$FIRMWARE" in caldata_extract "art" 0x5000 0x844 ath10k_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) +1) ;; - glinet,gl-ar750|\ - glinet,gl-ar750s) + glinet,gl-ar750) caldata_extract "art" 0x5000 0x844 ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary art 0x0) +1) ;; diff --git a/target/linux/ath79/image/generic.mk b/target/linux/ath79/image/generic.mk index 6fc51ec647..f2c228926e 100644 --- a/target/linux/ath79/image/generic.mk +++ b/target/linux/ath79/image/generic.mk @@ -578,16 +578,6 @@ define Device/glinet_gl-ar750 endef TARGET_DEVICES += glinet_gl-ar750 -define Device/glinet_gl-ar750s - ATH_SOC := qca9563 - DEVICE_VENDOR := GL.iNet - DEVICE_MODEL := GL-AR750S - DEVICE_PACKAGES := kmod-usb2 kmod-ath10k-ct ath10k-firmware-qca9887-ct block-mount - IMAGE_SIZE := 16000k - SUPPORTED_DEVICES += gl-ar750s -endef -TARGET_DEVICES += glinet_gl-ar750s - define Device/glinet_gl-x750 ATH_SOC := qca9531 DEVICE_VENDOR := GL.iNet diff --git a/target/linux/ath79/image/nand.mk b/target/linux/ath79/image/nand.mk index f9961840f0..614a693285 100644 --- a/target/linux/ath79/image/nand.mk +++ b/target/linux/ath79/image/nand.mk @@ -75,6 +75,37 @@ define Device/glinet_gl-ar300m-nor endef TARGET_DEVICES += glinet_gl-ar300m-nor +define Device/glinet_gl-ar750s-common + ATH_SOC := qca9563 + DEVICE_VENDOR := GL.iNet + DEVICE_MODEL := GL-AR750S + DEVICE_PACKAGES := kmod-ath10k-ct ath10k-firmware-qca9887-ct \ + kmod-usb2 kmod-usb-storage block-mount + KERNEL_SIZE := 4096k + IMAGE_SIZE := 16000k + PAGESIZE := 2048 + VID_HDR_OFFSET := 2048 +endef + +define Device/glinet_gl-ar750s-nor-nand + $(Device/glinet_gl-ar750s-common) + DEVICE_VARIANT := NOR/NAND + BLOCKSIZE := 128k + IMAGES += factory.img + IMAGE/factory.img := append-kernel | pad-to $$$$(KERNEL_SIZE) | append-ubi + IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata + SUPPORTED_DEVICES += glinet,gl-ar750s-nor +endef +TARGET_DEVICES += glinet_gl-ar750s-nor-nand + +define Device/glinet_gl-ar750s-nor + $(Device/glinet_gl-ar750s-common) + DEVICE_VARIANT := NOR + BLOCKSIZE := 64k + SUPPORTED_DEVICES += gl-ar750s glinet,gl-ar750s glinet,gl-ar750s-nor-nand +endef +TARGET_DEVICES += glinet_gl-ar750s-nor + # fake rootfs is mandatory, pad-offset 129 equals (2 * uimage_header + 0xff) define Device/netgear_ath79_nand DEVICE_VENDOR := NETGEAR diff --git a/target/linux/ath79/nand/base-files/etc/board.d/02_network b/target/linux/ath79/nand/base-files/etc/board.d/02_network index 9d7a19c2eb..36ddb5e83a 100755 --- a/target/linux/ath79/nand/base-files/etc/board.d/02_network +++ b/target/linux/ath79/nand/base-files/etc/board.d/02_network @@ -11,6 +11,11 @@ ath79_setup_interfaces() aerohive,hiveap-121) ucidef_set_interface_lan "eth0" ;; + glinet,gl-ar750s-nor|\ + glinet,gl-ar750s-nor-nand) + ucidef_add_switch "switch0" \ + "0@eth0" "2:lan:2" "3:lan:1" "1:wan" + ;; netgear,wndr4300) ucidef_add_switch "switch0" \ "0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan" diff --git a/target/linux/ath79/nand/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/ath79/nand/base-files/etc/hotplug.d/firmware/11-ath10k-caldata index 433d6475dd..9305f061fe 100644 --- a/target/linux/ath79/nand/base-files/etc/hotplug.d/firmware/11-ath10k-caldata +++ b/target/linux/ath79/nand/base-files/etc/hotplug.d/firmware/11-ath10k-caldata @@ -9,6 +9,11 @@ board=$(board_name) case "$FIRMWARE" in "ath10k/cal-pci-0000:00:00.0.bin") case $board in + glinet,gl-ar750s-nor|\ + glinet,gl-ar750s-nor-nand) + caldata_extract "art" 0x5000 0x844 + ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary art 0x0) +1) + ;; zyxel,nbg6716) caldata_extract "art" 0x5000 0x844 ath10k_patch_mac $(macaddr_add $(mtd_get_mac_ascii u-boot-env ethaddr) +1) diff --git a/target/linux/ath79/nand/base-files/lib/upgrade/platform.sh b/target/linux/ath79/nand/base-files/lib/upgrade/platform.sh index 69105b1668..15d88a361e 100644 --- a/target/linux/ath79/nand/base-files/lib/upgrade/platform.sh +++ b/target/linux/ath79/nand/base-files/lib/upgrade/platform.sh @@ -18,6 +18,10 @@ platform_do_upgrade() { glinet,gl-ar300m-nor) glinet_nand_nor_do_upgrade "$1" ;; + glinet,gl-ar750s-nor|\ + glinet,gl-ar750s-nor-nand) + nand_nor_do_upgrade "$1" + ;; *) nand_do_upgrade "$1" ;; From 000b7687bc50be5b0f1161f4bf8ceb85c495c395 Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Thu, 14 Nov 2019 14:02:56 +0100 Subject: [PATCH 05/22] mac80211: restore mac80211_interface_cleanup() Changes introduced for dynamic wifi reconfiguration left behind unmanaged interface types. Restore parts of the old function to also clean (unencrypted, non-DFS) mesh and ad-hoc interfaces. Fixes: a5bc9787d4 ("mac80211: add support for dynamically reconfiguring wifi") Signed-off-by: Daniel Golle --- .../files/lib/netifd/wireless/mac80211.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh b/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh index 5b174cded6..2b8b2d4677 100644 --- a/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh +++ b/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh @@ -814,6 +814,13 @@ mac80211_interface_cleanup() { mac80211_vap_cleanup hostapd "${primary_ap}" mac80211_vap_cleanup wpa_supplicant "$(uci -q -P /var/state get wireless._${phy}.splist)" + for wdev in $(list_phy_interfaces "$phy"); do + local wdev_phy="$(readlink /sys/class/net/${wdev}/phy80211)" + wdev_phy="$(basename "$wdev_phy")" + [ -n "$wdev_phy" -a "$wdev_phy" != "$phy" ] && continue + ip link set dev "$wdev" down 2>/dev/null + iw dev "$wdev" del + done } mac80211_set_noscan() { @@ -945,6 +952,15 @@ drv_mac80211_setup() { wireless_set_up } +list_phy_interfaces() { + local phy="$1" + if [ -d "/sys/class/ieee80211/${phy}/device/net" ]; then + ls "/sys/class/ieee80211/${phy}/device/net" 2>/dev/null; + else + ls "/sys/class/ieee80211/${phy}/device" 2>/dev/null | grep net: | sed -e 's,net:,,g' + fi +} + drv_mac80211_teardown() { wireless_process_kill_all From 1c6066a867400eca9e335235ff4dc43acacc1183 Mon Sep 17 00:00:00 2001 From: Roger Pueyo Centelles Date: Wed, 13 Nov 2019 09:18:59 -0600 Subject: [PATCH 06/22] ath79: include rssileds package for ubnt devices with LEDs Some Ubiquiti devices had the RSSI LEDs configured in 01_leds but were missing the rssileds package, while others that don't have RSSI LEDS had the package included. This commit includes the rssileds package only for those devices that need it. Tested on a NanoStation M XW. Signed-off-by: Roger Pueyo Centelles --- target/linux/ath79/image/generic-ubnt.mk | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/target/linux/ath79/image/generic-ubnt.mk b/target/linux/ath79/image/generic-ubnt.mk index 727025ba67..19dbe2eb8b 100644 --- a/target/linux/ath79/image/generic-ubnt.mk +++ b/target/linux/ath79/image/generic-ubnt.mk @@ -64,7 +64,7 @@ endef define Device/ubnt-xm $(Device/ubnt) DEVICE_VARIANT := XM - DEVICE_PACKAGES += kmod-usb-ohci rssileds + DEVICE_PACKAGES += kmod-usb-ohci IMAGE_SIZE := 7448k UBNT_TYPE := XM UBNT_CHIP := ar7240 @@ -106,6 +106,7 @@ TARGET_DEVICES += ubnt_airrouter define Device/ubnt_bullet-m $(Device/ubnt-xm) DEVICE_MODEL := Bullet-M + DEVICE_PACKAGES += rssileds SUPPORTED_DEVICES += bullet-m endef TARGET_DEVICES += ubnt_bullet-m @@ -113,6 +114,7 @@ TARGET_DEVICES += ubnt_bullet-m define Device/ubnt_bullet-m-xw $(Device/ubnt-xw) DEVICE_MODEL := Bullet-M + DEVICE_PACKAGES += rssileds SUPPORTED_DEVICES += bullet-m-xw endef TARGET_DEVICES += ubnt_bullet-m-xw @@ -129,7 +131,7 @@ TARGET_DEVICES += ubnt_lap-120 define Device/ubnt_nanobeam-ac $(Device/ubnt-wa) DEVICE_MODEL := NanoBeam AC - DEVICE_PACKAGES += kmod-ath10k-ct ath10k-firmware-qca988x-ct + DEVICE_PACKAGES += kmod-ath10k-ct ath10k-firmware-qca988x-ct rssileds IMAGE/factory.bin := $$(IMAGE/sysupgrade.bin) | mkubntimage-split endef TARGET_DEVICES += ubnt_nanobeam-ac @@ -137,7 +139,7 @@ TARGET_DEVICES += ubnt_nanobeam-ac define Device/ubnt_nanostation-ac $(Device/ubnt-wa) DEVICE_MODEL := Nanostation AC - DEVICE_PACKAGES += kmod-ath10k-ct ath10k-firmware-qca988x-ct + DEVICE_PACKAGES += kmod-ath10k-ct ath10k-firmware-qca988x-ct rssileds IMAGE/factory.bin := $$(IMAGE/sysupgrade.bin) | mkubntimage-split endef TARGET_DEVICES += ubnt_nanostation-ac @@ -153,6 +155,7 @@ TARGET_DEVICES += ubnt_nanostation-ac-loco define Device/ubnt_nanostation-m $(Device/ubnt-xm) DEVICE_MODEL := Nanostation M + DEVICE_PACKAGES += rssileds SUPPORTED_DEVICES += nanostation-m endef TARGET_DEVICES += ubnt_nanostation-m @@ -160,6 +163,7 @@ TARGET_DEVICES += ubnt_nanostation-m define Device/ubnt_nanostation-m-xw $(Device/ubnt-xw) DEVICE_MODEL := Nanostation M + DEVICE_PACKAGES += rssileds SUPPORTED_DEVICES += nanostation-m-xw endef TARGET_DEVICES += ubnt_nanostation-m-xw @@ -167,6 +171,7 @@ TARGET_DEVICES += ubnt_nanostation-m-xw define Device/ubnt_rocket-m $(Device/ubnt-xm) DEVICE_MODEL := Rocket-M + DEVICE_PACKAGES += rssileds SUPPORTED_DEVICES += rocket-m endef TARGET_DEVICES += ubnt_rocket-m From 6990510aca41074351f92a5abc6f4afb4b606506 Mon Sep 17 00:00:00 2001 From: Sungbo Eo Date: Tue, 12 Nov 2019 01:16:28 +0900 Subject: [PATCH 07/22] kernel: fix typo in fb-sys-fops autoload AutoLoad parameter must match the exact kernel module name. Fix it. Fixes: 125f1ce9ad0c ("kernel: video: add DRM core and IMX DRM support for HDMI/LVDS") Signed-off-by: Sungbo Eo --- package/kernel/linux/modules/video.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/kernel/linux/modules/video.mk b/package/kernel/linux/modules/video.mk index 5e2484cec5..232dbd1d34 100644 --- a/package/kernel/linux/modules/video.mk +++ b/package/kernel/linux/modules/video.mk @@ -151,7 +151,7 @@ define KernelPackage/fb-sys-fops DEPENDS:=+kmod-fb KCONFIG:=CONFIG_FB_SYS_FOPS FILES:=$(LINUX_DIR)/drivers/video/fbdev/core/fb_sys_fops.ko - AUTOLOAD:=$(call AutoLoad,07,fbsysfops) + AUTOLOAD:=$(call AutoLoad,07,fb_sys_fops) endef define KernelPackage/fb-sys-fops/description From f962e021d48fc2cc4e9e884e3639b5046cec9c2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20=C5=A0tetiar?= Date: Mon, 11 Nov 2019 21:37:45 +0100 Subject: [PATCH 08/22] kernel-build: fix kernel_menuconfig breakage by forcing YACC MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commit 965f341aa9fd ("build: fix host menu config targets using ncurses") has moved host's path with pkg-config (usually /usr/bin) at the first place in PATH variable, which is now causing issues with bison as BISON_PKGDATADIR points into STAGING_DIR_HOST, but the actual bison used is the one under host PATH (usually /usr/bin/bison), leading to the following strange failures: $ make target/linux/clean kernel_menuconfig V=sc export MAKEFLAGS= ;make -C /somewhere/linux-4.19.81 menuconfig make -f ./scripts/Makefile.build obj=scripts/kconfig menuconfig ... bison -oscripts/kconfig/zconf.tab.c -t -l scripts/kconfig/zconf.y staging_dir/host/bin/m4: cannot open `staging_dir/host/share/bison/bison.m4': No such file or directory staging_dir/host/bin/m4: cannot open `staging_dir/host/share/bison/c-skel.m4': No such file or directory ... gcc -Wp,-MD,scripts/kconfig/.zconf.tab.o.d <...snip...> -o scripts/kconfig/zconf.tab.o scripts/kconfig/zconf.tab.c gcc: error: scripts/kconfig/zconf.tab.c: No such file or directory gcc: fatal error: no input files Fix this by forcing usage of bison under STAGING_DIR_HOST/bin via YACC make variable. Cc: Thomas Albers Cc: Stijn Tintel Cc: Eneas U de Queiroz Tested-by: Ivan Revyakin Tested-by: Thomas Albers Ref: https://forum.openwrt.org/t/bpi-r64-kernel-4-19-kernel-menuconfig-error Fixes: 965f341aa9fd ("build: fix host menu config targets using ncurses") Signed-off-by: Petr Štetiar --- include/kernel-build.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/include/kernel-build.mk b/include/kernel-build.mk index 3fdf7efc52..684fbd34d3 100644 --- a/include/kernel-build.mk +++ b/include/kernel-build.mk @@ -163,6 +163,7 @@ define BuildKernel $(LINUX_RECONF_CMD) > $(LINUX_DIR)/.config $(_SINGLE)$(KERNEL_MAKE) \ $(if $(findstring Darwin,$(HOST_OS)),HOST_LOADLIBES="-L$(STAGING_DIR_HOST)/lib -lncurses") \ + YACC=$(STAGING_DIR_HOST)/bin/bison \ $$@ $(LINUX_RECONF_DIFF) $(LINUX_DIR)/.config > $(LINUX_RECONFIG_TARGET) From fa8345539262f71a5fcc8667374b7e064dc43439 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20=C5=A0tetiar?= Date: Mon, 11 Nov 2019 22:14:21 +0100 Subject: [PATCH 09/22] ath79: remove obsolete OF PCI related config symbols MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Those symbols were removed in kernel 4.16: commit 4670d610d59233b017a6ea1fa25bbf06dabbff42 Author: Rob Herring PCI: Move OF-related PCI functions into PCI core Fixes: FS#2588 Signed-off-by: Petr Štetiar --- target/linux/ath79/config-4.19 | 3 --- 1 file changed, 3 deletions(-) diff --git a/target/linux/ath79/config-4.19 b/target/linux/ath79/config-4.19 index 42843a1858..be5e46ac76 100644 --- a/target/linux/ath79/config-4.19 +++ b/target/linux/ath79/config-4.19 @@ -179,7 +179,6 @@ CONFIG_NO_GENERIC_PCI_IOPORT_MAP=y CONFIG_NVMEM=y CONFIG_OF=y CONFIG_OF_ADDRESS=y -CONFIG_OF_ADDRESS_PCI=y CONFIG_OF_EARLY_FLATTREE=y CONFIG_OF_FLATTREE=y CONFIG_OF_GPIO=y @@ -187,8 +186,6 @@ CONFIG_OF_IRQ=y CONFIG_OF_KOBJ=y CONFIG_OF_MDIO=y CONFIG_OF_NET=y -CONFIG_OF_PCI=y -CONFIG_OF_PCI_IRQ=y CONFIG_PCI=y CONFIG_PCI_AR71XX=y CONFIG_PCI_AR724X=y From 953c27df315ded7fae45daba0229ced4309e4baa Mon Sep 17 00:00:00 2001 From: Peter Stadler Date: Tue, 12 Nov 2019 15:54:53 +0100 Subject: [PATCH 10/22] base-files: rc.common: fix missing EXTRA_HELP texts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commit ed5b9129d7a4 ("base-files: implement generic service_running") has added EXTRA_HELP variable, thus overriding already available EXTRA_HELP text available in other init scripts, resulting in the missing help text from services like dropbear for example. So fix this regression by appending EXTRA_HELP text provided by the other init scripts into the one provided by the script itself. Fixes: ed5b9129d7a4 ("base-files: implement generic service_running") Signed-off-by: Peter Stadler [commit title/description facelift, fixes tag, fixed From:, pkg bump] Signed-off-by: Petr Štetiar --- package/base-files/Makefile | 2 +- package/base-files/files/etc/rc.common | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package/base-files/Makefile b/package/base-files/Makefile index b35d00cf94..0ca4d739f3 100644 --- a/package/base-files/Makefile +++ b/package/base-files/Makefile @@ -12,7 +12,7 @@ include $(INCLUDE_DIR)/version.mk include $(INCLUDE_DIR)/feeds.mk PKG_NAME:=base-files -PKG_RELEASE:=208 +PKG_RELEASE:=209 PKG_FLAGS:=nonshared PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/ diff --git a/package/base-files/files/etc/rc.common b/package/base-files/files/etc/rc.common index d3fa3be505..dbe26ec3bd 100755 --- a/package/base-files/files/etc/rc.common +++ b/package/base-files/files/etc/rc.common @@ -109,7 +109,7 @@ ${INIT_TRACE:+set -x} EXTRA_HELP="\ running Check if service is running status Service status - " +${EXTRA_HELP}" . $IPKG_INSTROOT/lib/functions/procd.sh basescript=$(readlink "$initscript") From c001ace8bdf03fec036840638a1fa2a1edd8b2b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20=C5=A0tetiar?= Date: Thu, 14 Nov 2019 16:50:18 +0100 Subject: [PATCH 11/22] build: prereq: simplify Python 3 version checks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We don't need to check if python3.5 binary is actually Python 3.5+. Signed-off-by: Petr Štetiar --- include/prereq-build.mk | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/prereq-build.mk b/include/prereq-build.mk index 4c59910056..d73f0040c3 100644 --- a/include/prereq-build.mk +++ b/include/prereq-build.mk @@ -144,15 +144,15 @@ $(eval $(call SetupHostCommand,perl,Please install Perl 5.x, \ $(eval $(call CleanupPython2)) $(eval $(call SetupHostCommand,python,Please install Python >= 3.5, \ - python3.7 -V 2>&1 | grep -E 'Python 3\.[5-9]\.?', \ - python3.6 -V 2>&1 | grep -E 'Python 3\.[5-9]\.?', \ - python3.5 -V 2>&1 | grep -E 'Python 3\.[5-9]\.?', \ + python3.7 -V 2>&1 | grep 'Python 3', \ + python3.6 -V 2>&1 | grep 'Python 3', \ + python3.5 -V 2>&1 | grep 'Python 3', \ python3 -V 2>&1 | grep -E 'Python 3\.[5-9]\.?')) $(eval $(call SetupHostCommand,python3,Please install Python >= 3.5, \ - python3.7 -V 2>&1 | grep -E 'Python 3\.[5-9]\.?', \ - python3.6 -V 2>&1 | grep -E 'Python 3\.[5-9]\.?', \ - python3.5 -V 2>&1 | grep -E 'Python 3\.[5-9]\.?', \ + python3.7 -V 2>&1 | grep 'Python 3', \ + python3.6 -V 2>&1 | grep 'Python 3', \ + python3.5 -V 2>&1 | grep 'Python 3', \ python3 -V 2>&1 | grep -E 'Python 3\.[5-9]\.?')) $(eval $(call SetupHostCommand,git,Please install Git (git-core) >= 1.7.12.2, \ From 2066ee09d99441a67a5f23b6e38baeadc9f92e15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Thu, 14 Nov 2019 16:41:10 +0100 Subject: [PATCH 12/22] build: prereq: add support for Python 3.8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add support for Python 3.8 which was released Oct. 14, 2019. Signed-off-by: Thomas Weißschuh [added missing commit description, simplified version check] Signed-off-by: Petr Štetiar --- include/prereq-build.mk | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/prereq-build.mk b/include/prereq-build.mk index d73f0040c3..a711ae33f7 100644 --- a/include/prereq-build.mk +++ b/include/prereq-build.mk @@ -144,12 +144,14 @@ $(eval $(call SetupHostCommand,perl,Please install Perl 5.x, \ $(eval $(call CleanupPython2)) $(eval $(call SetupHostCommand,python,Please install Python >= 3.5, \ + python3.8 -V 2>&1 | grep 'Python 3', \ python3.7 -V 2>&1 | grep 'Python 3', \ python3.6 -V 2>&1 | grep 'Python 3', \ python3.5 -V 2>&1 | grep 'Python 3', \ python3 -V 2>&1 | grep -E 'Python 3\.[5-9]\.?')) $(eval $(call SetupHostCommand,python3,Please install Python >= 3.5, \ + python3.8 -V 2>&1 | grep 'Python 3', \ python3.7 -V 2>&1 | grep 'Python 3', \ python3.6 -V 2>&1 | grep 'Python 3', \ python3.5 -V 2>&1 | grep 'Python 3', \ From 5d7fcd07a21aada05e2f5b406a0eb25264e68f29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20=C5=A0tetiar?= Date: Thu, 14 Nov 2019 21:06:47 +0100 Subject: [PATCH 13/22] libnl-tiny: update to latest Git head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 0219008cc876 remove never used err variable assignment disliked by scan-build 7ce813fcd667 silence use after the free clang analyzer warning 1f73b6a8e678 use offsetof macro to make scan-build happy Signed-off-by: Petr Štetiar --- package/libs/libnl-tiny/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package/libs/libnl-tiny/Makefile b/package/libs/libnl-tiny/Makefile index 4fde17a365..3c5f6d79f4 100644 --- a/package/libs/libnl-tiny/Makefile +++ b/package/libs/libnl-tiny/Makefile @@ -12,9 +12,9 @@ PKG_RELEASE:=1 PKG_SOURCE_PROTO:=git PKG_SOURCE_URL=$(PROJECT_GIT)/project/libnl-tiny.git -PKG_SOURCE_DATE:=2019-10-04 -PKG_SOURCE_VERSION:=0230d0698e596ab2e836abd2459d970b14bacb25 -PKG_MIRROR_HASH:=a2543a577a91fbf9ee7fe662a1e2675da1d65d2f56bba8471a2cfe2ddd1cd46a +PKG_SOURCE_DATE:=2019-10-29 +PKG_SOURCE_VERSION:=0219008cc8767655d7e747497e8e1133a3e8f840 +PKG_MIRROR_HASH:=b84fab21374c6ddbf992acc4ec1c9c6896b32af97603027ca5c866d69d95780f CMAKE_INSTALL:=1 PKG_LICENSE:=LGPL-2.1 From 240d590ca4513b021ebcbe38bde91770bd800536 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20=C5=A0tetiar?= Date: Thu, 14 Nov 2019 22:31:02 +0100 Subject: [PATCH 14/22] uci: update to latest Git head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 8dd50da20de0 lua: fix error handling a2cab3b088a2 ucimap: fix possible use of memory after it is freed 9cf978bc7964 delta: prevent possible null pointer use 7736f497d2d9 cli: remove unused variable assigment 39093f3b040d lua: fix memory leak in set method 19ceff323f1e lua: fix memory leak in changes method 18049a84fe40 tests: add cram based unit tests 2b549cc050de lua: fix copy&paste in error string f5dd5217d627 cli: fix realloc issue spotted by cppcheck af59f86a0db9 iron out all extra compiler warnings 1637d2918692 tests: shunit2: run all tests under Valgrind by default c1af73bfb023 cmake: enable extra compiler checks be69504e3666 cmake: build Lua module only if enabled 38a2f12ec5ab tests: shunit2: fix issues reported by shellcheck 266fc9e94c1e add initial GitLab CI support 17d6144a49c6 tests: shunit2: make it working under CMake a6e8bbefd860 cmake: add unit testing option and shunit2 tests 0ca93fec701a test: move shunit2 tests under standalone subdirectory Signed-off-by: Petr Štetiar --- package/system/uci/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package/system/uci/Makefile b/package/system/uci/Makefile index d3169e01fa..dd08c43d29 100644 --- a/package/system/uci/Makefile +++ b/package/system/uci/Makefile @@ -13,9 +13,9 @@ PKG_RELEASE:=3 PKG_SOURCE_URL=$(PROJECT_GIT)/project/uci.git PKG_SOURCE_PROTO:=git -PKG_SOURCE_DATE=2019-11-08 -PKG_SOURCE_VERSION:=fc417e808087f96466d9ce18819e16476af9527b -PKG_MIRROR_HASH:=9d9f4756633e4b011ae68138793723c6443d0d81c7f626580881dc0cae77eceb +PKG_SOURCE_DATE=2019-11-14 +PKG_SOURCE_VERSION:=8dd50da20de0ece65118b2b4b71f8df8ac3a1f6d +PKG_MIRROR_HASH:=6c74d7dc777a64fd833c207fb7c7107f55d7b42ba7184ebaef5fc34f686c4a25 PKG_LICENSE:=LGPL-2.1 PKG_LICENSE_FILES:= From 8f0a540648e1089ed83faf6f0283a1957123526b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20=C5=A0tetiar?= Date: Thu, 14 Nov 2019 22:42:41 +0100 Subject: [PATCH 15/22] fwtool: update to latest Git head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 8f7fe925ca20 cmake: use extra compiler warnings only on gcc6+ Signed-off-by: Petr Štetiar --- package/system/fwtool/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package/system/fwtool/Makefile b/package/system/fwtool/Makefile index 8397282392..00f0339b02 100644 --- a/package/system/fwtool/Makefile +++ b/package/system/fwtool/Makefile @@ -12,9 +12,9 @@ PKG_RELEASE:=1 PKG_SOURCE_PROTO:=git PKG_SOURCE_URL=$(PROJECT_GIT)/project/fwtool.git -PKG_SOURCE_DATE:=2019-11-09 -PKG_SOURCE_VERSION:=9d9d4c2847862adec2f474d4126213c17f98e024 -PKG_MIRROR_HASH:=4a72a48cbc7cda4c1860ec8328c049b4b84f7f00273d82ee98175937b63af1f8 +PKG_SOURCE_DATE:=2019-11-12 +PKG_SOURCE_VERSION:=8f7fe925ca205c8e8e2d0d1b16218c1e148d5173 +PKG_MIRROR_HASH:=ff68e77397a7ba8f497aae9a6d1f89e196c89391a8d5ed0b81c4eafb889ba744 CMAKE_INSTALL:=1 PKG_FLAGS:=nonshared From bcee364944808759ec4fc572ea6d21cd1393b84b Mon Sep 17 00:00:00 2001 From: Adrian Schmutzler Date: Thu, 14 Nov 2019 12:19:16 +0100 Subject: [PATCH 16/22] ath79: improve common DTSI name for TP-Link Archer C5, C7 v1/v2 As the former qca9558_tplink_archer-c7.dtsi is also used for Archer C5 v1 this patch removes the number from the DTSI name to indicate that. Signed-off-by: Adrian Schmutzler --- ...a9558_tplink_archer-c7.dtsi => qca9558_tplink_archer-c.dtsi} | 0 target/linux/ath79/dts/qca9558_tplink_archer-c5-v1.dts | 2 +- target/linux/ath79/dts/qca9558_tplink_archer-c7-v1.dts | 2 +- target/linux/ath79/dts/qca9558_tplink_archer-c7-v2.dts | 2 +- 4 files changed, 3 insertions(+), 3 deletions(-) rename target/linux/ath79/dts/{qca9558_tplink_archer-c7.dtsi => qca9558_tplink_archer-c.dtsi} (100%) diff --git a/target/linux/ath79/dts/qca9558_tplink_archer-c7.dtsi b/target/linux/ath79/dts/qca9558_tplink_archer-c.dtsi similarity index 100% rename from target/linux/ath79/dts/qca9558_tplink_archer-c7.dtsi rename to target/linux/ath79/dts/qca9558_tplink_archer-c.dtsi diff --git a/target/linux/ath79/dts/qca9558_tplink_archer-c5-v1.dts b/target/linux/ath79/dts/qca9558_tplink_archer-c5-v1.dts index 960d80eee2..261f655756 100644 --- a/target/linux/ath79/dts/qca9558_tplink_archer-c5-v1.dts +++ b/target/linux/ath79/dts/qca9558_tplink_archer-c5-v1.dts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-or-later OR MIT /dts-v1/; -#include "qca9558_tplink_archer-c7.dtsi" +#include "qca9558_tplink_archer-c.dtsi" / { compatible = "tplink,archer-c5-v1", "qca,qca9558"; diff --git a/target/linux/ath79/dts/qca9558_tplink_archer-c7-v1.dts b/target/linux/ath79/dts/qca9558_tplink_archer-c7-v1.dts index fda519439a..0988359984 100644 --- a/target/linux/ath79/dts/qca9558_tplink_archer-c7-v1.dts +++ b/target/linux/ath79/dts/qca9558_tplink_archer-c7-v1.dts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-or-later OR MIT /dts-v1/; -#include "qca9558_tplink_archer-c7.dtsi" +#include "qca9558_tplink_archer-c.dtsi" / { compatible = "tplink,archer-c7-v1", "qca,qca9558"; diff --git a/target/linux/ath79/dts/qca9558_tplink_archer-c7-v2.dts b/target/linux/ath79/dts/qca9558_tplink_archer-c7-v2.dts index 7cdfa56dfd..7040d9b52b 100644 --- a/target/linux/ath79/dts/qca9558_tplink_archer-c7-v2.dts +++ b/target/linux/ath79/dts/qca9558_tplink_archer-c7-v2.dts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-or-later OR MIT /dts-v1/; -#include "qca9558_tplink_archer-c7.dtsi" +#include "qca9558_tplink_archer-c.dtsi" / { compatible = "tplink,archer-c7-v2", "qca,qca9558"; From 71fbec0eff7aeadf63bf3f2dd5fa11c58c20995e Mon Sep 17 00:00:00 2001 From: Adrian Schmutzler Date: Thu, 14 Nov 2019 13:03:49 +0100 Subject: [PATCH 17/22] ath79: fix indent in TP-Link TL-WDR4900 v2 DTS Signed-off-by: Adrian Schmutzler --- target/linux/ath79/dts/qca9558_tplink_tl-wdr4900-v2.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/linux/ath79/dts/qca9558_tplink_tl-wdr4900-v2.dts b/target/linux/ath79/dts/qca9558_tplink_tl-wdr4900-v2.dts index f32e9ff125..4f6d39e92e 100644 --- a/target/linux/ath79/dts/qca9558_tplink_tl-wdr4900-v2.dts +++ b/target/linux/ath79/dts/qca9558_tplink_tl-wdr4900-v2.dts @@ -57,7 +57,7 @@ }; }; - ath9k-leds { + ath9k-leds { compatible = "gpio-leds"; wlan5g { From 119e0d57aedb8fd586fee57d2c8be023a309c2cb Mon Sep 17 00:00:00 2001 From: Michal Cieslakiewicz Date: Wed, 13 Nov 2019 14:19:31 -0500 Subject: [PATCH 18/22] ath79: split dts file for Netgear WNDR4300 Move board configuration to dtsi file in preparation for WNDR3700v4 router support. Signed-off-by: Michal Cieslakiewicz --- .../linux/ath79/dts/ar9344_netgear_wndr.dtsi | 290 ++++++++++++++++++ .../ath79/dts/ar9344_netgear_wndr4300.dts | 286 +---------------- 2 files changed, 291 insertions(+), 285 deletions(-) create mode 100644 target/linux/ath79/dts/ar9344_netgear_wndr.dtsi diff --git a/target/linux/ath79/dts/ar9344_netgear_wndr.dtsi b/target/linux/ath79/dts/ar9344_netgear_wndr.dtsi new file mode 100644 index 0000000000..16a4e3f6e8 --- /dev/null +++ b/target/linux/ath79/dts/ar9344_netgear_wndr.dtsi @@ -0,0 +1,290 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/dts-v1/; + +#include +#include + +#include "ar9344.dtsi" + +/ { + chosen { + bootargs = "console=ttyS0,115200n8"; + }; + + aliases { + led-boot = &led_power_amber; + led-failsafe = &led_power_amber; + led-running = &led_power_green; + led-upgrade = &led_power_amber; + label-mac-device = ð0; + }; + + keys { + compatible = "gpio-keys"; + + wps { + label = "wps"; + linux,code = ; + gpios = <&gpio 12 GPIO_ACTIVE_LOW>; + }; + + reset { + label = "reset"; + linux,code = ; + gpios = <&gpio 21 GPIO_ACTIVE_LOW>; + }; + + rfkill { + label = "rfkill"; + linux,code = ; + gpios = <&gpio 15 GPIO_ACTIVE_LOW>; + }; + }; + + leds { + compatible = "gpio-leds"; + + pinctrl-names = "default"; + pinctrl-0 = <&enable_gpio_11>; + + led_power_green: power_green { + label = "netgear:green:power"; + gpios = <&gpio 0 GPIO_ACTIVE_LOW>; + }; + + led_power_amber: power_amber { + label = "netgear:amber:power"; + gpios = <&gpio 2 GPIO_ACTIVE_LOW>; + default-state = "keep"; + }; + + wan_green { + label = "netgear:green:wan"; + gpios = <&gpio 1 GPIO_ACTIVE_LOW>; + }; + + wan_amber { + label = "netgear:amber:wan"; + gpios = <&gpio 3 GPIO_ACTIVE_LOW>; + }; + + wlan2g_green { + label = "netgear:green:wlan2g"; + gpios = <&gpio 11 GPIO_ACTIVE_LOW>; + linux,default-trigger = "phy0tpt"; + }; + + wlan5g_blue { + label = "netgear:blue:wlan5g"; + gpios = <&gpio 14 GPIO_ACTIVE_LOW>; + linux,default-trigger = "phy1tpt"; + }; + + wps_green { + label = "netgear:green:wps"; + gpios = <&gpio 16 GPIO_ACTIVE_LOW>; + }; + + wps_amber { + label = "netgear:amber:wps"; + gpios = <&gpio 17 GPIO_ACTIVE_LOW>; + }; + + usb_green { + label = "netgear:green:usb"; + gpios = <&gpio 13 GPIO_ACTIVE_LOW>; + trigger-sources = <&hub_port>; + linux,default-trigger = "usbport"; + }; + }; +}; + +&pinmux { + enable_gpio_11: pinmux_enable_gpio_11 { + pinctrl-single,bits = <0x8 0x0 0xff000000>; + }; +}; + +&nand { + status = "okay"; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "u-boot"; + reg = <0x0 0x40000>; + read-only; + }; + + partition@40000 { + label = "u-boot-env"; + reg = <0x40000 0x40000>; + }; + + art: partition@80000 { + label = "caldata"; + reg = <0x80000 0x40000>; + read-only; + }; + + partition@c0000 { + label = "pot"; + reg = <0xc0000 0x80000>; + }; + + partition@140000 { + label = "language"; + reg = <0x140000 0x200000>; + }; + + partition@340000 { + label = "config"; + reg = <0x340000 0x80000>; + }; + + partition@3c0000 { + label = "traffic_meter"; + reg = <0x3c0000 0x300000>; + }; + + kernel@6c0000 { + label = "kernel"; + reg = <0x6c0000 0x200000>; + }; + + ubi@8c0000 { + label = "ubi"; + reg = <0x8c0000 0x1700000>; + }; + + partition@6c0000 { + label = "firmware"; + reg = <0x6c0000 0x1900000>; + compatible = "netgear,uimage"; + }; + + partition@1fc0000 { + label = "caldata_backup"; + reg = <0x1fc0000 0x40000>; + read-only; + }; + + partition@2000000 { + label = "reserved"; + reg = <0x2000000 0x6000000>; + read-only; + }; + }; +}; + +&ref { + clock-frequency = <40000000>; +}; + +&builtin_switch { + resets = <&rst 8>, <&rst 12>; + reset-names = "switch", "switch-analog"; +}; + +&mdio0 { + status = "okay"; + + phy-mask = <0>; + + phy0: ethernet-phy@0 { + reg = <0>; + phy-mode = "rgmii"; + qca,mib-poll-interval = <500>; + + qca,ar8327-initvals = < + 0x04 0x07600000 + 0x0c 0x01000000 + 0x10 0xc1000000 + 0x50 0xcc35cc35 + 0x54 0xcb37cb37 + 0x58 0x00000000 + 0x5c 0x00f3cf00 + 0x7c 0x0000007e + 0x94 0x0000007e + >; + }; +}; + +ð0 { + status = "okay"; + + /* default for ar934x, except for 1000M */ + pll-data = <0x06000000 0x00000101 0x00001616>; + + mtd-mac-address = <&art 0x0>; + + phy-mode = "rgmii"; + phy-handle = <&phy0>; +}; + +&gpio { + status = "okay"; + + lna0 { + gpio-hog; + line-name = "netgear:ext:lna0"; + gpios = <18 GPIO_ACTIVE_HIGH>; + output-high; + }; + + lna1 { + gpio-hog; + line-name = "netgear:ext:lna1"; + gpios = <19 GPIO_ACTIVE_HIGH>; + output-high; + }; +}; + +&wmac { + status = "okay"; + + mtd-mac-address = <&art 0x0>; + qca,no-eeprom; +}; + +&pcie { + status = "okay"; + + ath9k: wifi@0,0 { + compatible = "pci168c,0033"; + reg = <0x0000 0 0 0 0>; + mtd-mac-address = <&art 0xc>; + qca,no-eeprom; + #gpio-cells = <2>; + gpio-controller; + + usb_power { + gpio-hog; + line-name = "netgear:power:usb"; + gpios = <0 GPIO_ACTIVE_HIGH>; + output-high; + }; + }; +}; + +&usb_phy { + status = "okay"; +}; + +&usb { + status = "okay"; + #address-cells = <1>; + #size-cells = <0>; + + hub_port: port@1 { + reg = <1>; + #trigger-source-cells = <0>; + }; +}; + +&uart { + status = "okay"; +}; diff --git a/target/linux/ath79/dts/ar9344_netgear_wndr4300.dts b/target/linux/ath79/dts/ar9344_netgear_wndr4300.dts index 08cd84e51e..9b57bb88a6 100644 --- a/target/linux/ath79/dts/ar9344_netgear_wndr4300.dts +++ b/target/linux/ath79/dts/ar9344_netgear_wndr4300.dts @@ -1,293 +1,9 @@ // SPDX-License-Identifier: GPL-2.0-or-later OR MIT /dts-v1/; -#include -#include - -#include "ar9344.dtsi" +#include "ar9344_netgear_wndr.dtsi" / { compatible = "netgear,wndr4300", "qca,ar9344"; model = "Netgear WNDR4300"; - - chosen { - bootargs = "console=ttyS0,115200n8"; - }; - - aliases { - led-boot = &led_power_amber; - led-failsafe = &led_power_amber; - led-running = &led_power_green; - led-upgrade = &led_power_amber; - label-mac-device = ð0; - }; - - keys { - compatible = "gpio-keys"; - - wps { - label = "wps"; - linux,code = ; - gpios = <&gpio 12 GPIO_ACTIVE_LOW>; - }; - - reset { - label = "reset"; - linux,code = ; - gpios = <&gpio 21 GPIO_ACTIVE_LOW>; - }; - - rfkill { - label = "rfkill"; - linux,code = ; - gpios = <&gpio 15 GPIO_ACTIVE_LOW>; - }; - }; - - leds { - compatible = "gpio-leds"; - - pinctrl-names = "default"; - pinctrl-0 = <&enable_gpio_11>; - - led_power_green: power_green { - label = "netgear:green:power"; - gpios = <&gpio 0 GPIO_ACTIVE_LOW>; - }; - - led_power_amber: power_amber { - label = "netgear:amber:power"; - gpios = <&gpio 2 GPIO_ACTIVE_LOW>; - default-state = "keep"; - }; - - wan_green { - label = "netgear:green:wan"; - gpios = <&gpio 1 GPIO_ACTIVE_LOW>; - }; - - wan_amber { - label = "netgear:amber:wan"; - gpios = <&gpio 3 GPIO_ACTIVE_LOW>; - }; - - wlan2g_green { - label = "netgear:green:wlan2g"; - gpios = <&gpio 11 GPIO_ACTIVE_LOW>; - linux,default-trigger = "phy0tpt"; - }; - - wlan5g_blue { - label = "netgear:blue:wlan5g"; - gpios = <&gpio 14 GPIO_ACTIVE_LOW>; - linux,default-trigger = "phy1tpt"; - }; - - wps_green { - label = "netgear:green:wps"; - gpios = <&gpio 16 GPIO_ACTIVE_LOW>; - }; - - wps_amber { - label = "netgear:amber:wps"; - gpios = <&gpio 17 GPIO_ACTIVE_LOW>; - }; - - usb_green { - label = "netgear:green:usb"; - gpios = <&gpio 13 GPIO_ACTIVE_LOW>; - trigger-sources = <&hub_port>; - linux,default-trigger = "usbport"; - }; - }; -}; - -&pinmux { - enable_gpio_11: pinmux_enable_gpio_11 { - pinctrl-single,bits = <0x8 0x0 0xff000000>; - }; -}; - -&nand { - status = "okay"; - - partitions { - compatible = "fixed-partitions"; - #address-cells = <1>; - #size-cells = <1>; - - partition@0 { - label = "u-boot"; - reg = <0x0 0x40000>; - read-only; - }; - - partition@40000 { - label = "u-boot-env"; - reg = <0x40000 0x40000>; - }; - - art: partition@80000 { - label = "caldata"; - reg = <0x80000 0x40000>; - read-only; - }; - - partition@c0000 { - label = "pot"; - reg = <0xc0000 0x80000>; - }; - - partition@140000 { - label = "language"; - reg = <0x140000 0x200000>; - }; - - partition@340000 { - label = "config"; - reg = <0x340000 0x80000>; - }; - - partition@3c0000 { - label = "traffic_meter"; - reg = <0x3c0000 0x300000>; - }; - - kernel@6c0000 { - label = "kernel"; - reg = <0x6c0000 0x200000>; - }; - - ubi@8c0000 { - label = "ubi"; - reg = <0x8c0000 0x1700000>; - }; - - partition@6c0000 { - label = "firmware"; - reg = <0x6c0000 0x1900000>; - compatible = "netgear,uimage"; - }; - - partition@1fc0000 { - label = "caldata_backup"; - reg = <0x1fc0000 0x40000>; - read-only; - }; - - partition@2000000 { - label = "reserved"; - reg = <0x2000000 0x6000000>; - read-only; - }; - }; -}; - -&ref { - clock-frequency = <40000000>; -}; - -&builtin_switch { - resets = <&rst 8>, <&rst 12>; - reset-names = "switch", "switch-analog"; -}; - -&mdio0 { - status = "okay"; - - phy-mask = <0>; - - phy0: ethernet-phy@0 { - reg = <0>; - phy-mode = "rgmii"; - qca,mib-poll-interval = <500>; - - qca,ar8327-initvals = < - 0x04 0x07600000 - 0x0c 0x01000000 - 0x10 0xc1000000 - 0x50 0xcc35cc35 - 0x54 0xcb37cb37 - 0x58 0x00000000 - 0x5c 0x00f3cf00 - 0x7c 0x0000007e - 0x94 0x0000007e - >; - }; -}; - -ð0 { - status = "okay"; - - /* default for ar934x, except for 1000M */ - pll-data = <0x06000000 0x00000101 0x00001616>; - - mtd-mac-address = <&art 0x0>; - - phy-mode = "rgmii"; - phy-handle = <&phy0>; -}; - -&gpio { - status = "okay"; - - lna0 { - gpio-hog; - line-name = "netgear:ext:lna0"; - gpios = <18 GPIO_ACTIVE_HIGH>; - output-high; - }; - - lna1 { - gpio-hog; - line-name = "netgear:ext:lna1"; - gpios = <19 GPIO_ACTIVE_HIGH>; - output-high; - }; -}; - -&wmac { - status = "okay"; - - mtd-mac-address = <&art 0x0>; - qca,no-eeprom; -}; - -&pcie { - status = "okay"; - - ath9k: wifi@0,0 { - compatible = "pci168c,0033"; - reg = <0x0000 0 0 0 0>; - mtd-mac-address = <&art 0xc>; - qca,no-eeprom; - #gpio-cells = <2>; - gpio-controller; - - usb_power { - gpio-hog; - line-name = "netgear:power:usb"; - gpios = <0 GPIO_ACTIVE_HIGH>; - output-high; - }; - }; -}; - -&usb_phy { - status = "okay"; -}; - -&usb { - status = "okay"; - #address-cells = <1>; - #size-cells = <0>; - - hub_port: port@1 { - reg = <1>; - #trigger-source-cells = <0>; - }; -}; - -&uart { - status = "okay"; }; From 7e623c312832386d5eb5aa970738288cf96d96c3 Mon Sep 17 00:00:00 2001 From: Paul Blazejowski Date: Wed, 13 Nov 2019 14:19:32 -0500 Subject: [PATCH 19/22] ath79: add support for Netgear WNDR3700v4 This patch adds ath79 support for Netgear WNDR3700v4. Router was previously supported by ar71xx target only. Note: device requires 'ar934x-nand' driver in kernel. Specification ============= * Description: Netgear WNDR3700v4 * Loader: U-boot * SOC: Atheros AR9344 (560 MHz) * RAM: 128 MiB * Flash: 128 MiB (NAND) - U-boot binary: 256 KiB - U-boot environment: 256 KiB - ART: 256 KiB - POT: 512 KiB - Language: 2 MiB - Config: 512 KiB - Traffic Meter: 3 MiB - Firmware: 25 MiB - ART Backup: 256 KiB - Reserved: 96 MiB * Ethernet: 5 x 10/100/1000 (4 x LAN, 1 x WAN) (AR8327) * Wireless: - 2.4 GHz b/g/n (internal) - 5 GHz a/n (AR9580) * USB: yes, 1 x USB 2.0 * Buttons: - Reset - WiFi (rfkill) - WPS * LEDs: - Power (amber/green) - WAN (amber/green) - WLAN 2G (green) - WLAN 5G (blue) - 4 x LAN (amber/green) - USB (green) - WPS (amber/green) * UART: 4-pin connector JP1, 3.3V (Vcc, TX, RX, GND), 115200 8N1 * Power supply: DC 12V 2.5A * MAC addresses: LAN=WLAN2G on case label, WAN +1, WLAN5G +2 Installation ============ * TFTP recovery * TFTP via U-boot prompt * sysupgrade * Web interface Note about partitioning: firmware partition offset (0x6c0000) is hardcoded into vendor's u-boot, so this partition cannot be moved and resized to include Netgear-specific flash areas (pot, language, config, traffic_meter) not used by OpenWrt. Test build configuration ======================== CONFIG_TARGET_ath79=y CONFIG_TARGET_ath79_nand=y CONFIG_TARGET_ath79_nand_DEVICE_netgear_wndr3700-v4=y CONFIG_ALL_KMODS=y CONFIG_DEVEL=y CONFIG_CCACHE=y CONFIG_COLLECT_KERNEL_DEBUG=y CONFIG_IMAGEOPT=y Signed-off-by: Paul Blazejowski --- package/boot/uboot-envtools/files/ath79 | 1 + .../linux/ath79/dts/ar9344_netgear_wndr3700-v4.dts | 9 +++++++++ target/linux/ath79/image/nand.mk | 12 ++++++++++++ .../linux/ath79/nand/base-files/etc/board.d/01_leds | 1 + .../ath79/nand/base-files/etc/board.d/02_network | 2 ++ .../etc/hotplug.d/firmware/10-ath9k-eeprom | 2 ++ 6 files changed, 27 insertions(+) create mode 100644 target/linux/ath79/dts/ar9344_netgear_wndr3700-v4.dts diff --git a/package/boot/uboot-envtools/files/ath79 b/package/boot/uboot-envtools/files/ath79 index e31100877e..bab5fa556f 100644 --- a/package/boot/uboot-envtools/files/ath79 +++ b/package/boot/uboot-envtools/files/ath79 @@ -42,6 +42,7 @@ buffalo,wzr-hp-ag300h) netgear,wndr3700) ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x20000" "0x10000" ;; +netgear,wndr3700-v4|\ netgear,wndr4300) ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x40000" "0x20000" ;; diff --git a/target/linux/ath79/dts/ar9344_netgear_wndr3700-v4.dts b/target/linux/ath79/dts/ar9344_netgear_wndr3700-v4.dts new file mode 100644 index 0000000000..8a38aeab59 --- /dev/null +++ b/target/linux/ath79/dts/ar9344_netgear_wndr3700-v4.dts @@ -0,0 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/dts-v1/; + +#include "ar9344_netgear_wndr.dtsi" + +/ { + compatible = "netgear,wndr3700-v4", "qca,ar9344"; + model = "Netgear WNDR3700 v4"; +}; diff --git a/target/linux/ath79/image/nand.mk b/target/linux/ath79/image/nand.mk index 614a693285..19c2d42142 100644 --- a/target/linux/ath79/image/nand.mk +++ b/target/linux/ath79/image/nand.mk @@ -125,6 +125,18 @@ define Device/netgear_ath79_nand UBINIZE_OPTS := -E 5 endef +define Device/netgear_wndr3700-v4 + ATH_SOC := ar9344 + DEVICE_MODEL := WNDR3700 + DEVICE_VARIANT := v4 + NETGEAR_KERNEL_MAGIC := 0x33373033 + NETGEAR_BOARD_ID := WNDR3700v4 + NETGEAR_HW_ID := 29763948+128+128 + SUPPORTED_DEVICES += wndr3700v4 + $(Device/netgear_ath79_nand) +endef +TARGET_DEVICES += netgear_wndr3700-v4 + define Device/netgear_wndr4300 ATH_SOC := ar9344 DEVICE_MODEL := WNDR4300 diff --git a/target/linux/ath79/nand/base-files/etc/board.d/01_leds b/target/linux/ath79/nand/base-files/etc/board.d/01_leds index f58527d87e..49d4005495 100755 --- a/target/linux/ath79/nand/base-files/etc/board.d/01_leds +++ b/target/linux/ath79/nand/base-files/etc/board.d/01_leds @@ -12,6 +12,7 @@ glinet,gl-ar300m-nand|\ glinet,gl-ar300m-nor) ucidef_set_led_netdev "lan" "LAN" "gl-ar300m:green:lan" "eth0" ;; +netgear,wndr3700-v4|\ netgear,wndr4300) ucidef_set_led_switch "wan-amber" "WAN (amber)" "netgear:amber:wan" "switch0" "0x20" ;; diff --git a/target/linux/ath79/nand/base-files/etc/board.d/02_network b/target/linux/ath79/nand/base-files/etc/board.d/02_network index 36ddb5e83a..f7e43addc1 100755 --- a/target/linux/ath79/nand/base-files/etc/board.d/02_network +++ b/target/linux/ath79/nand/base-files/etc/board.d/02_network @@ -16,6 +16,7 @@ ath79_setup_interfaces() ucidef_add_switch "switch0" \ "0@eth0" "2:lan:2" "3:lan:1" "1:wan" ;; + netgear,wndr3700-v4|\ netgear,wndr4300) ucidef_add_switch "switch0" \ "0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan" @@ -35,6 +36,7 @@ ath79_setup_macs() local board="$1" case "$board" in + netgear,wndr3700-v4|\ netgear,wndr4300) wan_mac=$(mtd_get_mac_binary caldata 0x6) ;; diff --git a/target/linux/ath79/nand/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom b/target/linux/ath79/nand/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom index ae1d3572a8..25bafe67ac 100644 --- a/target/linux/ath79/nand/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom +++ b/target/linux/ath79/nand/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom @@ -9,6 +9,7 @@ board=$(board_name) case "$FIRMWARE" in "ath9k-eeprom-ahb-18100000.wmac.bin") case $board in + netgear,wndr3700-v4|\ netgear,wndr4300) caldata_extract "caldata" 0x1000 0x440 ;; @@ -23,6 +24,7 @@ case "$FIRMWARE" in ;; "ath9k-eeprom-pci-0000:00:00.0.bin") case $board in + netgear,wndr3700-v4|\ netgear,wndr4300) caldata_extract "caldata" 0x5000 0x440 ;; From fc44a8481cbf317febaf27a550e0c9fa49be68d5 Mon Sep 17 00:00:00 2001 From: Adrian Schmutzler Date: Thu, 14 Nov 2019 17:26:44 +0100 Subject: [PATCH 20/22] ath79: fix sysupgrade from ar71xx for WNDR3700 V2 and WNDR3800(CH) ar71xx has just one board name "wndr3700" for WNDR3700 V1/V2, WNDR3800 and WNDR3800CH, whereas ath79 provides separate images for the boards. So, update SUPPORTED_DEVICES to store the correct ar71xx board names. Fixes: FS#2510 Signed-off-by: Adrian Schmutzler --- target/linux/ath79/image/generic.mk | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/target/linux/ath79/image/generic.mk b/target/linux/ath79/image/generic.mk index f2c228926e..2396219b00 100644 --- a/target/linux/ath79/image/generic.mk +++ b/target/linux/ath79/image/generic.mk @@ -758,7 +758,7 @@ define Device/netgear_wndr3700v2 NETGEAR_BOARD_ID := WNDR3700v2 NETGEAR_HW_ID := 29763654+16+64 IMAGE_SIZE := 15872k - SUPPORTED_DEVICES += wndr3700v2 + SUPPORTED_DEVICES += wndr3700 endef TARGET_DEVICES += netgear_wndr3700v2 @@ -769,7 +769,7 @@ define Device/netgear_wndr3800 NETGEAR_BOARD_ID := WNDR3800 NETGEAR_HW_ID := 29763654+16+128 IMAGE_SIZE := 15872k - SUPPORTED_DEVICES += wndr3800 + SUPPORTED_DEVICES += wndr3700 endef TARGET_DEVICES += netgear_wndr3800 @@ -780,7 +780,7 @@ define Device/netgear_wndr3800ch NETGEAR_BOARD_ID := WNDR3800CH NETGEAR_HW_ID := 29763654+16+128 IMAGE_SIZE := 15872k - SUPPORTED_DEVICES += wndr3800ch + SUPPORTED_DEVICES += wndr3700 endef TARGET_DEVICES += netgear_wndr3800ch From 50735df7b238ce886c6f718b3e9437a09c8efb28 Mon Sep 17 00:00:00 2001 From: John Crispin Date: Fri, 15 Nov 2019 07:51:32 +0100 Subject: [PATCH 21/22] mediatek: fix bootup problem on mt7629 EVB Signed-off-by: John Crispin --- target/linux/mediatek/mt7629/config-4.19 | 7 + target/linux/mediatek/patches-4.1 | 534 ++++++++++++++++++ ...atek-Add-SPI-Nand-support-for-MT7629.patch | 187 ++++++ 3 files changed, 728 insertions(+) create mode 100644 target/linux/mediatek/patches-4.1 create mode 100644 target/linux/mediatek/patches-4.19/0307-spi-mem-Mediatek-Add-SPI-Nand-support-for-MT7629.patch diff --git a/target/linux/mediatek/mt7629/config-4.19 b/target/linux/mediatek/mt7629/config-4.19 index e43f758cdf..f32d9d1919 100644 --- a/target/linux/mediatek/mt7629/config-4.19 +++ b/target/linux/mediatek/mt7629/config-4.19 @@ -232,8 +232,10 @@ CONFIG_MODULES_USE_ELF_REL=y CONFIG_MT753X_GSW=y CONFIG_MTD_MT81xx_NOR=y CONFIG_MTD_NAND=y +CONFIG_MTD_NAND_CORE=y CONFIG_MTD_NAND_ECC=y CONFIG_MTD_NAND_MTK=y ++CONFIG_MTD_SPI_NAND=y CONFIG_MTD_SPI_NOR=y CONFIG_MTD_SPLIT_FIRMWARE=y CONFIG_MTD_SPLIT_FIT_FW=y @@ -330,6 +332,11 @@ CONFIG_SGL_ALLOC=y CONFIG_SG_POOL=y CONFIG_SMP=y CONFIG_SMP_ON_UP=y +CONFIG_SPI=y +CONFIG_SPI_MASTER=y +CONFIG_SPI_MEM=y +# CONFIG_SPI_MT65XX is not set +CONFIG_SPI_MTK_SNFI=y CONFIG_SPARSE_IRQ=y CONFIG_SRCU=y CONFIG_STACKTRACE=y diff --git a/target/linux/mediatek/patches-4.1 b/target/linux/mediatek/patches-4.1 new file mode 100644 index 0000000000..bf7c1ea32b --- /dev/null +++ b/target/linux/mediatek/patches-4.1 @@ -0,0 +1,534 @@ +diff -urN a/drivers/clk/clk-devres.c b/drivers/clk/clk-devres.c +--- a/drivers/clk/clk-devres.c 2019-08-29 16:59:26.540010395 +0800 ++++ b/drivers/clk/clk-devres.c 2019-08-29 17:02:09.215924786 +0800 +@@ -34,6 +34,17 @@ + } + EXPORT_SYMBOL(devm_clk_get); + ++struct clk *devm_clk_get_optional(struct device *dev, const char *id) ++{ ++ struct clk *clk = devm_clk_get(dev, id); ++ ++ if (clk == ERR_PTR(-ENOENT)) ++ return NULL; ++ ++ return clk; ++} ++EXPORT_SYMBOL(devm_clk_get_optional); ++ + struct clk_bulk_devres { + struct clk_bulk_data *clks; + int num_clks; +diff -urN a/drivers/pci/controller/pcie-mediatek.c b/drivers/pci/controller/pcie-mediatek.c +--- a/drivers/pci/controller/pcie-mediatek.c 2019-08-29 16:59:10.520410188 +0800 ++++ b/drivers/pci/controller/pcie-mediatek.c 2019-08-29 17:01:58.340199243 +0800 +@@ -15,6 +15,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -162,6 +163,7 @@ + * @phy: pointer to PHY control block + * @lane: lane count + * @slot: port slot ++ * @irq: GIC irq + * @irq_domain: legacy INTx IRQ domain + * @inner_domain: inner IRQ domain + * @msi_domain: MSI IRQ domain +@@ -182,6 +184,7 @@ + struct phy *phy; + u32 lane; + u32 slot; ++ int irq; + struct irq_domain *irq_domain; + struct irq_domain *inner_domain; + struct irq_domain *msi_domain; +@@ -225,10 +228,8 @@ + + clk_disable_unprepare(pcie->free_ck); + +- if (dev->pm_domain) { +- pm_runtime_put_sync(dev); +- pm_runtime_disable(dev); +- } ++ pm_runtime_put_sync(dev); ++ pm_runtime_disable(dev); + } + + static void mtk_pcie_port_free(struct mtk_pcie_port *port) +@@ -394,75 +395,6 @@ + .write = mtk_pcie_config_write, + }; + +-static int mtk_pcie_startup_port_v2(struct mtk_pcie_port *port) +-{ +- struct mtk_pcie *pcie = port->pcie; +- struct resource *mem = &pcie->mem; +- const struct mtk_pcie_soc *soc = port->pcie->soc; +- u32 val; +- size_t size; +- int err; +- +- /* MT7622 platforms need to enable LTSSM and ASPM from PCIe subsys */ +- if (pcie->base) { +- val = readl(pcie->base + PCIE_SYS_CFG_V2); +- val |= PCIE_CSR_LTSSM_EN(port->slot) | +- PCIE_CSR_ASPM_L1_EN(port->slot); +- writel(val, pcie->base + PCIE_SYS_CFG_V2); +- } +- +- /* Assert all reset signals */ +- writel(0, port->base + PCIE_RST_CTRL); +- +- /* +- * Enable PCIe link down reset, if link status changed from link up to +- * link down, this will reset MAC control registers and configuration +- * space. +- */ +- writel(PCIE_LINKDOWN_RST_EN, port->base + PCIE_RST_CTRL); +- +- /* De-assert PHY, PE, PIPE, MAC and configuration reset */ +- val = readl(port->base + PCIE_RST_CTRL); +- val |= PCIE_PHY_RSTB | PCIE_PERSTB | PCIE_PIPE_SRSTB | +- PCIE_MAC_SRSTB | PCIE_CRSTB; +- writel(val, port->base + PCIE_RST_CTRL); +- +- /* Set up vendor ID and class code */ +- if (soc->need_fix_class_id) { +- val = PCI_VENDOR_ID_MEDIATEK; +- writew(val, port->base + PCIE_CONF_VEND_ID); +- +- val = PCI_CLASS_BRIDGE_HOST; +- writew(val, port->base + PCIE_CONF_CLASS_ID); +- } +- +- /* 100ms timeout value should be enough for Gen1/2 training */ +- err = readl_poll_timeout(port->base + PCIE_LINK_STATUS_V2, val, +- !!(val & PCIE_PORT_LINKUP_V2), 20, +- 100 * USEC_PER_MSEC); +- if (err) +- return -ETIMEDOUT; +- +- /* Set INTx mask */ +- val = readl(port->base + PCIE_INT_MASK); +- val &= ~INTX_MASK; +- writel(val, port->base + PCIE_INT_MASK); +- +- /* Set AHB to PCIe translation windows */ +- size = mem->end - mem->start; +- val = lower_32_bits(mem->start) | AHB2PCIE_SIZE(fls(size)); +- writel(val, port->base + PCIE_AHB_TRANS_BASE0_L); +- +- val = upper_32_bits(mem->start); +- writel(val, port->base + PCIE_AHB_TRANS_BASE0_H); +- +- /* Set PCIe to AXI translation memory space.*/ +- val = fls(0xffffffff) | WIN_ENABLE; +- writel(val, port->base + PCIE_AXI_WINDOW0); +- +- return 0; +-} +- + static void mtk_compose_msi_msg(struct irq_data *data, struct msi_msg *msg) + { + struct mtk_pcie_port *port = irq_data_get_irq_chip_data(data); +@@ -601,6 +533,27 @@ + writel(val, port->base + PCIE_INT_MASK); + } + ++static void mtk_pcie_irq_teardown(struct mtk_pcie *pcie) ++{ ++ struct mtk_pcie_port *port, *tmp; ++ ++ list_for_each_entry_safe(port, tmp, &pcie->ports, list) { ++ irq_set_chained_handler_and_data(port->irq, NULL, NULL); ++ ++ if (port->irq_domain) ++ irq_domain_remove(port->irq_domain); ++ ++ if (IS_ENABLED(CONFIG_PCI_MSI)) { ++ if (port->msi_domain) ++ irq_domain_remove(port->msi_domain); ++ if (port->inner_domain) ++ irq_domain_remove(port->inner_domain); ++ } ++ ++ irq_dispose_mapping(port->irq); ++ } ++} ++ + static int mtk_pcie_intx_map(struct irq_domain *domain, unsigned int irq, + irq_hw_number_t hwirq) + { +@@ -630,6 +583,7 @@ + + port->irq_domain = irq_domain_add_linear(pcie_intc_node, PCI_NUM_INTX, + &intx_domain_ops, port); ++ of_node_put(pcie_intc_node); + if (!port->irq_domain) { + dev_err(dev, "failed to get INTx IRQ domain\n"); + return -ENODEV; +@@ -639,8 +593,6 @@ + ret = mtk_pcie_allocate_msi_domains(port); + if (ret) + return ret; +- +- mtk_pcie_enable_msi(port); + } + + return 0; +@@ -693,7 +645,7 @@ + struct mtk_pcie *pcie = port->pcie; + struct device *dev = pcie->dev; + struct platform_device *pdev = to_platform_device(dev); +- int err, irq; ++ int err; + + err = mtk_pcie_init_irq_domain(port, node); + if (err) { +@@ -701,8 +653,81 @@ + return err; + } + +- irq = platform_get_irq(pdev, port->slot); +- irq_set_chained_handler_and_data(irq, mtk_pcie_intr_handler, port); ++ port->irq = platform_get_irq(pdev, port->slot); ++ irq_set_chained_handler_and_data(port->irq, ++ mtk_pcie_intr_handler, port); ++ ++ return 0; ++} ++ ++static int mtk_pcie_startup_port_v2(struct mtk_pcie_port *port) ++{ ++ struct mtk_pcie *pcie = port->pcie; ++ struct resource *mem = &pcie->mem; ++ const struct mtk_pcie_soc *soc = port->pcie->soc; ++ u32 val; ++ size_t size; ++ int err; ++ ++ /* MT7622 platforms need to enable LTSSM and ASPM from PCIe subsys */ ++ if (pcie->base) { ++ val = readl(pcie->base + PCIE_SYS_CFG_V2); ++ val |= PCIE_CSR_LTSSM_EN(port->slot) | ++ PCIE_CSR_ASPM_L1_EN(port->slot); ++ writel(val, pcie->base + PCIE_SYS_CFG_V2); ++ } ++ ++ /* Assert all reset signals */ ++ writel(0, port->base + PCIE_RST_CTRL); ++ ++ /* ++ * Enable PCIe link down reset, if link status changed from link up to ++ * link down, this will reset MAC control registers and configuration ++ * space. ++ */ ++ writel(PCIE_LINKDOWN_RST_EN, port->base + PCIE_RST_CTRL); ++ ++ /* De-assert PHY, PE, PIPE, MAC and configuration reset */ ++ val = readl(port->base + PCIE_RST_CTRL); ++ val |= PCIE_PHY_RSTB | PCIE_PERSTB | PCIE_PIPE_SRSTB | ++ PCIE_MAC_SRSTB | PCIE_CRSTB; ++ writel(val, port->base + PCIE_RST_CTRL); ++ ++ /* Set up vendor ID and class code */ ++ if (soc->need_fix_class_id) { ++ val = PCI_VENDOR_ID_MEDIATEK; ++ writew(val, port->base + PCIE_CONF_VEND_ID); ++ ++ val = PCI_CLASS_BRIDGE_PCI; ++ writew(val, port->base + PCIE_CONF_CLASS_ID); ++ } ++ ++ /* 100ms timeout value should be enough for Gen1/2 training */ ++ err = readl_poll_timeout(port->base + PCIE_LINK_STATUS_V2, val, ++ !!(val & PCIE_PORT_LINKUP_V2), 20, ++ 100 * USEC_PER_MSEC); ++ if (err) ++ return -ETIMEDOUT; ++ ++ /* Set INTx mask */ ++ val = readl(port->base + PCIE_INT_MASK); ++ val &= ~INTX_MASK; ++ writel(val, port->base + PCIE_INT_MASK); ++ ++ if (IS_ENABLED(CONFIG_PCI_MSI)) ++ mtk_pcie_enable_msi(port); ++ ++ /* Set AHB to PCIe translation windows */ ++ size = mem->end - mem->start; ++ val = lower_32_bits(mem->start) | AHB2PCIE_SIZE(fls(size)); ++ writel(val, port->base + PCIE_AHB_TRANS_BASE0_L); ++ ++ val = upper_32_bits(mem->start); ++ writel(val, port->base + PCIE_AHB_TRANS_BASE0_H); ++ ++ /* Set PCIe to AXI translation memory space.*/ ++ val = fls(0xffffffff) | WIN_ENABLE; ++ writel(val, port->base + PCIE_AXI_WINDOW0); + + return 0; + } +@@ -903,49 +928,29 @@ + + /* sys_ck might be divided into the following parts in some chips */ + snprintf(name, sizeof(name), "ahb_ck%d", slot); +- port->ahb_ck = devm_clk_get(dev, name); +- if (IS_ERR(port->ahb_ck)) { +- if (PTR_ERR(port->ahb_ck) == -EPROBE_DEFER) +- return -EPROBE_DEFER; +- +- port->ahb_ck = NULL; +- } ++ port->ahb_ck = devm_clk_get_optional(dev, name); ++ if (IS_ERR(port->ahb_ck)) ++ return PTR_ERR(port->ahb_ck); + + snprintf(name, sizeof(name), "axi_ck%d", slot); +- port->axi_ck = devm_clk_get(dev, name); +- if (IS_ERR(port->axi_ck)) { +- if (PTR_ERR(port->axi_ck) == -EPROBE_DEFER) +- return -EPROBE_DEFER; +- +- port->axi_ck = NULL; +- } ++ port->axi_ck = devm_clk_get_optional(dev, name); ++ if (IS_ERR(port->axi_ck)) ++ return PTR_ERR(port->axi_ck); + + snprintf(name, sizeof(name), "aux_ck%d", slot); +- port->aux_ck = devm_clk_get(dev, name); +- if (IS_ERR(port->aux_ck)) { +- if (PTR_ERR(port->aux_ck) == -EPROBE_DEFER) +- return -EPROBE_DEFER; +- +- port->aux_ck = NULL; +- } ++ port->aux_ck = devm_clk_get_optional(dev, name); ++ if (IS_ERR(port->aux_ck)) ++ return PTR_ERR(port->aux_ck); + + snprintf(name, sizeof(name), "obff_ck%d", slot); +- port->obff_ck = devm_clk_get(dev, name); +- if (IS_ERR(port->obff_ck)) { +- if (PTR_ERR(port->obff_ck) == -EPROBE_DEFER) +- return -EPROBE_DEFER; +- +- port->obff_ck = NULL; +- } ++ port->obff_ck = devm_clk_get_optional(dev, name); ++ if (IS_ERR(port->obff_ck)) ++ return PTR_ERR(port->obff_ck); + + snprintf(name, sizeof(name), "pipe_ck%d", slot); +- port->pipe_ck = devm_clk_get(dev, name); +- if (IS_ERR(port->pipe_ck)) { +- if (PTR_ERR(port->pipe_ck) == -EPROBE_DEFER) +- return -EPROBE_DEFER; +- +- port->pipe_ck = NULL; +- } ++ port->pipe_ck = devm_clk_get_optional(dev, name); ++ if (IS_ERR(port->pipe_ck)) ++ return PTR_ERR(port->pipe_ck); + + snprintf(name, sizeof(name), "pcie-rst%d", slot); + port->reset = devm_reset_control_get_optional_exclusive(dev, name); +@@ -998,10 +1003,8 @@ + pcie->free_ck = NULL; + } + +- if (dev->pm_domain) { +- pm_runtime_enable(dev); +- pm_runtime_get_sync(dev); +- } ++ pm_runtime_enable(dev); ++ pm_runtime_get_sync(dev); + + /* enable top level clock */ + err = clk_prepare_enable(pcie->free_ck); +@@ -1013,10 +1016,8 @@ + return 0; + + err_free_ck: +- if (dev->pm_domain) { +- pm_runtime_put_sync(dev); +- pm_runtime_disable(dev); +- } ++ pm_runtime_put_sync(dev); ++ pm_runtime_disable(dev); + + return err; + } +@@ -1125,34 +1126,6 @@ + return 0; + } + +-static int mtk_pcie_register_host(struct pci_host_bridge *host) +-{ +- struct mtk_pcie *pcie = pci_host_bridge_priv(host); +- struct pci_bus *child; +- int err; +- +- host->busnr = pcie->busn.start; +- host->dev.parent = pcie->dev; +- host->ops = pcie->soc->ops; +- host->map_irq = of_irq_parse_and_map_pci; +- host->swizzle_irq = pci_common_swizzle; +- host->sysdata = pcie; +- +- err = pci_scan_root_bus_bridge(host); +- if (err < 0) +- return err; +- +- pci_bus_size_bridges(host->bus); +- pci_bus_assign_resources(host->bus); +- +- list_for_each_entry(child, &host->bus->children, node) +- pcie_bus_configure_settings(child); +- +- pci_bus_add_devices(host->bus); +- +- return 0; +-} +- + static int mtk_pcie_probe(struct platform_device *pdev) + { + struct device *dev = &pdev->dev; +@@ -1179,7 +1152,14 @@ + if (err) + goto put_resources; + +- err = mtk_pcie_register_host(host); ++ host->busnr = pcie->busn.start; ++ host->dev.parent = pcie->dev; ++ host->ops = pcie->soc->ops; ++ host->map_irq = of_irq_parse_and_map_pci; ++ host->swizzle_irq = pci_common_swizzle; ++ host->sysdata = pcie; ++ ++ err = pci_host_probe(host); + if (err) + goto put_resources; + +@@ -1192,6 +1172,80 @@ + return err; + } + ++ ++static void mtk_pcie_free_resources(struct mtk_pcie *pcie) ++{ ++ struct pci_host_bridge *host = pci_host_bridge_from_priv(pcie); ++ struct list_head *windows = &host->windows; ++ ++ pci_free_resource_list(windows); ++} ++ ++static int mtk_pcie_remove(struct platform_device *pdev) ++{ ++ struct mtk_pcie *pcie = platform_get_drvdata(pdev); ++ struct pci_host_bridge *host = pci_host_bridge_from_priv(pcie); ++ ++ pci_stop_root_bus(host->bus); ++ pci_remove_root_bus(host->bus); ++ mtk_pcie_free_resources(pcie); ++ ++ mtk_pcie_irq_teardown(pcie); ++ ++ mtk_pcie_put_resources(pcie); ++ ++ return 0; ++} ++ ++static int __maybe_unused mtk_pcie_suspend_noirq(struct device *dev) ++{ ++ struct mtk_pcie *pcie = dev_get_drvdata(dev); ++ struct mtk_pcie_port *port; ++ ++ if (list_empty(&pcie->ports)) ++ return 0; ++ ++ list_for_each_entry(port, &pcie->ports, list) { ++ clk_disable_unprepare(port->pipe_ck); ++ clk_disable_unprepare(port->obff_ck); ++ clk_disable_unprepare(port->axi_ck); ++ clk_disable_unprepare(port->aux_ck); ++ clk_disable_unprepare(port->ahb_ck); ++ clk_disable_unprepare(port->sys_ck); ++ phy_power_off(port->phy); ++ phy_exit(port->phy); ++ } ++ ++ clk_disable_unprepare(pcie->free_ck); ++ ++ return 0; ++} ++ ++static int __maybe_unused mtk_pcie_resume_noirq(struct device *dev) ++{ ++ struct mtk_pcie *pcie = dev_get_drvdata(dev); ++ struct mtk_pcie_port *port, *tmp; ++ ++ if (list_empty(&pcie->ports)) ++ return 0; ++ ++ clk_prepare_enable(pcie->free_ck); ++ ++ list_for_each_entry_safe(port, tmp, &pcie->ports, list) ++ mtk_pcie_enable_port(port); ++ ++ /* In case of EP was removed while system suspend. */ ++ if (list_empty(&pcie->ports)) ++ clk_disable_unprepare(pcie->free_ck); ++ ++ return 0; ++} ++ ++static const struct dev_pm_ops mtk_pcie_pm_ops = { ++ SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(mtk_pcie_suspend_noirq, ++ mtk_pcie_resume_noirq) ++}; ++ + static const struct mtk_pcie_soc mtk_pcie_soc_v1 = { + .ops = &mtk_pcie_ops, + .startup = mtk_pcie_startup_port, +@@ -1220,10 +1274,13 @@ + + static struct platform_driver mtk_pcie_driver = { + .probe = mtk_pcie_probe, ++ .remove = mtk_pcie_remove, + .driver = { + .name = "mtk-pcie", + .of_match_table = mtk_pcie_ids, + .suppress_bind_attrs = true, ++ .pm = &mtk_pcie_pm_ops, + }, + }; +-builtin_platform_driver(mtk_pcie_driver); ++module_platform_driver(mtk_pcie_driver); ++MODULE_LICENSE("GPL v2"); +diff -urN a/include/linux/clk.h b/include/linux/clk.h +--- a/include/linux/clk.h 2019-08-29 16:59:52.335365591 +0800 ++++ b/include/linux/clk.h 2019-08-29 17:02:17.107725525 +0800 +@@ -349,6 +349,17 @@ + struct clk *devm_clk_get(struct device *dev, const char *id); + + /** ++ * devm_clk_get_optional - lookup and obtain a managed reference to an optional ++ * clock producer. ++ * @dev: device for clock "consumer" ++ * @id: clock consumer ID ++ * ++ * Behaves the same as devm_clk_get() except where there is no clock producer. ++ * In this case, instead of returning -ENOENT, the function returns NULL. ++ */ ++struct clk *devm_clk_get_optional(struct device *dev, const char *id); ++ ++/** + * devm_get_clk_from_child - lookup and obtain a managed reference to a + * clock producer from child node. + * @dev: device for clock "consumer" diff --git a/target/linux/mediatek/patches-4.19/0307-spi-mem-Mediatek-Add-SPI-Nand-support-for-MT7629.patch b/target/linux/mediatek/patches-4.19/0307-spi-mem-Mediatek-Add-SPI-Nand-support-for-MT7629.patch new file mode 100644 index 0000000000..72e56945d9 --- /dev/null +++ b/target/linux/mediatek/patches-4.19/0307-spi-mem-Mediatek-Add-SPI-Nand-support-for-MT7629.patch @@ -0,0 +1,187 @@ +From c813fbe806257c574240770ef716fbee19f7dbfa Mon Sep 17 00:00:00 2001 +From: Xiangsheng Hou +Date: Thu, 6 Jun 2019 16:29:04 +0800 +Subject: [PATCH] spi: spi-mem: Mediatek: Add SPI Nand support for MT7629 + +Signed-off-by: Xiangsheng Hou +--- + arch/arm/boot/dts/mt7629-rfb.dts | 45 ++++++++++++++++++++++++++++++++ + arch/arm/boot/dts/mt7629-lynx-rfb.dts | 45 ++++++++++++++++++++++++++++++++ + arch/arm/boot/dts/mt7629.dtsi | 22 ++++++++++++++++ + drivers/spi/spi-mtk-snfi.c | 12 +++++++++ + 3 files changed, 79 insertions(+) + +diff --git a/arch/arm/boot/dts/mt7629-rfb.dts b/arch/arm/boot/dts/mt7629-rfb.dts +index 8043238fe..ef140623e 100755 +--- a/arch/arm/boot/dts/mt7629-rfb.dts ++++ b/arch/arm/boot/dts/mt7629-rfb.dts +@@ -258,6 +258,51 @@ + }; + }; + ++&bch { ++ status = "okay"; ++}; ++ ++&snfi { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&serial_nand_pins>; ++ status = "okay"; ++ ++ spi_nand@0 { ++ #address-cells = <1>; ++ #size-cells = <1>; ++ compatible = "spi-nand"; ++ spi-max-frequency = <104000000>; ++ reg = <0>; ++ ++ partitions { ++ compatible = "fixed-partitions"; ++ #address-cells = <1>; ++ #size-cells = <1>; ++ ++ partition@0 { ++ label = "Bootloader"; ++ reg = <0x00000 0x0100000>; ++ read-only; ++ }; ++ ++ partition@100000 { ++ label = "Config"; ++ reg = <0x100000 0x0040000>; ++ }; ++ ++ partition@140000 { ++ label = "factory"; ++ reg = <0x140000 0x0080000>; ++ }; ++ ++ partition@1c0000 { ++ label = "firmware"; ++ reg = <0x1c0000 0x1000000>; ++ }; ++ }; ++ }; ++}; ++ + &spi { + pinctrl-names = "default"; + pinctrl-0 = <&spi_pins>; +diff --git a/arch/arm/boot/dts/mt7629.dtsi b/arch/arm/boot/dts/mt7629.dtsi +index 53f47796b..c7bd5fc9b 100755 +--- a/arch/arm/boot/dts/mt7629.dtsi ++++ b/arch/arm/boot/dts/mt7629.dtsi +@@ -259,6 +259,28 @@ + status = "disabled"; + }; + ++ bch: ecc@1100e000 { ++ compatible = "mediatek,mt7622-ecc"; ++ reg = <0x1100e000 0x1000>; ++ interrupts = ; ++ clocks = <&pericfg CLK_PERI_NFIECC_PD>; ++ clock-names = "nfiecc_clk"; ++ status = "disabled"; ++ }; ++ ++ snfi: spi@1100d000 { ++ compatible = "mediatek,mt7629-snfi"; ++ reg = <0x1100d000 0x1000>; ++ interrupts = ; ++ clocks = <&pericfg CLK_PERI_NFI_PD>, ++ <&pericfg CLK_PERI_SNFI_PD>; ++ clock-names = "nfi_clk", "spi_clk"; ++ ecc-engine = <&bch>; ++ #address-cells = <1>; ++ #size-cells = <0>; ++ status = "disabled"; ++ }; ++ + spi: spi@1100a000 { + compatible = "mediatek,mt7629-spi", + "mediatek,mt7622-spi"; +diff --git a/drivers/spi/spi-mtk-snfi.c b/drivers/spi/spi-mtk-snfi.c +index cd600d9fb..113f541e6 100644 +--- a/drivers/spi/spi-mtk-snfi.c ++++ b/drivers/spi/spi-mtk-snfi.c +@@ -1029,8 +1029,20 @@ static const struct mtk_snfi_caps snfi_mt7622 = { + .bad_mark_swap = 0, + }; + ++static const struct mtk_snfi_caps snfi_mt7629 = { ++ .spare_size = spare_size_mt7622, ++ .num_spare_size = 4, ++ .nand_sec_size = 512, ++ .nand_fdm_size = 8, ++ .nand_fdm_ecc_size = 1, ++ .ecc_parity_bits = 13, ++ .pageformat_spare_shift = 4, ++ .bad_mark_swap = 1, ++}; ++ + static const struct of_device_id mtk_snfi_id_table[] = { + { .compatible = "mediatek,mt7622-snfi", .data = &snfi_mt7622, }, ++ { .compatible = "mediatek,mt7629-snfi", .data = &snfi_mt7629, }, + { /* sentinel */ } + }; + +-- +2.21.0 + +diff --git a/arch/arm/boot/dts/mt7629-lynx-rfb.dts b/arch/arm/boot/dts/mt7629-lynx-rfb.dts +index f3fadd3..895d6c4 100755 +--- a/arch/arm/boot/dts/mt7629-lynx-rfb.dts ++++ b/arch/arm/boot/dts/mt7629-lynx-rfb.dts +@@ -278,6 +278,52 @@ + }; + }; + ++&bch { ++ status = "okay"; ++}; ++ ++&snfi { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&serial_nand_pins>; ++ status = "okay"; ++ ++ spi_nand@0 { ++ #address-cells = <1>; ++ #size-cells = <1>; ++ compatible = "spi-nand"; ++ spi-max-frequency = <104000000>; ++ reg = <0>; ++ ++ partitions { ++ compatible = "fixed-partitions"; ++ #address-cells = <1>; ++ #size-cells = <1>; ++ ++ partition@0 { ++ label = "Bootloader"; ++ reg = <0x00000 0x0100000>; ++ read-only; ++ }; ++ ++ partition@100000 { ++ label = "Config"; ++ reg = <0x100000 0x0040000>; ++ }; ++ ++ partition@140000 { ++ label = "factory"; ++ reg = <0x140000 0x0080000>; ++ }; ++ ++ partition@1c0000 { ++ label = "firmware"; ++ reg = <0x1c0000 0x1000000>; ++ }; ++ ++ }; ++ }; ++}; ++ + &spi { + pinctrl-names = "default"; + pinctrl-0 = <&spi_pins>; From 1ea22e4de6f0ee08fe3463a34d3b207b4979f1bc Mon Sep 17 00:00:00 2001 From: John Crispin Date: Fri, 15 Nov 2019 07:52:57 +0100 Subject: [PATCH 22/22] mediatek: drop accidentially commited file Signed-off-by: John Crispin --- target/linux/mediatek/patches-4.1 | 534 ------------------------------ 1 file changed, 534 deletions(-) delete mode 100644 target/linux/mediatek/patches-4.1 diff --git a/target/linux/mediatek/patches-4.1 b/target/linux/mediatek/patches-4.1 deleted file mode 100644 index bf7c1ea32b..0000000000 --- a/target/linux/mediatek/patches-4.1 +++ /dev/null @@ -1,534 +0,0 @@ -diff -urN a/drivers/clk/clk-devres.c b/drivers/clk/clk-devres.c ---- a/drivers/clk/clk-devres.c 2019-08-29 16:59:26.540010395 +0800 -+++ b/drivers/clk/clk-devres.c 2019-08-29 17:02:09.215924786 +0800 -@@ -34,6 +34,17 @@ - } - EXPORT_SYMBOL(devm_clk_get); - -+struct clk *devm_clk_get_optional(struct device *dev, const char *id) -+{ -+ struct clk *clk = devm_clk_get(dev, id); -+ -+ if (clk == ERR_PTR(-ENOENT)) -+ return NULL; -+ -+ return clk; -+} -+EXPORT_SYMBOL(devm_clk_get_optional); -+ - struct clk_bulk_devres { - struct clk_bulk_data *clks; - int num_clks; -diff -urN a/drivers/pci/controller/pcie-mediatek.c b/drivers/pci/controller/pcie-mediatek.c ---- a/drivers/pci/controller/pcie-mediatek.c 2019-08-29 16:59:10.520410188 +0800 -+++ b/drivers/pci/controller/pcie-mediatek.c 2019-08-29 17:01:58.340199243 +0800 -@@ -15,6 +15,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -162,6 +163,7 @@ - * @phy: pointer to PHY control block - * @lane: lane count - * @slot: port slot -+ * @irq: GIC irq - * @irq_domain: legacy INTx IRQ domain - * @inner_domain: inner IRQ domain - * @msi_domain: MSI IRQ domain -@@ -182,6 +184,7 @@ - struct phy *phy; - u32 lane; - u32 slot; -+ int irq; - struct irq_domain *irq_domain; - struct irq_domain *inner_domain; - struct irq_domain *msi_domain; -@@ -225,10 +228,8 @@ - - clk_disable_unprepare(pcie->free_ck); - -- if (dev->pm_domain) { -- pm_runtime_put_sync(dev); -- pm_runtime_disable(dev); -- } -+ pm_runtime_put_sync(dev); -+ pm_runtime_disable(dev); - } - - static void mtk_pcie_port_free(struct mtk_pcie_port *port) -@@ -394,75 +395,6 @@ - .write = mtk_pcie_config_write, - }; - --static int mtk_pcie_startup_port_v2(struct mtk_pcie_port *port) --{ -- struct mtk_pcie *pcie = port->pcie; -- struct resource *mem = &pcie->mem; -- const struct mtk_pcie_soc *soc = port->pcie->soc; -- u32 val; -- size_t size; -- int err; -- -- /* MT7622 platforms need to enable LTSSM and ASPM from PCIe subsys */ -- if (pcie->base) { -- val = readl(pcie->base + PCIE_SYS_CFG_V2); -- val |= PCIE_CSR_LTSSM_EN(port->slot) | -- PCIE_CSR_ASPM_L1_EN(port->slot); -- writel(val, pcie->base + PCIE_SYS_CFG_V2); -- } -- -- /* Assert all reset signals */ -- writel(0, port->base + PCIE_RST_CTRL); -- -- /* -- * Enable PCIe link down reset, if link status changed from link up to -- * link down, this will reset MAC control registers and configuration -- * space. -- */ -- writel(PCIE_LINKDOWN_RST_EN, port->base + PCIE_RST_CTRL); -- -- /* De-assert PHY, PE, PIPE, MAC and configuration reset */ -- val = readl(port->base + PCIE_RST_CTRL); -- val |= PCIE_PHY_RSTB | PCIE_PERSTB | PCIE_PIPE_SRSTB | -- PCIE_MAC_SRSTB | PCIE_CRSTB; -- writel(val, port->base + PCIE_RST_CTRL); -- -- /* Set up vendor ID and class code */ -- if (soc->need_fix_class_id) { -- val = PCI_VENDOR_ID_MEDIATEK; -- writew(val, port->base + PCIE_CONF_VEND_ID); -- -- val = PCI_CLASS_BRIDGE_HOST; -- writew(val, port->base + PCIE_CONF_CLASS_ID); -- } -- -- /* 100ms timeout value should be enough for Gen1/2 training */ -- err = readl_poll_timeout(port->base + PCIE_LINK_STATUS_V2, val, -- !!(val & PCIE_PORT_LINKUP_V2), 20, -- 100 * USEC_PER_MSEC); -- if (err) -- return -ETIMEDOUT; -- -- /* Set INTx mask */ -- val = readl(port->base + PCIE_INT_MASK); -- val &= ~INTX_MASK; -- writel(val, port->base + PCIE_INT_MASK); -- -- /* Set AHB to PCIe translation windows */ -- size = mem->end - mem->start; -- val = lower_32_bits(mem->start) | AHB2PCIE_SIZE(fls(size)); -- writel(val, port->base + PCIE_AHB_TRANS_BASE0_L); -- -- val = upper_32_bits(mem->start); -- writel(val, port->base + PCIE_AHB_TRANS_BASE0_H); -- -- /* Set PCIe to AXI translation memory space.*/ -- val = fls(0xffffffff) | WIN_ENABLE; -- writel(val, port->base + PCIE_AXI_WINDOW0); -- -- return 0; --} -- - static void mtk_compose_msi_msg(struct irq_data *data, struct msi_msg *msg) - { - struct mtk_pcie_port *port = irq_data_get_irq_chip_data(data); -@@ -601,6 +533,27 @@ - writel(val, port->base + PCIE_INT_MASK); - } - -+static void mtk_pcie_irq_teardown(struct mtk_pcie *pcie) -+{ -+ struct mtk_pcie_port *port, *tmp; -+ -+ list_for_each_entry_safe(port, tmp, &pcie->ports, list) { -+ irq_set_chained_handler_and_data(port->irq, NULL, NULL); -+ -+ if (port->irq_domain) -+ irq_domain_remove(port->irq_domain); -+ -+ if (IS_ENABLED(CONFIG_PCI_MSI)) { -+ if (port->msi_domain) -+ irq_domain_remove(port->msi_domain); -+ if (port->inner_domain) -+ irq_domain_remove(port->inner_domain); -+ } -+ -+ irq_dispose_mapping(port->irq); -+ } -+} -+ - static int mtk_pcie_intx_map(struct irq_domain *domain, unsigned int irq, - irq_hw_number_t hwirq) - { -@@ -630,6 +583,7 @@ - - port->irq_domain = irq_domain_add_linear(pcie_intc_node, PCI_NUM_INTX, - &intx_domain_ops, port); -+ of_node_put(pcie_intc_node); - if (!port->irq_domain) { - dev_err(dev, "failed to get INTx IRQ domain\n"); - return -ENODEV; -@@ -639,8 +593,6 @@ - ret = mtk_pcie_allocate_msi_domains(port); - if (ret) - return ret; -- -- mtk_pcie_enable_msi(port); - } - - return 0; -@@ -693,7 +645,7 @@ - struct mtk_pcie *pcie = port->pcie; - struct device *dev = pcie->dev; - struct platform_device *pdev = to_platform_device(dev); -- int err, irq; -+ int err; - - err = mtk_pcie_init_irq_domain(port, node); - if (err) { -@@ -701,8 +653,81 @@ - return err; - } - -- irq = platform_get_irq(pdev, port->slot); -- irq_set_chained_handler_and_data(irq, mtk_pcie_intr_handler, port); -+ port->irq = platform_get_irq(pdev, port->slot); -+ irq_set_chained_handler_and_data(port->irq, -+ mtk_pcie_intr_handler, port); -+ -+ return 0; -+} -+ -+static int mtk_pcie_startup_port_v2(struct mtk_pcie_port *port) -+{ -+ struct mtk_pcie *pcie = port->pcie; -+ struct resource *mem = &pcie->mem; -+ const struct mtk_pcie_soc *soc = port->pcie->soc; -+ u32 val; -+ size_t size; -+ int err; -+ -+ /* MT7622 platforms need to enable LTSSM and ASPM from PCIe subsys */ -+ if (pcie->base) { -+ val = readl(pcie->base + PCIE_SYS_CFG_V2); -+ val |= PCIE_CSR_LTSSM_EN(port->slot) | -+ PCIE_CSR_ASPM_L1_EN(port->slot); -+ writel(val, pcie->base + PCIE_SYS_CFG_V2); -+ } -+ -+ /* Assert all reset signals */ -+ writel(0, port->base + PCIE_RST_CTRL); -+ -+ /* -+ * Enable PCIe link down reset, if link status changed from link up to -+ * link down, this will reset MAC control registers and configuration -+ * space. -+ */ -+ writel(PCIE_LINKDOWN_RST_EN, port->base + PCIE_RST_CTRL); -+ -+ /* De-assert PHY, PE, PIPE, MAC and configuration reset */ -+ val = readl(port->base + PCIE_RST_CTRL); -+ val |= PCIE_PHY_RSTB | PCIE_PERSTB | PCIE_PIPE_SRSTB | -+ PCIE_MAC_SRSTB | PCIE_CRSTB; -+ writel(val, port->base + PCIE_RST_CTRL); -+ -+ /* Set up vendor ID and class code */ -+ if (soc->need_fix_class_id) { -+ val = PCI_VENDOR_ID_MEDIATEK; -+ writew(val, port->base + PCIE_CONF_VEND_ID); -+ -+ val = PCI_CLASS_BRIDGE_PCI; -+ writew(val, port->base + PCIE_CONF_CLASS_ID); -+ } -+ -+ /* 100ms timeout value should be enough for Gen1/2 training */ -+ err = readl_poll_timeout(port->base + PCIE_LINK_STATUS_V2, val, -+ !!(val & PCIE_PORT_LINKUP_V2), 20, -+ 100 * USEC_PER_MSEC); -+ if (err) -+ return -ETIMEDOUT; -+ -+ /* Set INTx mask */ -+ val = readl(port->base + PCIE_INT_MASK); -+ val &= ~INTX_MASK; -+ writel(val, port->base + PCIE_INT_MASK); -+ -+ if (IS_ENABLED(CONFIG_PCI_MSI)) -+ mtk_pcie_enable_msi(port); -+ -+ /* Set AHB to PCIe translation windows */ -+ size = mem->end - mem->start; -+ val = lower_32_bits(mem->start) | AHB2PCIE_SIZE(fls(size)); -+ writel(val, port->base + PCIE_AHB_TRANS_BASE0_L); -+ -+ val = upper_32_bits(mem->start); -+ writel(val, port->base + PCIE_AHB_TRANS_BASE0_H); -+ -+ /* Set PCIe to AXI translation memory space.*/ -+ val = fls(0xffffffff) | WIN_ENABLE; -+ writel(val, port->base + PCIE_AXI_WINDOW0); - - return 0; - } -@@ -903,49 +928,29 @@ - - /* sys_ck might be divided into the following parts in some chips */ - snprintf(name, sizeof(name), "ahb_ck%d", slot); -- port->ahb_ck = devm_clk_get(dev, name); -- if (IS_ERR(port->ahb_ck)) { -- if (PTR_ERR(port->ahb_ck) == -EPROBE_DEFER) -- return -EPROBE_DEFER; -- -- port->ahb_ck = NULL; -- } -+ port->ahb_ck = devm_clk_get_optional(dev, name); -+ if (IS_ERR(port->ahb_ck)) -+ return PTR_ERR(port->ahb_ck); - - snprintf(name, sizeof(name), "axi_ck%d", slot); -- port->axi_ck = devm_clk_get(dev, name); -- if (IS_ERR(port->axi_ck)) { -- if (PTR_ERR(port->axi_ck) == -EPROBE_DEFER) -- return -EPROBE_DEFER; -- -- port->axi_ck = NULL; -- } -+ port->axi_ck = devm_clk_get_optional(dev, name); -+ if (IS_ERR(port->axi_ck)) -+ return PTR_ERR(port->axi_ck); - - snprintf(name, sizeof(name), "aux_ck%d", slot); -- port->aux_ck = devm_clk_get(dev, name); -- if (IS_ERR(port->aux_ck)) { -- if (PTR_ERR(port->aux_ck) == -EPROBE_DEFER) -- return -EPROBE_DEFER; -- -- port->aux_ck = NULL; -- } -+ port->aux_ck = devm_clk_get_optional(dev, name); -+ if (IS_ERR(port->aux_ck)) -+ return PTR_ERR(port->aux_ck); - - snprintf(name, sizeof(name), "obff_ck%d", slot); -- port->obff_ck = devm_clk_get(dev, name); -- if (IS_ERR(port->obff_ck)) { -- if (PTR_ERR(port->obff_ck) == -EPROBE_DEFER) -- return -EPROBE_DEFER; -- -- port->obff_ck = NULL; -- } -+ port->obff_ck = devm_clk_get_optional(dev, name); -+ if (IS_ERR(port->obff_ck)) -+ return PTR_ERR(port->obff_ck); - - snprintf(name, sizeof(name), "pipe_ck%d", slot); -- port->pipe_ck = devm_clk_get(dev, name); -- if (IS_ERR(port->pipe_ck)) { -- if (PTR_ERR(port->pipe_ck) == -EPROBE_DEFER) -- return -EPROBE_DEFER; -- -- port->pipe_ck = NULL; -- } -+ port->pipe_ck = devm_clk_get_optional(dev, name); -+ if (IS_ERR(port->pipe_ck)) -+ return PTR_ERR(port->pipe_ck); - - snprintf(name, sizeof(name), "pcie-rst%d", slot); - port->reset = devm_reset_control_get_optional_exclusive(dev, name); -@@ -998,10 +1003,8 @@ - pcie->free_ck = NULL; - } - -- if (dev->pm_domain) { -- pm_runtime_enable(dev); -- pm_runtime_get_sync(dev); -- } -+ pm_runtime_enable(dev); -+ pm_runtime_get_sync(dev); - - /* enable top level clock */ - err = clk_prepare_enable(pcie->free_ck); -@@ -1013,10 +1016,8 @@ - return 0; - - err_free_ck: -- if (dev->pm_domain) { -- pm_runtime_put_sync(dev); -- pm_runtime_disable(dev); -- } -+ pm_runtime_put_sync(dev); -+ pm_runtime_disable(dev); - - return err; - } -@@ -1125,34 +1126,6 @@ - return 0; - } - --static int mtk_pcie_register_host(struct pci_host_bridge *host) --{ -- struct mtk_pcie *pcie = pci_host_bridge_priv(host); -- struct pci_bus *child; -- int err; -- -- host->busnr = pcie->busn.start; -- host->dev.parent = pcie->dev; -- host->ops = pcie->soc->ops; -- host->map_irq = of_irq_parse_and_map_pci; -- host->swizzle_irq = pci_common_swizzle; -- host->sysdata = pcie; -- -- err = pci_scan_root_bus_bridge(host); -- if (err < 0) -- return err; -- -- pci_bus_size_bridges(host->bus); -- pci_bus_assign_resources(host->bus); -- -- list_for_each_entry(child, &host->bus->children, node) -- pcie_bus_configure_settings(child); -- -- pci_bus_add_devices(host->bus); -- -- return 0; --} -- - static int mtk_pcie_probe(struct platform_device *pdev) - { - struct device *dev = &pdev->dev; -@@ -1179,7 +1152,14 @@ - if (err) - goto put_resources; - -- err = mtk_pcie_register_host(host); -+ host->busnr = pcie->busn.start; -+ host->dev.parent = pcie->dev; -+ host->ops = pcie->soc->ops; -+ host->map_irq = of_irq_parse_and_map_pci; -+ host->swizzle_irq = pci_common_swizzle; -+ host->sysdata = pcie; -+ -+ err = pci_host_probe(host); - if (err) - goto put_resources; - -@@ -1192,6 +1172,80 @@ - return err; - } - -+ -+static void mtk_pcie_free_resources(struct mtk_pcie *pcie) -+{ -+ struct pci_host_bridge *host = pci_host_bridge_from_priv(pcie); -+ struct list_head *windows = &host->windows; -+ -+ pci_free_resource_list(windows); -+} -+ -+static int mtk_pcie_remove(struct platform_device *pdev) -+{ -+ struct mtk_pcie *pcie = platform_get_drvdata(pdev); -+ struct pci_host_bridge *host = pci_host_bridge_from_priv(pcie); -+ -+ pci_stop_root_bus(host->bus); -+ pci_remove_root_bus(host->bus); -+ mtk_pcie_free_resources(pcie); -+ -+ mtk_pcie_irq_teardown(pcie); -+ -+ mtk_pcie_put_resources(pcie); -+ -+ return 0; -+} -+ -+static int __maybe_unused mtk_pcie_suspend_noirq(struct device *dev) -+{ -+ struct mtk_pcie *pcie = dev_get_drvdata(dev); -+ struct mtk_pcie_port *port; -+ -+ if (list_empty(&pcie->ports)) -+ return 0; -+ -+ list_for_each_entry(port, &pcie->ports, list) { -+ clk_disable_unprepare(port->pipe_ck); -+ clk_disable_unprepare(port->obff_ck); -+ clk_disable_unprepare(port->axi_ck); -+ clk_disable_unprepare(port->aux_ck); -+ clk_disable_unprepare(port->ahb_ck); -+ clk_disable_unprepare(port->sys_ck); -+ phy_power_off(port->phy); -+ phy_exit(port->phy); -+ } -+ -+ clk_disable_unprepare(pcie->free_ck); -+ -+ return 0; -+} -+ -+static int __maybe_unused mtk_pcie_resume_noirq(struct device *dev) -+{ -+ struct mtk_pcie *pcie = dev_get_drvdata(dev); -+ struct mtk_pcie_port *port, *tmp; -+ -+ if (list_empty(&pcie->ports)) -+ return 0; -+ -+ clk_prepare_enable(pcie->free_ck); -+ -+ list_for_each_entry_safe(port, tmp, &pcie->ports, list) -+ mtk_pcie_enable_port(port); -+ -+ /* In case of EP was removed while system suspend. */ -+ if (list_empty(&pcie->ports)) -+ clk_disable_unprepare(pcie->free_ck); -+ -+ return 0; -+} -+ -+static const struct dev_pm_ops mtk_pcie_pm_ops = { -+ SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(mtk_pcie_suspend_noirq, -+ mtk_pcie_resume_noirq) -+}; -+ - static const struct mtk_pcie_soc mtk_pcie_soc_v1 = { - .ops = &mtk_pcie_ops, - .startup = mtk_pcie_startup_port, -@@ -1220,10 +1274,13 @@ - - static struct platform_driver mtk_pcie_driver = { - .probe = mtk_pcie_probe, -+ .remove = mtk_pcie_remove, - .driver = { - .name = "mtk-pcie", - .of_match_table = mtk_pcie_ids, - .suppress_bind_attrs = true, -+ .pm = &mtk_pcie_pm_ops, - }, - }; --builtin_platform_driver(mtk_pcie_driver); -+module_platform_driver(mtk_pcie_driver); -+MODULE_LICENSE("GPL v2"); -diff -urN a/include/linux/clk.h b/include/linux/clk.h ---- a/include/linux/clk.h 2019-08-29 16:59:52.335365591 +0800 -+++ b/include/linux/clk.h 2019-08-29 17:02:17.107725525 +0800 -@@ -349,6 +349,17 @@ - struct clk *devm_clk_get(struct device *dev, const char *id); - - /** -+ * devm_clk_get_optional - lookup and obtain a managed reference to an optional -+ * clock producer. -+ * @dev: device for clock "consumer" -+ * @id: clock consumer ID -+ * -+ * Behaves the same as devm_clk_get() except where there is no clock producer. -+ * In this case, instead of returning -ENOENT, the function returns NULL. -+ */ -+struct clk *devm_clk_get_optional(struct device *dev, const char *id); -+ -+/** - * devm_get_clk_from_child - lookup and obtain a managed reference to a - * clock producer from child node. - * @dev: device for clock "consumer"