kiddin9 2 jaren geleden
bovenliggende
commit
7d7f735f8d
59 gewijzigde bestanden met toevoegingen van 836 en 4369 verwijderingen
  1. 1 1
      .github/workflows/Openwrt-AutoBuild.yml
  2. 1 1
      README.md
  3. 1 2
      devices/armvirt_64/diy.sh
  4. 1 1
      devices/ath79_nand/diy.sh
  5. 1 1
      devices/bcm27xx_bcm2708/diy.sh
  6. 1 1
      devices/bcm27xx_bcm2709/diy.sh
  7. 0 1
      devices/bcm27xx_bcm2710/diy.sh
  8. 0 1
      devices/bcm27xx_bcm2711/diy.sh
  9. 1 1
      devices/bcm53xx/diy.sh
  10. 12 2
      devices/common/.config
  11. 8 0
      devices/common/diy.sh
  12. 0 4
      devices/common/feeds.conf
  13. 0 38
      devices/common/kernel_5.15.sh
  14. 2 2
      devices/common/patches/imagebuilder.patch
  15. 1 1
      devices/common/settings.ini
  16. 0 2
      devices/ipq40xx_generic/diy.sh
  17. 0 2
      devices/ipq50xx_arm/.config
  18. 5 10
      devices/ipq50xx_arm/diy.sh
  19. 4 4
      devices/ipq50xx_arm/feeds.conf
  20. 3 1
      devices/ipq60xx_generic/.config
  21. 8 3
      devices/ipq60xx_generic/diy.sh
  22. 1 1
      devices/ipq60xx_generic/patches/fix.patch
  23. 0 1
      devices/ipq807x_generic/README.md
  24. 0 2
      devices/ipq807x_generic/diy.sh
  25. 0 4
      devices/ipq807x_generic/feeds.conf
  26. 0 2
      devices/ipq807x_generic/settings.ini
  27. 1 4
      devices/ipq807x_ipq60xx/.config
  28. 6 7
      devices/ipq807x_ipq60xx/diy.sh
  29. 2 2
      devices/ipq807x_ipq60xx/feeds.conf
  30. 1 1
      devices/kirkwood_generic/diy.sh
  31. 1 1
      devices/mediatek_filogic/.config
  32. 1 7
      devices/mediatek_filogic/diy.sh
  33. 411 0
      devices/mediatek_filogic/patches/360t7.patch
  34. 1 1
      devices/mediatek_mt7622/diy.sh
  35. 0 4
      devices/mediatek_mt7981/.config
  36. 5 10
      devices/mediatek_mt7981/diy.sh
  37. 3 3
      devices/mediatek_mt7981/feeds.conf
  38. 0 3
      devices/mediatek_mt7986/.config
  39. 5 10
      devices/mediatek_mt7986/diy.sh
  40. 4 4
      devices/mediatek_mt7986/feeds.conf
  41. 72 2548
      devices/ramips_mt7620/patches/hiwifi_r33.patch
  42. 1 1
      devices/ramips_mt7621/diy.sh
  43. 128 0
      devices/ramips_mt7621/patches/01-small_flash.patch
  44. 0 503
      devices/ramips_mt7621/patches/02-4a-v2.patch
  45. 72 123
      devices/ramips_mt7621/patches/02-cr660x.patch
  46. 1 27
      devices/ramips_mt7621/patches/03-4a-breed-fix.patch
  47. 0 432
      devices/ramips_mt7621/patches/TX1800.patch
  48. 55 371
      devices/ramips_mt7621/patches/k2p_32m.patch
  49. 0 21
      devices/ramips_mt7621/patches/luban.patch
  50. 1 52
      devices/ramips_mt7621/patches/zte_e8820s.patch
  51. 1 1
      devices/ramips_mt76x8/diy.sh
  52. 0 135
      devices/ramips_mt76x8/patches/hc5611.patch
  53. 1 1
      devices/ramips_mt76x8/patches/small_flash.patch
  54. 0 1
      devices/rockchip_armv8/diy.sh
  55. 12 3
      devices/rockchip_armv8/patches/r6s.patch
  56. 0 1
      devices/sunxi_cortexa53/diy.sh
  57. 0 1
      devices/sunxi_cortexa7/diy.sh
  58. 0 1
      devices/x86_64/diy.sh
  59. 0 1
      devices/x86_generic/diy.sh

+ 1 - 1
.github/workflows/Openwrt-AutoBuild.yml

@@ -119,7 +119,7 @@ jobs:
       run: |
         sudo -E apt-get -qq update
         sudo -E apt-get -qq install build-essential clang flex g++ gawk gcc-multilib gettext \
-        git libncurses5-dev libssl-dev python3-distutils python3-pyelftools libpython3-dev rsync unzip zlib1g-dev swig aria2 jq subversion qemu-utils ccache rename libelf-dev device-tree-compiler libgnutls28-dev
+        git libncurses5-dev libssl-dev python3-distutils python3-pyelftools libpython3-dev rsync unzip zlib1g-dev swig aria2 jq subversion qemu-utils ccache rename libelf-dev device-tree-compiler libgnutls28-dev coccinelle
         sudo -E apt-get -qq purge azure-cli ghc* zulu* llvm* firefox powershell openjdk* dotnet* google* mysql* php* android*
         sudo rm -rf /etc/apt/sources.list.d/* /usr/share/dotnet /usr/local/lib/android /opt/ghc
         sudo -E apt-get -qq autoremove --purge

+ 1 - 1
README.md

@@ -25,7 +25,7 @@ X86/64, 友善 NanoPi、R2S、R4S、R4SE、R5S、R2C、R5C、R6S、NEO3, 斐讯
 <a href="https://t.me/opwrt" target="_blank">TG通知频道</a>
 ## 1. **特色**
 
-+ Cutting edge,openwrt官方openwrt-22.03分支版本, Kernel 5.15, 与官方最新源码同步.
++ Cutting edge,openwrt官方openwrt-23.05分支版本, Kernel 5.15, 与官方最新源码同步.
 
 + 原生极致纯净,固件默认只包含基础上网功能, 后台在线选装插件,系统升级不丢失插件和配置.
 

+ 1 - 2
devices/armvirt_64/diy.sh

@@ -1,10 +1,9 @@
 
 
 SHELL_FOLDER=$(dirname $(readlink -f "$0"))
-bash $SHELL_FOLDER/../common/kernel_5.15.sh
 
 
 
-sed -i 's/DEFAULT_PACKAGES +=/DEFAULT_PACKAGES += perl btrfs-progs luci-app-amlogic kmod-brcmfmac wpad-basic-wolfssl iw -luci-app-attendedsysupgrade -luci-app-gpsysupgrade fdisk lsblk/' target/linux/armvirt/Makefile
+sed -i 's/DEFAULT_PACKAGES +=/DEFAULT_PACKAGES += perl btrfs-progs luci-app-amlogic kmod-brcmfmac wpad-basic-mbedtls iw -luci-app-attendedsysupgrade -luci-app-gpsysupgrade fdisk lsblk/' target/linux/armvirt/Makefile
 
 

+ 1 - 1
devices/ath79_nand/diy.sh

@@ -3,7 +3,7 @@
 shopt -s extglob
 
 SHELL_FOLDER=$(dirname $(readlink -f "$0"))
-#bash $SHELL_FOLDER/../common/kernel_5.15.sh
+
 
 
 

+ 1 - 1
devices/bcm27xx_bcm2708/diy.sh

@@ -1,7 +1,7 @@
 #!/bin/bash
 
 SHELL_FOLDER=$(dirname $(readlink -f "$0"))
-#bash $SHELL_FOLDER/../common/kernel_5.15.sh
+
 
 sed -i 's/DEFAULT_PACKAGES +=/DEFAULT_PACKAGES += fdisk lsblk kmod-usb-net-asix-ax88179 kmod-usb-net-rtl8152/' target/linux/bcm27xx/Makefile
 

+ 1 - 1
devices/bcm27xx_bcm2709/diy.sh

@@ -1,6 +1,6 @@
 #!/bin/bash
 SHELL_FOLDER=$(dirname $(readlink -f "$0"))
-#bash $SHELL_FOLDER/../common/kernel_5.15.sh
+
 
 sed -i 's/DEFAULT_PACKAGES +=/DEFAULT_PACKAGES += fdisk lsblk kmod-usb-net-asix-ax88179 kmod-usb-net-rtl8152/' target/linux/bcm27xx/Makefile
 

+ 0 - 1
devices/bcm27xx_bcm2710/diy.sh

@@ -1,7 +1,6 @@
 #!/bin/bash
 
 SHELL_FOLDER=$(dirname $(readlink -f "$0"))
-bash $SHELL_FOLDER/../common/kernel_5.15.sh
 
 
 

+ 0 - 1
devices/bcm27xx_bcm2711/diy.sh

@@ -1,7 +1,6 @@
 #!/bin/bash
 
 SHELL_FOLDER=$(dirname $(readlink -f "$0"))
-bash $SHELL_FOLDER/../common/kernel_5.15.sh
 
 
 

+ 1 - 1
devices/bcm53xx/diy.sh

@@ -3,7 +3,7 @@
 shopt -s extglob
 
 SHELL_FOLDER=$(dirname $(readlink -f "$0"))
-#bash $SHELL_FOLDER/../common/kernel_5.15.sh
+
 
 sed -i "s/^TARGET_DEVICES /# TARGET_DEVICES /" target/linux/bcm53xx/image/Makefile
 sed -i "s/# TARGET_DEVICES += phicomm_k3/TARGET_DEVICES += phicomm_k3/" target/linux/bcm53xx/image/Makefile

+ 12 - 2
devices/common/.config

@@ -79,7 +79,17 @@ CONFIG_BUSYBOX_CONFIG_FEATURE_SYSLOG_INFO=y
 CONFIG_PACKAGE_bash=y
 CONFIG_PACKAGE_ca-bundle=y
 
-CONFIG_PACKAGE_dockerd=m
+CONFIG_KERNEL_CGROUP_DEVICE=y
+CONFIG_KERNEL_CGROUP_FREEZER=y
+CONFIG_KERNEL_NET_CLS_CGROUP=y
+CONFIG_KERNEL_CGROUP_NET_PRIO=y
+CONFIG_KERNEL_MEMCG_SWAP_ENABLED=y
+CONFIG_KERNEL_CFQ_GROUP_IOSCHED=y
+CONFIG_KERNEL_CGROUP_PERF=y
+CONFIG_KERNEL_CGROUP_HUGETLB=y
+CONFIG_KERNEL_EXT4_FS_POSIX_ACL=y
+CONFIG_KERNEL_EXT4_FS_SECURITY=y
+CONFIG_KERNEL_BTRFS_FS_POSIX_ACL=y
 
 CONFIG_PACKAGE_kmod-drm-nouveau=n
 CONFIG_PACKAGE_kmod-rtl8821cu=n
@@ -98,7 +108,7 @@ CONFIG_PACKAGE_kmod-mii=n
 
 CONFIG_IMAGEOPT=y
 CONFIG_VERSIONOPT=y
-CONFIG_VERSION_REPO="https://op.supes.top"
+CONFIG_VERSION_REPO="https://op.supes.top/23.05"
 CONFIG_VERSION_MANUFACTURER="Kiddin'"
 CONFIG_VERSION_FILENAMES=n
 CONFIG_VERSION_CODE_FILENAMES=n

+ 8 - 0
devices/common/diy.sh

@@ -4,6 +4,7 @@ shopt -s extglob
 
 [ ! -f feeds.conf ] && {
 sed -i '$a src-git kiddin9 https://github.com/kiddin9/openwrt-packages.git;master' feeds.conf.default
+sed -i "/telephony/d" feeds.conf.default
 }
 
 sed -i "s?targets/%S/packages?targets/%S/\$(LINUX_VERSION)?" include/feeds.mk
@@ -41,6 +42,13 @@ sed -i "s/192.168.1/10.0.0/" package/base-files/files/bin/config_generate
 (
 svn co https://github.com/coolsnowwolf/lede/trunk/target/linux/generic/hack-5.10 target/linux/generic/hack-5.10
 rm -rf target/linux/generic/hack-5.10/{220-gc_sections*,781-dsa-register*,780-drivers-net*,996-fs-ntfs3*,100-update-mtk_wed_h.patch}
+
+svn co https://github.com/coolsnowwolf/lede/trunk/target/linux/generic/hack-5.15 target/linux/generic/hack-5.15
+svn co https://github.com/coolsnowwolf/lede/trunk/target/linux/generic/backport-5.15 target/linux/generic/backport-5.15
+find target/linux/generic/backport-5.15 -name "[0-9][0-9][0-9]-[a-z][a-z]*" -exec rm -f {} \;
+rm -rf target/linux/generic/backport-5.15/{799-v6.0-net-mii*,802-v6.1-nvmem*,803-v5.19-nvmem*,733-v6.2-02-net-mediatek-sgmii-ensure*,733-v6.2-03-net-mediatek*,733-v6.2-04-mtk_sgmii-enable*,730-11-v6.3-net-ethernet-mtk_eth*,775-v5.16-net-phylink*,776-v5.16-net-ethernet-*,612-v6.3-skbuff-Fix*}
+curl -sfL https://raw.githubusercontent.com/coolsnowwolf/lede/master/target/linux/generic/pending-5.15/613-netfilter_optional_tcp_window_check.patch -o target/linux/generic/pending-5.15/613-netfilter_optional_tcp_window_check.patch
+sed -i "s/CONFIG_WERROR=y/CONFIG_WERROR=n/" target/linux/generic/config-5.15
 ) &
 
 curl -sfL https://raw.githubusercontent.com/coolsnowwolf/lede/master/target/linux/generic/pending-5.10/613-netfilter_optional_tcp_window_check.patch -o target/linux/generic/pending-5.10/613-netfilter_optional_tcp_window_check.patch

+ 0 - 4
devices/common/feeds.conf

@@ -1,4 +0,0 @@
-src-git packages https://git.openwrt.org/feed/packages.git;openwrt-22.03
-src-git luci https://git.openwrt.org/project/luci.git;openwrt-22.03
-src-git routing https://git.openwrt.org/feed/routing.git;openwrt-22.03
-src-git kiddin9 https://github.com/kiddin9/openwrt-packages.git;master

+ 0 - 38
devices/common/kernel_5.15.sh

@@ -1,38 +0,0 @@
-#!/bin/bash
-
-rm -rf target/linux package/kernel package/boot package/firmware/linux-firmware include/{kernel-*,netfilter.mk}
-latest="$(curl -sfL https://github.com/openwrt/openwrt/commits/master/include | grep -o 'href=".*>kernel: bump 5.15' | head -1 | cut -d / -f 5 | cut -d '"' -f 1)"
-latest=""
-mkdir new; cp -rf .git new/.git
-cd new
-[ "$latest" ] && (git reset --hard $latest  && git checkout HEAD^) || git reset --hard origin/master
-
-[ "$(echo $(git log -1 --pretty=short) | grep "kernel: bump 5.15")" ] && git checkout $latest
-
-cp -rf --parents target/linux package/kernel package/boot package/firmware/linux-firmware include/{kernel-*,netfilter.mk} ../
-cd -
-
-#sed -i "s/9 -Xe/extreme/" include/image.mk
-
-sed -i "s/^.*vermagic$/\techo '1' > \$(LINUX_DIR)\/.vermagic/" include/kernel-defaults.mk
-
-curl -sfL https://raw.githubusercontent.com/openwrt/openwrt/master/include/image-commands.mk -o include/image-commands.mk
-sed -i "s/\$(STAGING_DIR_HOST)\/bin\/gzip/gzip/" include/image-commands.mk
-svn export --force https://github.com/openwrt/packages/trunk/kernel feeds/packages/kernel
-svn export --force  https://github.com/openwrt/packages/trunk/net/xtables-addons feeds/packages/net/xtables-addons
-
-svn co https://github.com/coolsnowwolf/lede/trunk/target/linux/generic/hack-5.15 target/linux/generic/hack-5.15
-svn co https://github.com/coolsnowwolf/lede/trunk/target/linux/generic/backport-5.15 target/linux/generic/backport-5.15
-find target/linux/generic/backport-5.15 -name "[0-9][0-9][0-9]-[a-z][a-z]*" -exec rm -f {} \;
-rm -rf target/linux/generic/backport-5.15/{799-v6.0-net-mii*,802-v6.1-nvmem*,803-v5.19-nvmem*,733-v6.2-02-net-mediatek-sgmii-ensure*,733-v6.2-03-net-mediatek*,733-v6.2-04-mtk_sgmii-enable*,730-11-v6.3-net-ethernet-mtk_eth*,775-v5.16-net-phylink*,776-v5.16-net-ethernet-*,612-v6.3-skbuff-Fix*}
-curl -sfL https://raw.githubusercontent.com/coolsnowwolf/lede/master/target/linux/generic/pending-5.15/613-netfilter_optional_tcp_window_check.patch -o target/linux/generic/pending-5.15/613-netfilter_optional_tcp_window_check.patch
-
-sed -i "s/tty\(0\|1\)::askfirst/tty\1::respawn/g" target/linux/*/base-files/etc/inittab
-
-sed -i "s/CONFIG_WERROR=y/CONFIG_WERROR=n/" target/linux/generic/config-5.15
-
-echo "
-CONFIG_TESTING_KERNEL=y
-CONFIG_PACKAGE_kmod-ipt-coova=n
-CONFIG_PACKAGE_kmod-pf-ring=n
-" >> devices/common/.config

+ 2 - 2
devices/common/patches/imagebuilder.patch

@@ -13,8 +13,8 @@
  	$(call FeedSourcesAppend,$(PKG_BUILD_DIR)/repositories.conf)
  	$(VERSION_SED_SCRIPT) $(PKG_BUILD_DIR)/repositories.conf
 -endif
-+	$(SED) 's/^src\/gz \(.*\) https.*top\/\(packages.*\)/src \1 file:\/\/www\/wwwroot\/op.supes.top\/\2/' $(PKG_BUILD_DIR)/repositories.conf
-+	$(SED) 's/^src\/gz \(.*\) https.*top\/\(targets.*\)/src \1 file:\/\/www\/wwwroot\/op.supes.top\/releases\/\2/' $(PKG_BUILD_DIR)/repositories.conf
++	$(SED) 's/^src\/gz \(.*\) https.*top\/\(.*packages.*\)/src \1 file:\/\/www\/wwwroot\/op.supes.top\/\2/' $(PKG_BUILD_DIR)/repositories.conf
++	$(SED) 's/^src\/gz \(.*\) https.*top\/\(.*targets.*\)/src \1 file:\/\/www\/wwwroot\/op.supes.top\/\2/' $(PKG_BUILD_DIR)/repositories.conf
 +	$(SED) 's/\/kiddin9//' $(PKG_BUILD_DIR)/repositories.conf
 +	$(SED) '/openwrt_core/d' $(PKG_BUILD_DIR)/repositories.conf
  

+ 1 - 1
devices/common/settings.ini

@@ -1,5 +1,5 @@
 REPO_URL="https://github.com/openwrt/openwrt"
-REPO_BRANCH=""
+REPO_BRANCH="openwrt-23.05"
 CONFIG_FILE=".config"
 DIY_SH="diy.sh"
 FREE_UP_DISK="false"

+ 0 - 2
devices/ipq40xx_generic/diy.sh

@@ -4,8 +4,6 @@ shopt -s extglob
 
 SHELL_FOLDER=$(dirname $(readlink -f "$0"))
 
-bash $SHELL_FOLDER/../common/kernel_5.15.sh
-
 
 
 svn export --force https://github.com/openwrt/openwrt/trunk/package/firmware/ipq-wifi package/firmware/ipq-wifi

+ 0 - 2
devices/ipq50xx_arm/.config

@@ -6,8 +6,6 @@ CONFIG_TARGET_ALL_PROFILES=y
 
 CONFIG_PACKAGE_luci-ssl=y # uhttpd服务
 
-CONFIG_PACKAGE_kmod-mdio-netlink=n
-CONFIG_PACKAGE_kmod-jool-netfilter=n
 CONFIG_PACKAGE_perf=n
 
 CONFIG_PACKAGE_kmod-netem=n

+ 5 - 10
devices/ipq50xx_arm/diy.sh

@@ -4,18 +4,13 @@ shopt -s extglob
 
 SHELL_FOLDER=$(dirname $(readlink -f "$0"))
 
-sed -i '/postgres=5432/d' feeds/packages.index
-sed -i '/postgres=5432/d' feeds/packages/net/gnunet/Makefile
-./scripts/feeds install -a
-
-sed -i "s/make-ext4fs missing-macros/make-ext4fs meson missing-macros/" tools/Makefile
-curl -sfL https://raw.githubusercontent.com/openwrt/openwrt/openwrt-22.03/include/meson.mk -o include/meson.mk
-svn co https://github.com/openwrt/openwrt/branches/openwrt-22.03/tools/meson tools/meson
-
 rm -rf package/feeds/kiddin9/rtl* feeds/kiddin9/{shortcut-fe,fullconenat-nft} package/kernel/mt76 package/kernel/exfat package/feeds/packages/fuse*
 
 rm -rf devices/common/patches/{fix.patch,iptables.patch,kernel-defaults.patch,targets.patch}
 
-rm -rf toolchain/musl
+rm -rf toolchain/musl package/utils/e2fsprogs package/libs/libselinux package/feeds/packages/acl
 
-svn co https://github.com/openwrt/openwrt/branches/openwrt-22.03/toolchain/musl toolchain/musl
+svn co https://github.com/openwrt/openwrt/branches/openwrt-23.05/toolchain/musl toolchain/musl
+svn co https://github.com/openwrt/openwrt/branches/openwrt-23.05/package/utils/e2fsprogs package/utils/e2fsprogs
+svn co https://github.com/openwrt/openwrt/branches/openwrt-23.05/package/libs/libselinux package/libs/libselinux
+ln -sf $(pwd)/feeds/luci/modules/luci-base package/feeds/kiddin9/

+ 4 - 4
devices/ipq50xx_arm/feeds.conf

@@ -1,4 +1,4 @@
-src-git packages https://git.openwrt.org/feed/packages.git;openwrt-22.03
-src-git luci https://git.openwrt.org/project/luci.git;openwrt-22.03
-src-git routing https://git.openwrt.org/feed/routing.git;openwrt-22.03
-src-git kiddin9 https://github.com/kiddin9/openwrt-packages.git;master
+src-git packages https://git.openwrt.org/feed/packages.git;openwrt-21.02
+src-git luci https://github.com/openwrt/luci.git;openwrt-22.03
+src-git routing https://git.openwrt.org/feed/routing.git;openwrt-21.02
+src-git kiddin9 https://github.com/kiddin9/openwrt-packages.git;master

+ 3 - 1
devices/ipq60xx_generic/.config

@@ -8,7 +8,7 @@ CONFIG_TARGET_DEVICE_ipq60xx_generic_DEVICE_glinet_gl-axt1800=n
 
 CONFIG_TARGET_ROOTFS_INITRAMFS=n
 
-CONFIG_PACKAGE_dockerd=n
+CONFIG_PACKAGE_perf=n
 
 CONFIG_GCC_USE_VERSION_7=y
 CONFIG_PACKAGE_kmod-dm-raid=n
@@ -56,6 +56,8 @@ CONFIG_PACKAGE_kmod-batman-adv=n
 CONFIG_PACKAGE_kmod-rtl8812au-ct=n
 CONFIG_PACKAGE_kmod-rtl8821cu=n
 CONFIG_PACKAGE_kmod-rtl88x2bu=n
+CONFIG_PACKAGE_kmod-pf-ring=n
+CONFIG_PACKAGE_kmod-netatop=n
 
 
 CONFIG_SECCOMP=n

+ 8 - 3
devices/ipq60xx_generic/diy.sh

@@ -21,9 +21,14 @@ curl -sfL https://raw.githubusercontent.com/coolsnowwolf/openwrt-gl-ax1800/maste
 curl -sfL https://raw.githubusercontent.com/coolsnowwolf/openwrt-gl-ax1800/master/include/quilt.mk -o include/quilt.mk
 
 rm -rf toolchain/.svn
-rm -rf feeds/kiddin9/{rtl*,fullconenat-nft,shortcut-fe,netifd} package/kernel/mt76 toolchain/musl package/feeds/packages/{xtables-addons,openvswitch}
-svn co https://github.com/openwrt/openwrt/branches/openwrt-22.03/toolchain/musl toolchain/musl
-svn co https://github.com/openwrt/openwrt/branches/openwrt-22.03/toolchain/glibc toolchain/glibc
+rm -rf feeds/kiddin9/{rtl*,fullconenat-nft,shortcut-fe,netifd} package/kernel/mt76 toolchain/musl package/feeds/packages/{xtables-addons,openvswitch} package/libs/elfutils package/utils/util-linux package/feeds/luci/ucode-mod-html package/libs/openssl package/network/utils/iptables package/feeds/packages/v4l2loopback package/feeds/packages/jool package/network/utils/uqmi
+svn co https://github.com/openwrt/openwrt/branches/openwrt-23.05/toolchain/musl toolchain/musl
+svn co https://github.com/openwrt/openwrt/branches/openwrt-23.05/toolchain/glibc toolchain/glibc
+svn co https://github.com/openwrt/openwrt/branches/openwrt-22.03/package/libs/elfutils package/libs/elfutils
+svn co https://github.com/openwrt/openwrt/branches/openwrt-22.03/package/utils/util-linux package/utils/util-linux
+svn co https://github.com/openwrt/openwrt/branches/openwrt-22.03/package/libs/openssl package/libs/openssl
+svn co https://github.com/openwrt/openwrt/branches/openwrt-22.03/package/network/utils/iptables package/network/utils/iptables
+svn co https://github.com/openwrt/openwrt/branches/openwrt-22.03/package/network/utils/uqmi package/network/utils/uqmi
 
 sed -i "s/5.4.0/4.4.0/" toolchain/glibc/common.mk
 

+ 1 - 1
devices/ipq60xx_generic/patches/fix.patch

@@ -92,7 +92,7 @@
  	kmod-leds-gpio kmod-gpio-button-hotplug swconfig \
  	kmod-qca-nss-dp kmod-qca-nss-drv kmod-qca-ssdk \
 -	kmod-ath11k-ahb qca-ssdk-shell wpad-openssl \
-+	kmod-ath11k-ahb qca-ssdk-shell wpad-basic-wolfssl \
++	kmod-ath11k-ahb qca-ssdk-shell wpad-basic-mbedtls \
  	ath11k-firmware-ipq6018 nss-firmware-ipq6018 \
  	kmod-qca-nss-drv-pppoe kmod-qca-nss-ecm uboot-envtools
  

+ 0 - 1
devices/ipq807x_generic/README.md

@@ -1 +0,0 @@
-Kernel等部分源码来源 https://github.com/Boos4721/openwrt 感谢

+ 0 - 2
devices/ipq807x_generic/diy.sh

@@ -3,8 +3,6 @@ shopt -s extglob
 
 SHELL_FOLDER=$(dirname $(readlink -f "$0"))
 
-bash $SHELL_FOLDER/../common/kernel_5.15.sh
-
 svn co https://github.com/robimarko/nss-packages/trunk/qca/qca-ssdk-shell package/network/utils/qca-ssdk-shell
 
 sh -c "curl -sfL https://github.com/robimarko/openwrt/commit/23fa931934151f72c1655ffa62ff1a979575f07e.patch | patch -d './' -p1 --forward"

+ 0 - 4
devices/ipq807x_generic/feeds.conf

@@ -1,4 +0,0 @@
-src-git packages https://git.openwrt.org/feed/packages.git;openwrt-22.03
-src-git luci https://git.openwrt.org/project/luci.git;openwrt-22.03
-src-git routing https://git.openwrt.org/feed/routing.git;openwrt-22.03
-src-git kiddin9 https://github.com/kiddin9/openwrt-packages.git;master

+ 0 - 2
devices/ipq807x_generic/settings.ini

@@ -1,2 +0,0 @@
-REPO_URL="https://github.com/openwrt/openwrt"
-REPO_BRANCH="master"

+ 1 - 4
devices/ipq807x_ipq60xx/.config

@@ -7,10 +7,7 @@ CONFIG_TARGET_DEVICE_ipq807x_ipq60xx_DEVICE_glinet_ax1800=y
 
 CONFIG_CCACHE=n
 
-CONFIG_PACKAGE_dockerd=n
-CONFIG_PACKAGE_kmod-mdio-netlink=n
-CONFIG_PACKAGE_kmod-jool-netfilter=n
-CONFIG_PACKAGE_kmod-ovpn-dco=n
+CONFIG_PACKAGE_perf=n
 
 CONFIG_PACKAGE_kmod-dm-raid=n
 CONFIG_PACKAGE_kmod-dm=n

+ 6 - 7
devices/ipq807x_ipq60xx/diy.sh

@@ -12,13 +12,9 @@ rm -rf package/feeds
 ./scripts/feeds install -a -p wifi_ax -f
 ./scripts/feeds install -a -p gl_feeds_common -f
 ./scripts/feeds install -a -p kiddin9 -f
-sed -i '/postgres=5432/d' feeds/packages.index
-sed -i '/postgres=5432/d' feeds/packages/net/gnunet/Makefile
 ./scripts/feeds install -a
 
-sed -i "s/make-ext4fs missing-macros/make-ext4fs meson missing-macros/" tools/Makefile
-curl -sfL https://raw.githubusercontent.com/openwrt/openwrt/openwrt-22.03/include/meson.mk -o include/meson.mk
-svn co https://github.com/openwrt/openwrt/branches/openwrt-22.03/tools/meson tools/meson
+sed -i "/CONFIG_KERNEL_/d" devices/common/.config
 
 echo "
 CONFIG_FEED_gl_feeds_common=n
@@ -39,6 +35,9 @@ rm -rf package/kernel/exfat
 
 rm -rf devices/common/patches/{glinet,fix.patch,iptables.patch,targets.patch,kernel-defaults.patch,disable_flock.patch}
 
-rm -rf toolchain/musl
+rm -rf toolchain/musl package/utils/e2fsprogs package/libs/libselinux package/feeds/packages/acl
 
-svn co https://github.com/openwrt/openwrt/branches/openwrt-22.03/toolchain/musl toolchain/musl
+svn co https://github.com/openwrt/openwrt/branches/openwrt-23.05/toolchain/musl toolchain/musl
+svn co https://github.com/openwrt/openwrt/branches/openwrt-23.05/package/utils/e2fsprogs package/utils/e2fsprogs
+svn co https://github.com/openwrt/openwrt/branches/openwrt-23.05/package/libs/libselinux package/libs/libselinux
+ln -sf $(pwd)/feeds/luci/modules/luci-base package/feeds/kiddin9/

+ 2 - 2
devices/ipq807x_ipq60xx/feeds.conf

@@ -1,6 +1,6 @@
-src-git packages https://git.openwrt.org/feed/packages.git;openwrt-22.03
+src-git packages https://git.openwrt.org/feed/packages.git;openwrt-21.02
 src-git luci https://github.com/openwrt/luci.git;openwrt-22.03
-src-git routing https://git.openwrt.org/feed/routing.git;openwrt-22.03
+src-git routing https://git.openwrt.org/feed/routing.git;openwrt-21.02
 src-git kiddin9 https://github.com/kiddin9/openwrt-packages.git;master
 src-git gl_feeds_common https://github.com/gl-inet/gl-feeds.git;common
 src-link ipq807x ../../feeds/ipq807x

+ 1 - 1
devices/kirkwood_generic/diy.sh

@@ -3,6 +3,6 @@
 shopt -s extglob
 
 SHELL_FOLDER=$(dirname $(readlink -f "$0"))
-#bash $SHELL_FOLDER/../common/kernel_5.15.sh
+
 
 

+ 1 - 1
devices/mediatek_filogic/.config

@@ -7,5 +7,5 @@ CONFIG_TARGET_DEVICE_mediatek_filogic_DEVICE_bananapi_bpi-r3=y
 CONFIG_TARGET_DEVICE_mediatek_filogic_DEVICE_tplink_tl-xdr4288=y
 CONFIG_TARGET_DEVICE_mediatek_filogic_DEVICE_tplink_tl-xdr6086=y
 CONFIG_TARGET_DEVICE_mediatek_filogic_DEVICE_tplink_tl-xdr6088=y
-
+CONFIG_TARGET_DEVICE_mediatek_filogic_DEVICE_glinet_gl-mt3000=y
 CONFIG_PACKAGE_luci-ssl=y # uhttpd服务

+ 1 - 7
devices/mediatek_filogic/diy.sh

@@ -2,10 +2,4 @@
 
 shopt -s extglob
 
-SHELL_FOLDER=$(dirname $(readlink -f "$0"))
-bash $SHELL_FOLDER/../common/kernel_5.15.sh
-
-rm -rf tools/mkimage
-svn co https://github.com/openwrt/openwrt/trunk/tools/mkimage tools/mkimage
-
-curl -sfL https://raw.githubusercontent.com/openwrt/openwrt/master/scripts/mkits.sh -o scripts/mkits.sh
+sh -c "curl -sfL https://patch-diff.githubusercontent.com/raw/openwrt/openwrt/pull/11115.patch | patch -d './' -p1 --forward"

+ 411 - 0
devices/mediatek_filogic/patches/360t7.patch

@@ -0,0 +1,411 @@
+From 0e0de4f8b35a36d170c80cd54498d65dacdade18 Mon Sep 17 00:00:00 2001
+From: Tianling Shen <[email protected]>
+Date: Fri, 12 May 2023 18:00:42 +0800
+Subject: [PATCH] mediatek: add Qihoo 360 T7 support
+
+Co-authored-by: Chen Minqiang <[email protected]>
+Signed-off-by: Tianling Shen <[email protected]>
+---
+ .../uboot-envtools/files/mediatek_filogic     |   4 +-
+ .../dts/mt7981b-qihoo-360-t7-stock.dts         |  26 ++
+ .../dts/mt7981b-qihoo-360-t7-ubootmod.dts      |  16 ++
+ .../mediatek/dts/mt7981b-qihoo-360-t7.dtsi     | 238 ++++++++++++++++++
+ .../filogic/base-files/etc/board.d/02_network |   9 +-
+ .../etc/hotplug.d/ieee80211/11_fix_wifi_mac   |   5 +
+ target/linux/mediatek/image/filogic.mk        |  32 +++
+ 7 files changed, 328 insertions(+), 2 deletions(-)
+ create mode 100644 target/linux/mediatek/dts/mt7981b-qihoo-360-t7-stock.dts
+ create mode 100644 target/linux/mediatek/dts/mt7981b-qihoo-360-t7-ubootmod.dts
+ create mode 100644 target/linux/mediatek/dts/mt7981b-qihoo-360-t7.dtsi
+
+diff --git a/package/boot/uboot-envtools/files/mediatek_filogic b/package/boot/uboot-envtools/files/mediatek_filogic
+index 50b9cd0e4631c..739a6f007e23a 100644
+--- a/package/boot/uboot-envtools/files/mediatek_filogic
++++ b/package/boot/uboot-envtools/files/mediatek_filogic
+@@ -37,6 +37,10 @@ bananapi,bpi-r3)
+ 		;;
+ 	esac
+ 	;;
++qihoo,360-t7-stock|\
++qihoo,360-t7-ubootmod)
++	ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x20000" "0x20000" "1"
++	;;
+ xiaomi,redmi-router-ax6000-stock)
+ 	ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x10000" "0x20000"
+ 	ubootenv_add_uci_sys_config "/dev/mtd2" "0x0" "0x10000" "0x20000"
+diff --git a/target/linux/mediatek/dts/mt7981b-qihoo-360-t7-stock.dts b/target/linux/mediatek/dts/mt7981b-qihoo-360-t7-stock.dts
+new file mode 100644
+index 00000000000..9311ccc6f01
+--- /dev/null
++++ b/target/linux/mediatek/dts/mt7981b-qihoo-360-t7-stock.dts
+@@ -0,0 +1,26 @@
++// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
++
++/dts-v1/;
++#include "mt7981b-qihoo-360-t7.dtsi"
++
++/ {
++	model = "Qihoo 360 T7 (stock layout)";
++	compatible = "qihoo,360-t7-stock", "mediatek,mt7981";
++};
++
++&partitions {
++	partition@580000 {
++		label = "ubi";
++		reg = <0x580000 0x2400000>;
++	};
++
++	partition@2980000 {
++		label = "firmware-1";
++		reg = <0x2980000 0x2400000>;
++	};
++
++	partition@4D80000 {
++		label = "plugin";
++		reg = <0x4d80000 0x2400000>;
++	};
++};
+diff --git a/target/linux/mediatek/dts/mt7981b-qihoo-360-t7-ubootmod.dts b/target/linux/mediatek/dts/mt7981b-qihoo-360-t7-ubootmod.dts
+new file mode 100644
+index 00000000000..6e009509fd5
+--- /dev/null
++++ b/target/linux/mediatek/dts/mt7981b-qihoo-360-t7-ubootmod.dts
+@@ -0,0 +1,16 @@
++// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
++
++/dts-v1/;
++#include "mt7981b-qihoo-360-t7.dtsi"
++
++/ {
++	model = "Qihoo 360 T7 (modified U-Boot layout)";
++	compatible = "qihoo,360-t7-ubootmod", "mediatek,mt7981";
++};
++
++&partitions {
++	partition@580000 {
++		label = "ubi";
++		reg = <0x580000 0x6c00000>;
++	};
++};
+diff --git a/target/linux/mediatek/dts/mt7981b-qihoo-360-t7.dtsi b/target/linux/mediatek/dts/mt7981b-qihoo-360-t7.dtsi
+new file mode 100644
+index 00000000000..387712ec330
+--- /dev/null
++++ b/target/linux/mediatek/dts/mt7981b-qihoo-360-t7.dtsi
+@@ -0,0 +1,242 @@
++// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
++
++/dts-v1/;
++#include "mt7981.dtsi"
++
++/ {
++	aliases {
++		led-boot = &red_led;
++		led-failsafe = &red_led;
++		led-running = &green_led;
++		led-upgrade = &green_led;
++		serial0 = &uart0;
++	};
++
++	chosen {
++		stdout-path = "serial0:115200n8";
++	};
++
++	gpio-keys {
++		compatible = "gpio-keys";
++
++		button-reset {
++			label = "reset";
++			linux,code = <KEY_RESTART>;
++			gpios = <&pio 1 GPIO_ACTIVE_LOW>;
++		};
++
++		button-wps {
++			label = "wps";
++			linux,code = <KEY_WPS_BUTTON>;
++			gpios = <&pio 0 GPIO_ACTIVE_LOW>;
++		};
++	};
++
++	gpio-leds {
++		compatible = "gpio-leds";
++
++		red_led: led-0 {
++			label = "red:system";
++			gpios = <&pio 3 GPIO_ACTIVE_LOW>;
++		};
++
++		green_led: led-1 {
++			label = "green:system";
++			gpios = <&pio 7 GPIO_ACTIVE_LOW>;
++		};
++	};
++};
++
++&uart0 {
++	status = "okay";
++};
++
++&watchdog {
++	status = "okay";
++};
++
++&eth {
++	pinctrl-names = "default";
++	pinctrl-0 = <&mdio_pins>;
++
++	status = "okay";
++
++	gmac0: mac@0 {
++		compatible = "mediatek,eth-mac";
++		reg = <0>;
++		phy-mode = "2500base-x";
++
++		nvmem-cells = <&macaddr_factory_14>;
++		nvmem-cell-names = "mac-address-ascii";
++
++		fixed-link {
++			speed = <2500>;
++			full-duplex;
++			pause;
++		};
++	};
++};
++
++&mdio_bus {
++	switch0: switch@0 {
++		compatible = "mediatek,mt7531";
++		reg = <31>;
++		dsa,member = <0 0>;
++		reset-gpios = <&pio 39 GPIO_ACTIVE_HIGH>;
++		interrupt-controller;
++		#interrupt-cells = <1>;
++		interrupt-parent = <&pio>;
++		interrupts = <38 IRQ_TYPE_LEVEL_HIGH>;
++	};
++};
++
++&switch0 {
++	ports {
++		#address-cells = <1>;
++		#size-cells = <0>;
++
++		port@0 {
++			reg = <0>;
++			label = "lan1";
++		};
++
++		port@1 {
++			reg = <1>;
++			label = "lan2";
++		};
++
++		port@2 {
++			reg = <2>;
++			label = "lan3";
++		};
++
++		port@3 {
++			reg = <3>;
++			label = "wan";
++
++			nvmem-cells = <&macaddr_factory_14>;
++			nvmem-cell-names = "mac-address-ascii";
++			mac-address-increment = <1>;
++		};
++
++		port@6 {
++			reg = <6>;
++			ethernet = <&gmac0>;
++			phy-mode = "2500base-x";
++
++			fixed-link {
++				speed = <2500>;
++				full-duplex;
++				pause;
++			};
++		};
++	};
++};
++
++&spi0 {
++	pinctrl-names = "default";
++	pinctrl-0 = <&spi0_flash_pins>;
++	status = "okay";
++
++	spi_nand: flash@0 {
++		#address-cells = <1>;
++		#size-cells = <1>;
++		compatible = "spi-nand";
++		reg = <0>;
++		spi-max-frequency = <52000000>;
++
++		spi-cal-enable;
++		spi-cal-mode = "read-data";
++		spi-cal-datalen = <7>;
++		spi-cal-data = /bits/ 8 <0x53 0x50 0x49 0x4E 0x41 0x4E 0x44>;
++		spi-cal-addrlen = <5>;
++		spi-cal-addr = /bits/ 32 <0x0 0x0 0x0 0x0 0x0>;
++
++		spi-tx-buswidth = <4>;
++		spi-rx-buswidth = <4>;
++		mediatek,nmbm;
++		mediatek,bmt-max-ratio = <1>;
++		mediatek,bmt-max-reserved-blocks = <64>;
++
++		partitions: partitions {
++			compatible = "fixed-partitions";
++			#address-cells = <1>;
++			#size-cells = <1>;
++
++			partition@0 {
++				label = "BL2";
++				reg = <0x00 0x100000>;
++			};
++
++			partition@100000 {
++				label = "u-boot-env";
++				reg = <0x100000 0x80000>;
++			};
++
++			factory: partition@180000 {
++				label = "Factory";
++				reg = <0x180000 0x200000>;
++			};
++
++			partition@380000 {
++				label = "FIP";
++				reg = <0x380000 0x200000>;
++			};
++
++			partition@7180000 {
++				label = "stock-config";
++				reg = <0x7180000 0x100000>;
++			};
++
++			partition@7280000 {
++				label = "stock-factory";
++				reg = <0x7280000 0x80000>;
++
++				compatible = "nvmem-cells";
++				#address-cells = <1>;
++				#size-cells = <1>;
++
++				macaddr_factory_14: macaddr@14 {
++					reg = <0x14 0x11>;
++				};
++
++			};
++
++			partition@7300000 {
++				label = "stock-log";
++				reg = <0x7300000 0x400000>;
++			};
++		};
++	};
++};
++
++&pio {
++	spi0_flash_pins: spi0-pins {
++		mux {
++			function = "spi";
++			groups = "spi0", "spi0_wp_hold";
++		};
++
++		conf-pu {
++			pins = "SPI0_CS", "SPI0_HOLD", "SPI0_WP";
++			drive-strength = <MTK_DRIVE_8mA>;
++			bias-pull-up = <MTK_PUPD_SET_R1R0_11>;
++		};
++
++		conf-pd {
++			pins = "SPI0_CLK", "SPI0_MOSI", "SPI0_MISO";
++			drive-strength = <MTK_DRIVE_8mA>;
++			bias-pull-down = <MTK_PUPD_SET_R1R0_11>;
++		};
++	};
++};
++
++&wifi {
++	mediatek,mtd-eeprom = <&factory 0x0>;
++
++	nvmem-cells = <&macaddr_factory_14>;
++	nvmem-cell-names = "mac-address-ascii";
++	mac-address-increment = <2>;
++
++	status = "okay";
++};
+diff --git a/target/linux/mediatek/filogic/base-files/etc/board.d/02_network b/target/linux/mediatek/filogic/base-files/etc/board.d/02_network
+index 2fca00921b8ca..983aa9a83aa86 100644
+--- a/target/linux/mediatek/filogic/base-files/etc/board.d/02_network
++++ b/target/linux/mediatek/filogic/base-files/etc/board.d/02_network
+@@ -36,6 +36,10 @@ mediatek_setup_interfaces()
+ 	tplink,tl-xdr6086)
+ 		ucidef_set_interfaces_lan_wan "lan1 lan2" eth1
+ 		;;
++	qihoo,360-t7-stock|\
++	qihoo,360-t7-ubootmod)
++ 		ucidef_set_interfaces_lan_wan "lan1 lan2 lan3" wan
++ 		;;
+ 	xiaomi,redmi-router-ax6000-stock|\
+ 	xiaomi,redmi-router-ax6000-ubootmod)
+ 		ucidef_set_interfaces_lan_wan "lan2 lan3 lan4" wan
+diff --git a/target/linux/mediatek/filogic/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac b/target/linux/mediatek/filogic/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac
+index 29edea9c502..32853dcef4a 100644
+--- a/target/linux/mediatek/filogic/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac
++++ b/target/linux/mediatek/filogic/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac
+@@ -28,6 +28,11 @@ case "$board" in
+ 		addr=$(mtd_get_mac_ascii config2 wifi5gmac)
+ 		[ "$PHYNBR" = "1" ] && echo $macaddr > /sys${DEVPATH}/macaddress
+ 		;;
++	qihoo,360-t7-stock|\
++	qihoo,360-t7-ubootmod)
++		addr=$(macaddr_add $(cat /sys/class/net/eth0/address) 2)
++		[ "$PHYNBR" = "1" ] && macaddr_setbit $addr 6 > /sys${DEVPATH}/macaddress
++		;;
+ 	tplink,tl-xdr4288|\
+ 	tplink,tl-xdr6086|\
+ 	tplink,tl-xdr6088)
+diff --git a/target/linux/mediatek/image/filogic.mk b/target/linux/mediatek/image/filogic.mk
+index 16c9ea2c130..d6fcb395dd9 100644
+--- a/target/linux/mediatek/image/filogic.mk
++++ b/target/linux/mediatek/image/filogic.mk
+@@ -162,6 +162,38 @@ define Device/mediatek_mt7986b-rfb
+ endef
+ TARGET_DEVICES += mediatek_mt7986b-rfb
+ 
++define Device/qihoo_360-t7-common
++  DEVICE_VENDOR := Qihoo
++  DEVICE_DTS_DIR := ../dts
++  DEVICE_PACKAGES := kmod-mt7981-firmware mt7981-wo-firmware
++  UBINIZE_OPTS := -E 5
++  BLOCKSIZE := 128k
++  PAGESIZE := 2048
++  IMAGE_SIZE := 65536k
++  KERNEL_IN_UBI := 1
++  IMAGES += factory.bin
++  IMAGE/factory.bin := append-ubi | check-size $$$$(IMAGE_SIZE)
++  IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
++  KERNEL = kernel-bin | lzma | \
++	fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb
++  KERNEL_INITRAMFS = kernel-bin | lzma | \
++	fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb with-initrd
++endef
++
++define Device/qihoo_360-t7-stock
++  DEVICE_MODEL := 360 T7 (stock layout)
++  DEVICE_DTS := mt7981b-qihoo-360-t7-stock
++  $(call Device/qihoo_360-t7-common)
++endef
++TARGET_DEVICES += qihoo_360-t7-stock
++
++define Device/qihoo_360-t7-ubootmod
++  DEVICE_MODEL := 360 T7 (modified U-Boot layout)
++  DEVICE_DTS := mt7981b-qihoo-360-t7-ubootmod
++  $(call Device/qihoo_360-t7-common)
++endef
++TARGET_DEVICES += qihoo_360-t7-ubootmod
++
+ define Device/tplink_tl-xdr-common
+   DEVICE_VENDOR := TP-Link
+   DEVICE_DTS_DIR := ../dts

+ 1 - 1
devices/mediatek_mt7622/diy.sh

@@ -3,7 +3,7 @@
 shopt -s extglob
 
 SHELL_FOLDER=$(dirname $(readlink -f "$0"))
-#bash $SHELL_FOLDER/../common/kernel_5.15.sh
+
 
 #curl -sfL https://raw.githubusercontent.com/x-wrt/x-wrt/master/target/linux/mediatek/patches-5.15/995-0001-hwnat-add-natflow-flow-offload-support.patch -o target/linux/mediatek/patches-5.15/995-0001-hwnat-add-natflow-flow-offload-support.patch
 

+ 0 - 4
devices/mediatek_mt7981/.config

@@ -3,7 +3,6 @@ CONFIG_TARGET_mediatek=y
 CONFIG_TARGET_mediatek_mt7981=y
 CONFIG_TARGET_MULTI_PROFILE=y
 CONFIG_TARGET_DEVICE_mediatek_mt7981_DEVICE_glinet_gl-mt2500=y
-CONFIG_TARGET_DEVICE_mediatek_mt7981_DEVICE_glinet_gl-mt3000=y
 CONFIG_TARGET_DEVICE_mediatek_mt7981_DEVICE_glinet_gl-x3000=y
 CONFIG_TARGET_DEVICE_mediatek_mt7981_DEVICE_glinet_gl-xe3000=y
 CONFIG_TARGET_DEVICE_mediatek_mt7981_DEVICE_mt7981-360-t7-108M=y
@@ -30,9 +29,6 @@ CONFIG_PACKAGE_kmod-sched-mqprio=n
 
 CONFIG_PACKAGE_kmod-i40e-vendor=n
 
-CONFIG_PACKAGE_kmod-mdio-netlink=n
-CONFIG_PACKAGE_kmod-jool-netfilter=n
-
 CONFIG_MTK_ACK_CTS_TIMEOUT_SUPPORT=y
 CONFIG_MTK_AIR_MONITOR=y
 CONFIG_MTK_AMPDU_CONF_SUPPORT=y

+ 5 - 10
devices/mediatek_mt7981/diy.sh

@@ -4,20 +4,15 @@ shopt -s extglob
 
 SHELL_FOLDER=$(dirname $(readlink -f "$0"))
 
-sed -i '/postgres=5432/d' feeds/packages.index
-sed -i '/postgres=5432/d' feeds/packages/net/gnunet/Makefile
-./scripts/feeds install -a
-
-sed -i "s/make-ext4fs missing-macros/make-ext4fs meson missing-macros/" tools/Makefile
-curl -sfL https://raw.githubusercontent.com/openwrt/openwrt/openwrt-22.03/include/meson.mk -o include/meson.mk
-svn co https://github.com/openwrt/openwrt/branches/openwrt-22.03/tools/meson tools/meson
-
 rm -rf package/feeds/kiddin9/rtl*
 
 rm -rf devices/common/patches/{fix.patch,iptables.patch,kernel-defaults.patch,targets.patch}
 
 sed -i "s/PKG_SOURCE_DATE:=.*/PKG_SOURCE_DATE:=2024-12-06/" package/network/config/netifd/Makefile
 
-rm -rf toolchain/musl
+rm -rf toolchain/musl package/utils/e2fsprogs package/libs/libselinux package/feeds/packages/acl
 
-svn co https://github.com/openwrt/openwrt/branches/openwrt-22.03/toolchain/musl toolchain/musl
+svn co https://github.com/openwrt/openwrt/branches/openwrt-23.05/toolchain/musl toolchain/musl
+svn co https://github.com/openwrt/openwrt/branches/openwrt-23.05/package/utils/e2fsprogs package/utils/e2fsprogs
+svn co https://github.com/openwrt/openwrt/branches/openwrt-23.05/package/libs/libselinux package/libs/libselinux
+ln -sf $(pwd)/feeds/luci/modules/luci-base package/feeds/kiddin9/

+ 3 - 3
devices/mediatek_mt7981/feeds.conf

@@ -1,4 +1,4 @@
-src-git packages https://git.openwrt.org/feed/packages.git;openwrt-22.03
-src-git luci https://git.openwrt.org/project/luci.git;openwrt-22.03
-src-git routing https://git.openwrt.org/feed/routing.git;openwrt-22.03
+src-git packages https://git.openwrt.org/feed/packages.git;openwrt-21.02
+src-git luci https://github.com/openwrt/luci.git;openwrt-22.03
+src-git routing https://git.openwrt.org/feed/routing.git;openwrt-21.02
 src-git kiddin9 https://github.com/kiddin9/openwrt-packages.git;master

+ 0 - 3
devices/mediatek_mt7986/.config

@@ -27,9 +27,6 @@ CONFIG_PACKAGE_kmod-sched-mqprio=n
 
 CONFIG_PACKAGE_kmod-i40e-vendor=n
 
-CONFIG_PACKAGE_kmod-mdio-netlink=n
-CONFIG_PACKAGE_kmod-jool-netfilter=n
-
 CONFIG_MTK_ACK_CTS_TIMEOUT_SUPPORT=y
 CONFIG_MTK_AIR_MONITOR=y
 CONFIG_MTK_AMPDU_CONF_SUPPORT=y

+ 5 - 10
devices/mediatek_mt7986/diy.sh

@@ -4,20 +4,15 @@ shopt -s extglob
 
 SHELL_FOLDER=$(dirname $(readlink -f "$0"))
 
-sed -i '/postgres=5432/d' feeds/packages.index
-sed -i '/postgres=5432/d' feeds/packages/net/gnunet/Makefile
-./scripts/feeds install -a
-
-sed -i "s/make-ext4fs missing-macros/make-ext4fs meson missing-macros/" tools/Makefile
-curl -sfL https://raw.githubusercontent.com/openwrt/openwrt/openwrt-22.03/include/meson.mk -o include/meson.mk
-svn co https://github.com/openwrt/openwrt/branches/openwrt-22.03/tools/meson tools/meson
-
 rm -rf package/feeds/kiddin9/rtl*
 
 sed -i "s/PKG_SOURCE_DATE:=.*/PKG_SOURCE_DATE:=2024-12-06/" package/network/config/netifd/Makefile
 
 rm -rf devices/common/patches/{glinet,fix.patch,iptables.patch,kernel-defaults.patch,targets.patch}
 
-rm -rf toolchain/musl
+rm -rf toolchain/musl package/utils/e2fsprogs package/libs/libselinux package/feeds/packages/acl
 
-svn co https://github.com/openwrt/openwrt/branches/openwrt-22.03/toolchain/musl toolchain/musl
+svn co https://github.com/openwrt/openwrt/branches/openwrt-23.05/toolchain/musl toolchain/musl
+svn co https://github.com/openwrt/openwrt/branches/openwrt-23.05/package/utils/e2fsprogs package/utils/e2fsprogs
+svn co https://github.com/openwrt/openwrt/branches/openwrt-23.05/package/libs/libselinux package/libs/libselinux
+ln -sf $(pwd)/feeds/luci/modules/luci-base package/feeds/kiddin9/

+ 4 - 4
devices/mediatek_mt7986/feeds.conf

@@ -1,4 +1,4 @@
-src-git packages https://git.openwrt.org/feed/packages.git;openwrt-22.03
-src-git luci https://git.openwrt.org/project/luci.git;openwrt-22.03
-src-git routing https://git.openwrt.org/feed/routing.git;openwrt-22.03
-src-git kiddin9 https://github.com/kiddin9/openwrt-packages.git;master
+src-git packages https://git.openwrt.org/feed/packages.git;openwrt-21.02
+src-git luci https://github.com/openwrt/luci.git;openwrt-22.03
+src-git routing https://git.openwrt.org/feed/routing.git;openwrt-21.02
+src-git kiddin9 https://github.com/kiddin9/openwrt-packages.git;master

+ 72 - 2548
devices/ramips_mt7620/patches/hiwifi_r33.patch

@@ -1,37 +1,34 @@
-From 1077f225d9906c04dd56b93e63900701beb92483 Mon Sep 17 00:00:00 2001
+From 72f3df2ae3d841447cba8188d48b90d91325b284 Mon Sep 17 00:00:00 2001
 From: zfdx123 <[email protected]>
-Date: Thu, 26 Jan 2023 09:42:50 +0800
+Date: Thu, 26 Jan 2023 12:49:13 +0800
 Subject: [PATCH] ramips: MT7620 add Support HiWiFi R33(C312B B52)
 
 ---
- .../generic/files/drivers/net/phy/rtl8367b.c  |   11 +
- .../linux/ramips/dts/mt7620a_hiwifi_r33.dts   |  235 ++
- target/linux/ramips/image/mt7620.mk           |   21 +
- .../mt7620/base-files/etc/board.d/01_leds     |    3 +
- .../mt7620/base-files/etc/board.d/02_network  |   13 +
- .../etc/hotplug.d/ieee80211/10_fix_wifi_mac   |    7 +
- .../mt7620/base-files/lib/upgrade/platform.sh |    3 +
- target/linux/ramips/mt7620/config-5.10        |   21 +
- target/linux/ramips/mt7620/target.mk          |    2 +-
- ...38-mtd-ralink-add-mt7620-nand-driver.patch | 2373 +++++++++++++++++
- 10 files changed, 2688 insertions(+), 1 deletion(-)
+ .../generic/files/drivers/net/phy/rtl8367b.c  |   9 +
+ .../linux/ramips/dts/mt7620a_hiwifi_r33.dts   | 235 ++++++++++++++++++
+ target/linux/ramips/image/mt7620.mk           |  22 ++
+ .../mt7620/base-files/etc/board.d/01_leds     |   3 +
+ .../mt7620/base-files/etc/board.d/02_network  |  13 +
+ .../etc/hotplug.d/ieee80211/10_fix_wifi_mac   |  33 +++
+ .../mt7620/base-files/lib/upgrade/platform.sh |   3 +
+ 7 files changed, 318 insertions(+)
  create mode 100644 target/linux/ramips/dts/mt7620a_hiwifi_r33.dts
- create mode 100644 target/linux/ramips/patches-5.10/0038-mtd-ralink-add-mt7620-nand-driver.patch
+ create mode 100644 target/linux/ramips/mt7620/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac
 
 diff --git a/target/linux/generic/files/drivers/net/phy/rtl8367b.c b/target/linux/generic/files/drivers/net/phy/rtl8367b.c
-index 3599791a517bb..942cbd73b7205 100644
+index 3599791a517b..6297e07628ba 100644
 --- a/target/linux/generic/files/drivers/net/phy/rtl8367b.c
 +++ b/target/linux/generic/files/drivers/net/phy/rtl8367b.c
-@@ -266,6 +266,8 @@ struct rtl8367b_initval {
- #define RTL8367B_MIB_RXB_ID		0	/* IfInOctets */
- #define RTL8367B_MIB_TXB_ID		28	/* IfOutOctets */
+@@ -263,6 +263,8 @@ struct rtl8367b_initval {
+ 	u16 val;
+ };
  
 +u32 rtl_device_id;
 +
- static struct rtl8366_mib_counter
- rtl8367b_mib_counters[RTL8367B_NUM_MIB_COUNTERS] = {
- 	{0,   0, 4, "ifInOctets"			},
-@@ -612,8 +614,14 @@ static int rtl8367b_write_initvals(struct rtl8366_smi *smi,
+ #define RTL8367B_MIB_RXB_ID		0	/* IfInOctets */
+ #define RTL8367B_MIB_TXB_ID		28	/* IfOutOctets */
+ 
+@@ -612,6 +614,10 @@ static int rtl8367b_write_initvals(struct rtl8366_smi *smi,
  	int err;
  	int i;
  
@@ -40,13 +37,9 @@ index 3599791a517bb..942cbd73b7205 100644
 +	}
 +
  	for (i = 0; i < count; i++)
-+	{
  		REG_WR(smi, initvals[i].reg, initvals[i].val);
-+	}
  
- 	return 0;
- }
-@@ -1540,7 +1548,10 @@ static int rtl8367b_detect(struct rtl8366_smi *smi)
+@@ -1540,7 +1546,10 @@ static int rtl8367b_detect(struct rtl8366_smi *smi)
  		return ret;
  	}
  
@@ -59,10 +52,10 @@ index 3599791a517bb..942cbd73b7205 100644
  		break;
 diff --git a/target/linux/ramips/dts/mt7620a_hiwifi_r33.dts b/target/linux/ramips/dts/mt7620a_hiwifi_r33.dts
 new file mode 100644
-index 0000000000000..09f5a84b773c5
+index 000000000000..6761b1b68a06
 --- /dev/null
 +++ b/target/linux/ramips/dts/mt7620a_hiwifi_r33.dts
-@@ -0,0 +1,235 @@
+@@ -0,0 +1,234 @@
 +#include "mt7620a.dtsi"
 +
 +#include <dt-bindings/gpio/gpio.h>
@@ -122,7 +115,7 @@ index 0000000000000..09f5a84b773c5
 +				reg = <0x540000 0x1c80000>;
 +			};
 +
-+			partition@21c0000 {
++			bdinfo: partition@21c0000 {
 +				label = "bdinfo";
 +				reg = <0x21c0000 0x80000>;
 +				read-only;
@@ -130,7 +123,7 @@ index 0000000000000..09f5a84b773c5
 +
 +			ubiconcat1: partition@2240000 {
 +				label = "ubiconcat1";
-+				reg = <0x2240000 0x5d40000>;
++				reg = <0x2240000 0x5dc0000>;
 +			};
 +		};
 +	};
@@ -146,7 +139,7 @@ index 0000000000000..09f5a84b773c5
 +
 +			partition@0 {
 +				label = "ubi";
-+				reg = <0x0 0x79c0000>;
++				reg = <0x0 0x7a40000>;
 +			};
 +		};
 +	};
@@ -162,12 +155,13 @@ index 0000000000000..09f5a84b773c5
 +
 +		led_system: system {
 +			label = "blue:system";
-+			gpios = <&gpio0 9 GPIO_ACTIVE_HIGH>;
++			gpios = <&gpio0 9 GPIO_ACTIVE_LOW>;
 +		};
 +
 +		turbo {
 +			label = "blue:turbo";
-+			gpios = <&gpio0 10 GPIO_ACTIVE_HIGH>;
++			gpios = <&gpio0 10 GPIO_ACTIVE_LOW>;
++			linux,default-trigger = "none";
 +		};
 +
 +		wlan2g {
@@ -211,13 +205,6 @@ index 0000000000000..09f5a84b773c5
 +	};
 +};
 +
-+//在最新的openwrt master分支中sysc已经被剔除,此处进行备份标记
-+// &sysc {
-+// 	ralink,gpiomux = "i2c", "jtag";
-+// 	ralink,uartmux = "gpio";
-+// 	ralink,wdtmux = <1>;
-+// };
-+
 +&gpio3 {
 +	status = "okay";
 +};
@@ -234,14 +221,17 @@ index 0000000000000..09f5a84b773c5
 +	status = "okay";
 +};
 +
++&gsw {
++	mediatek,port4-gmac;
++	mediatek,ephy-base = /bits/ 8 <12>;
++};
++
 +&ethernet {
 +	pinctrl-names = "default";
 +	pinctrl-0 = <&rgmii1_pins &rgmii2_pins &mdio_pins>;
 +
-+	//mtd-mac-address = <&factory 0x4>;
-+
-+	nvmem-cells = <&macaddr_factory_4>;
-+	nvmem-cell-names = "mac-address";
++	nvmem-cells = <&macaddr_bdinfo_18a>;
++	nvmem-cell-names = "mac-address-ascii";
 +
 +	port@5 {
 +		status = "okay";
@@ -260,26 +250,28 @@ index 0000000000000..09f5a84b773c5
 +	};
 +};
 +
-+//5G WIFI
++&wmac {
++	pinctrl-names = "default", "pa_gpio";
++	pinctrl-0 = <&pa_pins>;
++	pinctrl-1 = <&pa_gpio_pins>;
++	ralink,mtd-eeprom = <&factory 0x0>;
++
++	nvmem-cells = <&macaddr_bdinfo_18a>;
++	nvmem-cell-names = "mac-address-ascii";
++	mac-address-increment = <1>;
++};
++
 +&pcie0 {
 +	wifi@0,0 {
 +		compatible = "pci14c3,7662";
 +		reg = <0x0000 0 0 0 0>;
 +		mediatek,mtd-eeprom = <&factory 0x8000>;
 +		ieee80211-freq-limit = <5000000 6000000>;
-+		// nvmem-cells = <&macaddr_factory_4>;
-+		// nvmem-cell-names = "mac-address";
-+		// mac-address-increment = <2>;
-+	};
-+};
 +
-+//2.4G WIFI
-+&wmac {
-+	pinctrl-names = "default";
-+	pinctrl-0 = <&pa_pins>;
-+	ralink,mtd-eeprom = <&factory 0x0>;
-+	// nvmem-cells = <&macaddr_factory_4>;
-+	// nvmem-cell-names = "mac-address";
++		nvmem-cells = <&macaddr_bdinfo_18a>;
++		nvmem-cell-names = "mac-address-ascii";
++		mac-address-increment = <2>;
++	};
 +};
 +
 +&state_default {
@@ -289,28 +281,29 @@ index 0000000000000..09f5a84b773c5
 +	};
 +};
 +
-+&factory {
-+	compatible = "nvmem-cells";
-+	#address-cells = <1>;
-+	#size-cells = <1>;
++&bdinfo {
++        compatible = "nvmem-cells";
++        #address-cells = <1>;
++        #size-cells = <1>;
 +
-+	macaddr_factory_4: macaddr@4 {
-+		reg = <0x4 0x6>;
-+	};
++        macaddr_bdinfo_18a: macaddr@18a {
++                reg = <0x18a 0x11>;
++        };
 +};
 diff --git a/target/linux/ramips/image/mt7620.mk b/target/linux/ramips/image/mt7620.mk
-index 445d3dec34238..c90b8d1f93d02 100644
+index 631e5043f411..c68b9a69c60d 100644
 --- a/target/linux/ramips/image/mt7620.mk
 +++ b/target/linux/ramips/image/mt7620.mk
-@@ -1495,3 +1495,24 @@ define Device/zyxel_keenetic-viva
+@@ -1338,3 +1338,25 @@ define Device/zyxel_keenetic-viva
    SUPPORTED_DEVICES += kng_rc
  endef
  TARGET_DEVICES += zyxel_keenetic-viva
 +
++
 +define Device/hiwifi_r33
 +  SOC := mt7620a
 +  DEVICE_VENDOR := HiWiFi
-+  DEVICE_MODEL := R33 / 3Pro
++  DEVICE_MODEL := R33
 +  DEVICE_PACKAGES := kmod-usb2 kmod-usb-ohci kmod-usb-ledtrig-usbport \
 +	kmod-switch-rtl8366-smi kmod-switch-rtl8367b kmod-mt76x2
 +  BLOCKSIZE := 128k
@@ -327,25 +320,26 @@ index 445d3dec34238..c90b8d1f93d02 100644
 +  SUPPORTED_DEVICES += r33
 +endef
 +TARGET_DEVICES += hiwifi_r33
+\ No newline at end of file
 diff --git a/target/linux/ramips/mt7620/base-files/etc/board.d/01_leds b/target/linux/ramips/mt7620/base-files/etc/board.d/01_leds
-index 36e3045a38a82..5e221159eb80a 100644
+index 53487d752688..1240b0efdae4 100644
 --- a/target/linux/ramips/mt7620/base-files/etc/board.d/01_leds
 +++ b/target/linux/ramips/mt7620/base-files/etc/board.d/01_leds
-@@ -126,6 +126,9 @@ hiwifi,hc5761)
+@@ -112,6 +112,9 @@ hiwifi,hc5761)
  hiwifi,hc5861)
  	ucidef_set_led_switch "internet" "internet" "blue:internet" "switch0" "0x20"
  	;;
 +hiwifi,r33)
-+	ucidef_set_led_netdev "internet" "internet" "blue:internet" "eth0.2" "link tx rx"
++	ucidef_set_led_switch "internet" "internet" "blue:internet" "switch1" "0x01"
 +	;;
  hnet,c108)
  	ucidef_set_led_netdev "lan" "lan" "green:lan" "eth0"
  	ucidef_set_led_netdev "modem" "modem" "green:modem" "wwan0"
 diff --git a/target/linux/ramips/mt7620/base-files/etc/board.d/02_network b/target/linux/ramips/mt7620/base-files/etc/board.d/02_network
-index 424e3709969a1..cbba6c2029366 100644
+index 00ffb1b5420c..5f4e7268e8a9 100644
 --- a/target/linux/ramips/mt7620/base-files/etc/board.d/02_network
 +++ b/target/linux/ramips/mt7620/base-files/etc/board.d/02_network
-@@ -175,6 +175,13 @@ ramips_setup_interfaces()
+@@ -156,6 +156,13 @@ ramips_setup_interfaces()
  		ucidef_add_switch "switch0" \
  			"0:lan" "1:lan" "5:wan" "6@eth0"
  		;;
@@ -359,7 +353,7 @@ index 424e3709969a1..cbba6c2029366 100644
  	iodata,wn-ac1167gr|\
  	iodata,wn-ac733gr3|\
  	iptime,a1004ns)
-@@ -350,6 +357,12 @@ ramips_setup_macs()
+@@ -336,6 +343,12 @@ ramips_setup_macs()
  		[ -n "$lan_mac" ] || lan_mac=$(cat /sys/class/net/eth0/address)
  		wan_mac=$(macaddr_add "$lan_mac" 1)
  		;;
@@ -389,12 +383,12 @@ index aa0ad99158271..c7b818a0af7c0 100644
 +		;;
  esac
 diff --git a/target/linux/ramips/mt7620/base-files/lib/upgrade/platform.sh b/target/linux/ramips/mt7620/base-files/lib/upgrade/platform.sh
-index 9f71dc918e50a..9c1aa42326e82 100755
+index 40272d4a744d..e4f83fd8ccb5 100755
 --- a/target/linux/ramips/mt7620/base-files/lib/upgrade/platform.sh
 +++ b/target/linux/ramips/mt7620/base-files/lib/upgrade/platform.sh
-@@ -30,6 +30,9 @@ platform_do_upgrade() {
- 		}
- 		default_do_upgrade "$1"
+@@ -35,6 +35,9 @@ platform_do_upgrade() {
+ 		dd if=/dev/mtd0 bs=64 count=1 2>/dev/null | grep -qi breed && CI_KERNPART_EXT="kernel_stock"
+ 		nand_do_upgrade "$1"
  		;;
 +	hiwifi,r33)
 +		nand_do_upgrade "$1"
@@ -402,2473 +396,3 @@ index 9f71dc918e50a..9c1aa42326e82 100755
  	*)
  		default_do_upgrade "$1"
  		;;
-diff --git a/target/linux/ramips/mt7620/config-5.10 b/target/linux/ramips/mt7620/config-5.10
-index 135c1689e164d..c2c06b9996b45 100644
---- a/target/linux/ramips/mt7620/config-5.10
-+++ b/target/linux/ramips/mt7620/config-5.10
-@@ -32,7 +32,13 @@ CONFIG_CPU_SUPPORTS_HIGHMEM=y
- CONFIG_CPU_SUPPORTS_MSA=y
- CONFIG_CRYPTO_BLAKE2S=y
- CONFIG_CRYPTO_LIB_BLAKE2S_GENERIC=y
-+CONFIG_CRC16=y
-+CONFIG_CRYPTO_DEFLATE=y
-+CONFIG_CRYPTO_GF128MUL=y
-+CONFIG_CRYPTO_HASH_INFO=y
- CONFIG_CRYPTO_LIB_POLY1305_RSIZE=2
-+CONFIG_CRYPTO_LZO=y
-+CONFIG_CRYPTO_NULL2=y
- CONFIG_CRYPTO_RNG2=y
- CONFIG_CSRC_R4K=y
- CONFIG_DEBUG_PINCTRL=y
-@@ -88,9 +94,12 @@ CONFIG_IRQ_WORK=y
- # CONFIG_KERNEL_ZSTD is not set
- CONFIG_LIBFDT=y
- CONFIG_LOCK_DEBUGGING_SUPPORT=y
-+CONFIG_LZO_COMPRESS=y
-+CONFIG_LZO_DECOMPRESS=y
- CONFIG_MARVELL_PHY=y
- CONFIG_MDIO_BUS=y
- CONFIG_MDIO_DEVICE=y
-+CONFIG_MDIO_DEVRES=y
- CONFIG_MEMFD_CREATE=y
- CONFIG_MFD_SYSCON=y
- CONFIG_MIGRATION=y
-@@ -103,6 +112,7 @@ CONFIG_MIPS_CLOCK_VSYSCALL=y
- # CONFIG_MIPS_CMDLINE_DTB_EXTEND is not set
- # CONFIG_MIPS_CMDLINE_FROM_BOOTLOADER is not set
- CONFIG_MIPS_CMDLINE_FROM_DTB=y
-+CONFIG_MIPS_EBPF_JIT=y
- # CONFIG_MIPS_ELF_APPENDED_DTB is not set
- CONFIG_MIPS_L1_CACHE_SHIFT=5
- CONFIG_MIPS_LD_CAN_LINK_VDSO=y
-@@ -113,6 +123,7 @@ CONFIG_MODULES_USE_ELF_REL=y
- # CONFIG_MT7621_WDT is not set
- # CONFIG_MTD_CFI_INTELEXT is not set
- CONFIG_MTD_CMDLINE_PARTS=y
-+CONFIG_MTD_NAND_MT7620=y
- # CONFIG_MTD_PARSER_TPLINK_SAFELOADER is not set
- CONFIG_MTD_PHYSMAP=y
- CONFIG_MTD_SPI_NOR=y
-@@ -122,6 +133,10 @@ CONFIG_MTD_SPLIT_JIMAGE_FW=y
- CONFIG_MTD_SPLIT_SEAMA_FW=y
- CONFIG_MTD_SPLIT_TPLINK_FW=y
- CONFIG_MTD_SPLIT_UIMAGE_FW=y
-+CONFIG_MTD_UBI=y
-+CONFIG_MTD_UBI_BEB_LIMIT=20
-+CONFIG_MTD_UBI_BLOCK=y
-+CONFIG_MTD_UBI_WL_THRESHOLD=4096
- CONFIG_MTD_VIRT_CONCAT=y
- CONFIG_NEED_DMA_MAP_STATE=y
- CONFIG_NEED_PER_CPU_KM=y
-@@ -165,6 +180,7 @@ CONFIG_RESET_CONTROLLER=y
- CONFIG_SERIAL_8250_RT288X=y
- CONFIG_SERIAL_MCTRL_GPIO=y
- CONFIG_SERIAL_OF_PLATFORM=y
-+CONFIG_SGL_ALLOC=y
- CONFIG_SOC_MT7620=y
- # CONFIG_SOC_MT7621 is not set
- # CONFIG_SOC_RT288X is not set
-@@ -193,6 +209,11 @@ CONFIG_TICK_CPU_ACCOUNTING=y
- CONFIG_TIMER_OF=y
- CONFIG_TIMER_PROBE=y
- CONFIG_TINY_SRCU=y
-+CONFIG_UBIFS_FS=y
-+CONFIG_UBIFS_FS_ADVANCED_COMPR=y
-+# CONFIG_UBIFS_FS_ZSTD is not set
- CONFIG_USB_SUPPORT=y
- CONFIG_USE_OF=y
- CONFIG_WATCHDOG_CORE=y
-+CONFIG_ZLIB_DEFLATE=y
-+CONFIG_ZLIB_INFLATE=y
-diff --git a/target/linux/ramips/mt7620/target.mk b/target/linux/ramips/mt7620/target.mk
-index 5fc61e49cf8f3..ce992fc208b68 100644
---- a/target/linux/ramips/mt7620/target.mk
-+++ b/target/linux/ramips/mt7620/target.mk
-@@ -4,7 +4,7 @@
- 
- SUBTARGET:=mt7620
- BOARDNAME:=MT7620 based boards
--FEATURES+=usb ramdisk
-+FEATURES+=usb nand ramdisk
- CPU_TYPE:=24kc
- 
- DEFAULT_PACKAGES += kmod-rt2800-soc wpad-basic-wolfssl swconfig
-diff --git a/target/linux/ramips/patches-5.10/0038-mtd-ralink-add-mt7620-nand-driver.patch b/target/linux/ramips/patches-5.10/0038-mtd-ralink-add-mt7620-nand-driver.patch
-new file mode 100644
-index 0000000000000..b2d098b048319
---- /dev/null
-+++ b/target/linux/ramips/patches-5.10/0038-mtd-ralink-add-mt7620-nand-driver.patch
-@@ -0,0 +1,2373 @@
-+From afb07a5b467217af1df4162c707cbe554a79130d Mon Sep 17 00:00:00 2001
-+From: Chen Minqiang <[email protected]>
-+Date: Thu, 3 Sep 2020 03:27:48 +0800
-+Subject: [PATCH] mtd ralink add mt7620-nand driver
-+
-+---
-+ drivers/mtd/maps/Kconfig       |    4 +
-+ drivers/mtd/maps/Makefile      |    1 +
-+ drivers/mtd/maps/ralink_nand.c | 2095 ++++++++++++++++++++++++++++++++
-+ drivers/mtd/maps/ralink_nand.h |  240 ++++
-+ 4 files changed, 2340 insertions(+)
-+ create mode 100644 drivers/mtd/maps/ralink_nand.c
-+ create mode 100644 drivers/mtd/maps/ralink_nand.h
-+
-+--- a/drivers/mtd/maps/Kconfig
-++++ b/drivers/mtd/maps/Kconfig
-+@@ -423,4 +423,8 @@ config MTD_PISMO
-+ 
-+ 	  When built as a module, it will be called pismo.ko
-+ 
-++config MTD_NAND_MT7620
-++	tristate "Support for NAND on Mediatek MT7620"
-++	depends on RALINK && SOC_MT7620
-++
-+ endmenu
-+--- a/drivers/mtd/maps/Makefile
-++++ b/drivers/mtd/maps/Makefile
-+@@ -46,3 +46,4 @@ obj-$(CONFIG_MTD_INTEL_VR_NOR)	+= intel_
-+ obj-$(CONFIG_MTD_RBTX4939)	+= rbtx4939-flash.o
-+ obj-$(CONFIG_MTD_VMU)		+= vmu-flash.o
-+ obj-$(CONFIG_MTD_LANTIQ)	+= lantiq-flash.o
-++obj-$(CONFIG_MTD_NAND_MT7620)	+= ralink_nand.o
-+--- /dev/null
-++++ b/drivers/mtd/maps/ralink_nand.c
-+@@ -0,0 +1,2095 @@
-++#define DEBUG
-++#include <linux/device.h>
-++#undef DEBUG
-++#include <linux/slab.h>
-++#include <linux/mtd/mtd.h>
-++#include <linux/delay.h>
-++#include <linux/module.h>
-++#include <linux/interrupt.h>
-++#include <linux/dma-mapping.h>
-++#include <linux/mtd/partitions.h>
-++#include <asm/io.h>
-++#include <linux/delay.h>
-++#include <linux/sched.h>
-++#include <linux/of.h>
-++#include <linux/platform_device.h>
-++
-++#include "ralink_nand.h"
-++#ifdef RANDOM_GEN_BAD_BLOCK
-++#include <linux/random.h>
-++#endif
-++
-++#define LARGE_MTD_BOOT_PART_SIZE       (CFG_BLOCKSIZE<<2)
-++#define LARGE_MTD_CONFIG_PART_SIZE     (CFG_BLOCKSIZE<<2)
-++#define LARGE_MTD_FACTORY_PART_SIZE    (CFG_BLOCKSIZE<<1)
-++
-++#define BLOCK_ALIGNED(a) ((a) & (CFG_BLOCKSIZE - 1))
-++
-++#define READ_STATUS_RETRY	1000
-++
-++struct nand_ecclayout {
-++	__u32 eccbytes;
-++	__u32 eccpos[MTD_MAX_ECCPOS_ENTRIES_LARGE];
-++	__u32 oobavail;
-++	struct nand_oobfree oobfree[MTD_MAX_OOBFREE_ENTRIES_LARGE];
-++};
-++
-++struct mtd_info *ranfc_mtd = NULL;
-++
-++int skipbbt = 0;
-++int ranfc_debug = 1;
-++static int ranfc_bbt = 1;
-++#if defined (WORKAROUND_RX_BUF_OV)
-++static int ranfc_verify = 1;
-++#endif
-++static u32 nand_addrlen;
-++
-++#if 0
-++module_param(ranfc_debug, int, 0644);
-++module_param(ranfc_bbt, int, 0644);
-++module_param(ranfc_verify, int, 0644);
-++#endif
-++
-++#if 0
-++#define ra_dbg(args...) do { if (ranfc_debug) printk(args); } while(0)
-++#else
-++#define ra_dbg(args...)
-++#endif
-++
-++#define CLEAR_INT_STATUS()	ra_outl(NFC_INT_ST, ra_inl(NFC_INT_ST))
-++#define NFC_TRANS_DONE()	(ra_inl(NFC_INT_ST) & INT_ST_ND_DONE)
-++
-++int is_nand_page_2048 = 0;
-++const unsigned int nand_size_map[2][3] = {{25, 30, 30}, {20, 27, 30}};
-++
-++static int nfc_wait_ready(int snooze_ms);
-++
-++static const char * const mtk_probe_types[] = { "cmdlinepart", "ofpart", NULL };
-++
-++/**
-++ * reset nand chip
-++ */
-++static int nfc_chip_reset(void)
-++{
-++	int status;
-++
-++	//ra_dbg("%s:\n", __func__);
-++
-++	// reset nand flash
-++	ra_outl(NFC_CMD1, 0x0);
-++	ra_outl(NFC_CMD2, 0xff);
-++	ra_outl(NFC_ADDR, 0x0);
-++	ra_outl(NFC_CONF, 0x0411);
-++
-++	status = nfc_wait_ready(5);  //erase wait 5us
-++	if (status & NAND_STATUS_FAIL) {
-++		printk("%s: fail \n", __func__);
-++	}
-++
-++	return (int)(status & NAND_STATUS_FAIL);
-++}
-++
-++/**
-++ * clear NFC and flash chip.
-++ */
-++static int nfc_all_reset(void)
-++{
-++	int retry;
-++
-++	ra_dbg("%s: \n", __func__);
-++
-++	// reset controller
-++	ra_outl(NFC_CTRL, ra_inl(NFC_CTRL) | 0x02); //clear data buffer
-++	ra_outl(NFC_CTRL, ra_inl(NFC_CTRL) & ~0x02); //clear data buffer
-++
-++	CLEAR_INT_STATUS();
-++
-++	retry = READ_STATUS_RETRY;
-++	while ((ra_inl(NFC_INT_ST) & 0x02) != 0x02 && retry--);
-++	if (retry <= 0) {
-++		printk("nfc_all_reset: clean buffer fail \n");
-++		return -1;
-++	}
-++
-++	retry = READ_STATUS_RETRY;
-++	while ((ra_inl(NFC_STATUS) & 0x1) != 0x0 && retry--) { //fixme, controller is busy ?
-++		udelay(1);
-++	}
-++
-++	nfc_chip_reset();
-++
-++	return 0;
-++}
-++
-++/** NOTICE: only called by nfc_wait_ready().
-++ * @return -1, nfc can not get transction done
-++ * @return 0, ok.
-++ */
-++static int _nfc_read_status(char *status)
-++{
-++	unsigned long cmd1, conf;
-++	int int_st, nfc_st;
-++	int retry;
-++
-++	cmd1 = 0x70;
-++	conf = 0x000101 | (1 << 20);
-++
-++	//fixme, should we check nfc status?
-++	CLEAR_INT_STATUS();
-++
-++	ra_outl(NFC_CMD1, cmd1);
-++	ra_outl(NFC_CONF, conf);
-++
-++	/* FIXME,
-++	 * 1. since we have no wired ready signal, directly
-++	 * calling this function is not gurantee to read right status under ready state.
-++	 * 2. the other side, we can not determine how long to become ready, this timeout retry is nonsense.
-++	 * 3. SUGGESTION: call nfc_read_status() from nfc_wait_ready(),
-++	 * that is aware about caller (in sementics) and has snooze plused nfc ND_DONE.
-++	 */
-++	retry = READ_STATUS_RETRY;
-++	do {
-++		nfc_st = ra_inl(NFC_STATUS);
-++		int_st = ra_inl(NFC_INT_ST);
-++
-++		ndelay(10);
-++	} while (!(int_st & INT_ST_RX_BUF_RDY) && retry--);
-++
-++	if (!(int_st & INT_ST_RX_BUF_RDY)) {
-++		printk("nfc_read_status: NFC fail, int_st(%x), retry:%x. nfc:%x, reset nfc and flash. \n",
-++		       int_st, retry, nfc_st);
-++		nfc_all_reset();
-++		*status = NAND_STATUS_FAIL;
-++		return -1;
-++	}
-++
-++	*status = (char)(le32_to_cpu(ra_inl(NFC_DATA)) & 0x0ff);
-++	return 0;
-++}
-++
-++/**
-++ * @return !0, chip protect.
-++ * @return 0, chip not protected.
-++ */
-++static int nfc_check_wp(void)
-++{
-++	/* Check the WP bit */
-++#if !defined CONFIG_NOT_SUPPORT_WP
-++	return !!(ra_inl(NFC_CTRL) & 0x01);
-++#else
-++	char result = 0;
-++	int ret;
-++
-++	ret = _nfc_read_status(&result);
-++	//FIXME, if ret < 0
-++
-++	return !(result & NAND_STATUS_WP);
-++#endif
-++}
-++
-++#if !defined CONFIG_NOT_SUPPORT_RB
-++/*
-++ * @return !0, chip ready.
-++ * @return 0, chip busy.
-++ */
-++static int nfc_device_ready(void)
-++{
-++	/* Check the ready  */
-++	return !!(ra_inl(NFC_STATUS) & 0x04);
-++}
-++#endif
-++
-++/**
-++ * generic function to get data from flash.
-++ * @return data length reading from flash.
-++ */
-++static int _ra_nand_pull_data(char *buf, int len, int use_gdma)
-++{
-++#ifdef RW_DATA_BY_BYTE
-++	char *p = buf;
-++#else
-++	__u32 *p = (__u32 *)buf;
-++#endif
-++	int retry, int_st;
-++	unsigned int ret_data;
-++	int ret_size;
-++
-++	// receive data by use_gdma
-++	if (use_gdma) {
-++		//if (_ra_nand_dma_pull((unsigned long)p, len)) {
-++		if (1) {
-++			printk("%s: fail \n", __func__);
-++			len = -1; //return error
-++		}
-++
-++		return len;
-++	}
-++
-++	//fixme: retry count size?
-++	retry = READ_STATUS_RETRY;
-++	// no gdma
-++	while (len > 0) {
-++		int_st = ra_inl(NFC_INT_ST);
-++		if (int_st & INT_ST_RX_BUF_RDY) {
-++
-++			ret_data = ra_inl(NFC_DATA);
-++			ra_outl(NFC_INT_ST, INT_ST_RX_BUF_RDY);
-++#ifdef RW_DATA_BY_BYTE
-++			ret_size = sizeof(unsigned int);
-++			ret_size = min(ret_size, len);
-++			len -= ret_size;
-++			while (ret_size-- > 0) {
-++				//nfc is little endian
-++				*p++ = ret_data & 0x0ff;
-++				ret_data >>= 8;
-++			}
-++#else
-++			ret_size = min(len, 4);
-++			len -= ret_size;
-++			if (ret_size == 4)
-++				*p++ = ret_data;
-++			else {
-++				__u8 *q = (__u8 *)p;
-++				while (ret_size-- > 0) {
-++					*q++ = ret_data & 0x0ff;
-++					ret_data >>= 8;
-++				}
-++				p = (__u32 *)q;
-++			}
-++#endif
-++			retry = READ_STATUS_RETRY;
-++		}
-++		else if (int_st & INT_ST_ND_DONE) {
-++			break;
-++		}
-++		else {
-++			udelay(1);
-++			if (retry-- < 0)
-++				break;
-++		}
-++	}
-++
-++#ifdef RW_DATA_BY_BYTE
-++	return (int)(p - buf);
-++#else
-++	return ((int)p - (int)buf);
-++#endif
-++}
-++
-++/**
-++ * generic function to put data into flash.
-++ * @return data length writing into flash.
-++ */
-++static int _ra_nand_push_data(char *buf, int len, int use_gdma)
-++{
-++#ifdef RW_DATA_BY_BYTE
-++	char *p = buf;
-++#else
-++	__u32 *p = (__u32 *)buf;
-++#endif
-++	int retry, int_st;
-++	unsigned int tx_data = 0;
-++	int tx_size, iter = 0;
-++
-++	// receive data by use_gdma
-++	if (use_gdma) {
-++		//if (_ra_nand_dma_push((unsigned long)p, len))
-++		if (1)
-++			len = 0;
-++		printk("%s: fail \n", __func__);
-++		return len;
-++	}
-++
-++	// no gdma
-++	retry = READ_STATUS_RETRY;
-++	while (len > 0) {
-++		int_st = ra_inl(NFC_INT_ST);
-++		if (int_st & INT_ST_TX_BUF_RDY) {
-++#ifdef RW_DATA_BY_BYTE
-++			tx_size = min(len, (int)sizeof(unsigned long));
-++			for (iter = 0; iter < tx_size; iter++) {
-++				tx_data |= (*p++ << (8*iter));
-++			}
-++#else
-++			tx_size = min(len, 4);
-++			if (tx_size == 4)
-++				tx_data = (*p++);
-++			else {
-++				__u8 *q = (__u8 *)p;
-++				for (iter = 0; iter < tx_size; iter++)
-++					tx_data |= (*q++ << (8*iter));
-++				p = (__u32 *)q;
-++			}
-++#endif
-++			ra_outl(NFC_INT_ST, INT_ST_TX_BUF_RDY);
-++			ra_outl(NFC_DATA, tx_data);
-++			len -= tx_size;
-++			retry = READ_STATUS_RETRY;
-++		}
-++		else if (int_st & INT_ST_ND_DONE) {
-++			break;
-++		}
-++		else {
-++			udelay(1);
-++			if (retry-- < 0) {
-++				ra_dbg("%s p:%p buf:%p \n", __func__, p, buf);
-++				break;
-++			}
-++		}
-++	}
-++
-++#ifdef RW_DATA_BY_BYTE
-++	return (int)(p - buf);
-++#else
-++	return ((int)p - (int)buf);
-++#endif
-++}
-++
-++static int nfc_select_chip(struct ra_nand_chip *ra, int chipnr)
-++{
-++#if (CONFIG_NUMCHIPS == 1)
-++	if (!(chipnr < CONFIG_NUMCHIPS))
-++		return -1;
-++	return 0;
-++#else
-++	BUG();
-++#endif
-++}
-++
-++/** @return -1: chip_select fail
-++ *	    0 : both CE and WP==0 are OK
-++ * 	    1 : CE OK and WP==1
-++ */
-++static int nfc_enable_chip(struct ra_nand_chip *ra, unsigned int offs, int read_only)
-++{
-++	int chipnr = offs >> ra->chip_shift;
-++
-++	ra_dbg("%s: offs:%x read_only:%x \n", __func__, offs, read_only);
-++
-++	chipnr = nfc_select_chip(ra, chipnr);
-++	if (chipnr < 0) {
-++		printk("%s: chip select error, offs(%x)\n", __func__, offs);
-++		return -1;
-++	}
-++
-++	if (!read_only)
-++		return nfc_check_wp();
-++
-++	return 0;
-++}
-++
-++/** wait nand chip becomeing ready and return queried status.
-++ * @param snooze: sleep time in ms unit before polling device ready.
-++ * @return status of nand chip
-++ * @return NAN_STATUS_FAIL if something unexpected.
-++ */
-++static int nfc_wait_ready(int snooze_ms)
-++{
-++	int retry;
-++	char status;
-++
-++	// wait nfc idle,
-++	if (snooze_ms == 0)
-++		snooze_ms = 1;
-++	else
-++		schedule_timeout(snooze_ms * HZ / 1000);
-++
-++	snooze_ms = retry = snooze_ms *1000000 / 100 ;  // ndelay(100)
-++
-++	while (!NFC_TRANS_DONE() && retry--) {
-++		if (!cond_resched())
-++			ndelay(100);
-++	}
-++
-++	if (!NFC_TRANS_DONE()) {
-++		printk("nfc_wait_ready: no transaction done \n");
-++		return NAND_STATUS_FAIL;
-++	}
-++
-++#if !defined (CONFIG_NOT_SUPPORT_RB)
-++	//fixme
-++	while(!(status = nfc_device_ready()) && retry--) {
-++		ndelay(100);
-++	}
-++
-++	if (status == 0) {
-++		printk("nfc_wait_ready: no device ready. \n");
-++		return NAND_STATUS_FAIL;
-++	}
-++
-++	_nfc_read_status(&status);
-++	return status;
-++#else
-++
-++	while(retry--) {
-++		_nfc_read_status(&status);
-++		if (status & NAND_STATUS_READY)
-++			break;
-++		ndelay(100);
-++	}
-++	if (retry<0)
-++		printk("nfc_wait_ready 2: no device ready, status(%x). \n", status);
-++
-++	return status;
-++#endif
-++}
-++
-++/**
-++ * return 0: erase OK
-++ * return -EIO: fail
-++ */
-++int nfc_erase_block(struct ra_nand_chip *ra, int row_addr)
-++{
-++	unsigned long cmd1, cmd2, bus_addr, conf;
-++	char status;
-++
-++	cmd1 = 0x60;
-++	cmd2 = 0xd0;
-++	bus_addr = row_addr;
-++	conf = 0x00511 | ((CFG_ROW_ADDR_CYCLE)<<16);
-++
-++	// set NFC
-++	ra_dbg("%s: cmd1: %lx, cmd2:%lx bus_addr: %lx, conf: %lx \n",
-++	       __func__, cmd1, cmd2, bus_addr, conf);
-++
-++	//fixme, should we check nfc status?
-++	CLEAR_INT_STATUS();
-++
-++	ra_outl(NFC_CMD1, cmd1);
-++	ra_outl(NFC_CMD2, cmd2);
-++	ra_outl(NFC_ADDR, bus_addr);
-++	ra_outl(NFC_CONF, conf);
-++
-++	status = nfc_wait_ready(3);  //erase wait 3ms
-++	if (status & NAND_STATUS_FAIL) {
-++		printk("%s: fail \n", __func__);
-++		return -EIO;
-++	}
-++
-++	return 0;
-++}
-++
-++static inline int _nfc_read_raw_data(int cmd1, int cmd2, int bus_addr, int bus_addr2, int conf, char *buf, int len, int flags)
-++{
-++	int ret;
-++
-++	CLEAR_INT_STATUS();
-++	ra_outl(NFC_CMD1, cmd1);
-++	ra_outl(NFC_CMD2, cmd2);
-++	ra_outl(NFC_ADDR, bus_addr);
-++#if defined (CONFIG_SOC_MT7620)
-++	ra_outl(NFC_ADDR2, bus_addr2);
-++#endif
-++	ra_outl(NFC_CONF, conf);
-++
-++	ret = _ra_nand_pull_data(buf, len, 0);
-++	if (ret != len) {
-++		ra_dbg("%s: ret:%x (%x) \n", __func__, ret, len);
-++		return NAND_STATUS_FAIL;
-++	}
-++
-++	//FIXME, this section is not necessary
-++	ret = nfc_wait_ready(0); //wait ready
-++	/* to prevent the DATA FIFO 's old data from next operation */
-++	ra_outl(NFC_CTRL, ra_inl(NFC_CTRL) | 0x02); //clear data buffer
-++	ra_outl(NFC_CTRL, ra_inl(NFC_CTRL) & ~0x02); //clear data buffer
-++
-++	if (ret & NAND_STATUS_FAIL) {
-++		printk("%s: fail \n", __func__);
-++		return NAND_STATUS_FAIL;
-++	}
-++
-++	return 0;
-++}
-++
-++static inline int _nfc_write_raw_data(int cmd1, int cmd3, int bus_addr, int bus_addr2, int conf, char *buf, int len, int flags)
-++{
-++	int ret;
-++
-++	CLEAR_INT_STATUS();
-++	ra_outl(NFC_CMD1, cmd1);
-++	ra_outl(NFC_CMD3, cmd3);
-++	ra_outl(NFC_ADDR, bus_addr);
-++#if defined (CONFIG_SOC_MT7620)
-++	ra_outl(NFC_ADDR2, bus_addr2);
-++#endif
-++	ra_outl(NFC_CONF, conf);
-++
-++	ret = _ra_nand_push_data(buf, len, 0);
-++	if (ret != len) {
-++		ra_dbg("%s: ret:%x (%x) \n", __func__, ret, len);
-++		return NAND_STATUS_FAIL;
-++	}
-++
-++	ret = nfc_wait_ready(1); //write wait 1ms
-++	/* to prevent the DATA FIFO 's old data from next operation */
-++	ra_outl(NFC_CTRL, ra_inl(NFC_CTRL) | 0x02); //clear data buffer
-++	ra_outl(NFC_CTRL, ra_inl(NFC_CTRL) & ~0x02); //clear data buffer
-++
-++	if (ret & NAND_STATUS_FAIL) {
-++		printk("%s: fail \n", __func__);
-++		return NAND_STATUS_FAIL;
-++	}
-++
-++	return 0;
-++}
-++
-++/**
-++ * @return !0: fail
-++ * @return 0: OK
-++ */
-++int nfc_read_oob(struct ra_nand_chip *ra, int page, unsigned int offs, char *buf, int len, int flags)
-++{
-++	unsigned int cmd1 = 0, cmd2 = 0, conf = 0;
-++	unsigned int bus_addr = 0, bus_addr2 = 0;
-++	unsigned int ecc_en;
-++	int use_gdma;
-++	int status;
-++
-++	int pages_perblock = 1<<(ra->erase_shift - ra->page_shift);
-++	// constrain of nfc read function
-++
-++#if defined (WORKAROUND_RX_BUF_OV)
-++	BUG_ON (len > 60); 	//problem of rx-buffer overrun
-++#endif
-++	BUG_ON (offs >> ra->oob_shift); //page boundry
-++	BUG_ON ((unsigned int)(((offs + len) >> ra->oob_shift) + page) >
-++	        ((page + pages_perblock) & ~(pages_perblock-1))); //block boundry
-++
-++	use_gdma = flags & FLAG_USE_GDMA;
-++	ecc_en = flags & FLAG_ECC_EN;
-++	bus_addr = (page << (CFG_COLUMN_ADDR_CYCLE*8)) | (offs & ((1<<CFG_COLUMN_ADDR_CYCLE*8) - 1));
-++
-++	if (is_nand_page_2048) {
-++		bus_addr += CFG_PAGESIZE;
-++		bus_addr2 = page >> (CFG_COLUMN_ADDR_CYCLE*8);
-++		cmd1 = 0x0;
-++		cmd2 = 0x30;
-++		conf = 0x000511| ((CFG_ADDR_CYCLE)<<16) | (len << 20);
-++	}
-++	else {
-++		cmd1 = 0x50;
-++		conf = 0x000141| ((CFG_ADDR_CYCLE)<<16) | (len << 20);
-++	}
-++	if (ecc_en)
-++		conf |= (1<<3);
-++	if (use_gdma)
-++		conf |= (1<<2);
-++
-++	ra_dbg("%s: cmd1:%x, bus_addr:%x, conf:%x, len:%x, flag:%x\n",
-++	       __func__, cmd1, bus_addr, conf, len, flags);
-++
-++	status = _nfc_read_raw_data(cmd1, cmd2, bus_addr, bus_addr2, conf, buf, len, flags);
-++	if (status & NAND_STATUS_FAIL) {
-++		printk("%s: fail\n", __func__);
-++		return -EIO;
-++	}
-++
-++	return 0;
-++}
-++
-++/**
-++ * @return !0: fail
-++ * @return 0: OK
-++ */
-++int nfc_write_oob(struct ra_nand_chip *ra, int page, unsigned int offs, char *buf, int len, int flags)
-++{
-++	unsigned int cmd1 = 0, cmd3=0, conf = 0;
-++	unsigned int bus_addr = 0, bus_addr2 = 0;
-++	int use_gdma;
-++	int status;
-++
-++	int pages_perblock = 1<<(ra->erase_shift - ra->page_shift);
-++	// constrain of nfc read function
-++
-++	BUG_ON (offs >> ra->oob_shift); //page boundry
-++	BUG_ON ((unsigned int)(((offs + len) >> ra->oob_shift) + page) >
-++	        ((page + pages_perblock) & ~(pages_perblock-1))); //block boundry
-++
-++	use_gdma = flags & FLAG_USE_GDMA;
-++	bus_addr = (page << (CFG_COLUMN_ADDR_CYCLE*8)) | (offs & ((1<<CFG_COLUMN_ADDR_CYCLE*8) - 1));
-++
-++	if (is_nand_page_2048) {
-++		cmd1 = 0x80;
-++		cmd3 = 0x10;
-++		bus_addr += CFG_PAGESIZE;
-++		bus_addr2 = page >> (CFG_COLUMN_ADDR_CYCLE*8);
-++		conf = 0x001123 | ((CFG_ADDR_CYCLE)<<16) | ((len) << 20);
-++	}
-++	else {
-++		cmd1 = 0x08050;
-++		cmd3 = 0x10;
-++		conf = 0x001223 | ((CFG_ADDR_CYCLE)<<16) | ((len) << 20);
-++	}
-++	if (use_gdma)
-++		conf |= (1<<2);
-++
-++	// set NFC
-++	ra_dbg("%s: cmd1: %x, cmd3: %x bus_addr: %x, conf: %x, len:%x\n",
-++	       __func__, cmd1, cmd3, bus_addr, conf, len);
-++
-++	status = _nfc_write_raw_data(cmd1, cmd3, bus_addr, bus_addr2, conf, buf, len, flags);
-++	if (status & NAND_STATUS_FAIL) {
-++		printk("%s: fail \n", __func__);
-++		return -EIO;
-++	}
-++
-++	return 0;
-++}
-++
-++
-++int nfc_read_page(struct ra_nand_chip *ra, char *buf, int page, int flags);
-++int nfc_write_page(struct ra_nand_chip *ra, char *buf, int page, int flags);
-++
-++
-++#if !defined (WORKAROUND_RX_BUF_OV)
-++static int one_bit_correction(char *ecc, char *expected, int *bytes, int *bits);
-++int nfc_ecc_verify(struct ra_nand_chip *ra, char *buf, int page, int mode)
-++{
-++	int ret, i;
-++	char *p, *e;
-++	int ecc;
-++
-++	//ra_dbg("%s, page:%x mode:%d\n", __func__, page, mode);
-++
-++	if (mode == FL_WRITING) {
-++		int len = CFG_PAGESIZE + CFG_PAGE_OOBSIZE;
-++		int conf = 0x000141| ((CFG_ADDR_CYCLE)<<16) | (len << 20);
-++		conf |= (1<<3); //(ecc_en)
-++		//conf |= (1<<2); // (use_gdma)
-++
-++		p = ra->readback_buffers;
-++		ret = nfc_read_page(ra, ra->readback_buffers, page, FLAG_ECC_EN);
-++		if (ret == 0)
-++			goto ecc_check;
-++
-++		//FIXME, double comfirm
-++		printk("%s: read back fail, try again \n",__func__);
-++		ret = nfc_read_page(ra, ra->readback_buffers, page, FLAG_ECC_EN);
-++		if (ret != 0) {
-++			printk("\t%s: read back fail agian \n",__func__);
-++			goto bad_block;
-++		}
-++	}
-++	else if (mode == FL_READING) {
-++		p = buf;
-++	}
-++	else
-++		return -2;
-++
-++ecc_check:
-++	p += CFG_PAGESIZE;
-++	if (!is_nand_page_2048) {
-++		ecc = ra_inl(NFC_ECC);
-++		if (ecc == 0) //clean page.
-++			return 0;
-++		e = (char*)&ecc;
-++		for (i=0; i<CONFIG_ECC_BYTES; i++) {
-++			int eccpos = CONFIG_ECC_OFFSET + i;
-++			if (*(p + eccpos) != (char)0xff)
-++				break;
-++			if (i == CONFIG_ECC_BYTES - 1) {
-++				printk("skip ecc 0xff at page %x\n", page);
-++				return 0;
-++			}
-++		}
-++		for (i=0; i<CONFIG_ECC_BYTES; i++) {
-++			int eccpos = CONFIG_ECC_OFFSET + i;
-++			if (*(p + eccpos) != *(e + i)) {
-++				printk("%s mode:%s, invalid ecc, page: %x read:%x %x %x, ecc:%x \n",
-++				       __func__, (mode == FL_READING)?"read":"write", page,
-++				       *(p+ CONFIG_ECC_OFFSET), *(p+ CONFIG_ECC_OFFSET+1), *(p+ CONFIG_ECC_OFFSET +2), ecc);
-++				return -1;
-++			}
-++		}
-++	}
-++#if defined (CONFIG_SOC_MT7620)
-++	else {
-++		int ecc2, ecc3, ecc4, qsz;
-++		char *e2, *e3, *e4;
-++		int correction_flag = 0;
-++		ecc = ra_inl(NFC_ECC_P1);
-++		ecc2 = ra_inl(NFC_ECC_P2);
-++		ecc3 = ra_inl(NFC_ECC_P3);
-++		ecc4 = ra_inl(NFC_ECC_P4);
-++		e = (char*)&ecc;
-++		e2 = (char*)&ecc2;
-++		e3 = (char*)&ecc3;
-++		e4 = (char*)&ecc4;
-++		qsz = CFG_PAGE_OOBSIZE / 4;
-++		if (ecc == 0 && ecc2 == 0 && ecc3 == 0 && ecc4 == 0)
-++			return 0;
-++		for (i=0; i<CONFIG_ECC_BYTES; i++) {
-++			int eccpos = CONFIG_ECC_OFFSET + i;
-++			if (*(p + eccpos) != (char)0xff)
-++				break;
-++			else if (*(p + eccpos + qsz) != (char)0xff)
-++				break;
-++			else if (*(p + eccpos + qsz*2) != (char)0xff)
-++				break;
-++			else if (*(p + eccpos + qsz*3) != (char)0xff)
-++				break;
-++			if (i == CONFIG_ECC_BYTES - 1) {
-++				printk("skip ecc 0xff at page %x\n", page);
-++				return 0;
-++			}
-++		}
-++		for (i=0; i<CONFIG_ECC_BYTES; i++) {
-++			int eccpos = CONFIG_ECC_OFFSET + i;
-++			if (*(p + eccpos) != *(e + i)) {
-++				printk("%s mode:%s, invalid ecc, page: %x read:%x %x %x, ecc:%x \n",
-++				       __func__, (mode == FL_READING)?"read":"write", page,
-++				       *(p+ CONFIG_ECC_OFFSET), *(p+ CONFIG_ECC_OFFSET+1), *(p+ CONFIG_ECC_OFFSET +2), ecc);
-++				correction_flag |= 0x1;
-++			}
-++			if (*(p + eccpos + qsz) != *(e2 + i)) {
-++				printk("%s mode:%s, invalid ecc2, page: %x read:%x %x %x, ecc2:%x \n",
-++				       __func__, (mode == FL_READING)?"read":"write", page,
-++				       *(p+CONFIG_ECC_OFFSET+qsz), *(p+ CONFIG_ECC_OFFSET+1+qsz), *(p+ CONFIG_ECC_OFFSET+2+qsz), ecc2);
-++				correction_flag |= 0x2;
-++			}
-++			if (*(p + eccpos + qsz*2) != *(e3 + i)) {
-++				printk("%s mode:%s, invalid ecc3, page: %x read:%x %x %x, ecc3:%x \n",
-++				       __func__, (mode == FL_READING)?"read":"write", page,
-++				       *(p+CONFIG_ECC_OFFSET+qsz*2), *(p+ CONFIG_ECC_OFFSET+1+qsz*2), *(p+ CONFIG_ECC_OFFSET+2+qsz*2), ecc3);
-++				correction_flag |= 0x4;
-++			}
-++			if (*(p + eccpos + qsz*3) != *(e4 + i)) {
-++				printk("%s mode:%s, invalid ecc4, page: %x read:%x %x %x, ecc4:%x \n",
-++				       __func__, (mode == FL_READING)?"read":"write", page,
-++				       *(p+CONFIG_ECC_OFFSET+qsz*3), *(p+ CONFIG_ECC_OFFSET+1+qsz*3), *(p+ CONFIG_ECC_OFFSET+2+qsz*3), ecc4);
-++				correction_flag |= 0x8;
-++			}
-++		}
-++
-++		if (correction_flag)
-++		{
-++			printk("trying to do correction!\n");
-++			if (correction_flag & 0x1)
-++			{
-++				int bytes, bits;
-++				char *pBuf = p - CFG_PAGESIZE;
-++
-++				if (one_bit_correction(p + CONFIG_ECC_OFFSET, e, &bytes, &bits) == 0)
-++				{
-++					pBuf[bytes] = pBuf[bytes] ^ (1 << bits);
-++					printk("1. correct byte %d, bit %d!\n", bytes, bits);
-++				}
-++				else
-++				{
-++					printk("failed to correct!\n");
-++					return -1;
-++				}
-++			}
-++
-++			if (correction_flag & 0x2)
-++			{
-++				int bytes, bits;
-++				char *pBuf = (p - CFG_PAGESIZE) + CFG_PAGESIZE/4;
-++
-++				if (one_bit_correction((p + CONFIG_ECC_OFFSET + qsz), e2, &bytes, &bits) == 0)
-++				{
-++					pBuf[bytes] = pBuf[bytes] ^ (1 << bits);
-++					printk("2. correct byte %d, bit %d!\n", bytes, bits);
-++				}
-++				else
-++				{
-++					printk("failed to correct!\n");
-++					return -1;
-++				}
-++			}
-++			if (correction_flag & 0x4)
-++			{
-++				int bytes, bits;
-++				char *pBuf = (p - CFG_PAGESIZE) + CFG_PAGESIZE/2;
-++
-++				if (one_bit_correction((p + CONFIG_ECC_OFFSET + qsz * 2), e3, &bytes, &bits) == 0)
-++				{
-++					pBuf[bytes] = pBuf[bytes] ^ (1 << bits);
-++					printk("3. correct byte %d, bit %d!\n", bytes, bits);
-++				}
-++				else
-++				{
-++					printk("failed to correct!\n");
-++					return -1;
-++				}
-++			}
-++			if (correction_flag & 0x8)
-++			{
-++				int bytes, bits;
-++				char *pBuf = (p - CFG_PAGESIZE) + CFG_PAGESIZE*3/4;
-++
-++				if (one_bit_correction((p + CONFIG_ECC_OFFSET + qsz * 3), e4, &bytes, &bits) == 0)
-++				{
-++					pBuf[bytes] = pBuf[bytes] ^ (1 << bits);
-++					printk("4. correct byte %d, bit %d!\n", bytes, bits);
-++				}
-++				else
-++				{
-++					printk("failed to correct!\n");
-++					return -1;
-++				}
-++			}
-++		}
-++
-++	}
-++#endif
-++	return 0;
-++
-++bad_block:
-++	return -1;
-++}
-++
-++#else
-++
-++void ranfc_dump(void)
-++{
-++	int i;
-++	for (i=0; i<11; i++) {
-++		if (i==6)
-++			continue;
-++		printk("%x: %x \n", NFC_BASE + i*4, ra_inl(NFC_BASE + i*4));
-++	}
-++}
-++
-++/**
-++ * @return 0, ecc OK or corrected.
-++ * @return NAND_STATUS_FAIL, ecc fail.
-++ */
-++
-++int nfc_ecc_verify(struct ra_nand_chip *ra, char *buf, int page, int mode)
-++{
-++	int ret, i;
-++	char *p, *e;
-++	int ecc;
-++
-++	if (ranfc_verify == 0)
-++		return 0;
-++
-++	ra_dbg("%s, page:%x mode:%d\n", __func__, page, mode);
-++
-++	if (mode == FL_WRITING) { // read back and memcmp
-++		ret = nfc_read_page(ra, ra->readback_buffers, page, FLAG_NONE);
-++		if (ret != 0) //double comfirm
-++			ret = nfc_read_page(ra, ra->readback_buffers, page, FLAG_NONE);
-++
-++		if (ret != 0) {
-++			printk("%s: mode:%x read back fail \n", __func__, mode);
-++			return -1;
-++		}
-++		return memcmp(buf, ra->readback_buffers, 1<<ra->page_shift);
-++	}
-++
-++	if (mode == FL_READING) {
-++#if 0
-++		if (ra->sandbox_page == 0)
-++			return 0;
-++
-++		ret = nfc_write_page(ra, buf, ra->sandbox_page, FLAG_USE_GDMA | FLAG_ECC_EN);
-++		if (ret != 0) {
-++			printk("%s, fail write sandbox_page \n", __func__);
-++			return -1;
-++		}
-++#else
-++		/** @note:
-++		 * The following command is actually not 'write' command to drive NFC to write flash.
-++		 * However, it can make NFC to calculate ECC, that will be used to compare with original ones.
-++		 * --YT
-++		 */
-++		unsigned int conf = 0x001223| (CFG_ADDR_CYCLE<<16) | (0x200 << 20) | (1<<3) | (1<<2);
-++		_nfc_write_raw_data(0xff, 0xff, ra->sandbox_page<<ra->page_shift, conf, buf, 0x200, FLAG_USE_GDMA);
-++#endif
-++
-++		ecc = ra_inl(NFC_ECC);
-++		if (ecc == 0) //clean page.
-++			return 0;
-++		e = (char*)&ecc;
-++		p = buf + (1<<ra->page_shift);
-++		for (i=0; i<CONFIG_ECC_BYTES; i++) {
-++			int eccpos = CONFIG_ECC_OFFSET + i;
-++			if (*(p + eccpos) != *(e + i)) {
-++				printk("%s mode:%s, invalid ecc, page: %x read:%x %x %x, write:%x \n",
-++				       __func__, (mode == FL_READING)?"read":"write", page,
-++				       *(p+ CONFIG_ECC_OFFSET), *(p+ CONFIG_ECC_OFFSET+1), *(p+ CONFIG_ECC_OFFSET +2), ecc);
-++
-++				for (i=0; i<528; i++)
-++					printk("%-2x \n", *(buf + i));
-++				return -1;
-++			}
-++		}
-++		return 0;
-++	}
-++
-++	return -1;
-++}
-++#endif
-++
-++/**
-++ * @return -EIO, writing size is less than a page
-++ * @return 0, OK
-++ */
-++int nfc_read_page(struct ra_nand_chip *ra, char *buf, int page, int flags)
-++{
-++	unsigned int cmd1 = 0, cmd2 = 0, conf = 0;
-++	unsigned int bus_addr = 0, bus_addr2 = 0;
-++	unsigned int ecc_en;
-++	int use_gdma;
-++	int size, offs;
-++	int status = 0;
-++
-++	use_gdma = flags & FLAG_USE_GDMA;
-++	ecc_en = flags & FLAG_ECC_EN;
-++
-++	page = page & (CFG_CHIPSIZE - 1); // chip boundary
-++	size = CFG_PAGESIZE + CFG_PAGE_OOBSIZE; //add oobsize
-++	offs = 0;
-++
-++	while (size > 0) {
-++		int len;
-++#if defined (WORKAROUND_RX_BUF_OV)
-++		len = min(60, size);
-++#else
-++		len = size;
-++#endif
-++		bus_addr = (page << (CFG_COLUMN_ADDR_CYCLE*8)) | (offs & ((1<<CFG_COLUMN_ADDR_CYCLE*8)-1));
-++		if (is_nand_page_2048) {
-++			bus_addr2 = page >> (CFG_COLUMN_ADDR_CYCLE*8);
-++			cmd1 = 0x0;
-++			cmd2 = 0x30;
-++			conf = 0x000511| ((CFG_ADDR_CYCLE)<<16) | (len << 20);
-++		}
-++		else {
-++			if (offs & ~(CFG_PAGESIZE-1))
-++				cmd1 = 0x50;
-++			else if (offs & ~((1<<CFG_COLUMN_ADDR_CYCLE*8)-1))
-++				cmd1 = 0x01;
-++			else
-++				cmd1 = 0;
-++
-++			conf = 0x000141| ((CFG_ADDR_CYCLE)<<16) | (len << 20);
-++		}
-++#if !defined (WORKAROUND_RX_BUF_OV)
-++		if (ecc_en)
-++			conf |= (1<<3);
-++#endif
-++		if (use_gdma)
-++			conf |= (1<<2);
-++
-++		status = _nfc_read_raw_data(cmd1, cmd2, bus_addr, bus_addr2, conf, buf+offs, len, flags);
-++		if (status & NAND_STATUS_FAIL) {
-++			printk("%s: fail \n", __func__);
-++			return -EIO;
-++		}
-++
-++		offs += len;
-++		size -= len;
-++	}
-++
-++	// verify and correct ecc
-++	if ((flags & (FLAG_VERIFY | FLAG_ECC_EN)) == (FLAG_VERIFY | FLAG_ECC_EN)) {
-++		status = nfc_ecc_verify(ra, buf, page, FL_READING);
-++		if (status != 0) {
-++			printk("%s: fail, buf:%x, page:%x, flag:%x\n",
-++			       __func__, (unsigned int)buf, page, flags);
-++			return -EBADMSG;
-++		}
-++	}
-++	else {
-++		// fix,e not yet support
-++		ra->buffers_page = -1; //cached
-++	}
-++
-++	return 0;
-++}
-++
-++
-++/**
-++ * @return -EIO, fail to write
-++ * @return 0, OK
-++ */
-++int nfc_write_page(struct ra_nand_chip *ra, char *buf, int page, int flags)
-++{
-++	unsigned int cmd1 = 0, cmd3, conf = 0;
-++	unsigned int bus_addr = 0, bus_addr2 = 0;
-++	unsigned int ecc_en;
-++	int use_gdma;
-++	int size;
-++	char status;
-++	uint8_t *oob = buf + (1<<ra->page_shift);
-++
-++	use_gdma = flags & FLAG_USE_GDMA;
-++	ecc_en = flags & FLAG_ECC_EN;
-++
-++	oob[ra->badblockpos] = 0xff;	//tag as good block.
-++	ra->buffers_page = -1; //cached
-++
-++	page = page & (CFG_CHIPSIZE-1); //chip boundary
-++	size = CFG_PAGESIZE + CFG_PAGE_OOBSIZE; //add oobsize
-++	bus_addr = (page << (CFG_COLUMN_ADDR_CYCLE*8)); //write_page always write from offset 0.
-++
-++	if (is_nand_page_2048) {
-++		bus_addr2 = page >> (CFG_COLUMN_ADDR_CYCLE*8);
-++		cmd1 = 0x80;
-++		cmd3 = 0x10;
-++		conf = 0x001123| ((CFG_ADDR_CYCLE)<<16) | (size << 20);
-++	}
-++	else {
-++		cmd1 = 0x8000;
-++		cmd3 = 0x10;
-++		conf = 0x001223| ((CFG_ADDR_CYCLE)<<16) | (size << 20);
-++	}
-++	if (ecc_en)
-++		conf |= (1<<3); //enable ecc
-++	if (use_gdma)
-++		conf |= (1<<2);
-++
-++	// set NFC
-++	ra_dbg("nfc_write_page: cmd1: %x, cmd3: %x bus_addr: %x, conf: %x, len:%x\n",
-++	       cmd1, cmd3, bus_addr, conf, size);
-++
-++	status = _nfc_write_raw_data(cmd1, cmd3, bus_addr, bus_addr2, conf, buf, size, flags);
-++	if (status & NAND_STATUS_FAIL) {
-++		printk("%s: fail \n", __func__);
-++		return -EIO;
-++	}
-++
-++
-++	if (flags & FLAG_VERIFY) { // verify and correct ecc
-++		status = nfc_ecc_verify(ra, buf, page, FL_WRITING);
-++
-++#ifdef RANDOM_GEN_BAD_BLOCK
-++		if (((random32() & 0x1ff) == 0x0) && (page >= 0x100)) // randomly create bad block
-++		{
-++			printk("hmm... create a bad block at page %x\n", (bus_addr >> 16));
-++			status = -1;
-++		}
-++#endif
-++
-++		if (status != 0) {
-++			printk("%s: ecc_verify fail: ret:%x \n", __func__, status);
-++			oob[ra->badblockpos] = 0x33;
-++			page -= page % (CFG_BLOCKSIZE/CFG_PAGESIZE);
-++			printk("create a bad block at page %x\n", page);
-++			if (!is_nand_page_2048)
-++				status = nfc_write_oob(ra, page, ra->badblockpos, oob+ra->badblockpos, 1, flags);
-++			else
-++			{
-++				status = _nfc_write_raw_data(cmd1, cmd3, bus_addr, bus_addr2, conf, buf, size, flags);
-++				nfc_write_oob(ra, page, 0, oob, 16, FLAG_NONE);
-++			}
-++			return -EBADMSG;
-++		}
-++	}
-++
-++	ra->buffers_page = page; //cached
-++	return 0;
-++}
-++
-++
-++
-++/*************************************************************
-++ * nand internal process
-++ *************************************************************/
-++
-++/**
-++ * nand_release_device - [GENERIC] release chip
-++ * @mtd:	MTD device structure
-++ *
-++ * Deselect, release chip lock and wake up anyone waiting on the device
-++ */
-++static void nand_release_device(struct ra_nand_chip *ra)
-++{
-++	/* De-select the NAND device */
-++	nfc_select_chip(ra, -1);
-++
-++	/* Release the controller and the chip */
-++	ra->state = FL_READY;
-++
-++	mutex_unlock(ra->controller);
-++}
-++
-++/**
-++ * nand_get_device - [GENERIC] Get chip for selected access
-++ * @chip:	the nand chip descriptor
-++ * @mtd:	MTD device structure
-++ * @new_state:	the state which is requested
-++ *
-++ * Get the device and lock it for exclusive access
-++ */
-++static int
-++nand_get_device(struct ra_nand_chip *ra, int new_state)
-++{
-++	int ret = 0;
-++
-++	ret = mutex_lock_interruptible(ra->controller);
-++	if (!ret)
-++		ra->state = new_state;
-++
-++	return ret;
-++}
-++
-++/*************************************************************
-++ * nand internal process
-++ *************************************************************/
-++
-++int ra_nand_bbt_get(struct ra_nand_chip *ra, int block)
-++{
-++	int byte, bits;
-++	bits = block * BBTTAG_BITS;
-++
-++	byte = bits / 8;
-++	bits = bits % 8;
-++
-++	return (ra->bbt[byte] >> bits) & BBTTAG_BITS_MASK;
-++}
-++
-++int ra_nand_bbt_set(struct ra_nand_chip *ra, int block, int tag)
-++{
-++	int byte, bits;
-++	bits = block * BBTTAG_BITS;
-++
-++	byte = bits / 8;
-++	bits = bits % 8;
-++
-++	// If previous tag is bad, dont overwrite it
-++	if (((ra->bbt[byte] >> bits) & BBTTAG_BITS_MASK) == BBT_TAG_BAD)
-++	{
-++		return BBT_TAG_BAD;
-++	}
-++
-++	ra->bbt[byte] = (ra->bbt[byte] & ~(BBTTAG_BITS_MASK << bits)) | ((tag & BBTTAG_BITS_MASK) << bits);
-++
-++	return tag;
-++}
-++
-++/**
-++ * nand_block_checkbad - [GENERIC] Check if a block is marked bad
-++ * @mtd:	MTD device structure
-++ * @ofs:	offset from device start
-++ *
-++ * Check, if the block is bad. Either by reading the bad block table or
-++ * calling of the scan function.
-++ */
-++int nand_block_checkbad(struct ra_nand_chip *ra, loff_t offs)
-++{
-++	int page, block;
-++	int ret = 4;
-++	unsigned int tag;
-++	char *str[]= {"UNK", "RES", "BAD", "GOOD"};
-++
-++	if (ranfc_bbt == 0)
-++		return 0;
-++
-++	{
-++		// align with chip
-++
-++		offs = offs & ((1<<ra->chip_shift) -1);
-++
-++		page = offs >> ra->page_shift;
-++		block = offs >> ra->erase_shift;
-++	}
-++
-++	tag = ra_nand_bbt_get(ra, block);
-++
-++	if (tag == BBT_TAG_UNKNOWN) {
-++		ret = nfc_read_oob(ra, page, ra->badblockpos, (char*)&tag, 1, FLAG_NONE);
-++		if (ret == 0)
-++			tag = ((le32_to_cpu(tag) & 0x0ff) == 0x0ff) ? BBT_TAG_GOOD : BBT_TAG_BAD;
-++		else
-++			tag = BBT_TAG_BAD;
-++
-++		ra_nand_bbt_set(ra, block, tag);
-++	}
-++
-++	if (tag != BBT_TAG_GOOD) {
-++		printk("%s: offs:%x tag: %s \n", __func__, (unsigned int)offs, str[tag]);
-++		return 1;
-++	}
-++	else
-++		return 0;
-++}
-++
-++/**
-++ * nand_block_markbad -
-++ */
-++int nand_block_markbad(struct ra_nand_chip *ra, loff_t offs)
-++{
-++	int page, block;
-++	int ret = 4;
-++	unsigned int tag;
-++	char *ecc;
-++
-++	// align with chip
-++	ra_dbg("%s offs: %x \n", __func__, (int)offs);
-++
-++	offs = offs & ((1<<ra->chip_shift) -1);
-++
-++	page = offs >> ra->page_shift;
-++	block = offs >> ra->erase_shift;
-++
-++	tag = ra_nand_bbt_get(ra, block);
-++
-++	if (tag == BBT_TAG_BAD) {
-++		printk("%s: mark repeatedly \n", __func__);
-++		return 0;
-++	}
-++
-++	// new tag as bad
-++	tag =BBT_TAG_BAD;
-++	ret = nfc_read_page(ra, ra->buffers, page, FLAG_NONE);
-++	if (ret != 0) {
-++		printk("%s: fail to read bad block tag \n", __func__);
-++		goto tag_bbt;
-++	}
-++
-++	ecc = &ra->buffers[(1<<ra->page_shift)+ra->badblockpos];
-++	if (*ecc == (char)0x0ff) {
-++		//tag into flash
-++		*ecc = (char)tag;
-++		ret = nfc_write_page(ra, ra->buffers, page, FLAG_USE_GDMA);
-++		if (ret)
-++			printk("%s: fail to write bad block tag \n", __func__);
-++	}
-++
-++tag_bbt:
-++	//update bbt
-++	ra_nand_bbt_set(ra, block, tag);
-++
-++	return 0;
-++}
-++
-++#if defined (WORKAROUND_RX_BUF_OV)
-++/**
-++ * to find a bad block for ecc verify of read_page
-++ */
-++unsigned int nand_bbt_find_sandbox(struct ra_nand_chip *ra)
-++{
-++	loff_t offs = 0;
-++	int chipsize = 1 << ra->chip_shift;
-++	int blocksize = 1 << ra->erase_shift;
-++
-++
-++	while (offs < chipsize) {
-++		if (nand_block_checkbad(ra, offs)) //scan and verify the unknown tag
-++			break;
-++		offs += blocksize;
-++	}
-++
-++	if (offs >= chipsize) {
-++		offs = chipsize - blocksize;
-++	}
-++
-++	ra_nand_bbt_set(ra, (unsigned int)offs>>ra->erase_shift, BBT_TAG_RES);	 // tag bbt only, instead of update badblockpos of flash.
-++	return (offs >> ra->page_shift);
-++}
-++#endif
-++
-++/**
-++ * nand_erase_nand - [Internal] erase block(s)
-++ * @mtd:	MTD device structure
-++ * @instr:	erase instruction
-++ * @allowbbt:	allow erasing the bbt area
-++ *
-++ * Erase one ore more blocks
-++ */
-++static int _nand_erase_nand(struct ra_nand_chip *ra, struct erase_info *instr)
-++{
-++	int page, len, status, ret, state;
-++	unsigned int addr, blocksize = 1<<ra->erase_shift;
-++
-++	ra_dbg("%s: start:%x, len:%x \n", __func__,
-++	       (unsigned int)instr->addr, (unsigned int)instr->len);
-++
-++//#define BLOCK_ALIGNED(a) ((a) & (blocksize - 1)) // already defined
-++
-++	if (BLOCK_ALIGNED(instr->addr) || BLOCK_ALIGNED(instr->len)) {
-++		ra_dbg("%s: erase block not aligned, addr:%x len:%x\n", __func__, instr->addr, instr->len);
-++		return -EINVAL;
-++	}
-++
-++	instr->fail_addr = 0xffffffff;
-++
-++	len = instr->len;
-++	addr = instr->addr;
-++	state = MTD_ERASING;
-++
-++	while (len) {
-++
-++		page = (int)(addr >> ra->page_shift);
-++
-++		/* select device and check wp */
-++		if (nfc_enable_chip(ra, addr, 0)) {
-++			printk("%s: nand is write protected \n", __func__);
-++			state = MTD_ERASE_FAILED;
-++			goto erase_exit;
-++		}
-++
-++		/* if we have a bad block, we do not erase bad blocks */
-++		if (nand_block_checkbad(ra, addr)) {
-++			printk(KERN_WARNING "nand_erase: attempt to erase a "
-++			       "bad block at 0x%08x\n", addr);
-++			state = MTD_ERASE_FAILED;
-++			goto erase_exit;
-++		}
-++
-++		/*
-++		 * Invalidate the page cache, if we erase the block which
-++		 * contains the current cached page
-++		 */
-++		if (BLOCK_ALIGNED(addr) == BLOCK_ALIGNED(ra->buffers_page << ra->page_shift))
-++			ra->buffers_page = -1;
-++
-++		status = nfc_erase_block(ra, page);
-++		/* See if block erase succeeded */
-++		if (status) {
-++			printk("%s: failed erase, page 0x%08x\n", __func__, page);
-++			state = MTD_ERASE_FAILED;
-++			instr->fail_addr = (page << ra->page_shift);
-++			goto erase_exit;
-++		}
-++
-++		/* Increment page address and decrement length */
-++		len -= blocksize;
-++		addr += blocksize;
-++
-++	}
-++	state = MTD_ERASE_DONE;
-++
-++erase_exit:
-++
-++	ret = ((state == MTD_ERASE_DONE) ? 0 : -EIO);
-++
-++	if (ret) {
-++		ra_nand_bbt_set(ra, addr >> ra->erase_shift, BBT_TAG_BAD);
-++	}
-++
-++	/* Return more or less happy */
-++	return ret;
-++}
-++
-++static int
-++nand_write_oob_buf(struct ra_nand_chip *ra, uint8_t *buf, uint8_t *oob, size_t size,
-++                   int mode, int ooboffs)
-++{
-++	size_t oobsize = 1<<ra->oob_shift;
-++	struct nand_oobfree *free;
-++	uint32_t woffs = ooboffs;
-++	int retsize = 0;
-++
-++	ra_dbg("%s: size:%x, mode:%x, offs:%x  \n", __func__, size, mode, ooboffs);
-++
-++	switch(mode) {
-++	case MTD_OPS_PLACE_OOB:
-++	case MTD_OPS_RAW:
-++		if (ooboffs > oobsize)
-++			return -1;
-++
-++		size = min(size, oobsize - ooboffs);
-++		memcpy(buf + ooboffs, oob, size);
-++		retsize = size;
-++		break;
-++
-++	case MTD_OPS_AUTO_OOB:
-++		if (ooboffs > ra->oob->oobavail)
-++			return -1;
-++
-++		while (size) {
-++			for(free = ra->oob->oobfree; free->length && size; free++) {
-++				int wlen = free->length - woffs;
-++				int bytes = 0;
-++
-++				/* Write request not from offset 0 ? */
-++				if (wlen <= 0) {
-++					woffs = -wlen;
-++					continue;
-++				}
-++
-++				bytes = min_t(size_t, size, wlen);
-++				memcpy (buf + free->offset + woffs, oob, bytes);
-++				woffs = 0;
-++				oob += bytes;
-++				size -= bytes;
-++				retsize += bytes;
-++			}
-++			buf += oobsize;
-++		}
-++		break;
-++
-++	default:
-++		BUG();
-++	}
-++
-++	return retsize;
-++}
-++
-++static int nand_read_oob_buf(struct ra_nand_chip *ra, uint8_t *oob, size_t size,
-++                             int mode, int ooboffs)
-++{
-++	size_t oobsize = 1<<ra->oob_shift;
-++	uint8_t *buf = ra->buffers + (1<<ra->page_shift);
-++	int retsize=0;
-++
-++	ra_dbg("%s: size:%x, mode:%x, offs:%x  \n", __func__, size, mode, ooboffs);
-++
-++	switch(mode) {
-++	case MTD_OPS_PLACE_OOB:
-++	case MTD_OPS_RAW:
-++		if (ooboffs > oobsize)
-++			return -1;
-++
-++		size = min(size, oobsize - ooboffs);
-++		memcpy(oob, buf + ooboffs, size);
-++		return size;
-++
-++	case MTD_OPS_AUTO_OOB: {
-++		struct nand_oobfree *free;
-++		uint32_t woffs = ooboffs;
-++
-++		if (ooboffs > ra->oob->oobavail)
-++			return -1;
-++
-++		size = min(size, ra->oob->oobavail - ooboffs);
-++		for(free = ra->oob->oobfree; free->length && size; free++) {
-++			int wlen = free->length - woffs;
-++			int bytes = 0;
-++
-++			/* Write request not from offset 0 ? */
-++			if (wlen <= 0) {
-++				woffs = -wlen;
-++				continue;
-++			}
-++
-++			bytes = min_t(size_t, size, wlen);
-++			memcpy (oob, buf + free->offset + woffs, bytes);
-++			woffs = 0;
-++			oob += bytes;
-++			size -= bytes;
-++			retsize += bytes;
-++		}
-++		return retsize;
-++	}
-++	default:
-++		BUG();
-++	}
-++
-++	return -1;
-++}
-++
-++/**
-++ * nand_do_write_ops - [Internal] NAND write with ECC
-++ * @mtd:	MTD device structure
-++ * @to:		offset to write to
-++ * @ops:	oob operations description structure
-++ *
-++ * NAND write with ECC
-++ */
-++static int nand_do_write_ops(struct ra_nand_chip *ra, loff_t to,
-++                             struct mtd_oob_ops *ops)
-++{
-++	int page;
-++	uint32_t datalen = ops->len;
-++	uint32_t ooblen = ops->ooblen;
-++	uint8_t *oob = ops->oobbuf;
-++	uint8_t *data = ops->datbuf;
-++	int pagesize = (1<<ra->page_shift);
-++	int pagemask = (pagesize -1);
-++	int oobsize = 1<<ra->oob_shift;
-++	loff_t addr = to;
-++	//int i = 0; //for ra_dbg only
-++
-++	ra_dbg("%s: to:%x, ops data:%p, oob:%p datalen:%x ooblen:%x, ooboffs:%x oobmode:%x \n",
-++	       __func__, (unsigned int)to, data, oob, datalen, ooblen, ops->ooboffs, ops->mode);
-++
-++	ops->retlen = 0;
-++	ops->oobretlen = 0;
-++
-++
-++	/* Invalidate the page cache, when we write to the cached page */
-++	ra->buffers_page = -1;
-++
-++
-++	if (data ==0)
-++		datalen = 0;
-++
-++	// oob sequential (burst) write
-++	if (datalen == 0 && ooblen) {
-++		int len = ((ooblen + ops->ooboffs) + (ra->oob->oobavail - 1)) / ra->oob->oobavail * oobsize;
-++
-++		/* select chip, and check if it is write protected */
-++		if (nfc_enable_chip(ra, addr, 0))
-++			return -EIO;
-++
-++		//FIXME, need sanity check of block boundary
-++		page = (int)((to & ((1<<ra->chip_shift)-1)) >> ra->page_shift); //chip boundary
-++		memset(ra->buffers, 0x0ff, pagesize);
-++		//fixme, should we reserve the original content?
-++		if (ops->mode == MTD_OPS_AUTO_OOB) {
-++			nfc_read_oob(ra, page, 0, ra->buffers, len, FLAG_NONE);
-++		}
-++		//prepare buffers
-++		if (ooblen != 8)
-++		{
-++			nand_write_oob_buf(ra, ra->buffers, oob, ooblen, ops->mode, ops->ooboffs);
-++			// write out buffer to chip
-++			nfc_write_oob(ra, page, 0, ra->buffers, len, FLAG_USE_GDMA);
-++		}
-++
-++		ops->oobretlen = ooblen;
-++		ooblen = 0;
-++	}
-++
-++	// data sequential (burst) write
-++	if (datalen && ooblen == 0) {
-++		// ranfc can not support write_data_burst, since hw-ecc and fifo constraints..
-++	}
-++
-++	// page write
-++	while(datalen || ooblen) {
-++		int len;
-++		int ret;
-++		int offs;
-++		int ecc_en = 0;
-++
-++		ra_dbg("%s (%d): addr:%x, ops data:%p, oob:%p datalen:%x ooblen:%x, ooboffs:%x \n",
-++		       __func__, i++, (unsigned int)addr, data, oob, datalen, ooblen, ops->ooboffs);
-++
-++		page = (int)((addr & ((1<<ra->chip_shift)-1)) >> ra->page_shift); //chip boundary
-++
-++		/* select chip, and check if it is write protected */
-++		if (nfc_enable_chip(ra, addr, 0))
-++			return -EIO;
-++
-++		// oob write
-++		if (ops->mode == MTD_OPS_AUTO_OOB) {
-++			//fixme, this path is not yet varified
-++			nfc_read_oob(ra, page, 0, ra->buffers + pagesize, oobsize, FLAG_NONE);
-++		}
-++		if (oob && ooblen > 0) {
-++			len = nand_write_oob_buf(ra, ra->buffers + pagesize, oob, ooblen, ops->mode, ops->ooboffs);
-++			if (len < 0)
-++				return -EINVAL;
-++
-++			oob += len;
-++			ops->oobretlen += len;
-++			ooblen -= len;
-++		}
-++
-++		// data write
-++		offs = addr & pagemask;
-++		len = min_t(size_t, datalen, pagesize - offs);
-++		if (data && len > 0) {
-++			memcpy(ra->buffers + offs, data, len);	// we can not sure ops->buf wether is DMA-able.
-++
-++			data += len;
-++			datalen -= len;
-++			ops->retlen += len;
-++
-++			ecc_en = FLAG_ECC_EN;
-++		}
-++		ret = nfc_write_page(ra, ra->buffers, page, FLAG_USE_GDMA | FLAG_VERIFY |
-++		                     ((ops->mode == MTD_OPS_RAW || ops->mode == MTD_OPS_PLACE_OOB) ? 0 : ecc_en ));
-++		if (ret) {
-++			ra_nand_bbt_set(ra, addr >> ra->erase_shift, BBT_TAG_BAD);
-++			return ret;
-++		}
-++
-++		ra_nand_bbt_set(ra, addr >> ra->erase_shift, BBT_TAG_GOOD);
-++
-++		addr = (page+1) << ra->page_shift;
-++
-++	}
-++	return 0;
-++}
-++
-++/**
-++ * nand_do_read_ops - [Internal] Read data with ECC
-++ *
-++ * @mtd:	MTD device structure
-++ * @from:	offset to read from
-++ * @ops:	oob ops structure
-++ *
-++ * Internal function. Called with chip held.
-++ */
-++static int nand_do_read_ops(struct ra_nand_chip *ra, loff_t from,
-++                            struct mtd_oob_ops *ops)
-++{
-++	int page;
-++	uint32_t datalen = ops->len;
-++	uint32_t ooblen = ops->ooblen;
-++	uint8_t *oob = ops->oobbuf;
-++	uint8_t *data = ops->datbuf;
-++	int pagesize = (1<<ra->page_shift);
-++	int pagemask = (pagesize -1);
-++	loff_t addr = from;
-++	//int i = 0; //for ra_dbg only
-++
-++	ra_dbg("%s: addr:%x, ops data:%p, oob:%p datalen:%x ooblen:%x, ooboffs:%x \n",
-++	       __func__, (unsigned int)addr, data, oob, datalen, ooblen, ops->ooboffs);
-++
-++	ops->retlen = 0;
-++	ops->oobretlen = 0;
-++	if (data == 0)
-++		datalen = 0;
-++
-++
-++	while(datalen || ooblen) {
-++		int len;
-++		int ret;
-++		int offs;
-++
-++		ra_dbg("%s (%d): addr:%x, ops data:%p, oob:%p datalen:%x ooblen:%x, ooboffs:%x \n",
-++		       __func__, i++, (unsigned int)addr, data, oob, datalen, ooblen, ops->ooboffs);
-++		/* select chip */
-++		if (nfc_enable_chip(ra, addr, 1) < 0)
-++			return -EIO;
-++
-++		page = (int)((addr & ((1<<ra->chip_shift)-1)) >> ra->page_shift);
-++
-++		ret = nfc_read_page(ra, ra->buffers, page, FLAG_VERIFY |
-++		                    ((ops->mode == MTD_OPS_RAW || ops->mode == MTD_OPS_PLACE_OOB) ? 0: FLAG_ECC_EN ));
-++		//FIXME, something strange here, some page needs 2 more tries to guarantee read success.
-++		if (ret) {
-++			printk("read again:\n");
-++			ret = nfc_read_page(ra, ra->buffers, page, FLAG_VERIFY |
-++			                    ((ops->mode == MTD_OPS_RAW || ops->mode == MTD_OPS_PLACE_OOB) ? 0: FLAG_ECC_EN ));
-++
-++			if (ret) {
-++				printk("read again fail \n");
-++				ra_nand_bbt_set(ra, addr >> ra->erase_shift, BBT_TAG_BAD);
-++				if ((ret != -EUCLEAN) && (ret != -EBADMSG)) {
-++					return ret;
-++				}
-++				else {
-++					/* ecc verification fail, but data need to be returned. */
-++				}
-++			}
-++			else {
-++				printk(" read agian susccess \n");
-++			}
-++		}
-++
-++		// oob read
-++		if (oob && ooblen > 0) {
-++			len = nand_read_oob_buf(ra, oob, ooblen, ops->mode, ops->ooboffs);
-++			if (len < 0) {
-++				printk("nand_read_oob_buf: fail return %x \n", len);
-++				return -EINVAL;
-++			}
-++
-++			oob += len;
-++			ops->oobretlen += len;
-++			ooblen -= len;
-++		}
-++
-++		// data read
-++		offs = addr & pagemask;
-++		len = min_t(size_t, datalen, pagesize - offs);
-++		if (data && len > 0) {
-++			memcpy(data, ra->buffers + offs, len);	// we can not sure ops->buf wether is DMA-able.
-++
-++			data += len;
-++			datalen -= len;
-++			ops->retlen += len;
-++			if (ret)
-++				return ret;
-++		}
-++
-++
-++		ra_nand_bbt_set(ra, addr >> ra->erase_shift, BBT_TAG_GOOD);
-++		// address go further to next page, instead of increasing of length of write. This avoids some special cases wrong.
-++		addr = (page+1) << ra->page_shift;
-++	}
-++	return 0;
-++}
-++
-++static int
-++ramtd_nand_erase(struct mtd_info *mtd, struct erase_info *instr)
-++{
-++	struct ra_nand_chip *ra = (struct ra_nand_chip *)mtd->priv;
-++	int ret;
-++
-++	ra_dbg("%s: start:%x, len:%x \n", __func__,
-++	       (unsigned int)instr->addr, (unsigned int)instr->len);
-++
-++	nand_get_device(ra, FL_ERASING);
-++	ret = _nand_erase_nand((struct ra_nand_chip *)mtd->priv, instr);
-++	nand_release_device(ra);
-++
-++	return ret;
-++}
-++
-++static int
-++ramtd_nand_write(struct mtd_info *mtd, loff_t to, size_t len,
-++                 size_t *retlen, const uint8_t *buf)
-++{
-++	struct ra_nand_chip *ra = mtd->priv;
-++	struct mtd_oob_ops ops;
-++	int ret;
-++
-++	ra_dbg("%s: to 0x%x len=0x%x\n", __func__, to, len);
-++
-++	if ((to + len) > mtd->size)
-++		return -EINVAL;
-++
-++	if (!len)
-++		return 0;
-++
-++	nand_get_device(ra, FL_WRITING);
-++
-++	memset(&ops, 0, sizeof(ops));
-++	ops.len = len;
-++	ops.datbuf = (uint8_t *)buf;
-++	ops.oobbuf = NULL;
-++	ops.mode =  MTD_OPS_AUTO_OOB;
-++
-++	ret = nand_do_write_ops(ra, to, &ops);
-++
-++	*retlen = ops.retlen;
-++
-++	nand_release_device(ra);
-++
-++	return ret;
-++}
-++
-++static int
-++ramtd_nand_read(struct mtd_info *mtd, loff_t from, size_t len,
-++                size_t *retlen, uint8_t *buf)
-++{
-++	struct ra_nand_chip *ra = mtd->priv;
-++	int ret;
-++	struct mtd_oob_ops ops;
-++
-++	ra_dbg("%s: mtd:%p from:%x, len:%x, buf:%p \n", __func__, mtd, (unsigned int)from, len, buf);
-++
-++	/* Do not allow reads past end of device */
-++	if ((from + len) > mtd->size)
-++		return -EINVAL;
-++	if (!len)
-++		return 0;
-++
-++	nand_get_device(ra, FL_READING);
-++
-++	memset(&ops, 0, sizeof(ops));
-++	ops.len = len;
-++	ops.datbuf = buf;
-++	ops.oobbuf = NULL;
-++	ops.mode = MTD_OPS_AUTO_OOB;
-++
-++	ret = nand_do_read_ops(ra, from, &ops);
-++
-++	*retlen = ops.retlen;
-++
-++	nand_release_device(ra);
-++
-++	return ret;
-++}
-++
-++static int
-++ramtd_nand_readoob(struct mtd_info *mtd, loff_t from,
-++                   struct mtd_oob_ops *ops)
-++{
-++	struct ra_nand_chip *ra = mtd->priv;
-++	int ret;
-++
-++	ra_dbg("%s: \n", __func__);
-++
-++	nand_get_device(ra, FL_READING);
-++
-++	ret = nand_do_read_ops(ra, from, ops);
-++
-++	nand_release_device(ra);
-++
-++	return ret;
-++}
-++
-++static int
-++ramtd_nand_writeoob(struct mtd_info *mtd, loff_t to,
-++                    struct mtd_oob_ops *ops)
-++{
-++	struct ra_nand_chip *ra = mtd->priv;
-++	int ret;
-++
-++	nand_get_device(ra, FL_READING);
-++	ret = nand_do_write_ops(ra, to, ops);
-++	nand_release_device(ra);
-++
-++	return ret;
-++}
-++
-++static int
-++ramtd_nand_block_isbad(struct mtd_info *mtd, loff_t offs)
-++{
-++	if (offs > mtd->size)
-++		return -EINVAL;
-++
-++	return nand_block_checkbad((struct ra_nand_chip *)mtd->priv, offs);
-++}
-++
-++static int
-++ramtd_nand_block_markbad(struct mtd_info *mtd, loff_t ofs)
-++{
-++	struct ra_nand_chip *ra = mtd->priv;
-++	int ret;
-++
-++	ra_dbg("%s: \n", __func__);
-++	nand_get_device(ra, FL_WRITING);
-++	ret = nand_block_markbad(ra, ofs);
-++	nand_release_device(ra);
-++
-++	return ret;
-++}
-++
-++// 1-bit error detection
-++static int one_bit_correction(char *ecc1, char *ecc2, int *bytes, int *bits)
-++{
-++	// check if ecc and expected are all valid
-++	char *p, nibble, crumb;
-++	int i, xor, iecc1 = 0, iecc2 = 0;
-++
-++	printk("correction : %x %x %x\n", ecc1[0], ecc1[1], ecc1[2]);
-++	printk("correction : %x %x %x\n", ecc2[0], ecc2[1], ecc2[2]);
-++
-++	p = (char *)ecc1;
-++	for (i = 0; i < CONFIG_ECC_BYTES; i++)
-++	{
-++		nibble = *(p+i) & 0xf;
-++		if ((nibble != 0x0) && (nibble != 0xf) && (nibble != 0x3) && (nibble != 0xc) &&
-++		        (nibble != 0x5) && (nibble != 0xa) && (nibble != 0x6) && (nibble != 0x9))
-++			return -1;
-++		nibble = ((*(p+i)) >> 4) & 0xf;
-++		if ((nibble != 0x0) && (nibble != 0xf) && (nibble != 0x3) && (nibble != 0xc) &&
-++		        (nibble != 0x5) && (nibble != 0xa) && (nibble != 0x6) && (nibble != 0x9))
-++			return -1;
-++	}
-++
-++	p = (char *)ecc2;
-++	for (i = 0; i < CONFIG_ECC_BYTES; i++)
-++	{
-++		nibble = *(p+i) & 0xf;
-++		if ((nibble != 0x0) && (nibble != 0xf) && (nibble != 0x3) && (nibble != 0xc) &&
-++		        (nibble != 0x5) && (nibble != 0xa) && (nibble != 0x6) && (nibble != 0x9))
-++			return -1;
-++		nibble = ((*(p+i)) >> 4) & 0xf;
-++		if ((nibble != 0x0) && (nibble != 0xf) && (nibble != 0x3) && (nibble != 0xc) &&
-++		        (nibble != 0x5) && (nibble != 0xa) && (nibble != 0x6) && (nibble != 0x9))
-++			return -1;
-++	}
-++
-++	memcpy(&iecc1, ecc1, 3);
-++	memcpy(&iecc2, ecc2, 3);
-++
-++	xor = iecc1 ^ iecc2;
-++	printk("xor = %x (%x %x)\n", xor, iecc1, iecc2);
-++
-++	*bytes = 0;
-++	for (i = 0; i < 9; i++)
-++	{
-++		crumb = (xor >> (2*i)) & 0x3;
-++		if ((crumb == 0x0) || (crumb == 0x3))
-++			return -1;
-++		if (crumb == 0x2)
-++			*bytes += (1 << i);
-++	}
-++
-++	*bits = 0;
-++	for (i = 0; i < 3; i++)
-++	{
-++		crumb = (xor >> (18 + 2*i)) & 0x3;
-++		if ((crumb == 0x0) || (crumb == 0x3))
-++			return -1;
-++		if (crumb == 0x2)
-++			*bits += (1 << i);
-++	}
-++
-++	return 0;
-++}
-++
-++/************************************************************
-++ * the init/exit section.
-++ */
-++
-++static struct nand_ecclayout ra_oob_layout = {
-++	.eccbytes = CONFIG_ECC_BYTES,
-++	.eccpos = {5, 6, 7},
-++	.oobfree = {
-++		{.offset = 0, .length = 4},
-++		{.offset = 8, .length = 8},
-++		{.offset = 0, .length = 0}
-++	},
-++#define RA_CHIP_OOB_AVAIL (4+8)
-++	.oobavail = RA_CHIP_OOB_AVAIL,
-++	// 5th byte is bad-block flag.
-++};
-++
-++static int
-++mtk_nand_probe(struct platform_device *pdev)
-++{
-++	struct mtd_part_parser_data ppdata;
-++	struct ra_nand_chip *ra;
-++	int alloc_size, bbt_size, buffers_size, reg, err;
-++	unsigned char chip_mode = 12;
-++
-++	/*	if(ra_check_flash_type()!=BOOT_FROM_NAND) {
-++			return 0;
-++		}*/
-++
-++	//FIXME: config 512 or 2048-byte page according to HWCONF
-++#if defined (CONFIG_SOC_MT7620)
-++	ra_outl(RALINK_SYSCTL_BASE+0x60, ra_inl(RALINK_SYSCTL_BASE+0x60) & ~(0x3<<18));
-++	reg = ra_inl(RALINK_SYSCTL_BASE+0x10);
-++	chip_mode = (reg & 0x0F);
-++	if((chip_mode==1)||(chip_mode==11)) {
-++		ra_or(NFC_CONF1, 1);
-++		is_nand_page_2048 = 1;
-++		nand_addrlen = ((chip_mode!=11) ? 4 : 5);
-++		printk("!!! nand page size = 2048, addr len=%d\n", nand_addrlen);
-++	}
-++	else {
-++		ra_and(NFC_CONF1, ~1);
-++		is_nand_page_2048 = 0;
-++		nand_addrlen = ((chip_mode!=10) ? 3 : 4);
-++		printk("!!! nand page size = 512, addr len=%d\n", nand_addrlen);
-++	}
-++#else
-++	is_nand_page_2048 = 0;
-++	nand_addrlen = 3;
-++	printk("!!! nand page size = 512, addr len=%d\n", nand_addrlen);
-++#endif
-++
-++#if defined (CONFIG_SOC_MT7620)
-++	//config ECC location
-++	ra_and(NFC_CONF1, 0xfff000ff);
-++	ra_or(NFC_CONF1, ((CONFIG_ECC_OFFSET + 2) << 16) +
-++	      ((CONFIG_ECC_OFFSET + 1) << 12) +
-++	      (CONFIG_ECC_OFFSET << 8));
-++#endif
-++
-++#define ALIGNE_16(a) (((unsigned long)(a)+15) & ~15)
-++	buffers_size = ALIGNE_16((1<<CONFIG_PAGE_SIZE_BIT) + (1<<CONFIG_OOBSIZE_PER_PAGE_BIT)); //ra->buffers
-++	bbt_size = BBTTAG_BITS * (1<<(CONFIG_CHIP_SIZE_BIT - (CONFIG_PAGE_SIZE_BIT + CONFIG_NUMPAGE_PER_BLOCK_BIT))) / 8; //ra->bbt
-++	bbt_size = ALIGNE_16(bbt_size);
-++
-++	alloc_size = buffers_size + bbt_size;
-++	alloc_size += buffers_size; //for ra->readback_buffers
-++	alloc_size += sizeof(*ra);
-++	alloc_size += sizeof(*ranfc_mtd);
-++
-++	//make sure gpio-0 is input
-++	ra_outl(RALINK_PIO_BASE+0x24, ra_inl(RALINK_PIO_BASE+0x24) & ~0x01);
-++
-++	ra = (struct ra_nand_chip *)kzalloc(alloc_size, GFP_KERNEL | GFP_DMA);
-++	if (!ra) {
-++		printk("%s: mem alloc fail \n", __func__);
-++		return -ENOMEM;
-++	}
-++	memset(ra, 0, alloc_size);
-++
-++	//dynamic
-++	ra->buffers = (char *)((char *)ra + sizeof(*ra));
-++	ra->readback_buffers = ra->buffers + buffers_size;
-++	ra->bbt = ra->readback_buffers + buffers_size;
-++	ranfc_mtd = (struct mtd_info *)(ra->bbt + bbt_size);
-++
-++	//static
-++	ra->numchips		= CONFIG_NUMCHIPS;
-++	ra->chip_shift		= CONFIG_CHIP_SIZE_BIT;
-++	ra->page_shift		= CONFIG_PAGE_SIZE_BIT;
-++	ra->oob_shift		= CONFIG_OOBSIZE_PER_PAGE_BIT;
-++	ra->erase_shift		= (CONFIG_PAGE_SIZE_BIT + CONFIG_NUMPAGE_PER_BLOCK_BIT);
-++	ra->badblockpos		= CONFIG_BAD_BLOCK_POS;
-++	ra_oob_layout.eccpos[0] = CONFIG_ECC_OFFSET;
-++	ra_oob_layout.eccpos[1] = CONFIG_ECC_OFFSET + 1;
-++	ra_oob_layout.eccpos[2] = CONFIG_ECC_OFFSET + 2;
-++	ra->oob			= &ra_oob_layout;
-++	ra->buffers_page	= -1;
-++
-++#if defined (WORKAROUND_RX_BUF_OV)
-++	if (ranfc_verify) {
-++		ra->sandbox_page = nand_bbt_find_sandbox(ra);
-++	}
-++#endif
-++	ra_outl(NFC_CTRL, ra_inl(NFC_CTRL) | 0x01); //set wp to high
-++	nfc_all_reset();
-++
-++	ranfc_mtd->type		= MTD_NANDFLASH;
-++	ranfc_mtd->flags	= MTD_CAP_NANDFLASH;
-++	ranfc_mtd->size		= CONFIG_NUMCHIPS * CFG_CHIPSIZE;
-++	ranfc_mtd->erasesize	= CFG_BLOCKSIZE;
-++	ranfc_mtd->writesize	= CFG_PAGESIZE;
-++	ranfc_mtd->writebufsize = ranfc_mtd->writesize;
-++	ranfc_mtd->oobsize 	= CFG_PAGE_OOBSIZE;
-++	ranfc_mtd->oobavail	= RA_CHIP_OOB_AVAIL;
-++	ranfc_mtd->name		= "ra_nfc";
-++	//ranfc_mtd->index
-++	//ranfc_mtd->ecclayout	= &ra_oob_layout;
-++	//ranfc_mtd->numberaseregions
-++	//ranfc_mtd->eraseregions
-++	//ranfc_mtd->bansize
-++	ranfc_mtd->_erase 	= ramtd_nand_erase;
-++	//ranfc_mtd->point
-++	//ranfc_mtd->unpoint
-++	ranfc_mtd->_read		= ramtd_nand_read;
-++	ranfc_mtd->_write	= ramtd_nand_write;
-++	//ranfc_mtd->_read_oob	= ramtd_nand_readoob;
-++	//ranfc_mtd->_write_oob	= ramtd_nand_writeoob;
-++	//ranfc_mtd->get_fact_prot_info; ranfc_mtd->read_fact_prot_reg;
-++	//ranfc_mtd->get_user_prot_info; ranfc_mtd->read_user_prot_reg;
-++	//ranfc_mtd->write_user_prot_reg; ranfc_mtd->lock_user_prot_reg;
-++	//ranfc_mtd->writev; ranfc_mtd->sync; ranfc_mtd->lock; ranfc_mtd->unlock; ranfc_mtd->suspend; ranfc_mtd->resume;
-++	ranfc_mtd->_block_isbad		= ramtd_nand_block_isbad;
-++	ranfc_mtd->_block_markbad	= ramtd_nand_block_markbad;
-++	//ranfc_mtd->reboot_notifier
-++	//ranfc_mtd->ecc_stats;
-++	// subpage_sht;
-++
-++	//ranfc_mtd->get_device; ranfc_mtd->put_device
-++	ranfc_mtd->priv = ra;
-++
-++	ranfc_mtd->owner = THIS_MODULE;
-++	ra->controller = &ra->hwcontrol;
-++	mutex_init(ra->controller);
-++
-++	printk("%s: alloc %x, at %p , btt(%p, %x), ranfc_mtd:%p\n",
-++	       __func__, alloc_size, ra, ra->bbt, bbt_size, ranfc_mtd);
-++
-++	mtd_set_of_node(ranfc_mtd, pdev->dev.of_node);
-++	err = mtd_device_parse_register(ranfc_mtd, mtk_probe_types,
-++	                                &ppdata, NULL, 0);
-++
-++	return err;
-++}
-++
-++static int
-++mtk_nand_remove(struct platform_device *pdev)
-++{
-++	struct ra_nand_chip *ra;
-++
-++	if (ranfc_mtd) {
-++		ra = (struct ra_nand_chip  *)ranfc_mtd->priv;
-++
-++		/* Deregister partitions */
-++		//del_mtd_partitions(ranfc_mtd);
-++		kfree(ra);
-++	}
-++	return 0;
-++}
-++
-++static const struct of_device_id mtk_nand_match[] = {
-++	{ .compatible = "mtk,mt7620-nand" },
-++	{},
-++};
-++MODULE_DEVICE_TABLE(of, mtk_nand_match);
-++
-++static struct platform_driver mtk_nand_driver = {
-++	.probe = mtk_nand_probe,
-++	.remove = mtk_nand_remove,
-++	.driver = {
-++		.name = "mt7620_nand",
-++		.owner = THIS_MODULE,
-++		.of_match_table = mtk_nand_match,
-++	},
-++};
-++
-++module_platform_driver(mtk_nand_driver);
-++
-++MODULE_LICENSE("GPL");
-+--- /dev/null
-++++ b/drivers/mtd/maps/ralink_nand.h
-+@@ -0,0 +1,240 @@
-++#ifndef RT2880_NAND_H
-++#define RT2880_NAND_H
-++
-++#include <linux/mtd/mtd.h>
-++
-++#define MTD_ERASE_PENDING	0x01
-++#define MTD_ERASING		0x02
-++#define MTD_ERASE_SUSPEND	0x04
-++#define MTD_ERASE_DONE		0x08
-++#define MTD_ERASE_FAILED	0x10
-++
-++#define MTD_FAIL_ADDR_UNKNOWN -1LL
-++
-++//#include "gdma.h"
-++
-++#define RALINK_SYSCTL_BASE		0xB0000000
-++#define RALINK_PIO_BASE			0xB0000600
-++#define RALINK_NAND_CTRL_BASE		0xB0000810
-++#define CONFIG_RALINK_MT7620
-++
-++#define SKIP_BAD_BLOCK
-++//#define RANDOM_GEN_BAD_BLOCK
-++
-++#define ra_inl(addr)  (*(volatile unsigned int *)(addr))
-++#define ra_outl(addr, value)  (*(volatile unsigned int *)(addr) = (value))
-++#define ra_aor(addr, a_mask, o_value)  ra_outl(addr, (ra_inl(addr) & (a_mask)) | (o_value))
-++#define ra_and(addr, a_mask)  ra_aor(addr, a_mask, 0)
-++#define ra_or(addr, o_value)  ra_aor(addr, -1, o_value)
-++
-++
-++#define CONFIG_NUMCHIPS 1
-++#define CONFIG_NOT_SUPPORT_WP //rt3052 has no WP signal for chip.
-++//#define CONFIG_NOT_SUPPORT_RB
-++
-++extern int is_nand_page_2048;
-++extern const unsigned int nand_size_map[2][3];
-++
-++//chip
-++// chip geometry: SAMSUNG small size 32MB.
-++#define CONFIG_CHIP_SIZE_BIT (nand_size_map[is_nand_page_2048][nand_addrlen-3]) //! (1<<NAND_SIZE_BYTE) MB
-++//#define CONFIG_CHIP_SIZE_BIT (is_nand_page_2048? 29 : 25)	//! (1<<NAND_SIZE_BYTE) MB
-++#define CONFIG_PAGE_SIZE_BIT (is_nand_page_2048? 11 : 9)	//! (1<<PAGE_SIZE) MB
-++//#define CONFIG_SUBPAGE_BIT 1		//! these bits will be compensate by command cycle
-++#define CONFIG_NUMPAGE_PER_BLOCK_BIT (is_nand_page_2048? 6 : 5)	//! order of number of pages a block.
-++#define CONFIG_OOBSIZE_PER_PAGE_BIT (is_nand_page_2048? 6 : 4)	//! byte number of oob a page.
-++#define CONFIG_BAD_BLOCK_POS (is_nand_page_2048? 0 : 4)     //! offset of byte to denote bad block.
-++#define CONFIG_ECC_BYTES 3      //! ecc has 3 bytes
-++#define CONFIG_ECC_OFFSET (is_nand_page_2048? 6 : 5)        //! ecc starts from offset 5.
-++
-++//this section should not be modified.
-++//#define CFG_COLUMN_ADDR_MASK ((1 << (CONFIG_PAGE_SIZE_BIT - CONFIG_SUBPAGE_BIT)) - 1)
-++//#define CFG_COLUMN_ADDR_CYCLE (((CONFIG_PAGE_SIZE_BIT - CONFIG_SUBPAGE_BIT) + 7)/8)
-++//#define CFG_ROW_ADDR_CYCLE ((CONFIG_CHIP_SIZE_BIT - CONFIG_PAGE_SIZE_BIT + 7)/8)
-++//#define CFG_ADDR_CYCLE (CFG_COLUMN_ADDR_CYCLE + CFG_ROW_ADDR_CYCLE)
-++
-++#define CFG_COLUMN_ADDR_CYCLE   (is_nand_page_2048? 2 : 1)
-++#define CFG_ROW_ADDR_CYCLE      (nand_addrlen - CFG_COLUMN_ADDR_CYCLE)
-++#define CFG_ADDR_CYCLE (CFG_COLUMN_ADDR_CYCLE + CFG_ROW_ADDR_CYCLE)
-++
-++#define CFG_CHIPSIZE    (1 << ((CONFIG_CHIP_SIZE_BIT>=32)? 31 : CONFIG_CHIP_SIZE_BIT))
-++//#define CFG_CHIPSIZE  	(1 << CONFIG_CHIP_SIZE_BIT)
-++#define CFG_PAGESIZE	(1 << CONFIG_PAGE_SIZE_BIT)
-++#define CFG_BLOCKSIZE 	(CFG_PAGESIZE << CONFIG_NUMPAGE_PER_BLOCK_BIT)
-++#define CFG_NUMPAGE	(1 << (CONFIG_CHIP_SIZE_BIT - CONFIG_PAGE_SIZE_BIT))
-++#define CFG_NUMBLOCK	(CFG_NUMPAGE >> CONFIG_NUMPAGE_PER_BLOCK_BIT)
-++#define CFG_BLOCK_OOBSIZE	(1 << (CONFIG_OOBSIZE_PER_PAGE_BIT + CONFIG_NUMPAGE_PER_BLOCK_BIT))
-++#define CFG_PAGE_OOBSIZE	(1 << CONFIG_OOBSIZE_PER_PAGE_BIT)
-++
-++#define NAND_BLOCK_ALIGN(addr) ((addr) & (CFG_BLOCKSIZE-1))
-++#define NAND_PAGE_ALIGN(addr) ((addr) & (CFG_PAGESIZE-1))
-++
-++
-++#define NFC_BASE 	RALINK_NAND_CTRL_BASE
-++#define NFC_CTRL	(NFC_BASE + 0x0)
-++#define NFC_CONF	(NFC_BASE + 0x4)
-++#define NFC_CMD1	(NFC_BASE + 0x8)
-++#define NFC_CMD2	(NFC_BASE + 0xc)
-++#define NFC_CMD3	(NFC_BASE + 0x10)
-++#define NFC_ADDR	(NFC_BASE + 0x14)
-++#define NFC_DATA	(NFC_BASE + 0x18)
-++#if defined (CONFIG_RALINK_RT6855) || defined (CONFIG_RALINK_RT6855A) || \
-++	defined (CONFIG_RALINK_MT7620) || defined (CONFIG_RALINK_MT7621)
-++#define NFC_ECC		(NFC_BASE + 0x30)
-++#else
-++#define NFC_ECC		(NFC_BASE + 0x1c)
-++#endif
-++#define NFC_STATUS	(NFC_BASE + 0x20)
-++#define NFC_INT_EN	(NFC_BASE + 0x24)
-++#define NFC_INT_ST	(NFC_BASE + 0x28)
-++#if defined (CONFIG_RALINK_RT6855) || defined (CONFIG_RALINK_RT6855A) || \
-++	defined (CONFIG_RALINK_MT7620) || defined (CONFIG_RALINK_MT7621)
-++#define NFC_CONF1	(NFC_BASE + 0x2c)
-++#define NFC_ECC_P1	(NFC_BASE + 0x30)
-++#define NFC_ECC_P2	(NFC_BASE + 0x34)
-++#define NFC_ECC_P3	(NFC_BASE + 0x38)
-++#define NFC_ECC_P4	(NFC_BASE + 0x3c)
-++#define NFC_ECC_ERR1	(NFC_BASE + 0x40)
-++#define NFC_ECC_ERR2	(NFC_BASE + 0x44)
-++#define NFC_ECC_ERR3	(NFC_BASE + 0x48)
-++#define NFC_ECC_ERR4	(NFC_BASE + 0x4c)
-++#define NFC_ADDR2	(NFC_BASE + 0x50)
-++#endif
-++
-++enum _int_stat {
-++	INT_ST_ND_DONE 	= 1<<0,
-++	INT_ST_TX_BUF_RDY       = 1<<1,
-++	INT_ST_RX_BUF_RDY	= 1<<2,
-++	INT_ST_ECC_ERR		= 1<<3,
-++	INT_ST_TX_TRAS_ERR	= 1<<4,
-++	INT_ST_RX_TRAS_ERR	= 1<<5,
-++	INT_ST_TX_KICK_ERR	= 1<<6,
-++	INT_ST_RX_KICK_ERR      = 1<<7
-++};
-++
-++
-++//#define WORKAROUND_RX_BUF_OV 1
-++
-++
-++/*************************************************************
-++ * stolen from nand.h
-++ *************************************************************/
-++
-++/*
-++ * Standard NAND flash commands
-++ */
-++#define NAND_CMD_READ0		0
-++#define NAND_CMD_READ1		1
-++#define NAND_CMD_RNDOUT		5
-++#define NAND_CMD_PAGEPROG	0x10
-++#define NAND_CMD_READOOB	0x50
-++#define NAND_CMD_ERASE1		0x60
-++#define NAND_CMD_STATUS		0x70
-++#define NAND_CMD_STATUS_MULTI	0x71
-++#define NAND_CMD_SEQIN		0x80
-++#define NAND_CMD_RNDIN		0x85
-++#define NAND_CMD_READID		0x90
-++#define NAND_CMD_ERASE2		0xd0
-++#define NAND_CMD_RESET		0xff
-++
-++/* Extended commands for large page devices */
-++#define NAND_CMD_READSTART	0x30
-++#define NAND_CMD_RNDOUTSTART	0xE0
-++#define NAND_CMD_CACHEDPROG	0x15
-++
-++/* Extended commands for AG-AND device */
-++/*
-++ * Note: the command for NAND_CMD_DEPLETE1 is really 0x00 but
-++ *       there is no way to distinguish that from NAND_CMD_READ0
-++ *       until the remaining sequence of commands has been completed
-++ *       so add a high order bit and mask it off in the command.
-++ */
-++#define NAND_CMD_DEPLETE1	0x100
-++#define NAND_CMD_DEPLETE2	0x38
-++#define NAND_CMD_STATUS_MULTI	0x71
-++#define NAND_CMD_STATUS_ERROR	0x72
-++/* multi-bank error status (banks 0-3) */
-++#define NAND_CMD_STATUS_ERROR0	0x73
-++#define NAND_CMD_STATUS_ERROR1	0x74
-++#define NAND_CMD_STATUS_ERROR2	0x75
-++#define NAND_CMD_STATUS_ERROR3	0x76
-++#define NAND_CMD_STATUS_RESET	0x7f
-++#define NAND_CMD_STATUS_CLEAR	0xff
-++
-++#define NAND_CMD_NONE		-1
-++
-++/* Status bits */
-++#define NAND_STATUS_FAIL	0x01
-++#define NAND_STATUS_FAIL_N1	0x02
-++#define NAND_STATUS_TRUE_READY	0x20
-++#define NAND_STATUS_READY	0x40
-++#define NAND_STATUS_WP		0x80
-++
-++typedef enum {
-++	FL_READY,
-++	FL_READING,
-++	FL_WRITING,
-++	FL_ERASING,
-++	FL_SYNCING,
-++	FL_CACHEDPRG,
-++	FL_PM_SUSPENDED,
-++} nand_state_t;
-++
-++/*************************************************************/
-++
-++
-++
-++typedef enum _ra_flags {
-++	FLAG_NONE	= 0,
-++	FLAG_ECC_EN 	= (1<<0),
-++	FLAG_USE_GDMA 	= (1<<1),
-++	FLAG_VERIFY 	= (1<<2),
-++} RA_FLAGS;
-++
-++
-++#define BBTTAG_BITS		2
-++#define BBTTAG_BITS_MASK	((1<<BBTTAG_BITS) -1)
-++enum BBT_TAG {
-++	BBT_TAG_UNKNOWN = 0, //2'b01
-++	BBT_TAG_GOOD	= 3, //2'b11
-++	BBT_TAG_BAD	= 2, //2'b10
-++	BBT_TAG_RES	= 1, //2'b01
-++};
-++
-++struct ra_nand_chip {
-++	int	numchips;
-++	int 	chip_shift;
-++	int	page_shift;
-++	int 	erase_shift;
-++	int 	oob_shift;
-++	int	badblockpos;
-++#if !defined (__UBOOT__)
-++	struct mutex hwcontrol;
-++	struct mutex *controller;
-++#endif
-++	struct nand_ecclayout	*oob;
-++	int 	state;
-++	unsigned int 	buffers_page;
-++	char	*buffers; //[CFG_PAGESIZE + CFG_PAGE_OOBSIZE];
-++	char 	*readback_buffers;
-++	unsigned char 	*bbt;
-++#if defined (WORKAROUND_RX_BUF_OV)
-++	unsigned int	 sandbox_page;	// steal a page (block) for read ECC verification
-++#endif
-++
-++};
-++
-++
-++
-++//fixme, gdma api
-++int nand_dma_sync(void);
-++void release_dma_buf(void);
-++int set_gdma_ch(unsigned long dst,
-++                unsigned long src, unsigned int len, int burst_size,
-++                int soft_mode, int src_req_type, int dst_req_type,
-++                int src_burst_mode, int dst_burst_mode);
-++
-++
-++
-++
-++#endif

+ 1 - 1
devices/ramips_mt7621/diy.sh

@@ -3,7 +3,7 @@
 shopt -s extglob
 
 SHELL_FOLDER=$(dirname $(readlink -f "$0"))
-#bash $SHELL_FOLDER/../common/kernel_5.15.sh
+
 
 sed -i "s/DEVICE_MODEL := HC5962$/DEVICE_MODEL := HC5962 \/ B70/" target/linux/ramips/image/mt7621.mk
 

+ 128 - 0
devices/ramips_mt7621/patches/01-small_flash.patch

@@ -0,0 +1,128 @@
+From f4b61c1960aa885d7de2953a36d9efacbf6e5406 Mon Sep 17 00:00:00 2001
+From: kiddin9 <[email protected]>
+Date: Sat, 27 May 2023 03:53:49 +0800
+Subject: [PATCH] Update mt7621.mk
+
+Signed-off-by: kiddin9 <[email protected]>
+---
+ target/linux/ramips/image/mt7621.mk | 18 +++++++++---------
+ 1 file changed, 9 insertions(+), 9 deletions(-)
+
+diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk
+index 2697f84bf7684..df8c7d233cf1e 100644
+--- a/target/linux/ramips/image/mt7621.mk
++++ b/target/linux/ramips/image/mt7621.mk
+@@ -330,7 +330,7 @@ define Device/asus_rt-n56u-b1
+   DEVICE_VARIANT := B1
+   IMAGE_SIZE := 16064k
+   DEVICE_PACKAGES := kmod-mt7603 kmod-mt76x2 kmod-usb3 \
+-	kmod-usb-ledtrig-usbport -uboot-envtools
++	kmod-usb-ledtrig-usbport -uboot-envtools wpad-mini -wpad-basic-mbedtls -coremark -htop -bash -openssh-sftp-server
+ endef
+ TARGET_DEVICES += asus_rt-n56u-b1
+ 
+@@ -1327,7 +1327,7 @@ define Device/jcg_y2
+   JCG_MAXSIZE := 16064k
+   DEVICE_VENDOR := JCG
+   DEVICE_MODEL := Y2
+-  DEVICE_PACKAGES := kmod-mt7615-firmware kmod-usb3 -uboot-envtools
++  DEVICE_PACKAGES := kmod-mt7615-firmware kmod-usb3 -uboot-envtools wpad-mini -wpad-basic-mbedtls -coremark -htop -bash -openssh-sftp-server
+ endef
+ TARGET_DEVICES += jcg_y2
+ 
+@@ -1784,7 +1784,7 @@ define Device/netgear_wndr3700-v5
+   SERCOMM_SWVER := 0x1054
+   SERCOMM_PAD := 320k
+   DEVICE_PACKAGES := kmod-mt7603 kmod-mt76x2 kmod-usb3 \
+-	kmod-usb-ledtrig-usbport -uboot-envtools
++	kmod-usb-ledtrig-usbport -uboot-envtools wpad-mini -wpad-basic-mbedtls -coremark -htop -bash -openssh-sftp-server
+   SUPPORTED_DEVICES += wndr3700v5
+ endef
+ TARGET_DEVICES += netgear_wndr3700-v5
+@@ -1812,7 +1812,7 @@ define Device/oraybox_x3a
+   IMAGE_SIZE := 15360k
+   DEVICE_VENDOR := OrayBox
+   DEVICE_MODEL := X3A
+-  DEVICE_PACKAGES := kmod-mt7615-firmware -uboot-envtools
++  DEVICE_PACKAGES := kmod-mt7615-firmware -uboot-envtools wpad-mini -wpad-basic-mbedtls -coremark -htop -bash -openssh-sftp-server
+ endef
+ TARGET_DEVICES += oraybox_x3a
+ 
+@@ -1824,7 +1824,7 @@ define Device/phicomm_k2p
+   DEVICE_ALT0_VENDOR := Phicomm
+   DEVICE_ALT0_MODEL := KE 2P
+   SUPPORTED_DEVICES += k2p
+-  DEVICE_PACKAGES := kmod-mt7615-firmware -uboot-envtools
++  DEVICE_PACKAGES := kmod-mt7615-firmware -uboot-envtools wpad-mini -wpad-basic-mbedtls -coremark -htop -bash -openssh-sftp-server
+ endef
+ TARGET_DEVICES += phicomm_k2p
+ 
+@@ -1988,7 +1988,7 @@ define Device/thunder_timecloud
+   IMAGE_SIZE := 16064k
+   DEVICE_VENDOR := Thunder
+   DEVICE_MODEL := Timecloud
+-  DEVICE_PACKAGES := kmod-usb3 -wpad-basic-mbedtls -uboot-envtools
++  DEVICE_PACKAGES := kmod-usb3 -wpad-basic-mbedtls -uboot-envtools -bash -openssh-sftp-server -coremark -htop
+   SUPPORTED_DEVICES += timecloud
+ endef
+ TARGET_DEVICES += thunder_timecloud
+@@ -2445,11 +2445,11 @@ TARGET_DEVICES += xiaomi_mi-router-3g
+ define Device/xiaomi_mi-router-3g-v2
+   $(Device/dsa-migration)
+   $(Device/uimage-lzma-loader)
+-  IMAGE_SIZE := 14848k
++  IMAGE_SIZE := 16064k
+   DEVICE_VENDOR := Xiaomi
+   DEVICE_MODEL := Mi Router 3G
+   DEVICE_VARIANT := v2
+-  DEVICE_PACKAGES := kmod-mt7603 kmod-mt76x2 -uboot-envtools
++  DEVICE_PACKAGES := kmod-mt7603 kmod-mt76x2 -uboot-envtools wpad-mini -wpad-basic-mbedtls -coremark -htop -bash -openssh-sftp-server
+   SUPPORTED_DEVICES += xiaomi,mir3g-v2
+ endef
+ TARGET_DEVICES += xiaomi_mi-router-3g-v2
+@@ -2479,23 +2479,23 @@ TARGET_DEVICES += xiaomi_mi-router-4
+ define Device/xiaomi_mi-router-4a-gigabit
+   $(Device/dsa-migration)
+   $(Device/uimage-lzma-loader)
+-  IMAGE_SIZE := 14848k
++  IMAGE_SIZE := 16064k
+   DEVICE_VENDOR := Xiaomi
+   DEVICE_MODEL := Mi Router 4A
+   DEVICE_VARIANT := Gigabit Edition
+-  DEVICE_PACKAGES := kmod-mt7603 kmod-mt76x2 -uboot-envtools
++  DEVICE_PACKAGES := kmod-mt7603 kmod-mt76x2 -uboot-envtools wpad-mini -wpad-basic-mbedtls -coremark -htop -bash -openssh-sftp-server
+ endef
+ TARGET_DEVICES += xiaomi_mi-router-4a-gigabit
+ 
+ define Device/xiaomi_mi-router-4a-gigabit-v2
+   $(Device/dsa-migration)
+   $(Device/uimage-lzma-loader)
+-  IMAGE_SIZE := 14784k
++  IMAGE_SIZE := 16064k
+   DEVICE_VENDOR := Xiaomi
+   DEVICE_MODEL := Mi Router 4A
+   DEVICE_VARIANT := Gigabit Edition v2
+   DEVICE_PACKAGES := kmod-mt7603 kmod-mt7615e kmod-mt7663-firmware-ap \
+-	-uboot-envtools
++	-uboot-envtools wpad-mini -wpad-basic-mbedtls -coremark -htop -bash -openssh-sftp-server
+ endef
+ TARGET_DEVICES += xiaomi_mi-router-4a-gigabit-v2
+ 
+@@ -2570,7 +2570,7 @@ define Device/youhua_wr1200js
+   DEVICE_VENDOR := YouHua
+   DEVICE_MODEL := WR1200JS
+   DEVICE_PACKAGES := kmod-mt7603 kmod-mt76x2 kmod-usb3 \
+-	kmod-usb-ledtrig-usbport -uboot-envtools
++	kmod-usb-ledtrig-usbport -uboot-envtools wpad-mini -wpad-basic-mbedtls -coremark -htop -bash -openssh-sftp-server
+ endef
+ TARGET_DEVICES += youhua_wr1200js
+ 
+@@ -2580,7 +2580,7 @@ define Device/youku_yk-l2
+   DEVICE_VENDOR := Youku
+   DEVICE_MODEL := YK-L2
+   DEVICE_PACKAGES := kmod-mt7603 kmod-mt76x2 kmod-usb3 \
+-	kmod-usb-ledtrig-usbport -uboot-envtools
++	kmod-usb-ledtrig-usbport -uboot-envtools wpad-mini -wpad-basic-mbedtls -coremark -htop -bash -openssh-sftp-server
+   UIMAGE_MAGIC := 0x12291000
+   UIMAGE_NAME := 400000000000000000003000
+ endef

+ 0 - 503
devices/ramips_mt7621/patches/02-4a-v2.patch

@@ -1,503 +0,0 @@
-From 5dd566ff99d17b2c7e459001b4750bc911ee0d4c Mon Sep 17 00:00:00 2001
-From: Dmitry Sokolov <[email protected]>
-Date: Mon, 16 Jan 2023 02:52:27 +0500
-Subject: [PATCH] ramips: mt7621: add support for Xiaomi Mi Router 4A Gigabit
- v2
-
-Device is the same as Xiaomi Mi Router 4A Gigabit, except of:
-- 5G WiFi is MT7663
-- addresses of leds, wifi and eth ports are slightly changed
-
-Specs:
-  SoC:  MT7621
-  CPU:  2 x 880 MHz
-  ROM:  16 MB
-  RAM:  128 MB
-  WLAN: MT7603, MT7663
-
-MAC addresses:
-  WAN     ****  factory 0xe006 (label)
-  LAN     *:f7  factory 0xe000
-  2.4 GHz *:f8  factory 0x0000+0x4 (mtd-eeprom+0x4)
-  5 GHz   *:f9  factory 0x8000+0x4 (mtd-eeprom+0x4)
-
-Installation:
-
-Factory firmware is based on a custom OpenWrt 17.x.
-Installation is the same as for Xiaomi Mi Router 4A Gigabit.
-
-Probably the easiest way to install is to use the script from
-this repository: https://github.com/acecilia/OpenWRTInvasion/pull/155
-
-In a more advanced case, you can do everything yourself:
-- gain access to the device through one of the exploits described
-  in the link above
-- upload sysupgrade image to /tmp
-- overwrite stock firmware:
-  # mtd -e OS1 -r write /tmp/sysupgrade.bin OS1
-
-Recovery:
-
-Recovery procedure is the same as for Xiaomi Mi Router 4A Gigabit.
-Possible options can be found here:
-https://openwrt.org/inbox/toh/xiaomi/xiaomi_mi_router_4a_gigabit_edition
-
-One of the ways is to use another router with OpenWrt:
-- connect both routers by their LAN ports
-- download stock firmware from [1]
-- place it inside /tmp/test.bin on the main router
-- configure PXE/TFTP on the main router
-- power off 4Av2, hold Reset button, power on
-- as soon as image download via TFTP starts, Reset can be released
-- blinking blue wan LED will indicate the end of the flashing process,
-  now router can be rebooted
-[1] http://cdn.cnbj1.fds.api.mi-img.com/xiaoqiang/rom/r4av2/miwifi_r4av2_firmware_release_2.30.28.bin
-
-Signed-off-by: Dmitry Sokolov <[email protected]>
----
- .../dts/mt7621_xiaomi_mi-router-4a-3g-v2.dtsi | 138 +-----------------
- .../mt7621_xiaomi_mi-router-4a-common.dtsi    | 138 ++++++++++++++++++
- .../mt7621_xiaomi_mi-router-4a-gigabit-v2.dts |  80 ++++++++++
- target/linux/ramips/image/mt7621.mk           |  11 ++
- .../mt7621/base-files/etc/board.d/01_leds     |   3 +
- .../mt7621/base-files/etc/board.d/02_network  |   3 +-
- 6 files changed, 241 insertions(+), 132 deletions(-)
- create mode 100644 target/linux/ramips/dts/mt7621_xiaomi_mi-router-4a-common.dtsi
- create mode 100644 target/linux/ramips/dts/mt7621_xiaomi_mi-router-4a-gigabit-v2.dts
-
-diff --git a/target/linux/ramips/dts/mt7621_xiaomi_mi-router-4a-3g-v2.dtsi b/target/linux/ramips/dts/mt7621_xiaomi_mi-router-4a-3g-v2.dtsi
-index a0ee79ae23ce4..d05872337be26 100644
---- a/target/linux/ramips/dts/mt7621_xiaomi_mi-router-4a-3g-v2.dtsi
-+++ b/target/linux/ramips/dts/mt7621_xiaomi_mi-router-4a-3g-v2.dtsi
-@@ -1,23 +1,12 @@
- // SPDX-License-Identifier: GPL-2.0-or-later OR MIT
- 
--#include "mt7621.dtsi"
--
--#include <dt-bindings/gpio/gpio.h>
--#include <dt-bindings/input/input.h>
-+#include "mt7621_xiaomi_mi-router-4a-common.dtsi"
- 
- / {
- 	aliases {
--		led-boot = &led_status_yellow;
--		led-failsafe = &led_status_yellow;
--		led-running = &led_status_blue;
--		led-upgrade = &led_status_yellow;
- 		label-mac-device = &wan;
- 	};
- 
--	chosen {
--		bootargs = "console=ttyS0,115200n8";
--	};
--
- 	leds {
- 		compatible = "gpio-leds";
- 
-@@ -31,108 +20,16 @@
- 			gpios = <&gpio 10 GPIO_ACTIVE_LOW>;
- 		};
- 	};
--
--	keys {
--		compatible = "gpio-keys";
--
--		reset {
--			label = "reset";
--			gpios = <&gpio 18 GPIO_ACTIVE_LOW>;
--			linux,code = <KEY_RESTART>;
--		};
--	};
- };
- 
--&spi0 {
--	status = "okay";
--
--	flash@0 {
--		compatible = "jedec,spi-nor";
--		reg = <0>;
--		spi-max-frequency = <50000000>;
--		m25p,fast-read;
--
--		partitions {
--			compatible = "fixed-partitions";
--			#address-cells = <1>;
--			#size-cells = <1>;
--
--			partition@0 {
--				label = "u-boot";
--				reg = <0x0 0x30000>;
--				read-only;
--			};
--
--			partition@30000 {
--				label = "u-boot-env";
--				reg = <0x30000 0x10000>;
--				read-only;
--			};
--
--			partition@40000 {
--				label = "Bdata";
--				reg = <0x40000 0x10000>;
--				read-only;
--			};
--
--			factory: partition@50000 {
--				label = "factory";
--				reg = <0x50000 0x10000>;
--				read-only;
--			};
--
--			partition@60000 {
--				label = "crash";
--				reg = <0x60000 0x10000>;
--				read-only;
--			};
--
--			partition@70000 {
--				label = "cfg_bak";
--				reg = <0x70000 0x10000>;
--				read-only;
--			};
--
--			partition@80000 {
--				label = "overlay";
--				reg = <0x80000 0x100000>;
--				read-only;
--			};
--
--			firmware: partition@180000 {
--				compatible = "denx,uimage";
--				label = "firmware";
--				reg = <0x180000 0xe80000>;
--			};
--		};
--	};
-+&wifi0 {
-+	mediatek,mtd-eeprom = <&factory 0x8000>;
-+	ieee80211-freq-limit = <5000000 6000000>;
- };
- 
--&pcie {
--	status = "okay";
--};
--
--&pcie0 {
--	wifi@0,0 {
--		compatible = "pci14c3,7662";
--		reg = <0x0000 0 0 0 0>;
--		mediatek,mtd-eeprom = <&factory 0x8000>;
--		ieee80211-freq-limit = <5000000 6000000>;
--	};
--};
--
--&pcie1 {
--	wifi@0,0 {
--		compatible = "pci14c3,7603";
--		reg = <0x0000 0 0 0 0>;
--		mediatek,mtd-eeprom = <&factory 0x0000>;
--		ieee80211-freq-limit = <2400000 2500000>;
--	};
--};
--
--&gmac0 {
--	nvmem-cells = <&macaddr_factory_e000>;
--	nvmem-cell-names = "mac-address";
-+&wifi1 {
-+	mediatek,mtd-eeprom = <&factory 0x0000>;
-+	ieee80211-freq-limit = <2400000 2500000>;
- };
- 
- &switch0 {
-@@ -163,24 +60,3 @@
- 		};
- 	};
- };
--
--&state_default {
--	gpio {
--		groups = "jtag", "uart2", "uart3", "wdt";
--		function = "gpio";
--	};
--};
--
--&factory {
--	compatible = "nvmem-cells";
--	#address-cells = <1>;
--	#size-cells = <1>;
--
--	macaddr_factory_e000: macaddr@e000 {
--		reg = <0xe000 0x6>;
--	};
--
--	macaddr_factory_e006: macaddr@e006 {
--		reg = <0xe006 0x6>;
--	};
--};
-diff --git a/target/linux/ramips/dts/mt7621_xiaomi_mi-router-4a-common.dtsi b/target/linux/ramips/dts/mt7621_xiaomi_mi-router-4a-common.dtsi
-new file mode 100644
-index 0000000000000..efc32733e9bc1
---- /dev/null
-+++ b/target/linux/ramips/dts/mt7621_xiaomi_mi-router-4a-common.dtsi
-@@ -0,0 +1,138 @@
-+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
-+
-+#include "mt7621.dtsi"
-+
-+#include <dt-bindings/gpio/gpio.h>
-+#include <dt-bindings/input/input.h>
-+
-+/ {
-+	aliases {
-+		led-boot = &led_status_yellow;
-+		led-failsafe = &led_status_yellow;
-+		led-running = &led_status_blue;
-+		led-upgrade = &led_status_yellow;
-+	};
-+
-+	chosen {
-+		bootargs = "console=ttyS0,115200n8";
-+	};
-+
-+	keys {
-+		compatible = "gpio-keys";
-+
-+		reset {
-+			label = "reset";
-+			gpios = <&gpio 18 GPIO_ACTIVE_LOW>;
-+			linux,code = <KEY_RESTART>;
-+		};
-+	};
-+};
-+
-+&spi0 {
-+	status = "okay";
-+
-+	flash@0 {
-+		compatible = "jedec,spi-nor";
-+		reg = <0>;
-+		spi-max-frequency = <50000000>;
-+		m25p,fast-read;
-+
-+		partitions: partitions {
-+			compatible = "fixed-partitions";
-+			#address-cells = <1>;
-+			#size-cells = <1>;
-+
-+			partition@0 {
-+				label = "u-boot";
-+				reg = <0x0 0x30000>;
-+				read-only;
-+			};
-+
-+			partition@30000 {
-+				label = "u-boot-env";
-+				reg = <0x30000 0x10000>;
-+				read-only;
-+			};
-+
-+			partition@40000 {
-+				label = "Bdata";
-+				reg = <0x40000 0x10000>;
-+				read-only;
-+			};
-+
-+			factory: partition@50000 {
-+				label = "factory";
-+				reg = <0x50000 0x10000>;
-+				read-only;
-+			};
-+
-+			partition@60000 {
-+				label = "crash";
-+				reg = <0x60000 0x10000>;
-+				read-only;
-+			};
-+
-+			partition@70000 {
-+				label = "cfg_bak";
-+				reg = <0x70000 0x10000>;
-+				read-only;
-+			};
-+
-+			partition@80000 {
-+				label = "overlay";
-+				reg = <0x80000 0x100000>;
-+				read-only;
-+			};
-+
-+			firmware: partition@180000 {
-+				compatible = "denx,uimage";
-+				label = "firmware";
-+				reg = <0x180000 0xe80000>;
-+			};
-+		};
-+	};
-+};
-+
-+&pcie {
-+	status = "okay";
-+};
-+
-+&pcie0 {
-+	wifi0: wifi@0,0 {
-+		compatible = "mediatek,mt76";
-+		reg = <0x0000 0 0 0 0>;
-+	};
-+};
-+
-+&pcie1 {
-+	wifi1: wifi@0,0 {
-+		compatible = "mediatek,mt76";
-+		reg = <0x0000 0 0 0 0>;
-+	};
-+};
-+
-+&gmac0 {
-+	nvmem-cells = <&macaddr_factory_e000>;
-+	nvmem-cell-names = "mac-address";
-+};
-+
-+&state_default {
-+	gpio {
-+		groups = "jtag", "uart2", "uart3", "wdt";
-+		function = "gpio";
-+	};
-+};
-+
-+&factory {
-+	compatible = "nvmem-cells";
-+	#address-cells = <1>;
-+	#size-cells = <1>;
-+
-+	macaddr_factory_e000: macaddr@e000 {
-+		reg = <0xe000 0x6>;
-+	};
-+
-+	macaddr_factory_e006: macaddr@e006 {
-+		reg = <0xe006 0x6>;
-+	};
-+};
-diff --git a/target/linux/ramips/dts/mt7621_xiaomi_mi-router-4a-gigabit-v2.dts b/target/linux/ramips/dts/mt7621_xiaomi_mi-router-4a-gigabit-v2.dts
-new file mode 100644
-index 0000000000000..67ff6ea11e161
---- /dev/null
-+++ b/target/linux/ramips/dts/mt7621_xiaomi_mi-router-4a-gigabit-v2.dts
-@@ -0,0 +1,67 @@
-+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
-+
-+#include "mt7621_xiaomi_mi-router-4a-common.dtsi"
-+
-+/ {
-+	compatible = "xiaomi,mi-router-4a-gigabit-v2", "mediatek,mt7621-soc";
-+	model = "Xiaomi Mi Router 4A Gigabit Edition v2";
-+
-+	aliases {
-+		label-mac-device = &wan;
-+	};
-+
-+	leds {
-+		compatible = "gpio-leds";
-+
-+		led_status_blue: status_blue {
-+			label = "blue:status";
-+			gpios = <&gpio 13 GPIO_ACTIVE_LOW>;
-+		};
-+
-+		led_status_yellow: status_yellow {
-+			label = "yellow:status";
-+			gpios = <&gpio 15 GPIO_ACTIVE_LOW>;
-+		};
-+
-+		wan_blue {
-+			label = "blue:wan";
-+			gpios = <&gpio 14 GPIO_ACTIVE_LOW>;
-+		};
-+
-+		wan_yellow {
-+			label = "yellow:wan";
-+			gpios = <&gpio 16 GPIO_ACTIVE_LOW>;
-+		};
-+	};
-+};
-+
-+&wifi0 {
-+	mediatek,mtd-eeprom = <&factory 0x0000>;
-+	ieee80211-freq-limit = <2400000 2500000>;
-+};
-+
-+&wifi1 {
-+	mediatek,mtd-eeprom = <&factory 0x8000>;
-+	ieee80211-freq-limit = <5000000 6000000>;
-+};
-+
-+&switch0 {
-+	ports {
-+		port@1 {
-+			status = "okay";
-+			label = "lan1";
-+		};
-+
-+		port@2 {
-+			status = "okay";
-+			label = "lan2";
-+		};
-+
-+		wan: port@3 {
-+			status = "okay";
-+			label = "wan";
-+			nvmem-cells = <&macaddr_factory_e006>;
-+			nvmem-cell-names = "mac-address";
-+		};
-+	};
-+};
-diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk
-index 9d01399c5cc3c..6871243a5f6c6 100644
---- a/target/linux/ramips/image/mt7621.mk
-+++ b/target/linux/ramips/image/mt7621.mk
-@@ -2427,6 +2427,17 @@ define Device/xiaomi_mi-router-4a-gigabit
- endef
- TARGET_DEVICES += xiaomi_mi-router-4a-gigabit
- 
-+define Device/xiaomi_mi-router-4a-gigabit-v2
-+  $(Device/dsa-migration)
-+  $(Device/uimage-lzma-loader)
-+  IMAGE_SIZE := 16064k
-+  DEVICE_VENDOR := Xiaomi
-+  DEVICE_MODEL := Mi Router 4A
-+  DEVICE_VARIANT := Gigabit Edition v2
-+  DEVICE_PACKAGES := kmod-mt7603 kmod-mt7615e kmod-mt7663-firmware-ap wpad-mini -wpad-basic-wolfssl -coremark -htop -bash -openssh-sftp-server
-+endef
-+TARGET_DEVICES += xiaomi_mi-router-4a-gigabit-v2
-+
- define Device/xiaomi_mi-router-ac2100
-   $(Device/xiaomi_nand_separate)
-   DEVICE_MODEL := Mi Router AC2100
-diff --git a/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds b/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds
-index 91f3fe6e93c13..597d7302ac88e 100644
---- a/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds
-+++ b/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds
-@@ -179,6 +179,9 @@ tplink,re650-v2)
- tplink,tl-wpa8631p-v3)
- 	ucidef_set_led_netdev "lan" "LAN" "green:lan" "br-lan"
- 	;;
-+xiaomi,mi-router-4a-gigabit-v2)
-+	ucidef_set_led_netdev "wan" "wan" "blue:wan" "wan" "link"
-+	;;
- xiaomi,mi-router-ac2100)
- 	ucidef_set_led_netdev "wan-blue" "WAN (blue)" "blue:wan" "wan"
- 	;;
-diff --git a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network
-index ddbbf9891d63a..67f58b10b2715 100644
---- a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network
-+++ b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network
-@@ -72,7 +72,8 @@ ramips_setup_interfaces()
- 	xiaomi,mi-router-3g|\
- 	xiaomi,mi-router-3g-v2|\
- 	xiaomi,mi-router-4|\
--	xiaomi,mi-router-4a-gigabit)
-+	xiaomi,mi-router-4a-gigabit|\
-+	xiaomi,mi-router-4a-gigabit-v2)
- 		ucidef_set_interfaces_lan_wan "lan1 lan2" "wan"
- 		;;
- 	bolt,arion)

+ 72 - 123
devices/ramips_mt7621/patches/01-cr660x.patch → devices/ramips_mt7621/patches/02-cr660x.patch

@@ -1,39 +1,19 @@
-From 593d238ebf777c36c9ee819a1e20f59da5adc361 Mon Sep 17 00:00:00 2001
-From: kiddin9 <[email protected]>
-Date: Tue, 5 Jul 2022 17:54:53 +0800
-Subject: [PATCH] Update mt7621.mk
-
-Signed-off-by: kiddin9 <[email protected]>
----
- target/linux/ramips/image/mt7621.mk | 46 +++++++++--------------------
- 1 file changed, 14 insertions(+), 32 deletions(-)
-
-diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk
-index bdaeac2cb16e..72fbd3930a80 100644
 --- a/target/linux/ramips/image/mt7621.mk
 +++ b/target/linux/ramips/image/mt7621.mk
-@@ -223,7 +223,7 @@ define Device/asus_rt-n56u-b1
-   DEVICE_VARIANT := B1
-   IMAGE_SIZE := 16064k
-   DEVICE_PACKAGES := kmod-mt7603 kmod-mt76x2 kmod-usb3 \
--	kmod-usb-ledtrig-usbport
-+	kmod-usb-ledtrig-usbport wpad-mini -wpad-basic-wolfssl -coremark -htop -bash -openssh-sftp-server
- endef
- TARGET_DEVICES += asus_rt-n56u-b1
- 
-@@ -984,7 +984,7 @@ define Device/jcg_y2
-   JCG_MAXSIZE := 16064k
-   DEVICE_VENDOR := JCG
-   DEVICE_MODEL := Y2
--  DEVICE_PACKAGES := kmod-mt7615e kmod-mt7615-firmware kmod-usb3
-+  DEVICE_PACKAGES := kmod-mt7615e kmod-mt7615-firmware kmod-usb3 wpad-mini -wpad-basic-wolfssl -coremark -htop -bash -openssh-sftp-server
- endef
- TARGET_DEVICES += jcg_y2
- 
-@@ -1000,6 +1000,16 @@ define Device/lenovo_newifi-d1
+@@ -157,6 +157,65 @@ define Device/nand
+   IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
  endef
- TARGET_DEVICES += lenovo_newifi-d1
  
++define Device/phicomm_k2p-32m
++  IMAGE_SIZE := 32128k
++  DEVICE_VENDOR := Phicomm
++  DEVICE_MODEL := K2P
++  DEVICE_VARIANT := 32M
++  SUPPORTED_DEVICES += k2p-32M
++  DEVICE_PACKAGES := kmod-mt7615e kmod-mt7615-firmware
++endef
++TARGET_DEVICES += phicomm_k2p-32m
++
 +define Device/jdcloud_re-sp-01b
 +  $(Device/dsa-migration)
 +  $(Device/uimage-lzma-loader)
@@ -42,84 +22,70 @@ index bdaeac2cb16e..72fbd3930a80 100644
 +  DEVICE_MODEL := RE-SP-01B
 +  DEVICE_PACKAGES := kmod-fs-ext4 kmod-mt7603 kmod-mt7615e kmod-mt7615-firmware kmod-sdhci-mt7620 kmod-usb3
 + endef
-+  TARGET_DEVICES += jdcloud_re-sp-01b
++ TARGET_DEVICES += jdcloud_re-sp-01b
++
++define Device/jdcloud_luban
++  $(Device/dsa-migration)
++  $(Device/uimage-lzma-loader)
++  IMAGE_SIZE := 15808k
++  DEVICE_VENDOR := JDCloud
++  DEVICE_MODEL := Luban 鲁班
++  DEVICE_PACKAGES += kmod-mt7915e uboot-envtools wpad-mini -wpad-basic-mbedtls -coremark -htop -bash -openssh-sftp-server
++endef
++TARGET_DEVICES += jdcloud_luban
 +
- define Device/linksys_e5600
++define Device/zte_e8820s
++  $(Device/dsa-migration)
++  $(Device/uimage-lzma-loader)
++  BLOCKSIZE := 128k
++  PAGESIZE := 2048
++  KERNEL_SIZE := 4096k
++  UBINIZE_OPTS := -E 5
++  IMAGE_SIZE := 130304k
++  IMAGES += factory.bin
++  IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
++  IMAGE/factory.bin := append-kernel | pad-to $$(KERNEL_SIZE) | append-ubi | \
++	check-size
++  DEVICE_VENDOR := ZTE
++  DEVICE_MODEL := E8820S
++  DEVICE_PACKAGES := kmod-mt7603 kmod-mt76x2 kmod-usb3 uboot-envtools
++endef
++TARGET_DEVICES += zte_e8820s
++
++define Device/zte_e8820v2
++  $(Device/dsa-migration)
++  $(Device/uimage-lzma-loader)
++  IMAGE_SIZE := 16064k
++  DEVICE_VENDOR := ZTE
++  DEVICE_MODEL := E8820V2
++  DEVICE_PACKAGES := kmod-mt7603 kmod-mt76x2 kmod-usb2 \
++	kmod-usb-ledtrig-usbport wpad-mini -wpad-basic-mbedtls -coremark -htop -bash -openssh-sftp-server
++endef
++TARGET_DEVICES += zte_e8820v2
++
+ define Device/adslr_g7
    $(Device/dsa-migration)
-   $(Device/uimage-lzma-loader)
-@@ -1369,7 +1379,7 @@ define Device/netgear_wndr3700-v5
-   SERCOMM_SWVER := 0x1054
-   SERCOMM_PAD := 320k
-   DEVICE_PACKAGES := kmod-mt7603 kmod-mt76x2 kmod-usb3 \
--	kmod-usb-ledtrig-usbport
-+	kmod-usb-ledtrig-usbport wpad-mini -wpad-basic-wolfssl -coremark -htop -bash -openssh-sftp-server
-   SUPPORTED_DEVICES += wndr3700v5
- endef
- TARGET_DEVICES += netgear_wndr3700-v5
-@@ -1400,7 +1410,7 @@ define Device/oraybox_x3a
-   IMAGE_SIZE := 15360k
-   DEVICE_VENDOR := OrayBox
-   DEVICE_MODEL := X3A
--  DEVICE_PACKAGES := kmod-mt7615e kmod-mt7615-firmware
-+  DEVICE_PACKAGES := kmod-mt7615e kmod-mt7615-firmware wpad-mini -wpad-basic-wolfssl -coremark -htop -bash -openssh-sftp-server
- endef
- TARGET_DEVICES += oraybox_x3a
- 
-@@ -1412,7 +1422,7 @@ define Device/phicomm_k2p
-   DEVICE_ALT0_VENDOR := Phicomm
-   DEVICE_ALT0_MODEL := KE 2P
-   SUPPORTED_DEVICES += k2p
--  DEVICE_PACKAGES := kmod-mt7615e kmod-mt7615-firmware
-+  DEVICE_PACKAGES := kmod-mt7615e kmod-mt7615-firmware wpad-mini -wpad-basic-wolfssl -coremark -htop -bash -openssh-sftp-server
- endef
- TARGET_DEVICES += phicomm_k2p
- 
-@@ -1533,7 +1543,7 @@ define Device/thunder_timecloud
    IMAGE_SIZE := 16064k
-   DEVICE_VENDOR := Thunder
-   DEVICE_MODEL := Timecloud
--  DEVICE_PACKAGES := kmod-usb3 -wpad-basic-wolfssl
-+  DEVICE_PACKAGES := kmod-usb3 -wpad-basic-wolfssl -bash -openssh-sftp-server -coremark -htop
-   SUPPORTED_DEVICES += timecloud
- endef
- TARGET_DEVICES += thunder_timecloud
-@@ -1843,7 +1853,6 @@ define Device/xiaomi_nand_separate
-   PAGESIZE := 2048
-   KERNEL_SIZE := 4096k
-   UBINIZE_OPTS := -E 5
+@@ -2427,7 +2486,6 @@ define Device/xiaomi_nand_separate
+   $(Device/nand)
+   $(Device/uimage-lzma-loader)
+   DEVICE_VENDOR := Xiaomi
 -  IMAGES += kernel1.bin rootfs0.bin
    IMAGE/kernel1.bin := append-kernel
    IMAGE/rootfs0.bin := append-ubi | check-size
-   IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
-@@ -1866,7 +1875,7 @@ define Device/xiaomi_mi-router-3g-v2
-   DEVICE_VENDOR := Xiaomi
-   DEVICE_MODEL := Mi Router 3G
-   DEVICE_VARIANT := v2
--  DEVICE_PACKAGES := kmod-mt7603 kmod-mt76x2
-+  DEVICE_PACKAGES := kmod-mt7603 kmod-mt76x2 wpad-mini -wpad-basic-wolfssl -coremark -htop -bash -openssh-sftp-server
-   SUPPORTED_DEVICES += xiaomi,mir3g-v2
  endef
- TARGET_DEVICES += xiaomi_mi-router-3g-v2
-@@ -1881,7 +1890,6 @@ define Device/xiaomi_mi-router-3-pro
-   IMAGE_SIZE := 255488k
+@@ -2511,30 +2569,14 @@ define Device/xiaomi_mi-router-cr660x
+   $(Device/nand)
+   $(Device/uimage-lzma-loader)
    DEVICE_VENDOR := Xiaomi
-   DEVICE_MODEL := Mi Router 3 Pro
--  IMAGES += factory.bin
-   IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
-   IMAGE/factory.bin := append-kernel | pad-to $$(KERNEL_SIZE) | append-ubi | \
- 	check-size
-@@ -1927,30 +1935,14 @@ define Device/xiaomi_mi-router-cr660x
-   KERNEL_SIZE := 4096k
-   UBINIZE_OPTS := -E 5
++  DEVICE_MODEL := Mi Router CR660X / TR60X
    IMAGE_SIZE := 128512k
 -  IMAGES += firmware.bin
-+  IMAGES += factory.bin
-   IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
 -  IMAGE/firmware.bin := append-kernel | pad-to $$(KERNEL_SIZE) | append-ubi | \
++  IMAGES += factory.bin
 +  IMAGE/factory.bin := append-kernel | pad-to $$(KERNEL_SIZE) | append-ubi | \
  	check-size
-   DEVICE_PACKAGES += kmod-mt7915e uboot-envtools
-+  DEVICE_MODEL := Mi Router CR660X / TR60X
+   DEVICE_PACKAGES += kmod-mt7915-firmware
  endef
 -
 -define Device/xiaomi_mi-router-cr6606
@@ -142,25 +108,7 @@ index bdaeac2cb16e..72fbd3930a80 100644
 +TARGET_DEVICES += xiaomi_mi-router-cr660x
  
  define Device/xiaomi_redmi-router-ac2100
-   $(Device/xiaomi_nand_separate)
-@@ -1985,7 +1977,7 @@ define Device/youhua_wr1200js
-   DEVICE_VENDOR := YouHua
-   DEVICE_MODEL := WR1200JS
-   DEVICE_PACKAGES := kmod-mt7603 kmod-mt76x2 kmod-usb3 \
--	kmod-usb-ledtrig-usbport
-+	kmod-usb-ledtrig-usbport wpad-mini -wpad-basic-wolfssl -coremark -htop -bash -openssh-sftp-server
- endef
- TARGET_DEVICES += youhua_wr1200js
- 
-@@ -1995,7 +1987,7 @@ define Device/youku_yk-l2
-   DEVICE_VENDOR := Youku
-   DEVICE_MODEL := YK-L2
-   DEVICE_PACKAGES := kmod-mt7603 kmod-mt76x2 kmod-usb3 \
--	kmod-usb-ledtrig-usbport
-+	kmod-usb-ledtrig-usbport wpad-mini -wpad-basic-wolfssl -coremark -htop -bash -openssh-sftp-server
-   UIMAGE_MAGIC := 0x12291000
-   UIMAGE_NAME := 400000000000000000003000
- 
+   $(Device/xiaomi_nand_separate) 
 
 --- /dev/null
 +++ b/target/linux/ramips/dts/mt7621_xiaomi_mi-router-cr660x.dts
@@ -190,29 +138,29 @@ index bdaeac2cb16e..72fbd3930a80 100644
 
 --- a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network
 +++ b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network
-@@ -28,9 +28,7 @@ ramips_setup_interfaces()
- 	hiwifi,hc5962|\
+@@ -48,9 +48,7 @@ ramips_setup_interfaces()
+ 	sim,simax1800t|\
  	xiaomi,mi-router-3-pro|\
  	xiaomi,mi-router-ac2100|\
 -	xiaomi,mi-router-cr6606|\
 -	xiaomi,mi-router-cr6608|\
 -	xiaomi,mi-router-cr6609|\
 +	xiaomi,mi-router-cr660x|\
- 	xiaomi,redmi-router-ac2100)
+ 	xiaomi,redmi-router-ac2100|\
+ 	zyxel,wsm20)
  		ucidef_set_interfaces_lan_wan "lan1 lan2 lan3" "wan"
- 		;;
-@@ -45,6 +43,7 @@ ramips_setup_interfaces()
+@@ -68,6 +66,7 @@ ramips_setup_interfaces()
  	iptime,a3002mesh|\
  	jcg,q20|\
  	lenovo,newifi-d1|\
 +	jdcloud,re-sp-01b|\
  	mikrotik,routerboard-m33g|\
+ 	mts,wg430223|\
  	oraybox,x3a|\
- 	renkforce,ws-wn530hp3-a|\
 
 --- a/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh
 +++ b/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh
-@@ -92,9 +92,7 @@ platform_do_upgrade() {
+@@ -109,9 +109,8 @@ platform_do_upgrade() {
  	xiaomi,mi-router-3-pro|\
  	xiaomi,mi-router-4|\
  	xiaomi,mi-router-ac2100|\
@@ -220,6 +168,7 @@ index bdaeac2cb16e..72fbd3930a80 100644
 -	xiaomi,mi-router-cr6608|\
 -	xiaomi,mi-router-cr6609|\
 +	xiaomi,mi-router-cr660x|\
++	zte,e8820s|\
  	xiaomi,redmi-router-ac2100|\
  	zyxel,nwa50ax|\
  	zyxel,nwa55axe)

+ 1 - 27
devices/ramips_mt7621/patches/03-4a-breed-fix.patch

@@ -44,30 +44,4 @@
 +				reg = <0x50000 0xfb0000>;
  			};
  		};
- 	};
-
---- a/target/linux/ramips/image/mt7621.mk
-+++ b/target/linux/ramips/image/mt7621.mk
-@@ -1963,7 +1963,7 @@ TARGET_DEVICES += xiaomi_mi-router-3g
- define Device/xiaomi_mi-router-3g-v2
-   $(Device/dsa-migration)
-   $(Device/uimage-lzma-loader)
--  IMAGE_SIZE := 14848k
-+  IMAGE_SIZE := 16064k
-   DEVICE_VENDOR := Xiaomi
-   DEVICE_MODEL := Mi Router 3G
-   DEVICE_VARIANT := v2
-@@ -2003,11 +2003,11 @@ TARGET_DEVICES += xiaomi_mi-router-4
- define Device/xiaomi_mi-router-4a-gigabit
-   $(Device/dsa-migration)
-   $(Device/uimage-lzma-loader)
--  IMAGE_SIZE := 14848k
-+  IMAGE_SIZE := 16064k
-   DEVICE_VENDOR := Xiaomi
-   DEVICE_MODEL := Mi Router 4A
-   DEVICE_VARIANT := Gigabit Edition
--  DEVICE_PACKAGES := kmod-mt7603 kmod-mt76x2
-+  DEVICE_PACKAGES := kmod-mt7603 kmod-mt76x2 wpad-mini -wpad-basic-wolfssl -coremark -htop -bash -openssh-sftp-server
- endef
- TARGET_DEVICES += xiaomi_mi-router-4a-gigabit
- 
+ 	};

+ 0 - 432
devices/ramips_mt7621/patches/TX1800.patch

@@ -1,432 +0,0 @@
-From 13308161788c98ae6cd48c22b13339fdb8c77130 Mon Sep 17 00:00:00 2001
-From: Shiji Yang <[email protected]>
-Date: Sun, 20 Mar 2022 23:42:37 +0800
-Subject: [PATCH] ramips: add support for H3C TX1800 Plus / TX1801 Plus /
- TX1806
-
-H3C TX180x series WiFi6 routers are customized by different carrier.
-While these three devices look different, they use the same motherboard
-inside. Another minor difference comes from the model name definition
-in the u-boot environment variable.
-
-Specifications:
- SOC:      MT7621 + MT7915
- ROM:      128 MiB
- RAM:      256 MiB
- LED:      status *2
- Button:   reset *1 + wps/mesh *1
- Ethernet:        lan *3 + wan *1 (10/100/1000Mbps)
- TTL Baudrate:    115200
- TFTP server IP:  192.168.124.99
-
-MAC Address:
- use        address(sample 1)   address(sample 2)    source
- label      88:xx:xx:98:xx:12   88:xx:xx:a2:xx:a5   u-boot-env@ethaddr
- lan        88:xx:xx:98:xx:13   88:xx:xx:a2:xx:a6   $label +1
- wan        88:xx:xx:98:xx:12   88:xx:xx:a2:xx:a5   $label
- WiFi4_2G   8a:xx:xx:58:xx:14   8a:xx:xx:52:xx:a7   (Compatibility mode)
- WiFi5_5G   8a:xx:xx:b8:xx:14   8a:xx:xx:b2:xx:a7   (Compatibility mode)
- WiFi6_2G   8a:xx:xx:18:xx:14   8a:xx:xx:12:xx:a7
- WiFi6_5G   8a:xx:xx:78:xx:14   8a:xx:xx:72:xx:a7
-
-Compatibility mode is used to guarantee the connection of old devices
-that only support WiFi4 or WiFi5.
-
-TFTP + TTL Installation:
-Although a TTL connection is required for installation, we do not need
-to tear down it. We can find the TTL port from the cooling hole at the
-bottom. It is located below LAN3 and the pins are defined as follows:
-|LAN1|LAN2|LAN3|----|WAN|
---------------------
-    |GND|TX|RX|VCC|
-
-1. Set tftp server IP to 192.168.124.99 and put initramfs firmware in
-   server's root directory, rename it to a simple name "initramfs.bin".
-2. Plug in the power supply and wait for power on, connect the TTL cable
-   and open a TTL session, enter "reboot", then enter "Y" to confirm.
-   Finally push "0" to interruput boot while booting.
-3. Execute command to install a initramfs system:
-   # tftp 0x80010000 192.168.124.99:initramfs.bin
-   # bootm 0x80010000
-4. Backup nand flash by OpenWrt LuCI or dd instruction. We need those
-   partitions if we want to back to stock firmwre due to official
-   website does not provide download link.
-   # dd if=/dev/mtd1 of=/tmp/u-boot-env.bin
-   # dd if=/dev/mtd4 of=/tmp/firmware.bin
-5. Edit u-boot env to ensure use default bootargs and first image slot:
-   # fw_setenv bootargs
-   # fw_setenv bootflag 0
-6. Upgrade sysupgrade firmware.
-7. About restore stock firmware: flash the "firmware" and "u-boot-env"
-   partitions that we backed up in step 4.
-   # mtd write /tmp/u-boot-env.bin u-boot-env
-   # mtd write /tmp/firmware.bin firmware
-
-Additional Info:
-The H3C stock firmware has a 160-byte firmware header that appears to
-use a non-standard CRC32 verification algorithm. For this part of the
-data, the u-boot does not check it so we can just directly replace it
-with a placeholder.
-
-Signed-off-by: Shiji Yang <[email protected]>
----
- package/boot/uboot-envtools/files/ramips      |   9 +-
- .../ramips/dts/mt7621_h3c_tx1800-plus.dts     |   8 +
- .../ramips/dts/mt7621_h3c_tx1801-plus.dts     |   8 +
- target/linux/ramips/dts/mt7621_h3c_tx1806.dts |   8 +
- .../linux/ramips/dts/mt7621_h3c_tx180x.dtsi   | 165 ++++++++++++++++++
- target/linux/ramips/image/mt7621.mk           |  40 +++++
- .../mt7621/base-files/etc/board.d/02_network  |  10 ++
- .../etc/hotplug.d/ieee80211/10_fix_wifi_mac   |   7 +
- .../mt7621/base-files/lib/upgrade/platform.sh |   3 +
- 9 files changed, 255 insertions(+), 3 deletions(-)
- create mode 100644 target/linux/ramips/dts/mt7621_h3c_tx1800-plus.dts
- create mode 100644 target/linux/ramips/dts/mt7621_h3c_tx1801-plus.dts
- create mode 100644 target/linux/ramips/dts/mt7621_h3c_tx1806.dts
- create mode 100644 target/linux/ramips/dts/mt7621_h3c_tx180x.dtsi
-
-diff --git a/package/boot/uboot-envtools/files/ramips b/package/boot/uboot-envtools/files/ramips
-index 7514bf65fb10e..738d983af2041 100644
---- a/package/boot/uboot-envtools/files/ramips
-+++ b/package/boot/uboot-envtools/files/ramips
-@@ -47,6 +47,9 @@ ravpower,rp-wd03)
- 	[ -n "$idx" ] && \
- 		ubootenv_add_uci_config "/dev/mtd$idx" "0x4000" "0x1000" "0x1000"
- 	;;
-+h3c,tx1800-plus|\
-+h3c,tx1801-plus|\
-+h3c,tx1806|\
- asus,rt-ax53u|\
- jcg,q20|\
- netgear,wax202)
-diff --git a/target/linux/ramips/dts/mt7621_h3c_tx1800-plus.dts b/target/linux/ramips/dts/mt7621_h3c_tx1800-plus.dts
-new file mode 100644
-index 0000000000000..f763dd14dddf9
---- /dev/null
-+++ b/target/linux/ramips/dts/mt7621_h3c_tx1800-plus.dts
-@@ -0,0 +1,8 @@
-+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
-+
-+#include "mt7621_h3c_tx180x.dtsi"
-+
-+/ {
-+	compatible = "h3c,tx1800-plus", "mediatek,mt7621-soc";
-+	model = "H3C TX1800 Plus";
-+};
-diff --git a/target/linux/ramips/dts/mt7621_h3c_tx1801-plus.dts b/target/linux/ramips/dts/mt7621_h3c_tx1801-plus.dts
-new file mode 100644
-index 0000000000000..4588b142c4fbb
---- /dev/null
-+++ b/target/linux/ramips/dts/mt7621_h3c_tx1801-plus.dts
-@@ -0,0 +1,8 @@
-+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
-+
-+#include "mt7621_h3c_tx180x.dtsi"
-+
-+/ {
-+	compatible = "h3c,tx1801-plus", "mediatek,mt7621-soc";
-+	model = "H3C TX1801 Plus";
-+};
-diff --git a/target/linux/ramips/dts/mt7621_h3c_tx1806.dts b/target/linux/ramips/dts/mt7621_h3c_tx1806.dts
-new file mode 100644
-index 0000000000000..1e9b6456eec5c
---- /dev/null
-+++ b/target/linux/ramips/dts/mt7621_h3c_tx1806.dts
-@@ -0,0 +1,8 @@
-+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
-+
-+#include "mt7621_h3c_tx180x.dtsi"
-+
-+/ {
-+	compatible = "h3c,tx1806", "mediatek,mt7621-soc";
-+	model = "H3C TX1806";
-+};
-diff --git a/target/linux/ramips/dts/mt7621_h3c_tx180x.dtsi b/target/linux/ramips/dts/mt7621_h3c_tx180x.dtsi
-new file mode 100644
-index 0000000000000..61f2f8cc98c01
---- /dev/null
-+++ b/target/linux/ramips/dts/mt7621_h3c_tx180x.dtsi
-@@ -0,0 +1,165 @@
-+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
-+
-+#include "mt7621.dtsi"
-+
-+#include <dt-bindings/gpio/gpio.h>
-+#include <dt-bindings/input/input.h>
-+#include <dt-bindings/leds/common.h>
-+
-+/ {
-+	aliases {
-+		led-boot = &led_status_amber;
-+		led-failsafe = &led_status_green;
-+		led-running = &led_status_green;
-+		led-upgrade = &led_status_amber;
-+	};
-+
-+	chosen {
-+		bootargs = "console=ttyS0,115200";
-+	};
-+
-+	keys {
-+		compatible = "gpio-keys";
-+
-+		reset {
-+			label = "reset";
-+			gpios = <&gpio 13 GPIO_ACTIVE_LOW>;
-+			linux,code = <KEY_RESTART>;
-+		};
-+
-+		wps {
-+			label = "wps";
-+			gpios = <&gpio 14 GPIO_ACTIVE_LOW>;
-+			linux,code = <KEY_WPS_BUTTON>;
-+		};
-+	};
-+
-+	leds {
-+		compatible = "gpio-leds";
-+
-+		led_status_amber: led-0 {
-+			label = "amber:status";
-+			color = <LED_COLOR_ID_AMBER>;
-+			function = LED_FUNCTION_STATUS;
-+			gpios = <&gpio 15 GPIO_ACTIVE_LOW>;
-+		};
-+
-+		led_status_green: led-1 {
-+			label = "green:status";
-+			color = <LED_COLOR_ID_GREEN>;
-+			function = LED_FUNCTION_STATUS;
-+			gpios = <&gpio 16 GPIO_ACTIVE_LOW>;
-+		};
-+	};
-+};
-+
-+&gmac1 {
-+	status = "okay";
-+	label = "wan";
-+	phy-handle = <&ethphy4>;
-+};
-+
-+&mdio {
-+	ethphy4: ethernet-phy@4 {
-+		reg = <4>;
-+	};
-+};
-+
-+&nand {
-+	status = "okay";
-+
-+	mediatek,nmbm;
-+	mediatek,bmt-max-ratio = <1>;
-+	mediatek,bmt-max-reserved-blocks = <64>;
-+	mediatek,bmt-remap-range = <0x0000000 0x0a00000>;
-+
-+	partitions {
-+		compatible = "fixed-partitions";
-+		#address-cells = <1>;
-+		#size-cells = <1>;
-+
-+		partition@0 {
-+			label = "u-boot";
-+			reg = <0x0000000 0x0080000>;
-+			read-only;
-+		};
-+
-+		partition@80000 {
-+			label = "u-boot-env";
-+			reg = <0x0080000 0x0080000>;
-+		};
-+
-+		partition@100000 {
-+			label = "exp";
-+			reg = <0x0100000 0x0080000>;
-+			read-only;
-+		};
-+
-+		factory: partition@180000 {
-+			label = "factory";
-+			reg = <0x0180000 0x0080000>;
-+			read-only;
-+		};
-+
-+		partition@200000 {
-+			label = "firmware";
-+			reg = <0x0200000 0x7600000>;
-+
-+			compatible = "fixed-partitions";
-+			#address-cells = <1>;
-+			#size-cells = <1>;
-+
-+			partition@0 {
-+				label = "kernel";
-+				reg = <0x0000000 0x0800000>;
-+			};
-+
-+			partition@800000 {
-+				label = "ubi";
-+				reg = <0x0800000 0x6e00000>;
-+			};
-+		};
-+
-+		/* last 8 MiB is reserved for NMBM bad block table */
-+	};
-+};
-+
-+&pcie {
-+	status = "okay";
-+};
-+
-+&pcie1 {
-+	wifi@0,0 {
-+		compatible = "mediatek,mt76";
-+		reg = <0x0000 0 0 0 0>;
-+		mediatek,mtd-eeprom = <&factory 0x0>;
-+		mediatek,disable-radar-background;
-+	};
-+};
-+
-+&pcie2 {
-+	status = "disabled";
-+};
-+
-+&switch0 {
-+	ports {
-+		port@1 {
-+			status = "okay";
-+			label = "lan1";
-+		};
-+
-+		port@2 {
-+			status = "okay";
-+			label = "lan2";
-+		};
-+
-+		port@3 {
-+			status = "okay";
-+			label = "lan3";
-+		};
-+	};
-+};
-+
-+&xhci {
-+	status = "disabled";
-+};
-diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk
-index 34eac321127be..b560ce3d95b6a 100644
---- a/target/linux/ramips/image/mt7621.mk
-+++ b/target/linux/ramips/image/mt7621.mk
-@@ -31,6 +31,12 @@ define Build/gemtek-trailer
- 	printf "%s%08X" ".GEMTEK." "$$(cksum $@ | cut -d ' ' -f1)" >> $@
- endef
- 
-+define Build/h3c-blank-header
-+	dd if=/dev/zero [email protected] bs=160 count=1
-+	cat $@ >> [email protected]
-+	mv [email protected] $@
-+endef
-+
- define Build/iodata-factory
- 	$(eval fw_size=$(word 1,$(1)))
- 	$(eval fw_type=$(word 2,$(1)))
-@@ -752,6 +758,40 @@ define Device/gnubee_gb-pc2
- endef
- TARGET_DEVICES += gnubee_gb-pc2
- 
-+define Device/h3c_tx180x
-+  $(Device/dsa-migration)
-+  BLOCKSIZE := 128k
-+  PAGESIZE := 2048
-+  KERNEL_SIZE := 8192k
-+  IMAGE_SIZE := 120832k
-+  UBINIZE_OPTS := -E 5
-+  KERNEL_LOADADDR := 0x82000000
-+  KERNEL_INITRAMFS := kernel-bin | relocate-kernel 0x80001000 | lzma | \
-+	fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb
-+  KERNEL := $$(KERNEL_INITRAMFS) | h3c-blank-header
-+  IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
-+  DEVICE_VENDOR := H3C
-+  DEVICE_PACKAGES := kmod-mt7915e uboot-envtools
-+endef
-+
-+define Device/h3c_tx1800-plus
-+  $(Device/h3c_tx180x)
-+  DEVICE_MODEL := TX1800 Plus
-+endef
-+TARGET_DEVICES += h3c_tx1800-plus
-+
-+define Device/h3c_tx1801-plus
-+  $(Device/h3c_tx180x)
-+  DEVICE_MODEL := TX1801 Plus
-+endef
-+TARGET_DEVICES += h3c_tx1801-plus
-+
-+define Device/h3c_tx1806
-+  $(Device/h3c_tx180x)
-+  DEVICE_MODEL := TX1806
-+endef
-+TARGET_DEVICES += h3c_tx1806
-+
- define Device/hilink_hlk-7621a-evb
-   $(Device/dsa-migration)
-   $(Device/uimage-lzma-loader)
-diff --git a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network
-index 320325f487e3f..400b03133ec82 100644
---- a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network
-+++ b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network
-@@ -28,6 +28,9 @@ ramips_setup_interfaces()
- 		;;
- 	ampedwireless,ally-r1900k|\
- 	gehua,ghl-r-001|\
-+	h3c,tx1800-plus|\
-+	h3c,tx1801-plus|\
-+	h3c,tx1806|\
- 	hiwifi,hc5962|\
- 	netgear,wax202|\
- 	xiaomi,mi-router-3-pro|\
-@@ -158,6 +161,13 @@ ramips_setup_macs()
- 		wan_mac=$(mtd_get_mac_ascii u-boot-env wanaddr)
- 		label_mac=$wan_mac
- 		;;
-+	h3c,tx1800-plus|\
-+	h3c,tx1801-plus|\
-+	h3c,tx1806)
-+		label_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
-+		lan_mac=$(macaddr_add "$label_mac" 1)
-+		wan_mac=$label_mac
-+		;;
- 	hiwifi,hc5962)
- 		lan_mac=$(mtd_get_mac_ascii bdinfo "Vfac_mac ")
- 		label_mac=$lan_mac
-diff --git a/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac b/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac
-index bced044234360..0ace1933e3f81 100644
---- a/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac
-+++ b/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac
-@@ -37,6 +37,13 @@ case "$board" in
- 		[ "$PHYNBR" = "1" ] && \
- 			macaddr_add "$(mtd_get_mac_binary factory 0x4)" 1 > /sys${DEVPATH}/macaddress
- 		;;
-+	h3c,tx1800-plus|\
-+	h3c,tx1801-plus|\
-+	h3c,tx1806)
-+		addr=$(macaddr_setbit $(macaddr_add $(mtd_get_mac_ascii u-boot-env ethaddr) 2) 7)
-+		[ "$PHYNBR" = "0" ] && echo -n ${addr:0:9}'1'${addr:10:7} > /sys${DEVPATH}/macaddress
-+		[ "$PHYNBR" = "1" ] && echo -n ${addr:0:9}'7'${addr:10:7} > /sys${DEVPATH}/macaddress
-+		;;
- 	hiwifi,hc5962)
- 		label_mac=$(mtd_get_mac_ascii bdinfo "Vfac_mac ")
- 		[ "$PHYNBR" = "0" ] && [ -n "$label_mac" ] && \
-diff --git a/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh b/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh
-index 8a84130ab5bef..9af46202ba954 100755
---- a/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh
-+++ b/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh
-@@ -60,6 +60,9 @@ platform_do_upgrade() {
- 	dlink,dir-2640-a1|\
- 	dlink,dir-2660-a1|\
- 	dlink,dir-853-a3|\
-+	h3c,tx1800-plus|\
-+	h3c,tx1801-plus|\
-+	h3c,tx1806|\
- 	hiwifi,hc5962|\
- 	iptime,a3004t|\
- 	iptime,ax2004m|\

+ 55 - 371
devices/ramips_mt7621/patches/k2p_32m.patch

@@ -1,393 +1,77 @@
-diff --git a/target/linux/ramips/dts/mt7621_phicomm_k2p-32m.dts b/target/linux/ramips/dts/mt7621_phicomm_k2p-32m.dts
-new file mode 100644
-index 000000000000..e828b069afb4
---- /dev/null
-+++ b/target/linux/ramips/dts/mt7621_phicomm_k2p-32m.dts
-@@ -0,0 +1,14 @@
-+#include "mt7621_phicomm_k2p.dtsi"
-+
-+/ {
-+	compatible = "phicomm,k2p-32m", "mediatek,mt7621-soc";
-+	model = "Phicomm K2P (32M)";
-+};
-+
-+&firmware {
-+	reg = <0xa0000 0x1f60000>;
-+};
-+
-+&flash {
-+	broken-flash-reset;
-+};
-diff --git a/target/linux/ramips/dts/mt7621_phicomm_k2p.dts b/target/linux/ramips/dts/mt7621_phicomm_k2p.dts
-index fa02521ba6c1..1a973a2a82ce 100644
+diff --git a/target/linux/ramips/dts/mt7621_phicomm_k2p.dts b/target/linux/ramips/dts/mt7621_phicomm_k2p.dtsi
+similarity index 94%
+rename from target/linux/ramips/dts/mt7621_phicomm_k2p.dts
+rename to target/linux/ramips/dts/mt7621_phicomm_k2p.dtsi
+index b18d12608acc7..8f72ac2a48280 100644
 --- a/target/linux/ramips/dts/mt7621_phicomm_k2p.dts
-+++ b/target/linux/ramips/dts/mt7621_phicomm_k2p.dts
-@@ -1,169 +1,10 @@
--#include "mt7621.dtsi"
--
--#include <dt-bindings/gpio/gpio.h>
--#include <dt-bindings/input/input.h>
-+#include "mt7621_phicomm_k2p.dtsi"
++++ b/target/linux/ramips/dts/mt7621_phicomm_k2p.dtsi
+@@ -4,9 +4,6 @@
+ #include <dt-bindings/input/input.h>
  
  / {
- 	compatible = "phicomm,k2p", "mediatek,mt7621-soc";
- 	model = "Phicomm K2P";
--
--	aliases {
--		led-boot = &led_blue;
--		led-failsafe = &led_blue;
--		led-running = &led_blue;
--		led-upgrade = &led_blue;
--	};
--
--	leds {
--		compatible = "gpio-leds";
--
--		stat_r {
--			label = "red:status";
--			gpios = <&gpio 13 GPIO_ACTIVE_HIGH>;
--		};
--
--		stat_y {
--			label = "yellow:status";
--			gpios = <&gpio 14 GPIO_ACTIVE_LOW>;
--		};
--
--		led_blue: stat_b {
--			label = "blue:status";
--			gpios = <&gpio 15 GPIO_ACTIVE_LOW>;
--		};
--	};
--
--	keys {
--		compatible = "gpio-keys";
--
--		reset {
--			label = "reset";
--			gpios = <&gpio 3 GPIO_ACTIVE_LOW>;
--			linux,code = <KEY_RESTART>;
--		};
--	};
--};
--
--&spi0 {
--	status = "okay";
--
+-	compatible = "phicomm,k2p", "mediatek,mt7621-soc";
+-	model = "Phicomm K2P";
+-
+ 	aliases {
+ 		led-boot = &led_blue;
+ 		led-failsafe = &led_blue;
+@@ -47,7 +44,7 @@
+ &spi0 {
+ 	status = "okay";
+ 
 -	flash@0 {
--		compatible = "jedec,spi-nor";
--		reg = <0>;
--		spi-max-frequency = <50000000>;
--
--		partitions {
--			compatible = "fixed-partitions";
--			#address-cells = <1>;
--			#size-cells = <1>;
--
--			partition@0 {
--				label = "u-boot";
--				reg = <0x0 0x30000>;
--				read-only;
--			};
--
--			partition@30000 {
--				label = "u-boot-env";
--				reg = <0x30000 0x10000>;
--				read-only;
--			};
--
--			factory: partition@40000 {
--				label = "factory";
--				reg = <0x40000 0x10000>;
--				read-only;
--			};
--
--			partition@50000 {
--				label = "permanent_config";
--				reg = <0x50000 0x50000>;
--				read-only;
--			};
--
++	flash: flash@0 {
+ 		compatible = "jedec,spi-nor";
+ 		reg = <0>;
+ 		spi-max-frequency = <50000000>;
+@@ -81,10 +78,9 @@
+ 				read-only;
+ 			};
+ 
 -			partition@a0000 {
--				compatible = "denx,uimage";
--				label = "firmware";
++			firmware: partition@a0000 {
+ 				compatible = "denx,uimage";
+ 				label = "firmware";
 -				reg = <0xa0000 0xf60000>;
--			};
--		};
--	};
- };
- 
--&pcie {
--	status = "okay";
--};
--
--&pcie0 {
--	wifi@0,0 {
--		compatible = "mediatek,mt76";
--		reg = <0x0000 0 0 0 0>;
--		mediatek,mtd-eeprom = <&factory 0x0>;
--
--		/* 5 GHz (phy1) does not take the address from calibration data,
--		   but setting it manually here works */
--		nvmem-cells = <&macaddr_factory_4>;
--		nvmem-cell-names = "mac-address";
--	};
--};
--
--&gmac0 {
--	nvmem-cells = <&macaddr_factory_e000>;
--	nvmem-cell-names = "mac-address";
--};
--
--&switch0 {
--	ports {
--		port@0 {
--			status = "okay";
--			label = "lan1";
--		};
--
--		port@1 {
--			status = "okay";
--			label = "lan2";
--		};
--
--		port@2 {
--			status = "okay";
--			label = "lan3";
--		};
--
--		port@3 {
--			status = "okay";
--			label = "lan4";
--		};
--
--		port@4 {
--			status = "okay";
--			label = "wan";
--			nvmem-cells = <&macaddr_factory_e006>;
--			nvmem-cell-names = "mac-address";
--		};
--	};
--};
--
--&state_default {
--	gpio {
--		groups = "i2c", "jtag";
--		function = "gpio";
--	};
--};
--
--&factory {
--	compatible = "nvmem-cells";
--	#address-cells = <1>;
--	#size-cells = <1>;
--
--	macaddr_factory_4: macaddr@4 {
--		reg = <0x4 0x6>;
--	};
--
--	macaddr_factory_e000: macaddr@e000 {
--		reg = <0xe000 0x6>;
--	};
--
--	macaddr_factory_e006: macaddr@e006 {
--		reg = <0xe006 0x6>;
--	};
-+&firmware {
-+	reg = <0xa0000 0xf60000>;
- };
-diff --git a/target/linux/ramips/dts/mt7621_phicomm_k2p.dtsi b/target/linux/ramips/dts/mt7621_phicomm_k2p.dtsi
+ 			};
+ 		};
+ 	};
+diff --git a/target/linux/ramips/dts/mt7621_phicomm_k2p.dts b/target/linux/ramips/dts/mt7621_phicomm_k2p.dts
 new file mode 100644
-index 000000000000..90458050554c
+index 0000000000000..5bad6f2d9562d
 --- /dev/null
-+++ b/target/linux/ramips/dts/mt7621_phicomm_k2p.dtsi
-@@ -0,0 +1,165 @@
-+#include "mt7621.dtsi"
-+
-+#include <dt-bindings/gpio/gpio.h>
-+#include <dt-bindings/input/input.h>
++++ b/target/linux/ramips/dts/mt7621_phicomm_k2p.dts
+@@ -0,0 +1,10 @@
++#include "mt7621_phicomm_k2p.dtsi"
 +
 +/ {
-+	aliases {
-+		led-boot = &led_blue;
-+		led-failsafe = &led_blue;
-+		led-running = &led_blue;
-+		led-upgrade = &led_blue;
-+	};
-+
-+	leds {
-+		compatible = "gpio-leds";
-+
-+		stat_r {
-+			label = "red:status";
-+			gpios = <&gpio 13 GPIO_ACTIVE_HIGH>;
-+		};
-+
-+		stat_y {
-+			label = "yellow:status";
-+			gpios = <&gpio 14 GPIO_ACTIVE_LOW>;
-+		};
-+
-+		led_blue: stat_b {
-+			label = "blue:status";
-+			gpios = <&gpio 15 GPIO_ACTIVE_LOW>;
-+		};
-+	};
-+
-+	keys {
-+		compatible = "gpio-keys";
-+
-+		reset {
-+			label = "reset";
-+			gpios = <&gpio 3 GPIO_ACTIVE_LOW>;
-+			linux,code = <KEY_RESTART>;
-+		};
-+	};
-+};
-+
-+&spi0 {
-+	status = "okay";
-+
-+	flash: flash@0 {
-+		compatible = "jedec,spi-nor";
-+		reg = <0>;
-+		spi-max-frequency = <50000000>;
-+
-+		partitions {
-+			compatible = "fixed-partitions";
-+			#address-cells = <1>;
-+			#size-cells = <1>;
-+
-+			partition@0 {
-+				label = "u-boot";
-+				reg = <0x0 0x30000>;
-+				read-only;
-+			};
-+
-+			partition@30000 {
-+				label = "u-boot-env";
-+				reg = <0x30000 0x10000>;
-+				read-only;
-+			};
-+
-+			factory: partition@40000 {
-+				label = "factory";
-+				reg = <0x40000 0x10000>;
-+				read-only;
-+			};
-+
-+			partition@50000 {
-+				label = "permanent_config";
-+				reg = <0x50000 0x50000>;
-+				read-only;
-+			};
-+
-+			firmware: partition@a0000 {
-+				compatible = "denx,uimage";
-+				label = "firmware";
-+			};
-+		};
-+	};
-+};
-+
-+&pcie {
-+	status = "okay";
++	compatible = "phicomm,k2p", "mediatek,mt7621-soc";
++ 	model = "Phicomm K2P";
 +};
 +
-+&pcie0 {
-+	wifi@0,0 {
-+		compatible = "mediatek,mt76";
-+		reg = <0x0000 0 0 0 0>;
-+		mediatek,mtd-eeprom = <&factory 0x0>;
-+
-+		/* 5 GHz (phy1) does not take the address from calibration data,
-+		   but setting it manually here works */
-+		nvmem-cells = <&macaddr_factory_4>;
-+		nvmem-cell-names = "mac-address";
-+	};
-+};
-+
-+&gmac0 {
-+	nvmem-cells = <&macaddr_factory_e000>;
-+	nvmem-cell-names = "mac-address";
++&firmware {
++	reg = <0xa0000 0x1f60000>;
 +};
+diff --git a/target/linux/ramips/dts/mt7621_phicomm_k2p-32m.dts b/target/linux/ramips/dts/mt7621_phicomm_k2p-32m.dts
+new file mode 100644
+index 0000000000000..5bad6f2d9562d
+--- /dev/null
++++ b/target/linux/ramips/dts/mt7621_phicomm_k2p-32m.dts
+@@ -0,0 +1,14 @@
++#include "mt7621_phicomm_k2p.dtsi"
 +
-+&switch0 {
-+	ports {
-+		port@0 {
-+			status = "okay";
-+			label = "lan1";
-+		};
-+
-+		port@1 {
-+			status = "okay";
-+			label = "lan2";
-+		};
-+
-+		port@2 {
-+			status = "okay";
-+			label = "lan3";
-+		};
-+
-+		port@3 {
-+			status = "okay";
-+			label = "lan4";
-+		};
-+
-+		port@4 {
-+			status = "okay";
-+			label = "wan";
-+			nvmem-cells = <&macaddr_factory_e006>;
-+			nvmem-cell-names = "mac-address";
-+		};
-+	};
++/ {
++	compatible = "phicomm,k2p-32m", "mediatek,mt7621-soc";
++	model = "Phicomm K2P (32M)";
 +};
 +
-+&state_default {
-+	gpio {
-+		groups = "i2c", "jtag";
-+		function = "gpio";
-+	};
++&firmware {
++	reg = <0xa0000 0x1f60000>;
 +};
 +
-+&factory {
-+	compatible = "nvmem-cells";
-+	#address-cells = <1>;
-+	#size-cells = <1>;
-+
-+	macaddr_factory_4: macaddr@4 {
-+		reg = <0x4 0x6>;
-+	};
-+
-+	macaddr_factory_e000: macaddr@e000 {
-+		reg = <0xe000 0x6>;
-+	};
-+
-+	macaddr_factory_e006: macaddr@e006 {
-+		reg = <0xe006 0x6>;
-+	};
++&flash {
++	broken-flash-reset;
 +};
-diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk
-index 8c3ef04e35f4..b043d14bd12f 100644
---- a/target/linux/ramips/image/mt7621.mk
-+++ b/target/linux/ramips/image/mt7621.mk
-@@ -829,6 +829,16 @@ define Device/phicomm_k2p
- endef
- TARGET_DEVICES += phicomm_k2p
- 
-+define Device/phicomm_k2p-32m
-+  IMAGE_SIZE := 32128k
-+  DEVICE_VENDOR := Phicomm
-+  DEVICE_MODEL := K2P
-+  DEVICE_VARIANT := 32M
-+  SUPPORTED_DEVICES += k2p-32M
-+  DEVICE_PACKAGES := kmod-mt7615e kmod-mt7615-firmware
-+endef
-+TARGET_DEVICES += phicomm_k2p-32m
-+
- define Device/planex_vr500
-   $(Device/uimage-lzma-loader)
-   IMAGE_SIZE := 65216k
-
 --- a/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac
 +++ b/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac
 @@ -28,7 +28,8 @@ case "$board" in

+ 0 - 21
devices/ramips_mt7621/patches/luban.patch

@@ -175,24 +175,3 @@ index 0000000..ed1ebed
 +		reg = <0x3fffa 0x6>;
 +	};
 +};
-diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk
-index 795f567..02c4da8 100644
---- a/target/linux/ramips/image/mt7621.mk
-+++ b/target/linux/ramips/image/mt7621.mk
-@@ -1816,6 +1816,16 @@ define Device/xiaoyu_xy-c5
- endef
- TARGET_DEVICES += xiaoyu_xy-c5
- 
-+define Device/jdcloud_luban
-+  $(Device/dsa-migration)
-+  $(Device/uimage-lzma-loader)
-+  IMAGE_SIZE := 15808k
-+  DEVICE_VENDOR := JDCloud
-+  DEVICE_MODEL := Luban 鲁班
-+  DEVICE_PACKAGES += kmod-mt7915e uboot-envtools wpad-mini -wpad-basic-wolfssl -coremark -htop -bash -openssh-sftp-server
-+endef
-+TARGET_DEVICES += jdcloud_luban
-+
- define Device/xzwifi_creativebox-v1
-   $(Device/dsa-migration)
-   IMAGE_SIZE := 32448k

+ 1 - 52
devices/ramips_mt7621/patches/zte_e8820s.patch

@@ -379,46 +379,7 @@ index 000000000000..5a0012441509
 +		reg = <0xe006 0x6>;
 +	};
 +};
-diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk
-index 961f8a3b7514a..266ecd57ec8d5 100644
---- a/target/linux/ramips/image/mt7621.mk
-+++ b/target/linux/ramips/image/mt7621.mk
-@@ -2205,6 +2205,35 @@ define Device/zio_freezio
- endef
- TARGET_DEVICES += zio_freezio
- 
-+define Device/zte_e8820s
-+  $(Device/dsa-migration)
-+  $(Device/uimage-lzma-loader)
-+  BLOCKSIZE := 128k
-+  PAGESIZE := 2048
-+  KERNEL_SIZE := 4096k
-+  UBINIZE_OPTS := -E 5
-+  IMAGE_SIZE := 130304k
-+  IMAGES += factory.bin
-+  IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
-+  IMAGE/factory.bin := append-kernel | pad-to $$(KERNEL_SIZE) | append-ubi | \
-+	check-size
-+  DEVICE_VENDOR := ZTE
-+  DEVICE_MODEL := E8820S
-+  DEVICE_PACKAGES := kmod-mt7603 kmod-mt76x2 kmod-usb3 uboot-envtools
-+endef
-+TARGET_DEVICES += zte_e8820s
-+
-+define Device/zte_e8820v2
-+  $(Device/dsa-migration)
-+  $(Device/uimage-lzma-loader)
-+  IMAGE_SIZE := 16064k
-+  DEVICE_VENDOR := ZTE
-+  DEVICE_MODEL := E8820V2
-+  DEVICE_PACKAGES := kmod-mt7603 kmod-mt76x2 kmod-usb2 \
-+	  kmod-usb-ledtrig-usbport wpad-mini -wpad-basic-wolfssl -coremark -htop -bash -openssh-sftp-server
-+endef
-+TARGET_DEVICES += zte_e8820v2
-+
- define Device/zyxel_nr7101
-   $(Device/dsa-migration)
-   BLOCKSIZE := 128k
+
 diff --git a/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds b/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds
 index aad2e32b36210..a6a4707fc295d 100644
 --- a/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds
@@ -440,15 +401,3 @@ index aad2e32b36210..a6a4707fc295d 100644
  esac
  
  board_config_flush
-diff --git a/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh b/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh
-index 6cfc852c11c25..0a73fed98927b 100755
---- a/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh
-+++ b/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh
-@@ -96,6 +96,7 @@ platform_do_upgrade() {
- 	xiaomi,mi-router-cr6608|\
- 	xiaomi,mi-router-cr6609|\
- 	xiaomi,redmi-router-ac2100|\
-+	zte,e8820s|\
- 	zyxel,nwa50ax|\
- 	zyxel,nwa55axe)
- 		nand_do_upgrade "$1"

+ 1 - 1
devices/ramips_mt76x8/diy.sh

@@ -5,7 +5,7 @@ shopt -s extglob
 SHELL_FOLDER=$(dirname $(readlink -f "$0"))
 
 sh -c "curl -sfL https://github.com/openwrt/openwrt/commit/2e6d19ee32399e37c7545aefc57d41541a406d55.patch | patch -d './' -p1 --forward" || true
-#bash $SHELL_FOLDER/../common/kernel_5.15.sh
+
 
 #sh -c "curl -sfL https://patch-diff.githubusercontent.com/raw/openwrt/openwrt/pull/11287.patch | patch -d './' -p1 --forward"
 

+ 0 - 135
devices/ramips_mt76x8/patches/hc5611.patch

@@ -1,135 +0,0 @@
-From a8f3c97ce83dc97cd7acb040a715ecd75d824161 Mon Sep 17 00:00:00 2001
-From: Senis John <[email protected]>
-Date: Sat, 19 Nov 2022 11:30:54 +0800
-Subject: [PATCH] ramips: add support for HiWiFi HC5611
-
-CPU: MediaTek MT7628AN @ 575 MHz
-Flash: 16 MB
-RAM: 128 MB
-Ethernet: 10/100Mbps x 1
-Wlan: 300 Mbps
-USB: USB 2.0 x 1
-LED: red/green x 1
-Button: reset x 1
-
-1. Open https://www.hiwifi.wtf/, Get Cloud token and unlock ssh
-2. Upload the openwrt firmware to the router via SCP
-3. Login the router via SSH
-4. Run `mtd -r write path_to_firmware.bin firmware`
-
-I have tested on my device.
-- The LED will display RED on power-on, After system start completed, trun GREEN
-- Reset button working now. Long press after 5s will reset factory. Short press less 1s will reboot the device
-- USB can working under official u-boot
-
-Signed-off-by: Senis John <[email protected]>
----
- .../ramips/dts/mt7628an_hiwifi_hc5611.dts     | 30 +++++++++++++++++++
- target/linux/ramips/image/mt76x8.mk           |  8 +++++
- .../mt76x8/base-files/etc/board.d/01_leds     |  3 ++
- .../mt76x8/base-files/etc/board.d/02_network  |  2 ++
- .../etc/hotplug.d/ieee80211/10_fix_wifi_mac   |  1 +
- 5 files changed, 44 insertions(+)
- create mode 100644 target/linux/ramips/dts/mt7628an_hiwifi_hc5611.dts
-
-diff --git a/target/linux/ramips/dts/mt7628an_hiwifi_hc5611.dts b/target/linux/ramips/dts/mt7628an_hiwifi_hc5611.dts
-new file mode 100644
-index 0000000000000..17de299b3cbc4
---- /dev/null
-+++ b/target/linux/ramips/dts/mt7628an_hiwifi_hc5611.dts
-@@ -0,0 +1,30 @@
-+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
-+
-+#include "mt7628an_hiwifi_hc5x61a.dtsi"
-+
-+/ {
-+	compatible = "hiwifi,hc5611", "mediatek,mt7628an-soc";
-+	model = "HiWiFi HC5611";
-+
-+	leds {
-+		compatible = "gpio-leds";
-+
-+		led_system: system {
-+			label = "green:system";
-+			gpios = <&gpio 11 GPIO_ACTIVE_HIGH>;
-+			default-state = "on";
-+		};
-+
-+		internet {
-+			label = "red:internet";
-+			gpios = <&gpio 6 GPIO_ACTIVE_LOW>;
-+		};
-+	};
-+};
-+
-+&state_default {
-+	gpio {
-+		groups = "gpio", "spi cs1", "wdt";
-+		function = "gpio";
-+	};
-+};
-diff --git a/target/linux/ramips/image/mt76x8.mk b/target/linux/ramips/image/mt76x8.mk
-index 5e8d05b04283f..1b7e786b52b88 100644
---- a/target/linux/ramips/image/mt76x8.mk
-+++ b/target/linux/ramips/image/mt76x8.mk
-@@ -243,6 +243,14 @@ define Device/hilink_hlk-7688a
- endef
- TARGET_DEVICES += hilink_hlk-7688a
- 
-+define Device/hiwifi_hc5611
-+  IMAGE_SIZE := 15808k
-+  DEVICE_VENDOR := HiWiFi
-+  DEVICE_MODEL := GO (HC5611)
-+  DEVICE_PACKAGES := kmod-usb2 kmod-usb-ohci
-+endef
-+TARGET_DEVICES += hiwifi_hc5611
-+
- define Device/hiwifi_hc5661a
-   IMAGE_SIZE := 15808k
-   DEVICE_VENDOR := HiWiFi
-diff --git a/target/linux/ramips/mt76x8/base-files/etc/board.d/01_leds b/target/linux/ramips/mt76x8/base-files/etc/board.d/01_leds
-index 8a21756225acf..66628cea09f8d 100644
---- a/target/linux/ramips/mt76x8/base-files/etc/board.d/01_leds
-+++ b/target/linux/ramips/mt76x8/base-files/etc/board.d/01_leds
-@@ -46,6 +46,9 @@ skylab,skw92a)
- hilink,hlk-7688a)
- 	ucidef_set_led_wlan "wlan" "WLAN" "green:wlan" "phy0tpt"
- 	;;
-+hiwifi,hc5611)
-+	ucidef_set_led_netdev "internet" "internet" "red:internet" "br-lan" "tx rx"
-+	;;
- hiwifi,hc5661a|\
- hiwifi,hc5761a)
- 	ucidef_set_led_switch "internet" "internet" "blue:internet" "switch0" "0x10"
-diff --git a/target/linux/ramips/mt76x8/base-files/etc/board.d/02_network b/target/linux/ramips/mt76x8/base-files/etc/board.d/02_network
-index 38ff38bac5fea..d85cdf3db7fac 100644
---- a/target/linux/ramips/mt76x8/base-files/etc/board.d/02_network
-+++ b/target/linux/ramips/mt76x8/base-files/etc/board.d/02_network
-@@ -14,6 +14,7 @@ ramips_setup_interfaces()
- 	glinet,microuter-n300|\
- 	glinet,vixmini|\
- 	hak5,wifi-pineapple-mk7|\
-+	hiwifi,hc5611|\
- 	mediatek,linkit-smart-7688|\
- 	minew,g1-c|\
- 	onion,omega2p|\
-@@ -226,6 +227,7 @@ ramips_setup_macs()
- 	zyxel,keenetic-extra-ii)
- 		wan_mac=$(macaddr_add "$(mtd_get_mac_binary factory 0x4)" 1)
- 		;;
-+	hiwifi,hc5611|\
- 	hiwifi,hc5661a|\
- 	hiwifi,hc5761a|\
- 	hiwifi,hc5861b)
-diff --git a/target/linux/ramips/mt76x8/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac b/target/linux/ramips/mt76x8/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac
-index b8f8faee9ca28..c9e205a0fc143 100644
---- a/target/linux/ramips/mt76x8/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac
-+++ b/target/linux/ramips/mt76x8/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac
-@@ -10,6 +10,7 @@ PHYNBR=${DEVPATH##*/phy}
- board=$(board_name)
- 
- case "$board" in
-+	hiwifi,hc5611|\
- 	hiwifi,hc5661a|\
- 	hiwifi,hc5761a|\
- 	hiwifi,hc5861b)

+ 1 - 1
devices/ramips_mt76x8/patches/small_flash.patch

@@ -5,6 +5,6 @@
  
  include $(INCLUDE_DIR)/target.mk
 -DEFAULT_PACKAGES += kmod-leds-gpio kmod-gpio-button-hotplug
-+DEFAULT_PACKAGES += kmod-leds-gpio kmod-gpio-button-hotplug wpad-mini -wpad-basic-wolfssl -coremark -htop -bash -openssh-sftp-server
++DEFAULT_PACKAGES += kmod-leds-gpio kmod-gpio-button-hotplug wpad-mini -wpad-basic-mbedtls -coremark -htop -bash -openssh-sftp-server
  
  $(eval $(call BuildTarget))

+ 0 - 1
devices/rockchip_armv8/diy.sh

@@ -2,7 +2,6 @@
 
 shopt -s extglob
 SHELL_FOLDER=$(dirname $(readlink -f "$0"))
-bash $SHELL_FOLDER/../common/kernel_5.15.sh
 
 rm -rf package/boot/uboot-rockchip
 svn export --force https://github.com/coolsnowwolf/lede/trunk/package/boot/uboot-rockchip package/boot/uboot-rockchip

+ 12 - 3
devices/rockchip_armv8/patches/r6s.patch

@@ -1,6 +1,6 @@
 --- a/target/linux/rockchip/image/armv8.mk
 +++ b/target/linux/rockchip/image/armv8.mk
-@@ -52,4 +52,22 @@
+@@ -52,4 +52,31 @@
  TARGET_DEVICES += friendlyarm_nanopi-r2s
  
 +define Device/friendlyarm_nanopi-r6c
@@ -20,6 +20,15 @@
 +  DEVICE_DTS = rockchip/rk3328-nanopi-r2s
 +endef
 +TARGET_DEVICES += friendlyarm_nanopi-r6s
++
++define Device/friendlyarm_nanopc-t6
++  DEVICE_VENDOR := FriendlyARM
++  DEVICE_MODEL := NanoPC T6
++  SOC := rk3328
++  DEVICE_PACKAGES := -luci-app-gpsysupgrade
++  DEVICE_DTS = rockchip/rk3328-nanopi-r2s
++endef
++TARGET_DEVICES += friendlyarm_nanopc-t6
 +
  define Device/friendlyarm_nanopi-r4s
    DEVICE_VENDOR := FriendlyARM
@@ -124,7 +133,7 @@
  include $(SUBTARGET).mk
  
 +define Image/Build
-+	if [[ "$(PROFILE_SANITIZED)" == "friendlyarm_nanopi-r6s" || "$(PROFILE_SANITIZED)" == "friendlyarm_nanopi-r6c" ]]; then \
++	if [[ "$(PROFILE_SANITIZED)" == "friendlyarm_nanopi-r6s" || "$(PROFILE_SANITIZED)" == "friendlyarm_nanopi-r6c" || "$(PROFILE_SANITIZED)" == "friendlyarm_nanopc-t6" ]]; then \
 +		export IMG_PREFIX="$(IMG_PREFIX)$(if $(PROFILE_SANITIZED),-$(PROFILE_SANITIZED))"; \
 +		export BIN_DIR=$(BIN_DIR); \
 +		export TOPDIR=$(TOPDIR); \
@@ -132,7 +141,7 @@
 +		. ../modify_packit.sh; \
 +		./build.sh sd-img; \
 +		[ "$(MORE)" == "eflasher" ] && ./build.sh emmc-img; \
-+		rm -rf $(BIN_DIR)/*r6s-squashfs-sysupgrade.img.gz $(BIN_DIR)/images-for-eflasher; \
++		rm -rf $(BIN_DIR)/$(PROFILE_SANITIZED)-squashfs-sysupgrade.img.gz $(BIN_DIR)/images-for-eflasher; \
 +	fi
 +endef
 +

+ 0 - 1
devices/sunxi_cortexa53/diy.sh

@@ -3,7 +3,6 @@
 shopt -s extglob
 
 SHELL_FOLDER=$(dirname $(readlink -f "$0"))
-bash $SHELL_FOLDER/../common/kernel_5.15.sh
 
 sed -i 's/DEFAULT_PACKAGES +=/DEFAULT_PACKAGES += fdisk lsblk/' target/linux/sunxi/Makefile
 

+ 0 - 1
devices/sunxi_cortexa7/diy.sh

@@ -3,7 +3,6 @@
 shopt -s extglob
 
 SHELL_FOLDER=$(dirname $(readlink -f "$0"))
-bash $SHELL_FOLDER/../common/kernel_5.15.sh
 
 
 

+ 0 - 1
devices/x86_64/diy.sh

@@ -1,7 +1,6 @@
 #!/bin/bash
 
 SHELL_FOLDER=$(dirname $(readlink -f "$0"))
-bash $SHELL_FOLDER/../common/kernel_5.15.sh
 
 svn co https://github.com/coolsnowwolf/lede/trunk/target/linux/x86/files target/linux/x86/files
 rm -rf target/linux/x86/files/.svn

+ 0 - 1
devices/x86_generic/diy.sh

@@ -1,7 +1,6 @@
 #!/bin/bash
 
 SHELL_FOLDER=$(dirname $(readlink -f "$0"))
-bash $SHELL_FOLDER/../common/kernel_5.15.sh
 
 svn co https://github.com/coolsnowwolf/lede/trunk/target/linux/x86/files target/linux/x86/files
 rm -rf target/linux/x86/files/.svn