Merge Official Source

Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
This commit is contained in:
Tianling Shen 2023-06-20 13:29:06 +08:00
commit d415f95aff
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
15 changed files with 683 additions and 14 deletions

View File

@ -39,6 +39,7 @@ ampedwireless,ally-r1900k)
;;
beeline,smartbox-giga|\
beeline,smartbox-turbo|\
beeline,smartbox-turbo-plus|\
etisalat,s3|\
rostelecom,rt-sf-1)
ubootenv_add_uci_config "/dev/mtd0" "0x80000" "0x1000" "0x20000"

View File

@ -48,12 +48,12 @@ def get_kernel_header(args):
struct.pack_into('<L', header, 0x2c, rootfs_size)
struct.pack_into('<L', header, 0x30, crc)
rootfs_end_offset = args.rootfs_offset + rootfs_size
struct.pack_into('<L', header, 0x4, rootfs_end_offset)
kernel_size = os.path.getsize(args.kernel_file)
struct.pack_into('<L', header, 0x14, kernel_size)
kernel_end_offset = args.kernel_offset + kernel_size
struct.pack_into('<L', header, 0x4, kernel_end_offset)
buf = open(args.kernel_file,'rb').read()
crc = binascii.crc32(buf) & 0xffffffff
struct.pack_into('<L', header, 0x18, crc)

View File

@ -6,6 +6,7 @@
board_config_update
case "$(board_name)" in
nucom,r5010unv2 |\
sercomm,ad1018)
ucidef_set_led_usbport "usb" "USB" "green:usb" "usb1-port1" "usb2-port1"
;;

View File

@ -6,7 +6,8 @@ board_config_update
case "$(board_name)" in
comtrend,ar-5381u |\
comtrend,ar-5387un)
comtrend,ar-5387un |\
nucom,r5010unv2)
ucidef_set_bridge_device switch
ucidef_set_interface_lan "lan1 lan2 lan3 lan4"
;;

View File

@ -4,7 +4,8 @@
case "$(board_name)" in
comtrend,ar-5381u |\
comtrend,ar-5387un)
comtrend,ar-5387un |\
nucom,r5010unv2)
mtd fixtrx firmware
;;
esac

View File

@ -0,0 +1,216 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#include "bcm6328.dtsi"
/ {
model = "NuCom R5010UNv2";
compatible = "nucom,r5010unv2", "brcm,bcm6328";
aliases {
led-boot = &led_power_green;
led-failsafe = &led_power_red;
led-running = &led_power_green;
led-upgrade = &led_power_green;
};
keys {
compatible = "gpio-keys-polled";
poll-interval = <100>;
reset {
label = "reset";
gpios = <&gpio 23 GPIO_ACTIVE_LOW>;
linux,code = <KEY_RESTART>;
debounce-interval = <60>;
};
wps {
label = "wps";
gpios = <&gpio 24 GPIO_ACTIVE_LOW>;
linux,code = <KEY_WPS_BUTTON>;
debounce-interval = <60>;
};
};
bcm43217-sprom {
compatible = "brcm,bcma-sprom";
pci-bus = <1>;
pci-dev = <0>;
nvmem-cells = <&macaddr_cfe_6a0>;
nvmem-cell-names = "mac-address";
mac-address-increment = <1>;
brcm,sprom = "brcm/bcm43217-sprom.bin";
};
};
&ehci {
status = "okay";
};
&ethernet {
status = "okay";
nvmem-cells = <&macaddr_cfe_6a0>;
nvmem-cell-names = "mac-address";
};
&hsspi {
status = "okay";
flash@0 {
compatible = "jedec,spi-nor";
spi-max-frequency = <16666667>;
spi-tx-bus-width = <2>;
spi-rx-bus-width = <2>;
reg = <0>;
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
cfe: partition@0 {
label = "cfe";
reg = <0x000000 0x010000>;
read-only;
};
partition@10000 {
compatible = "brcm,bcm963xx-imagetag";
label = "firmware";
reg = <0x010000 0xfe0000>;
};
partition@ff0000 {
label = "nvram";
reg = <0xff0000 0x010000>;
};
};
};
};
&leds {
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_ephy0_act_led &pinctrl_ephy1_act_led
&pinctrl_ephy2_act_led &pinctrl_ephy3_act_led
&pinctrl_leds>;
led@1 {
reg = <1>;
active-low;
label = "green:internet";
};
led@2 {
reg = <2>;
active-low;
label = "red:internet";
};
led@3 {
reg = <3>;
active-low;
label = "green:dsl";
};
led_power_green: led@4 {
reg = <4>;
active-low;
label = "green:power";
};
led_power_red: led@5 {
reg = <5>;
active-low;
label = "red:power";
panic-indicator;
};
led@10 {
reg = <10>;
active-low;
label = "green:wps";
};
led@11 {
reg = <11>;
active-low;
label = "green:usb";
};
};
&ohci {
status = "okay";
};
&pcie {
status = "okay";
};
&pinctrl {
pinctrl_leds: leds {
function = "led";
pins = "gpio1", "gpio2", "gpio3",
"gpio4", "gpio5", "gpio10",
"gpio11";
};
};
&switch0 {
ports {
port@0 {
reg = <0>;
label = "lan1";
phy-handle = <&phy1>;
phy-mode = "mii";
};
port@1 {
reg = <1>;
label = "lan2";
phy-handle = <&phy2>;
phy-mode = "mii";
};
port@2 {
reg = <2>;
label = "lan3";
phy-handle = <&phy3>;
phy-mode = "mii";
};
port@3 {
reg = <3>;
label = "lan4";
phy-handle = <&phy4>;
phy-mode = "mii";
};
};
};
&uart0 {
status = "okay";
};
&usbh {
status = "okay";
};
&cfe {
compatible = "nvmem-cells";
#address-cells = <1>;
#size-cells = <1>;
macaddr_cfe_6a0: macaddr@6a0 {
reg = <0x6a0 0x6>;
};
};

View File

@ -26,6 +26,19 @@ define Device/comtrend_ar-5387un
endef
TARGET_DEVICES += comtrend_ar-5387un
define Device/nucom_r5010unv2
$(Device/bcm63xx-cfe)
DEVICE_VENDOR := NuCom
DEVICE_MODEL := R5010UNv2
CHIP_ID := 6328
CFE_BOARD_ID := 96328ang
FLASH_MB := 16
DEVICE_PACKAGES += $(USB2_PACKAGES) \
$(B43_PACKAGES) broadcom-43217-sprom \
kmod-leds-bcm6328
endef
TARGET_DEVICES += nucom_r5010unv2
define Device/sercomm_ad1018
$(Device/sercomm-nand)
DEVICE_VENDOR := Sercomm

View File

@ -0,0 +1,84 @@
From 3e4c3863e0cfb8c2abdff6bb494ca69d3d2aed9c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= <noltari@gmail.com>
Date: Sat, 10 Jun 2023 17:01:40 +0200
Subject: [PATCH] mips: bmips: dma: fix CBR address
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Some BCM63xx SoCs may return CBR address as 0.
Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
---
arch/mips/bmips/dma.c | 12 ++++--------
arch/mips/bmips/setup.c | 11 ++++-------
2 files changed, 8 insertions(+), 15 deletions(-)
--- a/arch/mips/bmips/dma.c
+++ b/arch/mips/bmips/dma.c
@@ -64,11 +64,10 @@ phys_addr_t dma_to_phys(struct device *d
return dma_addr;
}
-bool bmips_rac_flush_disable;
+void __iomem *bmips_cbr_addr;
void arch_sync_dma_for_cpu_all(void)
{
- void __iomem *cbr = BMIPS_GET_CBR();
u32 cfg;
if (boot_cpu_type() != CPU_BMIPS3300 &&
@@ -76,13 +75,10 @@ void arch_sync_dma_for_cpu_all(void)
boot_cpu_type() != CPU_BMIPS4380)
return;
- if (unlikely(bmips_rac_flush_disable))
- return;
-
/* Flush stale data out of the readahead cache */
- cfg = __raw_readl(cbr + BMIPS_RAC_CONFIG);
- __raw_writel(cfg | 0x100, cbr + BMIPS_RAC_CONFIG);
- __raw_readl(cbr + BMIPS_RAC_CONFIG);
+ cfg = __raw_readl(bmips_cbr_addr + BMIPS_RAC_CONFIG);
+ __raw_writel(cfg | 0x100, bmips_cbr_addr + BMIPS_RAC_CONFIG);
+ __raw_readl(bmips_cbr_addr + BMIPS_RAC_CONFIG);
}
static int __init bmips_init_dma_ranges(void)
--- a/arch/mips/bmips/setup.c
+++ b/arch/mips/bmips/setup.c
@@ -89,7 +89,7 @@
#define DDR_CSEND_REG 0x8
-extern bool bmips_rac_flush_disable;
+extern void __iomem *bmips_cbr_addr;
static const unsigned long kbase = VMLINUX_LOAD_ADDRESS & 0xfff00000;
@@ -170,12 +170,6 @@ static void bcm6358_quirks(void)
* disable SMP for now
*/
bmips_smp_enabled = 0;
-
- /*
- * RAC flush causes kernel panics on BCM6358 when booting from TP1
- * because the bootloader is not initializing it properly.
- */
- bmips_rac_flush_disable = !!(read_c0_brcm_cmt_local() & (1 << 31));
}
static void bcm6368_quirks(void)
@@ -198,6 +192,11 @@ static const struct bmips_quirk bmips_qu
void __init prom_init(void)
{
+ if (!(read_c0_brcm_cbr() >> 18))
+ bmips_cbr_addr = (void __iomem *)0xff400000;
+ else
+ bmips_cbr_addr = BMIPS_GET_CBR();
+
bmips_cpu_setup();
register_bmips_smp_ops();
}

View File

@ -0,0 +1,42 @@
From 7f862eaedac56b67972393f0a9affcd2fe53479b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Gonz=C3=A1lez=20Cabanelas?= <dgcbueu@gmail.com>
Date: Sun, 18 Jun 2023 19:59:25 +0200
Subject: [PATCH] mips: bmips: enable RAC on BMIPS4350
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The data RAC is left disabled by the bootloader in some SoCs, at least in
the core it boots from.
Enabling this feature increases the performance up to +30% depending on the
task.
Signed-off-by: Daniel González Cabanelas <dgcbueu@gmail.com>
Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
---
arch/mips/kernel/smp-bmips.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
--- a/arch/mips/kernel/smp-bmips.c
+++ b/arch/mips/kernel/smp-bmips.c
@@ -614,6 +614,20 @@ void bmips_cpu_setup(void)
__raw_readl(cbr + BMIPS_RAC_ADDRESS_RANGE);
break;
+ case CPU_BMIPS4350:
+ /* Enable data RAC */
+ if (!(read_c0_brcm_cmt_local() & (1 << 31))) {
+ cfg = __raw_readl(cbr + BMIPS_RAC_CONFIG);
+ __raw_writel(cfg | 0xa, cbr + BMIPS_RAC_CONFIG);
+ __raw_readl(cbr + BMIPS_RAC_CONFIG);
+ } else {
+ cbr = (void __iomem *)0xff400000;
+ cfg = __raw_readl(cbr + BMIPS_RAC_CONFIG_1);
+ __raw_writel(cfg | 0xa, cbr + BMIPS_RAC_CONFIG_1);
+ __raw_readl(cbr + BMIPS_RAC_CONFIG_1);
+ }
+ break;
+
case CPU_BMIPS4380:
/* CBG workaround for early BMIPS4380 CPUs */
switch (read_c0_prid()) {

View File

@ -0,0 +1,248 @@
// 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>
/ {
compatible = "beeline,smartbox-turbo-plus", "mediatek,mt7621-soc";
model = "Beeline SmartBox TURBO+";
aliases {
label-mac-device = &gmac0;
led-boot = &led_status_green;
led-failsafe = &led_status_red;
led-running = &led_status_green;
led-upgrade = &led_status_red;
};
leds {
compatible = "gpio-leds";
led-0 {
label = "blue:wan";
color = <LED_COLOR_ID_BLUE>;
function = LED_FUNCTION_WAN;
gpios = <&gpio 13 GPIO_ACTIVE_HIGH>;
};
led_status_green: led-1 {
label = "green:status";
color = <LED_COLOR_ID_GREEN>;
function = LED_FUNCTION_STATUS;
gpios = <&gpio 15 GPIO_ACTIVE_HIGH>;
};
led_status_red: led-2 {
label = "red:status";
color = <LED_COLOR_ID_RED>;
function = LED_FUNCTION_STATUS;
gpios = <&gpio 16 GPIO_ACTIVE_HIGH>;
};
};
keys {
compatible = "gpio-keys";
wps {
label = "wps";
gpios = <&gpio 11 GPIO_ACTIVE_HIGH>;
linux,code = <KEY_WPS_BUTTON>;
};
reset {
label = "reset";
gpios = <&gpio 14 GPIO_ACTIVE_LOW>;
linux,code = <KEY_RESTART>;
};
};
ubi-concat {
compatible = "mtd-concat";
devices = <&ubiconcat0 &ubiconcat1 &ubiconcat2>;
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
partition@0 {
label = "ubi";
reg = <0x0 0x4f80000>;
};
};
};
};
&nand {
status = "okay";
partitions {
compatible = "sercomm,sc-partitions", "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
partition@0 {
label = "u-boot";
reg = <0x0 0x100000>;
sercomm,scpart-id = <0>;
read-only;
};
partition@100000 {
label = "dynamic partition map";
reg = <0x100000 0x100000>;
sercomm,scpart-id = <1>;
read-only;
};
factory: partition@200000 {
label = "Factory";
reg = <0x200000 0x100000>;
sercomm,scpart-id = <2>;
read-only;
compatible = "nvmem-cells";
#address-cells = <1>;
#size-cells = <1>;
macaddr_factory_21000: macaddr@21000 {
reg = <0x21000 0x6>;
};
};
partition@300000 {
label = "Boot Flag";
reg = <0x300000 0x100000>;
sercomm,scpart-id = <3>;
};
partition@400000 {
label = "kernel";
reg = <0x400000 0x600000>;
sercomm,scpart-id = <4>;
};
partition@a00000 {
label = "Kernel 2";
reg = <0xa00000 0x600000>;
sercomm,scpart-id = <5>;
read-only;
};
ubiconcat0: partition@1000000 {
label = "File System 1";
reg = <0x1000000 0x2000000>;
sercomm,scpart-id = <6>;
};
partition@3000000 {
label = "File System 2";
reg = <0x3000000 0x2000000>;
sercomm,scpart-id = <7>;
read-only;
};
ubiconcat1: partition@5000000 {
label = "Configuration/log";
reg = <0x5000000 0x1400000>;
sercomm,scpart-id = <8>;
};
ubiconcat2: partition@6400000 {
label = "application tmp buffer (Ftool)";
reg = <0x6400000 0x1b80000>;
sercomm,scpart-id = <9>;
};
};
};
&pcie {
status = "okay";
};
&pcie0 {
wifi@0,0 {
compatible = "mediatek,mt76";
reg = <0x0000 0 0 0 0>;
mediatek,mtd-eeprom = <&factory 0x8000>;
ieee80211-freq-limit = <5000000 6000000>;
nvmem-cells = <&macaddr_factory_21000>;
nvmem-cell-names = "mac-address";
mac-address-increment = <(5)>;
};
};
&pcie1 {
wifi@0,0 {
compatible = "mediatek,mt76";
reg = <0x0000 0 0 0 0>;
mediatek,mtd-eeprom = <&factory 0x0>;
ieee80211-freq-limit = <2400000 2500000>;
nvmem-cells = <&macaddr_factory_21000>;
nvmem-cell-names = "mac-address";
mac-address-increment = <(4)>;
};
};
&gmac0 {
nvmem-cells = <&macaddr_factory_21000>;
nvmem-cell-names = "mac-address";
};
&gmac1 {
status = "okay";
label = "wan";
phy-handle = <&ethphy0>;
nvmem-cells = <&macaddr_factory_21000>;
nvmem-cell-names = "mac-address";
mac-address-increment = <(1)>;
};
&mdio {
ethphy0: ethernet-phy@0 {
reg = <0>;
};
};
&switch0 {
ports {
port@1 {
status = "okay";
label = "lan1";
};
port@2 {
status = "okay";
label = "lan2";
};
port@3 {
status = "okay";
label = "lan3";
};
port@4 {
status = "okay";
label = "lan4";
};
};
};
&uartlite3 {
status = "okay";
current-speed = <57600>;
};
&state_default {
gpio {
groups = "i2c", "jtag";
function = "gpio";
};
};

View File

@ -1,4 +1,5 @@
DEVICE_VARS += SERCOMM_KERNEL_OFFSET SERCOMM_ROOTFS_OFFSET
DEVICE_VARS += SERCOMM_KERNEL2_OFFSET SERCOMM_ROOTFS2_OFFSET
define Build/sercomm-crypto
$(TOPDIR)/scripts/sercomm-crypto.py \
@ -16,6 +17,23 @@ define Build/sercomm-crypto
rm -f $@.enc $@.key
endef
define Build/sercomm-factory-cqr
$(TOPDIR)/scripts/sercomm-pid.py \
--hw-version $(SERCOMM_HWVER) \
--hw-id $(SERCOMM_HWID) \
--sw-version $(SERCOMM_SWVER) \
--pid-file $@.fhdr
printf $$(stat -c%s $(IMAGE_KERNEL)) | \
dd seek=$$((0x70)) of=$@.fhdr bs=1 conv=notrunc 2>/dev/null
printf $$(($$(stat -c%s $@)-$$(stat -c%s $(IMAGE_KERNEL))-$$((0x200)))) | \
dd seek=$$((0x80)) of=$@.fhdr bs=1 conv=notrunc 2>/dev/null
dd bs=$$((0x200)) skip=1 if=$@ conv=notrunc 2>/dev/null | \
$(MKHASH) md5 | awk '{print $$1}' | tr -d '\n' | \
dd seek=$$((0x1e0)) of=$@.fhdr bs=1 conv=notrunc 2>/dev/null
dd if=$@ >> $@.fhdr 2>/dev/null
mv $@.fhdr $@
endef
define Build/sercomm-kernel
$(TOPDIR)/scripts/sercomm-kernel-header.py \
--kernel-image $@ \
@ -26,6 +44,22 @@ define Build/sercomm-kernel
mv $@.hdr $@
endef
define Build/sercomm-kernel-factory
$(TOPDIR)/scripts/sercomm-kernel-header.py \
--kernel-image $@ \
--kernel-offset $(SERCOMM_KERNEL_OFFSET) \
--rootfs-offset $(SERCOMM_ROOTFS_OFFSET) \
--output-header $@.khdr1
$(TOPDIR)/scripts/sercomm-kernel-header.py \
--kernel-image $@ \
--kernel-offset $(SERCOMM_KERNEL2_OFFSET) \
--rootfs-offset $(SERCOMM_ROOTFS2_OFFSET) \
--output-header $@.khdr2
cat $@.khdr1 $@.khdr2 > $@.khdr
dd if=$@ >> $@.khdr 2>/dev/null
mv $@.khdr $@
endef
define Build/sercomm-part-tag
$(call Build/sercomm-part-tag-common,$(word 1,$(1)) $@)
endef
@ -64,24 +98,37 @@ define Build/sercomm-prepend-tagged-kernel
mv $(IMAGE_KERNEL).tagged $@
endef
define Device/sercomm_dxx
$(Device/dsa-migration)
BLOCKSIZE := 128k
PAGESIZE := 2048
KERNEL_SIZE := 6144k
UBINIZE_OPTS := -E 5
define Device/sercomm
$(Device/nand)
LOADER_TYPE := bin
KERNEL_SIZE := 6144k
KERNEL_LOADADDR := 0x81001000
LZMA_TEXT_START := 0x82800000
SERCOMM_KERNEL_OFFSET := 0x400100
SERCOMM_ROOTFS_OFFSET := 0x1000000
IMAGES += factory.img
endef
define Device/sercomm_cxx
$(Device/sercomm)
SERCOMM_KERNEL2_OFFSET := 0xa00100
SERCOMM_ROOTFS2_OFFSET := 0x3000000
KERNEL := kernel-bin | append-dtb | lzma | loader-kernel | lzma -a0 | \
uImage lzma
IMAGE/sysupgrade.bin := append-kernel | sercomm-kernel | \
sysupgrade-tar kernel=$$$$@ | append-metadata
IMAGE/factory.img := append-kernel | sercomm-kernel-factory | \
append-ubi | sercomm-factory-cqr
endef
define Device/sercomm_dxx
$(Device/sercomm)
KERNEL := kernel-bin | append-dtb | lzma | loader-kernel | lzma -a0 | \
uImage lzma | sercomm-kernel
KERNEL_INITRAMFS := kernel-bin | append-dtb | lzma | loader-kernel | \
lzma -a0 | uImage lzma
IMAGES += factory.img
IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
IMAGE/factory.img := append-ubi | check-size | \
sercomm-part-tag rootfs | sercomm-prepend-tagged-kernel kernel | \
gzip | sercomm-payload | sercomm-crypto
SERCOMM_KERNEL_OFFSET := 0x400100
SERCOMM_ROOTFS_OFFSET := 0x1000000
endef

View File

@ -410,6 +410,18 @@ define Device/beeline_smartbox-turbo
endef
TARGET_DEVICES += beeline_smartbox-turbo
define Device/beeline_smartbox-turbo-plus
$(Device/sercomm_cxx)
IMAGE_SIZE := 32768k
SERCOMM_HWID := CQR
SERCOMM_HWVER := 10000
SERCOMM_SWVER := 2010
DEVICE_VENDOR := Beeline
DEVICE_MODEL := SmartBox TURBO+
DEVICE_PACKAGES := kmod-mt7603 kmod-mt7615-firmware kmod-usb3
endef
TARGET_DEVICES += beeline_smartbox-turbo-plus
define Device/belkin_rt1800
$(Device/nand)
IMAGE_SIZE := 49152k

View File

@ -35,6 +35,7 @@ asus,rt-n56u-b1)
beeline,smartbox-flash|\
beeline,smartbox-giga|\
beeline,smartbox-turbo|\
beeline,smartbox-turbo-plus|\
etisalat,s3|\
rostelecom,rt-sf-1)
ucidef_set_led_netdev "wan" "wan" "blue:wan" "wan"

View File

@ -9,6 +9,7 @@ boot() {
echo -e "bootcount\nbootchanged\n" | /usr/sbin/fw_setenv -s -
;;
beeline,smartbox-turbo|\
beeline,smartbox-turbo-plus|\
rostelecom,rt-sf-1)
[[ $(hexdump -n 1 -e '/1 "%1d"' -s $((0x20001)) /dev/mtd3) == \
$((0xff)) ]] || printf '\xff' | dd of=/dev/mtdblock3 \

View File

@ -60,6 +60,7 @@ platform_do_upgrade() {
beeline,smartbox-flash|\
beeline,smartbox-giga|\
beeline,smartbox-turbo|\
beeline,smartbox-turbo-plus|\
belkin,rt1800|\
dlink,dap-x1860-a1|\
dlink,dir-1960-a1|\