From 09fd59938b673ca10d4b3c46d32f18164bcdb21a Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Thu, 17 Aug 2023 17:14:37 +0200 Subject: [PATCH 01/20] netifd: update to the latest version 4711f74479e2 netifd: fix disabling radio via config if reconf is being used Signed-off-by: Felix Fietkau --- package/network/config/netifd/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package/network/config/netifd/Makefile b/package/network/config/netifd/Makefile index 94d2bfddece..ceedded96c9 100644 --- a/package/network/config/netifd/Makefile +++ b/package/network/config/netifd/Makefile @@ -5,9 +5,9 @@ PKG_RELEASE:=1 PKG_SOURCE_PROTO:=git PKG_SOURCE_URL=$(PROJECT_GIT)/project/netifd.git -PKG_SOURCE_DATE:=2023-07-17 -PKG_SOURCE_VERSION:=0ff22a6a68ce942d4c9e7d58355d128dd3793b06 -PKG_MIRROR_HASH:=4cc81829fa6eb571d67f6879c78d2f514b757a34cc963b7627d55a7a8deffb75 +PKG_SOURCE_DATE:=2023-08-17 +PKG_SOURCE_VERSION:=4711f74479e213ef86f8792b408b117d40148eb2 +PKG_MIRROR_HASH:=91c8aa8e890b0616c1ad1860618951ee73655c4e53cc31999dcbb8d00b8b456d PKG_MAINTAINER:=Felix Fietkau PKG_LICENSE:=GPL-2.0 From a61fd0f0bb0f70dc414b282ae20bdcd6a6e25926 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Thu, 17 Aug 2023 17:44:58 +0200 Subject: [PATCH 02/20] hostapd: fix bringing up mesh without supplicant when mcast rate is specified The iw command expects a specific command line argument Signed-off-by: Felix Fietkau --- package/network/services/hostapd/files/wdev.uc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/network/services/hostapd/files/wdev.uc b/package/network/services/hostapd/files/wdev.uc index 5b321423eb2..78037a9d271 100644 --- a/package/network/services/hostapd/files/wdev.uc +++ b/package/network/services/hostapd/files/wdev.uc @@ -47,7 +47,7 @@ function iface_start(wdev) system(cmd); } else if (wdev.mode == "mesh") { let cmd = [ "iw", "dev", ifname, "mesh", "join", wdev.ssid, "freq", wdev.freq, wdev.htmode ]; - for (let key in [ "beacon-interval", "mcast-rate" ]) + for (let key in [ "mcast-rate", "beacon-interval" ]) if (wdev[key]) push(cmd, key, wdev[key]); system(cmd); From 5356462ce54734afd32fce83ad118c58cfeb2a55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= Date: Fri, 18 Aug 2023 10:40:17 +0200 Subject: [PATCH 03/20] Revert "kernel: switch back 5.15 to fw_devlink=permissive" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 79af0593a30bfe382b350e9540ecfafa133b6ac0. A hack adjusting fw_devlink value was added to workaround issue with probing device drivers caused by of_platform_populate(). With upstream mtd commit (the one adding OF_POPULATED) backported there is no need for that hack anymore. Ref: 3eebb91317c6 ("kernel: backport proper fix for mtd preventing devices probing") Ref: #10232 Signed-off-by: Rafał Miłecki --- ...vert-driver-core-Set-fw_devlink-on-b.patch | 30 ------------------- ...vert-driver-core-Set-fw_devlink-on-b.patch | 30 ------------------- 2 files changed, 60 deletions(-) delete mode 100644 target/linux/generic/hack-5.15/930-Revert-Revert-Revert-driver-core-Set-fw_devlink-on-b.patch delete mode 100644 target/linux/generic/hack-6.1/930-Revert-Revert-Revert-driver-core-Set-fw_devlink-on-b.patch diff --git a/target/linux/generic/hack-5.15/930-Revert-Revert-Revert-driver-core-Set-fw_devlink-on-b.patch b/target/linux/generic/hack-5.15/930-Revert-Revert-Revert-driver-core-Set-fw_devlink-on-b.patch deleted file mode 100644 index 4f4d6c75091..00000000000 --- a/target/linux/generic/hack-5.15/930-Revert-Revert-Revert-driver-core-Set-fw_devlink-on-b.patch +++ /dev/null @@ -1,30 +0,0 @@ -From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= -Date: Tue, 19 Jul 2022 06:17:48 +0200 -Subject: [PATCH] Revert "Revert "Revert "driver core: Set fw_devlink=on by - default""" -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -This reverts commit ea718c699055c8566eb64432388a04974c43b2ea. - -With of_platform_populate() called for MTD partitions that commit breaks -probing devices which reference MTD in device tree. - -Link: https://lore.kernel.org/all/696cb2da-20b9-b3dd-46d9-de4bf91a1506@gmail.com/T/#u -Signed-off-by: Rafał Miłecki ---- - drivers/base/core.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - ---- a/drivers/base/core.c -+++ b/drivers/base/core.c -@@ -1562,7 +1562,7 @@ static void device_links_purge(struct de - #define FW_DEVLINK_FLAGS_RPM (FW_DEVLINK_FLAGS_ON | \ - DL_FLAG_PM_RUNTIME) - --static u32 fw_devlink_flags = FW_DEVLINK_FLAGS_ON; -+static u32 fw_devlink_flags = FW_DEVLINK_FLAGS_PERMISSIVE; - static int __init fw_devlink_setup(char *arg) - { - if (!arg) diff --git a/target/linux/generic/hack-6.1/930-Revert-Revert-Revert-driver-core-Set-fw_devlink-on-b.patch b/target/linux/generic/hack-6.1/930-Revert-Revert-Revert-driver-core-Set-fw_devlink-on-b.patch deleted file mode 100644 index 98081c4b64b..00000000000 --- a/target/linux/generic/hack-6.1/930-Revert-Revert-Revert-driver-core-Set-fw_devlink-on-b.patch +++ /dev/null @@ -1,30 +0,0 @@ -From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= -Date: Tue, 19 Jul 2022 06:17:48 +0200 -Subject: [PATCH] Revert "Revert "Revert "driver core: Set fw_devlink=on by - default""" -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -This reverts commit ea718c699055c8566eb64432388a04974c43b2ea. - -With of_platform_populate() called for MTD partitions that commit breaks -probing devices which reference MTD in device tree. - -Link: https://lore.kernel.org/all/696cb2da-20b9-b3dd-46d9-de4bf91a1506@gmail.com/T/#u -Signed-off-by: Rafał Miłecki ---- - drivers/base/core.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - ---- a/drivers/base/core.c -+++ b/drivers/base/core.c -@@ -1700,7 +1700,7 @@ static void device_links_purge(struct de - #define FW_DEVLINK_FLAGS_RPM (FW_DEVLINK_FLAGS_ON | \ - DL_FLAG_PM_RUNTIME) - --static u32 fw_devlink_flags = FW_DEVLINK_FLAGS_ON; -+static u32 fw_devlink_flags = FW_DEVLINK_FLAGS_PERMISSIVE; - static int __init fw_devlink_setup(char *arg) - { - if (!arg) From 93fabc05dc5e9e58165270dc1e37c1fef2983857 Mon Sep 17 00:00:00 2001 From: John Audia Date: Wed, 16 Aug 2023 14:17:57 -0400 Subject: [PATCH 04/20] kernel: bump 6.1 to 6.1.46 Changelog: https://cdn.kernel.org/pub/linux/kernel/v6.x/ChangeLog-6.1.46 All patches automatically rebased. Build system: x86/64 Build-tested: x86/64/AMD Cezanne, filogic/xiaomi_redmi-router-ax6000-ubootmod Run-tested: x86/64/AMD Cezanne, filogic/xiaomi_redmi-router-ax6000-ubootmod Signed-off-by: John Audia --- include/kernel-6.1 | 4 ++-- .../pending-6.1/630-packet_socket_type.patch | 16 ++++++++-------- ..._flow_offload-handle-netdevice-events-f.patch | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/include/kernel-6.1 b/include/kernel-6.1 index 8b6629001c6..580219c70f8 100644 --- a/include/kernel-6.1 +++ b/include/kernel-6.1 @@ -1,2 +1,2 @@ -LINUX_VERSION-6.1 = .45 -LINUX_KERNEL_HASH-6.1.45 = bd2343396e7ddad8974f3689a5a067ec931f4ade793e72b1070a85cd19f1f192 +LINUX_VERSION-6.1 = .46 +LINUX_KERNEL_HASH-6.1.46 = f5f67bcfccd47f8d9db2d5ba24e33af7778f40a777577d1fba424f4a1712a296 diff --git a/target/linux/generic/pending-6.1/630-packet_socket_type.patch b/target/linux/generic/pending-6.1/630-packet_socket_type.patch index 8e667fb4dde..c40c7096352 100644 --- a/target/linux/generic/pending-6.1/630-packet_socket_type.patch +++ b/target/linux/generic/pending-6.1/630-packet_socket_type.patch @@ -30,7 +30,7 @@ Signed-off-by: Felix Fietkau #define PACKET_FANOUT_LB 1 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c -@@ -1862,6 +1862,7 @@ static int packet_rcv_spkt(struct sk_buf +@@ -1866,6 +1866,7 @@ static int packet_rcv_spkt(struct sk_buf { struct sock *sk; struct sockaddr_pkt *spkt; @@ -38,7 +38,7 @@ Signed-off-by: Felix Fietkau /* * When we registered the protocol we saved the socket in the data -@@ -1869,6 +1870,7 @@ static int packet_rcv_spkt(struct sk_buf +@@ -1873,6 +1874,7 @@ static int packet_rcv_spkt(struct sk_buf */ sk = pt->af_packet_priv; @@ -46,7 +46,7 @@ Signed-off-by: Felix Fietkau /* * Yank back the headers [hope the device set this -@@ -1881,7 +1883,7 @@ static int packet_rcv_spkt(struct sk_buf +@@ -1885,7 +1887,7 @@ static int packet_rcv_spkt(struct sk_buf * so that this procedure is noop. */ @@ -55,7 +55,7 @@ Signed-off-by: Felix Fietkau goto out; if (!net_eq(dev_net(dev), sock_net(sk))) -@@ -2127,12 +2129,12 @@ static int packet_rcv(struct sk_buff *sk +@@ -2131,12 +2133,12 @@ static int packet_rcv(struct sk_buff *sk unsigned int snaplen, res; bool is_drop_n_account = false; @@ -71,7 +71,7 @@ Signed-off-by: Felix Fietkau if (!net_eq(dev_net(dev), sock_net(sk))) goto drop; -@@ -2259,12 +2261,12 @@ static int tpacket_rcv(struct sk_buff *s +@@ -2263,12 +2265,12 @@ static int tpacket_rcv(struct sk_buff *s BUILD_BUG_ON(TPACKET_ALIGN(sizeof(*h.h2)) != 32); BUILD_BUG_ON(TPACKET_ALIGN(sizeof(*h.h3)) != 48); @@ -87,7 +87,7 @@ Signed-off-by: Felix Fietkau if (!net_eq(dev_net(dev), sock_net(sk))) goto drop; -@@ -3374,6 +3376,7 @@ static int packet_create(struct net *net +@@ -3378,6 +3380,7 @@ static int packet_create(struct net *net mutex_init(&po->pg_vec_lock); po->rollover = NULL; po->prot_hook.func = packet_rcv; @@ -95,7 +95,7 @@ Signed-off-by: Felix Fietkau if (sock->type == SOCK_PACKET) po->prot_hook.func = packet_rcv_spkt; -@@ -4009,6 +4012,16 @@ packet_setsockopt(struct socket *sock, i +@@ -4013,6 +4016,16 @@ packet_setsockopt(struct socket *sock, i WRITE_ONCE(po->xmit, val ? packet_direct_xmit : dev_queue_xmit); return 0; } @@ -112,7 +112,7 @@ Signed-off-by: Felix Fietkau default: return -ENOPROTOOPT; } -@@ -4065,6 +4078,13 @@ static int packet_getsockopt(struct sock +@@ -4069,6 +4082,13 @@ static int packet_getsockopt(struct sock case PACKET_VNET_HDR: val = po->has_vnet_hdr; break; diff --git a/target/linux/generic/pending-6.1/700-netfilter-nft_flow_offload-handle-netdevice-events-f.patch b/target/linux/generic/pending-6.1/700-netfilter-nft_flow_offload-handle-netdevice-events-f.patch index 182a0cbc6a7..6050db3f5b7 100644 --- a/target/linux/generic/pending-6.1/700-netfilter-nft_flow_offload-handle-netdevice-events-f.patch +++ b/target/linux/generic/pending-6.1/700-netfilter-nft_flow_offload-handle-netdevice-events-f.patch @@ -59,7 +59,7 @@ Signed-off-by: Pablo Neira Ayuso } --- a/net/netfilter/nft_flow_offload.c +++ b/net/netfilter/nft_flow_offload.c -@@ -468,47 +468,14 @@ static struct nft_expr_type nft_flow_off +@@ -470,47 +470,14 @@ static struct nft_expr_type nft_flow_off .owner = THIS_MODULE, }; From 973c5d4a1d5d732f46b577384f39da2336a80fb1 Mon Sep 17 00:00:00 2001 From: John Audia Date: Wed, 16 Aug 2023 15:15:17 -0400 Subject: [PATCH 05/20] kernel: bump 5.15 to 5.15.127 Changelog: https://cdn.kernel.org/pub/linux/kernel/v5.x/ChangeLog-5.15.127 All patches automatically rebased. Build system: x86_64 Build-tested: ramips/tplink_archer-a6-v3 Run-tested: ramips/tplink_archer-a6-v3 Signed-off-by: John Audia --- include/kernel-5.15 | 4 ++-- ...x-add-support-for-qca-8327-internal-phy.patch | 4 ++-- ...803x-add-support-for-qca-8327-A-variant.patch | 4 ++-- ...x-add-resume-suspend-function-to-qca83x.patch | 6 +++--- ...x-fix-spacing-and-improve-name-for-83xx.patch | 2 +- ...t-phy-at803x-fix-resume-for-QCA8327-phy.patch | 6 +++--- ...803x-add-DAC-amplitude-fix-for-8327-phy.patch | 6 +++--- ...-NULL-pointer-dereference-on-AR9331-PHY.patch | 2 +- .../pending-5.15/630-packet_socket_type.patch | 16 ++++++++-------- ..._flow_offload-handle-netdevice-events-f.patch | 2 +- 10 files changed, 26 insertions(+), 26 deletions(-) diff --git a/include/kernel-5.15 b/include/kernel-5.15 index 7687c40aa8c..c1c1e791f71 100644 --- a/include/kernel-5.15 +++ b/include/kernel-5.15 @@ -1,2 +1,2 @@ -LINUX_VERSION-5.15 = .126 -LINUX_KERNEL_HASH-5.15.126 = adf4aab9840f89ee151b837defbe16e9f388e8eef20df7ee94bf63be33b3ed6f +LINUX_VERSION-5.15 = .127 +LINUX_KERNEL_HASH-5.15.127 = add0a575341b263a06e93599fc220a5dd34cb4ca5b9d05097a5db2a061928f26 diff --git a/target/linux/generic/backport-5.15/742-v5.16-net-phy-at803x-add-support-for-qca-8327-internal-phy.patch b/target/linux/generic/backport-5.15/742-v5.16-net-phy-at803x-add-support-for-qca-8327-internal-phy.patch index 8f000ba9187..03171d72cc7 100644 --- a/target/linux/generic/backport-5.15/742-v5.16-net-phy-at803x-add-support-for-qca-8327-internal-phy.patch +++ b/target/linux/generic/backport-5.15/742-v5.16-net-phy-at803x-add-support-for-qca-8327-internal-phy.patch @@ -17,7 +17,7 @@ Signed-off-by: David S. Miller --- a/drivers/net/phy/at803x.c +++ b/drivers/net/phy/at803x.c -@@ -1412,6 +1412,19 @@ static struct phy_driver at803x_driver[] +@@ -1410,6 +1410,19 @@ static struct phy_driver at803x_driver[] .get_sset_count = at803x_get_sset_count, .get_strings = at803x_get_strings, .get_stats = at803x_get_stats, @@ -37,7 +37,7 @@ Signed-off-by: David S. Miller }, }; module_phy_driver(at803x_driver); -@@ -1422,6 +1435,8 @@ static struct mdio_device_id __maybe_unu +@@ -1420,6 +1433,8 @@ static struct mdio_device_id __maybe_unu { PHY_ID_MATCH_EXACT(ATH8032_PHY_ID) }, { PHY_ID_MATCH_EXACT(ATH8035_PHY_ID) }, { PHY_ID_MATCH_EXACT(ATH9331_PHY_ID) }, diff --git a/target/linux/generic/backport-5.15/745-v5.16-01-net-phy-at803x-add-support-for-qca-8327-A-variant.patch b/target/linux/generic/backport-5.15/745-v5.16-01-net-phy-at803x-add-support-for-qca-8327-A-variant.patch index 99d91dfa765..7e4e9462e85 100644 --- a/target/linux/generic/backport-5.15/745-v5.16-01-net-phy-at803x-add-support-for-qca-8327-A-variant.patch +++ b/target/linux/generic/backport-5.15/745-v5.16-01-net-phy-at803x-add-support-for-qca-8327-A-variant.patch @@ -26,7 +26,7 @@ Signed-off-by: David S. Miller #define QCA8337_PHY_ID 0x004dd036 #define QCA8K_PHY_ID_MASK 0xffffffff -@@ -1413,10 +1414,23 @@ static struct phy_driver at803x_driver[] +@@ -1411,10 +1412,23 @@ static struct phy_driver at803x_driver[] .get_strings = at803x_get_strings, .get_stats = at803x_get_stats, }, { @@ -53,7 +53,7 @@ Signed-off-by: David S. Miller /* PHY_GBIT_FEATURES */ .probe = at803x_probe, .flags = PHY_IS_INTERNAL, -@@ -1436,7 +1450,8 @@ static struct mdio_device_id __maybe_unu +@@ -1434,7 +1448,8 @@ static struct mdio_device_id __maybe_unu { PHY_ID_MATCH_EXACT(ATH8035_PHY_ID) }, { PHY_ID_MATCH_EXACT(ATH9331_PHY_ID) }, { PHY_ID_MATCH_EXACT(QCA8337_PHY_ID) }, diff --git a/target/linux/generic/backport-5.15/745-v5.16-02-net-phy-at803x-add-resume-suspend-function-to-qca83x.patch b/target/linux/generic/backport-5.15/745-v5.16-02-net-phy-at803x-add-resume-suspend-function-to-qca83x.patch index cd83fac83c8..89aca23194d 100644 --- a/target/linux/generic/backport-5.15/745-v5.16-02-net-phy-at803x-add-resume-suspend-function-to-qca83x.patch +++ b/target/linux/generic/backport-5.15/745-v5.16-02-net-phy-at803x-add-resume-suspend-function-to-qca83x.patch @@ -16,7 +16,7 @@ Signed-off-by: David S. Miller --- a/drivers/net/phy/at803x.c +++ b/drivers/net/phy/at803x.c -@@ -1413,6 +1413,8 @@ static struct phy_driver at803x_driver[] +@@ -1411,6 +1411,8 @@ static struct phy_driver at803x_driver[] .get_sset_count = at803x_get_sset_count, .get_strings = at803x_get_strings, .get_stats = at803x_get_stats, @@ -25,7 +25,7 @@ Signed-off-by: David S. Miller }, { /* QCA8327-A from switch QCA8327-AL1A */ .phy_id = QCA8327_A_PHY_ID, -@@ -1426,6 +1428,8 @@ static struct phy_driver at803x_driver[] +@@ -1424,6 +1426,8 @@ static struct phy_driver at803x_driver[] .get_sset_count = at803x_get_sset_count, .get_strings = at803x_get_strings, .get_stats = at803x_get_stats, @@ -34,7 +34,7 @@ Signed-off-by: David S. Miller }, { /* QCA8327-B from switch QCA8327-BL1A */ .phy_id = QCA8327_B_PHY_ID, -@@ -1439,6 +1443,8 @@ static struct phy_driver at803x_driver[] +@@ -1437,6 +1441,8 @@ static struct phy_driver at803x_driver[] .get_sset_count = at803x_get_sset_count, .get_strings = at803x_get_strings, .get_stats = at803x_get_stats, diff --git a/target/linux/generic/backport-5.15/745-v5.16-03-net-phy-at803x-fix-spacing-and-improve-name-for-83xx.patch b/target/linux/generic/backport-5.15/745-v5.16-03-net-phy-at803x-fix-spacing-and-improve-name-for-83xx.patch index 586d8953b2b..920bef24fd6 100644 --- a/target/linux/generic/backport-5.15/745-v5.16-03-net-phy-at803x-fix-spacing-and-improve-name-for-83xx.patch +++ b/target/linux/generic/backport-5.15/745-v5.16-03-net-phy-at803x-fix-spacing-and-improve-name-for-83xx.patch @@ -15,7 +15,7 @@ Signed-off-by: David S. Miller --- a/drivers/net/phy/at803x.c +++ b/drivers/net/phy/at803x.c -@@ -1402,47 +1402,47 @@ static struct phy_driver at803x_driver[] +@@ -1400,47 +1400,47 @@ static struct phy_driver at803x_driver[] .config_aneg = at803x_config_aneg, }, { /* QCA8337 */ diff --git a/target/linux/generic/backport-5.15/746-v5.16-01-net-phy-at803x-fix-resume-for-QCA8327-phy.patch b/target/linux/generic/backport-5.15/746-v5.16-01-net-phy-at803x-fix-resume-for-QCA8327-phy.patch index 09797ae83bc..1029420ea9b 100644 --- a/target/linux/generic/backport-5.15/746-v5.16-01-net-phy-at803x-fix-resume-for-QCA8327-phy.patch +++ b/target/linux/generic/backport-5.15/746-v5.16-01-net-phy-at803x-fix-resume-for-QCA8327-phy.patch @@ -96,7 +96,7 @@ Signed-off-by: David S. Miller static struct phy_driver at803x_driver[] = { { /* Qualcomm Atheros AR8035 */ -@@ -1413,8 +1470,8 @@ static struct phy_driver at803x_driver[] +@@ -1411,8 +1468,8 @@ static struct phy_driver at803x_driver[] .get_sset_count = at803x_get_sset_count, .get_strings = at803x_get_strings, .get_stats = at803x_get_stats, @@ -107,7 +107,7 @@ Signed-off-by: David S. Miller }, { /* QCA8327-A from switch QCA8327-AL1A */ .phy_id = QCA8327_A_PHY_ID, -@@ -1428,8 +1485,8 @@ static struct phy_driver at803x_driver[] +@@ -1426,8 +1483,8 @@ static struct phy_driver at803x_driver[] .get_sset_count = at803x_get_sset_count, .get_strings = at803x_get_strings, .get_stats = at803x_get_stats, @@ -118,7 +118,7 @@ Signed-off-by: David S. Miller }, { /* QCA8327-B from switch QCA8327-BL1A */ .phy_id = QCA8327_B_PHY_ID, -@@ -1443,8 +1500,8 @@ static struct phy_driver at803x_driver[] +@@ -1441,8 +1498,8 @@ static struct phy_driver at803x_driver[] .get_sset_count = at803x_get_sset_count, .get_strings = at803x_get_strings, .get_stats = at803x_get_stats, diff --git a/target/linux/generic/backport-5.15/746-v5.16-02-net-phy-at803x-add-DAC-amplitude-fix-for-8327-phy.patch b/target/linux/generic/backport-5.15/746-v5.16-02-net-phy-at803x-add-DAC-amplitude-fix-for-8327-phy.patch index c504c37c84f..5813619c5c4 100644 --- a/target/linux/generic/backport-5.15/746-v5.16-02-net-phy-at803x-add-DAC-amplitude-fix-for-8327-phy.patch +++ b/target/linux/generic/backport-5.15/746-v5.16-02-net-phy-at803x-add-DAC-amplitude-fix-for-8327-phy.patch @@ -65,7 +65,7 @@ Signed-off-by: David S. Miller static int qca83xx_resume(struct phy_device *phydev) { int ret, val; -@@ -1463,6 +1493,7 @@ static struct phy_driver at803x_driver[] +@@ -1461,6 +1491,7 @@ static struct phy_driver at803x_driver[] .phy_id_mask = QCA8K_PHY_ID_MASK, .name = "Qualcomm Atheros 8337 internal PHY", /* PHY_GBIT_FEATURES */ @@ -73,7 +73,7 @@ Signed-off-by: David S. Miller .probe = at803x_probe, .flags = PHY_IS_INTERNAL, .config_init = qca83xx_config_init, -@@ -1478,6 +1509,7 @@ static struct phy_driver at803x_driver[] +@@ -1476,6 +1507,7 @@ static struct phy_driver at803x_driver[] .phy_id_mask = QCA8K_PHY_ID_MASK, .name = "Qualcomm Atheros 8327-A internal PHY", /* PHY_GBIT_FEATURES */ @@ -81,7 +81,7 @@ Signed-off-by: David S. Miller .probe = at803x_probe, .flags = PHY_IS_INTERNAL, .config_init = qca83xx_config_init, -@@ -1493,6 +1525,7 @@ static struct phy_driver at803x_driver[] +@@ -1491,6 +1523,7 @@ static struct phy_driver at803x_driver[] .phy_id_mask = QCA8K_PHY_ID_MASK, .name = "Qualcomm Atheros 8327-B internal PHY", /* PHY_GBIT_FEATURES */ diff --git a/target/linux/generic/backport-5.15/778-v5.18-03-net-phy-at803x-fix-NULL-pointer-dereference-on-AR9331-PHY.patch b/target/linux/generic/backport-5.15/778-v5.18-03-net-phy-at803x-fix-NULL-pointer-dereference-on-AR9331-PHY.patch index de8951db10c..53d6325c494 100644 --- a/target/linux/generic/backport-5.15/778-v5.18-03-net-phy-at803x-fix-NULL-pointer-dereference-on-AR9331-PHY.patch +++ b/target/linux/generic/backport-5.15/778-v5.18-03-net-phy-at803x-fix-NULL-pointer-dereference-on-AR9331-PHY.patch @@ -45,7 +45,7 @@ Signed-off-by: David S. Miller --- a/drivers/net/phy/at803x.c +++ b/drivers/net/phy/at803x.c -@@ -1594,6 +1594,8 @@ static struct phy_driver at803x_driver[] +@@ -1592,6 +1592,8 @@ static struct phy_driver at803x_driver[] /* ATHEROS AR9331 */ PHY_ID_MATCH_EXACT(ATH9331_PHY_ID), .name = "Qualcomm Atheros AR9331 built-in PHY", diff --git a/target/linux/generic/pending-5.15/630-packet_socket_type.patch b/target/linux/generic/pending-5.15/630-packet_socket_type.patch index ee13ce2a5c8..c36e9e9fbbe 100644 --- a/target/linux/generic/pending-5.15/630-packet_socket_type.patch +++ b/target/linux/generic/pending-5.15/630-packet_socket_type.patch @@ -30,7 +30,7 @@ Signed-off-by: Felix Fietkau #define PACKET_FANOUT_LB 1 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c -@@ -1826,6 +1826,7 @@ static int packet_rcv_spkt(struct sk_buf +@@ -1830,6 +1830,7 @@ static int packet_rcv_spkt(struct sk_buf { struct sock *sk; struct sockaddr_pkt *spkt; @@ -38,7 +38,7 @@ Signed-off-by: Felix Fietkau /* * When we registered the protocol we saved the socket in the data -@@ -1833,6 +1834,7 @@ static int packet_rcv_spkt(struct sk_buf +@@ -1837,6 +1838,7 @@ static int packet_rcv_spkt(struct sk_buf */ sk = pt->af_packet_priv; @@ -46,7 +46,7 @@ Signed-off-by: Felix Fietkau /* * Yank back the headers [hope the device set this -@@ -1845,7 +1847,7 @@ static int packet_rcv_spkt(struct sk_buf +@@ -1849,7 +1851,7 @@ static int packet_rcv_spkt(struct sk_buf * so that this procedure is noop. */ @@ -55,7 +55,7 @@ Signed-off-by: Felix Fietkau goto out; if (!net_eq(dev_net(dev), sock_net(sk))) -@@ -2091,12 +2093,12 @@ static int packet_rcv(struct sk_buff *sk +@@ -2095,12 +2097,12 @@ static int packet_rcv(struct sk_buff *sk unsigned int snaplen, res; bool is_drop_n_account = false; @@ -71,7 +71,7 @@ Signed-off-by: Felix Fietkau if (!net_eq(dev_net(dev), sock_net(sk))) goto drop; -@@ -2222,12 +2224,12 @@ static int tpacket_rcv(struct sk_buff *s +@@ -2226,12 +2228,12 @@ static int tpacket_rcv(struct sk_buff *s BUILD_BUG_ON(TPACKET_ALIGN(sizeof(*h.h2)) != 32); BUILD_BUG_ON(TPACKET_ALIGN(sizeof(*h.h3)) != 48); @@ -87,7 +87,7 @@ Signed-off-by: Felix Fietkau if (!net_eq(dev_net(dev), sock_net(sk))) goto drop; -@@ -3342,6 +3344,7 @@ static int packet_create(struct net *net +@@ -3346,6 +3348,7 @@ static int packet_create(struct net *net mutex_init(&po->pg_vec_lock); po->rollover = NULL; po->prot_hook.func = packet_rcv; @@ -95,7 +95,7 @@ Signed-off-by: Felix Fietkau if (sock->type == SOCK_PACKET) po->prot_hook.func = packet_rcv_spkt; -@@ -3979,6 +3982,16 @@ packet_setsockopt(struct socket *sock, i +@@ -3983,6 +3986,16 @@ packet_setsockopt(struct socket *sock, i WRITE_ONCE(po->xmit, val ? packet_direct_xmit : dev_queue_xmit); return 0; } @@ -112,7 +112,7 @@ Signed-off-by: Felix Fietkau default: return -ENOPROTOOPT; } -@@ -4035,6 +4048,13 @@ static int packet_getsockopt(struct sock +@@ -4039,6 +4052,13 @@ static int packet_getsockopt(struct sock case PACKET_VNET_HDR: val = po->has_vnet_hdr; break; diff --git a/target/linux/generic/pending-5.15/700-netfilter-nft_flow_offload-handle-netdevice-events-f.patch b/target/linux/generic/pending-5.15/700-netfilter-nft_flow_offload-handle-netdevice-events-f.patch index 488c6a8d92c..606e0535137 100644 --- a/target/linux/generic/pending-5.15/700-netfilter-nft_flow_offload-handle-netdevice-events-f.patch +++ b/target/linux/generic/pending-5.15/700-netfilter-nft_flow_offload-handle-netdevice-events-f.patch @@ -55,7 +55,7 @@ Signed-off-by: Pablo Neira Ayuso --- a/net/netfilter/nft_flow_offload.c +++ b/net/netfilter/nft_flow_offload.c -@@ -444,47 +444,14 @@ static struct nft_expr_type nft_flow_off +@@ -446,47 +446,14 @@ static struct nft_expr_type nft_flow_off .owner = THIS_MODULE, }; From 324673914d42f5fb9b70cc73e955117828b99f3b Mon Sep 17 00:00:00 2001 From: Stijn Tintel Date: Fri, 4 Aug 2023 10:03:10 +0300 Subject: [PATCH 06/20] hostapd: revert upstream commit to fix #13156 Commit e978072baaca ("Do prune_association only after the STA is authorized") causes issues when an STA roams from one interface to another interface on the same PHY. The mt7915 driver is not able to handle this properly. While the commits fixes a DoS, there are other devices and drivers with the same limitation, so revert to the orginal behavior for now, until we have a better solution in place. Fixes: #13156 Signed-off-by: Stijn Tintel --- .../patches/991-Fix-OpenWrt-13156.patch | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 package/network/services/hostapd/patches/991-Fix-OpenWrt-13156.patch diff --git a/package/network/services/hostapd/patches/991-Fix-OpenWrt-13156.patch b/package/network/services/hostapd/patches/991-Fix-OpenWrt-13156.patch new file mode 100644 index 00000000000..3f10fb1eef7 --- /dev/null +++ b/package/network/services/hostapd/patches/991-Fix-OpenWrt-13156.patch @@ -0,0 +1,63 @@ +From 26cd9bafc1d25e602952ee86cd2a5b8c3a995490 Mon Sep 17 00:00:00 2001 +From: Stijn Tintel +Date: Fri, 28 Jul 2023 16:27:47 +0300 +Subject: [PATCH] Revert "Do prune_association only after the STA is + authorized" + +Commit e978072baaca ("Do prune_association only after the STA is +authorized") causes issues when an STA roams from one interface to +another interface on the same PHY. The mt7915 driver is not able to +handle this properly. While the commits fixes a DoS, there are other +devices and drivers with the same limitation, so revert to the orginal +behavior for now, until we have a better solution in place. + +Ref: https://github.com/openwrt/openwrt/issues/13156 +Signed-off-by: Stijn Tintel +--- + src/ap/hostapd.c | 14 +++++++++++--- + src/ap/sta_info.c | 3 --- + 2 files changed, 11 insertions(+), 6 deletions(-) + +--- a/src/ap/hostapd.c ++++ b/src/ap/hostapd.c +@@ -3563,6 +3563,8 @@ int hostapd_remove_iface(struct hapd_int + void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta, + int reassoc) + { ++ int mld_assoc_link_id = -1; ++ + if (hapd->tkip_countermeasures) { + hostapd_drv_sta_deauth(hapd, sta->addr, + WLAN_REASON_MICHAEL_MIC_FAILURE); +@@ -3570,10 +3572,16 @@ void hostapd_new_assoc_sta(struct hostap + } + + #ifdef CONFIG_IEEE80211BE +- if (hapd->conf->mld_ap && sta->mld_info.mld_sta && +- sta->mld_assoc_link_id != hapd->mld_link_id) +- return; ++ if (hapd->conf->mld_ap && sta->mld_info.mld_sta) { ++ if (sta->mld_assoc_link_id == hapd->mld_link_id) { ++ mld_assoc_link_id = sta->mld_assoc_link_id; ++ } else { ++ return; ++ } ++ } + #endif /* CONFIG_IEEE80211BE */ ++ if (mld_assoc_link_id != -2) ++ hostapd_prune_associations(hapd, sta->addr, mld_assoc_link_id); + + ap_sta_clear_disconnect_timeouts(hapd, sta); + sta->post_csa_sa_query = 0; +--- a/src/ap/sta_info.c ++++ b/src/ap/sta_info.c +@@ -1318,9 +1318,6 @@ void ap_sta_set_authorized(struct hostap + mld_assoc_link_id = -2; + } + #endif /* CONFIG_IEEE80211BE */ +- if (mld_assoc_link_id != -2) +- hostapd_prune_associations(hapd, sta->addr, +- mld_assoc_link_id); + sta->flags |= WLAN_STA_AUTHORIZED; + } else { + sta->flags &= ~WLAN_STA_AUTHORIZED; From b7ee8c9f83ea0e3b861e6b71b08ed7a62066d149 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ar=C4=B1n=C3=A7=20=C3=9CNAL?= Date: Thu, 10 Aug 2023 15:23:08 +0300 Subject: [PATCH 07/20] bcm53xx: backport DT changes for ASUS RT-AC3100 queued for v6.6 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Backport the patch that adds the DT for ASUS RT-AC3100. Signed-off-by: Arınç ÜNAL --- ...s-BCM5301X-Add-DT-for-Asus-RT-AC3100.patch | 431 ++++++++++++++++++ ...RM-BCM5301X-Add-DT-for-Netgear-R7900.patch | 2 +- ...s-BCM5301X-Add-DT-for-Asus-RT-AC3100.patch | 431 ++++++++++++++++++ ...RM-BCM5301X-Add-DT-for-Netgear-R7900.patch | 2 +- 4 files changed, 864 insertions(+), 2 deletions(-) create mode 100644 target/linux/bcm53xx/patches-5.15/037-v6.6-0016-ARM-dts-BCM5301X-Add-DT-for-Asus-RT-AC3100.patch create mode 100644 target/linux/bcm53xx/patches-6.1/032-v6.6-0016-ARM-dts-BCM5301X-Add-DT-for-Asus-RT-AC3100.patch diff --git a/target/linux/bcm53xx/patches-5.15/037-v6.6-0016-ARM-dts-BCM5301X-Add-DT-for-Asus-RT-AC3100.patch b/target/linux/bcm53xx/patches-5.15/037-v6.6-0016-ARM-dts-BCM5301X-Add-DT-for-Asus-RT-AC3100.patch new file mode 100644 index 00000000000..6c2af02589c --- /dev/null +++ b/target/linux/bcm53xx/patches-5.15/037-v6.6-0016-ARM-dts-BCM5301X-Add-DT-for-Asus-RT-AC3100.patch @@ -0,0 +1,431 @@ +From 2900083269f7c0f0ff430bffc6ced2038aed9b6b Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Ar=C4=B1n=C3=A7=20=C3=9CNAL?= +Date: Thu, 3 Aug 2023 10:14:54 +0300 +Subject: [PATCH] ARM: dts: BCM5301X: Add DT for ASUS RT-AC3100 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +ASUS RT-AC3100 is ASUS RT-AC88U without the external switch. Move the +shared bindings to bcm47094-asus-rt-ac3100.dtsi. + +Remove the fixed-link node on port@7 as commit ba4aebce23b2 ("ARM: dts: +BCM5301X: Describe switch ports in the main DTS") states it's not +necessary. + +Replace the copyright notice with an author notice. + +Rename the model name from Asus to ASUS on bcm47094-asus-rt-ac88u.dts. + +Signed-off-by: Arınç ÜNAL +Reviewed-by: Linus Walleij +Link: https://lore.kernel.org/r/20230803071454.5902-2-arinc.unal@arinc9.com +Signed-off-by: Florian Fainelli +--- + arch/arm/boot/dts/Makefile | 1 + + .../dts/bcm47094-asus-rt-ac3100.dts | 23 +++ + .../dts/bcm47094-asus-rt-ac3100.dtsi | 163 ++++++++++++++++++ + .../dts/bcm47094-asus-rt-ac88u.dts | 155 +---------------- + 4 files changed, 190 insertions(+), 152 deletions(-) + create mode 100644 arch/arm/boot/dts/bcm47094-asus-rt-ac3100.dts + create mode 100644 arch/arm/boot/dts/bcm47094-asus-rt-ac3100.dtsi + +--- a/arch/arm/boot/dts/Makefile ++++ b/arch/arm/boot/dts/Makefile +@@ -119,6 +119,7 @@ dtb-$(CONFIG_ARCH_BCM_5301X) += \ + bcm4709-netgear-r7000.dtb \ + bcm4709-netgear-r8000.dtb \ + bcm4709-tplink-archer-c9-v1.dtb \ ++ bcm47094-asus-rt-ac3100.dtb \ + bcm47094-asus-rt-ac88u.dtb \ + bcm47094-dlink-dir-885l.dtb \ + bcm47094-dlink-dir-890l.dtb \ +--- /dev/null ++++ b/arch/arm/boot/dts/bcm47094-asus-rt-ac3100.dts +@@ -0,0 +1,23 @@ ++// SPDX-License-Identifier: GPL-2.0-or-later OR MIT ++/* ++ * Author: Arınç ÜNAL ++ */ ++ ++/dts-v1/; ++ ++#include "bcm47094-asus-rt-ac3100.dtsi" ++ ++/ { ++ compatible = "asus,rt-ac3100", "brcm,bcm47094", "brcm,bcm4708"; ++ model = "ASUS RT-AC3100"; ++ ++ nvram@1c080000 { ++ et0macaddr: et0macaddr { ++ }; ++ }; ++}; ++ ++&gmac0 { ++ nvmem-cells = <&et0macaddr>; ++ nvmem-cell-names = "mac-address"; ++}; +--- /dev/null ++++ b/arch/arm/boot/dts/bcm47094-asus-rt-ac3100.dtsi +@@ -0,0 +1,163 @@ ++// SPDX-License-Identifier: GPL-2.0-or-later OR MIT ++/* ++ * Author: Arınç ÜNAL ++ */ ++ ++#include "bcm47094.dtsi" ++#include "bcm5301x-nand-cs0-bch8.dtsi" ++ ++/ { ++ chosen { ++ bootargs = "earlycon"; ++ }; ++ ++ memory@0 { ++ device_type = "memory"; ++ reg = <0x00000000 0x08000000>, ++ <0x88000000 0x18000000>; ++ }; ++ ++ nvram@1c080000 { ++ compatible = "brcm,nvram"; ++ reg = <0x1c080000 0x00180000>; ++ }; ++ ++ leds { ++ compatible = "gpio-leds"; ++ ++ led-power { ++ label = "white:power"; ++ gpios = <&chipcommon 3 GPIO_ACTIVE_LOW>; ++ linux,default-trigger = "default-on"; ++ }; ++ ++ led-wan-red { ++ label = "red:wan"; ++ gpios = <&chipcommon 5 GPIO_ACTIVE_HIGH>; ++ }; ++ ++ led-lan { ++ label = "white:lan"; ++ gpios = <&chipcommon 21 GPIO_ACTIVE_LOW>; ++ }; ++ ++ led-usb2 { ++ label = "white:usb2"; ++ gpios = <&chipcommon 16 GPIO_ACTIVE_LOW>; ++ trigger-sources = <&ehci_port2>; ++ linux,default-trigger = "usbport"; ++ }; ++ ++ led-usb3 { ++ label = "white:usb3"; ++ gpios = <&chipcommon 17 GPIO_ACTIVE_LOW>; ++ trigger-sources = <&ehci_port1>, <&xhci_port1>; ++ linux,default-trigger = "usbport"; ++ }; ++ ++ led-wps { ++ label = "white:wps"; ++ gpios = <&chipcommon 19 GPIO_ACTIVE_LOW>; ++ }; ++ }; ++ ++ gpio-keys { ++ compatible = "gpio-keys"; ++ ++ button-wps { ++ label = "WPS"; ++ linux,code = ; ++ gpios = <&chipcommon 20 GPIO_ACTIVE_LOW>; ++ }; ++ ++ button-reset { ++ label = "Reset"; ++ linux,code = ; ++ gpios = <&chipcommon 11 GPIO_ACTIVE_LOW>; ++ }; ++ ++ button-wifi { ++ label = "Wi-Fi"; ++ linux,code = ; ++ gpios = <&chipcommon 18 GPIO_ACTIVE_LOW>; ++ }; ++ ++ button-led { ++ label = "Backlight"; ++ linux,code = ; ++ gpios = <&chipcommon 4 GPIO_ACTIVE_LOW>; ++ }; ++ }; ++}; ++ ++&srab { ++ compatible = "brcm,bcm53012-srab", "brcm,bcm5301x-srab"; ++ status = "okay"; ++ ++ ports { ++ port@0 { ++ label = "lan4"; ++ }; ++ ++ port@1 { ++ label = "lan3"; ++ }; ++ ++ port@2 { ++ label = "lan2"; ++ }; ++ ++ port@3 { ++ label = "lan1"; ++ }; ++ ++ port@4 { ++ label = "wan"; ++ }; ++ ++ port@5 { ++ label = "cpu"; ++ }; ++ ++ port@7 { ++ label = "cpu"; ++ }; ++ ++ port@8 { ++ label = "cpu"; ++ }; ++ }; ++}; ++ ++&usb2 { ++ vcc-gpio = <&chipcommon 9 GPIO_ACTIVE_HIGH>; ++}; ++ ++&usb3_phy { ++ status = "okay"; ++}; ++ ++&nandcs { ++ partitions { ++ compatible = "fixed-partitions"; ++ #address-cells = <1>; ++ #size-cells = <1>; ++ ++ partition@0 { ++ label = "boot"; ++ reg = <0x00000000 0x00080000>; ++ read-only; ++ }; ++ ++ partition@80000 { ++ label = "nvram"; ++ reg = <0x00080000 0x00180000>; ++ }; ++ ++ partition@200000 { ++ label = "firmware"; ++ reg = <0x00200000 0x07e00000>; ++ compatible = "brcm,trx"; ++ }; ++ }; ++}; +--- a/arch/arm/boot/dts/bcm47094-asus-rt-ac88u.dts ++++ b/arch/arm/boot/dts/bcm47094-asus-rt-ac88u.dts +@@ -1,102 +1,21 @@ + // SPDX-License-Identifier: GPL-2.0-or-later OR MIT + /* +- * Copyright (C) 2021-2022 Arınç ÜNAL ++ * Author: Arınç ÜNAL + */ + + /dts-v1/; + +-#include "bcm47094.dtsi" +-#include "bcm5301x-nand-cs0-bch8.dtsi" ++#include "bcm47094-asus-rt-ac3100.dtsi" + + / { + compatible = "asus,rt-ac88u", "brcm,bcm47094", "brcm,bcm4708"; +- model = "Asus RT-AC88U"; +- +- chosen { +- bootargs = "earlycon"; +- }; +- +- memory@0 { +- device_type = "memory"; +- reg = <0x00000000 0x08000000>, +- <0x88000000 0x18000000>; +- }; ++ model = "ASUS RT-AC88U"; + + nvram@1c080000 { +- compatible = "brcm,nvram"; +- reg = <0x1c080000 0x00180000>; +- + et1macaddr: et1macaddr { + }; + }; + +- leds { +- compatible = "gpio-leds"; +- +- led-power { +- label = "white:power"; +- gpios = <&chipcommon 3 GPIO_ACTIVE_LOW>; +- linux,default-trigger = "default-on"; +- }; +- +- led-wan-red { +- label = "red:wan"; +- gpios = <&chipcommon 5 GPIO_ACTIVE_HIGH>; +- }; +- +- led-lan { +- label = "white:lan"; +- gpios = <&chipcommon 21 GPIO_ACTIVE_LOW>; +- }; +- +- led-usb2 { +- label = "white:usb2"; +- gpios = <&chipcommon 16 GPIO_ACTIVE_LOW>; +- trigger-sources = <&ehci_port2>; +- linux,default-trigger = "usbport"; +- }; +- +- led-usb3 { +- label = "white:usb3"; +- gpios = <&chipcommon 17 GPIO_ACTIVE_LOW>; +- trigger-sources = <&ehci_port1>, <&xhci_port1>; +- linux,default-trigger = "usbport"; +- }; +- +- led-wps { +- label = "white:wps"; +- gpios = <&chipcommon 19 GPIO_ACTIVE_LOW>; +- }; +- }; +- +- gpio-keys { +- compatible = "gpio-keys"; +- +- button-wps { +- label = "WPS"; +- linux,code = ; +- gpios = <&chipcommon 20 GPIO_ACTIVE_LOW>; +- }; +- +- button-reset { +- label = "Reset"; +- linux,code = ; +- gpios = <&chipcommon 11 GPIO_ACTIVE_LOW>; +- }; +- +- button-wifi { +- label = "Wi-Fi"; +- linux,code = ; +- gpios = <&chipcommon 18 GPIO_ACTIVE_LOW>; +- }; +- +- button-led { +- label = "Backlight"; +- linux,code = ; +- gpios = <&chipcommon 4 GPIO_ACTIVE_LOW>; +- }; +- }; +- + switch { + compatible = "realtek,rtl8365mb"; + /* 7 = MDIO (has input reads), 6 = MDC (clock, output only) */ +@@ -175,31 +94,9 @@ + }; + + &srab { +- compatible = "brcm,bcm53012-srab", "brcm,bcm5301x-srab"; +- status = "okay"; + dsa,member = <0 0>; + + ports { +- port@0 { +- label = "lan4"; +- }; +- +- port@1 { +- label = "lan3"; +- }; +- +- port@2 { +- label = "lan2"; +- }; +- +- port@3 { +- label = "lan1"; +- }; +- +- port@4 { +- label = "wan"; +- }; +- + sw0_p5: port@5 { + /delete-property/ethernet; + +@@ -212,19 +109,6 @@ + pause; + }; + }; +- +- port@7 { +- label = "cpu"; +- +- fixed-link { +- speed = <1000>; +- full-duplex; +- }; +- }; +- +- port@8 { +- label = "cpu"; +- }; + }; + }; + +@@ -236,36 +120,3 @@ + nvmem-cells = <&et1macaddr>; + nvmem-cell-names = "mac-address"; + }; +- +-&usb2 { +- vcc-gpio = <&chipcommon 9 GPIO_ACTIVE_HIGH>; +-}; +- +-&usb3_phy { +- status = "okay"; +-}; +- +-&nandcs { +- partitions { +- compatible = "fixed-partitions"; +- #address-cells = <1>; +- #size-cells = <1>; +- +- partition@0 { +- label = "boot"; +- reg = <0x00000000 0x00080000>; +- read-only; +- }; +- +- partition@80000 { +- label = "nvram"; +- reg = <0x00080000 0x00180000>; +- }; +- +- partition@200000 { +- label = "firmware"; +- reg = <0x00200000 0x07e00000>; +- compatible = "brcm,trx"; +- }; +- }; +-}; diff --git a/target/linux/bcm53xx/patches-5.15/310-ARM-BCM5301X-Add-DT-for-Netgear-R7900.patch b/target/linux/bcm53xx/patches-5.15/310-ARM-BCM5301X-Add-DT-for-Netgear-R7900.patch index e76a12fe1b3..bc04cbd2d62 100644 --- a/target/linux/bcm53xx/patches-5.15/310-ARM-BCM5301X-Add-DT-for-Netgear-R7900.patch +++ b/target/linux/bcm53xx/patches-5.15/310-ARM-BCM5301X-Add-DT-for-Netgear-R7900.patch @@ -16,7 +16,7 @@ Signed-off-by: Rafał Miłecki + bcm4709-netgear-r7900.dtb \ bcm4709-netgear-r8000.dtb \ bcm4709-tplink-archer-c9-v1.dtb \ - bcm47094-asus-rt-ac88u.dtb \ + bcm47094-asus-rt-ac3100.dtb \ --- /dev/null +++ b/arch/arm/boot/dts/bcm4709-netgear-r7900.dts @@ -0,0 +1,42 @@ diff --git a/target/linux/bcm53xx/patches-6.1/032-v6.6-0016-ARM-dts-BCM5301X-Add-DT-for-Asus-RT-AC3100.patch b/target/linux/bcm53xx/patches-6.1/032-v6.6-0016-ARM-dts-BCM5301X-Add-DT-for-Asus-RT-AC3100.patch new file mode 100644 index 00000000000..47d5b108394 --- /dev/null +++ b/target/linux/bcm53xx/patches-6.1/032-v6.6-0016-ARM-dts-BCM5301X-Add-DT-for-Asus-RT-AC3100.patch @@ -0,0 +1,431 @@ +From 2900083269f7c0f0ff430bffc6ced2038aed9b6b Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Ar=C4=B1n=C3=A7=20=C3=9CNAL?= +Date: Thu, 3 Aug 2023 10:14:54 +0300 +Subject: [PATCH] ARM: dts: BCM5301X: Add DT for ASUS RT-AC3100 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +ASUS RT-AC3100 is ASUS RT-AC88U without the external switch. Move the +shared bindings to bcm47094-asus-rt-ac3100.dtsi. + +Remove the fixed-link node on port@7 as commit ba4aebce23b2 ("ARM: dts: +BCM5301X: Describe switch ports in the main DTS") states it's not +necessary. + +Replace the copyright notice with an author notice. + +Rename the model name from Asus to ASUS on bcm47094-asus-rt-ac88u.dts. + +Signed-off-by: Arınç ÜNAL +Reviewed-by: Linus Walleij +Link: https://lore.kernel.org/r/20230803071454.5902-2-arinc.unal@arinc9.com +Signed-off-by: Florian Fainelli +--- + arch/arm/boot/dts/Makefile | 1 + + .../dts/bcm47094-asus-rt-ac3100.dts | 23 +++ + .../dts/bcm47094-asus-rt-ac3100.dtsi | 163 ++++++++++++++++++ + .../dts/bcm47094-asus-rt-ac88u.dts | 155 +---------------- + 4 files changed, 190 insertions(+), 152 deletions(-) + create mode 100644 arch/arm/boot/dts/bcm47094-asus-rt-ac3100.dts + create mode 100644 arch/arm/boot/dts/bcm47094-asus-rt-ac3100.dtsi + +--- a/arch/arm/boot/dts/Makefile ++++ b/arch/arm/boot/dts/Makefile +@@ -127,6 +127,7 @@ dtb-$(CONFIG_ARCH_BCM_5301X) += \ + bcm4709-netgear-r7000.dtb \ + bcm4709-netgear-r8000.dtb \ + bcm4709-tplink-archer-c9-v1.dtb \ ++ bcm47094-asus-rt-ac3100.dtb \ + bcm47094-asus-rt-ac88u.dtb \ + bcm47094-dlink-dir-885l.dtb \ + bcm47094-dlink-dir-890l.dtb \ +--- /dev/null ++++ b/arch/arm/boot/dts/bcm47094-asus-rt-ac3100.dts +@@ -0,0 +1,23 @@ ++// SPDX-License-Identifier: GPL-2.0-or-later OR MIT ++/* ++ * Author: Arınç ÜNAL ++ */ ++ ++/dts-v1/; ++ ++#include "bcm47094-asus-rt-ac3100.dtsi" ++ ++/ { ++ compatible = "asus,rt-ac3100", "brcm,bcm47094", "brcm,bcm4708"; ++ model = "ASUS RT-AC3100"; ++ ++ nvram@1c080000 { ++ et0macaddr: et0macaddr { ++ }; ++ }; ++}; ++ ++&gmac0 { ++ nvmem-cells = <&et0macaddr>; ++ nvmem-cell-names = "mac-address"; ++}; +--- /dev/null ++++ b/arch/arm/boot/dts/bcm47094-asus-rt-ac3100.dtsi +@@ -0,0 +1,163 @@ ++// SPDX-License-Identifier: GPL-2.0-or-later OR MIT ++/* ++ * Author: Arınç ÜNAL ++ */ ++ ++#include "bcm47094.dtsi" ++#include "bcm5301x-nand-cs0-bch8.dtsi" ++ ++/ { ++ chosen { ++ bootargs = "earlycon"; ++ }; ++ ++ memory@0 { ++ device_type = "memory"; ++ reg = <0x00000000 0x08000000>, ++ <0x88000000 0x18000000>; ++ }; ++ ++ nvram@1c080000 { ++ compatible = "brcm,nvram"; ++ reg = <0x1c080000 0x00180000>; ++ }; ++ ++ leds { ++ compatible = "gpio-leds"; ++ ++ led-power { ++ label = "white:power"; ++ gpios = <&chipcommon 3 GPIO_ACTIVE_LOW>; ++ linux,default-trigger = "default-on"; ++ }; ++ ++ led-wan-red { ++ label = "red:wan"; ++ gpios = <&chipcommon 5 GPIO_ACTIVE_HIGH>; ++ }; ++ ++ led-lan { ++ label = "white:lan"; ++ gpios = <&chipcommon 21 GPIO_ACTIVE_LOW>; ++ }; ++ ++ led-usb2 { ++ label = "white:usb2"; ++ gpios = <&chipcommon 16 GPIO_ACTIVE_LOW>; ++ trigger-sources = <&ehci_port2>; ++ linux,default-trigger = "usbport"; ++ }; ++ ++ led-usb3 { ++ label = "white:usb3"; ++ gpios = <&chipcommon 17 GPIO_ACTIVE_LOW>; ++ trigger-sources = <&ehci_port1>, <&xhci_port1>; ++ linux,default-trigger = "usbport"; ++ }; ++ ++ led-wps { ++ label = "white:wps"; ++ gpios = <&chipcommon 19 GPIO_ACTIVE_LOW>; ++ }; ++ }; ++ ++ gpio-keys { ++ compatible = "gpio-keys"; ++ ++ button-wps { ++ label = "WPS"; ++ linux,code = ; ++ gpios = <&chipcommon 20 GPIO_ACTIVE_LOW>; ++ }; ++ ++ button-reset { ++ label = "Reset"; ++ linux,code = ; ++ gpios = <&chipcommon 11 GPIO_ACTIVE_LOW>; ++ }; ++ ++ button-wifi { ++ label = "Wi-Fi"; ++ linux,code = ; ++ gpios = <&chipcommon 18 GPIO_ACTIVE_LOW>; ++ }; ++ ++ button-led { ++ label = "Backlight"; ++ linux,code = ; ++ gpios = <&chipcommon 4 GPIO_ACTIVE_LOW>; ++ }; ++ }; ++}; ++ ++&srab { ++ compatible = "brcm,bcm53012-srab", "brcm,bcm5301x-srab"; ++ status = "okay"; ++ ++ ports { ++ port@0 { ++ label = "lan4"; ++ }; ++ ++ port@1 { ++ label = "lan3"; ++ }; ++ ++ port@2 { ++ label = "lan2"; ++ }; ++ ++ port@3 { ++ label = "lan1"; ++ }; ++ ++ port@4 { ++ label = "wan"; ++ }; ++ ++ port@5 { ++ label = "cpu"; ++ }; ++ ++ port@7 { ++ label = "cpu"; ++ }; ++ ++ port@8 { ++ label = "cpu"; ++ }; ++ }; ++}; ++ ++&usb2 { ++ vcc-gpio = <&chipcommon 9 GPIO_ACTIVE_HIGH>; ++}; ++ ++&usb3_phy { ++ status = "okay"; ++}; ++ ++&nandcs { ++ partitions { ++ compatible = "fixed-partitions"; ++ #address-cells = <1>; ++ #size-cells = <1>; ++ ++ partition@0 { ++ label = "boot"; ++ reg = <0x00000000 0x00080000>; ++ read-only; ++ }; ++ ++ partition@80000 { ++ label = "nvram"; ++ reg = <0x00080000 0x00180000>; ++ }; ++ ++ partition@200000 { ++ label = "firmware"; ++ reg = <0x00200000 0x07e00000>; ++ compatible = "brcm,trx"; ++ }; ++ }; ++}; +--- a/arch/arm/boot/dts/bcm47094-asus-rt-ac88u.dts ++++ b/arch/arm/boot/dts/bcm47094-asus-rt-ac88u.dts +@@ -1,102 +1,21 @@ + // SPDX-License-Identifier: GPL-2.0-or-later OR MIT + /* +- * Copyright (C) 2021-2022 Arınç ÜNAL ++ * Author: Arınç ÜNAL + */ + + /dts-v1/; + +-#include "bcm47094.dtsi" +-#include "bcm5301x-nand-cs0-bch8.dtsi" ++#include "bcm47094-asus-rt-ac3100.dtsi" + + / { + compatible = "asus,rt-ac88u", "brcm,bcm47094", "brcm,bcm4708"; +- model = "Asus RT-AC88U"; +- +- chosen { +- bootargs = "earlycon"; +- }; +- +- memory@0 { +- device_type = "memory"; +- reg = <0x00000000 0x08000000>, +- <0x88000000 0x18000000>; +- }; ++ model = "ASUS RT-AC88U"; + + nvram@1c080000 { +- compatible = "brcm,nvram"; +- reg = <0x1c080000 0x00180000>; +- + et1macaddr: et1macaddr { + }; + }; + +- leds { +- compatible = "gpio-leds"; +- +- led-power { +- label = "white:power"; +- gpios = <&chipcommon 3 GPIO_ACTIVE_LOW>; +- linux,default-trigger = "default-on"; +- }; +- +- led-wan-red { +- label = "red:wan"; +- gpios = <&chipcommon 5 GPIO_ACTIVE_HIGH>; +- }; +- +- led-lan { +- label = "white:lan"; +- gpios = <&chipcommon 21 GPIO_ACTIVE_LOW>; +- }; +- +- led-usb2 { +- label = "white:usb2"; +- gpios = <&chipcommon 16 GPIO_ACTIVE_LOW>; +- trigger-sources = <&ehci_port2>; +- linux,default-trigger = "usbport"; +- }; +- +- led-usb3 { +- label = "white:usb3"; +- gpios = <&chipcommon 17 GPIO_ACTIVE_LOW>; +- trigger-sources = <&ehci_port1>, <&xhci_port1>; +- linux,default-trigger = "usbport"; +- }; +- +- led-wps { +- label = "white:wps"; +- gpios = <&chipcommon 19 GPIO_ACTIVE_LOW>; +- }; +- }; +- +- gpio-keys { +- compatible = "gpio-keys"; +- +- button-wps { +- label = "WPS"; +- linux,code = ; +- gpios = <&chipcommon 20 GPIO_ACTIVE_LOW>; +- }; +- +- button-reset { +- label = "Reset"; +- linux,code = ; +- gpios = <&chipcommon 11 GPIO_ACTIVE_LOW>; +- }; +- +- button-wifi { +- label = "Wi-Fi"; +- linux,code = ; +- gpios = <&chipcommon 18 GPIO_ACTIVE_LOW>; +- }; +- +- button-led { +- label = "Backlight"; +- linux,code = ; +- gpios = <&chipcommon 4 GPIO_ACTIVE_LOW>; +- }; +- }; +- + switch { + compatible = "realtek,rtl8365mb"; + /* 7 = MDIO (has input reads), 6 = MDC (clock, output only) */ +@@ -175,31 +94,9 @@ + }; + + &srab { +- compatible = "brcm,bcm53012-srab", "brcm,bcm5301x-srab"; +- status = "okay"; + dsa,member = <0 0>; + + ports { +- port@0 { +- label = "lan4"; +- }; +- +- port@1 { +- label = "lan3"; +- }; +- +- port@2 { +- label = "lan2"; +- }; +- +- port@3 { +- label = "lan1"; +- }; +- +- port@4 { +- label = "wan"; +- }; +- + sw0_p5: port@5 { + /delete-property/ethernet; + +@@ -212,19 +109,6 @@ + pause; + }; + }; +- +- port@7 { +- label = "cpu"; +- +- fixed-link { +- speed = <1000>; +- full-duplex; +- }; +- }; +- +- port@8 { +- label = "cpu"; +- }; + }; + }; + +@@ -236,36 +120,3 @@ + nvmem-cells = <&et1macaddr>; + nvmem-cell-names = "mac-address"; + }; +- +-&usb2 { +- vcc-gpio = <&chipcommon 9 GPIO_ACTIVE_HIGH>; +-}; +- +-&usb3_phy { +- status = "okay"; +-}; +- +-&nandcs { +- partitions { +- compatible = "fixed-partitions"; +- #address-cells = <1>; +- #size-cells = <1>; +- +- partition@0 { +- label = "boot"; +- reg = <0x00000000 0x00080000>; +- read-only; +- }; +- +- partition@80000 { +- label = "nvram"; +- reg = <0x00080000 0x00180000>; +- }; +- +- partition@200000 { +- label = "firmware"; +- reg = <0x00200000 0x07e00000>; +- compatible = "brcm,trx"; +- }; +- }; +-}; diff --git a/target/linux/bcm53xx/patches-6.1/310-ARM-BCM5301X-Add-DT-for-Netgear-R7900.patch b/target/linux/bcm53xx/patches-6.1/310-ARM-BCM5301X-Add-DT-for-Netgear-R7900.patch index 02340f4e9f0..773c3e9be61 100644 --- a/target/linux/bcm53xx/patches-6.1/310-ARM-BCM5301X-Add-DT-for-Netgear-R7900.patch +++ b/target/linux/bcm53xx/patches-6.1/310-ARM-BCM5301X-Add-DT-for-Netgear-R7900.patch @@ -16,7 +16,7 @@ Signed-off-by: Rafał Miłecki + bcm4709-netgear-r7900.dtb \ bcm4709-netgear-r8000.dtb \ bcm4709-tplink-archer-c9-v1.dtb \ - bcm47094-asus-rt-ac88u.dtb \ + bcm47094-asus-rt-ac3100.dtb \ --- /dev/null +++ b/arch/arm/boot/dts/bcm4709-netgear-r7900.dts @@ -0,0 +1,42 @@ From 2214bab3503981fe6168746acd13044a9d5e89e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ar=C4=B1n=C3=A7=20=C3=9CNAL?= Date: Thu, 10 Aug 2023 15:23:09 +0300 Subject: [PATCH 08/20] bcm53xx: add support for ASUS RT-AC3100 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ASUS RT-AC3100 is ASUS RT-AC88U without the external switch. OpenWrt forum users effortless and ktmakwana have confirmed that there are revisions with either 4366b1 or 4366c0 wireless chips. Therefore, include firmware for 4366b1 along with 4366c0. This way, all hardware revisions of the router will be supported by having brcmfmac use the firmware file for the wireless chip it detects. Signed-off-by: Arınç ÜNAL --- target/linux/bcm53xx/image/Makefile | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/target/linux/bcm53xx/image/Makefile b/target/linux/bcm53xx/image/Makefile index b1eb4277b79..5158b432b3b 100644 --- a/target/linux/bcm53xx/image/Makefile +++ b/target/linux/bcm53xx/image/Makefile @@ -159,6 +159,14 @@ define Device/asus IMAGE/trx := append-ubi | trx-nand | asus-trx endef +define Device/asus_rt-ac3100 + $(call Device/asus) + DEVICE_MODEL := RT-AC3100 + DEVICE_PACKAGES := $(BRCMFMAC_4366B1) $(BRCMFMAC_4366C0) $(USB3_PACKAGES) + ASUS_PRODUCTID := RT-AC3100 +endef +TARGET_DEVICES += asus_rt-ac3100 + define Device/asus_rt-ac56u $(call Device/asus) DEVICE_MODEL := RT-AC56U From c46ac89ec6ac182939b4659dd83361d7636786e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ar=C4=B1n=C3=A7=20=C3=9CNAL?= Date: Thu, 10 Aug 2023 15:23:10 +0300 Subject: [PATCH 09/20] packages: nvram: add asus,rt-ac3100 to set_wireless_led_behaviour quirk MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add ASUS RT-AC3100 to the set wireless LED behaviour quirk. Signed-off-by: Arınç ÜNAL --- package/utils/nvram/Makefile | 2 +- package/utils/nvram/files/nvram-bcm53xx.init | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/package/utils/nvram/Makefile b/package/utils/nvram/Makefile index b957211283d..8547bfa2d6c 100644 --- a/package/utils/nvram/Makefile +++ b/package/utils/nvram/Makefile @@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=nvram -PKG_RELEASE:=11 +PKG_RELEASE:=12 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME) diff --git a/package/utils/nvram/files/nvram-bcm53xx.init b/package/utils/nvram/files/nvram-bcm53xx.init index 0502cd28b6e..2e9c9f3fce5 100755 --- a/package/utils/nvram/files/nvram-bcm53xx.init +++ b/package/utils/nvram/files/nvram-bcm53xx.init @@ -23,6 +23,7 @@ set_wireless_led_behaviour() { # 0x7 makes the wireless LEDs on, when radios are enabled, and blink when there's activity case $(board_name) in + asus,rt-ac3100|\ asus,rt-ac88u) COMMIT=1 nvram set 0:ledbh9=0x7 set 1:ledbh9=0x7 From 6b63fcf8df85e2b2a18499a424e3bef0ef24e7d3 Mon Sep 17 00:00:00 2001 From: Christian Marangi Date: Wed, 16 Aug 2023 18:51:28 +0200 Subject: [PATCH 10/20] generic: 6.1: backport patch adding support for LED PHY Backport patch adding support for LED PHY directly in PHY ops struct. Add new PHYLIB_LEDS config and refresh patches. Signed-off-by: Christian Marangi --- ...fix-circular-LEDS_CLASS-dependencies.patch | 65 ++++ ...net-phy-Fix-reading-LED-reg-property.patch | 43 +++ ...emove-LEDs-to-ensure-correct-orderin.patch | 67 ++++ ...dev-Remove-NULL-check-before-dev_-pu.patch | 44 +++ ...dev-uninitialized-variable-in-netdev.patch | 31 ++ ...netdev-Fix-requesting-offload-device.patch | 57 +++ ...ce-Call-into-the-PHY-driver-to-set-L.patch | 149 ++++++++ ...Add-support-for-offloading-LED-blink.patch | 344 ++++++++++++++++++ ...-Disable-offload-on-deactivation-of-.patch | 31 ++ target/linux/generic/config-6.1 | 1 + .../700-swconfig_switch_drivers.patch | 2 +- 11 files changed, 833 insertions(+), 1 deletion(-) create mode 100644 target/linux/generic/backport-6.1/820-v6.4-net-phy-fix-circular-LEDS_CLASS-dependencies.patch create mode 100644 target/linux/generic/backport-6.1/821-v6.4-net-phy-Fix-reading-LED-reg-property.patch create mode 100644 target/linux/generic/backport-6.1/822-v6.4-net-phy-Manual-remove-LEDs-to-ensure-correct-orderin.patch create mode 100644 target/linux/generic/backport-6.1/824-v6.5-leds-trigger-netdev-Remove-NULL-check-before-dev_-pu.patch create mode 100644 target/linux/generic/backport-6.1/825-v6.5-leds-trigger-netdev-uninitialized-variable-in-netdev.patch create mode 100644 target/linux/generic/backport-6.1/826-v6.6-01-led-trig-netdev-Fix-requesting-offload-device.patch create mode 100644 target/linux/generic/backport-6.1/826-v6.6-02-net-phy-phy_device-Call-into-the-PHY-driver-to-set-L.patch create mode 100644 target/linux/generic/backport-6.1/826-v6.6-03-net-phy-marvell-Add-support-for-offloading-LED-blink.patch create mode 100644 target/linux/generic/backport-6.1/826-v6.6-04-leds-trig-netdev-Disable-offload-on-deactivation-of-.patch diff --git a/target/linux/generic/backport-6.1/820-v6.4-net-phy-fix-circular-LEDS_CLASS-dependencies.patch b/target/linux/generic/backport-6.1/820-v6.4-net-phy-fix-circular-LEDS_CLASS-dependencies.patch new file mode 100644 index 00000000000..09a84201b59 --- /dev/null +++ b/target/linux/generic/backport-6.1/820-v6.4-net-phy-fix-circular-LEDS_CLASS-dependencies.patch @@ -0,0 +1,65 @@ +From 4bb7aac70b5d8a4bddf4ee0791b834f9f56883d2 Mon Sep 17 00:00:00 2001 +From: Arnd Bergmann +Date: Thu, 20 Apr 2023 10:45:51 +0200 +Subject: [PATCH] net: phy: fix circular LEDS_CLASS dependencies + +The CONFIG_PHYLIB symbol is selected by a number of device drivers that +need PHY support, but it now has a dependency on CONFIG_LEDS_CLASS, +which may not be enabled, causing build failures. + +Avoid the risk of missing and circular dependencies by guarding the +phylib LED support itself in another Kconfig symbol that can only be +enabled if the dependency is met. + +This could be made a hidden symbol and always enabled when both CONFIG_OF +and CONFIG_LEDS_CLASS are reachable from the phylib, but there may be an +advantage in having users see this option when they have a misconfigured +kernel without built-in LED support. + +Fixes: 01e5b728e9e4 ("net: phy: Add a binding for PHY LEDs") +Signed-off-by: Arnd Bergmann +Reviewed-by: Andrew Lunn +Link: https://lore.kernel.org/r/20230420084624.3005701-1-arnd@kernel.org +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/Kconfig | 9 ++++++++- + drivers/net/phy/phy_device.c | 3 ++- + 2 files changed, 10 insertions(+), 2 deletions(-) + +--- a/drivers/net/phy/Kconfig ++++ b/drivers/net/phy/Kconfig +@@ -18,7 +18,6 @@ menuconfig PHYLIB + depends on NETDEVICES + select MDIO_DEVICE + select MDIO_DEVRES +- depends on LEDS_CLASS || LEDS_CLASS=n + help + Ethernet controllers are usually attached to PHY + devices. This option provides infrastructure for +@@ -45,6 +44,14 @@ config LED_TRIGGER_PHY + Mbps OR Gbps OR link + for any speed known to the PHY. + ++config PHYLIB_LEDS ++ bool "Support probing LEDs from device tree" ++ depends on LEDS_CLASS=y || LEDS_CLASS=PHYLIB ++ depends on OF ++ default y ++ help ++ When LED class support is enabled, phylib can automatically ++ probe LED setting from device tree. + + config FIXED_PHY + tristate "MDIO Bus/PHY emulation with fixed speed/link PHYs" +--- a/drivers/net/phy/phy_device.c ++++ b/drivers/net/phy/phy_device.c +@@ -3208,7 +3208,8 @@ static int phy_probe(struct device *dev) + /* Get the LEDs from the device tree, and instantiate standard + * LEDs for them. + */ +- err = of_phy_leds(phydev); ++ if (IS_ENABLED(CONFIG_PHYLIB_LEDS)) ++ err = of_phy_leds(phydev); + + out: + /* Re-assert the reset signal on error */ diff --git a/target/linux/generic/backport-6.1/821-v6.4-net-phy-Fix-reading-LED-reg-property.patch b/target/linux/generic/backport-6.1/821-v6.4-net-phy-Fix-reading-LED-reg-property.patch new file mode 100644 index 00000000000..d6081d0e637 --- /dev/null +++ b/target/linux/generic/backport-6.1/821-v6.4-net-phy-Fix-reading-LED-reg-property.patch @@ -0,0 +1,43 @@ +From aed8fdad2152d946add50bec00a6b07c457bdcdf Mon Sep 17 00:00:00 2001 +From: Alexander Stein +Date: Mon, 24 Apr 2023 16:16:48 +0200 +Subject: [PATCH] net: phy: Fix reading LED reg property + +'reg' is always encoded in 32 bits, thus it has to be read using the +function with the corresponding bit width. + +Fixes: 01e5b728e9e4 ("net: phy: Add a binding for PHY LEDs") +Signed-off-by: Alexander Stein +Reviewed-by: Andrew Lunn +Reviewed-by: Florian Fainelli +Link: https://lore.kernel.org/r/20230424141648.317944-1-alexander.stein@ew.tq-group.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/phy_device.c | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +--- a/drivers/net/phy/phy_device.c ++++ b/drivers/net/phy/phy_device.c +@@ -2971,6 +2971,7 @@ static int of_phy_led(struct phy_device + struct led_init_data init_data = {}; + struct led_classdev *cdev; + struct phy_led *phyled; ++ u32 index; + int err; + + phyled = devm_kzalloc(dev, sizeof(*phyled), GFP_KERNEL); +@@ -2980,10 +2981,13 @@ static int of_phy_led(struct phy_device + cdev = &phyled->led_cdev; + phyled->phydev = phydev; + +- err = of_property_read_u8(led, "reg", &phyled->index); ++ err = of_property_read_u32(led, "reg", &index); + if (err) + return err; ++ if (index > U8_MAX) ++ return -EINVAL; + ++ phyled->index = index; + if (phydev->drv->led_brightness_set) + cdev->brightness_set_blocking = phy_led_set_brightness; + if (phydev->drv->led_blink_set) diff --git a/target/linux/generic/backport-6.1/822-v6.4-net-phy-Manual-remove-LEDs-to-ensure-correct-orderin.patch b/target/linux/generic/backport-6.1/822-v6.4-net-phy-Manual-remove-LEDs-to-ensure-correct-orderin.patch new file mode 100644 index 00000000000..04939deb6e3 --- /dev/null +++ b/target/linux/generic/backport-6.1/822-v6.4-net-phy-Manual-remove-LEDs-to-ensure-correct-orderin.patch @@ -0,0 +1,67 @@ +From c938ab4da0eb1620ae3243b0b24c572ddfc318fc Mon Sep 17 00:00:00 2001 +From: Andrew Lunn +Date: Sat, 17 Jun 2023 17:55:00 +0200 +Subject: [PATCH] net: phy: Manual remove LEDs to ensure correct ordering + +If the core is left to remove the LEDs via devm_, it is performed too +late, after the PHY driver is removed from the PHY. This results in +dereferencing a NULL pointer when the LED core tries to turn the LED +off before destroying the LED. + +Manually unregister the LEDs at a safe point in phy_remove. + +Cc: stable@vger.kernel.org +Reported-by: Florian Fainelli +Suggested-by: Florian Fainelli +Fixes: 01e5b728e9e4 ("net: phy: Add a binding for PHY LEDs") +Signed-off-by: Andrew Lunn +Signed-off-by: David S. Miller +--- + drivers/net/phy/phy_device.c | 15 ++++++++++++++- + 1 file changed, 14 insertions(+), 1 deletion(-) + +--- a/drivers/net/phy/phy_device.c ++++ b/drivers/net/phy/phy_device.c +@@ -2964,6 +2964,15 @@ static int phy_led_blink_set(struct led_ + return err; + } + ++static void phy_leds_unregister(struct phy_device *phydev) ++{ ++ struct phy_led *phyled; ++ ++ list_for_each_entry(phyled, &phydev->leds, list) { ++ led_classdev_unregister(&phyled->led_cdev); ++ } ++} ++ + static int of_phy_led(struct phy_device *phydev, + struct device_node *led) + { +@@ -2997,7 +3006,7 @@ static int of_phy_led(struct phy_device + init_data.fwnode = of_fwnode_handle(led); + init_data.devname_mandatory = true; + +- err = devm_led_classdev_register_ext(dev, cdev, &init_data); ++ err = led_classdev_register_ext(dev, cdev, &init_data); + if (err) + return err; + +@@ -3026,6 +3035,7 @@ static int of_phy_leds(struct phy_device + err = of_phy_led(phydev, led); + if (err) { + of_node_put(led); ++ phy_leds_unregister(phydev); + return err; + } + } +@@ -3229,6 +3239,9 @@ static int phy_remove(struct device *dev + + cancel_delayed_work_sync(&phydev->state_queue); + ++ if (IS_ENABLED(CONFIG_PHYLIB_LEDS)) ++ phy_leds_unregister(phydev); ++ + phydev->state = PHY_DOWN; + + sfp_bus_del_upstream(phydev->sfp_bus); diff --git a/target/linux/generic/backport-6.1/824-v6.5-leds-trigger-netdev-Remove-NULL-check-before-dev_-pu.patch b/target/linux/generic/backport-6.1/824-v6.5-leds-trigger-netdev-Remove-NULL-check-before-dev_-pu.patch new file mode 100644 index 00000000000..609115b04aa --- /dev/null +++ b/target/linux/generic/backport-6.1/824-v6.5-leds-trigger-netdev-Remove-NULL-check-before-dev_-pu.patch @@ -0,0 +1,44 @@ +From af7320ecae0ce646fd2c4a88341a3fbc243553da Mon Sep 17 00:00:00 2001 +From: Yang Li +Date: Thu, 11 May 2023 15:08:20 +0800 +Subject: [PATCH] leds: trigger: netdev: Remove NULL check before dev_{put, + hold} + +The call netdev_{put, hold} of dev_{put, hold} will check NULL, +so there is no need to check before using dev_{put, hold}, +remove it to silence the warnings: + +./drivers/leds/trigger/ledtrig-netdev.c:291:3-10: WARNING: NULL check before dev_{put, hold} functions is not needed. +./drivers/leds/trigger/ledtrig-netdev.c:401:2-9: WARNING: NULL check before dev_{put, hold} functions is not needed. + +Reported-by: Abaci Robot +Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=4929 +Signed-off-by: Yang Li +Link: https://lore.kernel.org/r/20230511070820.52731-1-yang.lee@linux.alibaba.com +Signed-off-by: Lee Jones +--- + drivers/leds/trigger/ledtrig-netdev.c | 6 ++---- + 1 file changed, 2 insertions(+), 4 deletions(-) + +--- a/drivers/leds/trigger/ledtrig-netdev.c ++++ b/drivers/leds/trigger/ledtrig-netdev.c +@@ -462,8 +462,7 @@ static int netdev_trig_notify(struct not + get_device_state(trigger_data); + fallthrough; + case NETDEV_REGISTER: +- if (trigger_data->net_dev) +- dev_put(trigger_data->net_dev); ++ dev_put(trigger_data->net_dev); + dev_hold(dev); + trigger_data->net_dev = dev; + break; +@@ -594,8 +593,7 @@ static void netdev_trig_deactivate(struc + + cancel_delayed_work_sync(&trigger_data->work); + +- if (trigger_data->net_dev) +- dev_put(trigger_data->net_dev); ++ dev_put(trigger_data->net_dev); + + kfree(trigger_data); + } diff --git a/target/linux/generic/backport-6.1/825-v6.5-leds-trigger-netdev-uninitialized-variable-in-netdev.patch b/target/linux/generic/backport-6.1/825-v6.5-leds-trigger-netdev-uninitialized-variable-in-netdev.patch new file mode 100644 index 00000000000..2f7a6ced901 --- /dev/null +++ b/target/linux/generic/backport-6.1/825-v6.5-leds-trigger-netdev-uninitialized-variable-in-netdev.patch @@ -0,0 +1,31 @@ +From 97c5209b3d374a25ebdb4c2ea9e9c1b121768da0 Mon Sep 17 00:00:00 2001 +From: Dan Carpenter +Date: Wed, 14 Jun 2023 10:03:59 +0300 +Subject: [PATCH] leds: trigger: netdev: uninitialized variable in + netdev_trig_activate() + +The qca8k_cled_hw_control_get() function which implements ->hw_control_get +sets the appropriate bits but does not clear them. This leads to an +uninitialized variable bug. Fix this by setting mode to zero at the +start. + +Fixes: e0256648c831 ("net: dsa: qca8k: implement hw_control ops") +Signed-off-by: Dan Carpenter +Reviewed-by: Andrew Lunn +Acked-by: Lee Jones +Signed-off-by: David S. Miller +--- + drivers/leds/trigger/ledtrig-netdev.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/leds/trigger/ledtrig-netdev.c ++++ b/drivers/leds/trigger/ledtrig-netdev.c +@@ -538,7 +538,7 @@ static void netdev_trig_work(struct work + static int netdev_trig_activate(struct led_classdev *led_cdev) + { + struct led_netdev_data *trigger_data; +- unsigned long mode; ++ unsigned long mode = 0; + struct device *dev; + int rc; + diff --git a/target/linux/generic/backport-6.1/826-v6.6-01-led-trig-netdev-Fix-requesting-offload-device.patch b/target/linux/generic/backport-6.1/826-v6.6-01-led-trig-netdev-Fix-requesting-offload-device.patch new file mode 100644 index 00000000000..dedf84c64bf --- /dev/null +++ b/target/linux/generic/backport-6.1/826-v6.6-01-led-trig-netdev-Fix-requesting-offload-device.patch @@ -0,0 +1,57 @@ +From 7df1f14c04cbb1950e79c19793420f87227c3e80 Mon Sep 17 00:00:00 2001 +From: Andrew Lunn +Date: Tue, 8 Aug 2023 23:04:33 +0200 +Subject: [PATCH 1/4] led: trig: netdev: Fix requesting offload device + +When the netdev trigger is activates, it tries to determine what +device the LED blinks for, and what the current blink mode is. + +The documentation for hw_control_get() says: + + * Return 0 on success, a negative error number on failing parsing the + * initial mode. Error from this function is NOT FATAL as the device + * may be in a not supported initial state by the attached LED trigger. + */ + +For the Marvell PHY and the Armada 370-rd board, the initial LED blink +mode is not supported by the trigger, so it returns an error. This +resulted in not getting the device the LED is blinking for. As a +result, the device is unknown and offloaded is never performed. + +Change to condition to always get the device if offloading is +supported, and reduce the scope of testing for an error from +hw_control_get() to skip setting trigger internal state if there is an +error. + +Reviewed-by: Simon Horman +Signed-off-by: Andrew Lunn +Tested-by: Daniel Golle +Link: https://lore.kernel.org/r/20230808210436.838995-2-andrew@lunn.ch +Signed-off-by: Jakub Kicinski +--- + drivers/leds/trigger/ledtrig-netdev.c | 8 +++++--- + 1 file changed, 5 insertions(+), 3 deletions(-) + +--- a/drivers/leds/trigger/ledtrig-netdev.c ++++ b/drivers/leds/trigger/ledtrig-netdev.c +@@ -564,15 +564,17 @@ static int netdev_trig_activate(struct l + /* Check if hw control is active by default on the LED. + * Init already enabled mode in hw control. + */ +- if (supports_hw_control(led_cdev) && +- !led_cdev->hw_control_get(led_cdev, &mode)) { ++ if (supports_hw_control(led_cdev)) { + dev = led_cdev->hw_control_get_device(led_cdev); + if (dev) { + const char *name = dev_name(dev); + + set_device_name(trigger_data, name, strlen(name)); + trigger_data->hw_control = true; +- trigger_data->mode = mode; ++ ++ rc = led_cdev->hw_control_get(led_cdev, &mode); ++ if (!rc) ++ trigger_data->mode = mode; + } + } + diff --git a/target/linux/generic/backport-6.1/826-v6.6-02-net-phy-phy_device-Call-into-the-PHY-driver-to-set-L.patch b/target/linux/generic/backport-6.1/826-v6.6-02-net-phy-phy_device-Call-into-the-PHY-driver-to-set-L.patch new file mode 100644 index 00000000000..6cd798fc5d6 --- /dev/null +++ b/target/linux/generic/backport-6.1/826-v6.6-02-net-phy-phy_device-Call-into-the-PHY-driver-to-set-L.patch @@ -0,0 +1,149 @@ +From 1dcc03c9a7a824a31eaaecdfaa03542fb25feb6c Mon Sep 17 00:00:00 2001 +From: Andrew Lunn +Date: Tue, 8 Aug 2023 23:04:34 +0200 +Subject: [PATCH 2/4] net: phy: phy_device: Call into the PHY driver to set LED + offload + +Linux LEDs can be requested to perform hardware accelerated blinking +to indicate link, RX, TX etc. Pass the rules for blinking to the PHY +driver, if it implements the ops needed to determine if a given +pattern can be offloaded, to offload it, and what the current offload +is. Additionally implement the op needed to get what device the LED is +for. + +Reviewed-by: Simon Horman +Signed-off-by: Andrew Lunn +Tested-by: Daniel Golle +Link: https://lore.kernel.org/r/20230808210436.838995-3-andrew@lunn.ch +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/phy_device.c | 68 ++++++++++++++++++++++++++++++++++++ + include/linux/phy.h | 33 +++++++++++++++++ + 2 files changed, 101 insertions(+) + +--- a/drivers/net/phy/phy_device.c ++++ b/drivers/net/phy/phy_device.c +@@ -2964,6 +2964,61 @@ static int phy_led_blink_set(struct led_ + return err; + } + ++static __maybe_unused struct device * ++phy_led_hw_control_get_device(struct led_classdev *led_cdev) ++{ ++ struct phy_led *phyled = to_phy_led(led_cdev); ++ struct phy_device *phydev = phyled->phydev; ++ ++ if (phydev->attached_dev) ++ return &phydev->attached_dev->dev; ++ return NULL; ++} ++ ++static int __maybe_unused ++phy_led_hw_control_get(struct led_classdev *led_cdev, ++ unsigned long *rules) ++{ ++ struct phy_led *phyled = to_phy_led(led_cdev); ++ struct phy_device *phydev = phyled->phydev; ++ int err; ++ ++ mutex_lock(&phydev->lock); ++ err = phydev->drv->led_hw_control_get(phydev, phyled->index, rules); ++ mutex_unlock(&phydev->lock); ++ ++ return err; ++} ++ ++static int __maybe_unused ++phy_led_hw_control_set(struct led_classdev *led_cdev, ++ unsigned long rules) ++{ ++ struct phy_led *phyled = to_phy_led(led_cdev); ++ struct phy_device *phydev = phyled->phydev; ++ int err; ++ ++ mutex_lock(&phydev->lock); ++ err = phydev->drv->led_hw_control_set(phydev, phyled->index, rules); ++ mutex_unlock(&phydev->lock); ++ ++ return err; ++} ++ ++static __maybe_unused int phy_led_hw_is_supported(struct led_classdev *led_cdev, ++ unsigned long rules) ++{ ++ struct phy_led *phyled = to_phy_led(led_cdev); ++ struct phy_device *phydev = phyled->phydev; ++ int err; ++ ++ mutex_lock(&phydev->lock); ++ err = phydev->drv->led_hw_is_supported(phydev, phyled->index, rules); ++ mutex_unlock(&phydev->lock); ++ ++ return err; ++} ++ + static void phy_leds_unregister(struct phy_device *phydev) + { + struct phy_led *phyled; +@@ -3001,6 +3056,19 @@ static int of_phy_led(struct phy_device + cdev->brightness_set_blocking = phy_led_set_brightness; + if (phydev->drv->led_blink_set) + cdev->blink_set = phy_led_blink_set; ++ ++#ifdef CONFIG_LEDS_TRIGGERS ++ if (phydev->drv->led_hw_is_supported && ++ phydev->drv->led_hw_control_set && ++ phydev->drv->led_hw_control_get) { ++ cdev->hw_control_is_supported = phy_led_hw_is_supported; ++ cdev->hw_control_set = phy_led_hw_control_set; ++ cdev->hw_control_get = phy_led_hw_control_get; ++ cdev->hw_control_trigger = "netdev"; ++ } ++ ++ cdev->hw_control_get_device = phy_led_hw_control_get_device; ++#endif + cdev->max_brightness = 1; + init_data.devicename = dev_name(&phydev->mdio.dev); + init_data.fwnode = of_fwnode_handle(led); +--- a/include/linux/phy.h ++++ b/include/linux/phy.h +@@ -1013,6 +1013,39 @@ struct phy_driver { + int (*led_blink_set)(struct phy_device *dev, u8 index, + unsigned long *delay_on, + unsigned long *delay_off); ++ /** ++ * @led_hw_is_supported: Can the HW support the given rules. ++ * @dev: PHY device which has the LED ++ * @index: Which LED of the PHY device ++ * @rules The core is interested in these rules ++ * ++ * Return 0 if yes, -EOPNOTSUPP if not, or an error code. ++ */ ++ int (*led_hw_is_supported)(struct phy_device *dev, u8 index, ++ unsigned long rules); ++ /** ++ * @led_hw_control_set: Set the HW to control the LED ++ * @dev: PHY device which has the LED ++ * @index: Which LED of the PHY device ++ * @rules The rules used to control the LED ++ * ++ * Returns 0, or a an error code. ++ */ ++ int (*led_hw_control_set)(struct phy_device *dev, u8 index, ++ unsigned long rules); ++ /** ++ * @led_hw_control_get: Get how the HW is controlling the LED ++ * @dev: PHY device which has the LED ++ * @index: Which LED of the PHY device ++ * @rules Pointer to the rules used to control the LED ++ * ++ * Set *@rules to how the HW is currently blinking. Returns 0 ++ * on success, or a error code if the current blinking cannot ++ * be represented in rules, or some other error happens. ++ */ ++ int (*led_hw_control_get)(struct phy_device *dev, u8 index, ++ unsigned long *rules); ++ + }; + #define to_phy_driver(d) container_of(to_mdio_common_driver(d), \ + struct phy_driver, mdiodrv) diff --git a/target/linux/generic/backport-6.1/826-v6.6-03-net-phy-marvell-Add-support-for-offloading-LED-blink.patch b/target/linux/generic/backport-6.1/826-v6.6-03-net-phy-marvell-Add-support-for-offloading-LED-blink.patch new file mode 100644 index 00000000000..1300583b665 --- /dev/null +++ b/target/linux/generic/backport-6.1/826-v6.6-03-net-phy-marvell-Add-support-for-offloading-LED-blink.patch @@ -0,0 +1,344 @@ +From 460b0b648fab24f576c481424e0de5479ffb9786 Mon Sep 17 00:00:00 2001 +From: Andrew Lunn +Date: Tue, 8 Aug 2023 23:04:35 +0200 +Subject: [PATCH 3/4] net: phy: marvell: Add support for offloading LED + blinking + +Add the code needed to indicate if a given blinking pattern can be +offloaded, to offload a pattern and to try to return the current +pattern. + +Reviewed-by: Simon Horman +Signed-off-by: Andrew Lunn +Tested-by: Daniel Golle +Link: https://lore.kernel.org/r/20230808210436.838995-4-andrew@lunn.ch +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/marvell.c | 281 ++++++++++++++++++++++++++++++++++++++ + 1 file changed, 281 insertions(+) + +--- a/drivers/net/phy/marvell.c ++++ b/drivers/net/phy/marvell.c +@@ -2893,6 +2893,272 @@ static int m88e1318_led_blink_set(struct + MII_88E1318S_PHY_LED_FUNC, reg); + } + ++struct marvell_led_rules { ++ int mode; ++ unsigned long rules; ++}; ++ ++static const struct marvell_led_rules marvell_led0[] = { ++ { ++ .mode = 0, ++ .rules = BIT(TRIGGER_NETDEV_LINK), ++ }, ++ { ++ .mode = 1, ++ .rules = (BIT(TRIGGER_NETDEV_LINK) | ++ BIT(TRIGGER_NETDEV_RX) | ++ BIT(TRIGGER_NETDEV_TX)), ++ }, ++ { ++ .mode = 3, ++ .rules = (BIT(TRIGGER_NETDEV_RX) | ++ BIT(TRIGGER_NETDEV_TX)), ++ }, ++ { ++ .mode = 4, ++ .rules = (BIT(TRIGGER_NETDEV_RX) | ++ BIT(TRIGGER_NETDEV_TX)), ++ }, ++ { ++ .mode = 5, ++ .rules = BIT(TRIGGER_NETDEV_TX), ++ }, ++ { ++ .mode = 6, ++ .rules = BIT(TRIGGER_NETDEV_LINK), ++ }, ++ { ++ .mode = 7, ++ .rules = BIT(TRIGGER_NETDEV_LINK_1000), ++ }, ++ { ++ .mode = 8, ++ .rules = 0, ++ }, ++}; ++ ++static const struct marvell_led_rules marvell_led1[] = { ++ { ++ .mode = 1, ++ .rules = (BIT(TRIGGER_NETDEV_LINK) | ++ BIT(TRIGGER_NETDEV_RX) | ++ BIT(TRIGGER_NETDEV_TX)), ++ }, ++ { ++ .mode = 2, ++ .rules = (BIT(TRIGGER_NETDEV_LINK) | ++ BIT(TRIGGER_NETDEV_RX)), ++ }, ++ { ++ .mode = 3, ++ .rules = (BIT(TRIGGER_NETDEV_RX) | ++ BIT(TRIGGER_NETDEV_TX)), ++ }, ++ { ++ .mode = 4, ++ .rules = (BIT(TRIGGER_NETDEV_RX) | ++ BIT(TRIGGER_NETDEV_TX)), ++ }, ++ { ++ .mode = 6, ++ .rules = (BIT(TRIGGER_NETDEV_LINK_100) | ++ BIT(TRIGGER_NETDEV_LINK_1000)), ++ }, ++ { ++ .mode = 7, ++ .rules = BIT(TRIGGER_NETDEV_LINK_100), ++ }, ++ { ++ .mode = 8, ++ .rules = 0, ++ }, ++}; ++ ++static const struct marvell_led_rules marvell_led2[] = { ++ { ++ .mode = 0, ++ .rules = BIT(TRIGGER_NETDEV_LINK), ++ }, ++ { ++ .mode = 1, ++ .rules = (BIT(TRIGGER_NETDEV_LINK) | ++ BIT(TRIGGER_NETDEV_RX) | ++ BIT(TRIGGER_NETDEV_TX)), ++ }, ++ { ++ .mode = 3, ++ .rules = (BIT(TRIGGER_NETDEV_RX) | ++ BIT(TRIGGER_NETDEV_TX)), ++ }, ++ { ++ .mode = 4, ++ .rules = (BIT(TRIGGER_NETDEV_RX) | ++ BIT(TRIGGER_NETDEV_TX)), ++ }, ++ { ++ .mode = 5, ++ .rules = BIT(TRIGGER_NETDEV_TX), ++ }, ++ { ++ .mode = 6, ++ .rules = (BIT(TRIGGER_NETDEV_LINK_10) | ++ BIT(TRIGGER_NETDEV_LINK_1000)), ++ }, ++ { ++ .mode = 7, ++ .rules = BIT(TRIGGER_NETDEV_LINK_10), ++ }, ++ { ++ .mode = 8, ++ .rules = 0, ++ }, ++}; ++ ++static int marvell_find_led_mode(unsigned long rules, ++ const struct marvell_led_rules *marvell_rules, ++ int count, ++ int *mode) ++{ ++ int i; ++ ++ for (i = 0; i < count; i++) { ++ if (marvell_rules[i].rules == rules) { ++ *mode = marvell_rules[i].mode; ++ return 0; ++ } ++ } ++ return -EOPNOTSUPP; ++} ++ ++static int marvell_get_led_mode(u8 index, unsigned long rules, int *mode) ++{ ++ int ret; ++ ++ switch (index) { ++ case 0: ++ ret = marvell_find_led_mode(rules, marvell_led0, ++ ARRAY_SIZE(marvell_led0), mode); ++ break; ++ case 1: ++ ret = marvell_find_led_mode(rules, marvell_led1, ++ ARRAY_SIZE(marvell_led1), mode); ++ break; ++ case 2: ++ ret = marvell_find_led_mode(rules, marvell_led2, ++ ARRAY_SIZE(marvell_led2), mode); ++ break; ++ default: ++ ret = -EINVAL; ++ } ++ ++ return ret; ++} ++ ++static int marvell_find_led_rules(unsigned long *rules, ++ const struct marvell_led_rules *marvell_rules, ++ int count, ++ int mode) ++{ ++ int i; ++ ++ for (i = 0; i < count; i++) { ++ if (marvell_rules[i].mode == mode) { ++ *rules = marvell_rules[i].rules; ++ return 0; ++ } ++ } ++ return -EOPNOTSUPP; ++} ++ ++static int marvell_get_led_rules(u8 index, unsigned long *rules, int mode) ++{ ++ int ret; ++ ++ switch (index) { ++ case 0: ++ ret = marvell_find_led_rules(rules, marvell_led0, ++ ARRAY_SIZE(marvell_led0), mode); ++ break; ++ case 1: ++ ret = marvell_find_led_rules(rules, marvell_led1, ++ ARRAY_SIZE(marvell_led1), mode); ++ break; ++ case 2: ++ ret = marvell_find_led_rules(rules, marvell_led2, ++ ARRAY_SIZE(marvell_led2), mode); ++ break; ++ default: ++ ret = -EOPNOTSUPP; ++ } ++ ++ return ret; ++} ++ ++static int m88e1318_led_hw_is_supported(struct phy_device *phydev, u8 index, ++ unsigned long rules) ++{ ++ int mode, ret; ++ ++ switch (index) { ++ case 0: ++ case 1: ++ case 2: ++ ret = marvell_get_led_mode(index, rules, &mode); ++ break; ++ default: ++ ret = -EINVAL; ++ } ++ ++ return ret; ++} ++ ++static int m88e1318_led_hw_control_set(struct phy_device *phydev, u8 index, ++ unsigned long rules) ++{ ++ int mode, ret, reg; ++ ++ switch (index) { ++ case 0: ++ case 1: ++ case 2: ++ ret = marvell_get_led_mode(index, rules, &mode); ++ break; ++ default: ++ ret = -EINVAL; ++ } ++ ++ if (ret < 0) ++ return ret; ++ ++ reg = phy_read_paged(phydev, MII_MARVELL_LED_PAGE, ++ MII_88E1318S_PHY_LED_FUNC); ++ if (reg < 0) ++ return reg; ++ ++ reg &= ~(0xf << (4 * index)); ++ reg |= mode << (4 * index); ++ return phy_write_paged(phydev, MII_MARVELL_LED_PAGE, ++ MII_88E1318S_PHY_LED_FUNC, reg); ++} ++ ++static int m88e1318_led_hw_control_get(struct phy_device *phydev, u8 index, ++ unsigned long *rules) ++{ ++ int mode, reg; ++ ++ if (index > 2) ++ return -EINVAL; ++ ++ reg = phy_read_paged(phydev, MII_MARVELL_LED_PAGE, ++ MII_88E1318S_PHY_LED_FUNC); ++ if (reg < 0) ++ return reg; ++ ++ mode = (reg >> (4 * index)) & 0xf; ++ ++ return marvell_get_led_rules(index, rules, mode); ++} ++ + static int marvell_probe(struct phy_device *phydev) + { + struct marvell_priv *priv; +@@ -3144,6 +3410,9 @@ static struct phy_driver marvell_drivers + .get_stats = marvell_get_stats, + .led_brightness_set = m88e1318_led_brightness_set, + .led_blink_set = m88e1318_led_blink_set, ++ .led_hw_is_supported = m88e1318_led_hw_is_supported, ++ .led_hw_control_set = m88e1318_led_hw_control_set, ++ .led_hw_control_get = m88e1318_led_hw_control_get, + }, + { + .phy_id = MARVELL_PHY_ID_88E1145, +@@ -3252,6 +3521,9 @@ static struct phy_driver marvell_drivers + .cable_test_get_status = marvell_vct7_cable_test_get_status, + .led_brightness_set = m88e1318_led_brightness_set, + .led_blink_set = m88e1318_led_blink_set, ++ .led_hw_is_supported = m88e1318_led_hw_is_supported, ++ .led_hw_control_set = m88e1318_led_hw_control_set, ++ .led_hw_control_get = m88e1318_led_hw_control_get, + }, + { + .phy_id = MARVELL_PHY_ID_88E1540, +@@ -3280,6 +3552,9 @@ static struct phy_driver marvell_drivers + .cable_test_get_status = marvell_vct7_cable_test_get_status, + .led_brightness_set = m88e1318_led_brightness_set, + .led_blink_set = m88e1318_led_blink_set, ++ .led_hw_is_supported = m88e1318_led_hw_is_supported, ++ .led_hw_control_set = m88e1318_led_hw_control_set, ++ .led_hw_control_get = m88e1318_led_hw_control_get, + }, + { + .phy_id = MARVELL_PHY_ID_88E1545, +@@ -3308,6 +3583,9 @@ static struct phy_driver marvell_drivers + .cable_test_get_status = marvell_vct7_cable_test_get_status, + .led_brightness_set = m88e1318_led_brightness_set, + .led_blink_set = m88e1318_led_blink_set, ++ .led_hw_is_supported = m88e1318_led_hw_is_supported, ++ .led_hw_control_set = m88e1318_led_hw_control_set, ++ .led_hw_control_get = m88e1318_led_hw_control_get, + }, + { + .phy_id = MARVELL_PHY_ID_88E3016, +@@ -3451,6 +3729,9 @@ static struct phy_driver marvell_drivers + .set_tunable = m88e1540_set_tunable, + .led_brightness_set = m88e1318_led_brightness_set, + .led_blink_set = m88e1318_led_blink_set, ++ .led_hw_is_supported = m88e1318_led_hw_is_supported, ++ .led_hw_control_set = m88e1318_led_hw_control_set, ++ .led_hw_control_get = m88e1318_led_hw_control_get, + }, + }; + diff --git a/target/linux/generic/backport-6.1/826-v6.6-04-leds-trig-netdev-Disable-offload-on-deactivation-of-.patch b/target/linux/generic/backport-6.1/826-v6.6-04-leds-trig-netdev-Disable-offload-on-deactivation-of-.patch new file mode 100644 index 00000000000..d6a69aa9ca2 --- /dev/null +++ b/target/linux/generic/backport-6.1/826-v6.6-04-leds-trig-netdev-Disable-offload-on-deactivation-of-.patch @@ -0,0 +1,31 @@ +From e8fbcc47a8e935f36f044d85f21a99acecbd7bfb Mon Sep 17 00:00:00 2001 +From: Andrew Lunn +Date: Tue, 8 Aug 2023 23:04:36 +0200 +Subject: [PATCH 4/4] leds: trig-netdev: Disable offload on deactivation of + trigger + +Ensure that the offloading of blinking is stopped when the trigger is +deactivated. Calling led_set_brightness() is documented as stopping +offload and setting the LED to a constant brightness. + +Suggested-by: Daniel Golle +Signed-off-by: Andrew Lunn +Reviewed-by: Simon Horman +Tested-by: Daniel Golle +Link: https://lore.kernel.org/r/20230808210436.838995-5-andrew@lunn.ch +Signed-off-by: Jakub Kicinski +--- + drivers/leds/trigger/ledtrig-netdev.c | 2 ++ + 1 file changed, 2 insertions(+) + +--- a/drivers/leds/trigger/ledtrig-netdev.c ++++ b/drivers/leds/trigger/ledtrig-netdev.c +@@ -595,6 +595,8 @@ static void netdev_trig_deactivate(struc + + cancel_delayed_work_sync(&trigger_data->work); + ++ led_set_brightness(led_cdev, LED_OFF); ++ + dev_put(trigger_data->net_dev); + + kfree(trigger_data); diff --git a/target/linux/generic/config-6.1 b/target/linux/generic/config-6.1 index 52a283237f0..29aa7292b80 100644 --- a/target/linux/generic/config-6.1 +++ b/target/linux/generic/config-6.1 @@ -4831,6 +4831,7 @@ CONFIG_PCI_SYSCALL=y # CONFIG_PHANTOM is not set # CONFIG_PHONET is not set # CONFIG_PHYLIB is not set +# CONFIG_PHYLIB_LEDS is not set # CONFIG_PHYS_ADDR_T_64BIT is not set # CONFIG_PHY_CADENCE_DP is not set # CONFIG_PHY_CADENCE_DPHY is not set diff --git a/target/linux/generic/hack-6.1/700-swconfig_switch_drivers.patch b/target/linux/generic/hack-6.1/700-swconfig_switch_drivers.patch index 9d77efaca6e..5f49678a34b 100644 --- a/target/linux/generic/hack-6.1/700-swconfig_switch_drivers.patch +++ b/target/linux/generic/hack-6.1/700-swconfig_switch_drivers.patch @@ -12,7 +12,7 @@ Signed-off-by: Felix Fietkau --- a/drivers/net/phy/Kconfig +++ b/drivers/net/phy/Kconfig -@@ -62,6 +62,80 @@ config SFP +@@ -69,6 +69,80 @@ config SFP depends on HWMON || HWMON=n select MDIO_I2C From edfe91372adfdaf5ee4e294fb0f5860a16adc551 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20B=C3=B6hler?= Date: Mon, 10 Jul 2023 11:55:30 +0200 Subject: [PATCH 11/20] ipq4019: add support for ZTE MF287 Pro aka DreiNeo Pro MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The ZTE MF287 Pro is a LTE router used (exclusively?) by the network operator "3". It is very similar to the MF287+, but the hardware layout and partition layout have changed quite a bit. Specifications ============== SoC: IPQ4018 RAM: 256MiB Flash: 8MiB SPI-NOR + 128MiB SPI-NAND LAN: 4x GBit LAN LTE: ZTE Cat12 WiFi: 802.11a/b/g/n/ac SoC-integrated USB: 1x 2.0 MAC addresses ============= LAN: from config + 2 WiFi 1: from config WiFi 2: from config + 1 Installation ============ Option 1 - TFTP --------------- TFTP installation using UART is preferred. Disassemble the device and connect serial. Put the initramfs image as openwrt.bin to your TFTP server and configure a static IP of 192.168.1.100. Load the initramfs image by typing: setenv serverip 192.168.1.100 setenv ipaddr 192.168.1.1 tftpboot 0x82000000 openwrt.bin bootm 0x82000000 From this intiramfs boot you can take a backup of the currently installed partitions as no vendor firmware is available for download: ubiattach -m17 cat /dev/ubi0_0 > /tmp/ubi0_0 cat /dev/ubi0_1 > /tmp/ubi0_1 Copy the files /tmp/ubi0_0 and /tmp/ubi0_1 somewhere save. Once booted, transfer the sysupgrade image and run sysupgrade. You might have to delete the stock volumes first: ubirmvol /dev/ubi0 -N ubi_rootfs ubirmvol /dev/ubi0 -N kernel Option 2 - From stock firmware ------------------------------ The installation from stock requires an exploit first. The exploit consists of a backup file that forces the firmware to download telnetd via TFTP from 192.168.0.22 and run it. Once exploited, you can connect via telnet and login as admin:admin. The exploit will be available at the device wiki page. Once inside the stock firmware, you can transfer the -factory.bin file to /tmp by using "scp" from the stock frmware or "tftp". ZTE has blocked writing to the NAND. Fortunately, it's easy to allow write access - you need to read from one file in /proc. Once done, you need to erase the UBI partition and flash OpenWrt. Before performing the operation, make sure that mtd13 is the partition labelled "rootfs" by calling "cat /proc/mtd". Complete commands: cd /tmp tftp -g -r factory.bin 192.168.0.22 cat /proc/driver/sensor_id flash_erase /dev/mtd17 0 0 dd if=/tmp/factory.bin of=/dev/mtdblock17 bs=131072 Afterwards, reboot your device and you should have a working OpenWrt installation. Restore Stock ============= Option 1 - via UART ------------------- Boot an OpenWrt initramfs image via TFTP as for the initial installation. Transfer the two backed-up files to your box to /tmp. Then, run the following commands - replace $kernel_length and $rootfs_size by the size of ubi0_0 and ubi0_1 in bytes. ubiattach -m 17 ubirmvol /dev/ubi0 -N kernel ubirmvol /dev/ubi0 -N rootfs ubirmvol /dev/ubi0 -N rootfs_data ubimkvol /dev/ubi0 -N kernel -s $kernel_length ubimkvol /dev/ubi0 -N ubi_rootfs -s $rootfs_size ubiupdatevol /dev/ubi0_0 /tmp/ubi0_0 ubiupdatevol /dev/ubi0_1 /tmp/ubi0_1 Option 2 - from within OpenWrt ------------------------------ This option requires to flash an initramfs version first so that access to the flash is possible. This can be achieved by sysupgrading to the recovery.bin version and rebooting. Once rebooted, you are again in a default OpenWrt installation, but no partition is mounted. Follow the commands from Option 1 to flash back to stock. LTE Modem ========= The LTE modem is similar to other ZTE devices and controls some more LEDs and battery management. Configuring the connection using uqmi works properly, the modem provides three serial ports and a QMI CDC ethernet interface. Other Notes =========== Contrary to the stock firmware, the USB port on the back can be used. There is one GPIO Switch "Power button blocker" which, if enabled, does not trigger a reset of the SoC if the modem reboots. If disabled, the SoC is rebooted along with the modem. The modem can be rebooted via the exported GPIO "modem-reset" in /sys/class/gpio. Signed-off-by: Andreas Böhler --- .../ipq40xx/base-files/etc/board.d/02_network | 3 +- .../base-files/etc/board.d/03_gpio_switches | 1 + .../base-files/lib/upgrade/platform.sh | 2 + .../arch/arm/boot/dts/qcom-ipq4018-mf287.dtsi | 183 ++++++++++++ .../arm/boot/dts/qcom-ipq4018-mf287plus.dts | 180 +----------- .../arm/boot/dts/qcom-ipq4018-mf287pro.dts | 265 ++++++++++++++++++ target/linux/ipq40xx/image/generic.mk | 21 +- 7 files changed, 476 insertions(+), 179 deletions(-) create mode 100644 target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4018-mf287.dtsi create mode 100644 target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4018-mf287pro.dts 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 c297566dd85..77dc892d078 100644 --- a/target/linux/ipq40xx/base-files/etc/board.d/02_network +++ b/target/linux/ipq40xx/base-files/etc/board.d/02_network @@ -108,7 +108,8 @@ ipq40xx_setup_interfaces() zte,mf286d) ucidef_set_interfaces_lan_wan "lan2 lan3 lan4" "wan" ;; - zte,mf287plus) + zte,mf287plus|\ + zte,mf287pro) ucidef_set_interface_lan "lan1 lan2 lan3 lan4" ucidef_set_interface "wan" device "/dev/cdc-wdm0" protocol "qmi" ;; diff --git a/target/linux/ipq40xx/base-files/etc/board.d/03_gpio_switches b/target/linux/ipq40xx/base-files/etc/board.d/03_gpio_switches index f76fe9402df..2035d84993b 100644 --- a/target/linux/ipq40xx/base-files/etc/board.d/03_gpio_switches +++ b/target/linux/ipq40xx/base-files/etc/board.d/03_gpio_switches @@ -36,6 +36,7 @@ wallys,dr40x9) ucidef_add_gpio_switch "sim_card_select" "SIM card select" "423" "0" ;; zte,mf286d|\ +zte,mf287pro|\ zte,mf289f) ucidef_add_gpio_switch "power_btn_block" "Power button blocker" "421" "0" ;; diff --git a/target/linux/ipq40xx/base-files/lib/upgrade/platform.sh b/target/linux/ipq40xx/base-files/lib/upgrade/platform.sh index 8807f844e59..83aac330ca2 100644 --- a/target/linux/ipq40xx/base-files/lib/upgrade/platform.sh +++ b/target/linux/ipq40xx/base-files/lib/upgrade/platform.sh @@ -28,6 +28,7 @@ EOF zte,mf18a |\ zte,mf286d |\ zte,mf287plus |\ + zte,mf287pro |\ zte,mf289f) CI_UBIPART="rootfs" local mtdnum="$( find_mtd_index $CI_UBIPART )" @@ -211,6 +212,7 @@ platform_do_upgrade() { zte,mf18a |\ zte,mf286d |\ zte,mf287plus |\ + zte,mf287pro |\ zte,mf289f) CI_UBIPART="rootfs" nand_do_upgrade "$1" diff --git a/target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4018-mf287.dtsi b/target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4018-mf287.dtsi new file mode 100644 index 00000000000..3cbe2eaa382 --- /dev/null +++ b/target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4018-mf287.dtsi @@ -0,0 +1,183 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +// Copyright (c) 2022, Pawel Dembicki . +// Copyright (c) 2022, Giammarco Marzano . +// Copyright (c) 2023, Andreas Böhler + +#include "qcom-ipq4019.dtsi" +#include +#include +#include +#include + +/ { + aliases { + led-boot = &led_status; + led-failsafe = &led_status; + led-running = &led_status; + led-upgrade = &led_status; + }; + + chosen { + /* + * bootargs forced by u-boot bootipq command: + * 'ubi.mtd=rootfs root=mtd:ubi_rootfs rootfstype=squashfs rootwait' + */ + bootargs-append = " root=/dev/ubiblock0_1"; + }; + + leds { + compatible = "gpio-leds"; + + led_status: led-0 { + label = "blue:power"; + function = LED_FUNCTION_POWER; + color = ; + }; + }; + + keys { + compatible = "gpio-keys"; + + key_reset: key-reset { + label = "reset"; + linux,code = ; + }; + + key_wps: key-wps { + label = "wps"; + linux,code = ; + }; + }; + + soc { + rng@22000 { + status = "okay"; + }; + + tcsr@1949000 { + compatible = "qcom,tcsr"; + reg = <0x1949000 0x100>; + qcom,wifi_glb_cfg = ; + }; + + tcsr@194b000 { + /* select hostmode */ + compatible = "qcom,tcsr"; + reg = <0x194b000 0x100>; + qcom,usb-hsphy-mode-select = ; + status = "okay"; + }; + + ess_tcsr@1953000 { + compatible = "qcom,tcsr"; + reg = <0x1953000 0x1000>; + qcom,ess-interface-select = ; + }; + + tcsr@1957000 { + compatible = "qcom,tcsr"; + reg = <0x1957000 0x100>; + qcom,wifi_noc_memtype_m0_m2 = ; + }; + }; +}; + +&mdio { + status = "okay"; +}; + +&watchdog { + status = "okay"; +}; + +&blsp_dma { + status = "okay"; +}; + +&usb2 { + status = "okay"; +}; + +&usb3 { + status = "okay"; +}; + +&blsp1_uart1 { + pinctrl-0 = <&serial_pins>; + pinctrl-names = "default"; + status = "okay"; +}; + +&crypto { + status = "okay"; +}; + +&cryptobam { + status = "okay"; +}; + +&gmac { + status = "okay"; + nvmem-cell-names = "mac-address"; + nvmem-cells = <&macaddr_mac_0>; + mac-address-increment = <2>; +}; + +&switch { + status = "okay"; +}; + +&swport2 { + status = "okay"; + + label = "lan1"; +}; + +&swport3 { + status = "okay"; + + label = "lan2"; +}; + +&swport4 { + status = "okay"; + + label = "lan3"; +}; + +&swport5 { + status = "okay"; + + label = "lan4"; +}; + +&qpic_bam { + status = "okay"; +}; + +&usb2_hs_phy { + status = "okay"; +}; + +&usb3_ss_phy { + status = "okay"; +}; + +&usb3_hs_phy { + status = "okay"; +}; + +&wifi0 { + status = "okay"; + nvmem-cell-names = "pre-calibration", "mac-address"; + nvmem-cells = <&precal_art_1000>, <&macaddr_mac_0>; + qcom,ath10k-calibration-variant = "zte,mf287plus"; +}; + +&wifi1 { + status = "okay"; + nvmem-cell-names = "pre-calibration", "mac-address"; + nvmem-cells = <&precal_art_5000>, <&macaddr_mac_0>; + mac-address-increment = <1>; + qcom,ath10k-calibration-variant = "zte,mf287plus"; +}; diff --git a/target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4018-mf287plus.dts b/target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4018-mf287plus.dts index 6c285f4b8ad..db8c8c9ad02 100644 --- a/target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4018-mf287plus.dts +++ b/target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4018-mf287plus.dts @@ -3,31 +3,12 @@ // Copyright (c) 2022, Giammarco Marzano . // Copyright (c) 2023, Andreas Böhler -#include "qcom-ipq4019.dtsi" -#include -#include -#include -#include +#include "qcom-ipq4018-mf287.dtsi" / { model = "ZTE MF287Plus"; compatible = "zte,mf287plus"; - aliases { - led-boot = &led_status; - led-failsafe = &led_status; - led-running = &led_status; - led-upgrade = &led_status; - }; - - chosen { - /* - * bootargs forced by u-boot bootipq command: - * 'ubi.mtd=rootfs root=mtd:ubi_rootfs rootfstype=squashfs rootwait' - */ - bootargs-append = " root=/dev/ubiblock0_1"; - }; - /* * This node is used to restart modem module to avoid anomalous * behaviours on initial communication. @@ -36,85 +17,18 @@ compatible = "gpio-restart"; gpios = <&tlmm 5 GPIO_ACTIVE_HIGH>; }; - - leds { - compatible = "gpio-leds"; - - led_status: led-0 { - label = "blue:power"; - function = LED_FUNCTION_POWER; - color = ; - gpios = <&tlmm 0 GPIO_ACTIVE_LOW>; - }; - }; - - keys { - compatible = "gpio-keys"; - - key-reset { - label = "reset"; - linux,code = ; - gpios = <&tlmm 63 GPIO_ACTIVE_LOW>; - }; - - key-wps { - label = "wps"; - linux,code = ; - gpios = <&tlmm 2 GPIO_ACTIVE_LOW>; - }; - }; - - soc { - rng@22000 { - status = "okay"; - }; - - tcsr@1949000 { - compatible = "qcom,tcsr"; - reg = <0x1949000 0x100>; - qcom,wifi_glb_cfg = ; - }; - - tcsr@194b000 { - /* select hostmode */ - compatible = "qcom,tcsr"; - reg = <0x194b000 0x100>; - qcom,usb-hsphy-mode-select = ; - status = "okay"; - }; - - ess_tcsr@1953000 { - compatible = "qcom,tcsr"; - reg = <0x1953000 0x1000>; - qcom,ess-interface-select = ; - }; - - tcsr@1957000 { - compatible = "qcom,tcsr"; - reg = <0x1957000 0x100>; - qcom,wifi_noc_memtype_m0_m2 = ; - }; - }; }; -&mdio { - status = "okay"; +&key_reset { + gpios = <&tlmm 63 GPIO_ACTIVE_LOW>; }; -&watchdog { - status = "okay"; +&key_wps { + gpios = <&tlmm 2 GPIO_ACTIVE_LOW>; }; -&blsp_dma { - status = "okay"; -}; - -&usb2 { - status = "okay"; -}; - -&usb3 { - status = "okay"; +&led_status { + gpios = <&tlmm 0 GPIO_ACTIVE_LOW>; }; &blsp1_spi1 { @@ -276,59 +190,6 @@ }; }; -&blsp1_uart1 { - pinctrl-0 = <&serial_pins>; - pinctrl-names = "default"; - status = "okay"; -}; - -&crypto { - status = "okay"; -}; - -&cryptobam { - status = "okay"; -}; - -&gmac { - status = "okay"; - nvmem-cell-names = "mac-address"; - nvmem-cells = <&macaddr_mac_0>; - mac-address-increment = <2>; -}; - -&switch { - status = "okay"; -}; - -&swport2 { - status = "okay"; - - label = "lan1"; -}; - -&swport3 { - status = "okay"; - - label = "lan2"; -}; - -&swport4 { - status = "okay"; - - label = "lan3"; -}; - -&swport5 { - status = "okay"; - - label = "lan4"; -}; - -&qpic_bam { - status = "okay"; -}; - &tlmm { serial_pins: serial_pinmux { mux { @@ -355,30 +216,3 @@ }; }; }; - -&usb2_hs_phy { - status = "okay"; -}; - -&usb3_ss_phy { - status = "okay"; -}; - -&usb3_hs_phy { - status = "okay"; -}; - -&wifi0 { - status = "okay"; - nvmem-cell-names = "pre-calibration", "mac-address"; - nvmem-cells = <&precal_art_1000>, <&macaddr_mac_0>; - qcom,ath10k-calibration-variant = "zte,mf287plus"; -}; - -&wifi1 { - status = "okay"; - nvmem-cell-names = "pre-calibration", "mac-address"; - nvmem-cells = <&precal_art_5000>, <&macaddr_mac_0>; - mac-address-increment = <1>; - qcom,ath10k-calibration-variant = "zte,mf287plus"; -}; diff --git a/target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4018-mf287pro.dts b/target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4018-mf287pro.dts new file mode 100644 index 00000000000..dda0f74449b --- /dev/null +++ b/target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4018-mf287pro.dts @@ -0,0 +1,265 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +// Copyright (c) 2022, Pawel Dembicki . +// Copyright (c) 2022, Giammarco Marzano . +// Copyright (c) 2023, Andreas Böhler + +#include "qcom-ipq4018-mf287.dtsi" + +/ { + model = "ZTE MF287Pro"; + compatible = "zte,mf287pro"; + + gpio_export { + compatible = "gpio-export"; + #size-cells = <0>; + + modem { + gpio-export,name = "modem-reset"; + gpio-export,output = <0>; + gpios = <&tlmm 8 GPIO_ACTIVE_HIGH>; + }; + }; + + regulator-usb-vbus { + compatible = "regulator-fixed"; + regulator-name = "USB_VBUS"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + regulator-always-on; + regulator-boot-on; + gpio = <&tlmm 25 GPIO_ACTIVE_LOW>; + }; +}; + +&key_reset { + gpios = <&tlmm 18 GPIO_ACTIVE_LOW>; +}; + +&key_wps { + gpios = <&tlmm 68 GPIO_ACTIVE_LOW>; +}; + +&led_status { + gpios = <&tlmm 35 GPIO_ACTIVE_LOW>; +}; + +&mdio { + status = "okay"; + pinctrl-0 = <&mdio_pins>; + pinctrl-names = "default"; + reset-gpios = <&tlmm 47 GPIO_ACTIVE_LOW>; + reset-delay-us = <2000>; +}; + +&blsp1_spi1 { + pinctrl-0 = <&spi_0_pins>; + pinctrl-names = "default"; + status = "okay"; + cs-gpios = <&tlmm 12 GPIO_ACTIVE_HIGH>, + <&tlmm 54 GPIO_ACTIVE_HIGH>; + + flash@0 { + compatible = "jedec,spi-nor"; + #address-cells = <1>; + #size-cells = <1>; + reg = <0>; + spi-max-frequency = <24000000>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "0:SBL1"; + reg = <0x0 0x40000>; + read-only; + }; + + partition@40000 { + label = "0:MIBIB"; + reg = <0x40000 0x20000>; + read-only; + }; + + partition@60000 { + label = "0:QSEE"; + reg = <0x60000 0x60000>; + read-only; + }; + + partition@c0000 { + label = "0:CDT"; + reg = <0xc0000 0x10000>; + read-only; + }; + + partition@d0000 { + label = "0:DDRPARAMS"; + reg = <0xd0000 0x10000>; + read-only; + }; + + partition@e0000 { + label = "0:APPSBLENV"; + reg = <0xe0000 0x10000>; + read-only; + }; + + partition@f0000 { + label = "0:APPSBL"; + reg = <0xf0000 0xc0000>; + read-only; + }; + + partition@1b0000 { + label = "0:reserved1"; + reg = <0x1b0000 0x50000>; + read-only; + }; + }; + }; + + spi-nand@1 { /* flash@1 ? */ + compatible = "spi-nand"; + reg = <1>; + spi-max-frequency = <24000000>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "fota-flag"; + reg = <0x0 0xa0000>; + read-only; + }; + + partition@a0000 { + label = "ART"; + reg = <0xa0000 0x80000>; + read-only; + compatible = "nvmem-cells"; + #address-cells = <1>; + #size-cells = <1>; + + precal_art_1000: precal@1000 { + reg = <0x1000 0x2f20>; + }; + + precal_art_5000: precal@5000 { + reg = <0x5000 0x2f20>; + }; + }; + + partition@120000 { + label = "mac"; + reg = <0x120000 0x80000>; + read-only; + compatible = "nvmem-cells"; + #address-cells = <1>; + #size-cells = <1>; + + macaddr_mac_0: macaddr@0 { + reg = <0x0 0x6>; + }; + }; + + partition@1a0000 { + label = "reserved2"; + reg = <0x1a0000 0xc0000>; + }; + + partition@260000 { + label = "cfg-param"; + reg = <0x260000 0x400000>; + read-only; + }; + + partition@660000 { + label = "log"; + reg = <0x660000 0x400000>; + }; + + partition@a60000 { + label = "oops"; + reg = <0xa60000 0xa0000>; + }; + + partition@b00000 { + label = "reserved3"; + reg = <0xb00000 0x500000>; + }; + + partition@1000000 { + label = "web"; + reg = <0x1000000 0x800000>; + }; + + partition@1800000 { + label = "rootfs"; + reg = <0x1800000 0x1d00000>; + }; + + partition@3500000 { + label = "data"; + reg = <0x3500000 0x1900000>; + }; + + partition@4e00000 { + label = "fota"; + reg = <0x4e00000 0x3200000>; + }; + }; + }; +}; + +&tlmm { + i2c_0_pins: i2c_0_pinmux { + mux { + pins = "gpio20", "gpio21"; + function = "blsp_i2c0"; + bias-disable; + }; + }; + + mdio_pins: mdio_pinmux { + mux_1 { + pins = "gpio6"; + function = "mdio"; + bias-pull-up; + }; + + mux_2 { + pins = "gpio7"; + function = "mdc"; + bias-pull-up; + }; + }; + + serial_pins: serial_pinmux { + mux { + pins = "gpio16", "gpio17"; + function = "blsp_uart0"; + bias-disable; + }; + }; + + spi_0_pins: spi_0_pinmux { + pinmux { + function = "blsp_spi0"; + pins = "gpio12", "gpio13", "gpio14", "gpio15"; + drive-strength = <12>; + bias-disable; + }; + + pinmux_cs { + function = "gpio"; + pins = "gpio12", "gpio54"; + drive-strength = <2>; + bias-disable; + output-high; + }; + }; +}; diff --git a/target/linux/ipq40xx/image/generic.mk b/target/linux/ipq40xx/image/generic.mk index dc5fbd64447..56aad5062ed 100644 --- a/target/linux/ipq40xx/image/generic.mk +++ b/target/linux/ipq40xx/image/generic.mk @@ -1129,12 +1129,8 @@ define Device/zte_mf286d endef TARGET_DEVICES += zte_mf286d -define Device/zte_mf287plus +define Device/zte_mf287_common $(call Device/zte_mf28x_common) - DEVICE_DTS_CONFIG := config@ap.dk01.1-c2 - DEVICE_MODEL := MF287Plus - DEVICE_ALT0_VENDOR := ZTE - DEVICE_ALT0_MODEL := MF287 DEVICE_PACKAGES += ipq-wifi-zte_mf287plus SOC := qcom-ipq4018 # The recovery image is used to return back to stock (an initramfs-based image @@ -1145,8 +1141,23 @@ define Device/zte_mf287plus IMAGE/factory.bin := append-ubi IMAGE/recovery.bin := append-squashfs4-fakeroot | sysupgrade-tar kernel=$$$$(BIN_DIR)/openwrt-$$(BOARD)$$(if $$(SUBTARGET),-$$(SUBTARGET))-$$(DEVICE_NAME)-initramfs-zImage.itb rootfs=$$$$@ | append-metadata endef + +define Device/zte_mf287plus + $(call Device/zte_mf287_common) + DEVICE_DTS_CONFIG := config@ap.dk01.1-c2 + DEVICE_MODEL := MF287Plus + DEVICE_ALT0_VENDOR := ZTE + DEVICE_ALT0_MODEL := MF287 +endef TARGET_DEVICES += zte_mf287plus +define Device/zte_mf287pro + $(call Device/zte_mf287_common) + DEVICE_DTS_CONFIG := config@ap.dk04.1-c1 + DEVICE_MODEL := MF287Pro +endef +TARGET_DEVICES += zte_mf287pro + define Device/zte_mf289f $(call Device/zte_mf28x_common) DEVICE_MODEL := MF289F From c123e4f0533ea0f0a01d0c81eb00b22da5ea9004 Mon Sep 17 00:00:00 2001 From: John Thomson Date: Wed, 16 Aug 2023 08:11:45 +1000 Subject: [PATCH 12/20] rtl8812au-ct: bump to fix kernel 6.1 compile 9b2b203 fix usb_recv_tasklet -Wcast-function-type a027da5 fix kernel 6.1 80211 link_id 7a9c802 fix build for kernel 6.1 prandom 3a3eb24 fix build for kernel 5.17 PDE_DATA fe2afbd fix build for kernel 5.17 const netdev->dev_addr 7275bae fix build for 5.17 kernel complete_and_exit c9c2aa7 Update usb_intf.c revert the upstream 6.1 link_id (depend on kernel version) changes and force 6.1 link_id The downstream patch casting const off the direct dev_addr writes triggers the runtime check from Linux d07b26f5bbea ("dev_addr: add a modification check") Fixes: #13261 Fixes: a07566ead82a ("rtl8812au-ct: fix even more compilation error with kernel 6.1") Signed-off-by: John Thomson --- package/kernel/rtl8812au-ct/Makefile | 6 +- .../patches/003-wireless-5.8.patch | 4 +- .../rtl8812au-ct/patches/005-kernel-6.1.patch | 14 --- ...osdep_service-use-new-get_random_u32.patch | 25 ----- ...de-fix-always-TRUE-condition-warning.patch | 2 +- ...de-use-correct-type-for-tasklet_init.patch | 93 ------------------- ...09-treewide-drop-const-from-dev_addr.patch | 56 ----------- ...linux-proc-move-to-pde_data-function.patch | 26 ------ ...nkid-linux-version-code-conditionals.patch | 86 +++++++++++++++++ .../rtl8812au-ct/patches/100-api_update.patch | 2 +- 10 files changed, 93 insertions(+), 221 deletions(-) delete mode 100644 package/kernel/rtl8812au-ct/patches/005-kernel-6.1.patch delete mode 100644 package/kernel/rtl8812au-ct/patches/006-os_dep-osdep_service-use-new-get_random_u32.patch delete mode 100644 package/kernel/rtl8812au-ct/patches/008-treewide-use-correct-type-for-tasklet_init.patch delete mode 100644 package/kernel/rtl8812au-ct/patches/009-treewide-drop-const-from-dev_addr.patch delete mode 100644 package/kernel/rtl8812au-ct/patches/010-os_dep-linux-proc-move-to-pde_data-function.patch create mode 100644 package/kernel/rtl8812au-ct/patches/099-cut-linkid-linux-version-code-conditionals.patch diff --git a/package/kernel/rtl8812au-ct/Makefile b/package/kernel/rtl8812au-ct/Makefile index be1acabf287..e3b71f75aa0 100644 --- a/package/kernel/rtl8812au-ct/Makefile +++ b/package/kernel/rtl8812au-ct/Makefile @@ -7,10 +7,10 @@ PKG_LICENSE:=GPLv2 PKG_LICENSE_FILES:= PKG_SOURCE_URL:=https://github.com/greearb/rtl8812AU_8821AU_linux.git -PKG_MIRROR_HASH:=31e658df3e4d4c18c396259c2e0bef2bfc44a4aa870931f031a31e948be98af4 +PKG_MIRROR_HASH:=7ae5ebcba382de97942b13f8edbcb2ebff1a93eb25ae1d3de98317386fafb830 PKG_SOURCE_PROTO:=git -PKG_SOURCE_DATE:=2021-11-07 -PKG_SOURCE_VERSION:=39df55967b7de9f6c9600017b724303f95a8b9e2 +PKG_SOURCE_DATE:=2022-10-26 +PKG_SOURCE_VERSION:=9b2b203a217e1320602a0eb07c338a1bfca0f5a6 PKG_MAINTAINER:=Ben Greear PKG_BUILD_PARALLEL:=1 diff --git a/package/kernel/rtl8812au-ct/patches/003-wireless-5.8.patch b/package/kernel/rtl8812au-ct/patches/003-wireless-5.8.patch index 67ebb82b387..f84adebe0ad 100644 --- a/package/kernel/rtl8812au-ct/patches/003-wireless-5.8.patch +++ b/package/kernel/rtl8812au-ct/patches/003-wireless-5.8.patch @@ -1,6 +1,6 @@ --- a/os_dep/linux/ioctl_cfg80211.c +++ b/os_dep/linux/ioctl_cfg80211.c -@@ -5177,6 +5177,15 @@ exit: +@@ -5196,6 +5196,15 @@ exit: return ret; } @@ -16,7 +16,7 @@ #if defined(CONFIG_TDLS) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)) static int cfg80211_rtw_tdls_mgmt(struct wiphy *wiphy, struct net_device *ndev, -@@ -5990,7 +5999,10 @@ static struct cfg80211_ops rtw_cfg80211_ +@@ -6009,7 +6018,10 @@ static struct cfg80211_ops rtw_cfg80211_ .cancel_remain_on_channel = cfg80211_rtw_cancel_remain_on_channel, #endif diff --git a/package/kernel/rtl8812au-ct/patches/005-kernel-6.1.patch b/package/kernel/rtl8812au-ct/patches/005-kernel-6.1.patch deleted file mode 100644 index 98aa6784910..00000000000 --- a/package/kernel/rtl8812au-ct/patches/005-kernel-6.1.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- a/include/osdep_service_linux.h -+++ b/include/osdep_service_linux.h -@@ -163,7 +163,11 @@ typedef void* _thread_hdl_; - typedef int thread_return; - typedef void* thread_context; - -+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,17,0)) -+#define thread_exit() kthread_complete_and_exit(NULL, 0) -+#else - #define thread_exit() complete_and_exit(NULL, 0) -+#endif - - typedef void timer_hdl_return; - typedef void* timer_hdl_context; diff --git a/package/kernel/rtl8812au-ct/patches/006-os_dep-osdep_service-use-new-get_random_u32.patch b/package/kernel/rtl8812au-ct/patches/006-os_dep-osdep_service-use-new-get_random_u32.patch deleted file mode 100644 index 16ebbb1eaa8..00000000000 --- a/package/kernel/rtl8812au-ct/patches/006-os_dep-osdep_service-use-new-get_random_u32.patch +++ /dev/null @@ -1,25 +0,0 @@ -From e8f10b21abd8ae440632f561f8b65f37b4b55cc8 Mon Sep 17 00:00:00 2001 -From: Christian Marangi -Date: Sun, 30 Jul 2023 11:16:32 +0200 -Subject: [PATCH 1/5] os_dep/osdep_service: use new get_random_u32 - -Drop prandom_u32 as got deprecated for get_random_u32. - -Signed-off-by: Christian Marangi ---- - os_dep/osdep_service.c | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - ---- a/os_dep/osdep_service.c -+++ b/os_dep/osdep_service.c -@@ -2335,7 +2335,9 @@ u64 rtw_division64(u64 x, u64 y) - inline u32 rtw_random32(void) - { - #ifdef PLATFORM_LINUX --#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) -+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6,1,0)) -+ return get_random_u32(); -+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) - return prandom_u32(); - #elif (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,18)) - u32 random_int; diff --git a/package/kernel/rtl8812au-ct/patches/007-treewide-fix-always-TRUE-condition-warning.patch b/package/kernel/rtl8812au-ct/patches/007-treewide-fix-always-TRUE-condition-warning.patch index be7b70ab5f2..c645c1e8e39 100644 --- a/package/kernel/rtl8812au-ct/patches/007-treewide-fix-always-TRUE-condition-warning.patch +++ b/package/kernel/rtl8812au-ct/patches/007-treewide-fix-always-TRUE-condition-warning.patch @@ -60,7 +60,7 @@ Signed-off-by: Christian Marangi if(input_idx>=1) { --- a/os_dep/linux/ioctl_cfg80211.c +++ b/os_dep/linux/ioctl_cfg80211.c -@@ -2170,8 +2170,7 @@ static int cfg80211_rtw_scan(struct wiph +@@ -2185,8 +2185,7 @@ static int cfg80211_rtw_scan(struct wiph #ifdef CONFIG_P2P if( pwdinfo->driver_interface == DRIVER_CFG80211 ) { diff --git a/package/kernel/rtl8812au-ct/patches/008-treewide-use-correct-type-for-tasklet_init.patch b/package/kernel/rtl8812au-ct/patches/008-treewide-use-correct-type-for-tasklet_init.patch deleted file mode 100644 index 60674131660..00000000000 --- a/package/kernel/rtl8812au-ct/patches/008-treewide-use-correct-type-for-tasklet_init.patch +++ /dev/null @@ -1,93 +0,0 @@ -From 5f3bb5602615894cda88ca1b44fdfafdfb01c8c8 Mon Sep 17 00:00:00 2001 -From: Christian Marangi -Date: Sun, 30 Jul 2023 11:20:39 +0200 -Subject: [PATCH 3/5] treewide: use correct type for tasklet_init - -Update and use correct type for tasklet_init to fix compilation error -for not valid cast. - -Signed-off-by: Christian Marangi ---- - hal/hal_hci/hal_usb.c | 2 +- - hal/rtl8812a/usb/rtl8812au_xmit.c | 2 +- - hal/rtl8812a/usb/usb_ops_linux.c | 2 +- - include/rtl8812a_xmit.h | 2 +- - include/usb_ops_linux.h | 2 +- - os_dep/linux/usb_ops_linux.c | 4 ++-- - 6 files changed, 7 insertions(+), 7 deletions(-) - ---- a/hal/hal_hci/hal_usb.c -+++ b/hal/hal_hci/hal_usb.c -@@ -35,7 +35,7 @@ int usb_init_recv_priv(_adapter *padapte - - #ifdef PLATFORM_LINUX - tasklet_init(&precvpriv->recv_tasklet, -- (void(*)(unsigned long))usb_recv_tasklet, -+ usb_recv_tasklet, - (unsigned long)padapter); - #endif /* PLATFORM_LINUX */ - ---- a/hal/rtl8812a/usb/rtl8812au_xmit.c -+++ b/hal/rtl8812a/usb/rtl8812au_xmit.c -@@ -30,7 +30,7 @@ s32 rtl8812au_init_xmit_priv(_adapter *p - - #ifdef PLATFORM_LINUX - tasklet_init(&pxmitpriv->xmit_tasklet, -- (void(*)(unsigned long))rtl8812au_xmit_tasklet, -+ rtl8812au_xmit_tasklet, - (unsigned long)padapter); - #endif - #ifdef CONFIG_TX_EARLY_MODE ---- a/hal/rtl8812a/usb/usb_ops_linux.c -+++ b/hal/rtl8812a/usb/usb_ops_linux.c -@@ -475,7 +475,7 @@ _exit_recvbuf2recvframe: - } - - --void rtl8812au_xmit_tasklet(void *priv) -+void rtl8812au_xmit_tasklet(unsigned long priv) - { - int ret = _FALSE; - _adapter *padapter = (_adapter*)priv; ---- a/include/rtl8812a_xmit.h -+++ b/include/rtl8812a_xmit.h -@@ -331,7 +331,7 @@ s32 rtl8812au_hal_xmit(PADAPTER padapter - s32 rtl8812au_mgnt_xmit(PADAPTER padapter, struct xmit_frame *pmgntframe); - s32 rtl8812au_hal_xmitframe_enqueue(_adapter *padapter, struct xmit_frame *pxmitframe); - s32 rtl8812au_xmit_buf_handler(PADAPTER padapter); --void rtl8812au_xmit_tasklet(void *priv); -+void rtl8812au_xmit_tasklet(unsigned long priv); - s32 rtl8812au_xmitframe_complete(_adapter *padapter, struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf); - #endif - ---- a/include/usb_ops_linux.h -+++ b/include/usb_ops_linux.h -@@ -78,7 +78,7 @@ int usb_write16(struct intf_hdl *pintfhd - int usb_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val); - int usb_writeN(struct intf_hdl *pintfhdl, u32 addr, u32 length, u8 *pdata); - u32 usb_read_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *rmem); --void usb_recv_tasklet(void *priv); -+void usb_recv_tasklet(unsigned long priv); - - #endif - ---- a/os_dep/linux/usb_ops_linux.c -+++ b/os_dep/linux/usb_ops_linux.c -@@ -717,7 +717,7 @@ void usb_init_recvbuf(_adapter *padapter - int recvbuf2recvframe(PADAPTER padapter, void *ptr); - - #ifdef CONFIG_USE_USB_BUFFER_ALLOC_RX --void usb_recv_tasklet(void *priv) -+void usb_recv_tasklet(unsigned long priv) - { - struct recv_buf *precvbuf = NULL; - _adapter *padapter = (_adapter*)priv; -@@ -870,7 +870,7 @@ u32 usb_read_port(struct intf_hdl *pintf - } - #else // CONFIG_USE_USB_BUFFER_ALLOC_RX - --void usb_recv_tasklet(void *priv) -+void usb_recv_tasklet(unsigned long priv) - { - _pkt *pskb; - _adapter *padapter = (_adapter*)priv; diff --git a/package/kernel/rtl8812au-ct/patches/009-treewide-drop-const-from-dev_addr.patch b/package/kernel/rtl8812au-ct/patches/009-treewide-drop-const-from-dev_addr.patch deleted file mode 100644 index 64ad85372bc..00000000000 --- a/package/kernel/rtl8812au-ct/patches/009-treewide-drop-const-from-dev_addr.patch +++ /dev/null @@ -1,56 +0,0 @@ -From 51ab9d6a959de87206731f941b1df39e5c5d63ea Mon Sep 17 00:00:00 2001 -From: Christian Marangi -Date: Sun, 30 Jul 2023 11:21:49 +0200 -Subject: [PATCH 4/5] treewide: drop const from dev_addr - -dev_addr is not const and conflict with memcpy function. Fix compilation -warning by casting dev_addr to void*. - -This operation is safe as this is done before netdev register. - -Signed-off-by: Christian Marangi ---- - os_dep/linux/os_intfs.c | 6 +++--- - os_dep/osdep_service.c | 2 +- - 2 files changed, 4 insertions(+), 4 deletions(-) - ---- a/os_dep/linux/os_intfs.c -+++ b/os_dep/linux/os_intfs.c -@@ -1885,7 +1885,7 @@ int _netdev_if2_open(struct net_device * - - _rtw_memcpy(padapter->eeprompriv.mac_addr, mac, ETH_ALEN); - rtw_init_wifidirect_addrs(padapter, padapter->eeprompriv.mac_addr, padapter->eeprompriv.mac_addr); -- _rtw_memcpy(pnetdev->dev_addr, padapter->eeprompriv.mac_addr, ETH_ALEN); -+ _rtw_memcpy((void *)pnetdev->dev_addr, padapter->eeprompriv.mac_addr, ETH_ALEN); - } - #endif //CONFIG_PLATFORM_INTEL_BYT - -@@ -2254,7 +2254,7 @@ static int _rtw_drv_register_netdev(_ada - /* alloc netdev name */ - rtw_init_netdev_name(pnetdev, name); - -- _rtw_memcpy(pnetdev->dev_addr, padapter->eeprompriv.mac_addr, ETH_ALEN); -+ _rtw_memcpy((void *)pnetdev->dev_addr, padapter->eeprompriv.mac_addr, ETH_ALEN); - - /* Tell the network stack we exist */ - if (register_netdev(pnetdev) != 0) { -@@ -2334,7 +2334,7 @@ int _netdev_open(struct net_device *pnet - #ifdef CONFIG_PLATFORM_INTEL_BYT - rtw_macaddr_cfg(padapter->eeprompriv.mac_addr); - rtw_init_wifidirect_addrs(padapter, padapter->eeprompriv.mac_addr, padapter->eeprompriv.mac_addr); -- _rtw_memcpy(pnetdev->dev_addr, padapter->eeprompriv.mac_addr, ETH_ALEN); -+ _rtw_memcpy((void *)pnetdev->dev_addr, padapter->eeprompriv.mac_addr, ETH_ALEN); - #endif //CONFIG_PLATFORM_INTEL_BYT - - padapter->bDriverStopped = _FALSE; ---- a/os_dep/osdep_service.c -+++ b/os_dep/osdep_service.c -@@ -2209,7 +2209,7 @@ int rtw_change_ifname(_adapter *padapter - - rtw_init_netdev_name(pnetdev, ifname); - -- _rtw_memcpy(pnetdev->dev_addr, padapter->eeprompriv.mac_addr, ETH_ALEN); -+ _rtw_memcpy((void *)pnetdev->dev_addr, padapter->eeprompriv.mac_addr, ETH_ALEN); - - #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)) - if(!rtnl_is_locked()) diff --git a/package/kernel/rtl8812au-ct/patches/010-os_dep-linux-proc-move-to-pde_data-function.patch b/package/kernel/rtl8812au-ct/patches/010-os_dep-linux-proc-move-to-pde_data-function.patch deleted file mode 100644 index 1c62e77d1b0..00000000000 --- a/package/kernel/rtl8812au-ct/patches/010-os_dep-linux-proc-move-to-pde_data-function.patch +++ /dev/null @@ -1,26 +0,0 @@ -From f455198acaa71c2963746a6b17c878c7d1d0e331 Mon Sep 17 00:00:00 2001 -From: Christian Marangi -Date: Sun, 30 Jul 2023 11:22:58 +0200 -Subject: [PATCH 5/5] os_dep/linux/proc: move to pde_data function - -PDE_DATA macro was dropped in 5.17 with the new pde_data that does the -exact thing. Fix compilation error and use new function. - -Signed-off-by: Christian Marangi ---- - os_dep/linux/rtw_proc.c | 4 ++++ - 1 file changed, 4 insertions(+) - ---- a/os_dep/linux/rtw_proc.c -+++ b/os_dep/linux/rtw_proc.c -@@ -37,6 +37,10 @@ inline struct proc_dir_entry *get_rtw_dr - #define file_inode(file) ((file)->f_dentry->d_inode) - #endif - -+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,17,0)) -+#define PDE_DATA(inode) pde_data(inode) -+#endif -+ - #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)) - #define PDE_DATA(inode) PDE((inode))->data - #define proc_get_parent_data(inode) PDE((inode))->parent->data diff --git a/package/kernel/rtl8812au-ct/patches/099-cut-linkid-linux-version-code-conditionals.patch b/package/kernel/rtl8812au-ct/patches/099-cut-linkid-linux-version-code-conditionals.patch new file mode 100644 index 00000000000..bb644a9ace4 --- /dev/null +++ b/package/kernel/rtl8812au-ct/patches/099-cut-linkid-linux-version-code-conditionals.patch @@ -0,0 +1,86 @@ +From 30fc9d96fa2ce16209306237e677d3d3cbb12685 Mon Sep 17 00:00:00 2001 +From: John Thomson +Date: Sun, 28 May 2023 13:26:46 +1000 +Subject: [PATCH] Revert "fix kernel 6.1 80211 link_id" + +This reverts commit a027da58e8d8e95827f97222ca321cd0b2d377dd. +--- + os_dep/linux/ioctl_cfg80211.c | 29 +++++------------------------ + 1 file changed, 5 insertions(+), 24 deletions(-) + +--- a/os_dep/linux/ioctl_cfg80211.c ++++ b/os_dep/linux/ioctl_cfg80211.c +@@ -797,14 +797,9 @@ check_bss: + #endif + + DBG_871X(FUNC_ADPT_FMT" call cfg80211_roamed\n", FUNC_ADPT_ARG(padapter)); +-#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 0, 0) +- roam_info.links[0].channel = notify_channel; +- roam_info.links[0].bssid = cur_network->network.MacAddress; +-#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0) ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0) + roam_info.channel = notify_channel; + roam_info.bssid = cur_network->network.MacAddress; +-#endif +-#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0) + roam_info.req_ie = pmlmepriv->assoc_req + sizeof(struct rtw_ieee80211_hdr_3addr) + 2; + roam_info.req_ie_len = pmlmepriv->assoc_req_len - sizeof(struct rtw_ieee80211_hdr_3addr) - 2; + roam_info.resp_ie = pmlmepriv->assoc_rsp + sizeof(struct rtw_ieee80211_hdr_3addr) + 6; +@@ -1393,9 +1388,7 @@ exit: + } + + static int cfg80211_rtw_add_key(struct wiphy *wiphy, struct net_device *ndev, +-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)) +- int link_id, u8 key_index, bool pairwise, const u8 *mac_addr, +-#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) || defined(COMPAT_KERNEL_RELEASE) ++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) || defined(COMPAT_KERNEL_RELEASE) + u8 key_index, bool pairwise, const u8 *mac_addr, + #else // (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) + u8 key_index, const u8 *mac_addr, +@@ -1535,9 +1528,7 @@ addkey_end: + } + + static int cfg80211_rtw_get_key(struct wiphy *wiphy, struct net_device *ndev, +-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)) +- int link_id, u8 key_index, bool pairwise, const u8 *mac_addr, +-#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) || defined(COMPAT_KERNEL_RELEASE) ++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) || defined(COMPAT_KERNEL_RELEASE) + u8 key_index, bool pairwise, const u8 *mac_addr, + #else // (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) + u8 key_index, const u8 *mac_addr, +@@ -1570,9 +1561,7 @@ static int cfg80211_rtw_get_key(struct w + } + + static int cfg80211_rtw_del_key(struct wiphy *wiphy, struct net_device *ndev, +-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)) +- int link_id, u8 key_index, bool pairwise, const u8 *mac_addr) +-#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) || defined(COMPAT_KERNEL_RELEASE) ++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) || defined(COMPAT_KERNEL_RELEASE) + u8 key_index, bool pairwise, const u8 *mac_addr) + #else // (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) + u8 key_index, const u8 *mac_addr) +@@ -1592,11 +1581,7 @@ static int cfg80211_rtw_del_key(struct w + } + + static int cfg80211_rtw_set_default_key(struct wiphy *wiphy, +- struct net_device *ndev, +-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)) +- int link_id, +-#endif +- u8 key_index ++ struct net_device *ndev, u8 key_index + #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) || defined(COMPAT_KERNEL_RELEASE) + , bool unicast, bool multicast + #endif +@@ -4033,11 +4018,7 @@ static int cfg80211_rtw_change_beacon(st + return ret; + } + +-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6,0,0)) +-static int cfg80211_rtw_stop_ap(struct wiphy *wiphy, struct net_device *ndev, unsigned int link_id) +-#else + static int cfg80211_rtw_stop_ap(struct wiphy *wiphy, struct net_device *ndev) +-#endif + { + DBG_871X(FUNC_NDEV_FMT"\n", FUNC_NDEV_ARG(ndev)); + return 0; diff --git a/package/kernel/rtl8812au-ct/patches/100-api_update.patch b/package/kernel/rtl8812au-ct/patches/100-api_update.patch index 2c081256ed7..e7ca4b05f34 100644 --- a/package/kernel/rtl8812au-ct/patches/100-api_update.patch +++ b/package/kernel/rtl8812au-ct/patches/100-api_update.patch @@ -44,7 +44,7 @@ #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) || defined(COMPAT_KERNEL_RELEASE) , bool unicast, bool multicast #endif -@@ -4019,7 +4022,8 @@ static int cfg80211_rtw_change_beacon(st +@@ -4018,7 +4021,8 @@ static int cfg80211_rtw_change_beacon(st return ret; } From 8ae861221042057b8a986cd0a47ecf88bd2fc2b2 Mon Sep 17 00:00:00 2001 From: Robert Marko Date: Sun, 13 Aug 2023 15:58:47 +0200 Subject: [PATCH 13/20] ipq40xx: qca8k: add ageing setting support qca8k driver we are currently based of is rather out of date and is lacking support for setting the ageing time or fast ageing so until we update the driver lets just backport support for those from qca8k. Signed-off-by: Robert Marko --- .../files/drivers/net/dsa/qca/qca8k-ipq4019.c | 32 +++++++++++++++++++ .../files/drivers/net/dsa/qca/qca8k-ipq4019.h | 4 +++ 2 files changed, 36 insertions(+) diff --git a/target/linux/ipq40xx/files/drivers/net/dsa/qca/qca8k-ipq4019.c b/target/linux/ipq40xx/files/drivers/net/dsa/qca/qca8k-ipq4019.c index 202d1a582cb..0526445d653 100644 --- a/target/linux/ipq40xx/files/drivers/net/dsa/qca/qca8k-ipq4019.c +++ b/target/linux/ipq40xx/files/drivers/net/dsa/qca/qca8k-ipq4019.c @@ -7,6 +7,7 @@ * Copyright (c) 2021 Robert Marko */ +#include #include #include #include @@ -1330,6 +1331,35 @@ qca8k_port_bridge_leave(struct dsa_switch *ds, int port, struct net_device *br) QCA8K_PORT_LOOKUP_MEMBER, BIT(cpu_port)); } +void qca8k_port_fast_age(struct dsa_switch *ds, int port) +{ + struct qca8k_priv *priv = ds->priv; + + mutex_lock(&priv->reg_mutex); + qca8k_fdb_access(priv, QCA8K_FDB_FLUSH_PORT, port); + mutex_unlock(&priv->reg_mutex); +} + +int qca8k_set_ageing_time(struct dsa_switch *ds, unsigned int msecs) +{ + struct qca8k_priv *priv = ds->priv; + unsigned int secs = msecs / 1000; + u32 val; + + /* AGE_TIME reg is set in 7s step */ + val = secs / 7; + + /* Handle case with 0 as val to NOT disable + * learning + */ + if (!val) + val = 1; + + return qca8k_rmw(priv, QCA8K_REG_ATU_CTRL, + QCA8K_ATU_AGE_TIME_MASK, + QCA8K_ATU_AGE_TIME(val)); +} + static int qca8k_port_enable(struct dsa_switch *ds, int port, struct phy_device *phy) @@ -1509,6 +1539,7 @@ static const struct dsa_switch_ops qca8k_switch_ops = { .get_strings = qca8k_get_strings, .get_ethtool_stats = qca8k_get_ethtool_stats, .get_sset_count = qca8k_get_sset_count, + .set_ageing_time = qca8k_set_ageing_time, .get_mac_eee = qca8k_get_mac_eee, .set_mac_eee = qca8k_set_mac_eee, .port_enable = qca8k_port_enable, @@ -1518,6 +1549,7 @@ static const struct dsa_switch_ops qca8k_switch_ops = { .port_stp_state_set = qca8k_port_stp_state_set, .port_bridge_join = qca8k_port_bridge_join, .port_bridge_leave = qca8k_port_bridge_leave, + .port_fast_age = qca8k_port_fast_age, .port_fdb_add = qca8k_port_fdb_add, .port_fdb_del = qca8k_port_fdb_del, .port_fdb_dump = qca8k_port_fdb_dump, diff --git a/target/linux/ipq40xx/files/drivers/net/dsa/qca/qca8k-ipq4019.h b/target/linux/ipq40xx/files/drivers/net/dsa/qca/qca8k-ipq4019.h index 1133501335b..1e1f45a443e 100644 --- a/target/linux/ipq40xx/files/drivers/net/dsa/qca/qca8k-ipq4019.h +++ b/target/linux/ipq40xx/files/drivers/net/dsa/qca/qca8k-ipq4019.h @@ -128,6 +128,9 @@ #define QCA8K_VTU_FUNC1_BUSY BIT(31) #define QCA8K_VTU_FUNC1_VID_S 16 #define QCA8K_VTU_FUNC1_FULL BIT(4) +#define QCA8K_REG_ATU_CTRL 0x618 +#define QCA8K_ATU_AGE_TIME_MASK GENMASK(15, 0) +#define QCA8K_ATU_AGE_TIME(x) FIELD_PREP(QCA8K_ATU_AGE_TIME_MASK, (x)) #define QCA8K_REG_GLOBAL_FW_CTRL0 0x620 #define QCA8K_GLOBAL_FW_CTRL0_CPU_PORT_EN BIT(10) #define QCA8K_REG_GLOBAL_FW_CTRL1 0x624 @@ -240,6 +243,7 @@ enum qca8k_fdb_cmd { QCA8K_FDB_FLUSH = 1, QCA8K_FDB_LOAD = 2, QCA8K_FDB_PURGE = 3, + QCA8K_FDB_FLUSH_PORT = 5, QCA8K_FDB_NEXT = 6, QCA8K_FDB_SEARCH = 7, }; From 4d79a65d607c471eab04a3821000d1a37440da33 Mon Sep 17 00:00:00 2001 From: Thomas Kupper Date: Fri, 5 May 2023 17:04:33 +0200 Subject: [PATCH 14/20] ipq807x: add support for Netgear RAX120v2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Netgear Nighthawk RAX120v2 AX WIFI router with 5 1G and 1 5G ports. The majority of the code is based on @jewwest's PR #11830. Specifications: * CPU: Qualcomm IPQ8074 Quad core Cortex-A53 2.2GHz * RAM: 1024MB of DDR3 (Nanya NT5CC256M16EP-EK × 2) * Flash: SPI-NAND 512 MiB (Winbond W29N04GZBIBA) * Ethernet: 4x 10/100/1000 Mbps LAN, 1x 10/100/1000 Mbps WAN (Qualcomm QCA8075), 1x 10/100/1000/2500/5000 Mbps LAN/WAN (Aquantia AQR111B0 PHY) * Wi-Fi: * 2.4 GHz: Qualcomm QCN5024 4x4 * 2x 5 GHz: Qualcomm QCN5054 4x4 * USB: 2x USB 3.0 * LEDs: Power, 2.4GHz & 5GHz Radio, WPS, WAN, USB1 & USB2, 5G LAN * Keys: LEDs On/Off, Power, Reset, RFKILL, WPS * UART: Marked J9003 VCC TX RX GND, beginning from "1". 3.3v, 115200n8 * Power: 19 VDC, 3.1 A Installation: * Flashing OpenWrt is done in two steps: a) Flash *-squashfs-web-ui-factory.img from stock UI (thanks to @wangyu-). This writes an initramfs based OpenWrt image onto the RAX120v2 b) From OpenWrt flash the *-squashfs-sysupgrade.bin using LuCI or the commandline * U-Boot allows booting an initramfs image via TFTP: - Set ip of your PC to 192.168.1.100 - At the serial console interrupt boot at "Hit any key to stop autoboot:" - In u-boot run `tftpsrv` - On your PC send the OpenWrt initramfs image: tftp 192.168.1.1 -m binary -c put openwrt-ipq807x-generic-netgear_rax120v2-initramfs-uImage.itb Make 5G Aquantia phy work: For the 5G port labeled 'lan5' to work a firmware is needed. This can be loaded in u-boot by writing the firmware to the correct mtd partition. The firmware file found in the Netgear stock firmware under /lib/firmware/ named 'AQR-G3_v4.3.C-AQR_DNI_DR-EQ35AX8-R-prov1_ID23888_VER1311.cld' is needed and has to be converted to a MBN file. The `mkheader.py` script used here can be found in the Netgear V1.2.8.40 GPL source, under 'git_home/u-boot.git/tools/mkheader.py' Convert the CLD file to MBN using: $ python2 mkheader.py 0x44000000 0x13 <*.cld file> aqr_4.3.C.mbn This MBN file can then be flashed to the MTD partition to be used by u-boot. The necessary files can also be found in https://github.com/boretom/openwrt-fork/tree/rax120v2/aquantia-firmware * Write MBN file to MTD partition to be loaded automatically by u-boot: U-boot automatically tries to load the firmware from nand at address 0x7e00000 which corresponds to `/dev/mtd25` in OpenWrt. - find ETHPHYFW partition while running OpenWrt (expected: /dev/mtd25) $ fgrep -i 'ethphyfw' /proc/mtd mtd25: 00080000 00020000 "ethphyfw - copy mbn file to /tmp/ folder of the router $ scp aqr-v4.3.C.mbn 192.168.1.1:/tmp/ - write mbn file to ethphyfw partition $ mtd write /tmp/aqr_v4.3.C.mbn /dev/mtd25 Revert to stock firmware: * Flash the stock firmware to the bootloader using TFTP/NMRP. References to RAX120v2 GPL source: https://www.downloads.netgear.com/files/GPL/RAX120-V1.2.8.40_gpl_src.zip Reviewed-by: Robert Marko Signed-off-by: Thomas Kupper --- .../uboot-envtools/files/qualcommax_ipq807x | 1 + package/firmware/ipq-wifi/Makefile | 2 + ...-aquantia-enable-AQR111-and-AQR111B0.patch | 109 ++++ ...-aquantia-enable-AQR111-and-AQR111B0.patch | 110 ++++ .../arm64/boot/dts/qcom/ipq8074-rax120v2.dts | 553 ++++++++++++++++++ target/linux/qualcommax/image/ipq807x.mk | 24 + .../ipq807x/base-files/etc/board.d/01_leds | 3 + .../ipq807x/base-files/etc/board.d/02_network | 3 + .../etc/hotplug.d/firmware/11-ath11k-caldata | 1 + .../base-files/lib/upgrade/platform.sh | 1 + 10 files changed, 807 insertions(+) create mode 100644 target/linux/generic/hack-5.15/726-net-phy-aquantia-enable-AQR111-and-AQR111B0.patch create mode 100644 target/linux/generic/hack-6.1/726-net-phy-aquantia-enable-AQR111-and-AQR111B0.patch create mode 100644 target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq8074-rax120v2.dts diff --git a/package/boot/uboot-envtools/files/qualcommax_ipq807x b/package/boot/uboot-envtools/files/qualcommax_ipq807x index 345cdadebee..297c7278579 100644 --- a/package/boot/uboot-envtools/files/qualcommax_ipq807x +++ b/package/boot/uboot-envtools/files/qualcommax_ipq807x @@ -9,6 +9,7 @@ board=$(board_name) case "$board" in dynalink,dl-wrx36|\ +netgear,rax120v2|\ netgear,wax218) idx="$(find_mtd_index 0:appsblenv)" [ -n "$idx" ] && \ diff --git a/package/firmware/ipq-wifi/Makefile b/package/firmware/ipq-wifi/Makefile index 1e4b3a95c20..aa1466418ed 100644 --- a/package/firmware/ipq-wifi/Makefile +++ b/package/firmware/ipq-wifi/Makefile @@ -33,6 +33,7 @@ ALLWIFIBOARDS:= \ dynalink_dl-wrx36 \ edgecore_eap102 \ edimax_cax1800 \ + netgear_rax120v2 \ netgear_wax218 \ prpl_haze \ qnap_301w \ @@ -121,6 +122,7 @@ $(eval $(call generate-ipq-wifi-package,compex_wpq873,Compex WPQ-873)) $(eval $(call generate-ipq-wifi-package,dynalink_dl-wrx36,Dynalink DL-WRX36)) $(eval $(call generate-ipq-wifi-package,edgecore_eap102,Edgecore EAP102)) $(eval $(call generate-ipq-wifi-package,edimax_cax1800,Edimax CAX1800)) +$(eval $(call generate-ipq-wifi-package,netgear_rax120v2,Netgear RAX120v2)) $(eval $(call generate-ipq-wifi-package,netgear_wax218,Netgear WAX218)) $(eval $(call generate-ipq-wifi-package,qnap_301w,QNAP 301w)) $(eval $(call generate-ipq-wifi-package,prpl_haze,prpl Haze)) diff --git a/target/linux/generic/hack-5.15/726-net-phy-aquantia-enable-AQR111-and-AQR111B0.patch b/target/linux/generic/hack-5.15/726-net-phy-aquantia-enable-AQR111-and-AQR111B0.patch new file mode 100644 index 00000000000..e14a5f17477 --- /dev/null +++ b/target/linux/generic/hack-5.15/726-net-phy-aquantia-enable-AQR111-and-AQR111B0.patch @@ -0,0 +1,109 @@ +Author: Thomas Kupper +Date: Wed May 24 21:14:17 2023 +0200 + +kernel: phy: add Aquantia PHY AQR111 & AQR111B0 + +Add the IDs for Aquantia PHY AQR111 and AQR111B0 as found in the GPL sources +of the Netgear RAX120v2 firmware v1.2.8.40. + +This is a 5GbE chip but it reports support for 10G. Implement config_init() +to set max speed to 5G. + +Signed-off-by: Thomas Kupper +--- a/drivers/net/phy/aquantia_main.c ++++ b/drivers/net/phy/aquantia_main.c +@@ -20,6 +20,8 @@ + #define PHY_ID_AQR105 0x03a1b4a2 + #define PHY_ID_AQR106 0x03a1b4d0 + #define PHY_ID_AQR107 0x03a1b4e0 ++#define PHY_ID_AQR111 0x03a1b610 ++#define PHY_ID_AQR111B0 0x03a1b612 + #define PHY_ID_AQR112 0x03a1b662 + #define PHY_ID_AQR112C 0x03a1b790 + #define PHY_ID_AQR112R 0x31c31d12 +@@ -686,6 +688,33 @@ static int aqcs109_config_init(struct ph + return aqr107_set_downshift(phydev, MDIO_AN_VEND_PROV_DOWNSHIFT_DFLT); + } + ++static int aqr111_config_init(struct phy_device *phydev) ++{ ++ int ret; ++ ++ /* Check that the PHY interface type is compatible */ ++ if (phydev->interface != PHY_INTERFACE_MODE_SGMII && ++ phydev->interface != PHY_INTERFACE_MODE_2500BASEX && ++ phydev->interface != PHY_INTERFACE_MODE_XGMII && ++ phydev->interface != PHY_INTERFACE_MODE_USXGMII && ++ phydev->interface != PHY_INTERFACE_MODE_10GKR && ++ phydev->interface != PHY_INTERFACE_MODE_10GBASER) ++ return -ENODEV; ++ ++ WARN(phydev->interface == PHY_INTERFACE_MODE_XGMII, ++ "Your devicetree is out of date, please update it. The AQR107 family doesn't support XGMII, maybe you mean USXGMII.\n"); ++ ++ ret = aqr107_wait_reset_complete(phydev); ++ if (!ret) ++ aqr107_chip_info(phydev); ++ ++ /* AQR111 reports supporting speed up to 10G, however only speeds up to 5G are supported. */ ++ ret = phy_set_max_speed(phydev, SPEED_5000); ++ if (ret) ++ return ret; ++ ++ return aqr107_set_downshift(phydev, MDIO_AN_VEND_PROV_DOWNSHIFT_DFLT); ++} + static void aqr107_link_change_notify(struct phy_device *phydev) + { + u8 fw_major, fw_minor; +@@ -905,6 +934,42 @@ static struct phy_driver aqr_driver[] = + .link_change_notify = aqr107_link_change_notify, + }, + { ++ PHY_ID_MATCH_MODEL(PHY_ID_AQR111), ++ .name = "Aquantia AQR111", ++ .probe = aqr107_probe, ++ .config_init = aqr111_config_init, ++ .config_aneg = aqr_config_aneg, ++ .config_intr = aqr_config_intr, ++ .handle_interrupt = aqr_handle_interrupt, ++ .read_status = aqr107_read_status, ++ .get_tunable = aqr107_get_tunable, ++ .set_tunable = aqr107_set_tunable, ++ .suspend = aqr107_suspend, ++ .resume = aqr107_resume, ++ .get_sset_count = aqr107_get_sset_count, ++ .get_strings = aqr107_get_strings, ++ .get_stats = aqr107_get_stats, ++ .link_change_notify = aqr107_link_change_notify, ++}, ++{ ++ PHY_ID_MATCH_MODEL(PHY_ID_AQR111B0), ++ .name = "Aquantia AQR111B0", ++ .probe = aqr107_probe, ++ .config_init = aqr111_config_init, ++ .config_aneg = aqr_config_aneg, ++ .config_intr = aqr_config_intr, ++ .handle_interrupt = aqr_handle_interrupt, ++ .read_status = aqr107_read_status, ++ .get_tunable = aqr107_get_tunable, ++ .set_tunable = aqr107_set_tunable, ++ .suspend = aqr107_suspend, ++ .resume = aqr107_resume, ++ .get_sset_count = aqr107_get_sset_count, ++ .get_strings = aqr107_get_strings, ++ .get_stats = aqr107_get_stats, ++ .link_change_notify = aqr107_link_change_notify, ++}, ++{ + PHY_ID_MATCH_MODEL(PHY_ID_AQR112), + .name = "Aquantia AQR112", + .probe = aqr107_probe, +@@ -970,6 +1035,8 @@ static struct mdio_device_id __maybe_unu + { PHY_ID_MATCH_MODEL(PHY_ID_AQR105) }, + { PHY_ID_MATCH_MODEL(PHY_ID_AQR106) }, + { PHY_ID_MATCH_MODEL(PHY_ID_AQR107) }, ++ { PHY_ID_MATCH_MODEL(PHY_ID_AQR111) }, ++ { PHY_ID_MATCH_MODEL(PHY_ID_AQR111B0) }, + { PHY_ID_MATCH_MODEL(PHY_ID_AQR112) }, + { PHY_ID_MATCH_MODEL(PHY_ID_AQR112C) }, + { PHY_ID_MATCH_MODEL(PHY_ID_AQR112R) }, diff --git a/target/linux/generic/hack-6.1/726-net-phy-aquantia-enable-AQR111-and-AQR111B0.patch b/target/linux/generic/hack-6.1/726-net-phy-aquantia-enable-AQR111-and-AQR111B0.patch new file mode 100644 index 00000000000..dc25905fee1 --- /dev/null +++ b/target/linux/generic/hack-6.1/726-net-phy-aquantia-enable-AQR111-and-AQR111B0.patch @@ -0,0 +1,110 @@ +Author: Thomas Kupper +Date: Wed May 24 21:14:17 2023 +0200 + +kernel: phy: add Aquantia PHY AQR111 & AQR111B0 + +Add the IDs for Aquantia PHY AQR111 and AQR111B0 as found in the GPL sources +of the Netgear RAX120v2 firmware v1.2.8.40. + +This is a 5GbE chip but it reports support for 10G. Implement config_init() +to set max speed to 5G. + +Signed-off-by: Thomas Kupper +--- a/drivers/net/phy/aquantia_main.c ++++ b/drivers/net/phy/aquantia_main.c +@@ -24,6 +24,8 @@ + #define PHY_ID_AQR405 0x03a1b4b0 + #define PHY_ID_AQR113C 0x31c31c12 + #define PHY_ID_AQR813 0x31c31cb2 ++#define PHY_ID_AQR111 0x03a1b610 ++#define PHY_ID_AQR111B0 0x03a1b612 + #define PHY_ID_AQR112 0x03a1b662 + #define PHY_ID_AQR412 0x03a1b712 + #define PHY_ID_AQR113 0x31c31c40 +@@ -729,6 +731,34 @@ static int aqcs109_config_init(struct ph + return aqr107_set_downshift(phydev, MDIO_AN_VEND_PROV_DOWNSHIFT_DFLT); + } + ++static int aqr111_config_init(struct phy_device *phydev) ++{ ++ int ret; ++ ++ /* Check that the PHY interface type is compatible */ ++ if (phydev->interface != PHY_INTERFACE_MODE_SGMII && ++ phydev->interface != PHY_INTERFACE_MODE_1000BASEKX && ++ phydev->interface != PHY_INTERFACE_MODE_2500BASEX && ++ phydev->interface != PHY_INTERFACE_MODE_XGMII && ++ phydev->interface != PHY_INTERFACE_MODE_USXGMII && ++ phydev->interface != PHY_INTERFACE_MODE_10GKR && ++ phydev->interface != PHY_INTERFACE_MODE_10GBASER && ++ phydev->interface != PHY_INTERFACE_MODE_XAUI && ++ phydev->interface != PHY_INTERFACE_MODE_RXAUI) ++ return -ENODEV; ++ ++ WARN(phydev->interface == PHY_INTERFACE_MODE_XGMII, ++ "Your devicetree is out of date, please update it. The AQR107 family doesn't support XGMII, maybe you mean USXGMII.\n"); ++ ++ ret = aqr107_wait_reset_complete(phydev); ++ if (!ret) ++ aqr107_chip_info(phydev); ++ ++ /* AQR111 reports supporting speed up to 10G, however only speeds up to 5G are supported. */ ++ phy_set_max_speed(phydev, SPEED_5000); ++ ++ return aqr107_set_downshift(phydev, MDIO_AN_VEND_PROV_DOWNSHIFT_DFLT); ++} + static void aqr107_link_change_notify(struct phy_device *phydev) + { + u8 fw_major, fw_minor; +@@ -961,6 +991,42 @@ static struct phy_driver aqr_driver[] = + .link_change_notify = aqr107_link_change_notify, + }, + { ++ PHY_ID_MATCH_MODEL(PHY_ID_AQR111), ++ .name = "Aquantia AQR111", ++ .probe = aqr107_probe, ++ .config_init = aqr111_config_init, ++ .config_aneg = aqr_config_aneg, ++ .config_intr = aqr_config_intr, ++ .handle_interrupt = aqr_handle_interrupt, ++ .read_status = aqr107_read_status, ++ .get_tunable = aqr107_get_tunable, ++ .set_tunable = aqr107_set_tunable, ++ .suspend = aqr107_suspend, ++ .resume = aqr107_resume, ++ .get_sset_count = aqr107_get_sset_count, ++ .get_strings = aqr107_get_strings, ++ .get_stats = aqr107_get_stats, ++ .link_change_notify = aqr107_link_change_notify, ++}, ++{ ++ PHY_ID_MATCH_MODEL(PHY_ID_AQR111B0), ++ .name = "Aquantia AQR111B0", ++ .probe = aqr107_probe, ++ .config_init = aqr111_config_init, ++ .config_aneg = aqr_config_aneg, ++ .config_intr = aqr_config_intr, ++ .handle_interrupt = aqr_handle_interrupt, ++ .read_status = aqr107_read_status, ++ .get_tunable = aqr107_get_tunable, ++ .set_tunable = aqr107_set_tunable, ++ .suspend = aqr107_suspend, ++ .resume = aqr107_resume, ++ .get_sset_count = aqr107_get_sset_count, ++ .get_strings = aqr107_get_strings, ++ .get_stats = aqr107_get_stats, ++ .link_change_notify = aqr107_link_change_notify, ++}, ++{ + PHY_ID_MATCH_MODEL(PHY_ID_AQR112), + .name = "Aquantia AQR112", + .probe = aqr107_probe, +@@ -1030,6 +1096,8 @@ static struct mdio_device_id __maybe_unu + { PHY_ID_MATCH_MODEL(PHY_ID_AQR405) }, + { PHY_ID_MATCH_MODEL(PHY_ID_AQR113C) }, + { PHY_ID_MATCH_MODEL(PHY_ID_AQR813) }, ++ { PHY_ID_MATCH_MODEL(PHY_ID_AQR111) }, ++ { PHY_ID_MATCH_MODEL(PHY_ID_AQR111B0) }, + { PHY_ID_MATCH_MODEL(PHY_ID_AQR112) }, + { PHY_ID_MATCH_MODEL(PHY_ID_AQR412) }, + { PHY_ID_MATCH_MODEL(PHY_ID_AQR113) }, diff --git a/target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq8074-rax120v2.dts b/target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq8074-rax120v2.dts new file mode 100644 index 00000000000..188ad03fe04 --- /dev/null +++ b/target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq8074-rax120v2.dts @@ -0,0 +1,553 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +/dts-v1/; + +#include "ipq8074.dtsi" +#include "ipq8074-ess.dtsi" +#include "ipq8074-hk-cpu.dtsi" +#include +#include +#include + +/ { + model = "Netgear RAX120v2"; + compatible = "netgear,rax120v2", "qcom,ipq8074"; + + aliases { + serial0 = &blsp1_uart5; + + led-running = &led_system_white; + led-upgrade = &led_system_white; + led-internet = &led_wan_white; + label-mac-device = &dp1; + }; + + chosen { + stdout-path = "serial0:115200n8"; + bootargs-append = " ubi.mtd=rootfs root=/dev/ubiblock0_0"; + }; + + keys { + compatible = "gpio-keys"; + + rfkill { + label = "rfkill"; + gpios = <&tlmm 25 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + wps { + label = "wps"; + gpios = <&tlmm 57 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + reset { + label = "reset"; + gpios = <&tlmm 54 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + led_spi { + compatible = "spi-gpio"; + #address-cells = <1>; + #size-cells = <0>; + + sck-gpios = <&tlmm 18 GPIO_ACTIVE_HIGH>; + mosi-gpios = <&tlmm 19 GPIO_ACTIVE_HIGH>; + + led_gpio: led_gpio@0 { + compatible = "fairchild,74hc595"; + reg = <0>; + gpio-controller; + #gpio-cells = <2>; + registers-number = <2>; + enable-gpios = <&tlmm 20 GPIO_ACTIVE_HIGH>; + spi-max-frequency = <1000000>; + }; + }; + + leds { + compatible = "gpio-leds"; + + led_system_white: system-white { + label = "white:system"; + gpios = <&led_gpio 0 GPIO_ACTIVE_LOW>; + color = ; + }; + + led_24g_white { + label = "white:24g"; + gpios = <&led_gpio 1 GPIO_ACTIVE_LOW>; + color = ; + linux,default-trigger = "phy1radio"; + }; + + led_5g_white { + label = "white:5g"; + gpios = <&led_gpio 2 GPIO_ACTIVE_LOW>; + color = ; + linux,default-trigger = "phy0radio"; + }; + + led_usb1_white { + label = "white:usb1"; + gpios = <&led_gpio 3 GPIO_ACTIVE_LOW>; + color = ; + }; + + led_usb2_white { + label = "white:usb2"; + gpios = <&led_gpio 4 GPIO_ACTIVE_LOW>; + color = ; + }; + + led_wan_white: wan-white { + label = "white:wan"; + gpios = <&led_gpio 5 GPIO_ACTIVE_LOW>; + color = ; + }; + + led_aqr_green { + label = "green:aqr"; + gpios = <&led_gpio 6 GPIO_ACTIVE_LOW>; + color = ; + }; + + led_aqr_red { + label = "red:aqr"; + gpios = <&led_gpio 10 GPIO_ACTIVE_LOW>; + color = ; + }; + + led_aqr_white { + label = "white:aqr"; + gpios = <&led_gpio 11 GPIO_ACTIVE_LOW>; + color = ; + }; + + led_wps_white { + label = "white:wps"; + gpios = <&tlmm 40 GPIO_ACTIVE_HIGH>; + color = ; + }; + }; +}; + +&tlmm { + mdio_pins: mdio-pins { + mdc { + pins = "gpio68"; + function = "mdc"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio { + pins = "gpio69"; + function = "mdio"; + drive-strength = <8>; + bias-pull-up; + }; + }; +}; + +&mdio { + status = "okay"; + + pinctrl-0 = <&mdio_pins>; + pinctrl-names = "default"; + reset-gpios = <&tlmm 37 GPIO_ACTIVE_LOW>; + + qca8075_0: ethernet-phy@0 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <0>; + }; + + qca8075_1: ethernet-phy@1 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <1>; + }; + + qca8075_2: ethernet-phy@2 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <2>; + }; + + qca8075_3: ethernet-phy@3 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <3>; + }; + + qca8075_4: ethernet-phy@4 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <4>; + }; + + aqr111b0: ethernet-phy@7 { + compatible ="ethernet-phy-ieee802.3-c45"; + reg = <7>; + reset-gpios = <&tlmm 59 GPIO_ACTIVE_LOW>; + }; +}; + +&switch { + status = "okay"; + + switch_lan_bmp = <0x3e>; /* lan port bitmap */ + switch_wan_bmp = <0x40>; /* wan port bitmap */ + switch_mac_mode = <0x0>; /* mac mode for uniphy instance0*/ + switch_mac_mode1 = <0xff>; /* mac mode for uniphy instance1*/ + switch_mac_mode2 = <0xd>; /* mac mode for uniphy instance2*/ + bm_tick_mode = <0>; /* bm tick mode */ + tm_tick_mode = <0>; /* tm tick mode */ + + qcom,port_phyinfo { + port@1 { + port_id = <1>; + phy_address = <0>; + }; + port@2 { + port_id = <2>; + phy_address = <1>; + }; + port@3 { + port_id = <3>; + phy_address = <2>; + }; + port@4 { + port_id = <4>; + phy_address = <3>; + }; + port@5 { + port_id = <5>; + phy_address = <4>; + }; + port@6 { + port_id = <6>; + phy_address = <7>; + compatible = "ethernet-phy-ieee802.3-c45"; + ethernet-phy-ieee802.3-c45; + }; + }; +}; + +&edma { + status = "okay"; +}; + +&dp1 { + status = "okay"; + phy-handle = <&qca8075_0>; + label = "lan4"; + nvmem-cells = <&macaddr_dp1>; + nvmem-cell-names = "mac-address"; +}; + +&dp2 { + status = "okay"; + phy-handle = <&qca8075_1>; + label = "lan3"; + nvmem-cells = <&macaddr_dp2>; + nvmem-cell-names = "mac-address"; +}; + +&dp3 { + status = "okay"; + phy-handle = <&qca8075_2>; + label = "lan2"; + nvmem-cells = <&macaddr_dp3>; + nvmem-cell-names = "mac-address"; +}; + +&dp4 { + status = "okay"; + phy-handle = <&qca8075_3>; + label = "lan1"; + nvmem-cells = <&macaddr_dp4>; + nvmem-cell-names = "mac-address"; +}; + +&dp5 { + status = "okay"; + phy-handle = <&qca8075_4>; + label = "wan"; + nvmem-cells = <&macaddr_dp5>; + nvmem-cell-names = "mac-address"; +}; + +&dp6_syn { + status = "okay"; + phy-handle = <&aqr111b0>; + label = "lan5"; + nvmem-cells = <&macaddr_dp6_syn>; + nvmem-cell-names = "mac-address"; +}; + +&blsp1_uart5 { + status = "okay"; +}; + +&blsp1_i2c2 { + status = "okay"; + + g761@3e { + compatible = "gmt,g763"; + reg = <0x3e>; + clocks =<&sleep_clk>; + fan_gear_mode = <0>; + fan_start = <1>; + pwm_polarity = <0>; + }; +}; + +&qpic_bam { + status = "okay"; +}; + +&qpic_nand { + status = "okay"; + + nand@0 { + reg = <0>; + nand-ecc-strength = <4>; + nand-ecc-step-size = <512>; + nand-bus-width = <8>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "0:sbl1"; + reg = <0x00 0x100000>; + read-only; + }; + + partition@100000 { + label = "0:mibib"; + reg = <0x100000 0x100000>; + read-only; + }; + + partition@200000 { + label = "0:bootconfig"; + reg = <0x200000 0x80000>; + read-only; + }; + + partition@280000 { + label = "0:bootconfig_1"; + reg = <0x280000 0x80000>; + read-only; + }; + + partition@300000 { + label = "0:qsee"; + reg = <0x300000 0x300000>; + read-only; + }; + + partition@600000 { + label = "0:qsee_1"; + reg = <0x600000 0x300000>; + read-only; + }; + + partition@900000 { + label = "0:devcfg"; + reg = <0x900000 0x80000>; + read-only; + }; + + partition@980000 { + label = "0:devcfg_1"; + reg = <0x980000 0x80000>; + read-only; + }; + + partition@a00000 { + label = "0:apdp"; + reg = <0xa00000 0x80000>; + read-only; + }; + + partition@a80000 { + label = "0:apdp_1"; + reg = <0xa80000 0x80000>; + read-only; + }; + + partition@b00000 { + label = "0:rpm"; + reg = <0xb00000 0x80000>; + read-only; + }; + + partition@b80000 { + label = "0:rpm_1"; + reg = <0xb80000 0x80000>; + read-only; + }; + + partition@c00000 { + label = "0:cdt"; + reg = <0xc00000 0x80000>; + read-only; + }; + + partition@c80000 { + label = "0:cdt_1"; + reg = <0xc80000 0x80000>; + read-only; + }; + + partition@d00000 { + label = "0:appsblenv"; + reg = <0xd00000 0x80000>; + }; + + partition@d80000 { + label = "0:appsbl"; + reg = <0xd80000 0x100000>; + read-only; + }; + + partition@e80000 { + label = "0:appsbl_1"; + reg = <0xe80000 0x100000>; + read-only; + }; + + partition@f80000 { + label = "0:art"; + reg = <0xf80000 0x80000>; + read-only; + }; + + partition@1000000 { + label = "0:art.bak"; + reg = <0x1000000 0x0080000>; + read-only; + }; + + partition@1080000 { + label = "config"; + reg = <0x1080000 0x0100000>; + read-only; + }; + + partition@1180000 { + label = "boarddata1"; + reg = <0x1180000 0x0100000>; + read-only; + + compatible = "nvmem-cells"; + #address-cells = <1>; + #size-cells = <1>; + + macaddr_dp1: macaddr@0 { + reg = <0x0 0x6>; + }; + + macaddr_dp2: macaddr@1 { + reg = <0x6 0x6>; + }; + + macaddr_dp3: macaddr@2 { + reg = <0xc 0x6>; + }; + + macaddr_dp4: macaddr@3 { + reg = <0x12 0x6>; + }; + + macaddr_dp5: macaddr@4 { + reg = <0x18 0x6>; + }; + + macaddr_dp6_syn: macaddr@5 { + reg = <0x1e 0x6>; + }; + + }; + + partition@1280000 { + label = "boarddata2"; + reg = <0x1280000 0x0100000>; + read-only; + }; + + partition@1380000 { + label = "pot"; + reg = <0x1380000 0x0100000>; + read-only; + }; + + partition@1480000 { + label = "dnidata"; + reg = <0x1480000 0x0500000>; + read-only; + }; + + partition@1980000 { + label = "kernel"; + reg = <0x1980000 0x1d00000>; + }; + + partition@7e00000 { + label = "ethphyfw"; + reg = <0x7e00000 0x80000>; + }; + + partition@e8800000 { + label = "rootfs"; + reg = <0xe880000 0x11780000>; + }; + }; + }; +}; + +&qusb_phy_0 { + status = "okay"; +}; + +&qusb_phy_1 { + status = "okay"; +}; + +&ssphy_0 { + status = "okay"; +}; + +&ssphy_1 { + status = "okay"; +}; + +&usb_0 { + status = "okay"; +}; + +&usb_1 { + status = "okay"; +}; + +&wifi{ + status = "okay"; + + qcom,ath11k-calibration-variant = "Netgear-RAX120v2"; +}; + +&cryptobam { + status = "okay"; +}; + +&crypto { + status = "okay"; +}; + +&prng { + status = "okay"; +}; diff --git a/target/linux/qualcommax/image/ipq807x.mk b/target/linux/qualcommax/image/ipq807x.mk index 555c723c5f4..440a2674976 100644 --- a/target/linux/qualcommax/image/ipq807x.mk +++ b/target/linux/qualcommax/image/ipq807x.mk @@ -91,6 +91,30 @@ define Device/edimax_cax1800 endef TARGET_DEVICES += edimax_cax1800 +define Device/netgear_rax120v2 + $(call Device/FitImage) + $(call Device/UbiFit) + DEVICE_VENDOR := Netgear + DEVICE_MODEL := RAX120v2 + BLOCKSIZE := 128k + PAGESIZE := 2048 + DEVICE_DTS_CONFIG := config@hk01 + SOC := ipq8074 + KERNEL_SIZE := 29696k + NETGEAR_BOARD_ID := RAX120 + NETGEAR_HW_ID := 29765589+0+512+1024+4x4+8x8 + DEVICE_PACKAGES := ipq-wifi-netgear_rax120v2 kmod-spi-gpio \ + kmod-spi-bitbang kmod-gpio-nxp-74hc164 kmod-hwmon-g761 + IMAGES = web-ui-factory.img sysupgrade.bin + IMAGE/web-ui-factory.img := append-image initramfs-uImage.itb | \ + pad-offset $$$$(BLOCKSIZE) 64 | append-uImage-fakehdr filesystem | \ + netgear-dni + IMAGE/sysupgrade.bin := append-kernel | pad-offset $$$$(BLOCKSIZE) 64 | \ + append-uImage-fakehdr filesystem | sysupgrade-tar kernel=$$$$@ | \ + append-metadata +endef +TARGET_DEVICES += netgear_rax120v2 + define Device/netgear_wax218 $(call Device/FitImage) $(call Device/UbiFit) diff --git a/target/linux/qualcommax/ipq807x/base-files/etc/board.d/01_leds b/target/linux/qualcommax/ipq807x/base-files/etc/board.d/01_leds index a89b4c15643..6e2ec60403a 100644 --- a/target/linux/qualcommax/ipq807x/base-files/etc/board.d/01_leds +++ b/target/linux/qualcommax/ipq807x/base-files/etc/board.d/01_leds @@ -9,6 +9,9 @@ case "$board" in edgecore,eap102) ucidef_set_led_netdev "wan" "WAN" "green:wanpoe" "wan" ;; +netgear,rax120v2) + ucidef_set_led_netdev "aqr" "AQR" "white:aqr" "lan5" + ;; netgear,wax218) ucidef_set_led_netdev "lan" "LAN" "blue:lan" "lan" ucidef_set_led_wlan "wlan5g" "WIFI 5GHz" "blue:wlan5g" "phy0radio" diff --git a/target/linux/qualcommax/ipq807x/base-files/etc/board.d/02_network b/target/linux/qualcommax/ipq807x/base-files/etc/board.d/02_network index 8175a99f97e..3953ae8db2e 100644 --- a/target/linux/qualcommax/ipq807x/base-files/etc/board.d/02_network +++ b/target/linux/qualcommax/ipq807x/base-files/etc/board.d/02_network @@ -22,6 +22,9 @@ ipq807x_setup_interfaces() edimax,cax1800) ucidef_set_interfaces_lan_wan "lan" ;; + netgear,rax120v2) + ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4 lan5" "wan" + ;; netgear,wax218) ucidef_set_interface_lan "lan" "dhcp" ;; diff --git a/target/linux/qualcommax/ipq807x/base-files/etc/hotplug.d/firmware/11-ath11k-caldata b/target/linux/qualcommax/ipq807x/base-files/etc/hotplug.d/firmware/11-ath11k-caldata index f9315573ec4..742730f4760 100644 --- a/target/linux/qualcommax/ipq807x/base-files/etc/hotplug.d/firmware/11-ath11k-caldata +++ b/target/linux/qualcommax/ipq807x/base-files/etc/hotplug.d/firmware/11-ath11k-caldata @@ -14,6 +14,7 @@ case "$FIRMWARE" in edgecore,eap102|\ edimax,cax1800|\ dynalink,dl-wrx36|\ + netgear,rax120v2|\ netgear,wax218|\ qnap,301w|\ redmi,ax6|\ diff --git a/target/linux/qualcommax/ipq807x/base-files/lib/upgrade/platform.sh b/target/linux/qualcommax/ipq807x/base-files/lib/upgrade/platform.sh index 458eb16b795..a7af1cc1df1 100644 --- a/target/linux/qualcommax/ipq807x/base-files/lib/upgrade/platform.sh +++ b/target/linux/qualcommax/ipq807x/base-files/lib/upgrade/platform.sh @@ -68,6 +68,7 @@ platform_do_upgrade() { ;; compex,wpq873|\ edimax,cax1800|\ + netgear,rax120v2|\ netgear,wax218) nand_do_upgrade "$1" ;; From b2e810f49588d1bbc90f657826e94b32474b482c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Mork?= Date: Tue, 28 Mar 2023 13:32:29 +0200 Subject: [PATCH 15/20] kernel: ubootenv-nvram: driver for RAM backed environments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The vendor U-Boot implementaion on Telenor branded ZyXEL EX5700 devices does not store its environment on flash. It is instead kept in a memory region. This is persistent over reboots, but not over power cycling. The dual partition failsafe system used by the vendor U-Boot requires the OS to modify a variable in this memory environment. This driver allows the ordinary uboot-envtools to access a memory region like it was a partition on NOR flash. The specific vendor U-Boot adds a "no-map" /reserved-memory section and a top level /ubootenv node pointing to the memory environment. The driver uses this device specific fact to locate the region. The matching and probing code will likely have to be adjusted for any other devices to be supported. Example partial device tree: / { .. ubootenv { memory-region = <&uenv>; compatible = "ubootenv"; }; .. reserved-memory { .. uenv: ubootenv@7ffe8000 { no-map; reg = <0 0x7ffe8000 0 0x4000>; }; Signed-off-by: Bjørn Mork --- package/kernel/ubootenv-nvram/Makefile | 30 ++++ package/kernel/ubootenv-nvram/src/Makefile | 1 + .../ubootenv-nvram/src/ubootenv-nvram.c | 158 ++++++++++++++++++ 3 files changed, 189 insertions(+) create mode 100644 package/kernel/ubootenv-nvram/Makefile create mode 100644 package/kernel/ubootenv-nvram/src/Makefile create mode 100644 package/kernel/ubootenv-nvram/src/ubootenv-nvram.c diff --git a/package/kernel/ubootenv-nvram/Makefile b/package/kernel/ubootenv-nvram/Makefile new file mode 100644 index 00000000000..0574ea61d7d --- /dev/null +++ b/package/kernel/ubootenv-nvram/Makefile @@ -0,0 +1,30 @@ +include $(TOPDIR)/rules.mk +include $(INCLUDE_DIR)/kernel.mk + +PKG_NAME:=ubootenv-nvram +PKG_RELEASE:=1 +PKG_LICENSE:=GPL-2.0 + +include $(INCLUDE_DIR)/package.mk + +define KernelPackage/ubootenv-nvram + SUBMENU:=Other modules + TITLE:=NVRAM environment for uboot-envtools + FILES:=$(PKG_BUILD_DIR)/ubootenv-nvram.ko + AUTOLOAD:=$(call AutoLoad,30,ubootenv-nvram,1) + KCONFIG:= +endef + +define KernelPackage/ubootenv-nvram/description + Support vendor modified U-Boot storing the environment + in RAM. This driver exports the environment memory + region as a misc device named "ubootenv", pretending + it is a NOR mtd device to let existing userspace tools + work without modifications. +endef + +define Build/Compile + $(KERNEL_MAKE) M="$(PKG_BUILD_DIR)" modules +endef + +$(eval $(call KernelPackage,ubootenv-nvram)) diff --git a/package/kernel/ubootenv-nvram/src/Makefile b/package/kernel/ubootenv-nvram/src/Makefile new file mode 100644 index 00000000000..469cb801f3b --- /dev/null +++ b/package/kernel/ubootenv-nvram/src/Makefile @@ -0,0 +1 @@ +obj-m += ubootenv-nvram.o diff --git a/package/kernel/ubootenv-nvram/src/ubootenv-nvram.c b/package/kernel/ubootenv-nvram/src/ubootenv-nvram.c new file mode 100644 index 00000000000..f6244142167 --- /dev/null +++ b/package/kernel/ubootenv-nvram/src/ubootenv-nvram.c @@ -0,0 +1,158 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (C) 2022 Bjørn Mork + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define NAME "ubootenv" + +struct ubootenv_drvdata { + void *env; + struct reserved_mem *rmem; + struct miscdevice misc; +}; + +static inline struct ubootenv_drvdata *to_ubootenv_drvdata(struct file *file) +{ + return container_of(file->private_data, struct ubootenv_drvdata, misc); +} + +static ssize_t ubootenv_write(struct file *file, const char __user *buffer, size_t count, + loff_t *ppos) +{ + struct ubootenv_drvdata *data = to_ubootenv_drvdata(file); + + if (!data->env) + return -EIO; + return simple_write_to_buffer(data->env, data->rmem->size, ppos, buffer, count); +} + +static ssize_t ubootenv_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos) +{ + struct ubootenv_drvdata *data = to_ubootenv_drvdata(file); + + if (!data->env) + return 0; + return simple_read_from_buffer(buffer, count, ppos, data->env, data->rmem->size); +} + +static loff_t ubootenv_llseek(struct file *file, loff_t off, int whence) +{ + struct ubootenv_drvdata *data = to_ubootenv_drvdata(file); + + return fixed_size_llseek(file, off, whence, data->rmem->size); +} + +/* Faking the minimal mtd ioctl subset required by the fw_env.c */ +static long ubootenv_ioctl(struct file *file, u_int cmd, u_long arg) +{ + struct ubootenv_drvdata *data = to_ubootenv_drvdata(file); + void __user *argp = (void __user *)arg; + struct mtd_info_user info = { + .type = MTD_NORFLASH, + .size = data->rmem->size, + }; + + switch (cmd) { + case MEMISLOCKED: + case MEMERASE: + break; + case MEMGETINFO: + if (copy_to_user(argp, &info, sizeof(struct mtd_info_user))) + return -EFAULT; + break; + default: + return -ENOTTY; + } + return 0; +} + +static const struct file_operations ubootenv_fops = { + .owner = THIS_MODULE, + .read = ubootenv_read, + .write = ubootenv_write, + .llseek = ubootenv_llseek, + .unlocked_ioctl = ubootenv_ioctl, +}; + +/* We can only map a single reserved-memory range */ +static struct ubootenv_drvdata drvdata = { + .misc = { + .fops = &ubootenv_fops, + .minor = MISC_DYNAMIC_MINOR, + .name = NAME, + }, +}; + +const struct of_device_id of_ubootenv_match[] = { + { .compatible = "ubootenv" }, + {}, +}; +MODULE_DEVICE_TABLE(of, of_ubootenv_match); + +static int ubootenv_probe(struct platform_device *pdev) +{ + struct ubootenv_drvdata *data = &drvdata; + struct device *dev = &pdev->dev; + struct device_node *np; + + /* enforce single instance */ + if (data->env) + return -EINVAL; + + np = of_parse_phandle(dev->of_node, "memory-region", 0); + if (!np) + return -ENODEV; + + data->rmem = of_reserved_mem_lookup(np); + of_node_put(np); + if (!data->rmem) + return -ENODEV; + + if (!data->rmem->size || (data->rmem->size > ULONG_MAX)) + return -EINVAL; + + if (!PAGE_ALIGNED(data->rmem->base) || !PAGE_ALIGNED(data->rmem->size)) + return -EINVAL; + + data->env = devm_memremap(&pdev->dev, data->rmem->base, data->rmem->size, MEMREMAP_WB); + platform_set_drvdata(pdev, data); + + data->misc.parent = &pdev->dev; + return misc_register(&data->misc); +} + +static int ubootenv_remove(struct platform_device *pdev) +{ + struct ubootenv_drvdata *data = platform_get_drvdata(pdev); + + data->env = NULL; + misc_deregister(&data->misc); + return 0; +} + +static struct platform_driver ubootenv_driver = { + .probe = ubootenv_probe, + .remove = ubootenv_remove, + .driver = { + .name = NAME, + .owner = THIS_MODULE, + .of_match_table = of_ubootenv_match, + }, +}; + +module_platform_driver(ubootenv_driver); + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Bjørn Mork "); +MODULE_DESCRIPTION("Access u-boot environment in RAM"); From 1dd1ac2c356ad37366dde64b624e5eb489b19393 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Mork?= Date: Thu, 18 May 2023 11:56:35 +0200 Subject: [PATCH 16/20] mediatek: filogic: set wan label in preinit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implement the functionality of target/linux/ramips/patches-5.15/700-net-ethernet-mediatek-support-net-labels.patch in userspace, since the driver patch has been rejected as a generic solution: https://github.com/openwrt/openwrt/pull/11435 Signed-off-by: Bjørn Mork --- .../base-files/lib/preinit/04_set_netdev_label | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 target/linux/mediatek/filogic/base-files/lib/preinit/04_set_netdev_label diff --git a/target/linux/mediatek/filogic/base-files/lib/preinit/04_set_netdev_label b/target/linux/mediatek/filogic/base-files/lib/preinit/04_set_netdev_label new file mode 100644 index 00000000000..f8b6f155deb --- /dev/null +++ b/target/linux/mediatek/filogic/base-files/lib/preinit/04_set_netdev_label @@ -0,0 +1,15 @@ +set_netdev_labels() { + local dir + local label + local netdev + + for dir in /sys/class/net/*; do + [ -r "$dir/of_node/label" ] || continue + label="$(cat "$dir/of_node/label")" + netdev="$(basename $dir)" + [ "$netdev" = "$label" ] && continue + ip link set "$netdev" name "$label" + done +} + +boot_hook_add preinit_main set_netdev_labels From 6cc14bf66aa924962b926ea9702b6153ae418a7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Mork?= Date: Tue, 28 Mar 2023 15:04:21 +0200 Subject: [PATCH 17/20] filogic: support Telenor branded ZyXEL EX5700 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Telenor quirks -------------- The operator specific firmware running on the Telenor branded ZyXEL EX5700 includes U-Boot modifications affecting the OpenWrt installation. Notable changes to U-Boot include - environment is stored in RAM and reset to defaults when power cycled - dual partition scheme with "nomimal" or "rescue" systems, falling back to "rescue" unless the OS signals success in 3 attempts - several runtime additions to the device-tree Some of these modifications have side effects requiring workarounds - U-Boot modifies /chosen/bootargs in an unsafe manner, and will crash unless this node exists - U-Boot verifies that the selected rootfs UBI volume exists, and refuses to boot if it doesn't. The chosen "rootfs" volume must contain a squashfs signature even for tftp or initramfs booting. - U-Boot parses the "factoryparams" UBI volume, setting the "ethaddr" variable to the label mac. But "factoryparams" does not always exist. Instead there is a "RIP" volume containing all the factory data. Copying the "RIP" volume to "factoryparams" will fix this Hardware -------- SOC: MediaTek MT7986 RAM: 1GB DDR4 FLASH: 512MB SPI-NAND (Mikron xxx) WIFI: Mediatek MT7986 802.11ax 5 GHz Mediatek MT7916 DBDC 802.11ax 2.4 + 6 GHz ETH: MediaTek MT7531 Switch + SoC 3 x builtin 1G phy (lan1, lan2, lan3) 2 x MaxLinear GPY211C 2.5 N-Base-T phy (lan4, wan) USB: 1 x USB 3.2 Enhanced SuperSpeed port UART: 3V3 115200 8N1 (Pinout: GND KEY RX TX VCC) Installation ------------ 1. Download the OpenWrt initramfs image. Copy the image to a TFTP server reachable at 192.168.1.2/24. Rename the image to C0A80101.img. 2. Connect the TFTP server to lan1, lan2 or lan3. Connect to the serial console, Interrupt the autoboot process by pressing ESC when prompted. 3. Download and boot the OpenWrt initramfs image. $ env set uboot_bootcount 0 $ env set firmware nominal $ tftpboot $ bootm 4. Wait for OpenWrt to boot. Transfer the sysupgrade image to the device using scp and install using sysupgrade. $ sysupgrade -n Missing features ---------------- - The "lan1", "lan2" and "lan3" port LEDs are driven by the switch but OpenWrt does not correctly configure the output. - The "lan4" and "wan" port LEDs are driven by the GPH211C phys and not configured by OpenWrt. Signed-off-by: Bjørn Mork --- .../uboot-envtools/files/mediatek_filogic | 3 + .../dts/mt7986a-zyxel-ex5700-telenor.dts | 374 ++++++++++++++++++ .../filogic/base-files/etc/init.d/bootcount | 12 + target/linux/mediatek/image/filogic.mk | 14 + 4 files changed, 403 insertions(+) create mode 100644 target/linux/mediatek/dts/mt7986a-zyxel-ex5700-telenor.dts create mode 100644 target/linux/mediatek/filogic/base-files/etc/init.d/bootcount diff --git a/package/boot/uboot-envtools/files/mediatek_filogic b/package/boot/uboot-envtools/files/mediatek_filogic index 4fb1af82183..dca6f430030 100644 --- a/package/boot/uboot-envtools/files/mediatek_filogic +++ b/package/boot/uboot-envtools/files/mediatek_filogic @@ -71,6 +71,9 @@ zyxel,ex5601-t0) local envdev=/dev/mtd$(find_mtd_index "u-boot-env") ubootenv_add_uci_config "$envdev" "0x0" "0x20000" "0x40000" "2" ;; +zyxel,ex5700-telenor) + ubootenv_add_uci_config "/dev/ubootenv" "0x0" "0x4000" "0x4000" "1" + ;; esac config_load ubootenv diff --git a/target/linux/mediatek/dts/mt7986a-zyxel-ex5700-telenor.dts b/target/linux/mediatek/dts/mt7986a-zyxel-ex5700-telenor.dts new file mode 100644 index 00000000000..b6bd746ef30 --- /dev/null +++ b/target/linux/mediatek/dts/mt7986a-zyxel-ex5700-telenor.dts @@ -0,0 +1,374 @@ +// SPDX-License-Identifier: (GPL-2.0 OR MIT) + +/dts-v1/; +#include +#include + +#include "mt7986a.dtsi" + +/ { + model = "ZyXEL EX5700 (Telenor)"; + compatible = "zyxel,ex5700-telenor", "mediatek,mt7986a"; + + aliases { + serial0 = &uart0; + ethernet0 = &gmac0; + led-boot = &led_status_green; + led-failsafe = &led_status_green; + led-running = &led_status_green; + led-upgrade = &led_status_amber; + }; + + chosen { + stdout-path = "serial0:115200n8"; + + // Stock U-Boot crashes unless /chosen/bootargs exists + bootargs = "earlycon=uart8250,mmio32,0x11002000 console=ttyS0,115200n8"; + }; + + memory { + reg = <0 0x40000000 0 0x40000000>; + }; + + reg_3p3v: regulator-3p3v { + compatible = "regulator-fixed"; + regulator-name = "fixed-3.3V"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + regulator-boot-on; + regulator-always-on; + }; + + reg_5v: regulator-5v { + compatible = "regulator-fixed"; + regulator-name = "fixed-5V"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + regulator-boot-on; + regulator-always-on; + }; + + + keys { + compatible = "gpio-keys"; + poll-interval = <20>; + + reset-button { + label = "reset"; + gpios = <&pio 9 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + wps-button { + label = "wps"; + gpios = <&pio 10 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + leds { + compatible = "gpio-leds"; + + red1 { + label = "red:net"; + gpios = <&pio 23 GPIO_ACTIVE_HIGH>; + default-state = "off"; + }; + + green1 { + label = "green:net"; + gpios = <&pio 25 GPIO_ACTIVE_HIGH>; + default-state = "off"; + }; + + amber1 { + label = "amber:net"; + gpios = <&pio 29 GPIO_ACTIVE_HIGH>; + default-state = "off"; + }; + + white2 { + label = "white:status"; + gpios = <&pio 16 GPIO_ACTIVE_HIGH>; + default-state = "off"; + }; + + red2 { + label = "red:status"; + gpios = <&pio 17 GPIO_ACTIVE_HIGH>; + default-state = "off"; + }; + + led_status_green: green2 { + label = "green:status"; + gpios = <&pio 31 GPIO_ACTIVE_HIGH>; + default-state = "off"; + }; + + led_status_amber: amber2 { + label = "amber:status"; + gpios = <&pio 18 GPIO_ACTIVE_HIGH>; + default-state = "off"; + }; + }; + +}; + +ð { + status = "okay"; + pinctrl-names = "default"; + pinctrl-0 = <ð_pins>; + + gmac0: mac@0 { + compatible = "mediatek,eth-mac"; + reg = <0>; + phy-mode = "2500base-x"; + + fixed-link { + speed = <2500>; + full-duplex; + pause; + }; + }; + + mac@1 { + compatible = "mediatek,eth-mac"; + reg = <1>; + label = "wan"; + phy-mode = "2500base-x"; + phy-handle = <&phy6>; + }; + + mdio: mdio-bus { + #address-cells = <1>; + #size-cells = <0>; + }; +}; + +&mdio { + reset-gpios = <&pio 6 GPIO_ACTIVE_LOW>; + reset-delay-us = <50000>; + reset-post-delay-us = <20000>; + + phy5: phy@5 { + compatible = "ethernet-phy-ieee802.3-c45"; + reg = <5>; + }; + + phy6: phy@6 { + compatible = "ethernet-phy-ieee802.3-c45"; + reg = <6>; + }; + + switch: switch@1f { + compatible = "mediatek,mt7531"; + reg = <31>; + reset-gpios = <&pio 5 GPIO_ACTIVE_HIGH>; + interrupt-controller; + #interrupt-cells = <1>; + interrupt-parent = <&pio>; + interrupts = <66 IRQ_TYPE_LEVEL_HIGH>; + }; +}; + +&switch { + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + label = "lan3"; + }; + + port@1 { + reg = <1>; + label = "lan2"; + }; + + port@2 { + reg = <2>; + label = "lan1"; + }; + + port@5 { + reg = <5>; + label = "lan4"; + phy-mode = "2500base-x"; + phy-handle = <&phy5>; + }; + + port@6 { + reg = <6>; + ethernet = <&gmac0>; + phy-mode = "2500base-x"; + + fixed-link { + speed = <2500>; + full-duplex; + pause; + }; + }; + }; +}; + +&crypto { + status = "okay"; +}; + +&pcie { + pinctrl-names = "default"; + pinctrl-0 = <&pcie_pins>; + status = "okay"; + + pcie@0,0 { + reg = <0x0000 0 0 0 0>; + + wifi@0,0 { + compatible = "mediatek,mt76"; + reg = <0x0000 0 0 0 0>; + mediatek,mtd-eeprom = <&factory 0xa0000>; + }; + }; +}; + +&pcie_phy { + status = "okay"; +}; + +&watchdog { + status = "okay"; +}; + +&wifi { + status = "okay"; + pinctrl-names = "default"; + pinctrl-0 = <&wf_5g_pins>; + + mediatek,mtd-eeprom = <&factory 0x0>; +}; + +&pio { + eth_pins: eth-pins { + mux { + function = "eth"; + groups = "switch_int", "mdc_mdio"; + }; + }; + + pcie_pins: pcie-pins { + mux { + function = "pcie"; + groups = "pcie_pereset"; // "pcie_clk" and "pcie_wake" is unused? + }; + }; + + spi_flash_pins: spi-flash-pins-33-to-38 { + mux { + function = "spi"; + groups = "spi0", "spi0_wp_hold"; + }; + conf-pu { + pins = "SPI2_CS", "SPI2_HOLD", "SPI2_WP"; + drive-strength = <8>; + mediatek,pull-up-adv = <0>; /* bias-disable */ + }; + conf-pd { + pins = "SPI2_CLK", "SPI2_MOSI", "SPI2_MISO"; + drive-strength = <8>; + mediatek,pull-down-adv = <0>; /* bias-disable */ + }; + }; + + wf_5g_pins: wf_5g-pins { + mux { + function = "wifi"; + groups = "wf_5g"; + }; + conf { + pins = "WF1_HB1", "WF1_HB2", "WF1_HB3", "WF1_HB4", + "WF1_HB0", "WF1_HB5", "WF1_HB6", "WF1_HB7", + "WF1_HB8", "WF1_TOP_CLK", "WF1_TOP_DATA"; + drive-strength = <4>; + }; + }; + +}; + +&spi0 { + pinctrl-names = "default"; + pinctrl-0 = <&spi_flash_pins>; + cs-gpios = <0>, <0>; + status = "okay"; + + flash@0 { + compatible = "jedec,spi-nor"; + reg = <0>; + spi-max-frequency = <20000000>; + }; + + flash@1 { + compatible = "spi-nand"; + reg = <1>; + + mediatek,nmbm; + mediatek,bmt-max-ratio = <1>; + mediatek,bmt-max-reserved-blocks = <64>; + + spi-max-frequency = <20000000>; + spi-tx-buswidth = <4>; + spi-rx-buswidth = <4>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "BL2"; + reg = <0x000000 0x100000>; + read-only; + }; + partition@100000 { + label = "u-boot-env"; + reg = <0x100000 0x80000>; + }; + factory: partition@180000 { + label = "Factory"; + reg = <0x180000 0x200000>; + read-only; + + compatible = "nvmem-cells"; + #address-cells = <1>; + #size-cells = <1>; + }; + partition@380000 { + label = "FIP"; + reg = <0x380000 0x200000>; + read-only; + }; + partition@580000 { + label = "ubi"; + reg = <0x580000 0x1da80000>; + }; + }; + }; +}; + +&ssusb { + vusb33-supply = <®_3p3v>; + vbus-supply = <®_5v>; + status = "okay"; +}; + +&trng { + status = "okay"; +}; + +&uart0 { + status = "okay"; +}; + +&usb_phy { + status = "okay"; +}; diff --git a/target/linux/mediatek/filogic/base-files/etc/init.d/bootcount b/target/linux/mediatek/filogic/base-files/etc/init.d/bootcount new file mode 100644 index 00000000000..c52d004c639 --- /dev/null +++ b/target/linux/mediatek/filogic/base-files/etc/init.d/bootcount @@ -0,0 +1,12 @@ +#!/bin/sh /etc/rc.common +# SPDX-License-Identifier: GPL-2.0-only + +START=99 + +boot() { + case $(board_name) in + zyxel,ex5700-telenor) + fw_setenv uboot_bootcount 0 + ;; + esac +} diff --git a/target/linux/mediatek/image/filogic.mk b/target/linux/mediatek/image/filogic.mk index e008c23c0af..c3300201cf6 100644 --- a/target/linux/mediatek/image/filogic.mk +++ b/target/linux/mediatek/image/filogic.mk @@ -509,6 +509,20 @@ define Device/zyxel_ex5601-t0-stock endef TARGET_DEVICES += zyxel_ex5601-t0-stock +define Device/zyxel_ex5700-telenor + DEVICE_VENDOR := ZyXEL + DEVICE_MODEL := EX5700 (Telenor) + DEVICE_DTS := mt7986a-zyxel-ex5700-telenor + DEVICE_DTS_DIR := ../dts + DEVICE_PACKAGES := kmod-mt7916-firmware kmod-ubootenv-nvram kmod-usb3 kmod-mt7986-firmware mt7986-wo-firmware + UBINIZE_OPTS := -E 5 + BLOCKSIZE := 128k + PAGESIZE := 2048 + IMAGE_SIZE := 65536k + IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata +endef +TARGET_DEVICES += zyxel_ex5700-telenor + define Device/zyxel_nwa50ax-pro DEVICE_VENDOR := ZyXEL DEVICE_MODEL := NWA50AX Pro From 9088b5445f8e3586836820a63fd804941eda7b8a Mon Sep 17 00:00:00 2001 From: INAGAKI Hiroshi Date: Sun, 6 Aug 2023 16:09:35 +0900 Subject: [PATCH 18/20] ramips: improve sysupgrade helpers for I-O DATA devices I-O DATA devices manufactured by MSTC (MitraStar Technology Corp.) have some important flags for booting, "bootnum" and "debugflag". The almost devices have both flags but some devices have only "bootnum" flag. So optimize helper functions in iodata.sh to set each flags. - both: - WN-AX1167GR2 - WN-AX2033GR - WN-DX1167R - WN-DX1200GR - WN-DX2033GR - "bootnum" only - WN-DEAX1800GR Signed-off-by: INAGAKI Hiroshi --- .../mt7621/base-files/lib/upgrade/iodata.sh | 112 +++++++++++------- .../mt7621/base-files/lib/upgrade/platform.sh | 6 +- 2 files changed, 72 insertions(+), 46 deletions(-) diff --git a/target/linux/ramips/mt7621/base-files/lib/upgrade/iodata.sh b/target/linux/ramips/mt7621/base-files/lib/upgrade/iodata.sh index 8303ae99226..40b2b2c76b2 100644 --- a/target/linux/ramips/mt7621/base-files/lib/upgrade/iodata.sh +++ b/target/linux/ramips/mt7621/base-files/lib/upgrade/iodata.sh @@ -10,55 +10,79 @@ iodata_mstc_prepare_fail() { reboot -f } -# I-O DATA devices manufactured by MSTC (MitraStar Technology Corp.) -# have two important flags: -# - bootnum: switch between two os images -# use 1st image in OpenWrt -# - debugflag: enable/disable debug -# users can interrupt Z-Loader for recovering the device if enabled +# read/write 1byte in mtd device # # parameters: -# - $1: the offset of "debugflag" -iodata_mstc_upgrade_prepare() { - local persist_mtd="$(find_mtd_part persist)" - local factory_mtd="$(find_mtd_part factory)" - local dflag_offset="$1" +# $1: target mtd device ("/dev/mtdblockN") +# $2: offset of target value (decimal or hex) +# $3: value to set (decimal or hex, don't set when reading) +iodata_mstc_rw_byte() { + local mtd="$1" + local offset="$2" + local setval="$3" + local _val=$(hexdump -s $offset -n 1 -e '"%d"' $mtd) - if [ -z "$dflag_offset" ]; then - echo 'no debugflag offset provided' - iodata_mstc_prepare_fail + if [ -z "$setval" ]; then + echo $_val + return 0 fi - if [ -z "$persist_mtd" ] || [ -z "$factory_mtd" ]; then - echo 'cannot find mtd partition(s), "factory" or "persist"' - iodata_mstc_prepare_fail - fi + # decimal or hex -> decimal + setval=$((setval)) + [ "$_val" = "$setval" ] && return 0 + setval="$(printf '%02x' $setval)" - local bootnum=$(hexdump -s 4 -n 1 -e '"%x"' ${persist_mtd}) - local debugflag=$(hexdump -s $((dflag_offset)) -n 1 -e '"%x"' ${factory_mtd}) - - if [ "$bootnum" != "1" ] && [ "$bootnum" != "2" ]; then - echo "failed to get bootnum, please check the value at 0x4 in ${persist_mtd}" - iodata_mstc_prepare_fail - fi - if [ "$debugflag" != "0" ] && [ "$debugflag" != "1" ]; then - echo "failed to get debugflag, please check the value at ${dflag_offset} in ${factory_mtd}" - iodata_mstc_prepare_fail - fi - echo "current: bootnum => ${bootnum}, debugflag => ${debugflag}" - - if [ "$bootnum" = "2" ]; then - if ! (echo -ne "\x01" | dd bs=1 count=1 seek=4 conv=notrunc of=${persist_mtd} 2>/dev/null); then - echo "failed to set bootnum" - iodata_mstc_prepare_fail - fi - echo "### switch to 1st os-image on next boot ###" - fi - if [ "$debugflag" = "0" ]; then - if ! (echo -ne "\x01" | dd bs=1 count=1 seek=$((dflag_offset)) conv=notrunc of=${factory_mtd} 2>/dev/null); then - echo "failed to set debugflag" - iodata_mstc_prepare_fail - fi - echo "### enable debug ###" + if ! (printf "\x$setval" | dd bs=1 seek=$((offset)) conv=notrunc of=$mtd 2>/dev/null); then + return 1 + fi +} + +# set flag in mtd device on I-O DATA devices manufactured by MSTC +# (MitraStar Technology Corp.) +# +# parameters: +# $1: parameter name +# $2: mtd name contains target flag +# $3: offset of flag +# $4: valid flag values ("n,n,...", ex:"0,1" or "1,2") +# $5: value to set to the flag +iodata_mstc_set_flag() { + local name="$1" + local mtddev="$(find_mtd_part $2)" + local offset="$3" + local valid="$4" + local setval="$5" + + if [ -z "$offset" ]; then + echo "no $name flag offset provided" + iodata_mstc_prepare_fail + fi + + if [ -z "$mtddev" ]; then + echo "cannot find \"$2\" mtd partition" + iodata_mstc_prepare_fail + fi + + local flag=$(iodata_mstc_rw_byte "$mtddev" "$offset") + local _tmp + for i in ${valid//,/ }; do + if [ "$flag" = "$((i))" ]; then + _tmp=$flag + break + fi + done + + if [ -z "$_tmp" ]; then + echo "failed to get valid $name flag, please check the value at $offset in $mtddev" + iodata_mstc_prepare_fail + fi + echo "current: $name => $flag" + + if [ "$flag" != "$((setval))" ]; then + if ! iodata_mstc_rw_byte "$mtddev" "$offset" "$setval"; then + echo "failed to set \"$name\" flag" + iodata_mstc_prepare_fail + fi + echo " --> set \"$name\" flag to $setval (valid: $valid)" fi } diff --git a/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh b/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh index 3c6d02f4fa6..85e97b4f839 100755 --- a/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh +++ b/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh @@ -125,11 +125,13 @@ platform_do_upgrade() { iodata,wn-ax2033gr|\ iodata,wn-dx1167r|\ iodata,wn-dx2033gr) - iodata_mstc_upgrade_prepare "0xfe75" + iodata_mstc_set_flag "debugflag" "factory" "0xfe75" "0,1" "1" + iodata_mstc_set_flag "bootnum" "persist" "0x4" "1,2" "1" nand_do_upgrade "$1" ;; iodata,wn-dx1200gr) - iodata_mstc_upgrade_prepare "0x1fe75" + iodata_mstc_set_flag "debugflag" "factory" "0x1fe75" "0,1" "1" + iodata_mstc_set_flag "bootnum" "persist" "0x4" "1,2" "1" nand_do_upgrade "$1" ;; tplink,er605-v2) From ac68fbf526d1b7145d611d5cbc4eb0cbc8a82094 Mon Sep 17 00:00:00 2001 From: INAGAKI Hiroshi Date: Sun, 2 May 2021 22:06:09 +0900 Subject: [PATCH 19/20] ramips: add support for I-O DATA WN-DEAX1800GR MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I-O DATA WN-DEAX1800GR is a 2.4/5 GHz band 11ax (Wi-Fi 6) router, based on MT7621A. Specification: - SoC : MediaTek MT7621A - RAM : DDR3 256 MiB (Nanya NT5CC128M16JR-EK) - Flash : RAW NAND 128 MiB (Winbond W29N01HVSINF) - WLAN : 2.4/5 GHz (MediaTek MT7915) - Ethernet : 5x 10/100/1000 Mbps - Switch : MT7530 (SoC) - LEDs/Keys : 6x/3x - UART : through-hole on PCB (J2) - assignment: 3.3V, GND, TX, RX from "1" marking - settings : 115200n8 - Power : 12 VDC, 1 A Flash instruction using initramfs-factory image: 1. Boot WN-DEAX1800GR normally 2. Access to "http://192.168.0.1/" and open firmware update page ("ファームウェア") 3. Select the OpenWrt initramfs-factory.bin image and click update ("更新") button to perform firmware update 4. On the initramfs image, perform sysupgrade with the squashfs-sysupgrade.bin image 5. Wait ~120 seconds to complete flashing Note: - This device has 2x OS images on the flash storage. In this support, the first one will be used. Warning: - Do not use "saveenv" command on U-Boot CLI. This device has wrong u-boot-env data. The actual length of individual env data installed to the device is 0x1000 (4 KiB), but installed U-Boot requires 0x20000 (128 KiB). So U-Boot determines the data is invalid. Then, if you perform saving environment data with saveenv on U-Boot CLI, installed env data will be overwritten with too few default values without individual values (SSID, password, MAC addresses, etc...). MAC addresses: LAN : 50:41:B9:xx:xx:F4 (Config, ethaddr (text)) WAN : 50:41:B9:xx:xx:F6 (Config, wanaddr (text)) 2.4 GHz: 50:41:B9:xx:xx:F4 (Config, rmac (text) / Factory, 0x4 (hex)) 5 GHz : 50:41:B9:xx:xx:F5 (none) Signed-off-by: INAGAKI Hiroshi --- .../dts/mt7621_iodata_wn-deax1800gr.dts | 239 ++++++++++++++++++ target/linux/ramips/image/mt7621.mk | 52 ++++ .../mt7621/base-files/etc/board.d/02_network | 1 + .../mt7621/base-files/lib/upgrade/platform.sh | 4 + 4 files changed, 296 insertions(+) create mode 100644 target/linux/ramips/dts/mt7621_iodata_wn-deax1800gr.dts diff --git a/target/linux/ramips/dts/mt7621_iodata_wn-deax1800gr.dts b/target/linux/ramips/dts/mt7621_iodata_wn-deax1800gr.dts new file mode 100644 index 00000000000..10959a1fcdc --- /dev/null +++ b/target/linux/ramips/dts/mt7621_iodata_wn-deax1800gr.dts @@ -0,0 +1,239 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "mt7621.dtsi" + +#include +#include +#include + +/ { + compatible = "iodata,wn-deax1800gr", "mediatek,mt7621-soc"; + model = "I-O DATA WN-DEAX1800GR"; + + aliases { + led-boot = &led_status_green; + led-failsafe = &led_status_red; + led-upgrade = &led_status_green; + label-mac-device = &gmac1; + }; + + chosen { + bootargs = "console=ttyS0,115200"; + }; + + leds { + compatible = "gpio-leds"; + + led_status_green: led-0 { + label = "green:status"; + gpios = <&gpio 3 GPIO_ACTIVE_HIGH>; + color = ; + function = LED_FUNCTION_STATUS; + }; + + led_status_red: led-1 { + label = "red:status"; + gpios = <&gpio 7 GPIO_ACTIVE_HIGH>; + color = ; + function = LED_FUNCTION_STATUS; + }; + + led-2 { + label = "green:wps_wifi"; + gpios = <&gpio 13 GPIO_ACTIVE_HIGH>; + color = ; + function = LED_FUNCTION_WPS; + }; + + led-3 { + label = "green:power"; + gpios = <&gpio 14 GPIO_ACTIVE_HIGH>; + color = ; + function = LED_FUNCTION_POWER; + default-state = "on"; + }; + + led-4 { + label = "green:router"; + gpios = <&gpio 15 GPIO_ACTIVE_HIGH>; + color = ; + function = LED_FUNCTION_INDICATOR; + }; + + led-5 { + label = "green:internet"; + gpios = <&gpio 16 GPIO_ACTIVE_HIGH>; + color = ; + function = LED_FUNCTION_WAN; + }; + }; + + keys { + compatible = "gpio-keys"; + + wps { + label = "wps"; + gpios = <&gpio 4 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + reset { + label = "reset"; + gpios = <&gpio 8 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + led_on { + label = "led_on"; + gpios = <&gpio 10 GPIO_ACTIVE_HIGH>; + linux,code = ; + linux,input-type = ; + }; + }; +}; + +&nand { + status = "okay"; + + mediatek,nmbm; + mediatek,bmt-remap-range = + <0x0000000 0x780000>, /* u-boot - kernel1(6 MiB) */ + <0x2f80000 0x600000>, /* kernel2 - kernel2(6 MiB) */ + <0x5d80000 0x780000>; /* storage - working */ + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "u-boot"; + reg = <0x0 0x80000>; + read-only; + }; + + partition@80000 { + label = "u-boot-env"; + reg = <0x80000 0x80000>; + read-only; + }; + + partition@100000 { + compatible = "nvmem-cells"; + label = "factory"; + reg = <0x100000 0x80000>; + read-only; + + nvmem-layout { + compatible = "fixed-layout"; + #address-cells = <1>; + #size-cells = <1>; + + eeprom: eeprom@0 { + reg = <0x0 0x1aa20>; + }; + + macaddr_factory_4: macaddr@4 { + compatible = "mac-base"; + reg = <0x4 0x6>; + #nvmem-cell-cells = <1>; + }; + }; + }; + + partition@180000 { + label = "kernel"; + reg = <0x180000 0x600000>; + }; + + partition@580000 { + label = "ubi"; + reg = <0x780000 0x2800000>; + }; + + partition@2f80000 { + label = "firmware2"; + reg = <0x2f80000 0x2e00000>; + }; + + partition@5d80000 { + label = "storage"; + reg = <0x5d80000 0x600000>; + read-only; + }; + + partition@6380000 { + label = "idmkey"; + reg = <0x6380000 0x100000>; + read-only; + }; + + partition@6480000 { + label = "working"; + reg = <0x6480000 0x80000>; + }; + }; +}; + +&gmac0 { + nvmem-cells = <&macaddr_factory_4 0>; + nvmem-cell-names = "mac-address"; +}; + +&gmac1 { + status = "okay"; + label = "wan"; + phy-handle = <ðphy0>; + + nvmem-cells = <&macaddr_factory_4 2>; + nvmem-cell-names = "mac-address"; +}; + +&mdio { + ethphy0: ethernet-phy@0 { + reg = <0>; + }; +}; + +&switch0 { + ports { + port@1 { + status = "okay"; + label = "lan2"; + }; + + port@2 { + status = "okay"; + label = "lan1"; + }; + }; +}; + +&pcie { + status = "okay"; +}; + +/* + * pcie0: MT7915 HIF (14c3,7916) + * pcie1: MT7915 (14c3,7915) + */ +&pcie1 { + wifi@0,0 { + compatible = "mediatek,mt76"; + reg = <0x0000 0 0 0 0>; + + nvmem-cells = <&eeprom>; + nvmem-cell-names = "eeprom"; + }; +}; + +&state_default { + gpio { + groups = "i2c", "jtag", "uart2", "uart3"; + function = "gpio"; + }; +}; + +&xhci { + status = "disabled"; +}; diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk index 07e8aea182a..ad45613a0b4 100644 --- a/target/linux/ramips/image/mt7621.mk +++ b/target/linux/ramips/image/mt7621.mk @@ -58,6 +58,37 @@ define Build/iodata-mstc-header ) endef +define Build/iodata-mstc-header2 + $(eval model=$(word 1,$(1))) + $(eval model_id=$(word 2,$(1))) + + ( \ + fw_len_crc=$$(gzip -c $@ | tail -c 8 | \ + od -An -tx8 --endian little); \ + printf "\x03\x1d\x61\x29\x07$(model)" | \ + dd bs=21 count=1 conv=sync 2>/dev/null; \ + printf "0.00.000" | dd bs=16 count=1 conv=sync 2>/dev/null; \ + printf "$$(echo $(REVISION) | cut -d- -f1 | head -c8)" | \ + dd bs=9 count=1 conv=sync 2>/dev/null; \ + printf "$(call toupper,$(LINUX_KARCH)) $(VERSION_DIST) Linux-$(LINUX_VERSION)" | \ + dd bs=33 count=1 conv=sync 2>/dev/null; \ + date -d "@$(SOURCE_DATE_EPOCH)" "+%F" | tr -d "\n" | \ + dd bs=15 count=1 conv=sync 2>/dev/null; \ + printf "$$(echo $(model_id) | sed 's/../\\x&/g')" | \ + dd bs=8 count=1 conv=sync 2>/dev/null; \ + printf "$$(echo $$fw_len_crc | sed 's/../\\x&/g')" | \ + dd bs=14 count=1 conv=sync 2>/dev/null; \ + cat $@; \ + ) > $@.new + ( \ + header_crc="$$(head -c116 $@.new | gzip -c | tail -c8 | \ + od -An -tx4 -N4 --endian little)"; \ + printf "$$(echo $$header_crc | sed 's/../\\x&/g')"; \ + ) | dd of=$@.new bs=4 oflag=seek_bytes seek=110 conv=notrunc + + mv $@.new $@ +endef + define Build/znet-header $(eval version=$(word 1,$(1))) ( \ @@ -1195,6 +1226,27 @@ define Device/iodata_wn-ax2033gr endef TARGET_DEVICES += iodata_wn-ax2033gr +define Device/iodata_wn-deax1800gr + $(Device/dsa-migration) + DEVICE_VENDOR := I-O DATA + DEVICE_MODEL := WN-DEAX1800GR + BLOCKSIZE := 128k + PAGESIZE := 2048 + KERNEL_SIZE := 6144k + IMAGE_SIZE := 47104k + UBINIZE_OPTS := -E 5 + KERNEL_LOADADDR := 0x82000000 + KERNEL := kernel-bin | relocate-kernel 0x80001000 | lzma | \ + fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb + IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata + ARTIFACTS := initramfs-factory.bin + ARTIFACT/initramfs-factory.bin := append-image-stage initramfs-kernel.bin | \ + check-size | xor-image -p 29944a25120984c2 -x | \ + iodata-mstc-header2 WN-DEAX1800GR 00021003 + DEVICE_PACKAGES := kmod-mt7915-firmware +endef +TARGET_DEVICES += iodata_wn-deax1800gr + define Device/iodata_wn-dx1167r $(Device/iodata_nand) DEVICE_MODEL := WN-DX1167R diff --git a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network index 8039c9ede10..bd4cb508126 100644 --- a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network +++ b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network @@ -67,6 +67,7 @@ ramips_setup_interfaces() beeline,smartbox-flash|\ beeline,smartbox-giga|\ glinet,gl-mt1300|\ + iodata,wn-deax1800gr|\ iptime,a3002mesh|\ jcg,q20|\ lenovo,newifi-d1|\ diff --git a/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh b/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh index 85e97b4f839..203872394bd 100755 --- a/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh +++ b/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh @@ -129,6 +129,10 @@ platform_do_upgrade() { iodata_mstc_set_flag "bootnum" "persist" "0x4" "1,2" "1" nand_do_upgrade "$1" ;; + iodata,wn-deax1800gr) + iodata_mstc_set_flag "bootnum" "working" "0x4" "0,1" "0" + nand_do_upgrade "$1" + ;; iodata,wn-dx1200gr) iodata_mstc_set_flag "debugflag" "factory" "0x1fe75" "0,1" "1" iodata_mstc_set_flag "bootnum" "persist" "0x4" "1,2" "1" From f2a8763587fb98862dd36ee05bd5e17e46155422 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 19 Jun 2023 08:36:15 +0200 Subject: [PATCH 20/20] uboot-bcm53xx: Add U-Boot for NorthStar BCM53xx I recently added support for the NorthStar ARM BCM53xx SoCs to the upstream U-Boot. This is a back port on top of the 2023.04 version already imported to OpenWrt with the 5 necessary upstream patches. This is needed to create a small U-Boot for the BCM53xx-based D-Link DIR-890L and I think also the DIR-885L, so that a recent (bigger) kernel can be loaded and executed from the SEAMA partitions on these devices. Signed-off-by: Linus Walleij --- .github/labeler.yml | 1 + package/boot/uboot-bcm53xx/Makefile | 37 + ...0001-nand-brcmnand-add-iproc-support.patch | 199 ++++++ ...nand_base-Handle-algorithm-selection.patch | 80 +++ ...t-device-tree-for-Broadcom-Northstar.patch | 659 ++++++++++++++++++ ...port-for-the-Broadcom-Northstar-SoCs.patch | 66 ++ ...ard-Add-new-Broadcom-Northstar-board.patch | 372 ++++++++++ 7 files changed, 1414 insertions(+) create mode 100644 package/boot/uboot-bcm53xx/Makefile create mode 100644 package/boot/uboot-bcm53xx/patches/0001-nand-brcmnand-add-iproc-support.patch create mode 100644 package/boot/uboot-bcm53xx/patches/0002-mtd-rawnand-nand_base-Handle-algorithm-selection.patch create mode 100644 package/boot/uboot-bcm53xx/patches/0003-arm-dts-Import-device-tree-for-Broadcom-Northstar.patch create mode 100644 package/boot/uboot-bcm53xx/patches/0004-arm-Add-support-for-the-Broadcom-Northstar-SoCs.patch create mode 100644 package/boot/uboot-bcm53xx/patches/0005-board-Add-new-Broadcom-Northstar-board.patch diff --git a/.github/labeler.yml b/.github/labeler.yml index e22f074604f..c8f8466d4a6 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -25,6 +25,7 @@ - "package/boot/uboot-bcm4908/**" "target/bcm53xx": - "target/linux/bcm53xx/**" + - "package/boot/uboot-bcm53xx/**" "target/bcm63xx": - "target/linux/bcm63xx/**" - "package/kernel/bcm63xx-cfe/**" diff --git a/package/boot/uboot-bcm53xx/Makefile b/package/boot/uboot-bcm53xx/Makefile new file mode 100644 index 00000000000..ab80b9608ad --- /dev/null +++ b/package/boot/uboot-bcm53xx/Makefile @@ -0,0 +1,37 @@ +include $(TOPDIR)/rules.mk + +PKG_VERSION:=2023.04 +PKG_HASH:=e31cac91545ff41b71cec5d8c22afd695645cd6e2a442ccdacacd60534069341 +PKG_RELEASE:=$(AUTORELEASE) + +include $(INCLUDE_DIR)/u-boot.mk +include $(INCLUDE_DIR)/package.mk + +define U-Boot/Default + BUILD_TARGET:=bcm53xx + BUILD_SUBTARGET:=generic + UBOOT_CONFIG:=bcmns + UBOOT_BOARD:=$(1) +endef + +define U-Boot/dir-885l + NAME:=D-Link DIR-885L + BUILD_DEVICES:=dlink_dir-885l +endef + +define U-Boot/dir-890l + NAME:=D-Link DIR-890L + BUILD_DEVICES:=dlink_dir-890l +endef + +UBOOT_TARGETS := dir-885l dir-890l + +define Build/InstallDev + $(INSTALL_DIR) $(STAGING_DIR_IMAGE) + $(CP) $(PKG_BUILD_DIR)/$(UBOOT_IMAGE) $(STAGING_DIR_IMAGE)/$(BUILD_DEVICES)-u-boot.bin +endef + +define Package/u-boot/install/default +endef + +$(eval $(call BuildPackage/U-Boot)) diff --git a/package/boot/uboot-bcm53xx/patches/0001-nand-brcmnand-add-iproc-support.patch b/package/boot/uboot-bcm53xx/patches/0001-nand-brcmnand-add-iproc-support.patch new file mode 100644 index 00000000000..fe6f4d944af --- /dev/null +++ b/package/boot/uboot-bcm53xx/patches/0001-nand-brcmnand-add-iproc-support.patch @@ -0,0 +1,199 @@ +From 854dc4b790ce1291326d52b8405ebe771bff2edd Mon Sep 17 00:00:00 2001 +From: Linus Walleij +Date: Wed, 8 Mar 2023 22:42:31 +0100 +Subject: [PATCH 1/5] nand: brcmnand: add iproc support + +Add support for the iproc Broadcom NAND controller, +used in Northstar SoCs for example. Based on the Linux +driver. + +Cc: Philippe Reynes +Cc: Dario Binacchi +Reviewed-by: Michael Trimarchi +Signed-off-by: Linus Walleij +Acked-by: William Zhang +Link: https://lore.kernel.org/all/20230308214231.378013-1-linus.walleij@linaro.org/ +Signed-off-by: Dario Binacchi +--- + drivers/mtd/nand/raw/Kconfig | 7 + + drivers/mtd/nand/raw/brcmnand/Makefile | 1 + + drivers/mtd/nand/raw/brcmnand/iproc_nand.c | 148 +++++++++++++++++++++ + 3 files changed, 156 insertions(+) + create mode 100644 drivers/mtd/nand/raw/brcmnand/iproc_nand.c + +--- a/drivers/mtd/nand/raw/Kconfig ++++ b/drivers/mtd/nand/raw/Kconfig +@@ -156,6 +156,13 @@ config NAND_BRCMNAND_63158 + help + Enable support for broadcom nand driver on bcm63158. + ++config NAND_BRCMNAND_IPROC ++ bool "Support Broadcom NAND controller on the iproc family" ++ depends on NAND_BRCMNAND ++ help ++ Enable support for broadcom nand driver on the Broadcom ++ iproc family such as Northstar (BCM5301x, BCM4708...) ++ + config NAND_DAVINCI + bool "Support TI Davinci NAND controller" + select SYS_NAND_SELF_INIT if TARGET_DA850EVM +--- a/drivers/mtd/nand/raw/brcmnand/Makefile ++++ b/drivers/mtd/nand/raw/brcmnand/Makefile +@@ -6,5 +6,6 @@ obj-$(CONFIG_NAND_BRCMNAND_6753) += bcm6 + obj-$(CONFIG_NAND_BRCMNAND_68360) += bcm68360_nand.o + obj-$(CONFIG_NAND_BRCMNAND_6838) += bcm6838_nand.o + obj-$(CONFIG_NAND_BRCMNAND_6858) += bcm6858_nand.o ++obj-$(CONFIG_NAND_BRCMNAND_IPROC) += iproc_nand.o + obj-$(CONFIG_NAND_BRCMNAND) += brcmnand.o + obj-$(CONFIG_NAND_BRCMNAND) += brcmnand_compat.o +--- /dev/null ++++ b/drivers/mtd/nand/raw/brcmnand/iproc_nand.c +@@ -0,0 +1,148 @@ ++// SPDX-License-Identifier: GPL-2.0 ++/* ++ * Code borrowed from the Linux driver ++ * Copyright (C) 2015 Broadcom Corporation ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include "brcmnand.h" ++ ++struct iproc_nand_soc { ++ struct brcmnand_soc soc; ++ void __iomem *idm_base; ++ void __iomem *ext_base; ++}; ++ ++#define IPROC_NAND_CTLR_READY_OFFSET 0x10 ++#define IPROC_NAND_CTLR_READY BIT(0) ++ ++#define IPROC_NAND_IO_CTRL_OFFSET 0x00 ++#define IPROC_NAND_APB_LE_MODE BIT(24) ++#define IPROC_NAND_INT_CTRL_READ_ENABLE BIT(6) ++ ++static bool iproc_nand_intc_ack(struct brcmnand_soc *soc) ++{ ++ struct iproc_nand_soc *priv = ++ container_of(soc, struct iproc_nand_soc, soc); ++ void __iomem *mmio = priv->ext_base + IPROC_NAND_CTLR_READY_OFFSET; ++ u32 val = brcmnand_readl(mmio); ++ ++ if (val & IPROC_NAND_CTLR_READY) { ++ brcmnand_writel(IPROC_NAND_CTLR_READY, mmio); ++ return true; ++ } ++ ++ return false; ++} ++ ++static void iproc_nand_intc_set(struct brcmnand_soc *soc, bool en) ++{ ++ struct iproc_nand_soc *priv = ++ container_of(soc, struct iproc_nand_soc, soc); ++ void __iomem *mmio = priv->idm_base + IPROC_NAND_IO_CTRL_OFFSET; ++ u32 val = brcmnand_readl(mmio); ++ ++ if (en) ++ val |= IPROC_NAND_INT_CTRL_READ_ENABLE; ++ else ++ val &= ~IPROC_NAND_INT_CTRL_READ_ENABLE; ++ ++ brcmnand_writel(val, mmio); ++} ++ ++static void iproc_nand_apb_access(struct brcmnand_soc *soc, bool prepare, ++ bool is_param) ++{ ++ struct iproc_nand_soc *priv = ++ container_of(soc, struct iproc_nand_soc, soc); ++ void __iomem *mmio = priv->idm_base + IPROC_NAND_IO_CTRL_OFFSET; ++ u32 val; ++ ++ val = brcmnand_readl(mmio); ++ ++ /* ++ * In the case of BE or when dealing with NAND data, always configure ++ * the APB bus to LE mode before accessing the FIFO and back to BE mode ++ * after the access is done ++ */ ++ if (IS_ENABLED(CONFIG_SYS_BIG_ENDIAN) || !is_param) { ++ if (prepare) ++ val |= IPROC_NAND_APB_LE_MODE; ++ else ++ val &= ~IPROC_NAND_APB_LE_MODE; ++ } else { /* when in LE accessing the parameter page, keep APB in BE */ ++ val &= ~IPROC_NAND_APB_LE_MODE; ++ } ++ ++ brcmnand_writel(val, mmio); ++} ++ ++static int iproc_nand_probe(struct udevice *dev) ++{ ++ struct udevice *pdev = dev; ++ struct iproc_nand_soc *priv = dev_get_priv(dev); ++ struct brcmnand_soc *soc; ++ struct resource res; ++ int ret; ++ ++ soc = &priv->soc; ++ ++ ret = dev_read_resource_byname(pdev, "iproc-idm", &res); ++ if (ret) ++ return ret; ++ ++ priv->idm_base = devm_ioremap(dev, res.start, resource_size(&res)); ++ if (IS_ERR(priv->idm_base)) ++ return PTR_ERR(priv->idm_base); ++ ++ ret = dev_read_resource_byname(pdev, "iproc-ext", &res); ++ if (ret) ++ return ret; ++ ++ priv->ext_base = devm_ioremap(dev, res.start, resource_size(&res)); ++ if (IS_ERR(priv->ext_base)) ++ return PTR_ERR(priv->ext_base); ++ ++ soc->ctlrdy_ack = iproc_nand_intc_ack; ++ soc->ctlrdy_set_enabled = iproc_nand_intc_set; ++ soc->prepare_data_bus = iproc_nand_apb_access; ++ ++ return brcmnand_probe(pdev, soc); ++} ++ ++static const struct udevice_id iproc_nand_dt_ids[] = { ++ { ++ .compatible = "brcm,nand-iproc", ++ }, ++ { /* sentinel */ } ++}; ++ ++U_BOOT_DRIVER(iproc_nand) = { ++ .name = "iproc-nand", ++ .id = UCLASS_MTD, ++ .of_match = iproc_nand_dt_ids, ++ .probe = iproc_nand_probe, ++ .priv_auto = sizeof(struct iproc_nand_soc), ++}; ++ ++void board_nand_init(void) ++{ ++ struct udevice *dev; ++ int ret; ++ ++ ret = uclass_get_device_by_driver(UCLASS_MTD, ++ DM_DRIVER_GET(iproc_nand), &dev); ++ if (ret && ret != -ENODEV) ++ pr_err("Failed to initialize %s. (error %d)\n", dev->name, ++ ret); ++} diff --git a/package/boot/uboot-bcm53xx/patches/0002-mtd-rawnand-nand_base-Handle-algorithm-selection.patch b/package/boot/uboot-bcm53xx/patches/0002-mtd-rawnand-nand_base-Handle-algorithm-selection.patch new file mode 100644 index 00000000000..eb2a5ec7039 --- /dev/null +++ b/package/boot/uboot-bcm53xx/patches/0002-mtd-rawnand-nand_base-Handle-algorithm-selection.patch @@ -0,0 +1,80 @@ +From d75483f8892f3a0dfb8f5aa4147e72c02c8b034c Mon Sep 17 00:00:00 2001 +From: Linus Walleij +Date: Fri, 7 Apr 2023 15:40:05 +0200 +Subject: [PATCH 2/5] mtd: rawnand: nand_base: Handle algorithm selection + +For BRCMNAND with 1-bit BCH ECC (BCH-1) such as used on the +D-Link DIR-885L and DIR-890L routers, we need to explicitly +select the ECC like this in the device tree: + + nand-ecc-algo = "bch"; + nand-ecc-strength = <1>; + nand-ecc-step-size = <512>; + +This is handled by the Linux kernel but U-Boot core does +not respect this. Fix it up by parsing the algorithm and +preserve the behaviour using this property to select +software BCH as far as possible. + +Reviewed-by: Michael Trimarchi +Acked-by: William Zhang +Signed-off-by: Linus Walleij +Tested-by: Tom Rini [am335x_evm] +Link: https://lore.kernel.org/all/20230407134008.1939717-3-linus.walleij@linaro.org/ +Signed-off-by: Dario Binacchi +--- + drivers/mtd/nand/raw/nand_base.c | 29 +++++++++++++++++++++++++---- + 1 file changed, 25 insertions(+), 4 deletions(-) + +--- a/drivers/mtd/nand/raw/nand_base.c ++++ b/drivers/mtd/nand/raw/nand_base.c +@@ -4487,6 +4487,7 @@ EXPORT_SYMBOL(nand_detect); + static int nand_dt_init(struct mtd_info *mtd, struct nand_chip *chip, ofnode node) + { + int ret, ecc_mode = -1, ecc_strength, ecc_step; ++ int ecc_algo = NAND_ECC_UNKNOWN; + const char *str; + + ret = ofnode_read_s32_default(node, "nand-bus-width", -1); +@@ -4512,10 +4513,22 @@ static int nand_dt_init(struct mtd_info + ecc_mode = NAND_ECC_SOFT_BCH; + } + +- if (ecc_mode == NAND_ECC_SOFT) { +- str = ofnode_read_string(node, "nand-ecc-algo"); +- if (str && !strcmp(str, "bch")) +- ecc_mode = NAND_ECC_SOFT_BCH; ++ str = ofnode_read_string(node, "nand-ecc-algo"); ++ if (str) { ++ /* ++ * If we are in NAND_ECC_SOFT mode, just alter the ++ * soft mode to BCH here. No change of algorithm. ++ */ ++ if (ecc_mode == NAND_ECC_SOFT) { ++ if (!strcmp(str, "bch")) ++ ecc_mode = NAND_ECC_SOFT_BCH; ++ } else { ++ if (!strcmp(str, "bch")) { ++ ecc_algo = NAND_ECC_BCH; ++ } else if (!strcmp(str, "hamming")) { ++ ecc_algo = NAND_ECC_HAMMING; ++ } ++ } + } + + ecc_strength = ofnode_read_s32_default(node, +@@ -4529,6 +4542,14 @@ static int nand_dt_init(struct mtd_info + return -EINVAL; + } + ++ /* ++ * Chip drivers may have assigned default algorithms here, ++ * onlt override it if we have found something explicitly ++ * specified in the device tree. ++ */ ++ if (ecc_algo != NAND_ECC_UNKNOWN) ++ chip->ecc.algo = ecc_algo; ++ + if (ecc_mode >= 0) + chip->ecc.mode = ecc_mode; + diff --git a/package/boot/uboot-bcm53xx/patches/0003-arm-dts-Import-device-tree-for-Broadcom-Northstar.patch b/package/boot/uboot-bcm53xx/patches/0003-arm-dts-Import-device-tree-for-Broadcom-Northstar.patch new file mode 100644 index 00000000000..6a4eef77f8f --- /dev/null +++ b/package/boot/uboot-bcm53xx/patches/0003-arm-dts-Import-device-tree-for-Broadcom-Northstar.patch @@ -0,0 +1,659 @@ +From 3d6098a662b7ff5b80c4b75c54fcd1b2baf9f150 Mon Sep 17 00:00:00 2001 +From: Linus Walleij +Date: Mon, 24 Apr 2023 09:38:28 +0200 +Subject: [PATCH 3/5] arm: dts: Import device tree for Broadcom Northstar +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This brings in the main SoC device tree used by the +Broadcom Northstar chipset, i.e. BCM4709x and BCM5301x. +This is taken from the v6.3 Linux kernel. + +Cc: Rafał Miłecki +Signed-off-by: Linus Walleij +--- + arch/arm/dts/bcm5301x.dtsi | 581 ++++++++++++++++++++++++++++ + include/dt-bindings/clock/bcm-nsp.h | 51 +++ + 2 files changed, 632 insertions(+) + create mode 100644 arch/arm/dts/bcm5301x.dtsi + create mode 100644 include/dt-bindings/clock/bcm-nsp.h + +--- /dev/null ++++ b/arch/arm/dts/bcm5301x.dtsi +@@ -0,0 +1,581 @@ ++/* ++ * Broadcom BCM470X / BCM5301X ARM platform code. ++ * Generic DTS part for all BCM53010, BCM53011, BCM53012, BCM53014, BCM53015, ++ * BCM53016, BCM53017, BCM53018, BCM4707, BCM4708 and BCM4709 SoCs ++ * ++ * Copyright 2013-2014 Hauke Mehrtens ++ * ++ * Licensed under the GNU/GPL. See COPYING for details. ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++ ++/ { ++ #address-cells = <1>; ++ #size-cells = <1>; ++ interrupt-parent = <&gic>; ++ ++ chipcommon-a-bus@18000000 { ++ compatible = "simple-bus"; ++ ranges = <0x00000000 0x18000000 0x00001000>; ++ #address-cells = <1>; ++ #size-cells = <1>; ++ ++ uart0: serial@300 { ++ compatible = "ns16550"; ++ reg = <0x0300 0x100>; ++ interrupts = ; ++ clocks = <&iprocslow>; ++ status = "disabled"; ++ }; ++ ++ uart1: serial@400 { ++ compatible = "ns16550"; ++ reg = <0x0400 0x100>; ++ interrupts = ; ++ clocks = <&iprocslow>; ++ pinctrl-names = "default"; ++ pinctrl-0 = <&pinmux_uart1>; ++ status = "disabled"; ++ }; ++ }; ++ ++ mpcore-bus@19000000 { ++ compatible = "simple-bus"; ++ ranges = <0x00000000 0x19000000 0x00023000>; ++ #address-cells = <1>; ++ #size-cells = <1>; ++ ++ a9pll: arm_clk@0 { ++ #clock-cells = <0>; ++ compatible = "brcm,nsp-armpll"; ++ clocks = <&osc>; ++ reg = <0x00000 0x1000>; ++ }; ++ ++ scu@20000 { ++ compatible = "arm,cortex-a9-scu"; ++ reg = <0x20000 0x100>; ++ }; ++ ++ timer@20200 { ++ compatible = "arm,cortex-a9-global-timer"; ++ reg = <0x20200 0x100>; ++ interrupts = ; ++ clocks = <&periph_clk>; ++ }; ++ ++ timer@20600 { ++ compatible = "arm,cortex-a9-twd-timer"; ++ reg = <0x20600 0x20>; ++ interrupts = ; ++ clocks = <&periph_clk>; ++ }; ++ ++ watchdog@20620 { ++ compatible = "arm,cortex-a9-twd-wdt"; ++ reg = <0x20620 0x20>; ++ interrupts = ; ++ clocks = <&periph_clk>; ++ }; ++ ++ gic: interrupt-controller@21000 { ++ compatible = "arm,cortex-a9-gic"; ++ #interrupt-cells = <3>; ++ #address-cells = <0>; ++ interrupt-controller; ++ reg = <0x21000 0x1000>, ++ <0x20100 0x100>; ++ }; ++ ++ L2: cache-controller@22000 { ++ compatible = "arm,pl310-cache"; ++ reg = <0x22000 0x1000>; ++ cache-unified; ++ arm,shared-override; ++ prefetch-data = <1>; ++ prefetch-instr = <1>; ++ cache-level = <2>; ++ }; ++ }; ++ ++ pmu { ++ compatible = "arm,cortex-a9-pmu"; ++ interrupts = ++ , ++ ; ++ }; ++ ++ clocks { ++ #address-cells = <1>; ++ #size-cells = <1>; ++ ranges; ++ ++ osc: oscillator { ++ #clock-cells = <0>; ++ compatible = "fixed-clock"; ++ clock-frequency = <25000000>; ++ }; ++ ++ iprocmed: iprocmed { ++ #clock-cells = <0>; ++ compatible = "fixed-factor-clock"; ++ clocks = <&genpll BCM_NSP_GENPLL_IPROCFAST_CLK>; ++ clock-div = <2>; ++ clock-mult = <1>; ++ }; ++ ++ iprocslow: iprocslow { ++ #clock-cells = <0>; ++ compatible = "fixed-factor-clock"; ++ clocks = <&genpll BCM_NSP_GENPLL_IPROCFAST_CLK>; ++ clock-div = <4>; ++ clock-mult = <1>; ++ }; ++ ++ periph_clk: periph_clk { ++ #clock-cells = <0>; ++ compatible = "fixed-factor-clock"; ++ clocks = <&a9pll>; ++ clock-div = <2>; ++ clock-mult = <1>; ++ }; ++ }; ++ ++ axi@18000000 { ++ compatible = "brcm,bus-axi"; ++ reg = <0x18000000 0x1000>; ++ ranges = <0x00000000 0x18000000 0x00100000>; ++ #address-cells = <1>; ++ #size-cells = <1>; ++ ++ #interrupt-cells = <1>; ++ interrupt-map-mask = <0x000fffff 0xffff>; ++ interrupt-map = ++ /* ChipCommon */ ++ <0x00000000 0 &gic GIC_SPI 85 IRQ_TYPE_LEVEL_HIGH>, ++ ++ /* Switch Register Access Block */ ++ <0x00007000 0 &gic GIC_SPI 95 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00007000 1 &gic GIC_SPI 96 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00007000 2 &gic GIC_SPI 97 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00007000 3 &gic GIC_SPI 98 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00007000 4 &gic GIC_SPI 99 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00007000 5 &gic GIC_SPI 100 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00007000 6 &gic GIC_SPI 101 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00007000 7 &gic GIC_SPI 102 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00007000 8 &gic GIC_SPI 103 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00007000 9 &gic GIC_SPI 104 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00007000 10 &gic GIC_SPI 105 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00007000 11 &gic GIC_SPI 106 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00007000 12 &gic GIC_SPI 107 IRQ_TYPE_LEVEL_HIGH>, ++ ++ /* PCIe Controller 0 */ ++ <0x00012000 0 &gic GIC_SPI 126 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00012000 1 &gic GIC_SPI 127 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00012000 2 &gic GIC_SPI 128 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00012000 3 &gic GIC_SPI 129 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00012000 4 &gic GIC_SPI 130 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00012000 5 &gic GIC_SPI 131 IRQ_TYPE_LEVEL_HIGH>, ++ ++ /* PCIe Controller 1 */ ++ <0x00013000 0 &gic GIC_SPI 132 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00013000 1 &gic GIC_SPI 133 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00013000 2 &gic GIC_SPI 134 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00013000 3 &gic GIC_SPI 135 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00013000 4 &gic GIC_SPI 136 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00013000 5 &gic GIC_SPI 137 IRQ_TYPE_LEVEL_HIGH>, ++ ++ /* PCIe Controller 2 */ ++ <0x00014000 0 &gic GIC_SPI 138 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00014000 1 &gic GIC_SPI 138 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00014000 2 &gic GIC_SPI 140 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00014000 3 &gic GIC_SPI 141 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00014000 4 &gic GIC_SPI 142 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00014000 5 &gic GIC_SPI 143 IRQ_TYPE_LEVEL_HIGH>, ++ ++ /* USB 2.0 Controller */ ++ <0x00021000 0 &gic GIC_SPI 79 IRQ_TYPE_LEVEL_HIGH>, ++ ++ /* USB 3.0 Controller */ ++ <0x00023000 0 &gic GIC_SPI 80 IRQ_TYPE_LEVEL_HIGH>, ++ ++ /* Ethernet Controller 0 */ ++ <0x00024000 0 &gic GIC_SPI 147 IRQ_TYPE_LEVEL_HIGH>, ++ ++ /* Ethernet Controller 1 */ ++ <0x00025000 0 &gic GIC_SPI 148 IRQ_TYPE_LEVEL_HIGH>, ++ ++ /* Ethernet Controller 2 */ ++ <0x00026000 0 &gic GIC_SPI 149 IRQ_TYPE_LEVEL_HIGH>, ++ ++ /* Ethernet Controller 3 */ ++ <0x00027000 0 &gic GIC_SPI 150 IRQ_TYPE_LEVEL_HIGH>, ++ ++ /* NAND Controller */ ++ <0x00028000 0 &gic GIC_SPI 64 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00028000 1 &gic GIC_SPI 65 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00028000 2 &gic GIC_SPI 66 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00028000 3 &gic GIC_SPI 67 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00028000 4 &gic GIC_SPI 68 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00028000 5 &gic GIC_SPI 69 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00028000 6 &gic GIC_SPI 70 IRQ_TYPE_LEVEL_HIGH>, ++ <0x00028000 7 &gic GIC_SPI 71 IRQ_TYPE_LEVEL_HIGH>; ++ ++ chipcommon: chipcommon@0 { ++ reg = <0x00000000 0x1000>; ++ ++ gpio-controller; ++ #gpio-cells = <2>; ++ interrupt-controller; ++ #interrupt-cells = <2>; ++ }; ++ ++ pcie0: pcie@12000 { ++ reg = <0x00012000 0x1000>; ++ }; ++ ++ pcie1: pcie@13000 { ++ reg = <0x00013000 0x1000>; ++ }; ++ ++ pcie2: pcie@14000 { ++ reg = <0x00014000 0x1000>; ++ }; ++ ++ usb2: usb2@21000 { ++ reg = <0x00021000 0x1000>; ++ ++ #address-cells = <1>; ++ #size-cells = <1>; ++ ranges; ++ ++ interrupt-parent = <&gic>; ++ ++ ehci: usb@21000 { ++ #usb-cells = <0>; ++ ++ compatible = "generic-ehci"; ++ reg = <0x00021000 0x1000>; ++ interrupts = ; ++ phys = <&usb2_phy>; ++ ++ #address-cells = <1>; ++ #size-cells = <0>; ++ ++ ehci_port1: port@1 { ++ reg = <1>; ++ #trigger-source-cells = <0>; ++ }; ++ ++ ehci_port2: port@2 { ++ reg = <2>; ++ #trigger-source-cells = <0>; ++ }; ++ }; ++ ++ ohci: usb@22000 { ++ #usb-cells = <0>; ++ ++ compatible = "generic-ohci"; ++ reg = <0x00022000 0x1000>; ++ interrupts = ; ++ ++ #address-cells = <1>; ++ #size-cells = <0>; ++ ++ ohci_port1: port@1 { ++ reg = <1>; ++ #trigger-source-cells = <0>; ++ }; ++ ++ ohci_port2: port@2 { ++ reg = <2>; ++ #trigger-source-cells = <0>; ++ }; ++ }; ++ }; ++ ++ usb3: usb3@23000 { ++ reg = <0x00023000 0x1000>; ++ ++ #address-cells = <1>; ++ #size-cells = <1>; ++ ranges; ++ ++ interrupt-parent = <&gic>; ++ ++ xhci: usb@23000 { ++ #usb-cells = <0>; ++ ++ compatible = "generic-xhci"; ++ reg = <0x00023000 0x1000>; ++ interrupts = ; ++ phys = <&usb3_phy>; ++ phy-names = "usb"; ++ ++ #address-cells = <1>; ++ #size-cells = <0>; ++ ++ xhci_port1: port@1 { ++ reg = <1>; ++ #trigger-source-cells = <0>; ++ }; ++ }; ++ }; ++ ++ gmac0: ethernet@24000 { ++ reg = <0x24000 0x800>; ++ }; ++ ++ gmac1: ethernet@25000 { ++ reg = <0x25000 0x800>; ++ }; ++ ++ gmac2: ethernet@26000 { ++ reg = <0x26000 0x800>; ++ }; ++ ++ gmac3: ethernet@27000 { ++ reg = <0x27000 0x800>; ++ }; ++ }; ++ ++ pwm: pwm@18002000 { ++ compatible = "brcm,iproc-pwm"; ++ reg = <0x18002000 0x28>; ++ clocks = <&osc>; ++ #pwm-cells = <3>; ++ status = "disabled"; ++ }; ++ ++ mdio: mdio@18003000 { ++ compatible = "brcm,iproc-mdio"; ++ reg = <0x18003000 0x8>; ++ #size-cells = <0>; ++ #address-cells = <1>; ++ }; ++ ++ mdio-mux@18003000 { ++ compatible = "mdio-mux-mmioreg", "mdio-mux"; ++ mdio-parent-bus = <&mdio>; ++ #address-cells = <1>; ++ #size-cells = <0>; ++ reg = <0x18003000 0x4>; ++ mux-mask = <0x200>; ++ ++ mdio@0 { ++ reg = <0x0>; ++ #address-cells = <1>; ++ #size-cells = <0>; ++ ++ usb3_phy: usb3-phy@10 { ++ compatible = "brcm,ns-ax-usb3-phy"; ++ reg = <0x10>; ++ usb3-dmp-syscon = <&usb3_dmp>; ++ #phy-cells = <0>; ++ status = "disabled"; ++ }; ++ }; ++ }; ++ ++ usb3_dmp: syscon@18105000 { ++ reg = <0x18105000 0x1000>; ++ }; ++ ++ uart2: serial@18008000 { ++ compatible = "ns16550a"; ++ reg = <0x18008000 0x20>; ++ clocks = <&iprocslow>; ++ interrupts = ; ++ reg-shift = <2>; ++ status = "disabled"; ++ }; ++ ++ i2c0: i2c@18009000 { ++ compatible = "brcm,iproc-i2c"; ++ reg = <0x18009000 0x50>; ++ interrupts = ; ++ #address-cells = <1>; ++ #size-cells = <0>; ++ clock-frequency = <100000>; ++ status = "disabled"; ++ }; ++ ++ dmu-bus@1800c000 { ++ compatible = "simple-bus"; ++ ranges = <0 0x1800c000 0x1000>; ++ #address-cells = <1>; ++ #size-cells = <1>; ++ ++ cru-bus@100 { ++ compatible = "brcm,ns-cru", "simple-mfd"; ++ reg = <0x100 0x1a4>; ++ ranges; ++ #address-cells = <1>; ++ #size-cells = <1>; ++ ++ lcpll0: clock-controller@100 { ++ #clock-cells = <1>; ++ compatible = "brcm,nsp-lcpll0"; ++ reg = <0x100 0x14>; ++ clocks = <&osc>; ++ clock-output-names = "lcpll0", "pcie_phy", ++ "sdio", "ddr_phy"; ++ }; ++ ++ genpll: clock-controller@140 { ++ #clock-cells = <1>; ++ compatible = "brcm,nsp-genpll"; ++ reg = <0x140 0x24>; ++ clocks = <&osc>; ++ clock-output-names = "genpll", "phy", ++ "ethernetclk", ++ "usbclk", "iprocfast", ++ "sata1", "sata2"; ++ }; ++ ++ usb2_phy: phy@164 { ++ compatible = "brcm,ns-usb2-phy"; ++ reg = <0x164 0x4>; ++ brcm,syscon-clkset = <&cru_clkset>; ++ clocks = <&genpll BCM_NSP_GENPLL_USB_PHY_REF_CLK>; ++ clock-names = "phy-ref-clk"; ++ #phy-cells = <0>; ++ }; ++ ++ cru_clkset: syscon@180 { ++ compatible = "brcm,cru-clkset", "syscon"; ++ reg = <0x180 0x4>; ++ }; ++ ++ pinctrl: pinctrl@1c0 { ++ compatible = "brcm,bcm4708-pinmux"; ++ reg = <0x1c0 0x24>; ++ reg-names = "cru_gpio_control"; ++ ++ spi-pins { ++ groups = "spi_grp"; ++ function = "spi"; ++ }; ++ ++ pinmux_i2c: i2c-pins { ++ groups = "i2c_grp"; ++ function = "i2c"; ++ }; ++ ++ pinmux_pwm: pwm-pins { ++ groups = "pwm0_grp", "pwm1_grp", ++ "pwm2_grp", "pwm3_grp"; ++ function = "pwm"; ++ }; ++ ++ pinmux_uart1: uart1-pins { ++ groups = "uart1_grp"; ++ function = "uart1"; ++ }; ++ }; ++ ++ thermal: thermal@2c0 { ++ compatible = "brcm,ns-thermal"; ++ reg = <0x2c0 0x10>; ++ #thermal-sensor-cells = <0>; ++ }; ++ }; ++ }; ++ ++ srab: ethernet-switch@18007000 { ++ compatible = "brcm,bcm53011-srab", "brcm,bcm5301x-srab"; ++ reg = <0x18007000 0x1000>; ++ ++ status = "disabled"; ++ ++ /* ports are defined in board DTS */ ++ ports { ++ #address-cells = <1>; ++ #size-cells = <0>; ++ }; ++ }; ++ ++ rng: rng@18004000 { ++ compatible = "brcm,bcm5301x-rng"; ++ reg = <0x18004000 0x14>; ++ }; ++ ++ nand_controller: nand-controller@18028000 { ++ compatible = "brcm,nand-iproc", "brcm,brcmnand-v6.1", "brcm,brcmnand"; ++ reg = <0x18028000 0x600>, <0x1811a408 0x600>, <0x18028f00 0x20>; ++ reg-names = "nand", "iproc-idm", "iproc-ext"; ++ interrupts = ; ++ ++ #address-cells = <1>; ++ #size-cells = <0>; ++ ++ brcm,nand-has-wp; ++ }; ++ ++ spi@18029200 { ++ compatible = "brcm,spi-nsp-qspi", "brcm,spi-bcm-qspi"; ++ reg = <0x18029200 0x184>, ++ <0x18029000 0x124>, ++ <0x1811b408 0x004>, ++ <0x180293a0 0x01c>; ++ reg-names = "mspi", "bspi", "intr_regs", "intr_status_reg"; ++ interrupts = , ++ , ++ , ++ , ++ , ++ , ++ ; ++ interrupt-names = "mspi_done", ++ "mspi_halted", ++ "spi_lr_fullness_reached", ++ "spi_lr_session_aborted", ++ "spi_lr_impatient", ++ "spi_lr_session_done", ++ "spi_lr_overread"; ++ clocks = <&iprocmed>; ++ clock-names = "iprocmed"; ++ num-cs = <2>; ++ #address-cells = <1>; ++ #size-cells = <0>; ++ ++ spi_nor: flash@0 { ++ compatible = "jedec,spi-nor"; ++ reg = <0>; ++ spi-max-frequency = <20000000>; ++ status = "disabled"; ++ ++ partitions { ++ compatible = "brcm,bcm947xx-cfe-partitions"; ++ }; ++ }; ++ }; ++ ++ thermal-zones { ++ cpu_thermal: cpu-thermal { ++ polling-delay-passive = <0>; ++ polling-delay = <1000>; ++ coefficients = <(-556) 418000>; ++ thermal-sensors = <&thermal>; ++ ++ trips { ++ cpu-crit { ++ temperature = <125000>; ++ hysteresis = <0>; ++ type = "critical"; ++ }; ++ }; ++ ++ cooling-maps { ++ }; ++ }; ++ }; ++}; +--- /dev/null ++++ b/include/dt-bindings/clock/bcm-nsp.h +@@ -0,0 +1,51 @@ ++/* ++ * BSD LICENSE ++ * ++ * Copyright(c) 2015 Broadcom Corporation. All rights reserved. ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * * Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * * Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * * Neither the name of Broadcom Corporation nor the names of its ++ * contributors may be used to endorse or promote products derived ++ * from this software without specific prior written permission. ++ * ++ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ++ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ++ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ++ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ++ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ++ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ++ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ++ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ++ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ++ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ++ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ */ ++ ++#ifndef _CLOCK_BCM_NSP_H ++#define _CLOCK_BCM_NSP_H ++ ++/* GENPLL clock channel ID */ ++#define BCM_NSP_GENPLL 0 ++#define BCM_NSP_GENPLL_PHY_CLK 1 ++#define BCM_NSP_GENPLL_ENET_SW_CLK 2 ++#define BCM_NSP_GENPLL_USB_PHY_REF_CLK 3 ++#define BCM_NSP_GENPLL_IPROCFAST_CLK 4 ++#define BCM_NSP_GENPLL_SATA1_CLK 5 ++#define BCM_NSP_GENPLL_SATA2_CLK 6 ++ ++/* LCPLL0 clock channel ID */ ++#define BCM_NSP_LCPLL0 0 ++#define BCM_NSP_LCPLL0_PCIE_PHY_REF_CLK 1 ++#define BCM_NSP_LCPLL0_SDIO_CLK 2 ++#define BCM_NSP_LCPLL0_DDR_PHY_CLK 3 ++ ++#endif /* _CLOCK_BCM_NSP_H */ diff --git a/package/boot/uboot-bcm53xx/patches/0004-arm-Add-support-for-the-Broadcom-Northstar-SoCs.patch b/package/boot/uboot-bcm53xx/patches/0004-arm-Add-support-for-the-Broadcom-Northstar-SoCs.patch new file mode 100644 index 00000000000..92eaa46e51c --- /dev/null +++ b/package/boot/uboot-bcm53xx/patches/0004-arm-Add-support-for-the-Broadcom-Northstar-SoCs.patch @@ -0,0 +1,66 @@ +From b81ea0a64b01ae42e8b41d2a8b9a3fabffe97489 Mon Sep 17 00:00:00 2001 +From: Linus Walleij +Date: Mon, 24 Apr 2023 09:38:29 +0200 +Subject: [PATCH 4/5] arm: Add support for the Broadcom Northstar SoCs +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The original Northstar is an ARM SoC series that comprise +BCM4709x and BCM5301x and uses a dual-core Cortex A9, the +global timer and a few other things. + +This series should not be confused with North Star Plus +(NSP) which is partly supported by U-Boot already. + +The SoC is well supported by the Linux kernel and OpenWrt +as it is used in many routers. + +Since we currently don't need any chip-specific quirks +and can get the system up from just the device tree, a +mach-* directory doesn't even need to be added, just +some small Kconfig fragments. + +Cc: Rafał Miłecki +Signed-off-by: Linus Walleij +--- + arch/arm/Kconfig | 21 ++++++++++++++++++++- + 1 file changed, 20 insertions(+), 1 deletion(-) + +--- a/arch/arm/Kconfig ++++ b/arch/arm/Kconfig +@@ -357,7 +357,7 @@ config SYS_ARM_ARCH + + choice + prompt "Select the ARM data write cache policy" +- default SYS_ARM_CACHE_WRITETHROUGH if TARGET_BCMCYGNUS || RZA1 ++ default SYS_ARM_CACHE_WRITETHROUGH if TARGET_BCMCYGNUS || TARGET_BCMNS || RZA1 + default SYS_ARM_CACHE_WRITEBACK + + config SYS_ARM_CACHE_WRITEBACK +@@ -670,6 +670,25 @@ config TARGET_BCMCYGNUS + imply HASH_VERIFY + imply NETDEVICES + ++config TARGET_BCMNS ++ bool "Support Broadcom Northstar" ++ select CPU_V7A ++ select DM ++ select DM_GPIO ++ select DM_SERIAL ++ select OF_CONTROL ++ select TIMER ++ select SYS_NS16550 ++ select ARM_GLOBAL_TIMER ++ imply SYS_THUMB_BUILD ++ imply MTD_RAW_NAND ++ imply NAND_BRCMNAND ++ imply NAND_BRCMNAND_IPROC ++ help ++ Support for Broadcom Northstar SoCs. NS is a dual-core 32-bit ++ ARMv7 Cortex-A9 SoC family including BCM4708, BCM47094, ++ BCM5301x etc. ++ + config TARGET_BCMNS2 + bool "Support Broadcom Northstar2" + select ARM64 diff --git a/package/boot/uboot-bcm53xx/patches/0005-board-Add-new-Broadcom-Northstar-board.patch b/package/boot/uboot-bcm53xx/patches/0005-board-Add-new-Broadcom-Northstar-board.patch new file mode 100644 index 00000000000..158718133d4 --- /dev/null +++ b/package/boot/uboot-bcm53xx/patches/0005-board-Add-new-Broadcom-Northstar-board.patch @@ -0,0 +1,372 @@ +From 652a6fa45b6c9d52dd9685fc12ad662e54a9092e Mon Sep 17 00:00:00 2001 +From: Linus Walleij +Date: Mon, 24 Apr 2023 09:38:30 +0200 +Subject: [PATCH 5/5] board: Add new Broadcom Northstar board +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This adds a simple Northstar "BRCMNS" board to be used with +the BCM4708x and BCM5301x chips. + +The main intention is to use this with the D-Link DIR-890L +and DIR-885L routers for loading the kernel into RAM from +NAND memory using the BCH-1 ECC and using the separately +submitted SEAMA load command, so we are currently not adding +support for things such as networking. + +The DTS file is a multiplatform NorthStar board, designed to +be usable with several NorthStar designs by avoiding any +particulars not related to the operation of U-Boot. + +If other board need other ECC for example, they need to +create a separate DTS file and augment the code, but I don't +know if any other users will turn up. + +Cc: Rafał Miłecki +Signed-off-by: Linus Walleij +--- + arch/arm/Kconfig | 1 + + arch/arm/dts/Makefile | 2 ++ + arch/arm/dts/ns-board.dts | 57 ++++++++++++++++++++++++++++++ + board/broadcom/bcmns/Kconfig | 12 +++++++ + board/broadcom/bcmns/MAINTAINERS | 6 ++++ + board/broadcom/bcmns/Makefile | 2 ++ + board/broadcom/bcmns/ns.c | 60 ++++++++++++++++++++++++++++++++ + configs/bcmns_defconfig | 41 ++++++++++++++++++++++ + doc/board/broadcom/index.rst | 1 + + doc/board/broadcom/northstar.rst | 44 +++++++++++++++++++++++ + include/configs/bcmns.h | 49 ++++++++++++++++++++++++++ + 11 files changed, 275 insertions(+) + create mode 100644 arch/arm/dts/ns-board.dts + create mode 100644 board/broadcom/bcmns/Kconfig + create mode 100644 board/broadcom/bcmns/MAINTAINERS + create mode 100644 board/broadcom/bcmns/Makefile + create mode 100644 board/broadcom/bcmns/ns.c + create mode 100644 configs/bcmns_defconfig + create mode 100644 doc/board/broadcom/northstar.rst + create mode 100644 include/configs/bcmns.h + +--- a/arch/arm/Kconfig ++++ b/arch/arm/Kconfig +@@ -2286,6 +2286,7 @@ source "board/Marvell/octeontx2/Kconfig" + source "board/armltd/vexpress/Kconfig" + source "board/armltd/vexpress64/Kconfig" + source "board/cortina/presidio-asic/Kconfig" ++source "board/broadcom/bcmns/Kconfig" + source "board/broadcom/bcmns3/Kconfig" + source "board/cavium/thunderx/Kconfig" + source "board/eets/pdu001/Kconfig" +--- a/arch/arm/dts/Makefile ++++ b/arch/arm/dts/Makefile +@@ -1185,6 +1185,8 @@ dtb-$(CONFIG_ARCH_BCM283X) += \ + bcm2837-rpi-cm3-io3.dtb \ + bcm2711-rpi-4-b.dtb + ++dtb-$(CONFIG_TARGET_BCMNS) += ns-board.dtb ++ + dtb-$(CONFIG_TARGET_BCMNS3) += ns3-board.dtb + + dtb-$(CONFIG_ARCH_BCMSTB) += bcm7xxx.dtb +--- /dev/null ++++ b/arch/arm/dts/ns-board.dts +@@ -0,0 +1,57 @@ ++// SPDX-License-Identifier: GPL-2.0+ ++ ++/dts-v1/; ++ ++#include "bcm5301x.dtsi" ++ ++/ { ++ /* ++ * The Northstar does not have a proper fallback compatible, but ++ * these basic chips will suffice. ++ */ ++ model = "Northstar model"; ++ compatible = "brcm,bcm47094", "brcm,bcm4708"; ++ #address-cells = <1>; ++ #size-cells = <1>; ++ interrupt-parent = <&gic>; ++ ++ memory { ++ device_type = "memory"; ++ reg = <0x00000000 0x08000000>, ++ <0x88000000 0x08000000>; ++ }; ++ ++ aliases { ++ serial0 = &uart0; ++ }; ++ ++ chosen { ++ stdout-path = "serial0:115200n8"; ++ }; ++ ++ nand-controller@18028000 { ++ nandcs: nand@0 { ++ compatible = "brcm,nandcs"; ++ reg = <0>; ++ #address-cells = <1>; ++ #size-cells = <1>; ++ ++ /* ++ * Same as using the bcm5301x-nand-cs0-bch1.dtsi ++ * include from the Linux kernel. ++ */ ++ nand-ecc-algo = "bch"; ++ nand-ecc-strength = <1>; ++ nand-ecc-step-size = <512>; ++ ++ partitions { ++ compatible = "brcm,bcm947xx-cfe-partitions"; ++ }; ++ }; ++ }; ++}; ++ ++&uart0 { ++ clock-frequency = <125000000>; ++ status = "okay"; ++}; +--- /dev/null ++++ b/board/broadcom/bcmns/Kconfig +@@ -0,0 +1,12 @@ ++if TARGET_BCMNS ++ ++config SYS_BOARD ++ default "bcmns" ++ ++config SYS_VENDOR ++ default "broadcom" ++ ++config SYS_CONFIG_NAME ++ default "bcmns" ++ ++endif +--- /dev/null ++++ b/board/broadcom/bcmns/MAINTAINERS +@@ -0,0 +1,6 @@ ++BCMNS BOARD ++M: Linus Walleij ++S: Maintained ++F: board/broadcom/bcmnsp/ ++F: configs/bcmnsp_defconfig ++F: include/configs/bcmnsp.h +--- /dev/null ++++ b/board/broadcom/bcmns/Makefile +@@ -0,0 +1,2 @@ ++# SPDX-License-Identifier: GPL-2.0-or-later ++obj-y := ns.o +--- /dev/null ++++ b/board/broadcom/bcmns/ns.c +@@ -0,0 +1,60 @@ ++// SPDX-License-Identifier: GPL-2.0+ ++/* ++ * Broadcom Northstar generic board set-up code ++ * Copyright (C) 2023 Linus Walleij ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++DECLARE_GLOBAL_DATA_PTR; ++ ++int dram_init(void) ++{ ++ return fdtdec_setup_mem_size_base(); ++} ++ ++int dram_init_banksize(void) ++{ ++ return fdtdec_setup_memory_banksize(); ++} ++ ++int board_late_init(void) ++{ ++ /* LEDs etc can be initialized here */ ++ return 0; ++} ++ ++int board_init(void) ++{ ++ return 0; ++} ++ ++void reset_cpu(void) ++{ ++} ++ ++int print_cpuinfo(void) ++{ ++ printf("BCMNS Northstar SoC\n"); ++ return 0; ++} ++ ++int misc_init_r(void) ++{ ++ return 0; ++} ++ ++int ft_board_setup(void *fdt, struct bd_info *bd) ++{ ++ printf("Northstar board setup: DTB at 0x%08lx\n", (ulong)fdt); ++ return 0; ++} ++ +--- /dev/null ++++ b/configs/bcmns_defconfig +@@ -0,0 +1,41 @@ ++CONFIG_ARM=y ++CONFIG_TARGET_BCMNS=y ++CONFIG_TEXT_BASE=0x00008000 ++CONFIG_SYS_MALLOC_LEN=0x2000000 ++CONFIG_SYS_MALLOC_F_LEN=0x8000 ++CONFIG_NR_DRAM_BANKS=2 ++CONFIG_DEFAULT_DEVICE_TREE="ns-board" ++CONFIG_IDENT_STRING="Broadcom Northstar" ++CONFIG_SYS_LOAD_ADDR=0x00008000 ++CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y ++CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x00100000 ++# CONFIG_BOOTSTD is not set ++CONFIG_AUTOBOOT_KEYED=y ++CONFIG_AUTOBOOT_PROMPT="Boot Northstar system in %d seconds\n" ++CONFIG_BOOTDELAY=1 ++CONFIG_USE_BOOTCOMMAND=y ++CONFIG_BOOTCOMMAND="run bootcmd_dlink_dir8xxl" ++CONFIG_SYS_PROMPT="northstar> " ++CONFIG_ENV_VARS_UBOOT_CONFIG=y ++CONFIG_OF_BOARD_SETUP=y ++CONFIG_OF_STDOUT_VIA_ALIAS=y ++CONFIG_DISPLAY_BOARDINFO_LATE=y ++CONFIG_HUSH_PARSER=y ++CONFIG_SYS_MAXARGS=64 ++CONFIG_CMD_SEAMA=y ++CONFIG_CMD_BOOTZ=y ++CONFIG_CMD_CACHE=y ++CONFIG_OF_EMBED=y ++CONFIG_USE_HOSTNAME=y ++CONFIG_HOSTNAME="NS" ++CONFIG_CLK=y ++CONFIG_MTD=y ++CONFIG_DM_MTD=y ++CONFIG_MTD_RAW_NAND=y ++CONFIG_NAND_BRCMNAND=y ++CONFIG_SYS_NAND_ONFI_DETECTION=y ++CONFIG_CMD_NAND=y ++CONFIG_DM_SERIAL=y ++CONFIG_SYS_NS16550=y ++# CONFIG_NET is not set ++# CONFIG_EFI_LOADER is not set +--- a/doc/board/broadcom/index.rst ++++ b/doc/board/broadcom/index.rst +@@ -9,3 +9,4 @@ Broadcom + + bcm7xxx + raspberrypi ++ northstar +--- /dev/null ++++ b/doc/board/broadcom/northstar.rst +@@ -0,0 +1,44 @@ ++.. SPDX-License-Identifier: GPL-2.0+ ++.. Copyright (C) 2023 Linus Walleij ++ ++Broadcom Northstar Boards ++========================= ++ ++This document describes how to use U-Boot on the Broadcom Northstar ++boards, comprised of the Cortex A9 ARM-based BCM470x and BCM5301x SoCs. These ++were introduced in 2012-2013 and some of them are also called StrataGX. ++ ++Northstar is part of the iProc SoC family. ++ ++A good overview of these boards can be found in Jon Mason's presentation ++"Enabling New Hardware in U-Boot" where the difference between Northstar ++and Northstar Plus and Northstar 2 (Aarch64) is addressed. ++ ++The ROM in the Northstar SoC will typically look into NOR flash memory ++for a boot loader, and the way this works is undocumented. It should be ++possible to execute U-Boot as the first binary from the NOR flash but ++this usage path is unexplored. Please add information if you know more. ++ ++D-Link Boards ++------------- ++ ++When we use U-Boot with D-Link routers, the NOR flash has a boot loader ++and web server that can re-flash the bigger NAND flash memory for object ++code in the SEAMA format, so on these platforms U-Boot is converted into ++a SEAMA binary and installed in the SoC using the flash tool resident in ++the NOR flash. Details can be found in the OpenWrt project codebase. ++ ++Configure ++--------- ++ ++.. code-block:: console ++ ++ $ make CROSS_COMPILE=${CROSS_COMPILE} bcmns_defconfig ++ ++Build ++----- ++ ++.. code-block:: console ++ ++ $ make CROSS_COMPILE=${CROSS_COMPILE} ++ $ ${CROSS_COMPILE}strip u-boot +--- /dev/null ++++ b/include/configs/bcmns.h +@@ -0,0 +1,49 @@ ++/* SPDX-License-Identifier: GPL-2.0+ */ ++ ++#ifndef __BCM_NS_H ++#define __BCM_NS_H ++ ++#include ++ ++/* Physical Memory Map */ ++#define V2M_BASE 0x00000000 ++#define PHYS_SDRAM_1 V2M_BASE ++ ++#define CFG_SYS_SDRAM_BASE PHYS_SDRAM_1 ++ ++/* Called "periph_clk" in Linux, used by the global timer */ ++#define CFG_SYS_HZ_CLOCK 500000000 ++ ++/* Called "iprocslow" in Linux */ ++#define CFG_SYS_NS16550_CLK 125000000 ++ ++/* console configuration */ ++#define CONSOLE_ARGS "console_args=console=ttyS0,115200n8\0" ++#define MAX_CPUS "max_cpus=maxcpus=2\0" ++#define EXTRA_ARGS "extra_args=earlycon=uart8250,mmio32,0x18000300\0" ++ ++#define BASE_ARGS "${console_args} ${extra_args} ${pcie_args}" \ ++ " ${max_cpus} ${log_level} ${reserved_mem}" ++#define SETBOOTARGS "setbootargs=setenv bootargs " BASE_ARGS "\0" ++ ++#define KERNEL_LOADADDR_CFG \ ++ "loadaddr=0x01000000\0" \ ++ "dtb_loadaddr=0x02000000\0" ++ ++/* ++ * Hardcoded for the only boards we support, if you add more ++ * boards, add a more clever bootcmd! ++ */ ++#define NS_BOOTCMD "bootcmd_dlink_dir8xxl=seama 0x00fe0000; go 0x01000000" ++ ++#define ARCH_ENV_SETTINGS \ ++ CONSOLE_ARGS \ ++ MAX_CPUS \ ++ EXTRA_ARGS \ ++ KERNEL_LOADADDR_CFG \ ++ NS_BOOTCMD ++ ++#define CFG_EXTRA_ENV_SETTINGS \ ++ ARCH_ENV_SETTINGS ++ ++#endif /* __BCM_NS_H */