diff --git a/package/base-files/Makefile b/package/base-files/Makefile index d8e7c31878..5fb275533d 100644 --- a/package/base-files/Makefile +++ b/package/base-files/Makefile @@ -12,7 +12,7 @@ include $(INCLUDE_DIR)/version.mk include $(INCLUDE_DIR)/feeds.mk PKG_NAME:=base-files -PKG_RELEASE:=220 +PKG_RELEASE:=221 PKG_FLAGS:=nonshared PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/ diff --git a/package/base-files/files/lib/upgrade/stage2 b/package/base-files/files/lib/upgrade/stage2 index 41a3b2aeb3..dbb33e8958 100755 --- a/package/base-files/files/lib/upgrade/stage2 +++ b/package/base-files/files/lib/upgrade/stage2 @@ -39,7 +39,7 @@ switch_to_ramfs() { md5sum hexdump cat zcat bzcat dd tar \ ls basename find cp mv rm mkdir rmdir mknod touch chmod \ '[' printf wc grep awk sed cut \ - mtd partx losetup mkfs.ext4 \ + mtd partx losetup mkfs.ext4 nandwrite flash_erase \ ubiupdatevol ubiattach ubiblock ubiformat \ ubidetach ubirsvol ubirmvol ubimkvol \ snapshot snapshot_tool \ diff --git a/package/kernel/bcm63xx-cfe/Makefile b/package/kernel/bcm63xx-cfe/Makefile new file mode 100644 index 0000000000..f97e07579c --- /dev/null +++ b/package/kernel/bcm63xx-cfe/Makefile @@ -0,0 +1,42 @@ +include $(TOPDIR)/rules.mk +include $(INCLUDE_DIR)/kernel.mk + +PKG_NAME:=bcm63xx-cfe +PKG_RELEASE:=1 + +PKG_SOURCE_URL:=https://github.com/openwrt/bcm63xx-cfe.git +PKG_SOURCE_PROTO:=git +PKG_SOURCE_DATE:=2020-05-18 +PKG_SOURCE_VERSION:=efe3b81121a84c0b8ba6a7d0d47cd5eeeb23808d +PKG_MIRROR_HASH:=299dcf6ef1ad034df26daee6446b574abcd7526a2fe90fb8115890e71bc0d58b + +PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(PKG_NAME) + +PKG_FLAGS:=nonshared + +include $(INCLUDE_DIR)/package.mk + +TAR_OPTIONS:=--strip-components 1 $(TAR_OPTIONS) +TAR_CMD=$(HOST_TAR) -C $(1) $(TAR_OPTIONS) + +define Package/bcm63xx-cfe + SECTION:=boot + CATEGORY:=Boot Loaders + DEPENDS:=@TARGET_bcm63xx + TITLE:=bcm63xx-cfe + DEFAULT:=y if TARGET_bcm63xx +endef + +define Package/bcm63xx-cfe/description + CFE RAM binaries for bcm63xx. +endef + +define Build/Compile + true +endef + +define Package/bcm63xx-cfe/install + true +endef + +$(eval $(call BuildPackage,bcm63xx-cfe)) diff --git a/scripts/cfe-bin-header.py b/scripts/cfe-bin-header.py new file mode 100755 index 0000000000..476a36d8dd --- /dev/null +++ b/scripts/cfe-bin-header.py @@ -0,0 +1,72 @@ +#!/bin/env python3 + +import argparse +import os +import struct + +def auto_int(x): + return int(x, 0) + +def create_header(args, size): + header = struct.pack('>III', args.entry_addr, args.load_addr, size) + return header + +def create_output(args): + in_st = os.stat(args.input_file) + in_size = in_st.st_size + + header = create_header(args, in_size) + print(header) + + in_f = open(args.input_file, 'r+b') + in_bytes = in_f.read(in_size) + in_f.close() + + out_f = open(args.output_file, 'w+b') + out_f.write(header) + out_f.write(in_bytes) + out_f.close() + +def main(): + global args + + parser = argparse.ArgumentParser(description='') + + parser.add_argument('--entry-addr', + dest='entry_addr', + action='store', + type=auto_int, + help='Entry Address') + + parser.add_argument('--input-file', + dest='input_file', + action='store', + type=str, + help='Input file') + + parser.add_argument('--load-addr', + dest='load_addr', + action='store', + type=auto_int, + help='Load Address') + + parser.add_argument('--output-file', + dest='output_file', + action='store', + type=str, + help='Output file') + + args = parser.parse_args() + + if (not args.input_file) or (not args.output_file): + parser.print_help() + + if not args.entry_addr: + args.entry_addr = 0x80010000 + + if not args.load_addr: + args.load_addr = 0x80010000 + + create_output(args) + +main() diff --git a/scripts/cfe-wfi-tag.py b/scripts/cfe-wfi-tag.py new file mode 100755 index 0000000000..3b60dbfc5d --- /dev/null +++ b/scripts/cfe-wfi-tag.py @@ -0,0 +1,200 @@ +#!/bin/env python3 + +""" +Whole Flash Image Tag + +{ + u32 crc32; + u32 version; + u32 chipID; + u32 flashType; + u32 flags; +} + +CRC32: Ethernet (Poly 0x04C11DB7) + +Version: + 0x00005700: Any version + 0x00005731: NAND 1MB data partition + 0x00005732: Normal version + +Chip ID: + Broadcom Chip ID + 0x00006328: BCM6328 + 0x00006362: BCM6362 + 0x00006368: BCM6368 + 0x00063268: BCM63268 + +Flash Type: + 1: NOR + 2: NAND 16k blocks + 3: NAND 128k blocks + 4: NAND 256k blocks + 5: NAND 512k blocks + 6: NAND 1MB blocks + 7: NAND 2MB blocks + +Flags: + 0x00000001: PMC + 0x00000002: Secure BootROM + +""" + +import argparse +import os +import struct + +CRC32_INIT = 0xFFFFFFFF +CRC32_TABLE = [ + 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, + 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, + 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, + 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, + 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, + 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, + 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, + 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5, + 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, + 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, + 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, + 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, + 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, + 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F, + 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, + 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, + 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, + 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433, + 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, + 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01, + 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, + 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, + 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, + 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, + 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, + 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, + 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, + 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, + 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, + 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, + 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, + 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD, + 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, + 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, + 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, + 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, + 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, + 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7, + 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, + 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, + 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, + 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, + 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, + 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79, + 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, + 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, + 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, + 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D, + 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, + 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, + 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, + 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, + 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, + 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, + 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, + 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45, + 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, + 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, + 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, + 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, + 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, + 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF, + 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, + 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D +] + +def auto_int(x): + return int(x, 0) + +def crc32(bytes, size, crc): + i = 0 + while (i < size): + crc = (crc >> 8) ^ CRC32_TABLE[(crc ^ bytes[i]) & 0xff] + i += 1 + return crc + +def create_tag(args, in_bytes, size): + crc = crc32(in_bytes, size, CRC32_INIT) + tag = struct.pack('>IIIII', crc, args.tag_version, args.chip_id, args.flash_type, args.flags) + return tag + +def create_output(args): + in_st = os.stat(args.input_file) + in_size = in_st.st_size + + in_f = open(args.input_file, 'r+b') + in_bytes = in_f.read(in_size) + in_f.close() + + tag = create_tag(args, in_bytes, in_size) + + out_f = open(args.output_file, 'w+b') + out_f.write(in_bytes) + out_f.write(tag) + out_f.close() + +def main(): + global args + + parser = argparse.ArgumentParser(description='') + + parser.add_argument('--input-file', + dest='input_file', + action='store', + type=str, + help='Input file') + + parser.add_argument('--output-file', + dest='output_file', + action='store', + type=str, + help='Output file') + + parser.add_argument('--version', + dest='tag_version', + action='store', + type=auto_int, + help='WFI Tag Version') + + parser.add_argument('--chip-id', + dest='chip_id', + action='store', + type=auto_int, + help='WFI Chip ID') + + parser.add_argument('--flash-type', + dest='flash_type', + action='store', + type=auto_int, + help='WFI Flash Type') + + parser.add_argument('--flags', + dest='flags', + action='store', + type=auto_int, + help='WFI Flags') + + args = parser.parse_args() + + if not args.flags: + args.flags = 0 + + if ((not args.input_file) or + (not args.output_file) or + (not args.tag_version) or + (not args.chip_id) or + (not args.flash_type)): + parser.print_help() + else: + create_output(args) + +main() diff --git a/target/linux/ath79/dts/tp9343_tplink_tl-wa901nd-v4.dts b/target/linux/ath79/dts/tp9343_tplink_tl-wa901nd-v4.dts new file mode 100644 index 0000000000..69080feb2f --- /dev/null +++ b/target/linux/ath79/dts/tp9343_tplink_tl-wa901nd-v4.dts @@ -0,0 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/dts-v1/; + +#include "tp9343_tplink_tl-wa901nd.dtsi" + +/ { + compatible = "tplink,tl-wa901nd-v4", "qca,tp9343"; + model = "TP-Link TL-WA901ND v4"; +}; diff --git a/target/linux/ath79/dts/tp9343_tplink_tl-wa901nd-v5.dts b/target/linux/ath79/dts/tp9343_tplink_tl-wa901nd-v5.dts new file mode 100644 index 0000000000..7d9e8e8f6c --- /dev/null +++ b/target/linux/ath79/dts/tp9343_tplink_tl-wa901nd-v5.dts @@ -0,0 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/dts-v1/; + +#include "tp9343_tplink_tl-wa901nd.dtsi" + +/ { + compatible = "tplink,tl-wa901nd-v5", "qca,tp9343"; + model = "TP-Link TL-WA901ND v5"; +}; diff --git a/target/linux/ath79/dts/tp9343_tplink_tl-wa901nd.dtsi b/target/linux/ath79/dts/tp9343_tplink_tl-wa901nd.dtsi new file mode 100644 index 0000000000..992c14842b --- /dev/null +++ b/target/linux/ath79/dts/tp9343_tplink_tl-wa901nd.dtsi @@ -0,0 +1,52 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "tp9343_tplink_tl-wx.dtsi" + +/ { + aliases { + led-boot = &led_system; + led-failsafe = &led_system; + led-running = &led_system; + led-upgrade = &led_system; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "Reset button"; + linux,code = ; + gpios = <&gpio 1 GPIO_ACTIVE_LOW>; + }; + }; + + leds { + compatible = "gpio-leds"; + + led_system: system { + label = "tp-link:green:system"; + gpios = <&gpio 18 GPIO_ACTIVE_LOW>; + default-state = "on"; + }; + + qss { + label = "tp-link:green:qss"; + gpios = <&gpio 3 GPIO_ACTIVE_LOW>; + }; + + lan { + label = "tp-link:green:lan"; + gpios = <&gpio 7 GPIO_ACTIVE_LOW>; + }; + + wlan { + label = "tp-link:green:wlan"; + gpios = <&gpio 8 GPIO_ACTIVE_LOW>; + linux,default-trigger = "phy0tpt"; + }; + }; +}; + +ð1 { + compatible = "syscon", "simple-mfd"; +}; diff --git a/target/linux/ath79/dts/tp9343_tplink_tl-wr94x.dtsi b/target/linux/ath79/dts/tp9343_tplink_tl-wr94x.dtsi index aeb5525308..ea30d3b311 100644 --- a/target/linux/ath79/dts/tp9343_tplink_tl-wr94x.dtsi +++ b/target/linux/ath79/dts/tp9343_tplink_tl-wr94x.dtsi @@ -1,19 +1,8 @@ // SPDX-License-Identifier: GPL-2.0-or-later OR MIT -#include -#include - -#include "qca956x.dtsi" +#include "tp9343_tplink_tl-wx.dtsi" / { - chosen { - bootargs = "console=ttyS0,115200n8"; - }; - - aliases { - label-mac-device = &wmac; - }; - keys { compatible = "gpio-keys"; @@ -30,62 +19,3 @@ }; }; }; - -&spi { - status = "okay"; - num-cs = <1>; - - flash@0 { - compatible = "jedec,spi-nor"; - reg = <0>; - spi-max-frequency = <25000000>; - - partitions { - compatible = "fixed-partitions"; - #address-cells = <1>; - #size-cells = <1>; - - uboot: partition@0 { - label = "u-boot"; - reg = <0x000000 0x020000>; - read-only; - }; - - partition@20000 { - compatible = "tplink,firmware"; - label = "firmware"; - reg = <0x020000 0x3d0000>; - }; - - art: partition@3f0000 { - label = "art"; - reg = <0x3f0000 0x010000>; - read-only; - }; - }; - }; -}; - -&uart { - status = "okay"; -}; - -ð0 { - status = "okay"; - - phy-handle = <&swphy4>; - - mtd-mac-address = <&uboot 0x1fc00>; - mtd-mac-address-increment = <1>; -}; - -ð1 { - status = "okay"; -}; - -&wmac { - status = "okay"; - - mtd-cal-data = <&art 0x1000>; - mtd-mac-address = <&uboot 0x1fc00>; -}; diff --git a/target/linux/ath79/dts/tp9343_tplink_tl-wx.dtsi b/target/linux/ath79/dts/tp9343_tplink_tl-wx.dtsi new file mode 100644 index 0000000000..5050c8cbd5 --- /dev/null +++ b/target/linux/ath79/dts/tp9343_tplink_tl-wx.dtsi @@ -0,0 +1,76 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include +#include + +#include "qca956x.dtsi" + +/ { + aliases { + label-mac-device = &wmac; + }; + + chosen { + bootargs = "console=ttyS0,115200n8"; + }; +}; + +&spi { + status = "okay"; + + num-cs = <1>; + + flash@0 { + compatible = "jedec,spi-nor"; + reg = <0>; + spi-max-frequency = <25000000>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + uboot: partition@0 { + label = "u-boot"; + reg = <0x000000 0x020000>; + read-only; + }; + + partition@20000 { + compatible = "tplink,firmware"; + label = "firmware"; + reg = <0x020000 0x3d0000>; + }; + + art: partition@3f0000 { + label = "art"; + reg = <0x3f0000 0x010000>; + read-only; + }; + }; + }; +}; + +&uart { + status = "okay"; +}; + +ð0 { + status = "okay"; + + phy-handle = <&swphy4>; + + mtd-mac-address = <&uboot 0x1fc00>; + mtd-mac-address-increment = <1>; +}; + +ð1 { + status = "okay"; +}; + +&wmac { + status = "okay"; + + mtd-cal-data = <&art 0x1000>; + mtd-mac-address = <&uboot 0x1fc00>; +}; diff --git a/target/linux/ath79/image/tiny-tp-link.mk b/target/linux/ath79/image/tiny-tp-link.mk index 481329938a..a5a76edd05 100644 --- a/target/linux/ath79/image/tiny-tp-link.mk +++ b/target/linux/ath79/image/tiny-tp-link.mk @@ -170,6 +170,28 @@ define Device/tplink_tl-wa901nd-v2 endef TARGET_DEVICES += tplink_tl-wa901nd-v2 +define Device/tplink_tl-wa901nd-v4 + $(Device/tplink-4mlzma) + SOC := tp9343 + DEVICE_MODEL := TL-WA901ND + DEVICE_VARIANT := v4 + TPLINK_HWID := 0x09010004 + SUPPORTED_DEVICES += tl-wa901nd-v4 + IMAGE/factory.bin := tplink-v1-image factory -C EU +endef +TARGET_DEVICES += tplink_tl-wa901nd-v4 + +define Device/tplink_tl-wa901nd-v5 + $(Device/tplink-4mlzma) + SOC := tp9343 + DEVICE_MODEL := TL-WA901ND + DEVICE_VARIANT := v5 + TPLINK_HWID := 0x09010005 + SUPPORTED_DEVICES += tl-wa901nd-v5 + IMAGE/factory.bin := tplink-v1-image factory -C EU +endef +TARGET_DEVICES += tplink_tl-wa901nd-v5 + define Device/tplink_tl-wr703n $(Device/tplink-4mlzma) SOC := ar9331 diff --git a/target/linux/ath79/tiny/base-files/etc/board.d/01_leds b/target/linux/ath79/tiny/base-files/etc/board.d/01_leds index 30773db332..3588278b01 100755 --- a/target/linux/ath79/tiny/base-files/etc/board.d/01_leds +++ b/target/linux/ath79/tiny/base-files/etc/board.d/01_leds @@ -47,7 +47,9 @@ tplink,tl-wa730re-v1|\ tplink,tl-wa801nd-v1|\ tplink,tl-wa830re-v1|\ tplink,tl-wa860re-v1|\ -tplink,tl-wa901nd-v1) +tplink,tl-wa901nd-v1|\ +tplink,tl-wa901nd-v4|\ +tplink,tl-wa901nd-v5) ucidef_set_led_netdev "lan" "LAN" "tp-link:green:lan" "eth0" ;; tplink,tl-mr3420-v2|\ diff --git a/target/linux/ath79/tiny/base-files/etc/board.d/02_network b/target/linux/ath79/tiny/base-files/etc/board.d/02_network index 53e2a1ebd4..5e559363b2 100755 --- a/target/linux/ath79/tiny/base-files/etc/board.d/02_network +++ b/target/linux/ath79/tiny/base-files/etc/board.d/02_network @@ -41,6 +41,8 @@ ath79_setup_interfaces() tplink,tl-wa860re-v1|\ tplink,tl-wa901nd-v1|\ tplink,tl-wa901nd-v2|\ + tplink,tl-wa901nd-v4|\ + tplink,tl-wa901nd-v5|\ tplink,tl-wr703n) ucidef_set_interface_lan "eth0" ;; diff --git a/target/linux/bcm63xx/base-files/etc/board.d/01_leds b/target/linux/bcm63xx/base-files/etc/board.d/01_leds index dd1c565bb9..3f73d914f9 100755 --- a/target/linux/bcm63xx/base-files/etc/board.d/01_leds +++ b/target/linux/bcm63xx/base-files/etc/board.d/01_leds @@ -30,6 +30,9 @@ bt,home-hub-2-a) comtrend,ar-5315u) ucidef_set_led_usbdev "usb" "USB" "AR-5315u:green:usb" "1-1" ;; +comtrend,vr-3032u) + ucidef_set_led_usbdev "usb" "USB" "vr-3032u:green:usb" "1-1" + ;; huawei,echolife-hg553) ucidef_set_led_netdev "lan" "LAN" "HW553:blue:lan" "eth0" ucidef_set_led_usbdev "usb1" "USB1" "HW553:red:hspa" "1-1" diff --git a/target/linux/bcm63xx/base-files/etc/board.d/02_network b/target/linux/bcm63xx/base-files/etc/board.d/02_network index 7fa1514b4f..7203b1c3fc 100755 --- a/target/linux/bcm63xx/base-files/etc/board.d/02_network +++ b/target/linux/bcm63xx/base-files/etc/board.d/02_network @@ -99,6 +99,10 @@ sagem,fast-2704n) ucidef_add_switch "switch0" \ "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "8t@eth0" ;; +comtrend,vr-3032u) + ucidef_add_switch "switch0" \ + "0:lan:2" "1:lan:3" "2:lan:4" "3:lan:1" "8t@eth0" + ;; comtrend,wap-5813n) ucidef_add_switch "switch0" \ "0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "5t@eth0" diff --git a/target/linux/bcm63xx/base-files/lib/upgrade/platform.sh b/target/linux/bcm63xx/base-files/lib/upgrade/platform.sh index 5c9e2c25f7..0debff28bb 100644 --- a/target/linux/bcm63xx/base-files/lib/upgrade/platform.sh +++ b/target/linux/bcm63xx/base-files/lib/upgrade/platform.sh @@ -1,9 +1,19 @@ PART_NAME=linux +REQUIRE_IMAGE_METADATA=0 + platform_check_image() { [ "$#" -gt 1 ] && return 1 + + case "$(board_name)" in + comtrend,vr-3032u) + # NAND sysupgrade + return 0 + ;; + esac + case "$(get_magic_word "$1")" in 3600|3700|3800) - # 6348GW-11 boards use openwrt-96348GW-11-squashfs-cfe.bin files + # CFE tag versions return 0 ;; *) @@ -13,4 +23,50 @@ platform_check_image() { esac } -# use default for platform_do_upgrade() +cfe_jffs2_upgrade_tar() { + local tar_file="$1" + local kernel_mtd="$(find_mtd_index $CI_KERNPART)" + + if [ -z "$kernel_mtd" ]; then + echo "$CI_KERNPART partition not found" + return 1 + fi + + local board_dir=$(tar tf $tar_file | grep -m 1 '^sysupgrade-.*/$') + board_dir=${board_dir%/} + + local kernel_length=$(tar xf $tar_file ${board_dir}/kernel -O | wc -c 2> /dev/null) + local rootfs_length=$(tar xf $tar_file ${board_dir}/root -O | wc -c 2> /dev/null) + + if [ "$kernel_length" = 0 ]; then + echo "kernel cannot be empty" + return 1 + fi + + flash_erase -j /dev/mtd${kernel_mtd} 0 0 + tar xf $tar_file ${board_dir}/kernel -O | nandwrite /dev/mtd${kernel_mtd} - + + local rootfs_type="$(identify_tar "$tar_file" ${board_dir}/root)" + + nand_upgrade_prepare_ubi "$rootfs_length" "$rootfs_type" "0" "0" + + local ubidev="$( nand_find_ubi "$CI_UBIPART" )" + + local root_ubivol="$(nand_find_volume $ubidev $CI_ROOTPART)" + tar xf $tar_file ${board_dir}/root -O | \ + ubiupdatevol /dev/$root_ubivol -s $rootfs_length - + + nand_do_upgrade_success +} + +platform_do_upgrade() { + case "$(board_name)" in + comtrend,vr-3032u) + REQUIRE_IMAGE_METADATA=1 + cfe_jffs2_upgrade_tar "$1" + ;; + *) + default_do_upgrade "$1" + ;; + esac +} diff --git a/target/linux/bcm63xx/dts/bcm63168-comtrend-vr-3032u.dts b/target/linux/bcm63xx/dts/bcm63168-comtrend-vr-3032u.dts new file mode 100644 index 0000000000..cc96c403b6 --- /dev/null +++ b/target/linux/bcm63xx/dts/bcm63168-comtrend-vr-3032u.dts @@ -0,0 +1,185 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +/dts-v1/; + +#include "bcm63268.dtsi" + +#include + +/ { + model = "Comtrend VR-3032u"; + compatible = "comtrend,vr-3032u", "brcm,bcm63268"; + + aliases { + led-boot = &led_power_green; + led-failsafe = &led_power_green; + led-running = &led_power_green; + led-upgrade = &led_power_green; + }; + + chosen { + bootargs = "rootfstype=squashfs,ubifs noinitrd console=ttyS0,115200"; + stdout-path = "serial0:115200n8"; + }; + + keys { + compatible = "gpio-keys-polled"; + #address-cells = <1>; + #size-cells = <0>; + poll-interval = <20>; + + reset { + label = "reset"; + gpios = <&pinctrl 33 1>; + linux,code = ; + debounce-interval = <60>; + }; + + wps { + label = "wps"; + gpios = <&pinctrl 34 1>; + linux,code = ; + debounce-interval = <60>; + }; + }; +}; + +&leds { + status = "okay"; + brcm,serial-leds; + brcm,serial-dat-low; + brcm,serial-shift-inv; + + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_serial_led>; + + led@0 { + /* GPHY0 Spd 0 */ + reg = <0>; + brcm,hardware-controlled; + brcm,link-signal-sources = <0>; + }; + + led@1 { + /* GPHY0 Spd 1 */ + reg = <1>; + brcm,hardware-controlled; + brcm,link-signal-sources = <1>; + }; + + led@2 { + reg = <2>; + active-low; + label = "vr-3032u:red:inet"; + }; + + led@3 { + reg = <3>; + active-low; + label = "vr-3032u:green:dsl"; + }; + + led@4 { + reg = <4>; + active-low; + label = "vr-3032u:green:usb"; + }; + + led@7 { + reg = <7>; + active-low; + label = "vr-3032u:green:wps"; + }; + + led@8 { + reg = <8>; + active-low; + label = "vr-3032u:green:inet"; + }; + + led@9 { + /* EPHY0 Act */ + reg = <9>; + brcm,hardware-controlled; + }; + + led@10 { + /* EPHY1 Act */ + reg = <10>; + brcm,hardware-controlled; + }; + + led@11 { + /* EPHY2 Act */ + reg = <11>; + brcm,hardware-controlled; + }; + + led@12 { + /* GPHY0 Act */ + reg = <12>; + brcm,hardware-controlled; + }; + + led@13 { + /* EPHY0 Spd */ + reg = <13>; + brcm,hardware-controlled; + }; + + led@14 { + /* EPHY1 Spd */ + reg = <14>; + brcm,hardware-controlled; + }; + + led@15 { + /* EPHY2 Spd */ + reg = <15>; + brcm,hardware-controlled; + }; + + led_power_green: led@20 { + reg = <20>; + active-low; + label = "vr-3032u:green:power"; + default-state = "on"; + }; +}; + +&nflash { + status = "okay"; + + nandcs@0 { + compatible = "brcm,nandcs"; + #size-cells = <1>; + #address-cells = <1>; + reg = <0>; + nand-ecc-step-size = <512>; + nand-ecc-strength = <15>; + nand-on-flash-bbt; + brcm,nand-oob-sector-size = <64>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "cferom"; + reg = <0x0000000 0x0020000>; + read-only; + }; + + partition@20000 { + compatible = "brcm,wfi"; + label = "wfi"; + reg = <0x0020000 0x7ee0000>; + }; + }; + }; +}; + +&uart0 { + status = "okay"; +}; diff --git a/target/linux/bcm63xx/dts/bcm63268.dtsi b/target/linux/bcm63xx/dts/bcm63268.dtsi index 1b4b3e6178..0c08aead20 100644 --- a/target/linux/bcm63xx/dts/bcm63268.dtsi +++ b/target/linux/bcm63xx/dts/bcm63268.dtsi @@ -4,6 +4,7 @@ compatible = "brcm,bcm63268"; aliases { + nflash = &nflash; pinctrl = &pinctrl; serial0 = &uart0; serial1 = &uart1; @@ -239,6 +240,30 @@ /* clocks = <&clkctl 16>; */ }; + nflash: nand@10000200 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "brcm,nand-bcm6368", + "brcm,brcmnand-v4.0", + "brcm,brcmnand"; + reg = <0x10000200 0x180>, + <0x10000600 0x200>, + <0x100000b0 0x10>; + reg-names = "nand", + "nand-cache", + "nand-int-base"; + + interrupt-parent = <&periph_intc>; + interrupts = <50>; + + /* clocks = <&clkctl 20>; */ + + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_nand>; + + status = "disabled"; + }; + leds: led-controller@10001900 { #address-cells = <1>; #size-cells = <0>; diff --git a/target/linux/bcm63xx/dts/bcm6328.dtsi b/target/linux/bcm63xx/dts/bcm6328.dtsi index d08b6bab7a..f62fad783e 100644 --- a/target/linux/bcm63xx/dts/bcm6328.dtsi +++ b/target/linux/bcm63xx/dts/bcm6328.dtsi @@ -4,6 +4,7 @@ compatible = "brcm,bcm6328"; aliases { + nflash = &nflash; pinctrl = &pinctrl; serial0 = &uart0; serial1 = &uart1; @@ -179,6 +180,25 @@ status = "disabled"; }; + nflash: nand@10000200 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "brcm,nand-bcm6368", + "brcm,brcmnand-v2.2", + "brcm,brcmnand"; + reg = <0x10000200 0x180>, + <0x10000400 0x200>, + <0x10000070 0x10>; + reg-names = "nand", + "nand-cache", + "nand-int-base"; + + interrupt-parent = <&periph_intc>; + interrupts = <0>; + + status = "disabled"; + }; + leds: led-controller@10000800 { #address-cells = <1>; #size-cells = <0>; diff --git a/target/linux/bcm63xx/dts/bcm6362.dtsi b/target/linux/bcm63xx/dts/bcm6362.dtsi index 2ff5c52ad7..e639fc8837 100644 --- a/target/linux/bcm63xx/dts/bcm6362.dtsi +++ b/target/linux/bcm63xx/dts/bcm6362.dtsi @@ -4,6 +4,7 @@ compatible = "brcm,bcm6362"; aliases { + nflash = &nflash; pinctrl = &pinctrl; serial0 = &uart0; serial1 = &uart1; @@ -283,6 +284,30 @@ /* clocks = <&clkctl 16>; */ }; + nflash: nand@10000200 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "brcm,nand-bcm6368", + "brcm,brcmnand-v2.2", + "brcm,brcmnand"; + reg = <0x10000200 0x180>, + <0x10000600 0x200>, + <0x10000070 0x10>; + reg-names = "nand", + "nand-cache", + "nand-int-base"; + + interrupt-parent = <&periph_intc>; + interrupts = <12>; + + /* clocks = <&clkctl 20>; */ + + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_nand>; + + status = "disabled"; + }; + leds: led-controller@10001900 { #address-cells = <1>; #size-cells = <0>; diff --git a/target/linux/bcm63xx/dts/bcm6368.dtsi b/target/linux/bcm63xx/dts/bcm6368.dtsi index b834f9ef0f..b539020c21 100644 --- a/target/linux/bcm63xx/dts/bcm6368.dtsi +++ b/target/linux/bcm63xx/dts/bcm6368.dtsi @@ -4,6 +4,7 @@ compatible = "brcm,bcm6368"; aliases { + nflash = &nflash; pflash = &pflash; pinctrl = &pinctrl; serial0 = &uart0; @@ -298,6 +299,27 @@ status = "disabled"; }; + nflash: nand@10000200 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "brcm,nand-bcm6368", + "brcm,brcmnand-v2.1", + "brcm,brcmnand"; + reg = <0x10000200 0x180>, + <0x10000600 0x200>, + <0x10000070 0x10>; + reg-names = "nand", + "nand-cache", + "nand-int-base"; + + interrupt-parent = <&periph_intc>; + interrupts = <10>; + + /* clocks = <&clkctl 17>; */ + + status = "disabled"; + }; + lsspi: spi@10000800 { #address-cells = <1>; #size-cells = <0>; diff --git a/target/linux/bcm63xx/image/Makefile b/target/linux/bcm63xx/image/Makefile index 321aec93a1..e392d99f2c 100644 --- a/target/linux/bcm63xx/image/Makefile +++ b/target/linux/bcm63xx/image/Makefile @@ -105,6 +105,79 @@ define Build/cfe-bin $(CFE_EXTRAS) $(1) endef +define Build/cfe-jffs2 + $(STAGING_DIR_HOST)/bin/mkfs.jffs2 \ + --big-endian \ + --pad \ + --no-cleanmarkers \ + --eraseblock=$(patsubst %k,%KiB,$(BLOCKSIZE)) \ + --root=$(1) \ + --output=$@ \ + --compression-mode=none + + $(call Build/pad-to,$(BLOCKSIZE)) +endef + +define Build/cfe-jffs2-cferam + mv $@ $@.kernel + + rm -rf $@-cferam + mkdir -p $@-cferam + + # CFE ROM checks JFFS2 dirent version of cferam. + # If version is not > 0 it will ignore the fs entry. + # JFFS2 sets version 0 to the first fs entry and increments + # it on the following ones, so let's create a dummy file that + # will have version 0 and let cferam be the second (version 1). + touch $@-cferam/1-openwrt + # Add cferam as the last file in the JFFS2 partition + cp $(KDIR)/bcm63xx-cfe/$(CFE_RAM_FILE) $@-cferam/$(CFE_RAM_JFFS2_NAME) + + # The JFFS2 partition creation should result in the following + # layout: + # 1) 1-openwrt (version 0, ino 2) + # 2) cferam.000 (version 1, ino 3) + $(call Build/cfe-jffs2,$@-cferam) + + # Some devices need padding between CFE RAM and kernel + $(if $(CFE_RAM_JFFS2_PAD),$(call Build/pad-to,$(CFE_RAM_JFFS2_PAD))) + + # Append kernel + dd if=$@.kernel >> $@ + rm -f $@.kernel +endef + +define Build/cfe-jffs2-kernel + rm -rf $@-kernel + mkdir -p $@-kernel + + # CFE RAM checks JFFS2 dirent version of vmlinux. + # If version is not > 0 it will ignore the fs entry. + # JFFS2 sets version 0 to the first fs entry and increments + # it on the following ones, so let's create a dummy file that + # will have version 0 and let cferam be the second (version 1). + touch $@-kernel/1-openwrt + # vmlinux is located on a different JFFS2 partition, but CFE RAM + # ignores it, so let's create another dummy file that will match + # the JFFS2 ino of cferam entry on the first JFFS2 partition. + # CFE RAM won't be able to find vmlinux if cferam has the same + # ino as vmlinux. + touch $@-kernel/2-openwrt + # Add vmlinux as the last file in the JFFS2 partition + $(TOPDIR)/scripts/cfe-bin-header.py \ + --input-file $@ \ + --output-file $@-kernel/vmlinux.lz \ + --load-addr $(LOADER_ENTRY) \ + --entry-addr $(LOADER_ENTRY) + + # The JFFS2 partition creation should result in the following + # layout: + # 1) 1-openwrt (version 0, ino 2) + # 2) 2-openwrt (version 1, ino 3) + # 3) vmlinux.lz (version 2, ino 4) + $(call Build/cfe-jffs2,$@-kernel) +endef + define Build/cfe-old-bin $(TOPDIR)/scripts/brcmImage.pl -t -p \ -o $@ -b $(CFE_BOARD_ID) -c $(CFE_CHIP_ID) \ @@ -121,6 +194,17 @@ define Build/cfe-spw303v-bin $(CFE_EXTRAS) $(1) endef +define Build/cfe-wfi-tag + $(TOPDIR)/scripts/cfe-wfi-tag.py \ + --input-file $@ \ + --output-file $@.new \ + --version $(if $(1),$(1),$(CFE_WFI_VERSION)) \ + --chip-id $(CFE_WFI_CHIP_ID) \ + --flash-type $(CFE_WFI_FLASH_TYPE) \ + $(if $(CFE_WFI_FLAGS),--flags $(CFE_WFI_FLAGS)) + mv $@.new $@ +endef + define Build/spw303v-bin $(STAGING_DIR_HOST)/bin/spw303v -i $@ -o $@.spw303v mv $@.spw303v $@ @@ -170,4 +254,8 @@ USB2_PACKAGES := kmod-usb2 kmod-usb-ohci kmod-usb-ledtrig-usbport include bcm63xx.mk +ifeq ($(SUBTARGET),smp) +include bcm63xx_nand.mk +endif + $(eval $(call BuildImage)) diff --git a/target/linux/bcm63xx/image/bcm63xx_nand.mk b/target/linux/bcm63xx/image/bcm63xx_nand.mk new file mode 100644 index 0000000000..5be27a3f75 --- /dev/null +++ b/target/linux/bcm63xx/image/bcm63xx_nand.mk @@ -0,0 +1,53 @@ +# +# BCM63XX NAND Profiles +# + +DEVICE_VARS += CFE_RAM_FILE +DEVICE_VARS += CFE_RAM_JFFS2_NAME CFE_RAM_JFFS2_PAD +DEVICE_VARS += CFE_WFI_CHIP_ID CFE_WFI_FLASH_TYPE +DEVICE_VARS += CFE_WFI_FLAGS CFE_WFI_VERSION + +# CFE expects a single JFFS2 partition with cferam and kernel. However, +# it's possible to fool CFE into properly loading both cferam and kernel +# from two different JFFS2 partitions by adding dummy files (see +# cfe-jffs2-cferam and cfe-jffs2-kernel). +# Separate JFFS2 partitions allow upgrading openwrt without reflashing cferam +# JFFS2 partition, which is much safer in case anything goes wrong. +define Device/bcm63xx-nand + FILESYSTEMS := squashfs ubifs + KERNEL := kernel-bin | append-dtb | relocate-kernel | lzma | cfe-jffs2-kernel + KERNEL_INITRAMFS := kernel-bin | append-dtb | lzma | loader-lzma elf + IMAGES := cfe.bin sysupgrade.bin + IMAGE/cfe.bin := append-kernel | pad-to $$$$(KERNEL_SIZE) | cfe-jffs2-cferam | append-ubi | cfe-wfi-tag + IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata + KERNEL_SIZE := 5120k + CFE_CHIP_ID := + CFE_RAM_FILE := + CFE_RAM_JFFS2_NAME := + CFE_RAM_JFFS2_PAD := + CFE_WFI_VERSION := 0x5731 + CFE_WFI_CHIP_ID = 0x$$(CFE_CHIP_ID) + CFE_WFI_FLASH_TYPE := + CFE_WFI_FLAGS := + UBINIZE_OPTS := -E 5 + DEVICE_PACKAGES += nand-utils + SUPPORTED_DEVICES := $(subst _,$(comma),$(1)) +endef + +### Comtrend ### +define Device/comtrend_vr-3032u + $(Device/bcm63xx-nand) + DEVICE_VENDOR := Comtrend + DEVICE_MODEL := VR-3032u + CFE_CHIP_ID := 63268 + SOC := bcm63168 + CFE_RAM_FILE := comtrend,vr-3032u/cferam.000 + CFE_RAM_JFFS2_NAME := cferam.000 + BLOCKSIZE := 128k + PAGESIZE := 2048 + SUBPAGESIZE := 512 + VID_HDR_OFFSET := 2048 + DEVICE_PACKAGES += $(USB2_PACKAGES) + CFE_WFI_FLASH_TYPE := 3 +endef +TARGET_DEVICES += comtrend_vr-3032u diff --git a/target/linux/bcm63xx/patches-5.4/430-MIPS-BCM63XX-add-nand-clocks.patch b/target/linux/bcm63xx/patches-5.4/430-MIPS-BCM63XX-add-nand-clocks.patch new file mode 100644 index 0000000000..883f76fe76 --- /dev/null +++ b/target/linux/bcm63xx/patches-5.4/430-MIPS-BCM63XX-add-nand-clocks.patch @@ -0,0 +1,50 @@ +--- a/arch/mips/bcm63xx/clk.c ++++ b/arch/mips/bcm63xx/clk.c +@@ -430,6 +430,23 @@ static struct clk clk_pcie = { + }; + + /* ++ * NAND clock ++ */ ++static void nand_set(struct clk *clk, int enable) ++{ ++ if (BCMCPU_IS_6362()) ++ bcm_hwclock_set(CKCTL_6362_NAND_EN, enable); ++ else if (BCMCPU_IS_6368()) ++ bcm_hwclock_set(CKCTL_6368_NAND_EN, enable); ++ else if (BCMCPU_IS_63268()) ++ bcm_hwclock_set(CKCTL_63268_NAND_EN, enable); ++} ++ ++static struct clk clk_nand = { ++ .set = nand_set, ++}; ++ ++/* + * Internal peripheral clock + */ + static struct clk clk_periph = { +@@ -612,6 +629,7 @@ static struct clk_lookup bcm6362_clks[] + CLKDEV_INIT("bcm63xx-hsspi.0", "pll", &clk_hsspi_pll), + CLKDEV_INIT("10001000.spi", "pll", &clk_hsspi_pll), + /* gated clocks */ ++ CLKDEV_INIT(NULL, "nand", &clk_nand), + CLKDEV_INIT(NULL, "enetsw", &clk_enetsw), + CLKDEV_INIT(NULL, "usbh", &clk_usbh), + CLKDEV_INIT(NULL, "usbd", &clk_usbd), +@@ -629,6 +647,7 @@ static struct clk_lookup bcm6368_clks[] + CLKDEV_INIT("10000100.serial", "refclk", &clk_periph), + CLKDEV_INIT("10000120.serial", "refclk", &clk_periph), + /* gated clocks */ ++ CLKDEV_INIT(NULL, "nand", &clk_nand), + CLKDEV_INIT(NULL, "enetsw", &clk_enetsw), + CLKDEV_INIT(NULL, "usbh", &clk_usbh), + CLKDEV_INIT(NULL, "usbd", &clk_usbd), +@@ -647,6 +666,7 @@ static struct clk_lookup bcm63268_clks[] + CLKDEV_INIT("bcm63xx-hsspi.0", "pll", &clk_hsspi_pll), + CLKDEV_INIT("10001000.spi", "pll", &clk_hsspi_pll), + /* gated clocks */ ++ CLKDEV_INIT(NULL, "nand", &clk_nand), + CLKDEV_INIT(NULL, "enetsw", &clk_enetsw), + CLKDEV_INIT(NULL, "usbh", &clk_usbh), + CLKDEV_INIT(NULL, "usbd", &clk_usbd), diff --git a/target/linux/bcm63xx/patches-5.4/431-MIPS-BCM63XX-add-nand-rset.patch b/target/linux/bcm63xx/patches-5.4/431-MIPS-BCM63XX-add-nand-rset.patch new file mode 100644 index 0000000000..1172b23197 --- /dev/null +++ b/target/linux/bcm63xx/patches-5.4/431-MIPS-BCM63XX-add-nand-rset.patch @@ -0,0 +1,145 @@ +--- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_cpu.h ++++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_cpu.h +@@ -181,7 +181,8 @@ enum bcm63xx_regs_set { + RSET_PCMDMAC, + RSET_PCMDMAS, + RSET_RNG, +- RSET_MISC ++ RSET_MISC, ++ RSET_NAND + }; + + #define RSET_DSL_LMEM_SIZE (64 * 1024 * 4) +@@ -259,6 +260,7 @@ enum bcm63xx_regs_set { + #define BCM_3368_PCMDMAS_BASE (0xdeadbeef) + #define BCM_3368_RNG_BASE (0xdeadbeef) + #define BCM_3368_MISC_BASE (0xdeadbeef) ++#define BCM_3368_NAND_BASE (0xdeadbeef) + + /* + * 6318 register sets base address +@@ -306,6 +308,7 @@ enum bcm63xx_regs_set { + #define BCM_6318_PCMDMAS_BASE (0xdeadbeef) + #define BCM_6318_RNG_BASE (0xdeadbeef) + #define BCM_6318_MISC_BASE (0xb0000280) ++#define BCM_6318_NAND_BASE (0xdeadbeef) + #define BCM_6318_OTP_BASE (0xdeadbeef) + + #define BCM_6318_STRAP_BASE (0xb0000900) +@@ -356,6 +359,7 @@ enum bcm63xx_regs_set { + #define BCM_6328_PCMDMAS_BASE (0xdeadbeef) + #define BCM_6328_RNG_BASE (0xdeadbeef) + #define BCM_6328_MISC_BASE (0xb0001800) ++#define BCM_6328_NAND_BASE (0xb0000200) + #define BCM_6328_OTP_BASE (0xb0000600) + + /* +@@ -405,6 +409,7 @@ enum bcm63xx_regs_set { + #define BCM_6338_PCMDMAS_BASE (0xdeadbeef) + #define BCM_6338_RNG_BASE (0xdeadbeef) + #define BCM_6338_MISC_BASE (0xdeadbeef) ++#define BCM_6338_NAND_BASE (0xdeadbeef) + + /* + * 6345 register sets base address +@@ -453,6 +458,7 @@ enum bcm63xx_regs_set { + #define BCM_6345_PCMDMAS_BASE (0xdeadbeef) + #define BCM_6345_RNG_BASE (0xdeadbeef) + #define BCM_6345_MISC_BASE (0xdeadbeef) ++#define BCM_6345_NAND_BASE (0xdeadbeef) + + /* + * 6348 register sets base address +@@ -499,6 +505,7 @@ enum bcm63xx_regs_set { + #define BCM_6348_PCMDMAS_BASE (0xdeadbeef) + #define BCM_6348_RNG_BASE (0xdeadbeef) + #define BCM_6348_MISC_BASE (0xdeadbeef) ++#define BCM_6348_NAND_BASE (0xdeadbeef) + + /* + * 6358 register sets base address +@@ -545,7 +552,7 @@ enum bcm63xx_regs_set { + #define BCM_6358_PCMDMAS_BASE (0xfffe1a00) + #define BCM_6358_RNG_BASE (0xdeadbeef) + #define BCM_6358_MISC_BASE (0xdeadbeef) +- ++#define BCM_6358_NAND_BASE (0xdeadbeef) + + /* + * 6362 register sets base address +@@ -593,6 +600,7 @@ enum bcm63xx_regs_set { + #define BCM_6362_PCMDMAS_BASE (0xdeadbeef) + #define BCM_6362_RNG_BASE (0xdeadbeef) + #define BCM_6362_MISC_BASE (0xb0001800) ++#define BCM_6362_NAND_BASE (0xb0000200) + + #define BCM_6362_NAND_REG_BASE (0xb0000200) + #define BCM_6362_NAND_CACHE_BASE (0xb0000600) +@@ -648,6 +656,7 @@ enum bcm63xx_regs_set { + #define BCM_6368_PCMDMAS_BASE (0xb0005c00) + #define BCM_6368_RNG_BASE (0xb0004180) + #define BCM_6368_MISC_BASE (0xdeadbeef) ++#define BCM_6368_NAND_BASE (0xb0000200) + + /* + * 63268 register sets base address +@@ -695,6 +704,7 @@ enum bcm63xx_regs_set { + #define BCM_63268_PCMDMAS_BASE (0xdeadbeef) + #define BCM_63268_RNG_BASE (0xdeadbeef) + #define BCM_63268_MISC_BASE (0xb0001800) ++#define BCM_63268_NAND_BASE (0xb0000200) + + extern const unsigned long *bcm63xx_regs_base; + +@@ -740,6 +750,7 @@ extern const unsigned long *bcm63xx_regs + [RSET_PCMDMAS] = BCM_## __cpu ##_PCMDMAS_BASE, \ + [RSET_RNG] = BCM_## __cpu ##_RNG_BASE, \ + [RSET_MISC] = BCM_## __cpu ##_MISC_BASE, \ ++ [RSET_NAND] = BCM_## __cpu ##_NAND_BASE, \ + + + static inline unsigned long bcm63xx_regset_address(enum bcm63xx_regs_set set) +--- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_io.h ++++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_io.h +@@ -111,5 +111,7 @@ + #define bcm_ddr_writel(v, o) bcm_rset_writel(RSET_DDR, (v), (o)) + #define bcm_misc_readl(o) bcm_rset_readl(RSET_MISC, (o)) + #define bcm_misc_writel(v, o) bcm_rset_writel(RSET_MISC, (v), (o)) ++#define bcm_nand_readl(o) bcm_rset_readl(RSET_NAND, (o)) ++#define bcm_nand_writel(v, o) bcm_rset_writel(RSET_NAND, (v), (o)) + + #endif /* ! BCM63XX_IO_H_ */ +--- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h ++++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h +@@ -1688,4 +1688,31 @@ + #define OTP_USER_BITS_6328_REG(i) (0x20 + (i) * 4) + #define OTP_6328_REG3_TP1_DISABLED BIT(9) + ++/************************************************************************* ++ * _REG relative to RSET_NAND ++ *************************************************************************/ ++ ++#define NAND_CS_SEL_REG 0x14 ++#define NAND_CS_SEL_EBC_CS0_SEL (1 << 0) ++#define NAND_CS_SEL_EBC_CS1_SEL (1 << 1) ++#define NAND_CS_SEL_EBC_CS2_SEL (1 << 2) ++#define NAND_CS_SEL_EBC_CS3_SEL (1 << 3) ++#define NAND_CS_SEL_EBC_CS4_SEL (1 << 4) ++#define NAND_CS_SEL_EBC_CS5_SEL (1 << 5) ++#define NAND_CS_SEL_EBC_CS6_SEL (1 << 6) ++#define NAND_CS_SEL_EBC_CS7_SEL (1 << 7) ++#define NAND_CS_SEL_EBI_CS0_USES_NAND (1 << 8) ++#define NAND_CS_SEL_EBI_CS1_USES_NAND (1 << 9) ++#define NAND_CS_SEL_EBI_CS2_USES_NAND (1 << 10) ++#define NAND_CS_SEL_EBI_CS3_USES_NAND (1 << 11) ++#define NAND_CS_SEL_EBI_CS4_USES_NAND (1 << 12) ++#define NAND_CS_SEL_EBI_CS5_USES_NAND (1 << 13) ++#define NAND_CS_SEL_EBI_CS6_USES_NAND (1 << 14) ++#define NAND_CS_SEL_EBI_CS7_USES_NAND (1 << 15) ++#define NAND_CS_SEL_WR_PROT_BLK0 (1 << 28) ++#define NAND_CS_SEL_AUTO_DEV_ID (1 << 30) ++#define NAND_CS_SEL_CS_LOCK (1 << 31) ++ ++#define NAND_CS_XOR_REG 0x18 ++ + #endif /* BCM63XX_REGS_H_ */ diff --git a/target/linux/bcm63xx/patches-5.4/432-MIPS-BCM63XX-detect-nand-nvram.patch b/target/linux/bcm63xx/patches-5.4/432-MIPS-BCM63XX-detect-nand-nvram.patch new file mode 100644 index 0000000000..5a2a5f2489 --- /dev/null +++ b/target/linux/bcm63xx/patches-5.4/432-MIPS-BCM63XX-detect-nand-nvram.patch @@ -0,0 +1,17 @@ +--- a/arch/mips/bcm63xx/dev-flash.c ++++ b/arch/mips/bcm63xx/dev-flash.c +@@ -229,6 +229,14 @@ void __init bcm63xx_flash_detect(void) + } + + bcm_rset_writel(RSET_HSSPI, val, HSSPI_FLASH_CTRL_REG); ++ } else if (flash_type == BCM63XX_FLASH_TYPE_NAND && ++ (BCMCPU_IS_6328() || BCMCPU_IS_6362() || BCMCPU_IS_6368() || ++ BCMCPU_IS_63268())) { ++ bcm_nand_writel(NAND_CS_SEL_AUTO_DEV_ID ++ | NAND_CS_SEL_EBI_CS0_USES_NAND ++ | NAND_CS_SEL_EBC_CS0_SEL, ++ NAND_CS_SEL_REG); ++ bcm_nand_writel(1, NAND_CS_XOR_REG); + } + } + diff --git a/target/linux/bcm63xx/patches-5.4/433-MIPS-BCM63XX-enable-nand-support.patch b/target/linux/bcm63xx/patches-5.4/433-MIPS-BCM63XX-enable-nand-support.patch new file mode 100644 index 0000000000..7d63ee7983 --- /dev/null +++ b/target/linux/bcm63xx/patches-5.4/433-MIPS-BCM63XX-enable-nand-support.patch @@ -0,0 +1,17 @@ +--- a/arch/mips/bcm63xx/dev-flash.c ++++ b/arch/mips/bcm63xx/dev-flash.c +@@ -271,8 +271,12 @@ int __init bcm63xx_flash_register(void) + return -ENODEV; + } + case BCM63XX_FLASH_TYPE_NAND: +- pr_warn("unsupported NAND flash detected\n"); +- return -ENODEV; ++ if (board_of_device_present("nflash")) { ++ return 0; ++ } else { ++ pr_warn("unsupported NAND flash detected\n"); ++ return -ENODEV; ++ } + default: + pr_err("flash detection failed for BCM%x: %d\n", + bcm63xx_get_cpu_id(), flash_type); diff --git a/target/linux/bcm63xx/patches-5.4/434-nand-raw-use-write_oob_raw-for-MTD_OPS_AUTO_OOB-mode.patch b/target/linux/bcm63xx/patches-5.4/434-nand-raw-use-write_oob_raw-for-MTD_OPS_AUTO_OOB-mode.patch new file mode 100644 index 0000000000..cf4322f29f --- /dev/null +++ b/target/linux/bcm63xx/patches-5.4/434-nand-raw-use-write_oob_raw-for-MTD_OPS_AUTO_OOB-mode.patch @@ -0,0 +1,11 @@ +--- a/drivers/mtd/nand/raw/nand_base.c ++++ b/drivers/mtd/nand/raw/nand_base.c +@@ -488,7 +488,7 @@ static int nand_do_write_oob(struct nand + + nand_fill_oob(chip, ops->oobbuf, ops->ooblen, ops); + +- if (ops->mode == MTD_OPS_RAW) ++ if (ops->mode == MTD_OPS_AUTO_OOB || ops->mode == MTD_OPS_RAW) + status = chip->ecc.write_oob_raw(chip, page & chip->pagemask); + else + status = chip->ecc.write_oob(chip, page & chip->pagemask); diff --git a/target/linux/bcm63xx/patches-5.4/435-mtd-rawnand-brcmnand-correctly-verify-erased-pages.patch b/target/linux/bcm63xx/patches-5.4/435-mtd-rawnand-brcmnand-correctly-verify-erased-pages.patch new file mode 100644 index 0000000000..cbd9e9e147 --- /dev/null +++ b/target/linux/bcm63xx/patches-5.4/435-mtd-rawnand-brcmnand-correctly-verify-erased-pages.patch @@ -0,0 +1,42 @@ +--- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c ++++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c +@@ -1787,28 +1787,31 @@ static int brcmnand_read_by_pio(struct m + static int brcmstb_nand_verify_erased_page(struct mtd_info *mtd, + struct nand_chip *chip, void *buf, u64 addr) + { +- int i, sas; +- void *oob = chip->oob_poi; ++ struct mtd_oob_region ecc; ++ int i; + int bitflips = 0; + int page = addr >> chip->page_shift; + int ret; ++ void *ecc_bytes; + void *ecc_chunk; + + if (!buf) + buf = nand_get_data_buf(chip); + +- sas = mtd->oobsize / chip->ecc.steps; +- + /* read without ecc for verification */ + ret = chip->ecc.read_page_raw(chip, buf, true, page); + if (ret) + return ret; + +- for (i = 0; i < chip->ecc.steps; i++, oob += sas) { ++ for (i = 0; i < chip->ecc.steps; i++) { + ecc_chunk = buf + chip->ecc.size * i; +- ret = nand_check_erased_ecc_chunk(ecc_chunk, +- chip->ecc.size, +- oob, sas, NULL, 0, ++ ++ mtd_ooblayout_ecc(mtd, i, &ecc); ++ ecc_bytes = chip->oob_poi + ecc.offset; ++ ++ ret = nand_check_erased_ecc_chunk(ecc_chunk, chip->ecc.size, ++ ecc_bytes, ecc.length, ++ NULL, 0, + chip->ecc.strength); + if (ret < 0) + return ret; diff --git a/target/linux/bcm63xx/patches-5.4/436-mtd-rawnand-brcmnand-fix-hamming-oob-layout.patch b/target/linux/bcm63xx/patches-5.4/436-mtd-rawnand-brcmnand-fix-hamming-oob-layout.patch new file mode 100644 index 0000000000..40536c282f --- /dev/null +++ b/target/linux/bcm63xx/patches-5.4/436-mtd-rawnand-brcmnand-fix-hamming-oob-layout.patch @@ -0,0 +1,21 @@ +--- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c ++++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c +@@ -1019,11 +1019,14 @@ static int brcmnand_hamming_ooblayout_fr + if (!section) { + /* + * Small-page NAND use byte 6 for BBI while large-page +- * NAND use byte 0. ++ * NAND use bytes 0 and 1. + */ +- if (cfg->page_size > 512) +- oobregion->offset++; +- oobregion->length--; ++ if (cfg->page_size > 512) { ++ oobregion->offset += 2; ++ oobregion->length -= 2; ++ } else { ++ oobregion->length--; ++ } + } + } + diff --git a/target/linux/bcm63xx/patches-5.4/437-mtd-rawnand-brcmnand-improve-hamming-oob-layout.patch b/target/linux/bcm63xx/patches-5.4/437-mtd-rawnand-brcmnand-improve-hamming-oob-layout.patch new file mode 100644 index 0000000000..68bbc7ad19 --- /dev/null +++ b/target/linux/bcm63xx/patches-5.4/437-mtd-rawnand-brcmnand-improve-hamming-oob-layout.patch @@ -0,0 +1,52 @@ +--- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c ++++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c +@@ -1003,33 +1003,30 @@ static int brcmnand_hamming_ooblayout_fr + struct brcmnand_cfg *cfg = &host->hwcfg; + int sas = cfg->spare_area_size << cfg->sector_size_1k; + int sectors = cfg->page_size / (512 << cfg->sector_size_1k); ++ u32 next; + +- if (section >= sectors * 2) ++ if (section > sectors) + return -ERANGE; + +- oobregion->offset = (section / 2) * sas; ++ next = (section * sas); ++ if (section < sectors) ++ next += 6; + +- if (section & 1) { +- oobregion->offset += 9; +- oobregion->length = 7; ++ if (section) { ++ oobregion->offset = ((section - 1) * sas) + 9; + } else { +- oobregion->length = 6; +- +- /* First sector of each page may have BBI */ +- if (!section) { +- /* +- * Small-page NAND use byte 6 for BBI while large-page +- * NAND use bytes 0 and 1. +- */ +- if (cfg->page_size > 512) { +- oobregion->offset += 2; +- oobregion->length -= 2; +- } else { +- oobregion->length--; +- } ++ if (cfg->page_size > 512) { ++ /* Large page NAND uses first 2 bytes for BBI */ ++ oobregion->offset = 2; ++ } else { ++ /* Small page NAND uses last byte before ECC for BBI */ ++ oobregion->offset = 0; ++ next--; + } + } + ++ oobregion->length = next - oobregion->offset; ++ + return 0; + } + diff --git a/target/linux/bcm63xx/patches-5.4/438-mtd-rawnand-brcmnand-rename-v4-registers.patch b/target/linux/bcm63xx/patches-5.4/438-mtd-rawnand-brcmnand-rename-v4-registers.patch new file mode 100644 index 0000000000..091f63f663 --- /dev/null +++ b/target/linux/bcm63xx/patches-5.4/438-mtd-rawnand-brcmnand-rename-v4-registers.patch @@ -0,0 +1,24 @@ +--- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c ++++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c +@@ -269,8 +269,8 @@ enum brcmnand_reg { + BRCMNAND_FC_BASE, + }; + +-/* BRCMNAND v4.0 */ +-static const u16 brcmnand_regs_v40[] = { ++/* BRCMNAND v3.3-v4.0 */ ++static const u16 brcmnand_regs_v33[] = { + [BRCMNAND_CMD_START] = 0x04, + [BRCMNAND_CMD_EXT_ADDRESS] = 0x08, + [BRCMNAND_CMD_ADDRESS] = 0x0c, +@@ -522,8 +522,8 @@ static int brcmnand_revision_init(struct + ctrl->reg_offsets = brcmnand_regs_v60; + else if (ctrl->nand_version >= 0x0500) + ctrl->reg_offsets = brcmnand_regs_v50; +- else if (ctrl->nand_version >= 0x0400) +- ctrl->reg_offsets = brcmnand_regs_v40; ++ else if (ctrl->nand_version >= 0x0303) ++ ctrl->reg_offsets = brcmnand_regs_v33; + + /* Chip-select stride */ + if (ctrl->nand_version >= 0x0701) diff --git a/target/linux/bcm63xx/patches-5.4/439-mtd-rawnand-brcmnand-fix-CS0-layout.patch b/target/linux/bcm63xx/patches-5.4/439-mtd-rawnand-brcmnand-fix-CS0-layout.patch new file mode 100644 index 0000000000..fdeff8734d --- /dev/null +++ b/target/linux/bcm63xx/patches-5.4/439-mtd-rawnand-brcmnand-fix-CS0-layout.patch @@ -0,0 +1,14 @@ +--- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c ++++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c +@@ -537,8 +537,9 @@ static int brcmnand_revision_init(struct + } else { + ctrl->cs_offsets = brcmnand_cs_offsets; + +- /* v5.0 and earlier has a different CS0 offset layout */ +- if (ctrl->nand_version <= 0x0500) ++ /* v3.3-5.0 have a different CS0 offset layout */ ++ if (ctrl->nand_version >= 0x0303 && ++ ctrl->nand_version <= 0x0500) + ctrl->cs0_offsets = brcmnand_cs_offsets_cs0; + } + diff --git a/target/linux/bcm63xx/patches-5.4/440-mtd-rawnand-brcmnand-rename-page-sizes.patch b/target/linux/bcm63xx/patches-5.4/440-mtd-rawnand-brcmnand-rename-page-sizes.patch new file mode 100644 index 0000000000..cdf8d3d4d6 --- /dev/null +++ b/target/linux/bcm63xx/patches-5.4/440-mtd-rawnand-brcmnand-rename-page-sizes.patch @@ -0,0 +1,20 @@ +--- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c ++++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c +@@ -502,7 +502,7 @@ static int brcmnand_revision_init(struct + { + static const unsigned int block_sizes_v6[] = { 8, 16, 128, 256, 512, 1024, 2048, 0 }; + static const unsigned int block_sizes_v4[] = { 16, 128, 8, 512, 256, 1024, 2048, 0 }; +- static const unsigned int page_sizes[] = { 512, 2048, 4096, 8192, 0 }; ++ static const unsigned int page_sizes_v3_4[] = { 512, 2048, 4096, 8192, 0 }; + + ctrl->nand_version = nand_readreg(ctrl, 0) & 0xffff; + +@@ -549,7 +549,7 @@ static int brcmnand_revision_init(struct + ctrl->max_page_size = 16 * 1024; + ctrl->max_block_size = 2 * 1024 * 1024; + } else { +- ctrl->page_sizes = page_sizes; ++ ctrl->page_sizes = page_sizes_v3_4; + if (ctrl->nand_version >= 0x0600) + ctrl->block_sizes = block_sizes_v6; + else diff --git a/target/linux/bcm63xx/patches-5.4/441-mtd-rawnand-brcmnand-support-v2.1-v2.2-controllers.patch b/target/linux/bcm63xx/patches-5.4/441-mtd-rawnand-brcmnand-support-v2.1-v2.2-controllers.patch new file mode 100644 index 0000000000..a212a5bda9 --- /dev/null +++ b/target/linux/bcm63xx/patches-5.4/441-mtd-rawnand-brcmnand-support-v2.1-v2.2-controllers.patch @@ -0,0 +1,143 @@ +--- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c ++++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c +@@ -269,6 +269,36 @@ enum brcmnand_reg { + BRCMNAND_FC_BASE, + }; + ++/* BRCMNAND v2.1-v2.2 */ ++static const u16 brcmnand_regs_v21[] = { ++ [BRCMNAND_CMD_START] = 0x04, ++ [BRCMNAND_CMD_EXT_ADDRESS] = 0x08, ++ [BRCMNAND_CMD_ADDRESS] = 0x0c, ++ [BRCMNAND_INTFC_STATUS] = 0x5c, ++ [BRCMNAND_CS_SELECT] = 0x14, ++ [BRCMNAND_CS_XOR] = 0x18, ++ [BRCMNAND_LL_OP] = 0, ++ [BRCMNAND_CS0_BASE] = 0x40, ++ [BRCMNAND_CS1_BASE] = 0, ++ [BRCMNAND_CORR_THRESHOLD] = 0, ++ [BRCMNAND_CORR_THRESHOLD_EXT] = 0, ++ [BRCMNAND_UNCORR_COUNT] = 0, ++ [BRCMNAND_CORR_COUNT] = 0, ++ [BRCMNAND_CORR_EXT_ADDR] = 0x60, ++ [BRCMNAND_CORR_ADDR] = 0x64, ++ [BRCMNAND_UNCORR_EXT_ADDR] = 0x68, ++ [BRCMNAND_UNCORR_ADDR] = 0x6c, ++ [BRCMNAND_SEMAPHORE] = 0x50, ++ [BRCMNAND_ID] = 0x54, ++ [BRCMNAND_ID_EXT] = 0, ++ [BRCMNAND_LL_RDATA] = 0, ++ [BRCMNAND_OOB_READ_BASE] = 0x20, ++ [BRCMNAND_OOB_READ_10_BASE] = 0, ++ [BRCMNAND_OOB_WRITE_BASE] = 0x30, ++ [BRCMNAND_OOB_WRITE_10_BASE] = 0, ++ [BRCMNAND_FC_BASE] = 0x200, ++}; ++ + /* BRCMNAND v3.3-v4.0 */ + static const u16 brcmnand_regs_v33[] = { + [BRCMNAND_CMD_START] = 0x04, +@@ -502,12 +532,16 @@ static int brcmnand_revision_init(struct + { + static const unsigned int block_sizes_v6[] = { 8, 16, 128, 256, 512, 1024, 2048, 0 }; + static const unsigned int block_sizes_v4[] = { 16, 128, 8, 512, 256, 1024, 2048, 0 }; ++ static const unsigned int block_sizes_v2_2[] = { 16, 128, 8, 512, 256, 0 }; ++ static const unsigned int block_sizes_v2_1[] = { 16, 128, 8, 512, 0 }; + static const unsigned int page_sizes_v3_4[] = { 512, 2048, 4096, 8192, 0 }; ++ static const unsigned int page_sizes_v2_2[] = { 512, 2048, 4096, 0 }; ++ static const unsigned int page_sizes_v2_1[] = { 512, 2048, 0 }; + + ctrl->nand_version = nand_readreg(ctrl, 0) & 0xffff; + +- /* Only support v4.0+? */ +- if (ctrl->nand_version < 0x0400) { ++ /* Only support v2.1+ */ ++ if (ctrl->nand_version < 0x0201) { + dev_err(ctrl->dev, "version %#x not supported\n", + ctrl->nand_version); + return -ENODEV; +@@ -524,6 +558,8 @@ static int brcmnand_revision_init(struct + ctrl->reg_offsets = brcmnand_regs_v50; + else if (ctrl->nand_version >= 0x0303) + ctrl->reg_offsets = brcmnand_regs_v33; ++ else if (ctrl->nand_version >= 0x0201) ++ ctrl->reg_offsets = brcmnand_regs_v21; + + /* Chip-select stride */ + if (ctrl->nand_version >= 0x0701) +@@ -549,14 +585,27 @@ static int brcmnand_revision_init(struct + ctrl->max_page_size = 16 * 1024; + ctrl->max_block_size = 2 * 1024 * 1024; + } else { +- ctrl->page_sizes = page_sizes_v3_4; ++ if (ctrl->nand_version >= 0x0304) ++ ctrl->page_sizes = page_sizes_v3_4; ++ else if (ctrl->nand_version >= 0x0202) ++ ctrl->page_sizes = page_sizes_v2_2; ++ else ++ ctrl->page_sizes = page_sizes_v2_1; ++ + if (ctrl->nand_version >= 0x0600) + ctrl->block_sizes = block_sizes_v6; +- else ++ else if (ctrl->nand_version >= 0x0400) + ctrl->block_sizes = block_sizes_v4; ++ else if (ctrl->nand_version >= 0x0202) ++ ctrl->block_sizes = block_sizes_v2_2; ++ else ++ ctrl->block_sizes = block_sizes_v2_1; + + if (ctrl->nand_version < 0x0400) { +- ctrl->max_page_size = 4096; ++ if (ctrl->nand_version < 0x0202) ++ ctrl->max_page_size = 2048; ++ else ++ ctrl->max_page_size = 4096; + ctrl->max_block_size = 512 * 1024; + } + } +@@ -724,6 +773,9 @@ static void brcmnand_wr_corr_thresh(stru + enum brcmnand_reg reg = BRCMNAND_CORR_THRESHOLD; + int cs = host->cs; + ++ if (!ctrl->reg_offsets[reg]) ++ return; ++ + if (ctrl->nand_version == 0x0702) + bits = 7; + else if (ctrl->nand_version >= 0x0600) +@@ -782,8 +834,10 @@ static inline u32 brcmnand_spare_area_ma + return GENMASK(7, 0); + else if (ctrl->nand_version >= 0x0600) + return GENMASK(6, 0); +- else ++ else if (ctrl->nand_version >= 0x0303) + return GENMASK(5, 0); ++ else ++ return GENMASK(4, 0); + } + + #define NAND_ACC_CONTROL_ECC_SHIFT 16 +@@ -2158,9 +2212,11 @@ static int brcmnand_set_cfg(struct brcmn + + tmp = nand_readreg(ctrl, acc_control_offs); + tmp &= ~brcmnand_ecc_level_mask(ctrl); +- tmp |= cfg->ecc_level << NAND_ACC_CONTROL_ECC_SHIFT; + tmp &= ~brcmnand_spare_area_mask(ctrl); +- tmp |= cfg->spare_area_size; ++ if (ctrl->nand_version >= 0x0302) { ++ tmp |= cfg->ecc_level << NAND_ACC_CONTROL_ECC_SHIFT; ++ tmp |= cfg->spare_area_size; ++ } + nand_writereg(ctrl, acc_control_offs, tmp); + + brcmnand_set_sector_size_1k(host, cfg->sector_size_1k); +@@ -2524,6 +2580,8 @@ const struct dev_pm_ops brcmnand_pm_ops + EXPORT_SYMBOL_GPL(brcmnand_pm_ops); + + static const struct of_device_id brcmnand_of_match[] = { ++ { .compatible = "brcm,brcmnand-v2.1" }, ++ { .compatible = "brcm,brcmnand-v2.2" }, + { .compatible = "brcm,brcmnand-v4.0" }, + { .compatible = "brcm,brcmnand-v5.0" }, + { .compatible = "brcm,brcmnand-v6.0" }, diff --git a/target/linux/bcm63xx/patches-5.4/511-board_V2500V.patch b/target/linux/bcm63xx/patches-5.4/511-board_V2500V.patch index e2a10846e0..47590af6e3 100644 --- a/target/linux/bcm63xx/patches-5.4/511-board_V2500V.patch +++ b/target/linux/bcm63xx/patches-5.4/511-board_V2500V.patch @@ -76,7 +76,7 @@ #include #include #include -@@ -248,6 +249,13 @@ int __init bcm63xx_flash_register(void) +@@ -256,6 +257,13 @@ int __init bcm63xx_flash_register(void) val = bcm_mpi_readl(MPI_CSBASE_REG(0)); val &= MPI_CSBASE_BASE_MASK; diff --git a/target/linux/bcm63xx/patches-5.4/599-board-VR-3032u.patch b/target/linux/bcm63xx/patches-5.4/599-board-VR-3032u.patch new file mode 100644 index 0000000000..fa63150a1d --- /dev/null +++ b/target/linux/bcm63xx/patches-5.4/599-board-VR-3032u.patch @@ -0,0 +1,63 @@ +--- a/arch/mips/bcm63xx/boards/board_bcm963xx.c ++++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c +@@ -2610,6 +2610,44 @@ static struct board_info __initdata boar + }, + }; + ++static struct board_info __initdata board_VR3032u = { ++ .name = "963168M-1841N1", ++ .expected_cpu_id = 0x63268, ++ ++ .has_ehci0 = 1, ++ .has_ohci0 = 1, ++ .num_usbh_ports = 1, ++ ++ .has_enetsw = 1, ++ .enetsw = { ++ .used_ports = { ++ [0] = { ++ .used = 1, ++ .phy_id = 1, ++ .name = "LAN2", ++ }, ++ ++ [1] = { ++ .used = 1, ++ .phy_id = 2, ++ .name = "LAN3", ++ }, ++ ++ [2] = { ++ .used = 1, ++ .phy_id = 3, ++ .name = "LAN4", ++ }, ++ ++ [3] = { ++ .used = 1, ++ .phy_id = 4, ++ .name = "LAN1", ++ }, ++ }, ++ }, ++}; ++ + static struct board_info __initdata board_vw6339gu = { + .name = "VW6339GU", + .expected_cpu_id = 0x63268, +@@ -2804,6 +2842,7 @@ static const struct board_info __initcon + #ifdef CONFIG_BCM63XX_CPU_63268 + &board_963268bu_p300, + &board_963269bhr, ++ &board_VR3032u, + &board_vw6339gu, + &board_BSKYB_63168, + #endif +@@ -2917,6 +2956,7 @@ static struct of_device_id const bcm963x + #ifdef CONFIG_BCM63XX_CPU_63268 + { .compatible = "brcm,bcm963268bu-p300", .data = &board_963268bu_p300, }, + { .compatible = "brcm,bcm963269bhr", .data = &board_963269bhr, }, ++ { .compatible = "comtrend,vr-3032u", .data = &board_VR3032u, }, + { .compatible = "inteno,vg50", .data = &board_vw6339gu, }, + { .compatible = "sky,sr102", .data = &board_BSKYB_63168, }, + #endif diff --git a/target/linux/bcm63xx/smp/config-default b/target/linux/bcm63xx/smp/config-default index 935e97f91a..cc43bb2023 100644 --- a/target/linux/bcm63xx/smp/config-default +++ b/target/linux/bcm63xx/smp/config-default @@ -1,17 +1,48 @@ CONFIG_CPU_RMAP=y +CONFIG_CRC16=y +CONFIG_CRYPTO_ACOMP2=y CONFIG_CRYPTO_AEAD=y CONFIG_CRYPTO_AEAD2=y +CONFIG_CRYPTO_DEFLATE=y +CONFIG_CRYPTO_HASH_INFO=y CONFIG_CRYPTO_HASH2=y +CONFIG_CRYPTO_LZO=y CONFIG_CRYPTO_MANAGER=y CONFIG_CRYPTO_MANAGER2=y CONFIG_CRYPTO_NULL2=y +CONFIG_CRYPTO_ZSTD=y +CONFIG_JFFS2_FS_NAND=y +CONFIG_LZO_COMPRESS=y +CONFIG_LZO_DECOMPRESS=y +CONFIG_MTD_NAND_BRCMNAND=y +CONFIG_MTD_NAND_CORE=y +CONFIG_MTD_NAND_ECC_SW_HAMMING=y +CONFIG_MTD_RAW_NAND=y +CONFIG_MTD_SPLIT_BCM_WFI_FW=y +CONFIG_MTD_UBI=y +CONFIG_MTD_UBI_BEB_LIMIT=20 +CONFIG_MTD_UBI_BLOCK=y +# CONFIG_MTD_UBI_FASTMAP is not set +# CONFIG_MTD_UBI_GLUEBI is not set +CONFIG_MTD_UBI_WL_THRESHOLD=4096 CONFIG_NET_FLOW_LIMIT=y CONFIG_NR_CPUS=2 CONFIG_PADATA=y CONFIG_RCU_STALL_COMMON=y CONFIG_RFS_ACCEL=y CONFIG_RPS=y +CONFIG_SGL_ALLOC=y CONFIG_SMP=y CONFIG_SMP_UP=y CONFIG_TREE_RCU=y +CONFIG_UBIFS_FS=y +CONFIG_UBIFS_FS_ADVANCED_COMPR=y +CONFIG_UBIFS_FS_LZO=y +CONFIG_UBIFS_FS_ZLIB=y +CONFIG_UBIFS_FS_ZSTD=y CONFIG_XPS=y +CONFIG_XXHASH=y +CONFIG_ZLIB_DEFLATE=y +CONFIG_ZLIB_INFLATE=y +CONFIG_ZSTD_COMPRESS=y +CONFIG_ZSTD_DECOMPRESS=y diff --git a/target/linux/bcm63xx/smp/target.mk b/target/linux/bcm63xx/smp/target.mk index b0ccf97498..36bc2becdc 100644 --- a/target/linux/bcm63xx/smp/target.mk +++ b/target/linux/bcm63xx/smp/target.mk @@ -1,8 +1,17 @@ BOARDNAME:=smp +FEATURES+=nand define Target/Description - Build firmware images for BCM63XX boards with SMP support. - Currently only BCM6362 and BCM6368 supported. + Build firmware images for BCM63XX boards with SMP and NAND support. + SoCs with 2 cores: + - BCM6328 (some boards only have 1 core) + - BCM6358 (SMP unsupported due to shared TLB) + - BCM6362 + - BCM6368 + - BCM63268 + SoCs with NAND controller: + - BCM6328 (v2.2) + - BCM6362 (v2.2) + - BCM6368 (v2.1) + - BCM63268 (v4.0) endef - - diff --git a/target/linux/generic/config-4.14 b/target/linux/generic/config-4.14 index c1378b99cb..9cbe0bdb4d 100644 --- a/target/linux/generic/config-4.14 +++ b/target/linux/generic/config-4.14 @@ -2886,6 +2886,7 @@ CONFIG_MTD_ROOTFS_ROOT_DEV=y # CONFIG_MTD_SPI_NOR_USE_4K_SECTORS is not set CONFIG_MTD_SPI_NOR_USE_4K_SECTORS_LIMIT=4096 CONFIG_MTD_SPLIT=y +# CONFIG_MTD_SPLIT_BCM_WFI_FW is not set # CONFIG_MTD_SPLIT_BRNIMAGE_FW is not set # CONFIG_MTD_SPLIT_EVA_FW is not set # CONFIG_MTD_SPLIT_FIRMWARE is not set diff --git a/target/linux/generic/config-4.19 b/target/linux/generic/config-4.19 index 4d3184de23..860d440a72 100644 --- a/target/linux/generic/config-4.19 +++ b/target/linux/generic/config-4.19 @@ -3034,6 +3034,7 @@ CONFIG_MTD_ROOTFS_ROOT_DEV=y # CONFIG_MTD_SPI_NOR_USE_4K_SECTORS is not set CONFIG_MTD_SPI_NOR_USE_4K_SECTORS_LIMIT=4096 CONFIG_MTD_SPLIT=y +# CONFIG_MTD_SPLIT_BCM_WFI_FW is not set # CONFIG_MTD_SPLIT_BRNIMAGE_FW is not set # CONFIG_MTD_SPLIT_EVA_FW is not set # CONFIG_MTD_SPLIT_FIRMWARE is not set diff --git a/target/linux/generic/config-5.4 b/target/linux/generic/config-5.4 index 769fc958a6..73e082c7ba 100644 --- a/target/linux/generic/config-5.4 +++ b/target/linux/generic/config-5.4 @@ -3232,6 +3232,7 @@ CONFIG_MTD_ROOTFS_ROOT_DEV=y # CONFIG_MTD_SPI_NOR_USE_4K_SECTORS is not set CONFIG_MTD_SPI_NOR_USE_4K_SECTORS_LIMIT=4096 CONFIG_MTD_SPLIT=y +# CONFIG_MTD_SPLIT_BCM_WFI_FW is not set # CONFIG_MTD_SPLIT_BRNIMAGE_FW is not set # CONFIG_MTD_SPLIT_EVA_FW is not set # CONFIG_MTD_SPLIT_FIRMWARE is not set diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/Kconfig b/target/linux/generic/files/drivers/mtd/mtdsplit/Kconfig index 81ece43db8..0447df585c 100644 --- a/target/linux/generic/files/drivers/mtd/mtdsplit/Kconfig +++ b/target/linux/generic/files/drivers/mtd/mtdsplit/Kconfig @@ -20,6 +20,11 @@ config MTD_SPLIT_SQUASHFS_ROOT comment "Firmware partition parsers" +config MTD_SPLIT_BCM_WFI_FW + bool "Broadcom Whole Flash Image parser" + depends on MTD_SPLIT_SUPPORT + select MTD_SPLIT + config MTD_SPLIT_SEAMA_FW bool "Seama firmware parser" depends on MTD_SPLIT_SUPPORT diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/Makefile b/target/linux/generic/files/drivers/mtd/mtdsplit/Makefile index 206e754a18..d3634e78db 100644 --- a/target/linux/generic/files/drivers/mtd/mtdsplit/Makefile +++ b/target/linux/generic/files/drivers/mtd/mtdsplit/Makefile @@ -1,4 +1,5 @@ obj-$(CONFIG_MTD_SPLIT) += mtdsplit.o +obj-$(CONFIG_MTD_SPLIT_BCM_WFI_FW) += mtdsplit_bcm_wfi.o obj-$(CONFIG_MTD_SPLIT_SEAMA_FW) += mtdsplit_seama.o obj-$(CONFIG_MTD_SPLIT_SQUASHFS_ROOT) += mtdsplit_squashfs.o obj-$(CONFIG_MTD_SPLIT_UIMAGE_FW) += mtdsplit_uimage.o diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_bcm_wfi.c b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_bcm_wfi.c new file mode 100644 index 0000000000..9fc3c8ac50 --- /dev/null +++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_bcm_wfi.c @@ -0,0 +1,203 @@ +/* + * MTD split for Broadcom Whole Flash Image + * + * Copyright (C) 2020 Álvaro Fernández Rojas + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation. + * + */ + +#define je16_to_cpu(x) ((x).v16) +#define je32_to_cpu(x) ((x).v32) + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "mtdsplit.h" + +#define BCM_WFI_PARTS 4 + +#define CFERAM_NAME "cferam" +#define CFERAM_NAME_LEN (sizeof(CFERAM_NAME) - 1) +#define KERNEL_NAME "vmlinux.lz" +#define KERNEL_NAME_LEN (sizeof(KERNEL_NAME) - 1) +#define OPENWRT_NAME "1-openwrt" +#define OPENWRT_NAME_LEN (sizeof(OPENWRT_NAME) - 1) + +#define UBI_MAGIC 0x55424923 + +static u32 jffs2_dirent_crc(struct jffs2_raw_dirent *node) +{ + return crc32(0, node, sizeof(struct jffs2_raw_dirent) - 8); +} + +static bool jffs2_dirent_valid(struct jffs2_raw_dirent *node) +{ + return ((je16_to_cpu(node->magic) == JFFS2_MAGIC_BITMASK) && + (je16_to_cpu(node->nodetype) == JFFS2_NODETYPE_DIRENT) && + je32_to_cpu(node->ino) && + je32_to_cpu(node->node_crc) == jffs2_dirent_crc(node)); +} + +static int jffs2_find_file(struct mtd_info *master, uint8_t *buf, + const char *name, size_t name_len, + loff_t *offs) +{ + struct jffs2_raw_dirent *node; + bool valid = false; + size_t retlen; + uint16_t magic; + int rc; + + for (; *offs < master->size; *offs += master->erasesize) { + unsigned int block_offs = 0; + + /* Skip CFE erased blocks */ + rc = mtd_read(master, *offs, sizeof(magic), &retlen, + (void *) &magic); + if (rc || retlen != sizeof(magic)) { + continue; + } + + /* Skip blocks not starting with JFFS2 magic */ + if (magic != JFFS2_MAGIC_BITMASK) + continue; + + /* Read full block */ + rc = mtd_read(master, *offs, master->erasesize, &retlen, + (void *) buf); + if (rc) + return rc; + if (retlen != master->erasesize) + return -EINVAL; + + while (block_offs < master->erasesize) { + node = (struct jffs2_raw_dirent *) &buf[block_offs]; + + if (!jffs2_dirent_valid(node)) { + block_offs += 4; + continue; + } + + if (!memcmp(node->name, OPENWRT_NAME, + OPENWRT_NAME_LEN)) + valid = true; + else if (!memcmp(node->name, name, name_len)) + return valid ? 0 : -EINVAL; + + block_offs += je32_to_cpu(node->totlen); + block_offs = (block_offs + 0x3) & ~0x3; + } + } + + return -ENOENT; +} + +static int ubifs_find(struct mtd_info *master, loff_t *offs) +{ + uint32_t magic; + size_t retlen; + int rc; + + for (; *offs < master->size; *offs += master->erasesize) { + rc = mtd_read(master, *offs, sizeof(magic), &retlen, + (unsigned char *) &magic); + if (rc || retlen != sizeof(magic)) + continue; + + if (be32_to_cpu(magic) == UBI_MAGIC) + return 0; + } + + return -ENOENT; +} + +static int mtdsplit_parse_bcm_wfi(struct mtd_info *master, + const struct mtd_partition **pparts, + struct mtd_part_parser_data *data) +{ + struct mtd_partition *parts; + loff_t cfe_off, kernel_off, rootfs_off; + uint8_t *buf; + int ret; + + buf = kzalloc(master->erasesize, GFP_KERNEL); + if (!buf) + return -ENOMEM; + + cfe_off = 0; + ret = jffs2_find_file(master, buf, CFERAM_NAME, CFERAM_NAME_LEN, + &cfe_off); + if (ret) { + kfree(buf); + return ret; + } + + kernel_off = cfe_off + master->erasesize; + ret = jffs2_find_file(master, buf, KERNEL_NAME, KERNEL_NAME_LEN, + &kernel_off); + kfree(buf); + if (ret) + return ret; + + rootfs_off = kernel_off + master->erasesize; + ret = ubifs_find(master, &rootfs_off); + if (ret) + return ret; + + parts = kzalloc(BCM_WFI_PARTS * sizeof(*parts), GFP_KERNEL); + if (!parts) + return -ENOMEM; + + parts[0].name = "cferam"; + parts[0].mask_flags = MTD_WRITEABLE; + parts[0].offset = 0; + parts[0].size = kernel_off; + + parts[1].name = "firmware"; + parts[1].offset = kernel_off; + parts[1].size = master->size - kernel_off; + + parts[2].name = KERNEL_PART_NAME; + parts[2].offset = kernel_off; + parts[2].size = rootfs_off - kernel_off; + + parts[3].name = UBI_PART_NAME; + parts[3].offset = rootfs_off; + parts[3].size = master->size - rootfs_off; + + *pparts = parts; + + return BCM_WFI_PARTS; +} + +static const struct of_device_id mtdsplit_fit_of_match_table[] = { + { .compatible = "brcm,wfi" }, + { }, +}; + +static struct mtd_part_parser mtdsplit_bcm_wfi_parser = { + .owner = THIS_MODULE, + .name = "bcm-wfi-fw", + .of_match_table = mtdsplit_fit_of_match_table, + .parse_fn = mtdsplit_parse_bcm_wfi, + .type = MTD_PARSER_TYPE_FIRMWARE, +}; + +static int __init mtdsplit_bcm_wfi_init(void) +{ + register_mtd_parser(&mtdsplit_bcm_wfi_parser); + + return 0; +} + +module_init(mtdsplit_bcm_wfi_init); diff --git a/target/linux/lantiq/files-4.19/arch/mips/boot/dts/lantiq/vr9_avm_fritz7360v2.dts b/target/linux/lantiq/files-4.19/arch/mips/boot/dts/lantiq/vr9_avm_fritz7360-v2.dts similarity index 77% rename from target/linux/lantiq/files-4.19/arch/mips/boot/dts/lantiq/vr9_avm_fritz7360v2.dts rename to target/linux/lantiq/files-4.19/arch/mips/boot/dts/lantiq/vr9_avm_fritz7360-v2.dts index 215a07e597..9129ef1f70 100644 --- a/target/linux/lantiq/files-4.19/arch/mips/boot/dts/lantiq/vr9_avm_fritz7360v2.dts +++ b/target/linux/lantiq/files-4.19/arch/mips/boot/dts/lantiq/vr9_avm_fritz7360-v2.dts @@ -7,32 +7,32 @@ #include / { - compatible = "avm,fritz7360v2", "avm,fritz736x", "lantiq,xway", "lantiq,vr9"; + compatible = "avm,fritz7360-v2", "avm,fritz736x", "lantiq,xway", "lantiq,vr9"; model = "AVM FRITZ!Box 7360 V2"; }; &power_green { - label = "fritz7360v2:green:power"; + label = "fritz7360-v2:green:power"; }; &power_red { - label = "fritz7360v2:red:power"; + label = "fritz7360-v2:red:power"; }; &info_green { - label = "fritz7360v2:green:info"; + label = "fritz7360-v2:green:info"; }; &wifi { - label = "fritz7360v2:green:wlan"; + label = "fritz7360-v2:green:wlan"; }; &info_red { - label = "fritz7360v2:red:info"; + label = "fritz7360-v2:red:info"; }; &dect { - label = "fritz7360v2:green:dect"; + label = "fritz7360-v2:green:dect"; }; &state_default { diff --git a/target/linux/lantiq/files-5.4/arch/mips/boot/dts/lantiq/vr9_avm_fritz7360v2.dts b/target/linux/lantiq/files-5.4/arch/mips/boot/dts/lantiq/vr9_avm_fritz7360-v2.dts similarity index 77% rename from target/linux/lantiq/files-5.4/arch/mips/boot/dts/lantiq/vr9_avm_fritz7360v2.dts rename to target/linux/lantiq/files-5.4/arch/mips/boot/dts/lantiq/vr9_avm_fritz7360-v2.dts index 215a07e597..9129ef1f70 100644 --- a/target/linux/lantiq/files-5.4/arch/mips/boot/dts/lantiq/vr9_avm_fritz7360v2.dts +++ b/target/linux/lantiq/files-5.4/arch/mips/boot/dts/lantiq/vr9_avm_fritz7360-v2.dts @@ -7,32 +7,32 @@ #include / { - compatible = "avm,fritz7360v2", "avm,fritz736x", "lantiq,xway", "lantiq,vr9"; + compatible = "avm,fritz7360-v2", "avm,fritz736x", "lantiq,xway", "lantiq,vr9"; model = "AVM FRITZ!Box 7360 V2"; }; &power_green { - label = "fritz7360v2:green:power"; + label = "fritz7360-v2:green:power"; }; &power_red { - label = "fritz7360v2:red:power"; + label = "fritz7360-v2:red:power"; }; &info_green { - label = "fritz7360v2:green:info"; + label = "fritz7360-v2:green:info"; }; &wifi { - label = "fritz7360v2:green:wlan"; + label = "fritz7360-v2:green:wlan"; }; &info_red { - label = "fritz7360v2:red:info"; + label = "fritz7360-v2:red:info"; }; &dect { - label = "fritz7360v2:green:dect"; + label = "fritz7360-v2:green:dect"; }; &state_default { diff --git a/target/linux/lantiq/image/vr9.mk b/target/linux/lantiq/image/vr9.mk index d59605a158..4267101072 100644 --- a/target/linux/lantiq/image/vr9.mk +++ b/target/linux/lantiq/image/vr9.mk @@ -127,15 +127,14 @@ define Device/avm_fritz7360sl endef TARGET_DEVICES += avm_fritz7360sl -define Device/avm_fritz7360v2 +define Device/avm_fritz7360-v2 $(Device/AVM) DEVICE_MODEL := FRITZ!Box 7360 DEVICE_VARIANT := v2 IMAGE_SIZE := 32128k DEVICE_PACKAGES := kmod-ath9k kmod-owl-loader wpad-basic kmod-usb-dwc2 - SUPPORTED_DEVICES += FRITZ7360V2 endef -TARGET_DEVICES += avm_fritz7360v2 +TARGET_DEVICES += avm_fritz7360-v2 define Device/avm_fritz7362sl $(Device/AVM) diff --git a/target/linux/lantiq/xrx200/base-files/etc/board.d/02_network b/target/linux/lantiq/xrx200/base-files/etc/board.d/02_network index 790fae58c9..5331288253 100755 --- a/target/linux/lantiq/xrx200/base-files/etc/board.d/02_network +++ b/target/linux/lantiq/xrx200/base-files/etc/board.d/02_network @@ -39,7 +39,7 @@ lantiq_setup_interfaces() avm,fritz3370-rev2-hynix|\ avm,fritz3370-rev2-micron|\ avm,fritz7360sl|\ - avm,fritz7360v2|\ + avm,fritz7360-v2|\ avm,fritz7362sl) ucidef_add_switch "switch0" \ "0:lan:3" "1:lan:4" "2:lan:2" "4:lan:1" "6t@eth0" diff --git a/target/linux/lantiq/xrx200/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom b/target/linux/lantiq/xrx200/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom index 4b6d0bf13a..75cc50a207 100644 --- a/target/linux/lantiq/xrx200/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom +++ b/target/linux/lantiq/xrx200/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom @@ -17,7 +17,7 @@ case "$FIRMWARE" in caldata_extract_reverse "urlader" 0x1541 0x440 ;; avm,fritz7360sl|\ - avm,fritz7360v2) + avm,fritz7360-v2) caldata_extract "urlader" 0x985 0x1000 ;; avm,fritz7412) diff --git a/target/linux/mpc85xx/Makefile b/target/linux/mpc85xx/Makefile index 4bb4d8812d..2ffdfeddcd 100644 --- a/target/linux/mpc85xx/Makefile +++ b/target/linux/mpc85xx/Makefile @@ -11,7 +11,7 @@ BOARD:=mpc85xx BOARDNAME:=Freescale MPC85xx CPU_TYPE:=8540 FEATURES:=squashfs ramdisk -SUBTARGETS:=generic p1020 p2020 +SUBTARGETS:=p1010 p1020 p2020 KERNEL_PATCHVER:=5.4 diff --git a/target/linux/mpc85xx/image/Makefile b/target/linux/mpc85xx/image/Makefile index 40002c13c4..eb70db04db 100644 --- a/target/linux/mpc85xx/image/Makefile +++ b/target/linux/mpc85xx/image/Makefile @@ -5,8 +5,6 @@ include $(TOPDIR)/rules.mk include $(INCLUDE_DIR)/image.mk -DEVICE_VARS += TPLINK_HWID TPLINK_HWREV TPLINK_FLASHLAYOUT TPLINK_HEADER_VERSION - define Build/copy-file cat "$(1)" > "$@" endef @@ -21,108 +19,6 @@ define Device/Default SUPPORTED_DEVICES := $(subst _,$(comma),$(1)) endef -ifeq ($(SUBTARGET),generic) - -define Device/tplink_tl-wdr4900-v1 - DEVICE_VENDOR := TP-Link - DEVICE_MODEL := TL-WDR4900 - DEVICE_VARIANT := v1 - TPLINK_HEADER_VERSION := 1 - TPLINK_HWID := 0x49000001 - TPLINK_HWREV := 1 - TPLINK_FLASHLAYOUT := 16Mppc - KERNEL_SIZE := 2684k - KERNEL_NAME := simpleImage.tl-wdr4900-v1 - KERNEL_INITRAMFS := - KERNEL := kernel-bin | uImage none - KERNEL_ENTRY := 0x1000000 - KERNEL_LOADADDR := 0x1000000 - SUPPORTED_DEVICES += tl-wdr4900-v1 - ARTIFACTS := fdt.bin - ARTIFACT/fdt.bin := append-dtb - IMAGES := fdt.bin factory.bin sysupgrade.bin - IMAGE/sysupgrade.bin := tplink-v1-image sysupgrade | append-metadata - IMAGE/factory.bin := tplink-v1-image factory -endef -TARGET_DEVICES += tplink_tl-wdr4900-v1 - -define Device/sophos_red-15w-rev1 - DEVICE_VENDOR := Sophos - DEVICE_MODEL := RED 15w - DEVICE_VARIANT := Rev.1 - # Original firmware uses a dedicated DTB-partition. - # The bootloader however supports FIT-images. - KERNEL = kernel-bin | gzip | fit gzip $(KDIR)/image-$$(DEVICE_DTS).dtb - IMAGES := sysupgrade.bin - IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata -endef -TARGET_DEVICES += sophos_red-15w-rev1 - -endif - -ifeq ($(SUBTARGET),p1020) - -define Device/aerohive_hiveap-330 - DEVICE_VENDOR := Aerohive - DEVICE_MODEL := HiveAP-330 - DEVICE_PACKAGES := kmod-tpm-i2c-atmel - BLOCKSIZE := 128k - KERNEL := kernel-bin | gzip | uImage gzip - KERNEL_SIZE := 8m - KERNEL_INITRAMFS := copy-file $(KDIR)/vmlinux-initramfs | uImage none - IMAGES := fdt.bin sysupgrade.bin - IMAGE/fdt.bin := append-dtb - IMAGE/sysupgrade.bin := append-dtb | pad-to 256k | check-size 256k | \ - append-uImage-fakehdr ramdisk | pad-to 256k | check-size 512k | \ - append-rootfs | pad-rootfs $$(BLOCKSIZE) | pad-to 41216k | check-size 41216k | \ - append-kernel | append-metadata -endef -TARGET_DEVICES += aerohive_hiveap-330 - -define Device/enterasys_ws-ap3710i - DEVICE_VENDOR := Enterasys - DEVICE_MODEL := WS-AP3710i - BLOCKSIZE := 128k - KERNEL = kernel-bin | lzma | fit lzma $(KDIR)/image-$$(DEVICE_DTS).dtb - IMAGES := sysupgrade.bin - IMAGE/sysupgrade.bin := append-kernel | append-rootfs | pad-rootfs | append-metadata -endef -TARGET_DEVICES += enterasys_ws-ap3710i - -define Device/ocedo_panda - DEVICE_VENDOR := OCEDO - DEVICE_MODEL := Panda - DEVICE_PACKAGES := kmod-rtc-ds1307 uboot-envtools - KERNEL = kernel-bin | gzip | fit gzip $(KDIR)/image-$$(DEVICE_DTS).dtb - PAGESIZE := 2048 - SUBPAGESIZE := 512 - BLOCKSIZE := 128k - IMAGES := fdt.bin sysupgrade.bin - IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata - IMAGE/fdt.bin := append-dtb -endef -TARGET_DEVICES += ocedo_panda - -endif - -ifeq ($(SUBTARGET),p2020) - -define Device/freescale_p2020rdb - DEVICE_VENDOR := Freescale - DEVICE_MODEL := P2020RDB - DEVICE_DTS_DIR := $(DTS_DIR)/fsl - DEVICE_PACKAGES := kmod-hwmon-lm90 kmod-rtc-ds1307 \ - kmod-gpio-pca953x kmod-eeprom-at24 - BLOCKSIZE := 128k - KERNEL := kernel-bin | gzip | \ - fit gzip $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb - SUPPORTED_DEVICES := fsl,P2020RDB - IMAGES := sysupgrade.bin - IMAGE/sysupgrade.bin := append-kernel | append-rootfs | \ - pad-rootfs $$(BLOCKSIZE) | append-metadata -endef -TARGET_DEVICES += freescale_p2020rdb - -endif +include $(SUBTARGET).mk $(eval $(call BuildImage)) diff --git a/target/linux/mpc85xx/image/p1010.mk b/target/linux/mpc85xx/image/p1010.mk new file mode 100644 index 0000000000..e12621e82c --- /dev/null +++ b/target/linux/mpc85xx/image/p1010.mk @@ -0,0 +1,36 @@ +DEVICE_VARS += TPLINK_HWID TPLINK_HWREV TPLINK_FLASHLAYOUT TPLINK_HEADER_VERSION + +define Device/tplink_tl-wdr4900-v1 + DEVICE_VENDOR := TP-Link + DEVICE_MODEL := TL-WDR4900 + DEVICE_VARIANT := v1 + TPLINK_HEADER_VERSION := 1 + TPLINK_HWID := 0x49000001 + TPLINK_HWREV := 1 + TPLINK_FLASHLAYOUT := 16Mppc + KERNEL_SIZE := 2684k + KERNEL_NAME := simpleImage.tl-wdr4900-v1 + KERNEL_INITRAMFS := + KERNEL := kernel-bin | uImage none + KERNEL_ENTRY := 0x1000000 + KERNEL_LOADADDR := 0x1000000 + SUPPORTED_DEVICES += tl-wdr4900-v1 + ARTIFACTS := fdt.bin + ARTIFACT/fdt.bin := append-dtb + IMAGES := fdt.bin factory.bin sysupgrade.bin + IMAGE/sysupgrade.bin := tplink-v1-image sysupgrade | append-metadata + IMAGE/factory.bin := tplink-v1-image factory +endef +TARGET_DEVICES += tplink_tl-wdr4900-v1 + +define Device/sophos_red-15w-rev1 + DEVICE_VENDOR := Sophos + DEVICE_MODEL := RED 15w + DEVICE_VARIANT := Rev.1 + # Original firmware uses a dedicated DTB-partition. + # The bootloader however supports FIT-images. + KERNEL = kernel-bin | gzip | fit gzip $(KDIR)/image-$$(DEVICE_DTS).dtb + IMAGES := sysupgrade.bin + IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata +endef +TARGET_DEVICES += sophos_red-15w-rev1 diff --git a/target/linux/mpc85xx/image/p1020.mk b/target/linux/mpc85xx/image/p1020.mk new file mode 100644 index 0000000000..a127723e89 --- /dev/null +++ b/target/linux/mpc85xx/image/p1020.mk @@ -0,0 +1,41 @@ +define Device/aerohive_hiveap-330 + DEVICE_VENDOR := Aerohive + DEVICE_MODEL := HiveAP-330 + DEVICE_PACKAGES := kmod-tpm-i2c-atmel + BLOCKSIZE := 128k + KERNEL := kernel-bin | gzip | uImage gzip + KERNEL_SIZE := 8m + KERNEL_INITRAMFS := copy-file $(KDIR)/vmlinux-initramfs | uImage none + IMAGES := fdt.bin sysupgrade.bin + IMAGE/fdt.bin := append-dtb + IMAGE/sysupgrade.bin := append-dtb | pad-to 256k | check-size 256k | \ + append-uImage-fakehdr ramdisk | pad-to 256k | check-size 512k | \ + append-rootfs | pad-rootfs $$(BLOCKSIZE) | pad-to 41216k | check-size 41216k | \ + append-kernel | append-metadata +endef +TARGET_DEVICES += aerohive_hiveap-330 + +define Device/enterasys_ws-ap3710i + DEVICE_VENDOR := Enterasys + DEVICE_MODEL := WS-AP3710i + BLOCKSIZE := 128k + KERNEL = kernel-bin | lzma | fit lzma $(KDIR)/image-$$(DEVICE_DTS).dtb + IMAGES := sysupgrade.bin + IMAGE/sysupgrade.bin := append-kernel | append-rootfs | pad-rootfs | append-metadata +endef +TARGET_DEVICES += enterasys_ws-ap3710i + +define Device/ocedo_panda + DEVICE_VENDOR := OCEDO + DEVICE_MODEL := Panda + DEVICE_PACKAGES := kmod-rtc-ds1307 uboot-envtools + KERNEL = kernel-bin | gzip | fit gzip $(KDIR)/image-$$(DEVICE_DTS).dtb + PAGESIZE := 2048 + SUBPAGESIZE := 512 + BLOCKSIZE := 128k + IMAGES := fdt.bin sysupgrade.bin + IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata + IMAGE/fdt.bin := append-dtb +endef +TARGET_DEVICES += ocedo_panda + diff --git a/target/linux/mpc85xx/image/p2020.mk b/target/linux/mpc85xx/image/p2020.mk new file mode 100644 index 0000000000..79b5fa660c --- /dev/null +++ b/target/linux/mpc85xx/image/p2020.mk @@ -0,0 +1,15 @@ +define Device/freescale_p2020rdb + DEVICE_VENDOR := Freescale + DEVICE_MODEL := P2020RDB + DEVICE_DTS_DIR := $(DTS_DIR)/fsl + DEVICE_PACKAGES := kmod-hwmon-lm90 kmod-rtc-ds1307 \ + kmod-gpio-pca953x kmod-eeprom-at24 + BLOCKSIZE := 128k + KERNEL := kernel-bin | gzip | \ + fit gzip $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb + SUPPORTED_DEVICES := fsl,P2020RDB + IMAGES := sysupgrade.bin + IMAGE/sysupgrade.bin := append-kernel | append-rootfs | \ + pad-rootfs $$(BLOCKSIZE) | append-metadata +endef +TARGET_DEVICES += freescale_p2020rdb diff --git a/target/linux/mpc85xx/generic/config-default b/target/linux/mpc85xx/p1010/config-default similarity index 100% rename from target/linux/mpc85xx/generic/config-default rename to target/linux/mpc85xx/p1010/config-default diff --git a/target/linux/mpc85xx/generic/profiles/00-default.mk b/target/linux/mpc85xx/p1010/profiles/00-default.mk similarity index 81% rename from target/linux/mpc85xx/generic/profiles/00-default.mk rename to target/linux/mpc85xx/p1010/profiles/00-default.mk index 67507ace8a..5356aaa939 100644 --- a/target/linux/mpc85xx/generic/profiles/00-default.mk +++ b/target/linux/mpc85xx/p1010/profiles/00-default.mk @@ -9,7 +9,7 @@ define Profile/Default endef define Profile/Default/Description - Default package set compatible with most MPC85xx boards. + Default package set compatible with most P1010 boards. endef $(eval $(call Profile,Default)) diff --git a/target/linux/mpc85xx/generic/target.mk b/target/linux/mpc85xx/p1010/target.mk similarity index 53% rename from target/linux/mpc85xx/generic/target.mk rename to target/linux/mpc85xx/p1010/target.mk index f826fe4d15..12ed78ace1 100644 --- a/target/linux/mpc85xx/generic/target.mk +++ b/target/linux/mpc85xx/p1010/target.mk @@ -1,8 +1,8 @@ -BOARDNAME:=Generic +BOARDNAME:=P1010 FEATURES+=nand KERNELNAME:=simpleImage.tl-wdr4900-v1 define Target/Description - Build firmware images for generic MPC85xx based boards. + Build firmware images for P1010 based boards. endef diff --git a/target/linux/ramips/dts/mt7620a_asus_rt-ac51u.dts b/target/linux/ramips/dts/mt7620a_asus_rt-ac51u.dts index e3a76037d4..eccbdee717 100644 --- a/target/linux/ramips/dts/mt7620a_asus_rt-ac51u.dts +++ b/target/linux/ramips/dts/mt7620a_asus_rt-ac51u.dts @@ -7,6 +7,7 @@ model = "Asus RT-AC51U"; aliases { + label-mac-device = ðernet; led-boot = &led_power; led-failsafe = &led_power; led-running = &led_power; @@ -28,15 +29,16 @@ linux,default-trigger = "usbport"; }; - wifi { - label = "rt-ac51u:blue:wifi"; + wifi2g { + label = "rt-ac51u:blue:wifi2g"; gpios = <&gpio3 0 GPIO_ACTIVE_LOW>; + linux,default-trigger = "phy1tpt"; }; }; }; ðernet { - mtd-mac-address = <&factory 0x4>; + mtd-mac-address = <&factory 0x28>; }; &state_default { diff --git a/target/linux/ramips/dts/mt7620a_asus_rt-ac54u.dts b/target/linux/ramips/dts/mt7620a_asus_rt-ac54u.dts index 09e9b780de..f7e64994d8 100644 --- a/target/linux/ramips/dts/mt7620a_asus_rt-ac54u.dts +++ b/target/linux/ramips/dts/mt7620a_asus_rt-ac54u.dts @@ -8,6 +8,7 @@ model = "Asus RT-AC54U"; aliases { + label-mac-device = ðernet; led-boot = &led_power; led-failsafe = &led_power; led-running = &led_power; @@ -38,7 +39,7 @@ }; ðernet { - mtd-mac-address = <&factory 0x22>; + mtd-mac-address = <&factory 0x28>; }; &state_default { diff --git a/target/linux/ramips/dts/mt7620a_asus_rt-ac5x.dtsi b/target/linux/ramips/dts/mt7620a_asus_rt-ac5x.dtsi index 83a789f287..3813efaa53 100644 --- a/target/linux/ramips/dts/mt7620a_asus_rt-ac5x.dtsi +++ b/target/linux/ramips/dts/mt7620a_asus_rt-ac5x.dtsi @@ -27,7 +27,9 @@ flash@0 { compatible = "jedec,spi-nor"; reg = <0>; - spi-max-frequency = <10000000>; + + spi-max-frequency = <50000000>; + m25p,fast-read; partitions { compatible = "fixed-partitions"; diff --git a/target/linux/ramips/dts/mt7620a_zyxel_keenetic-viva.dts b/target/linux/ramips/dts/mt7620a_zyxel_keenetic-viva.dts index c41d0a1c1d..4d4e5878eb 100644 --- a/target/linux/ramips/dts/mt7620a_zyxel_keenetic-viva.dts +++ b/target/linux/ramips/dts/mt7620a_zyxel_keenetic-viva.dts @@ -139,7 +139,7 @@ pinctrl-names = "default"; pinctrl-0 = <&rgmii2_pins &mdio_pins>; - mtd-mac-address = <&factory 0x00004>; + mtd-mac-address = <&factory 0x4>; port@4 { status = "okay"; diff --git a/target/linux/ramips/dts/rt3662_edimax_br-6475nd.dts b/target/linux/ramips/dts/rt3662_edimax_br-6475nd.dts index f189c31c60..86f724e871 100644 --- a/target/linux/ramips/dts/rt3662_edimax_br-6475nd.dts +++ b/target/linux/ramips/dts/rt3662_edimax_br-6475nd.dts @@ -142,7 +142,7 @@ ðernet { status = "okay"; - mtd-mac-address = <&devdata 0x0d>; + mtd-mac-address = <&devdata 0xd>; port@0 { mediatek,fixed-link = <1000 1 1 1>; diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk index 51d43e5bc4..7dbc69167c 100644 --- a/target/linux/ramips/image/mt7621.mk +++ b/target/linux/ramips/image/mt7621.mk @@ -83,7 +83,7 @@ endef define Build/ubnt-erx-factory-image if [ -e $(KDIR)/tmp/$(KERNEL_INITRAMFS_IMAGE) -a "$$(stat -c%s $@)" -lt "$(KERNEL_SIZE)" ]; then \ - echo '21001:6' > $(1).compat; \ + echo '21001:7' > $(1).compat; \ $(TAR) -cf $(1) --transform='s/^.*/compat/' $(1).compat; \ \ $(TAR) -rf $(1) --transform='s/^.*/vmlinux.tmp/' $(KDIR)/tmp/$(KERNEL_INITRAMFS_IMAGE); \ 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 d332e02bbd..c1deae59e3 100755 --- a/target/linux/ramips/mt7620/base-files/etc/board.d/01_leds +++ b/target/linux/ramips/mt7620/base-files/etc/board.d/01_leds @@ -47,12 +47,6 @@ asus,rt-n14u) ucidef_set_led_netdev "wan" "wan" "$boardname:blue:wan" eth0.2 set_wifi_led "$boardname:blue:air" ;; -asus,rt-ac51u|\ -kingston,mlw221|\ -kingston,mlwg2|\ -sanlinking,d240) - set_wifi_led "$boardname:blue:wifi" - ;; bdcom,wap2100-sk) set_wifi_led "$boardname:green:wlan2g" ;; @@ -139,6 +133,11 @@ kimax,u35wf) set_wifi_led "$boardname:blue:wifi" ucidef_set_led_netdev "eth" "ETH" "$boardname:green:eth" "eth0" ;; +kingston,mlw221|\ +kingston,mlwg2|\ +sanlinking,d240) + set_wifi_led "$boardname:blue:wifi" + ;; lava,lr-25g001) ucidef_set_led_netdev "wlan2g" "WiFi 2.4GHz" "$boardname:green:wlan2g" "wlan1" ucidef_set_led_netdev "wlan5g" "WiFi 5GHz" "$boardname:green:wlan5g" "wlan0" 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 c1dbf8d71d..b780d48179 100755 --- a/target/linux/ramips/mt7620/base-files/etc/board.d/02_network +++ b/target/linux/ramips/mt7620/base-files/etc/board.d/02_network @@ -236,7 +236,6 @@ ramips_setup_macs() case $board in aigale,ai-br100|\ - asus,rt-ac51u|\ asus,rt-n12p|\ asus,rt-n14u|\ bdcom,wap2100-sk|\ @@ -272,9 +271,9 @@ ramips_setup_macs() wan_mac=$(mtd_get_mac_binary factory 0x2e) label_mac=$(mtd_get_mac_binary factory 0x4) ;; + asus,rt-ac51u|\ asus,rt-ac54u) - wan_mac=$(mtd_get_mac_binary factory 0x28) - label_mac=$wan_mac + lan_mac=$(mtd_get_mac_binary factory 0x22) ;; dlink,dch-m225) lan_mac=$(mtd_get_mac_ascii factory lanmac)