Merge Mainline

Signed-off-by: ZiMing Mo <msylgj@immortalwrt.org>
This commit is contained in:
ZiMing Mo
2022-08-22 16:23:11 +08:00
184 changed files with 2928 additions and 957 deletions

View File

@@ -150,11 +150,7 @@ menu "Global build settings"
Adds -g3 to the CFLAGS.
config IPV6
bool
prompt "Enable IPv6 support in packages"
default y
help
Enables IPv6 support in kernel (builtin) and packages.
def_bool y
comment "Stripping options"

View File

@@ -79,6 +79,37 @@ mtd_get_mac_ascii() {
[ -n "$mac_dirty" ] && macaddr_canonicalize "$mac_dirty"
}
mtd_get_mac_encrypted_arcadyan() {
local iv="00000000000000000000000000000000"
local key="2A4B303D7644395C3B2B7053553C5200"
local mac_dirty
local mtdname="$1"
local part
local size
part=$(find_mtd_part "$mtdname")
if [ -z "$part" ]; then
echo "mtd_get_mac_encrypted_arcadyan: partition $mtdname not found!" >&2
return
fi
# Config decryption and getting mac. Trying uencrypt and openssl utils.
size=$((0x$(dd if=$part skip=9 bs=1 count=4 2>/dev/null | hexdump -v -e '1/4 "%08x"')))
if [[ -f "/usr/bin/uencrypt" ]]; then
mac_dirty=$(dd if=$part bs=1 count=$size skip=$((0x100)) 2>/dev/null | \
uencrypt -d -n -k $key -i $iv | grep mac | cut -c 5-)
elif [[ -f "/usr/bin/openssl" ]]; then
mac_dirty=$(dd if=$part bs=1 count=$size skip=$((0x100)) 2>/dev/null | \
openssl aes-128-cbc -d -nopad -K $key -iv $iv | grep mac | cut -c 5-)
else
echo "mtd_get_mac_encrypted_arcadyan: Neither uencrypt nor openssl was found!" >&2
return
fi
# "canonicalize" mac
[ -n "$mac_dirty" ] && macaddr_canonicalize "$mac_dirty"
}
mtd_get_mac_text() {
local mtdname=$1
local offset=$(($2))

View File

@@ -8,10 +8,11 @@ touch /etc/config/ubootenv
board=$(board_name)
case "$board" in
d-link,dgs-1210-10mp|\
d-link,dgs-1210-10p|\
d-link,dgs-1210-16|\
d-link,dgs-1210-20|\
d-link,dgs-1210-28|\
d-link,dgs-1210-10p|\
zyxel,gs1900-8|\
zyxel,gs1900-8hp-v1|\
zyxel,gs1900-8hp-v2|\

View File

@@ -421,9 +421,9 @@ mac80211_hostapd_setup_base() {
he_spr_non_srg_obss_pd_max_offset:1 \
he_bss_color
he_phy_cap=$(iw phy "$phy" info | awk -F "[()]" '/HE PHY Capabilities/ { print $2 }' | head -1)
he_phy_cap=$(iw phy "$phy" info | sed -n '/HE Iftypes: AP/,$p' | awk -F "[()]" '/HE PHY Capabilities/ { print $2 }' | head -1)
he_phy_cap=${he_phy_cap:2}
he_mac_cap=$(iw phy "$phy" info | awk -F "[()]" '/HE MAC Capabilities/ { print $2 }' | head -1)
he_mac_cap=$(iw phy "$phy" info | sed -n '/HE Iftypes: AP/,$p' | awk -F "[()]" '/HE MAC Capabilities/ { print $2 }' | head -1)
he_mac_cap=${he_mac_cap:2}
append base_cfg "ieee80211ax=1" "$N"

View File

@@ -5,9 +5,9 @@ PKG_RELEASE:=1
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL=$(PROJECT_GIT)/project/netifd.git
PKG_SOURCE_DATE:=2022-06-01
PKG_SOURCE_VERSION:=39ef9fe1388029c476db62889ef2ef5661613321
PKG_MIRROR_HASH:=a17353a33ae4ee0aec790169715e91e634660e15eb33900ec4a23c698425de8a
PKG_SOURCE_DATE:=2022-08-19
PKG_SOURCE_VERSION:=bfa039c414bc6613cc5361aaf5fa6baf5fa0264b
PKG_MIRROR_HASH:=f2fef3b61ffeecb116f63a4d53838d1d754f7c52750fd30e3304d26aa578d778
PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name>
PKG_LICENSE:=GPL-2.0

View File

@@ -48,12 +48,15 @@ hostapd_append_wpa_key_mgmt() {
;;
eap192)
append wpa_key_mgmt "WPA-EAP-SUITE-B-192"
[ "${ieee80211r:-0}" -gt 0 ] && append wpa_key_mgmt "FT-EAP"
[ "${ieee80211r:-0}" -gt 0 ] && append wpa_key_mgmt "FT-EAP-SHA384"
;;
eap-eap192)
append wpa_key_mgmt "WPA-EAP-SUITE-B-192"
append wpa_key_mgmt "WPA-EAP"
[ "${ieee80211r:-0}" -gt 0 ] && append wpa_key_mgmt "FT-EAP"
[ "${ieee80211r:-0}" -gt 0 ] && {
append wpa_key_mgmt "FT-EAP-SHA384"
append wpa_key_mgmt "FT-EAP"
}
[ "${ieee80211w:-0}" -gt 0 ] && append wpa_key_mgmt "WPA-EAP-SHA256"
;;
sae)
@@ -971,7 +974,11 @@ hostapd_set_bss_options() {
json_get_vars ieee80211w_mgmt_cipher ieee80211w_max_timeout ieee80211w_retry_timeout
append bss_conf "ieee80211w=$ieee80211w" "$N"
[ "$ieee80211w" -gt "0" ] && {
append bss_conf "group_mgmt_cipher=${ieee80211w_mgmt_cipher:-AES-128-CMAC}" "$N"
if [ "$auth_type" = "eap192" ]; then
append bss_conf "group_mgmt_cipher=BIP-GMAC-256" "$N"
else
append bss_conf "group_mgmt_cipher=${ieee80211w_mgmt_cipher:-AES-128-CMAC}" "$N"
fi
[ -n "$ieee80211w_max_timeout" ] && \
append bss_conf "assoc_sa_query_max_timeout=$ieee80211w_max_timeout" "$N"
[ -n "$ieee80211w_retry_timeout" ] && \

View File

@@ -176,7 +176,7 @@ TARGET_LDFLAGS += -Wl,--gc-sections -Wl,--as-needed
TARGET_CPPFLAGS += -I$(STAGING_DIR)/usr/include/libnl-tiny
MAKE_FLAGS += \
KERNEL_INCLUDE="$(LINUX_DIR)/user_headers/include" \
KERNEL_INCLUDE="$(LINUX_DIR)/include/uapi" \
SHARED_LIBS=$(SHARED_LIBS) \
IP_CONFIG_TINY=$(IP_CONFIG_TINY) \
BUILD_VARIANT=$(BUILD_VARIANT) \

View File

@@ -11,9 +11,9 @@ PKG_RELEASE:=1
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL=$(PROJECT_GIT)/project/iwinfo.git
PKG_SOURCE_DATE:=2022-08-13
PKG_SOURCE_VERSION:=705d3b5cc30ed1ac3b2fed131259bcbc61177e41
PKG_MIRROR_HASH:=091b7f20e95e9f1dfb993d71172d96590041f985e422b7248e15b11798a73644
PKG_SOURCE_DATE:=2022-08-19
PKG_SOURCE_VERSION:=0dad3e6660594592071ae49a77a907e2b11a98fe
PKG_MIRROR_HASH:=2162ee3158328ffe39018e50f34d74b47a6c7a26460e30d7984ca16cbc859d80
PKG_MAINTAINER:=Jo-Philipp Wich <jo@mein.io>
PKG_LICENSE:=GPL-2.0

View File

@@ -22,16 +22,17 @@ CMAKE_OPTIONS+=$(if $(CONFIG_UENCRYPT_WOLFSSL),-DUSE_WOLFSSL=1)
define Package/uencrypt
SECTION:=utils
CATEGORY:=Base system
TITLE:=Decryption utility for Arcadyan WG4xx223
DEPENDS:=@TARGET_ramips_mt7621 +UENCRYPT_WOLFSSL:libwolfssl +UENCRYPT_OPENSSL:libopenssl
TITLE:=Decryption utility for Arcadyan WG4xx223 and TP-Link Deco S4
DEPENDS:=+UENCRYPT_WOLFSSL:libwolfssl +UENCRYPT_OPENSSL:libopenssl
endef
define Package/uencrypt/description
This is a small AES-128-CBC encrypton/decryption program.
Even though it can be used for regular encryption and
decryption operations using AES-128-CBC, it is included
here to unencrypt the configuration from mtd on Arcadyan
WG430223 and WG443223 routers.
This is a small encrypton/decryption program. It defaults
to AES-128-CBC, but supports any encryption provided by
the available openssl/wolfssl library. Even though it can
be used for regular encryption and decryption operations,
it is included here to unencrypt the configuration from mtd
on Arcadyan WG430223/WG443223 and TP-Link Deco S4 routers
endef
define Package/uencrypt/config

View File

@@ -5,6 +5,7 @@
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#ifdef USE_WOLFSSL
@@ -14,7 +15,7 @@
# include <openssl/evp.h>
#endif
int do_crypt(FILE *infile, FILE *outfile, const char *key, const char *iv,
int do_crypt(FILE *infile, FILE *outfile, const EVP_CIPHER *cipher, const char *key, const char *iv,
int enc, int padding)
{
EVP_CIPHER_CTX *ctx;
@@ -22,7 +23,7 @@ int do_crypt(FILE *infile, FILE *outfile, const char *key, const char *iv,
int inlen, outlen;
ctx = EVP_CIPHER_CTX_new();
EVP_CipherInit_ex(ctx, EVP_aes_128_cbc(), NULL, key, iv, enc);
EVP_CipherInit_ex(ctx, cipher, NULL, key, iv, enc);
EVP_CIPHER_CTX_set_padding(ctx, padding);
for (;;) {
@@ -53,9 +54,27 @@ static void check_enc_dec(const int enc)
exit(EXIT_FAILURE);
}
#ifndef USE_WOLFSSL
static void print_ciphers(const OBJ_NAME *name,void *arg) {
fprintf(arg, "\t%s\n", name->name);
}
#endif
static void check_cipher(const EVP_CIPHER *cipher)
{
if (cipher == NULL) {
fprintf(stderr, "Error: invalid cipher: %s.\n", optarg);
#ifndef USE_WOLFSSL
fprintf(stderr, "Supported ciphers: \n", optarg);
OBJ_NAME_do_all_sorted(OBJ_NAME_TYPE_CIPHER_METH, print_ciphers, stderr);
#endif
exit(EXIT_FAILURE);
}
}
static void show_usage(const char* name)
{
fprintf(stderr, "Usage: %s: [-d | -e] [-n] -k key -i iv\n"
fprintf(stderr, "Usage: %s: [-d | -e] [-n] -k key [-i iv] [-c cipher]\n"
"-d = decrypt; -e = encrypt; -n = no padding\n", name);
}
@@ -67,10 +86,19 @@ int main(int argc, char *argv[])
long len;
int opt;
int padding = 1;
int need_iv = 1;
const EVP_CIPHER *cipher = EVP_aes_128_cbc();
int ret;
while ((opt = getopt(argc, argv, "dei:k:n")) != -1) {
while ((opt = getopt(argc, argv, "c:dei:k:n")) != -1) {
switch (opt) {
case 'c':
cipher = EVP_get_cipherbyname(optarg);
check_cipher(cipher);
int arglen = strlen(optarg);
if (arglen > 3 && strncmp(optarg+arglen-3, "ecb", 3) == 0) //if ends with "ecb"
need_iv = 0;
break;
case 'd':
check_enc_dec(enc);
enc = 0;
@@ -81,16 +109,16 @@ int main(int argc, char *argv[])
break;
case 'i':
iv = OPENSSL_hexstr2buf((const char *)optarg, &len);
if (iv == NULL || len != 16) {
fprintf(stderr, "Error setting IV to %s. The IV should be 16 bytes, encoded in hex.\n",
if (iv == NULL) {
fprintf(stderr, "Error setting IV to %s. The IV should be encoded in hex.\n",
optarg);
exit(EINVAL);
}
break;
case 'k':
key = OPENSSL_hexstr2buf((const char *)optarg, &len);
if (key == NULL || len != 16) {
fprintf(stderr, "Error setting key to %s. The key should be 16 bytes, encoded in hex.\n",
if (key == NULL) {
fprintf(stderr, "Error setting key to %s. The key should be encoded in hex.\n",
optarg);
exit(EINVAL);
}
@@ -103,12 +131,17 @@ int main(int argc, char *argv[])
exit(EINVAL);
}
}
if (iv == NULL || key == NULL) {
fprintf(stderr, "Error: %s not set.\n", key ? "iv" : (iv ? "key" : "key and iv"));
if (need_iv && iv == NULL) {
fprintf(stderr, "Error: iv not set.\n");
show_usage(argv[0]);
exit(EXIT_FAILURE);
}
if (key == NULL) {
fprintf(stderr, "Error: key not set.\n");
show_usage(argv[0]);
exit(EXIT_FAILURE);
}
ret = do_crypt(stdin, stdout, key, iv, !!enc, padding);
ret = do_crypt(stdin, stdout, cipher, key, iv, !!enc, padding);
if (ret)
fprintf(stderr, "Error during crypt operation.\n");
OPENSSL_free(iv);

View File

@@ -0,0 +1,46 @@
// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
#include "ar9342_zyxel_nwa11xx.dtsi"
/ {
compatible = "zyxel,nwa1100-nh", "qca,ar9342";
model = "Zyxel NWA1100-NH";
aliases {
label-mac-device = &eth0;
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_status_green: status_green {
label = "green:status";
gpios = <&gpio 12 GPIO_ACTIVE_HIGH>;
default-state = "on";
};
led_status_red: status_red {
label = "red:status";
gpios = <&gpio 11 GPIO_ACTIVE_LOW>;
};
led_wlan_green: wlan_green {
label = "green:wlan";
gpios = <&gpio 15 GPIO_ACTIVE_LOW>;
linux,default-trigger = "phy0tpt";
};
led_lan_green: lan_green {
label = "green:lan";
gpios = <&gpio 13 GPIO_ACTIVE_LOW>;
};
led_lan_amber: lan_amber {
label = "amber:lan";
gpios = <&gpio 17 GPIO_ACTIVE_LOW>;
};
};
};

View File

@@ -0,0 +1,31 @@
// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
#include "ar9342_zyxel_nwa11xx.dtsi"
/ {
compatible = "zyxel,nwa1121-ni", "qca,ar9342";
model = "Zyxel NWA1121-NI";
aliases {
label-mac-device = &eth0;
led-boot = &led_status_green;
led-failsafe = &led_status_amber;
led-running = &led_status_green;
led-upgrade = &led_status_amber;
};
leds {
compatible = "gpio-leds";
led_status_green: status_green {
label = "green:status";
gpios = <&gpio 12 GPIO_ACTIVE_LOW>;
default-state = "on";
};
led_status_amber: status_amber {
label = "amber:status";
gpios = <&gpio 11 GPIO_ACTIVE_LOW>;
};
};
};

View File

@@ -0,0 +1,35 @@
// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
#include "ar9342_zyxel_nwa11xx.dtsi"
/ {
compatible = "zyxel,nwa1123-ac", "qca,ar9342";
model = "Zyxel NWA1123-AC";
aliases {
label-mac-device = &eth0;
led-boot = &led_status_green;
led-failsafe = &led_status_amber;
led-running = &led_status_green;
led-upgrade = &led_status_amber;
};
leds {
compatible = "gpio-leds";
led_status_green: status_green {
label = "green:status";
gpios = <&gpio 12 GPIO_ACTIVE_LOW>;
default-state = "on";
};
led_status_amber: status_amber {
label = "amber:status";
gpios = <&gpio 11 GPIO_ACTIVE_LOW>;
};
};
};
&pcie {
status = "okay";
};

View File

@@ -0,0 +1,35 @@
// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
#include "ar9342_zyxel_nwa11xx.dtsi"
/ {
compatible = "zyxel,nwa1123-ni", "qca,ar9342";
model = "Zyxel NWA1123-NI";
aliases {
label-mac-device = &eth0;
led-boot = &led_status_green;
led-failsafe = &led_status_amber;
led-running = &led_status_green;
led-upgrade = &led_status_amber;
};
leds {
compatible = "gpio-leds";
led_status_green: status_green {
label = "green:status";
gpios = <&gpio 12 GPIO_ACTIVE_LOW>;
default-state = "on";
};
led_status_amber: status_amber {
label = "amber:status";
gpios = <&gpio 11 GPIO_ACTIVE_LOW>;
};
};
};
&pcie {
status = "okay";
};

View File

@@ -0,0 +1,166 @@
// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
#include "ar9344.dtsi"
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/input.h>
#include <dt-bindings/mtd/partitions/uimage.h>
/ {
keys {
compatible = "gpio-keys";
reset {
label = "reset";
linux,code = <KEY_RESTART>;
gpios = <&gpio 4 GPIO_ACTIVE_LOW>;
};
};
virtual_flash {
compatible = "mtd-concat";
devices = <&fwconcat0 &fwconcat1>;
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
partition@0 {
compatible = "openwrt,uimage", "denx,uimage";
openwrt,ih-magic = <IH_MAGIC_OKLI>;
label = "firmware";
reg = <0x0 0x0>;
};
};
};
};
&ref {
clock-frequency = <40000000>;
};
&spi {
status = "okay";
flash@0 {
compatible = "jedec,spi-nor";
reg = <0>;
spi-max-frequency = <50000000>;
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
partition@0 {
label = "u-boot";
reg = <0x000000 0x040000>;
read-only;
};
partition@40000 {
label = "u-boot-env";
reg = <0x040000 0x010000>;
};
fwconcat0: partition@50000 {
label = "fwconcat0";
reg = <0x050000 0x800000>;
};
partition@850000 {
label = "loader";
reg = <0x850000 0x010000>;
read-only;
};
fwconcat1: partition@860000 {
label = "fwconcat1";
reg = <0x860000 0x740000>;
};
partition@fa0000 {
label = "config";
reg = <0xfa0000 0x040000>;
read-only;
};
partition@fe0000 {
label = "mib0";
reg = <0xfe0000 0x010000>;
read-only;
compatible = "nvmem-cells";
#address-cells = <1>;
#size-cells = <1>;
macaddr_mib0_4b: macaddr@4b {
reg = <0x4b 0x11>;
};
macaddr_mib0_66: macaddr@66 {
reg = <0x66 0x11>;
};
};
art: partition@ff0000 {
label = "art";
reg = <0xff0000 0x010000>;
read-only;
compatible = "nvmem-cells";
#address-cells = <1>;
#size-cells = <1>;
calibration_ath9k: calibration@1000 {
reg = <0x1000 0x440>;
};
macaddr_art_1002: macaddr@1002 {
reg = <0x1002 0x6>;
};
};
};
};
};
&mdio0 {
status = "okay";
phy0: ethernet-phy@0 {
reg = <0>;
phy-mode = "rgmii";
};
};
&eth0 {
status = "okay";
pll-data = <0x06000000 0x00000101 0x00001313>;
nvmem-cells = <&macaddr_art_1002>;
nvmem-cell-names = "mac-address";
phy-mode = "rgmii-id";
phy-handle = <&phy0>;
gmac-config {
device = <&gmac>;
rxdv-delay = <3>;
rxd-delay = <3>;
txen-delay = <3>;
txd-delay = <3>;
rgmii-gmac0 = <1>;
};
};
&wmac {
status = "okay";
ieee80211-freq-limit = <2402000 2482000>;
nvmem-cells = <&macaddr_mib0_4b>, <&calibration_ath9k>;
nvmem-cell-names = "mac-address-ascii", "calibration";
};

View File

@@ -484,6 +484,9 @@ zbtlink,zbt-wd323)
ucidef_set_led_switch "lan1" "LAN1" "orange:lan1" "switch0" "0x10"
ucidef_set_led_switch "lan2" "LAN2" "orange:lan2" "switch0" "0x08"
;;
zyxel,nwa1100-nh)
ucidef_set_led_netdev "lan_data" "LAN_DATA" "amber:lan" "eth0" "tx rx"
ucidef_set_led_netdev "lan_link" "LAN_LINK" "green:lan" "eth0" "link"
esac
board_config_flush

View File

@@ -109,7 +109,11 @@ ath79_setup_interfaces()
ubnt,unifiac-mesh|\
ubnt,unifi|\
wd,mynet-wifi-rangeextender|\
winchannel,wb2000)
winchannel,wb2000|\
zyxel,nwa1100-nh|\
zyxel,nwa1121-ni|\
zyxel,nwa1123-ac|\
zyxel,nwa1123-ni)
ucidef_set_interface_lan "eth0"
;;
airtight,c-75)

View File

@@ -68,4 +68,12 @@ case "$board" in
[ "$PHYNBR" -eq 1 ] && \
mtd_get_mac_ascii u-boot-env ethaddr > /sys${DEVPATH}/macaddress
;;
zyxel,nwa1123-ac)
[ "$PHYNBR" -eq 0 ] && \
mtd_get_mac_text mib0 0x66 > /sys${DEVPATH}/macaddress
;;
zyxel,nwa1123-ni)
[ "$PHYNBR" -eq 1 ] && \
mtd_get_mac_text mib0 0x66 > /sys${DEVPATH}/macaddress
;;
esac

View File

@@ -9,7 +9,7 @@ DEVICE_VARS += ADDPATTERN_ID ADDPATTERN_VERSION
DEVICE_VARS += SEAMA_SIGNATURE SEAMA_MTDBLOCK
DEVICE_VARS += KERNEL_INITRAMFS_PREFIX DAP_SIGNATURE
DEVICE_VARS += EDIMAX_HEADER_MAGIC EDIMAX_HEADER_MODEL
DEVICE_VARS += OPENMESH_CE_TYPE
DEVICE_VARS += OPENMESH_CE_TYPE ZYXEL_MODEL_STRING
define Build/add-elecom-factory-initramfs
$(eval edimax_model=$(word 1,$(1)))
@@ -161,6 +161,13 @@ define Build/wrgg-pad-rootfs
$(STAGING_DIR_HOST)/bin/padjffs2 $(IMAGE_ROOTFS) -c 64 >>$@
endef
define Build/zyxel-tar-bz2
mkdir -p $@.tmp
mv $@ $@.tmp/$(word 2,$(1))
cp $(KDIR)/loader-$(DEVICE_NAME).uImage $@.tmp/$(word 1,$(1)).lzma.uImage
$(TAR) -cjf $@ -C $@.tmp .
rm -rf $@.tmp
endef
define Device/seama
KERNEL := kernel-bin | append-dtb | relocate-kernel | lzma
@@ -2689,6 +2696,54 @@ define Device/zbtlink_zbt-wd323
endef
TARGET_DEVICES += zbtlink_zbt-wd323
define Device/zyxel_nwa11xx
$(Device/loader-okli-uimage)
SOC := ar9342
DEVICE_VENDOR := ZyXEL
LOADER_FLASH_OFFS := 0x050000
KERNEL := kernel-bin | append-dtb | lzma | uImage lzma -M 0x4f4b4c49
IMAGE_SIZE := 8192k
IMAGES += factory-$$$$(ZYXEL_MODEL_STRING).bin
IMAGE/factory-$$$$(ZYXEL_MODEL_STRING).bin := \
append-kernel | pad-to $$$$(BLOCKSIZE) | append-rootfs | \
pad-rootfs | pad-to 8192k | check-size | zyxel-tar-bz2 \
vmlinux_mi124_f1e mi124_f1e-jffs2 | append-md5sum-bin
endef
define Device/zyxel_nwa1100-nh
$(Device/zyxel_nwa11xx)
DEVICE_MODEL := NWA1100
DEVICE_VARIANT := NH
ZYXEL_MODEL_STRING := AASI
endef
TARGET_DEVICES += zyxel_nwa1100-nh
define Device/zyxel_nwa1121-ni
$(Device/zyxel_nwa11xx)
DEVICE_MODEL := NWA1121
DEVICE_VARIANT := NI
ZYXEL_MODEL_STRING := AABJ
endef
TARGET_DEVICES += zyxel_nwa1121-ni
define Device/zyxel_nwa1123-ac
$(Device/zyxel_nwa11xx)
DEVICE_MODEL := NWA1123
DEVICE_VARIANT := AC
ZYXEL_MODEL_STRING := AAOX
DEVICE_PACKAGES := kmod-ath10k-ct-smallbuffers \
ath10k-firmware-qca988x-ct
endef
TARGET_DEVICES += zyxel_nwa1123-ac
define Device/zyxel_nwa1123-ni
$(Device/zyxel_nwa11xx)
DEVICE_MODEL := NWA1123
DEVICE_VARIANT := NI
ZYXEL_MODEL_STRING := AAEO
endef
TARGET_DEVICES += zyxel_nwa1123-ni
define Device/zyxel_nbg6616
SOC := qca9557
DEVICE_VENDOR := ZyXEL

View File

@@ -160,6 +160,9 @@ CONFIG_NET_FLOW_LIMIT=y
CONFIG_NET_SWITCHDEV=y
CONFIG_NO_IOPORT_MAP=y
CONFIG_NR_CPUS=4
CONFIG_NVMEM=y
CONFIG_NVMEM_SYSFS=y
CONFIG_NVMEM_U_BOOT_ENV=y
CONFIG_OF=y
CONFIG_OF_ADDRESS=y
CONFIG_OF_EARLY_FLATTREE=y

View File

@@ -19,9 +19,9 @@ Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
--- a/drivers/nvmem/Kconfig
+++ b/drivers/nvmem/Kconfig
@@ -270,4 +270,13 @@ config SPRD_EFUSE
This driver can also be built as a module. If so, the module
will be called nvmem-sprd-efuse.
@@ -283,4 +283,13 @@ config NVMEM_U_BOOT_ENV
If compiled as module it will be called nvmem_u-boot-env.
+
+config NVMEM_BRCM_NVRAM
@@ -35,10 +35,10 @@ Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
endif
--- a/drivers/nvmem/Makefile
+++ b/drivers/nvmem/Makefile
@@ -55,3 +55,5 @@ obj-$(CONFIG_NVMEM_ZYNQMP) += nvmem_zynq
nvmem_zynqmp_nvmem-y := zynqmp_nvmem.o
obj-$(CONFIG_SPRD_EFUSE) += nvmem_sprd_efuse.o
@@ -57,3 +57,5 @@ obj-$(CONFIG_SPRD_EFUSE) += nvmem_sprd_e
nvmem_sprd_efuse-y := sprd-efuse.o
obj-$(CONFIG_NVMEM_U_BOOT_ENV) += nvmem_u-boot-env.o
nvmem_u-boot-env-y := u-boot-env.o
+obj-$(CONFIG_NVMEM_BRCM_NVRAM) += nvmem_brcm_nvram.o
+nvmem_brcm_nvram-y := brcm_nvram.o
--- /dev/null

View File

@@ -0,0 +1,72 @@
From b0321721be50b80c03a51866a94fde4f94690e18 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
Date: Wed, 15 Jun 2022 21:42:59 +0200
Subject: [PATCH] mtd: allow getting MTD device associated with a specific DT
node
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
MTD subsystem API allows interacting with MTD devices (e.g. reading,
writing, handling bad blocks). So far a random driver could get MTD
device only by its name (get_mtd_device_nm()). This change allows
getting them also by a DT node.
This API is required for drivers handling DT defined MTD partitions in a
specific way (e.g. U-Boot (sub)partition with environment variables).
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Acked-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
drivers/mtd/mtdcore.c | 28 ++++++++++++++++++++++++++++
include/linux/mtd/mtd.h | 1 +
2 files changed, 29 insertions(+)
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -1070,6 +1070,34 @@ int __get_mtd_device(struct mtd_info *mt
EXPORT_SYMBOL_GPL(__get_mtd_device);
/**
+ * of_get_mtd_device_by_node - obtain an MTD device associated with a given node
+ *
+ * @np: device tree node
+ */
+struct mtd_info *of_get_mtd_device_by_node(struct device_node *np)
+{
+ struct mtd_info *mtd = NULL;
+ struct mtd_info *tmp;
+ int err;
+
+ mutex_lock(&mtd_table_mutex);
+
+ err = -EPROBE_DEFER;
+ mtd_for_each_device(tmp) {
+ if (mtd_get_of_node(tmp) == np) {
+ mtd = tmp;
+ err = __get_mtd_device(mtd);
+ break;
+ }
+ }
+
+ mutex_unlock(&mtd_table_mutex);
+
+ return err ? ERR_PTR(err) : mtd;
+}
+EXPORT_SYMBOL_GPL(of_get_mtd_device_by_node);
+
+/**
* get_mtd_device_nm - obtain a validated handle for an MTD device by
* device name
* @name: MTD device name to open
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -675,6 +675,7 @@ extern int mtd_device_unregister(struct
extern struct mtd_info *get_mtd_device(struct mtd_info *mtd, int num);
extern int __get_mtd_device(struct mtd_info *mtd);
extern void __put_mtd_device(struct mtd_info *mtd);
+extern struct mtd_info *of_get_mtd_device_by_node(struct device_node *np);
extern struct mtd_info *get_mtd_device_nm(const char *name);
extern void put_mtd_device(struct mtd_info *mtd);

View File

@@ -0,0 +1,278 @@
From f955dc14450695564926711cf9fa8e1d5d854302 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
Date: Wed, 15 Jun 2022 21:43:00 +0200
Subject: [PATCH] nvmem: add driver handling U-Boot environment variables
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
U-Boot stores its setup as environment variables. It's a list of
key-value pairs stored on flash device with a custom header.
This commit adds an NVMEM driver that:
1. Provides NVMEM access to environment vars binary data
2. Extracts variables as NVMEM cells
Current Linux's NVMEM sysfs API allows reading whole NVMEM data block.
It can be used by user-space tools for reading U-Boot env vars block
without the hassle of finding its location. Parsing will still need to
be re-done there.
Kernel-parsed NVMEM cells can be read however by Linux drivers. This may
be useful for Ethernet drivers for reading device MAC address which is
often stored as U-Boot env variable.
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
--- a/drivers/nvmem/Kconfig
+++ b/drivers/nvmem/Kconfig
@@ -270,4 +270,17 @@ config SPRD_EFUSE
This driver can also be built as a module. If so, the module
will be called nvmem-sprd-efuse.
+config NVMEM_U_BOOT_ENV
+ tristate "U-Boot environment variables support"
+ depends on OF && MTD
+ select CRC32
+ help
+ U-Boot stores its setup as environment variables. This driver adds
+ support for verifying & exporting such data. It also exposes variables
+ as NVMEM cells so they can be referenced by other drivers.
+
+ Currently this drivers works only with env variables on top of MTD.
+
+ If compiled as module it will be called nvmem_u-boot-env.
+
endif
--- a/drivers/nvmem/Makefile
+++ b/drivers/nvmem/Makefile
@@ -55,3 +55,5 @@ obj-$(CONFIG_NVMEM_ZYNQMP) += nvmem_zynq
nvmem_zynqmp_nvmem-y := zynqmp_nvmem.o
obj-$(CONFIG_SPRD_EFUSE) += nvmem_sprd_efuse.o
nvmem_sprd_efuse-y := sprd-efuse.o
+obj-$(CONFIG_NVMEM_U_BOOT_ENV) += nvmem_u-boot-env.o
+nvmem_u-boot-env-y := u-boot-env.o
--- /dev/null
+++ b/drivers/nvmem/u-boot-env.c
@@ -0,0 +1,218 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (C) 2022 Rafał Miłecki <rafal@milecki.pl>
+ */
+
+#include <linux/crc32.h>
+#include <linux/mod_devicetable.h>
+#include <linux/module.h>
+#include <linux/mtd/mtd.h>
+#include <linux/nvmem-consumer.h>
+#include <linux/nvmem-provider.h>
+#include <linux/of_device.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+
+enum u_boot_env_format {
+ U_BOOT_FORMAT_SINGLE,
+ U_BOOT_FORMAT_REDUNDANT,
+};
+
+struct u_boot_env {
+ struct device *dev;
+ enum u_boot_env_format format;
+
+ struct mtd_info *mtd;
+
+ /* Cells */
+ struct nvmem_cell_info *cells;
+ int ncells;
+};
+
+struct u_boot_env_image_single {
+ __le32 crc32;
+ uint8_t data[];
+} __packed;
+
+struct u_boot_env_image_redundant {
+ __le32 crc32;
+ u8 mark;
+ uint8_t data[];
+} __packed;
+
+static int u_boot_env_read(void *context, unsigned int offset, void *val,
+ size_t bytes)
+{
+ struct u_boot_env *priv = context;
+ struct device *dev = priv->dev;
+ size_t bytes_read;
+ int err;
+
+ err = mtd_read(priv->mtd, offset, bytes, &bytes_read, val);
+ if (err && !mtd_is_bitflip(err)) {
+ dev_err(dev, "Failed to read from mtd: %d\n", err);
+ return err;
+ }
+
+ if (bytes_read != bytes) {
+ dev_err(dev, "Failed to read %zu bytes\n", bytes);
+ return -EIO;
+ }
+
+ return 0;
+}
+
+static int u_boot_env_add_cells(struct u_boot_env *priv, uint8_t *buf,
+ size_t data_offset, size_t data_len)
+{
+ struct device *dev = priv->dev;
+ char *data = buf + data_offset;
+ char *var, *value, *eq;
+ int idx;
+
+ priv->ncells = 0;
+ for (var = data; var < data + data_len && *var; var += strlen(var) + 1)
+ priv->ncells++;
+
+ priv->cells = devm_kcalloc(dev, priv->ncells, sizeof(*priv->cells), GFP_KERNEL);
+ if (!priv->cells)
+ return -ENOMEM;
+
+ for (var = data, idx = 0;
+ var < data + data_len && *var;
+ var = value + strlen(value) + 1, idx++) {
+ eq = strchr(var, '=');
+ if (!eq)
+ break;
+ *eq = '\0';
+ value = eq + 1;
+
+ priv->cells[idx].name = devm_kstrdup(dev, var, GFP_KERNEL);
+ if (!priv->cells[idx].name)
+ return -ENOMEM;
+ priv->cells[idx].offset = data_offset + value - data;
+ priv->cells[idx].bytes = strlen(value);
+ }
+
+ if (WARN_ON(idx != priv->ncells))
+ priv->ncells = idx;
+
+ return 0;
+}
+
+static int u_boot_env_parse(struct u_boot_env *priv)
+{
+ struct device *dev = priv->dev;
+ size_t crc32_data_offset;
+ size_t crc32_data_len;
+ size_t crc32_offset;
+ size_t data_offset;
+ size_t data_len;
+ uint32_t crc32;
+ uint32_t calc;
+ size_t bytes;
+ uint8_t *buf;
+ int err;
+
+ buf = kcalloc(1, priv->mtd->size, GFP_KERNEL);
+ if (!buf) {
+ err = -ENOMEM;
+ goto err_out;
+ }
+
+ err = mtd_read(priv->mtd, 0, priv->mtd->size, &bytes, buf);
+ if ((err && !mtd_is_bitflip(err)) || bytes != priv->mtd->size) {
+ dev_err(dev, "Failed to read from mtd: %d\n", err);
+ goto err_kfree;
+ }
+
+ switch (priv->format) {
+ case U_BOOT_FORMAT_SINGLE:
+ crc32_offset = offsetof(struct u_boot_env_image_single, crc32);
+ crc32_data_offset = offsetof(struct u_boot_env_image_single, data);
+ data_offset = offsetof(struct u_boot_env_image_single, data);
+ break;
+ case U_BOOT_FORMAT_REDUNDANT:
+ crc32_offset = offsetof(struct u_boot_env_image_redundant, crc32);
+ crc32_data_offset = offsetof(struct u_boot_env_image_redundant, mark);
+ data_offset = offsetof(struct u_boot_env_image_redundant, data);
+ break;
+ }
+ crc32 = le32_to_cpu(*(uint32_t *)(buf + crc32_offset));
+ crc32_data_len = priv->mtd->size - crc32_data_offset;
+ data_len = priv->mtd->size - data_offset;
+
+ calc = crc32(~0, buf + crc32_data_offset, crc32_data_len) ^ ~0L;
+ if (calc != crc32) {
+ dev_err(dev, "Invalid calculated CRC32: 0x%08x (expected: 0x%08x)\n", calc, crc32);
+ err = -EINVAL;
+ goto err_kfree;
+ }
+
+ buf[priv->mtd->size - 1] = '\0';
+ err = u_boot_env_add_cells(priv, buf, data_offset, data_len);
+ if (err)
+ dev_err(dev, "Failed to add cells: %d\n", err);
+
+err_kfree:
+ kfree(buf);
+err_out:
+ return err;
+}
+
+static int u_boot_env_probe(struct platform_device *pdev)
+{
+ struct nvmem_config config = {
+ .name = "u-boot-env",
+ .reg_read = u_boot_env_read,
+ };
+ struct device *dev = &pdev->dev;
+ struct device_node *np = dev->of_node;
+ struct u_boot_env *priv;
+ int err;
+
+ priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
+ if (!priv)
+ return -ENOMEM;
+ priv->dev = dev;
+
+ priv->format = (uintptr_t)of_device_get_match_data(dev);
+
+ priv->mtd = of_get_mtd_device_by_node(np);
+ if (IS_ERR(priv->mtd)) {
+ dev_err_probe(dev, PTR_ERR(priv->mtd), "Failed to get %pOF MTD\n", np);
+ return PTR_ERR(priv->mtd);
+ }
+
+ err = u_boot_env_parse(priv);
+ if (err)
+ return err;
+
+ config.dev = dev;
+ config.cells = priv->cells;
+ config.ncells = priv->ncells;
+ config.priv = priv;
+ config.size = priv->mtd->size;
+
+ return PTR_ERR_OR_ZERO(devm_nvmem_register(dev, &config));
+}
+
+static const struct of_device_id u_boot_env_of_match_table[] = {
+ { .compatible = "u-boot,env", .data = (void *)U_BOOT_FORMAT_SINGLE, },
+ { .compatible = "u-boot,env-redundant-bool", .data = (void *)U_BOOT_FORMAT_REDUNDANT, },
+ { .compatible = "u-boot,env-redundant-count", .data = (void *)U_BOOT_FORMAT_REDUNDANT, },
+ {},
+};
+
+static struct platform_driver u_boot_env_driver = {
+ .probe = u_boot_env_probe,
+ .driver = {
+ .name = "u_boot_env",
+ .of_match_table = u_boot_env_of_match_table,
+ },
+};
+module_platform_driver(u_boot_env_driver);
+
+MODULE_AUTHOR("Rafał Miłecki");
+MODULE_LICENSE("GPL");
+MODULE_DEVICE_TABLE(of, u_boot_env_of_match_table);

View File

@@ -0,0 +1,72 @@
From b0321721be50b80c03a51866a94fde4f94690e18 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
Date: Wed, 15 Jun 2022 21:42:59 +0200
Subject: [PATCH] mtd: allow getting MTD device associated with a specific DT
node
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
MTD subsystem API allows interacting with MTD devices (e.g. reading,
writing, handling bad blocks). So far a random driver could get MTD
device only by its name (get_mtd_device_nm()). This change allows
getting them also by a DT node.
This API is required for drivers handling DT defined MTD partitions in a
specific way (e.g. U-Boot (sub)partition with environment variables).
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Acked-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
drivers/mtd/mtdcore.c | 28 ++++++++++++++++++++++++++++
include/linux/mtd/mtd.h | 1 +
2 files changed, 29 insertions(+)
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -1227,6 +1227,34 @@ int __get_mtd_device(struct mtd_info *mt
EXPORT_SYMBOL_GPL(__get_mtd_device);
/**
+ * of_get_mtd_device_by_node - obtain an MTD device associated with a given node
+ *
+ * @np: device tree node
+ */
+struct mtd_info *of_get_mtd_device_by_node(struct device_node *np)
+{
+ struct mtd_info *mtd = NULL;
+ struct mtd_info *tmp;
+ int err;
+
+ mutex_lock(&mtd_table_mutex);
+
+ err = -EPROBE_DEFER;
+ mtd_for_each_device(tmp) {
+ if (mtd_get_of_node(tmp) == np) {
+ mtd = tmp;
+ err = __get_mtd_device(mtd);
+ break;
+ }
+ }
+
+ mutex_unlock(&mtd_table_mutex);
+
+ return err ? ERR_PTR(err) : mtd;
+}
+EXPORT_SYMBOL_GPL(of_get_mtd_device_by_node);
+
+/**
* get_mtd_device_nm - obtain a validated handle for an MTD device by
* device name
* @name: MTD device name to open
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -682,6 +682,7 @@ extern int mtd_device_unregister(struct
extern struct mtd_info *get_mtd_device(struct mtd_info *mtd, int num);
extern int __get_mtd_device(struct mtd_info *mtd);
extern void __put_mtd_device(struct mtd_info *mtd);
+extern struct mtd_info *of_get_mtd_device_by_node(struct device_node *np);
extern struct mtd_info *get_mtd_device_nm(const char *name);
extern void put_mtd_device(struct mtd_info *mtd);

View File

@@ -0,0 +1,278 @@
From f955dc14450695564926711cf9fa8e1d5d854302 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
Date: Wed, 15 Jun 2022 21:43:00 +0200
Subject: [PATCH] nvmem: add driver handling U-Boot environment variables
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
U-Boot stores its setup as environment variables. It's a list of
key-value pairs stored on flash device with a custom header.
This commit adds an NVMEM driver that:
1. Provides NVMEM access to environment vars binary data
2. Extracts variables as NVMEM cells
Current Linux's NVMEM sysfs API allows reading whole NVMEM data block.
It can be used by user-space tools for reading U-Boot env vars block
without the hassle of finding its location. Parsing will still need to
be re-done there.
Kernel-parsed NVMEM cells can be read however by Linux drivers. This may
be useful for Ethernet drivers for reading device MAC address which is
often stored as U-Boot env variable.
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
--- a/drivers/nvmem/Kconfig
+++ b/drivers/nvmem/Kconfig
@@ -300,4 +300,17 @@ config NVMEM_BRCM_NVRAM
This driver provides support for Broadcom's NVRAM that can be accessed
using I/O mapping.
+config NVMEM_U_BOOT_ENV
+ tristate "U-Boot environment variables support"
+ depends on OF && MTD
+ select CRC32
+ help
+ U-Boot stores its setup as environment variables. This driver adds
+ support for verifying & exporting such data. It also exposes variables
+ as NVMEM cells so they can be referenced by other drivers.
+
+ Currently this drivers works only with env variables on top of MTD.
+
+ If compiled as module it will be called nvmem_u-boot-env.
+
endif
--- a/drivers/nvmem/Makefile
+++ b/drivers/nvmem/Makefile
@@ -61,3 +61,5 @@ obj-$(CONFIG_NVMEM_RMEM) += nvmem-rmem.
nvmem-rmem-y := rmem.o
obj-$(CONFIG_NVMEM_BRCM_NVRAM) += nvmem_brcm_nvram.o
nvmem_brcm_nvram-y := brcm_nvram.o
+obj-$(CONFIG_NVMEM_U_BOOT_ENV) += nvmem_u-boot-env.o
+nvmem_u-boot-env-y := u-boot-env.o
--- /dev/null
+++ b/drivers/nvmem/u-boot-env.c
@@ -0,0 +1,218 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (C) 2022 Rafał Miłecki <rafal@milecki.pl>
+ */
+
+#include <linux/crc32.h>
+#include <linux/mod_devicetable.h>
+#include <linux/module.h>
+#include <linux/mtd/mtd.h>
+#include <linux/nvmem-consumer.h>
+#include <linux/nvmem-provider.h>
+#include <linux/of_device.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+
+enum u_boot_env_format {
+ U_BOOT_FORMAT_SINGLE,
+ U_BOOT_FORMAT_REDUNDANT,
+};
+
+struct u_boot_env {
+ struct device *dev;
+ enum u_boot_env_format format;
+
+ struct mtd_info *mtd;
+
+ /* Cells */
+ struct nvmem_cell_info *cells;
+ int ncells;
+};
+
+struct u_boot_env_image_single {
+ __le32 crc32;
+ uint8_t data[];
+} __packed;
+
+struct u_boot_env_image_redundant {
+ __le32 crc32;
+ u8 mark;
+ uint8_t data[];
+} __packed;
+
+static int u_boot_env_read(void *context, unsigned int offset, void *val,
+ size_t bytes)
+{
+ struct u_boot_env *priv = context;
+ struct device *dev = priv->dev;
+ size_t bytes_read;
+ int err;
+
+ err = mtd_read(priv->mtd, offset, bytes, &bytes_read, val);
+ if (err && !mtd_is_bitflip(err)) {
+ dev_err(dev, "Failed to read from mtd: %d\n", err);
+ return err;
+ }
+
+ if (bytes_read != bytes) {
+ dev_err(dev, "Failed to read %zu bytes\n", bytes);
+ return -EIO;
+ }
+
+ return 0;
+}
+
+static int u_boot_env_add_cells(struct u_boot_env *priv, uint8_t *buf,
+ size_t data_offset, size_t data_len)
+{
+ struct device *dev = priv->dev;
+ char *data = buf + data_offset;
+ char *var, *value, *eq;
+ int idx;
+
+ priv->ncells = 0;
+ for (var = data; var < data + data_len && *var; var += strlen(var) + 1)
+ priv->ncells++;
+
+ priv->cells = devm_kcalloc(dev, priv->ncells, sizeof(*priv->cells), GFP_KERNEL);
+ if (!priv->cells)
+ return -ENOMEM;
+
+ for (var = data, idx = 0;
+ var < data + data_len && *var;
+ var = value + strlen(value) + 1, idx++) {
+ eq = strchr(var, '=');
+ if (!eq)
+ break;
+ *eq = '\0';
+ value = eq + 1;
+
+ priv->cells[idx].name = devm_kstrdup(dev, var, GFP_KERNEL);
+ if (!priv->cells[idx].name)
+ return -ENOMEM;
+ priv->cells[idx].offset = data_offset + value - data;
+ priv->cells[idx].bytes = strlen(value);
+ }
+
+ if (WARN_ON(idx != priv->ncells))
+ priv->ncells = idx;
+
+ return 0;
+}
+
+static int u_boot_env_parse(struct u_boot_env *priv)
+{
+ struct device *dev = priv->dev;
+ size_t crc32_data_offset;
+ size_t crc32_data_len;
+ size_t crc32_offset;
+ size_t data_offset;
+ size_t data_len;
+ uint32_t crc32;
+ uint32_t calc;
+ size_t bytes;
+ uint8_t *buf;
+ int err;
+
+ buf = kcalloc(1, priv->mtd->size, GFP_KERNEL);
+ if (!buf) {
+ err = -ENOMEM;
+ goto err_out;
+ }
+
+ err = mtd_read(priv->mtd, 0, priv->mtd->size, &bytes, buf);
+ if ((err && !mtd_is_bitflip(err)) || bytes != priv->mtd->size) {
+ dev_err(dev, "Failed to read from mtd: %d\n", err);
+ goto err_kfree;
+ }
+
+ switch (priv->format) {
+ case U_BOOT_FORMAT_SINGLE:
+ crc32_offset = offsetof(struct u_boot_env_image_single, crc32);
+ crc32_data_offset = offsetof(struct u_boot_env_image_single, data);
+ data_offset = offsetof(struct u_boot_env_image_single, data);
+ break;
+ case U_BOOT_FORMAT_REDUNDANT:
+ crc32_offset = offsetof(struct u_boot_env_image_redundant, crc32);
+ crc32_data_offset = offsetof(struct u_boot_env_image_redundant, mark);
+ data_offset = offsetof(struct u_boot_env_image_redundant, data);
+ break;
+ }
+ crc32 = le32_to_cpu(*(uint32_t *)(buf + crc32_offset));
+ crc32_data_len = priv->mtd->size - crc32_data_offset;
+ data_len = priv->mtd->size - data_offset;
+
+ calc = crc32(~0, buf + crc32_data_offset, crc32_data_len) ^ ~0L;
+ if (calc != crc32) {
+ dev_err(dev, "Invalid calculated CRC32: 0x%08x (expected: 0x%08x)\n", calc, crc32);
+ err = -EINVAL;
+ goto err_kfree;
+ }
+
+ buf[priv->mtd->size - 1] = '\0';
+ err = u_boot_env_add_cells(priv, buf, data_offset, data_len);
+ if (err)
+ dev_err(dev, "Failed to add cells: %d\n", err);
+
+err_kfree:
+ kfree(buf);
+err_out:
+ return err;
+}
+
+static int u_boot_env_probe(struct platform_device *pdev)
+{
+ struct nvmem_config config = {
+ .name = "u-boot-env",
+ .reg_read = u_boot_env_read,
+ };
+ struct device *dev = &pdev->dev;
+ struct device_node *np = dev->of_node;
+ struct u_boot_env *priv;
+ int err;
+
+ priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
+ if (!priv)
+ return -ENOMEM;
+ priv->dev = dev;
+
+ priv->format = (uintptr_t)of_device_get_match_data(dev);
+
+ priv->mtd = of_get_mtd_device_by_node(np);
+ if (IS_ERR(priv->mtd)) {
+ dev_err_probe(dev, PTR_ERR(priv->mtd), "Failed to get %pOF MTD\n", np);
+ return PTR_ERR(priv->mtd);
+ }
+
+ err = u_boot_env_parse(priv);
+ if (err)
+ return err;
+
+ config.dev = dev;
+ config.cells = priv->cells;
+ config.ncells = priv->ncells;
+ config.priv = priv;
+ config.size = priv->mtd->size;
+
+ return PTR_ERR_OR_ZERO(devm_nvmem_register(dev, &config));
+}
+
+static const struct of_device_id u_boot_env_of_match_table[] = {
+ { .compatible = "u-boot,env", .data = (void *)U_BOOT_FORMAT_SINGLE, },
+ { .compatible = "u-boot,env-redundant-bool", .data = (void *)U_BOOT_FORMAT_REDUNDANT, },
+ { .compatible = "u-boot,env-redundant-count", .data = (void *)U_BOOT_FORMAT_REDUNDANT, },
+ {},
+};
+
+static struct platform_driver u_boot_env_driver = {
+ .probe = u_boot_env_probe,
+ .driver = {
+ .name = "u_boot_env",
+ .of_match_table = u_boot_env_of_match_table,
+ },
+};
+module_platform_driver(u_boot_env_driver);
+
+MODULE_AUTHOR("Rafał Miłecki");
+MODULE_LICENSE("GPL");
+MODULE_DEVICE_TABLE(of, u_boot_env_of_match_table);

View File

@@ -4261,6 +4261,7 @@ CONFIG_NMI_LOG_BUF_SHIFT=13
# CONFIG_NVMEM_IMX_OCOTP is not set
# CONFIG_NVMEM_REBOOT_MODE is not set
# CONFIG_NVMEM_SYSFS is not set
# CONFIG_NVMEM_U_BOOT_ENV is not set
# CONFIG_NVME_FC is not set
# CONFIG_NVME_TARGET is not set
# CONFIG_NVME_TCP is not set

View File

@@ -4427,6 +4427,7 @@ CONFIG_NMI_LOG_BUF_SHIFT=13
# CONFIG_NVMEM_REBOOT_MODE is not set
# CONFIG_NVMEM_RMEM is not set
# CONFIG_NVMEM_SYSFS is not set
# CONFIG_NVMEM_U_BOOT_ENV is not set
# CONFIG_NVME_FC is not set
# CONFIG_NVME_TARGET is not set
# CONFIG_NVME_TCP is not set

View File

@@ -298,7 +298,7 @@
static inline uint32_t mtd_div_by_ws(uint64_t sz, struct mtd_info *mtd)
{
if (mtd->writesize_shift)
@@ -678,6 +696,13 @@ extern void __put_mtd_device(struct mtd_
@@ -679,6 +697,13 @@ extern struct mtd_info *of_get_mtd_devic
extern struct mtd_info *get_mtd_device_nm(const char *name);
extern void put_mtd_device(struct mtd_info *mtd);

View File

@@ -17,7 +17,7 @@ Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -1117,6 +1117,44 @@ out_unlock:
@@ -1145,6 +1145,44 @@ out_unlock:
}
EXPORT_SYMBOL_GPL(get_mtd_device_nm);
@@ -64,9 +64,9 @@ Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
mutex_lock(&mtd_table_mutex);
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -696,6 +696,8 @@ extern struct mtd_info *get_mtd_device(s
extern int __get_mtd_device(struct mtd_info *mtd);
@@ -697,6 +697,8 @@ extern int __get_mtd_device(struct mtd_i
extern void __put_mtd_device(struct mtd_info *mtd);
extern struct mtd_info *of_get_mtd_device_by_node(struct device_node *np);
extern struct mtd_info *get_mtd_device_nm(const char *name);
+extern struct mtd_info *get_mtd_device_by_node(
+ const struct device_node *of_node);

View File

@@ -288,7 +288,7 @@ Subject: [PATCH] mtd: mtdsplit support
static inline uint32_t mtd_div_by_ws(uint64_t sz, struct mtd_info *mtd)
{
if (mtd->writesize_shift)
@@ -685,6 +703,13 @@ extern void __put_mtd_device(struct mtd_
@@ -686,6 +704,13 @@ extern struct mtd_info *of_get_mtd_devic
extern struct mtd_info *get_mtd_device_nm(const char *name);
extern void put_mtd_device(struct mtd_info *mtd);

View File

@@ -17,7 +17,7 @@ Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -1274,6 +1274,44 @@ out_unlock:
@@ -1302,6 +1302,44 @@ out_unlock:
}
EXPORT_SYMBOL_GPL(get_mtd_device_nm);
@@ -64,9 +64,9 @@ Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
mutex_lock(&mtd_table_mutex);
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -703,6 +703,8 @@ extern struct mtd_info *get_mtd_device(s
extern int __get_mtd_device(struct mtd_info *mtd);
@@ -704,6 +704,8 @@ extern int __get_mtd_device(struct mtd_i
extern void __put_mtd_device(struct mtd_info *mtd);
extern struct mtd_info *of_get_mtd_device_by_node(struct device_node *np);
extern struct mtd_info *get_mtd_device_nm(const char *name);
+extern struct mtd_info *get_mtd_device_by_node(
+ const struct device_node *of_node);

View File

@@ -494,10 +494,8 @@
mediatek,ethsys = <&sysc>;
#ifdef DTS_LEGACY
pinctrl-names = "default";
pinctrl-0 = <&mdio_pins>, <&rgmii1_pins>, <&rgmii2_pins>;
#endif
gmac0: mac@0 {
compatible = "mediatek,eth-mac";

View File

@@ -105,6 +105,22 @@
nvmem-cell-names = "mac-address";
};
&gmac1 {
status = "okay";
label = "wan";
phy-handle = <&ethphy4>;
nvmem-cells = <&macaddr_factory_e00c>;
nvmem-cell-names = "mac-address";
mac-address-increment = <1>;
};
&mdio {
ethphy4: ethernet-phy@4 {
reg = <4>;
};
};
&switch0 {
ports {
port@0 {
@@ -126,14 +142,6 @@
status = "okay";
label = "lan4";
};
port@4 {
status = "okay";
label = "wan";
nvmem-cells = <&macaddr_factory_e00c>;
nvmem-cell-names = "mac-address";
mac-address-increment = <1>;
};
};
};

View File

@@ -110,6 +110,22 @@
nvmem-cell-names = "mac-address";
};
&gmac1 {
status = "okay";
label = "wan";
phy-handle = <&ethphy4>;
nvmem-cells = <&macaddr_factory_e000>;
nvmem-cell-names = "mac-address";
mac-address-increment = <1>;
};
&mdio {
ethphy4: ethernet-phy@4 {
reg = <4>;
};
};
&switch0 {
ports {
port@0 {
@@ -131,14 +147,6 @@
status = "okay";
label = "lan4";
};
port@4 {
status = "okay";
label = "wan";
nvmem-cells = <&macaddr_factory_e000>;
nvmem-cell-names = "mac-address";
mac-address-increment = <1>;
};
};
};

View File

@@ -7,6 +7,18 @@
model = "Amped Wireless ALLY-R1900K";
};
&gmac1 {
status = "okay";
label = "lan3";
phy-handle = <&ethphy4>;
};
&mdio {
ethphy4: ethernet-phy@4 {
reg = <4>;
};
};
&switch0 {
ports {
port@1 {
@@ -23,10 +35,5 @@
status = "okay";
label = "lan2";
};
port@4 {
status = "okay";
label = "lan3";
};
};
};

View File

@@ -171,6 +171,21 @@
nvmem-cell-names = "mac-address";
};
&gmac1 {
status = "okay";
label = "wan";
phy-handle = <&ethphy4>;
nvmem-cells = <&macaddr_factory_fff0>;
nvmem-cell-names = "mac-address";
};
&mdio {
ethphy4: ethernet-phy@4 {
reg = <4>;
};
};
&switch0 {
ports {
port@2 {
@@ -182,11 +197,6 @@
status = "okay";
label = "lan1";
};
port@4 {
status = "okay";
label = "wan";
};
};
};

View File

@@ -7,19 +7,27 @@
model = "AsiaRF AP7621-001";
};
&gmac1 {
status = "okay";
label = "wan";
phy-handle = <&ethphy4>;
nvmem-cells = <&macaddr_factory_e000>;
nvmem-cell-names = "mac-address";
mac-address-increment = <1>;
};
&mdio {
ethphy4: ethernet-phy@4 {
reg = <4>;
};
};
&switch0 {
ports {
port@0 {
status = "okay";
label = "lan";
};
port@4 {
status = "okay";
label = "wan";
nvmem-cells = <&macaddr_factory_e000>;
nvmem-cell-names = "mac-address";
mac-address-increment = <1>;
};
};
};

View File

@@ -7,16 +7,24 @@
model = "AsiaRF AP7621-NV1";
};
&gmac1 {
status = "okay";
label = "wan";
phy-handle = <&ethphy0>;
nvmem-cells = <&macaddr_factory_e000>;
nvmem-cell-names = "mac-address";
mac-address-increment = <1>;
};
&mdio {
ethphy0: ethernet-phy@0 {
reg = <0>;
};
};
&switch0 {
ports {
port@0 {
status = "okay";
label = "wan";
nvmem-cells = <&macaddr_factory_e000>;
nvmem-cell-names = "mac-address";
mac-address-increment = <1>;
};
port@2 {
status = "okay";
label = "lan1";

View File

@@ -134,15 +134,23 @@
nvmem-cell-names = "mac-address";
};
&gmac1 {
status = "okay";
label = "wan";
phy-handle = <&ethphy0>;
nvmem-cells = <&macaddr_factory_e006>;
nvmem-cell-names = "mac-address";
};
&mdio {
ethphy0: ethernet-phy@0 {
reg = <0>;
};
};
&switch0 {
ports {
port@0 {
status = "okay";
label = "wan";
nvmem-cells = <&macaddr_factory_e006>;
nvmem-cell-names = "mac-address";
};
port@1 {
status = "okay";
label = "lan1";

View File

@@ -135,13 +135,23 @@
nvmem-cell-names = "mac-address";
};
&gmac1 {
status = "okay";
label = "wan";
phy-handle = <&ethphy0>;
nvmem-cells = <&macaddr_factory_e000>;
nvmem-cell-names = "mac-address";
};
&mdio {
ethphy0: ethernet-phy@0 {
reg = <0>;
};
};
&switch0 {
ports {
port@0 {
status = "okay";
label = "wan";
};
port@1 {
status = "okay";
label = "lan1";

View File

@@ -126,13 +126,23 @@
nvmem-cell-names = "mac-address";
};
&gmac1 {
status = "okay";
label = "wan";
phy-handle = <&ethphy0>;
nvmem-cells = <&macaddr_factory_4>;
nvmem-cell-names = "mac-address";
};
&mdio {
ethphy0: ethernet-phy@0 {
reg = <0>;
};
};
&switch0 {
ports {
port@0 {
status = "okay";
label = "wan";
};
port@1 {
status = "okay";
label = "lan1";

View File

@@ -10,7 +10,7 @@
model = "ASUS RT-N56U B1";
aliases {
label-mac-device = &wan;
label-mac-device = &gmac1;
led-boot = &led_power;
led-failsafe = &led_power;
led-running = &led_power;
@@ -144,6 +144,21 @@
nvmem-cell-names = "mac-address";
};
&gmac1 {
status = "okay";
label = "wan";
phy-handle = <&ethphy4>;
nvmem-cells = <&macaddr_factory_4>;
nvmem-cell-names = "mac-address";
};
&mdio {
ethphy4: ethernet-phy@4 {
reg = <4>;
};
};
&switch0 {
ports {
port@0 {
@@ -165,13 +180,6 @@
status = "okay";
label = "lan1";
};
wan: port@4 {
status = "okay";
label = "wan";
nvmem-cells = <&macaddr_factory_4>;
nvmem-cell-names = "mac-address";
};
};
};

View File

@@ -202,17 +202,24 @@
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@0 {
status = "okay";
label = "wan";
nvmem-cells = <&macaddr_factory_21000>;
nvmem-cell-names = "mac-address";
mac-address-increment = <(1)>;
};
port@1 {
status = "okay";
label = "lan1";

View File

@@ -202,17 +202,24 @@
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@0 {
status = "okay";
label = "wan";
nvmem-cells = <&macaddr_factory_21000>;
nvmem-cell-names = "mac-address";
mac-address-increment = <(1)>;
};
port@1 {
status = "okay";
label = "lan1";

View File

@@ -163,9 +163,13 @@
};
};
&ethernet {
pinctrl-0 = <&mdio_pins>, <&rgmii1_pins>;
};
&state_default {
gpio {
groups = "jtag", "uart2", "uart3", "wdt";
groups = "jtag", "uart2", "uart3", "wdt", "rgmii2";
function = "gpio";
};
};

View File

@@ -152,8 +152,16 @@
};
};
&ethernet {
pinctrl-0 = <&mdio_pins>, <&rgmii1_pins>;
&gmac1 {
status = "okay";
label = "wan";
phy-handle = <&ethphy4>;
};
&mdio {
ethphy4: ethernet-phy@4 {
reg = <4>;
};
};
&switch0 {
@@ -177,17 +185,12 @@
status = "okay";
label = "lan4";
};
port@4 {
status = "okay";
label = "wan";
};
};
};
&state_default {
gpio {
groups = "i2c", "uart2", "uart3", "rgmii2", "sdhci";
groups = "i2c", "uart2", "uart3", "sdhci";
function = "gpio";
};
};

View File

@@ -169,13 +169,24 @@
mac-address-increment = <(-1)>;
};
&gmac1 {
status = "okay";
label = "wan";
phy-handle = <&ethphy0>;
nvmem-cells = <&macaddr_factory_4>;
nvmem-cell-names = "mac-address";
mac-address-increment = <(-1)>;
};
&mdio {
ethphy0: ethernet-phy@0 {
reg = <0>;
};
};
&switch0 {
ports {
port@0 {
status = "okay";
label = "wan";
};
port@1 {
status = "okay";
label = "lan4";

View File

@@ -149,7 +149,7 @@
&state_default {
gpio {
groups = "i2c", "uart2", "uart3", "rgmii2", "sdhci";
groups = "i2c", "uart2", "uart3", "sdhci";
function = "gpio";
};
};
@@ -172,15 +172,26 @@
};
};
&ethernet {
pinctrl-0 = <&mdio_pins>, <&rgmii1_pins>;
};
&gmac0 {
nvmem-cells = <&macaddr_factory_4>;
nvmem-cell-names = "mac-address";
};
&gmac1 {
status = "okay";
label = "wan";
phy-handle = <&ethphy4>;
nvmem-cells = <&macaddr_factory_4>;
nvmem-cell-names = "mac-address";
};
&mdio {
ethphy4: ethernet-phy@4 {
reg = <4>;
};
};
&switch0 {
ports {
port@0 {
@@ -202,11 +213,6 @@
status = "okay";
label = "lan4";
};
port@4 {
status = "okay";
label = "wan";
};
};
};

View File

@@ -159,6 +159,22 @@
nvmem-cell-names = "mac-address";
};
&gmac1 {
status = "okay";
label = "wan";
phy-handle = <&ethphy4>;
nvmem-cells = <&macaddr_bdinfo_de00>;
nvmem-cell-names = "mac-address";
mac-address-increment = <1>;
};
&mdio {
ethphy4: ethernet-phy@4 {
reg = <4>;
};
};
&switch0 {
ports {
port@0 {
@@ -180,14 +196,6 @@
status = "okay";
label = "lan1";
};
port@4 {
status = "okay";
label = "wan";
nvmem-cells = <&macaddr_bdinfo_de00>;
nvmem-cell-names = "mac-address";
mac-address-increment = <1>;
};
};
};

View File

@@ -169,6 +169,22 @@
};
};
&gmac1 {
status = "okay";
label = "wan";
phy-handle = <&ethphy4>;
nvmem-cells = <&macaddr_bdinfo_de00>;
nvmem-cell-names = "mac-address";
mac-address-increment = <1>;
};
&mdio {
ethphy4: ethernet-phy@4 {
reg = <4>;
};
};
&switch0 {
ports {
port@0 {
@@ -190,15 +206,6 @@
status = "okay";
label = "lan4";
};
port@4 {
status = "okay";
label = "wan";
nvmem-cells = <&macaddr_bdinfo_de00>;
nvmem-cell-names = "mac-address";
mac-address-increment = <1>;
};
};
};

View File

@@ -128,6 +128,22 @@
nvmem-cell-names = "mac-address";
};
&gmac1 {
status = "okay";
label = "wan";
phy-handle = <&ethphy4>;
nvmem-cells = <&macaddr_bdinfo_de00>;
nvmem-cell-names = "mac-address";
mac-address-increment = <1>;
};
&mdio {
ethphy4: ethernet-phy@4 {
reg = <4>;
};
};
&switch0 {
ports {
port@0 {
@@ -149,14 +165,6 @@
status = "okay";
label = "lan4";
};
port@4 {
status = "okay";
label = "wan";
nvmem-cells = <&macaddr_bdinfo_de00>;
nvmem-cell-names = "mac-address";
mac-address-increment = <1>;
};
};
};

View File

@@ -169,6 +169,21 @@
nvmem-cell-names = "mac-address";
};
&gmac1 {
status = "okay";
label = "wan";
phy-handle = <&ethphy4>;
nvmem-cells = <&macaddr_factory_e006>;
nvmem-cell-names = "mac-address";
};
&mdio {
ethphy4: ethernet-phy@4 {
reg = <4>;
};
};
&switch0 {
ports {
port@0 {
@@ -190,13 +205,6 @@
status = "okay";
label = "lan1";
};
port@4 {
status = "okay";
label = "wan";
nvmem-cells = <&macaddr_factory_e006>;
nvmem-cell-names = "mac-address";
};
};
};

View File

@@ -12,7 +12,7 @@
model = "D-Link DIR-853 R1";
aliases {
label-mac-device = &wan;
label-mac-device = &gmac1;
led-boot = &led_power_orange;
led-failsafe = &led_power_blue;
@@ -110,6 +110,22 @@
mac-address-increment = <(-1)>;
};
&gmac1 {
status = "okay";
label = "wan";
phy-handle = <&ethphy4>;
nvmem-cells = <&macaddr_factory_4>;
nvmem-cell-names = "mac-address";
mac-address-increment = <(-2)>;
};
&mdio {
ethphy4: ethernet-phy@4 {
reg = <4>;
};
};
&switch0 {
ports {
port@0 {
@@ -131,14 +147,6 @@
status = "okay";
label = "lan1";
};
wan: port@4 {
status = "okay";
label = "wan";
nvmem-cells = <&macaddr_factory_4>;
nvmem-cell-names = "mac-address";
mac-address-increment = <(-2)>;
};
};
};

View File

@@ -114,13 +114,23 @@
nvmem-cell-names = "mac-address";
};
&gmac1 {
status = "okay";
label = "wan";
phy-handle = <&ethphy0>;
nvmem-cells = <&macaddr_radio_4>;
nvmem-cell-names = "mac-address";
};
&mdio {
ethphy0: ethernet-phy@0 {
reg = <0>;
};
};
&switch0 {
ports {
port@0 {
status = "okay";
label = "wan";
};
port@1 {
status = "okay";
label = "lan4";

View File

@@ -17,7 +17,7 @@
nvmem-cell-names = "mac-address";
};
&wan {
&gmac1 {
nvmem-cells = <&macaddr_factory_e006>;
nvmem-cell-names = "mac-address";
};

View File

@@ -17,7 +17,7 @@
nvmem-cell-names = "mac-address";
};
&wan {
&gmac1 {
nvmem-cells = <&macaddr_factory_e006>;
nvmem-cell-names = "mac-address";
};

View File

@@ -17,7 +17,7 @@
nvmem-cell-names = "mac-address";
};
&wan {
&gmac1 {
nvmem-cells = <&macaddr_factory_e006>;
nvmem-cell-names = "mac-address";
};

View File

@@ -33,7 +33,7 @@
nvmem-cell-names = "mac-address";
};
&wan {
&gmac1 {
nvmem-cells = <&macaddr_factory_e006>;
nvmem-cell-names = "mac-address";
};

View File

@@ -33,7 +33,7 @@
nvmem-cell-names = "mac-address";
};
&wan {
&gmac1 {
nvmem-cells = <&macaddr_factory_e006>;
nvmem-cell-names = "mac-address";
};

View File

@@ -90,6 +90,18 @@
};
};
&gmac1 {
status = "okay";
label = "wan";
phy-handle = <&ethphy4>;
};
&mdio {
ethphy4: ethernet-phy@4 {
reg = <4>;
};
};
&switch0 {
ports {
port@0 {
@@ -111,11 +123,6 @@
status = "okay";
label = "lan1";
};
wan: port@4 {
status = "okay";
label = "wan";
};
};
};

View File

@@ -154,6 +154,21 @@
nvmem-cell-names = "mac-address";
};
&gmac1 {
status = "okay";
label = "wan";
phy-handle = <&ethphy4>;
nvmem-cells = <&macaddr_factory_e006>;
nvmem-cell-names = "mac-address";
};
&mdio {
ethphy4: ethernet-phy@4 {
reg = <4>;
};
};
&switch0 {
ports {
port@0 {
@@ -175,13 +190,6 @@
status = "okay";
label = "lan1";
};
port@4 {
status = "okay";
label = "wan";
nvmem-cells = <&macaddr_factory_e006>;
nvmem-cell-names = "mac-address";
};
};
};

View File

@@ -122,13 +122,23 @@
nvmem-cell-names = "mac-address";
};
&gmac1 {
status = "okay";
label = "wan";
phy-handle = <&ethphy0>;
nvmem-cells = <&macaddr_factory_4>;
nvmem-cell-names = "mac-address";
};
&mdio {
ethphy0: ethernet-phy@0 {
reg = <0>;
};
};
&switch0 {
ports {
port@0 {
status = "okay";
label = "wan";
};
port@1 {
status = "okay";
label = "lan4";

View File

@@ -71,15 +71,23 @@
nvmem-cell-names = "mac-address";
};
&gmac1 {
status = "okay";
label = "wan";
phy-handle = <&ethphy0>;
nvmem-cells = <&macaddr_factory_e006>;
nvmem-cell-names = "mac-address";
};
&mdio {
ethphy0: ethernet-phy@0 {
reg = <0>;
};
};
&switch0 {
ports {
port@0 {
status = "okay";
label = "wan";
nvmem-cells = <&macaddr_factory_e006>;
nvmem-cell-names = "mac-address";
};
port@1 {
status = "okay";
label = "lan4";

View File

@@ -12,7 +12,7 @@
nvmem-cell-names = "mac-address";
};
&wan {
&gmac1 {
nvmem-cells = <&macaddr_factory_fffa>;
nvmem-cell-names = "mac-address";
};

View File

@@ -12,7 +12,7 @@
nvmem-cell-names = "mac-address";
};
&wan {
&gmac1 {
nvmem-cells = <&macaddr_factory_e006>;
nvmem-cell-names = "mac-address";
};

View File

@@ -44,7 +44,7 @@
nvmem-cell-names = "mac-address";
};
&wan {
&gmac1 {
nvmem-cells = <&macaddr_factory_e006>;
nvmem-cell-names = "mac-address";
};

View File

@@ -44,7 +44,7 @@
nvmem-cell-names = "mac-address";
};
&wan {
&gmac1 {
nvmem-cells = <&macaddr_factory_e006>;
nvmem-cell-names = "mac-address";
};

View File

@@ -44,7 +44,7 @@
nvmem-cell-names = "mac-address";
};
&wan {
&gmac1 {
nvmem-cells = <&macaddr_factory_e006>;
nvmem-cell-names = "mac-address";
};

View File

@@ -44,7 +44,7 @@
nvmem-cell-names = "mac-address";
};
&wan {
&gmac1 {
nvmem-cells = <&macaddr_factory_e006>;
nvmem-cell-names = "mac-address";
};

View File

@@ -136,13 +136,20 @@
};
};
&gmac1 {
status = "okay";
label = "wan";
phy-handle = <&ethphy0>;
};
&mdio {
ethphy0: ethernet-phy@0 {
reg = <0>;
};
};
&switch0 {
ports {
port@0 {
status = "okay";
label = "wan";
};
port@1 {
status = "okay";
label = "lan4";

View File

@@ -44,7 +44,7 @@
nvmem-cell-names = "mac-address";
};
&wan {
&gmac1 {
nvmem-cells = <&macaddr_factory_fffa>;
nvmem-cell-names = "mac-address";
};

View File

@@ -42,7 +42,7 @@
nvmem-cell-names = "mac-address";
};
&wan {
&gmac1 {
nvmem-cells = <&macaddr_factory_e006>;
nvmem-cell-names = "mac-address";
};

View File

@@ -44,7 +44,7 @@
nvmem-cell-names = "mac-address";
};
&wan {
&gmac1 {
nvmem-cells = <&macaddr_factory_e006>;
nvmem-cell-names = "mac-address";
};

View File

@@ -11,7 +11,7 @@
led-failsafe = &led_power_green;
led-running = &led_power_green;
led-upgrade = &led_power_green;
label-mac-device = &wan;
label-mac-device = &gmac1;
};
leds: leds {
@@ -83,13 +83,20 @@
};
};
&gmac1 {
status = "okay";
label = "wan";
phy-handle = <&ethphy0>;
};
&mdio {
ethphy0: ethernet-phy@0 {
reg = <0>;
};
};
&switch0 {
ports {
wan: port@0 {
status = "okay";
label = "wan";
};
port@1 {
status = "okay";
label = "lan4";

View File

@@ -111,6 +111,22 @@
nvmem-cell-names = "mac-address";
};
&gmac1 {
status = "okay";
label = "wan";
phy-handle = <&ethphy4>;
nvmem-cells = <&macaddr_factory_e000>;
nvmem-cell-names = "mac-address";
mac-address-increment = <1>;
};
&mdio {
ethphy4: ethernet-phy@4 {
reg = <4>;
};
};
&switch0 {
ports {
port@0 {
@@ -127,14 +143,6 @@
status = "okay";
label = "lan3";
};
port@4 {
status = "okay";
label = "wan";
nvmem-cells = <&macaddr_factory_e000>;
nvmem-cell-names = "mac-address";
mac-address-increment = <1>;
};
};
};

View File

@@ -14,7 +14,7 @@
led-failsafe = &led_run;
led-running = &led_run;
led-upgrade = &led_run;
label-mac-device = &wan;
label-mac-device = &gmac1;
};
chosen {
@@ -121,6 +121,21 @@
mac-address-increment = <1>;
};
&gmac1 {
status = "okay";
label = "wan";
phy-handle = <&ethphy4>;
nvmem-cells = <&macaddr_factory_4000>;
nvmem-cell-names = "mac-address";
};
&mdio {
ethphy4: ethernet-phy@4 {
reg = <4>;
};
};
&switch0 {
ports {
port@2 {
@@ -132,13 +147,6 @@
status = "okay";
label = "lan2";
};
wan: port@4 {
status = "okay";
label = "wan";
nvmem-cells = <&macaddr_factory_4000>;
nvmem-cell-names = "mac-address";
};
};
};

View File

@@ -8,10 +8,10 @@
model = "GB-PC1";
aliases {
led-boot = &led_status;
led-failsafe = &led_status;
led-running = &led_status;
led-upgrade = &led_status;
led-boot = &led_system;
led-failsafe = &led_system;
led-running = &led_system;
led-upgrade = &led_system;
};
keys {
@@ -27,24 +27,26 @@
leds {
compatible = "gpio-leds";
system {
label = "green:system";
ethblack_act {
label = "green:ethblack_act";
gpios = <&gpio 3 GPIO_ACTIVE_LOW>;
};
ethblue_act {
label = "green:ethblue_act";
gpios = <&gpio 4 GPIO_ACTIVE_LOW>;
};
power {
label = "green:power";
gpios = <&gpio 6 GPIO_ACTIVE_LOW>;
linux,default-trigger = "default-on";
};
led_status: status {
label = "green:status";
led_system: system {
label = "green:system";
gpios = <&gpio 8 GPIO_ACTIVE_LOW>;
};
lan1 {
label = "green:lan1";
gpios = <&gpio 24 GPIO_ACTIVE_LOW>;
};
lan2 {
label = "green:lan2";
gpios = <&gpio 25 GPIO_ACTIVE_LOW>;
linux,default-trigger = "disk-activity";
};
};
};
@@ -59,9 +61,8 @@
flash@0 {
compatible = "jedec,spi-nor";
reg = <0>;
spi-max-frequency = <80000000>;
spi-max-frequency = <50000000>;
broken-flash-reset;
m25p,fast-read;
partitions {
compatible = "fixed-partitions";
@@ -99,32 +100,38 @@
status = "okay";
};
&ethernet {
pinctrl-0 = <&mdio_pins>, <&rgmii1_pins>;
};
&gmac0 {
nvmem-cells = <&macaddr_factory_e000>;
nvmem-cell-names = "mac-address";
};
&gmac1 {
status = "okay";
label = "ethblue";
phy-handle = <&ethphy4>;
nvmem-cells = <&macaddr_factory_e000>;
nvmem-cell-names = "mac-address";
};
&mdio {
ethphy4: ethernet-phy@4 {
reg = <4>;
};
};
&switch0 {
ports {
port@0 {
status = "okay";
label = "lan1";
};
port@4 {
status = "okay";
label = "lan2";
label = "ethblack";
};
};
};
&state_default {
gpio {
groups = "jtag", "rgmii2", "uart3", "wdt";
groups = "jtag", "uart3", "wdt";
function = "gpio";
};
};

View File

@@ -8,10 +8,10 @@
model = "GB-PC2";
aliases {
led-boot = &led_status;
led-failsafe = &led_status;
led-running = &led_status;
led-upgrade = &led_status;
led-boot = &led_system;
led-failsafe = &led_system;
led-running = &led_system;
led-upgrade = &led_system;
};
keys {
@@ -27,34 +27,26 @@
leds {
compatible = "gpio-leds";
system {
label = "green:system";
ethblack_act {
label = "green:ethblack_act";
gpios = <&gpio 3 GPIO_ACTIVE_LOW>;
};
ethblue_act {
label = "green:ethblue_act";
gpios = <&gpio 4 GPIO_ACTIVE_LOW>;
};
power {
label = "green:power";
gpios = <&gpio 6 GPIO_ACTIVE_LOW>;
linux,default-trigger = "default-on";
};
led_status: status {
label = "green:status";
led_system: system {
label = "green:system";
gpios = <&gpio 8 GPIO_ACTIVE_LOW>;
};
lan1 {
label = "green:lan1";
gpios = <&gpio 24 GPIO_ACTIVE_LOW>;
};
lan2 {
label = "green:lan2";
gpios = <&gpio 25 GPIO_ACTIVE_LOW>;
};
lan3-yellow {
label = "yellow:lan3";
gpios = <&gpio 13 GPIO_ACTIVE_LOW>;
};
lan3-green {
label = "green:lan3";
gpios = <&gpio 15 GPIO_ACTIVE_LOW>;
linux,default-trigger = "disk-activity";
};
};
};
@@ -69,9 +61,8 @@
flash@0 {
compatible = "jedec,spi-nor";
reg = <0>;
spi-max-frequency = <80000000>;
spi-max-frequency = <50000000>;
broken-flash-reset;
m25p,fast-read;
partitions {
compatible = "fixed-partitions";
@@ -109,32 +100,44 @@
status = "okay";
};
&ethernet {
pinctrl-0 = <&mdio_pins>, <&rgmii1_pins>;
};
&gmac0 {
nvmem-cells = <&macaddr_factory_e000>;
nvmem-cell-names = "mac-address";
};
&gmac1 {
status = "okay";
label = "ethyellow";
phy-handle = <&ethphy5>;
nvmem-cells = <&macaddr_factory_e000>;
nvmem-cell-names = "mac-address";
};
&mdio {
ethphy5: ethernet-phy@5 {
reg = <5>;
phy-mode = "rgmii-rxid";
};
};
&switch0 {
ports {
port@0 {
status = "okay";
label = "lan1";
label = "ethblack";
};
port@4 {
status = "okay";
label = "lan2";
label = "ethblue";
};
};
};
&state_default {
gpio {
groups = "jtag", "rgmii2", "uart3", "wdt";
groups = "jtag", "uart3", "wdt";
function = "gpio";
};
};

View File

@@ -61,6 +61,18 @@
};
};
&gmac1 {
status = "okay";
label = "wan";
phy-handle = <&ethphy4>;
};
&mdio {
ethphy4: ethernet-phy@4 {
reg = <4>;
};
};
&switch0 {
ports {
port@0 {
@@ -82,11 +94,6 @@
status = "okay";
label = "lan4";
};
port@4 {
status = "okay";
label = "wan";
};
};
};

View File

@@ -129,6 +129,18 @@
};
};
&gmac1 {
status = "okay";
label = "wan";
phy-handle = <&ethphy4>;
};
&mdio {
ethphy4: ethernet-phy@4 {
reg = <4>;
};
};
&switch0 {
ports {
port@1 {
@@ -145,11 +157,6 @@
status = "okay";
label = "lan3";
};
port@4 {
status = "okay";
label = "wan";
};
};
};

View File

@@ -15,7 +15,7 @@
led-failsafe = &led_power;
led-running = &led_power;
led-upgrade = &led_power;
label-mac-device = &wan;
label-mac-device = &gmac1;
};
gpio-export {
@@ -132,15 +132,23 @@
nvmem-cell-names = "mac-address";
};
&gmac1 {
status = "okay";
label = "wan";
phy-handle = <&ethphy0>;
nvmem-cells = <&macaddr_factory_1000d>;
nvmem-cell-names = "mac-address";
};
&mdio {
ethphy0: ethernet-phy@0 {
reg = <0>;
};
};
&switch0 {
ports {
wan: port@0 {
status = "okay";
label = "wan";
nvmem-cells = <&macaddr_factory_1000d>;
nvmem-cell-names = "mac-address";
};
port@1 {
status = "okay";
label = "lan";

View File

@@ -132,16 +132,24 @@
nvmem-cell-names = "mac-address";
};
&gmac1 {
status = "okay";
label = "wan";
phy-handle = <&ethphy0>;
nvmem-cells = <&macaddr_factory_4>;
nvmem-cell-names = "mac-address";
mac-address-increment = <1>;
};
&mdio {
ethphy0: ethernet-phy@0 {
reg = <0>;
};
};
&switch0 {
ports {
port@0 {
status = "okay";
label = "wan";
nvmem-cells = <&macaddr_factory_4>;
nvmem-cell-names = "mac-address";
mac-address-increment = <1>;
};
port@1 {
status = "okay";
label = "lan4";

View File

@@ -14,7 +14,7 @@
led-failsafe = &led_power;
led-running = &led_power;
led-upgrade = &led_power;
label-mac-device = &wan;
label-mac-device = &gmac1;
};
leds {
@@ -131,15 +131,23 @@
nvmem-cell-names = "mac-address";
};
&gmac1 {
status = "okay";
label = "wan";
phy-handle = <&ethphy0>;
nvmem-cells = <&macaddr_factory_1e006>;
nvmem-cell-names = "mac-address";
};
&mdio {
ethphy0: ethernet-phy@0 {
reg = <0>;
};
};
&switch0 {
ports {
wan: port@0 {
status = "okay";
label = "wan";
nvmem-cells = <&macaddr_factory_1e006>;
nvmem-cell-names = "mac-address";
};
port@1 {
status = "okay";
label = "lan4";

View File

@@ -132,16 +132,24 @@
nvmem-cell-names = "mac-address";
};
&gmac1 {
status = "okay";
label = "wan";
phy-handle = <&ethphy0>;
nvmem-cells = <&macaddr_factory_4>;
nvmem-cell-names = "mac-address";
mac-address-increment = <1>;
};
&mdio {
ethphy0: ethernet-phy@0 {
reg = <0>;
};
};
&switch0 {
ports {
port@0 {
status = "okay";
label = "wan";
nvmem-cells = <&macaddr_factory_4>;
nvmem-cell-names = "mac-address";
mac-address-increment = <1>;
};
port@1 {
status = "okay";
label = "lan4";

View File

@@ -11,7 +11,7 @@
led-failsafe = &led_power;
led-running = &led_power;
led-upgrade = &led_power;
label-mac-device = &wan;
label-mac-device = &gmac1;
};
leds {
@@ -122,15 +122,23 @@
nvmem-cell-names = "mac-address";
};
&gmac1 {
status = "okay";
label = "wan";
phy-handle = <&ethphy0>;
nvmem-cells = <&macaddr_factory_e006>;
nvmem-cell-names = "mac-address";
};
&mdio {
ethphy0: ethernet-phy@0 {
reg = <0>;
};
};
&switch0 {
ports {
wan: port@0 {
status = "okay";
label = "wan";
nvmem-cells = <&macaddr_factory_e006>;
nvmem-cell-names = "mac-address";
};
port@1 {
status = "okay";
label = "lan4";

View File

@@ -124,13 +124,23 @@
nvmem-cell-names = "mac-address";
};
&gmac1 {
status = "okay";
label = "wan";
phy-handle = <&ethphy0>;
nvmem-cells = <&macaddr_factory_4>;
nvmem-cell-names = "mac-address";
};
&mdio {
ethphy0: ethernet-phy@0 {
reg = <0>;
};
};
&switch0 {
ports {
port@0 {
status = "okay";
label = "wan";
};
port@1 {
status = "okay";
label = "lan4";

Some files were not shown because too many files have changed in this diff Show More