Add support for AVM FritzBox 4040

Since the ipq40xx ethernet driver has built-in handling for a few vlan
ids, this target requires a driver patch that disables this
functionality, so all vlan ids can be handled by the linux kernel.

Signed-off-by: Fabian Bläse <fabian@blaese.de>
Reviewed-by: Christian Dresel <freifunk@dresel.systems>
Tested-by: Fabian Bläse <fabian@blaese.de>
This commit is contained in:
Fabian Bläse 2021-08-06 10:38:18 +02:00
parent e07f6121cc
commit cf0290ad82
5 changed files with 171 additions and 0 deletions

6
bsp/ipq40xx-generic.bsp Normal file
View File

@ -0,0 +1,6 @@
chipset=ipq40xx
subtarget=generic
images=(
"openwrt-${chipset}-${subtarget}-avm_fritzbox-4040-squashfs-*"
)

View File

@ -0,0 +1,25 @@
# Generated using "./buildscript config openwrt".
# Do no edit manually
#
CONFIG_TARGET_ipq40xx=y
CONFIG_TARGET_ipq40xx_generic=y
CONFIG_TARGET_MULTI_PROFILE=y
CONFIG_TARGET_DEVICE_ipq40xx_generic_DEVICE_avm_fritzbox-4040=y
CONFIG_TARGET_DEVICE_PACKAGES_ipq40xx_generic_DEVICE_avm_fritzbox-4040="-kmod-ath10k-ct kmod-ath10k -ath10k-firmware-qca4019-ct ath10k-firmware-qca4019"
CONFIG_BUSYBOX_CUSTOM=y
CONFIG_TARGET_PER_DEVICE_ROOTFS=y
# CONFIG_BUSYBOX_CONFIG_BRCTL is not set
# CONFIG_BUSYBOX_CONFIG_CROND is not set
# CONFIG_BUSYBOX_CONFIG_CRONTAB is not set
# CONFIG_BUSYBOX_CONFIG_FEATURE_FAST_TOP is not set
# CONFIG_BUSYBOX_CONFIG_FEATURE_NTPD_SERVER is not set
CONFIG_CLEAN_IPKG=y
# CONFIG_DROPBEAR_CURVE25519 is not set
# CONFIG_PACKAGE_ALFRED_VIS is not set
CONFIG_PACKAGE_ath10k-firmware-qca4019=m
CONFIG_PACKAGE_ath10k-firmware-qca4019-ct=m
CONFIG_PACKAGE_kmod-ath10k=m
CONFIG_PACKAGE_kmod-ath10k-ct=m
CONFIG_PACKAGE_opkg=m
CONFIG_STRIP_KERNEL_EXPORTS=y
CONFIG_PACKAGE_kmod-hwmon-core=y

View File

@ -0,0 +1,132 @@
From: =?UTF-8?q?Fabian=20Bl=C3=A4se?= <fabian@blaese.de>
Date: Sat, 7 Aug 2021 00:40:34 +0200
Subject: [PATCH] Disable ipq40xx lan/wan separation
While the ipq40xx only has a single MDIO connection to the switch chip,
the ipq40xx essedma ethernet driver configures two gmac interfaces,
which are seperated into WAN and LAN ports using vlan cid at driver
level. Linux is not aware of these vlan tags.
However, this configuration does interfere with the vlan ids we use in
our firmware. Therefore, this feature is disabled by setting the default
vlan id for all gmacs to 0, changing the port mask so all physical ports
are connected to the first gmac, and reducing the amount of configured
gmacs to one. The definition of the second gmac is kept, because it is
referenced by some devices. The default configuration of the switch chip
is removed accordingly.
These changes are currently only done with the FritzBox 4040 in mind.
---
.../linux/ipq40xx/base-files/etc/board.d/01_leds | 2 +-
.../ipq40xx/base-files/etc/board.d/02_network | 3 +--
.../drivers/net/ethernet/qualcomm/essedma/edma.h | 16 ++++++++--------
.../linux/ipq40xx/files/drivers/net/phy/ar40xx.c | 2 ++
...1-dts-ipq4019-add-ethernet-essedma-node.patch | 6 +++---
5 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/target/linux/ipq40xx/base-files/etc/board.d/01_leds b/target/linux/ipq40xx/base-files/etc/board.d/01_leds
index ac11655904..147e159ea1 100755
--- a/target/linux/ipq40xx/base-files/etc/board.d/01_leds
+++ b/target/linux/ipq40xx/base-files/etc/board.d/01_leds
@@ -19,7 +19,7 @@ asus,rt-ac58u)
;;
avm,fritzbox-4040)
ucidef_set_led_wlan "wlan" "WLAN" "green:wlan" "phy0tpt" "phy1tpt"
- ucidef_set_led_netdev "wan" "WAN" "green:wan" "eth1"
+ ucidef_set_led_switch "wan" "WAN" "green:wan" "switch0" "0x20"
ucidef_set_led_switch "lan" "LAN" "green:lan" "switch0" "0x1e"
;;
avm,fritzbox-7530 |\
diff --git a/target/linux/ipq40xx/base-files/etc/board.d/02_network b/target/linux/ipq40xx/base-files/etc/board.d/02_network
index 1d4c78833a..ea2cc60186 100755
--- a/target/linux/ipq40xx/base-files/etc/board.d/02_network
+++ b/target/linux/ipq40xx/base-files/etc/board.d/02_network
@@ -59,9 +59,8 @@ ipq40xx_setup_interfaces()
linksys,ea6350v3|\
linksys,ea8300|\
linksys,mr8300)
- ucidef_set_interfaces_lan_wan "eth0" "eth1"
ucidef_add_switch "switch0" \
- "0u@eth0" "1:lan" "2:lan" "3:lan" "4:lan"
+ "0@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan"
;;
avm,fritzbox-7530)
ucidef_add_switch "switch0" \
diff --git a/target/linux/ipq40xx/files/drivers/net/ethernet/qualcomm/essedma/edma.h b/target/linux/ipq40xx/files/drivers/net/ethernet/qualcomm/essedma/edma.h
index 015e5f5026..daa60639d1 100644
--- a/target/linux/ipq40xx/files/drivers/net/ethernet/qualcomm/essedma/edma.h
+++ b/target/linux/ipq40xx/files/drivers/net/ethernet/qualcomm/essedma/edma.h
@@ -57,14 +57,14 @@
#define EDMA_LAN 1
/* VLAN tag */
-#define EDMA_LAN_DEFAULT_VLAN 1
-#define EDMA_WAN_DEFAULT_VLAN 2
-
-#define EDMA_DEFAULT_GROUP1_VLAN 1
-#define EDMA_DEFAULT_GROUP2_VLAN 2
-#define EDMA_DEFAULT_GROUP3_VLAN 3
-#define EDMA_DEFAULT_GROUP4_VLAN 4
-#define EDMA_DEFAULT_GROUP5_VLAN 5
+#define EDMA_LAN_DEFAULT_VLAN 0
+#define EDMA_WAN_DEFAULT_VLAN 0
+
+#define EDMA_DEFAULT_GROUP1_VLAN 0
+#define EDMA_DEFAULT_GROUP2_VLAN 0
+#define EDMA_DEFAULT_GROUP3_VLAN 0
+#define EDMA_DEFAULT_GROUP4_VLAN 0
+#define EDMA_DEFAULT_GROUP5_VLAN 0
/* Queues exposed to linux kernel */
#define EDMA_NETDEV_TX_QUEUE 4
diff --git a/target/linux/ipq40xx/files/drivers/net/phy/ar40xx.c b/target/linux/ipq40xx/files/drivers/net/phy/ar40xx.c
index c35ba2799f..0517e4f29e 100644
--- a/target/linux/ipq40xx/files/drivers/net/phy/ar40xx.c
+++ b/target/linux/ipq40xx/files/drivers/net/phy/ar40xx.c
@@ -1481,6 +1481,7 @@ ar40xx_vlan_init(struct ar40xx_priv *priv)
unsigned long bmp;
/* By default Enable VLAN */
+ /*
priv->vlan = 1;
priv->vlan_table[AR40XX_LAN_VLAN] = priv->cpu_bmp | priv->lan_bmp;
priv->vlan_table[AR40XX_WAN_VLAN] = priv->cpu_bmp | priv->wan_bmp;
@@ -1492,6 +1493,7 @@ ar40xx_vlan_init(struct ar40xx_priv *priv)
bmp = priv->wan_bmp;
for_each_set_bit(port, &bmp, AR40XX_NUM_PORTS)
priv->pvid[port] = AR40XX_WAN_VLAN;
+ */
return 0;
}
diff --git a/target/linux/ipq40xx/patches-5.4/711-dts-ipq4019-add-ethernet-essedma-node.patch b/target/linux/ipq40xx/patches-5.4/711-dts-ipq4019-add-ethernet-essedma-node.patch
index 7b2ddfe00d..1a01b08e41 100644
--- a/target/linux/ipq40xx/patches-5.4/711-dts-ipq4019-add-ethernet-essedma-node.patch
+++ b/target/linux/ipq40xx/patches-5.4/711-dts-ipq4019-add-ethernet-essedma-node.patch
@@ -36,7 +36,7 @@ Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
+ qcom,rx_head_buf_size = <1540>;
+ qcom,mdio_supported;
+ qcom,poll_required = <1>;
-+ qcom,num_gmac = <2>;
++ qcom,num_gmac = <1>;
+ interrupts = <0 65 IRQ_TYPE_EDGE_RISING
+ 0 66 IRQ_TYPE_EDGE_RISING
+ 0 67 IRQ_TYPE_EDGE_RISING
@@ -74,7 +74,7 @@ Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
+
+ gmac0: gmac0 {
+ local-mac-address = [00 00 00 00 00 00];
-+ vlan_tag = <1 0x1f>;
++ vlan_tag = <0 0x3f>;
+ };
+
+ gmac1: gmac1 {
@@ -83,7 +83,7 @@ Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
+ qcom,poll_required = <1>;
+ qcom,forced_speed = <1000>;
+ qcom,forced_duplex = <1>;
-+ vlan_tag = <2 0x20>;
++ vlan_tag = <0 0x00>;
+ };
+ };
+

View File

@ -0,0 +1,5 @@
WANDEV=eth0
SWITCHDEV=eth0
CLIENT_PORTS="0t 3 4"
WAN_PORTS="0t 5"
BATMAN_PORTS="0t 1 2"

View File

@ -7,6 +7,9 @@ get_port_order() {
local PORTORDER
case "$BOARD" in
avm,fritzbox-4040)
PORTORDER="5 1 2 3 4"
;;
glinet,gl-ar150)
PORTORDER="1"
;;