diff --git a/include/kernel-5.15 b/include/kernel-5.15 index bf681e2edbe..3052c783a95 100644 --- a/include/kernel-5.15 +++ b/include/kernel-5.15 @@ -1,2 +1,2 @@ -LINUX_VERSION-5.15 = .120 -LINUX_KERNEL_HASH-5.15.120 = 6499089eae6b271063cb3e873ab7f4ba0543cfb21dcc9c54d9bcf5357db683f6 +LINUX_VERSION-5.15 = .123 +LINUX_KERNEL_HASH-5.15.123 = 2de69544a12e6a059163c58fc901c13bcf22e8cac39c66b56f8fbb633399bf93 diff --git a/include/kernel-6.1 b/include/kernel-6.1 index d1628fbb80c..0bcf420f427 100644 --- a/include/kernel-6.1 +++ b/include/kernel-6.1 @@ -1,2 +1,2 @@ -LINUX_VERSION-6.1 = .41 -LINUX_KERNEL_HASH-6.1.41 = 312809a78eea052a08a6580f47b2ed8dd28e5633461d6731febaf3cb1e570bb7 \ No newline at end of file +LINUX_VERSION-6.1 = .42 +LINUX_KERNEL_HASH-6.1.42 = aaf8261b551c8b76b81eab8780b446e88cea4d551ae517ac3a9b2dbdbd381ed3 diff --git a/package/boot/arm-trusted-firmware-mediatek/Makefile b/package/boot/arm-trusted-firmware-mediatek/Makefile index 0d1ad8e98a2..853049cfb0e 100644 --- a/package/boot/arm-trusted-firmware-mediatek/Makefile +++ b/package/boot/arm-trusted-firmware-mediatek/Makefile @@ -15,7 +15,7 @@ PKG_SOURCE_PROTO:=git PKG_SOURCE_URL=https://github.com/mtk-openwrt/arm-trusted-firmware.git PKG_SOURCE_DATE:=2023-07-24 PKG_SOURCE_VERSION:=00ac6db375b76e57e1f5e9e9bffa033e907c3581 -PKG_MIRROR_HASH:=35e84b2160a7ddc083439e469d7366bb4e6098fc43b5616e68f001364eb05835 +PKG_MIRROR_HASH:=74fc18395532c4292f530da8d00fa1873ada4e05e600c0077a7b7f85ace0d913 PKG_MAINTAINER:=Daniel Golle diff --git a/package/boot/uboot-mediatek/patches/102-ram-mediatek-include-linux-sizes.h-for-SZ_-macros.patch b/package/boot/uboot-mediatek/patches/102-ram-mediatek-include-linux-sizes.h-for-SZ_-macros.patch new file mode 100644 index 00000000000..3cfc6849563 --- /dev/null +++ b/package/boot/uboot-mediatek/patches/102-ram-mediatek-include-linux-sizes.h-for-SZ_-macros.patch @@ -0,0 +1,47 @@ +From 4bd66fd5b69eda41b4320fd6f8db50a7b7fa7bf7 Mon Sep 17 00:00:00 2001 +Message-ID: <4bd66fd5b69eda41b4320fd6f8db50a7b7fa7bf7.1690828424.git.daniel@makrotopia.org> +From: Daniel Golle +Date: Mon, 31 Jul 2023 19:25:04 +0100 +Subject: [PATCH] ram: mediatek: include for SZ_* macros +To: Ryder Lee , + Weijie Gao , + Chunfeng Yun , + GSS_MTK_Uboot_upstream , + u-boot@lists.denx.de + +Something between U-Boot 2023.04 and 2023.07.02 resulted in no longer +implicitely including in the DDR3 RAM driver for the +MT7929 SoC. The result is a build failure: +drivers/ram/mediatek/ddr3-mt7629.c: In function 'mtk_ddr3_get_info': +drivers/ram/mediatek/ddr3-mt7629.c:734:30: error: 'SZ_128M' undeclared (first use in this function) + 734 | info->size = SZ_128M; + | ^~~~~~~ +drivers/ram/mediatek/ddr3-mt7629.c:734:30: note: each undeclared identifier is reported only once for each function it appears in +drivers/ram/mediatek/ddr3-mt7629.c:737:30: error: 'SZ_256M' undeclared (first use in this function) + 737 | info->size = SZ_256M; + | ^~~~~~~ +drivers/ram/mediatek/ddr3-mt7629.c:740:30: error: 'SZ_512M' undeclared (first use in this function) + 740 | info->size = SZ_512M; + | ^~~~~~~ +drivers/ram/mediatek/ddr3-mt7629.c:743:30: error: 'SZ_1G' undeclared (first use in this function) + 743 | info->size = SZ_1G; + | ^~~~~ + +Include so SZ_* is defined. + +Reported-by: Tianling Shen +Signed-off-by: Daniel Golle +--- + drivers/ram/mediatek/ddr3-mt7629.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/drivers/ram/mediatek/ddr3-mt7629.c ++++ b/drivers/ram/mediatek/ddr3-mt7629.c +@@ -14,6 +14,7 @@ + #include + #include + #include ++#include + + /* EMI */ + #define EMI_CONA 0x000 diff --git a/package/boot/uboot-mediatek/patches/412-add-ubnt-unifi-6-lr.patch b/package/boot/uboot-mediatek/patches/412-add-ubnt-unifi-6-lr.patch index b495f48d668..4bde0617653 100644 --- a/package/boot/uboot-mediatek/patches/412-add-ubnt-unifi-6-lr.patch +++ b/package/boot/uboot-mediatek/patches/412-add-ubnt-unifi-6-lr.patch @@ -150,7 +150,7 @@ +CONFIG_SERVERIP="192.168.1.254" --- /dev/null +++ b/arch/arm/dts/mt7622-ubnt-unifi-6-lr.dts -@@ -0,0 +1,188 @@ +@@ -0,0 +1,193 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2019 MediaTek Inc. @@ -173,6 +173,11 @@ + tick-timer = &timer0; + }; + ++ memory@40000000 { ++ device_type = "memory"; ++ reg = <0x40000000 0x20000000>; ++ }; ++ + aliases { + spi0 = &snor; + }; diff --git a/package/boot/uboot-mediatek/patches/431-add-xiaomi_redmi-ax6000.patch b/package/boot/uboot-mediatek/patches/431-add-xiaomi_redmi-ax6000.patch index 88e426366ba..070456b2ee8 100644 --- a/package/boot/uboot-mediatek/patches/431-add-xiaomi_redmi-ax6000.patch +++ b/package/boot/uboot-mediatek/patches/431-add-xiaomi_redmi-ax6000.patch @@ -182,7 +182,7 @@ +CONFIG_SERVERIP="192.168.1.254" --- /dev/null +++ b/arch/arm/dts/mt7986a-xiaomi_redmi-ax6000.dts -@@ -0,0 +1,156 @@ +@@ -0,0 +1,161 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2021 MediaTek Inc. @@ -205,6 +205,11 @@ + tick-timer = &timer0; + }; + ++ memory@40000000 { ++ device_type = "memory"; ++ reg = <0x40000000 0x20000000>; ++ }; ++ + keys { + compatible = "gpio-keys"; + factory { diff --git a/package/boot/uboot-mediatek/patches/432-add-tplink-xdr608x.patch b/package/boot/uboot-mediatek/patches/432-add-tplink-xdr608x.patch index b1c25ba7915..365f280947d 100644 --- a/package/boot/uboot-mediatek/patches/432-add-tplink-xdr608x.patch +++ b/package/boot/uboot-mediatek/patches/432-add-tplink-xdr608x.patch @@ -555,7 +555,7 @@ +CONFIG_SERVERIP="192.168.1.254" --- /dev/null +++ b/arch/arm/dts/mt7986a-tplink-tl-xdr608x.dts -@@ -0,0 +1,191 @@ +@@ -0,0 +1,196 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2021 MediaTek Inc. @@ -578,6 +578,11 @@ + tick-timer = &timer0; + }; + ++ memory@40000000 { ++ device_type = "memory"; ++ reg = <0x40000000 0x20000000>; ++ }; ++ + keys { + compatible = "gpio-keys"; + diff --git a/package/boot/uboot-mediatek/patches/433-add-qihoo_360t7.patch b/package/boot/uboot-mediatek/patches/433-add-qihoo_360t7.patch index aaaeaa4f8ae..4f98c95893b 100644 --- a/package/boot/uboot-mediatek/patches/433-add-qihoo_360t7.patch +++ b/package/boot/uboot-mediatek/patches/433-add-qihoo_360t7.patch @@ -178,7 +178,7 @@ +CONFIG_SERVERIP="192.168.1.254" --- /dev/null +++ b/arch/arm/dts/mt7981_qihoo-360t7.dts -@@ -0,0 +1,180 @@ +@@ -0,0 +1,185 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2022 MediaTek Inc. @@ -201,6 +201,11 @@ + tick-timer = &timer0; + }; + ++ memory@40000000 { ++ device_type = "memory"; ++ reg = <0x40000000 0x10000000>; ++ }; ++ + keys { + compatible = "gpio-keys"; + diff --git a/package/boot/uboot-mediatek/patches/434-add-xiaomi_mi-router-wr30u.patch b/package/boot/uboot-mediatek/patches/434-add-xiaomi_mi-router-wr30u.patch index 6be64e54216..2bd1afe7a8f 100644 --- a/package/boot/uboot-mediatek/patches/434-add-xiaomi_mi-router-wr30u.patch +++ b/package/boot/uboot-mediatek/patches/434-add-xiaomi_mi-router-wr30u.patch @@ -178,7 +178,7 @@ +CONFIG_SERVERIP="192.168.1.254" --- /dev/null +++ b/arch/arm/dts/mt7981_xiaomi_mi-router-wr30u.dts -@@ -0,0 +1,216 @@ +@@ -0,0 +1,221 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2022 MediaTek Inc. @@ -206,6 +206,11 @@ + system_led = "yellow:system"; + }; + ++ memory@40000000 { ++ device_type = "memory"; ++ reg = <0x40000000 0x10000000>; ++ }; ++ + gpio-keys { + compatible = "gpio-keys"; + diff --git a/package/boot/uboot-mediatek/patches/435-add-h3c_magic-nx30-pro.patch b/package/boot/uboot-mediatek/patches/435-add-h3c_magic-nx30-pro.patch index 57181c73c0e..d5a149b903b 100644 --- a/package/boot/uboot-mediatek/patches/435-add-h3c_magic-nx30-pro.patch +++ b/package/boot/uboot-mediatek/patches/435-add-h3c_magic-nx30-pro.patch @@ -178,7 +178,7 @@ +CONFIG_SERVERIP="192.168.1.254" --- /dev/null +++ b/arch/arm/dts/mt7981_h3c_magic-nx30-pro.dts -@@ -0,0 +1,200 @@ +@@ -0,0 +1,205 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2022 MediaTek Inc. @@ -201,6 +201,11 @@ + tick-timer = &timer0; + }; + ++ memory@40000000 { ++ device_type = "memory"; ++ reg = <0x40000000 0x10000000>; ++ }; ++ + keys { + compatible = "gpio-keys"; + diff --git a/package/kernel/linux/modules/netsupport.mk b/package/kernel/linux/modules/netsupport.mk index 2475828bdeb..35e627002ea 100644 --- a/package/kernel/linux/modules/netsupport.mk +++ b/package/kernel/linux/modules/netsupport.mk @@ -972,6 +972,18 @@ endef $(eval $(call KernelPackage,sched-red)) +define KernelPackage/sched-skbprio + SUBMENU:=$(NETWORK_SUPPORT_MENU) + TITLE:=SKB priority queue scheduler (SKBPRIO) + DEPENDS:=+kmod-sched-core + KCONFIG:= CONFIG_NET_SCH_SKBPRIO + FILES:= $(LINUX_DIR)/net/sched/sch_skbprio.ko + AUTOLOAD:=$(call AutoProbe,sch_skbprio) +endef + +$(eval $(call KernelPackage,sched-skbprio)) + + define KernelPackage/bpf-test SUBMENU:=$(NETWORK_SUPPORT_MENU) TITLE:=Test Berkeley Packet Filter functionality 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 new file mode 100644 index 00000000000..16ebbb1eaa8 --- /dev/null +++ b/package/kernel/rtl8812au-ct/patches/006-os_dep-osdep_service-use-new-get_random_u32.patch @@ -0,0 +1,25 @@ +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 new file mode 100644 index 00000000000..be7b70ab5f2 --- /dev/null +++ b/package/kernel/rtl8812au-ct/patches/007-treewide-fix-always-TRUE-condition-warning.patch @@ -0,0 +1,72 @@ +From dc4024894c9deefc56f8dd6b2d2822b277f268a5 Mon Sep 17 00:00:00 2001 +From: Christian Marangi +Date: Sun, 30 Jul 2023 11:18:48 +0200 +Subject: [PATCH 2/5] treewide: fix always TRUE condition warning + +Fix always TRUE condition warning an drop redundant check. + +Signed-off-by: Christian Marangi +--- + core/rtw_sta_mgt.c | 3 +-- + hal/OUTSRC/phydm_debug.c | 16 ++++++---------- + os_dep/linux/ioctl_cfg80211.c | 3 +-- + 3 files changed, 8 insertions(+), 14 deletions(-) + +--- a/core/rtw_sta_mgt.c ++++ b/core/rtw_sta_mgt.c +@@ -207,8 +207,7 @@ void rtw_mfree_stainfo(struct sta_info * + { + _func_enter_; + +- if(&psta->lock != NULL) +- _rtw_spinlock_free(&psta->lock); ++ _rtw_spinlock_free(&psta->lock); + + _rtw_free_sta_xmit_priv_lock(&psta->sta_xmitpriv); + _rtw_free_sta_recv_priv_lock(&psta->sta_recvpriv); +--- a/hal/OUTSRC/phydm_debug.c ++++ b/hal/OUTSRC/phydm_debug.c +@@ -870,12 +870,10 @@ phydm_cmd_parser( + case PHYDM_RA: + + for(i=0; i<5; i++) { +- if(input[i+1]) { +- PHYDM_SSCANF(input[i+1], DCMD_DECIMAL, &var1[i]); ++ PHYDM_SSCANF(input[i+1], DCMD_DECIMAL, &var1[i]); + +- PHYDM_SNPRINTF((output+used, out_len-used, "new SET, RA_var[%d]= (( %d ))\n", i , var1[i])); +- input_idx++; +- } ++ PHYDM_SNPRINTF((output+used, out_len-used, "new SET, RA_var[%d]= (( %d ))\n", i , var1[i])); ++ input_idx++; + } + + if(input_idx>=1) { +@@ -891,12 +889,10 @@ phydm_cmd_parser( + case PHYDM_PATHDIV: + + for(i=0; i<5; i++) { +- if(input[i+1]) { +- PHYDM_SSCANF(input[i+1], DCMD_HEX, &var1[i]); ++ PHYDM_SSCANF(input[i+1], DCMD_HEX, &var1[i]); + +- PHYDM_SNPRINTF((output+used, out_len-used, "new SET, PATHDIV_var[%d]= (( %d ))\n", i , var1[i])); +- input_idx++; +- } ++ PHYDM_SNPRINTF((output+used, out_len-used, "new SET, PATHDIV_var[%d]= (( %d ))\n", i , var1[i])); ++ input_idx++; + } + + 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 + + #ifdef CONFIG_P2P + if( pwdinfo->driver_interface == DRIVER_CFG80211 ) { +- if(ssids->ssid != NULL +- && _rtw_memcmp(ssids->ssid, "DIRECT-", 7) ++ if(_rtw_memcmp(ssids->ssid, "DIRECT-", 7) + && rtw_get_p2p_ie((u8 *)request->ie, request->ie_len, NULL, NULL) + ) { + if(rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) { 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 new file mode 100644 index 00000000000..60674131660 --- /dev/null +++ b/package/kernel/rtl8812au-ct/patches/008-treewide-use-correct-type-for-tasklet_init.patch @@ -0,0 +1,93 @@ +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 new file mode 100644 index 00000000000..64ad85372bc --- /dev/null +++ b/package/kernel/rtl8812au-ct/patches/009-treewide-drop-const-from-dev_addr.patch @@ -0,0 +1,56 @@ +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 new file mode 100644 index 00000000000..1c62e77d1b0 --- /dev/null +++ b/package/kernel/rtl8812au-ct/patches/010-os_dep-linux-proc-move-to-pde_data-function.patch @@ -0,0 +1,26 @@ +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/system/urngd/Makefile b/package/system/urngd/Makefile index e131e1be7eb..818f06b210d 100644 --- a/package/system/urngd/Makefile +++ b/package/system/urngd/Makefile @@ -7,7 +7,7 @@ PKG_SOURCE_PROTO:=git PKG_SOURCE_URL=$(PROJECT_GIT)/project/urngd.git PKG_SOURCE_DATE:=2023-07-25 PKG_SOURCE_VERSION:=7aefb47be57df0467d97d539f7fe9e23e607a3b4 -PKG_MIRROR_HASH:=941e4298acc9a0c9b485b9ad706bb11c4d0bc7a66eec22e569b430ab38a9f5fc +PKG_MIRROR_HASH:=427d4228fd65cf4320b8c212e710b86bcbfcdd4239f4e67132b3b471f7437202 PKG_LICENSE:=GPL-2.0 BSD-3-Clause PKG_LICENSE_FILES:= diff --git a/target/linux/ath79/patches-5.15/910-unaligned_access_hacks.patch b/target/linux/ath79/patches-5.15/910-unaligned_access_hacks.patch index 55539d7d539..f542c32d45d 100644 --- a/target/linux/ath79/patches-5.15/910-unaligned_access_hacks.patch +++ b/target/linux/ath79/patches-5.15/910-unaligned_access_hacks.patch @@ -750,7 +750,7 @@ SVN-Revision: 35130 EXPORT_SYMBOL(xfrm_parse_spi); --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c -@@ -4152,14 +4152,16 @@ static bool tcp_parse_aligned_timestamp( +@@ -4158,14 +4158,16 @@ static bool tcp_parse_aligned_timestamp( { const __be32 *ptr = (const __be32 *)(th + 1); diff --git a/target/linux/bcm27xx/patches-6.1/950-0188-hid-usb-Add-device-quirks-for-Freeway-Airmouse-T3-an.patch b/target/linux/bcm27xx/patches-6.1/950-0188-hid-usb-Add-device-quirks-for-Freeway-Airmouse-T3-an.patch index 2426a39ac37..f237c581be9 100644 --- a/target/linux/bcm27xx/patches-6.1/950-0188-hid-usb-Add-device-quirks-for-Freeway-Airmouse-T3-an.patch +++ b/target/linux/bcm27xx/patches-6.1/950-0188-hid-usb-Add-device-quirks-for-Freeway-Airmouse-T3-an.patch @@ -33,7 +33,7 @@ Signed-off-by: Jonathan Bell #define USB_VENDOR_ID_BELKIN 0x050d #define USB_DEVICE_ID_FLIP_KVM 0x3201 -@@ -1367,6 +1370,9 @@ +@@ -1368,6 +1371,9 @@ #define USB_VENDOR_ID_XIAOMI 0x2717 #define USB_DEVICE_ID_MI_SILENT_MOUSE 0x5014 @@ -53,7 +53,7 @@ Signed-off-by: Jonathan Bell { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_MULTI_TOUCH), HID_QUIRK_MULTI_INPUT }, { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_PIXART_USB_OPTICAL_MOUSE), HID_QUIRK_ALWAYS_POLL }, { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_PIXART_USB_OPTICAL_MOUSE2), HID_QUIRK_ALWAYS_POLL }, -@@ -197,6 +198,7 @@ static const struct hid_device_id hid_qu +@@ -198,6 +199,7 @@ static const struct hid_device_id hid_qu { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_QUAD_USB_JOYPAD), HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT }, { HID_USB_DEVICE(USB_VENDOR_ID_XIN_MO, USB_DEVICE_ID_XIN_MO_DUAL_ARCADE), HID_QUIRK_MULTI_INPUT }, { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_GROUP_AUDIO), HID_QUIRK_NOGET }, diff --git a/target/linux/bcm27xx/patches-6.1/950-0699-Bluetooth-hci_sync-Add-fallback-bd-address-prop.patch b/target/linux/bcm27xx/patches-6.1/950-0699-Bluetooth-hci_sync-Add-fallback-bd-address-prop.patch index fd847817297..7bb65c28d48 100644 --- a/target/linux/bcm27xx/patches-6.1/950-0699-Bluetooth-hci_sync-Add-fallback-bd-address-prop.patch +++ b/target/linux/bcm27xx/patches-6.1/950-0699-Bluetooth-hci_sync-Add-fallback-bd-address-prop.patch @@ -20,7 +20,7 @@ Signed-off-by: Phil Elwell --- a/net/bluetooth/hci_sync.c +++ b/net/bluetooth/hci_sync.c -@@ -4540,6 +4540,7 @@ static const struct { +@@ -4635,6 +4635,7 @@ static const struct { */ static int hci_dev_setup_sync(struct hci_dev *hdev) { @@ -28,7 +28,7 @@ Signed-off-by: Phil Elwell int ret = 0; bool invalid_bdaddr; size_t i; -@@ -4568,7 +4569,9 @@ static int hci_dev_setup_sync(struct hci +@@ -4663,7 +4664,9 @@ static int hci_dev_setup_sync(struct hci if (!ret) { if (test_bit(HCI_QUIRK_USE_BDADDR_PROPERTY, &hdev->quirks) && diff --git a/target/linux/bcm47xx/patches-5.15/791-tg3-no-pci-sleep.patch b/target/linux/bcm47xx/patches-5.15/791-tg3-no-pci-sleep.patch index 2c2f5406952..fb78dca7588 100644 --- a/target/linux/bcm47xx/patches-5.15/791-tg3-no-pci-sleep.patch +++ b/target/linux/bcm47xx/patches-5.15/791-tg3-no-pci-sleep.patch @@ -5,7 +5,7 @@ when a switch driver is in use. --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c -@@ -4267,7 +4267,8 @@ static int tg3_power_down_prepare(struct +@@ -4268,7 +4268,8 @@ static int tg3_power_down_prepare(struct static void tg3_power_down(struct tg3 *tp) { pci_wake_from_d3(tp->pdev, tg3_flag(tp, WOL_ENABLE)); diff --git a/target/linux/bcm4908/patches-5.15/071-v6.1-0001-net-broadcom-bcm4908_enet-handle-EPROBE_DEFER-when-g.patch b/target/linux/bcm4908/patches-5.15/071-v6.1-0001-net-broadcom-bcm4908_enet-handle-EPROBE_DEFER-when-g.patch index 1cf761838c5..85be40cef41 100644 --- a/target/linux/bcm4908/patches-5.15/071-v6.1-0001-net-broadcom-bcm4908_enet-handle-EPROBE_DEFER-when-g.patch +++ b/target/linux/bcm4908/patches-5.15/071-v6.1-0001-net-broadcom-bcm4908_enet-handle-EPROBE_DEFER-when-g.patch @@ -23,7 +23,7 @@ Signed-off-by: Jakub Kicinski @@ -720,6 +720,8 @@ static int bcm4908_enet_probe(struct pla SET_NETDEV_DEV(netdev, &pdev->dev); - err = of_get_mac_address(dev->of_node, netdev->dev_addr); + err = of_get_ethdev_address(dev->of_node, netdev); + if (err == -EPROBE_DEFER) + goto err_dma_free; if (err) diff --git a/target/linux/bcm53xx/patches-5.15/036-v6.5-0001-ARM-dts-BCM5301X-Relicense-Rafa-s-code-to-the-GPL-2..patch b/target/linux/bcm53xx/patches-5.15/036-v6.5-0001-ARM-dts-BCM5301X-Relicense-Rafa-s-code-to-the-GPL-2..patch index 9c6f0b8e534..3bb39dfd500 100644 --- a/target/linux/bcm53xx/patches-5.15/036-v6.5-0001-ARM-dts-BCM5301X-Relicense-Rafa-s-code-to-the-GPL-2..patch +++ b/target/linux/bcm53xx/patches-5.15/036-v6.5-0001-ARM-dts-BCM5301X-Relicense-Rafa-s-code-to-the-GPL-2..patch @@ -460,7 +460,7 @@ Signed-off-by: Florian Fainelli }; }; -@@ -558,24 +390,4 @@ +@@ -557,24 +389,4 @@ }; }; }; diff --git a/target/linux/bcm53xx/patches-5.15/036-v6.5-0003-ARM-dts-BCM5301X-Drop-clock-names-from-the-SPI-node.patch b/target/linux/bcm53xx/patches-5.15/036-v6.5-0003-ARM-dts-BCM5301X-Drop-clock-names-from-the-SPI-node.patch deleted file mode 100644 index 4065db8366a..00000000000 --- a/target/linux/bcm53xx/patches-5.15/036-v6.5-0003-ARM-dts-BCM5301X-Drop-clock-names-from-the-SPI-node.patch +++ /dev/null @@ -1,32 +0,0 @@ -From d3c8e2c5757153bbfad70019ec1decbca86f3def Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= -Date: Wed, 3 May 2023 14:28:30 +0200 -Subject: [PATCH] ARM: dts: BCM5301X: Drop "clock-names" from the SPI node -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -There is no such property in the SPI controller binding documentation. -Also Linux driver doesn't look for it. - -This fixes: -arch/arm/boot/dts/bcm4708-asus-rt-ac56u.dtb: spi@18029200: Unevaluated properties are not allowed ('clock-names' was unexpected) - From schema: Documentation/devicetree/bindings/spi/brcm,spi-bcm-qspi.yaml - -Signed-off-by: Rafał Miłecki -Link: https://lore.kernel.org/r/20230503122830.3200-1-zajec5@gmail.com -Signed-off-by: Florian Fainelli ---- - arch/arm/boot/dts/bcm5301x.dtsi | 1 - - 1 file changed, 1 deletion(-) - ---- a/arch/arm/boot/dts/bcm5301x.dtsi -+++ b/arch/arm/boot/dts/bcm5301x.dtsi -@@ -335,7 +335,6 @@ - "spi_lr_session_done", - "spi_lr_overread"; - clocks = <&iprocmed>; -- clock-names = "iprocmed"; - num-cs = <2>; - #address-cells = <1>; - #size-cells = <0>; diff --git a/target/linux/bcm53xx/patches-5.15/036-v6.5-0015-ARM-dts-BCM5301X-fix-duplex-full-full-duplex.patch b/target/linux/bcm53xx/patches-5.15/036-v6.5-0015-ARM-dts-BCM5301X-fix-duplex-full-full-duplex.patch deleted file mode 100644 index 805dcf54ebb..00000000000 --- a/target/linux/bcm53xx/patches-5.15/036-v6.5-0015-ARM-dts-BCM5301X-fix-duplex-full-full-duplex.patch +++ /dev/null @@ -1,44 +0,0 @@ -From fd274b733bfdde3ca72f0fa2a37f032f3a8c402c Mon Sep 17 00:00:00 2001 -From: Christian Lamparter -Date: Thu, 8 Jun 2023 17:36:29 +0200 -Subject: [PATCH] ARM: dts: BCM5301X: fix duplex-full => full-duplex - -this typo was found by the dtbs_check -| ports:port@5:fixed-link: 'oneOf' conditional failed, -| {'speed': [[1000]], 'duplex-full': True} is not of type 'array' -| 'duplex-full' does not match any of the regexes: 'pinctrl-[0-]..." - -this should have been full-duplex; - -Fixes: 935327a73553 ("ARM: dts: BCM5301X: Add DT for Meraki MR26") -Fixes: ec88a9c344d9 ("ARM: BCM5301X: Add DT for Meraki MR32") -Signed-off-by: Christian Lamparter -Link: https://lore.kernel.org/r/50522f45566951a9eabd22820647924cc6b4a264.1686238550.git.chunkeey@gmail.com -Signed-off-by: Florian Fainelli ---- - arch/arm/boot/dts/bcm53015-meraki-mr26.dts | 2 +- - arch/arm/boot/dts/bcm53016-meraki-mr32.dts | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - ---- a/arch/arm/boot/dts/bcm53015-meraki-mr26.dts -+++ b/arch/arm/boot/dts/bcm53015-meraki-mr26.dts -@@ -121,7 +121,7 @@ - - fixed-link { - speed = <1000>; -- duplex-full; -+ full-duplex; - }; - }; - }; ---- a/arch/arm/boot/dts/bcm53016-meraki-mr32.dts -+++ b/arch/arm/boot/dts/bcm53016-meraki-mr32.dts -@@ -182,7 +182,7 @@ - - fixed-link { - speed = <1000>; -- duplex-full; -+ full-duplex; - }; - }; - }; diff --git a/target/linux/bcm53xx/patches-5.15/180-usb-xhci-add-support-for-performing-fake-doorbell.patch b/target/linux/bcm53xx/patches-5.15/180-usb-xhci-add-support-for-performing-fake-doorbell.patch index bcf4776c12a..17013c75bad 100644 --- a/target/linux/bcm53xx/patches-5.15/180-usb-xhci-add-support-for-performing-fake-doorbell.patch +++ b/target/linux/bcm53xx/patches-5.15/180-usb-xhci-add-support-for-performing-fake-doorbell.patch @@ -127,11 +127,11 @@ it on BCM4708 family. /* --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h -@@ -1906,6 +1906,7 @@ struct xhci_hcd { - #define XHCI_EP_CTX_BROKEN_DCS BIT_ULL(42) - #define XHCI_SUSPEND_RESUME_CLKS BIT_ULL(43) +@@ -1908,6 +1908,7 @@ struct xhci_hcd { #define XHCI_RESET_TO_DEFAULT BIT_ULL(44) -+#define XHCI_FAKE_DOORBELL BIT_ULL(45) + #define XHCI_ZHAOXIN_TRB_FETCH BIT_ULL(45) + #define XHCI_ZHAOXIN_HOST BIT_ULL(46) ++#define XHCI_FAKE_DOORBELL BIT_ULL(47) unsigned int num_active_eps; unsigned int limit_active_eps; diff --git a/target/linux/generic/backport-5.15/350-v5.18-regmap-add-configurable-downshift-for-addresses.patch b/target/linux/generic/backport-5.15/350-v5.18-regmap-add-configurable-downshift-for-addresses.patch index 690e85d34be..99cd89ea002 100644 --- a/target/linux/generic/backport-5.15/350-v5.18-regmap-add-configurable-downshift-for-addresses.patch +++ b/target/linux/generic/backport-5.15/350-v5.18-regmap-add-configurable-downshift-for-addresses.patch @@ -53,7 +53,7 @@ Signed-off-by: Mark Brown map->format.format_write(map, reg, val); trace_regmap_hw_write_start(map, reg, 1); -@@ -2348,6 +2351,7 @@ static int _regmap_raw_multi_reg_write(s +@@ -2346,6 +2349,7 @@ static int _regmap_raw_multi_reg_write(s unsigned int reg = regs[i].reg; unsigned int val = regs[i].def; trace_regmap_hw_write_start(map, reg, 1); @@ -61,7 +61,7 @@ Signed-off-by: Mark Brown map->format.format_reg(u8, reg, map->reg_shift); u8 += reg_bytes + pad_bytes; map->format.format_val(u8, val, 0); -@@ -2675,6 +2679,7 @@ static int _regmap_raw_read(struct regma +@@ -2673,6 +2677,7 @@ static int _regmap_raw_read(struct regma return ret; } diff --git a/target/linux/generic/backport-5.15/351-v5.18-regmap-allow-a-defined-reg_base-to-be-added-to-every.patch b/target/linux/generic/backport-5.15/351-v5.18-regmap-allow-a-defined-reg_base-to-be-added-to-every.patch index ffde9e5d0c5..0f32288fcab 100644 --- a/target/linux/generic/backport-5.15/351-v5.18-regmap-allow-a-defined-reg_base-to-be-added-to-every.patch +++ b/target/linux/generic/backport-5.15/351-v5.18-regmap-allow-a-defined-reg_base-to-be-added-to-every.patch @@ -58,7 +58,7 @@ Signed-off-by: Mark Brown reg >>= map->format.reg_downshift; map->format.format_write(map, reg, val); -@@ -2351,6 +2355,7 @@ static int _regmap_raw_multi_reg_write(s +@@ -2349,6 +2353,7 @@ static int _regmap_raw_multi_reg_write(s unsigned int reg = regs[i].reg; unsigned int val = regs[i].def; trace_regmap_hw_write_start(map, reg, 1); @@ -66,7 +66,7 @@ Signed-off-by: Mark Brown reg >>= map->format.reg_downshift; map->format.format_reg(u8, reg, map->reg_shift); u8 += reg_bytes + pad_bytes; -@@ -2679,6 +2684,7 @@ static int _regmap_raw_read(struct regma +@@ -2677,6 +2682,7 @@ static int _regmap_raw_read(struct regma return ret; } diff --git a/target/linux/generic/backport-5.15/352-v6.3-regmap-apply-reg_base-and-reg_downshift-for-single-r.patch b/target/linux/generic/backport-5.15/352-v6.3-regmap-apply-reg_base-and-reg_downshift-for-single-r.patch index 34b587f5582..804f68d23c5 100644 --- a/target/linux/generic/backport-5.15/352-v6.3-regmap-apply-reg_base-and-reg_downshift-for-single-r.patch +++ b/target/linux/generic/backport-5.15/352-v6.3-regmap-apply-reg_base-and-reg_downshift-for-single-r.patch @@ -37,7 +37,7 @@ Signed-off-by: Mark Brown return map->bus->reg_write(map->bus_context, reg, val); } -@@ -2705,6 +2707,8 @@ static int _regmap_bus_reg_read(void *co +@@ -2703,6 +2705,8 @@ static int _regmap_bus_reg_read(void *co { struct regmap *map = context; @@ -46,7 +46,7 @@ Signed-off-by: Mark Brown return map->bus->reg_read(map->bus_context, reg, val); } -@@ -3080,6 +3084,8 @@ static int _regmap_update_bits(struct re +@@ -3078,6 +3082,8 @@ static int _regmap_update_bits(struct re *change = false; if (regmap_volatile(map, reg) && map->reg_update_bits) { diff --git a/target/linux/generic/backport-5.15/702-v5.19-00-net-ethernet-mtk_eth_soc-add-support-for-coherent-DM.patch b/target/linux/generic/backport-5.15/702-v5.19-00-net-ethernet-mtk_eth_soc-add-support-for-coherent-DM.patch index c83d659d1c0..d6de92a4873 100644 --- a/target/linux/generic/backport-5.15/702-v5.19-00-net-ethernet-mtk_eth_soc-add-support-for-coherent-DM.patch +++ b/target/linux/generic/backport-5.15/702-v5.19-00-net-ethernet-mtk_eth_soc-add-support-for-coherent-DM.patch @@ -225,7 +225,7 @@ Signed-off-by: Felix Fietkau if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628)) { ret = device_reset(eth->dev); if (ret) { -@@ -3079,6 +3086,35 @@ free_netdev: +@@ -3072,6 +3079,35 @@ free_netdev: return err; } @@ -261,7 +261,7 @@ Signed-off-by: Felix Fietkau static int mtk_probe(struct platform_device *pdev) { struct device_node *mac_np; -@@ -3092,6 +3128,7 @@ static int mtk_probe(struct platform_dev +@@ -3085,6 +3121,7 @@ static int mtk_probe(struct platform_dev eth->soc = of_device_get_match_data(&pdev->dev); eth->dev = &pdev->dev; @@ -269,7 +269,7 @@ Signed-off-by: Felix Fietkau eth->base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(eth->base)) return PTR_ERR(eth->base); -@@ -3140,6 +3177,16 @@ static int mtk_probe(struct platform_dev +@@ -3133,6 +3170,16 @@ static int mtk_probe(struct platform_dev } } diff --git a/target/linux/generic/backport-5.15/702-v5.19-02-net-ethernet-mtk_eth_soc-add-support-for-Wireless-Et.patch b/target/linux/generic/backport-5.15/702-v5.19-02-net-ethernet-mtk_eth_soc-add-support-for-Wireless-Et.patch index 2f3a0827fe4..06f94882361 100644 --- a/target/linux/generic/backport-5.15/702-v5.19-02-net-ethernet-mtk_eth_soc-add-support-for-Wireless-Et.patch +++ b/target/linux/generic/backport-5.15/702-v5.19-02-net-ethernet-mtk_eth_soc-add-support-for-Wireless-Et.patch @@ -56,7 +56,7 @@ Signed-off-by: Felix Fietkau static int mtk_msg_level = -1; module_param_named(msg_level, mtk_msg_level, int, 0); -@@ -3209,6 +3210,22 @@ static int mtk_probe(struct platform_dev +@@ -3202,6 +3203,22 @@ static int mtk_probe(struct platform_dev } } diff --git a/target/linux/generic/backport-5.15/702-v5.19-07-net-ethernet-mtk_eth_soc-allocate-struct-mtk_ppe-sep.patch b/target/linux/generic/backport-5.15/702-v5.19-07-net-ethernet-mtk_eth_soc-allocate-struct-mtk_ppe-sep.patch index f18a816b703..1951a1d6764 100644 --- a/target/linux/generic/backport-5.15/702-v5.19-07-net-ethernet-mtk_eth_soc-allocate-struct-mtk_ppe-sep.patch +++ b/target/linux/generic/backport-5.15/702-v5.19-07-net-ethernet-mtk_eth_soc-allocate-struct-mtk_ppe-sep.patch @@ -28,7 +28,7 @@ Signed-off-by: Felix Fietkau return 0; } -@@ -3301,10 +3301,11 @@ static int mtk_probe(struct platform_dev +@@ -3294,10 +3294,11 @@ static int mtk_probe(struct platform_dev } if (eth->soc->offload_version) { diff --git a/target/linux/generic/backport-5.15/702-v5.19-08-net-ethernet-mtk_eth_soc-rework-hardware-flow-table-.patch b/target/linux/generic/backport-5.15/702-v5.19-08-net-ethernet-mtk_eth_soc-rework-hardware-flow-table-.patch index 2609cbedec2..9213f28b2a0 100644 --- a/target/linux/generic/backport-5.15/702-v5.19-08-net-ethernet-mtk_eth_soc-rework-hardware-flow-table-.patch +++ b/target/linux/generic/backport-5.15/702-v5.19-08-net-ethernet-mtk_eth_soc-rework-hardware-flow-table-.patch @@ -54,7 +54,7 @@ Signed-off-by: Felix Fietkau if (netdev->features & NETIF_F_HW_VLAN_CTAG_RX && (trxd.rxd2 & RX_DMA_VTAG)) __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), -@@ -3301,7 +3307,7 @@ static int mtk_probe(struct platform_dev +@@ -3294,7 +3300,7 @@ static int mtk_probe(struct platform_dev } if (eth->soc->offload_version) { diff --git a/target/linux/generic/backport-5.15/702-v5.19-13-net-ethernet-mtk_eth_soc-use-standard-property-for-c.patch b/target/linux/generic/backport-5.15/702-v5.19-13-net-ethernet-mtk_eth_soc-use-standard-property-for-c.patch index a7c5f08f100..5a7561798d5 100644 --- a/target/linux/generic/backport-5.15/702-v5.19-13-net-ethernet-mtk_eth_soc-use-standard-property-for-c.patch +++ b/target/linux/generic/backport-5.15/702-v5.19-13-net-ethernet-mtk_eth_soc-use-standard-property-for-c.patch @@ -24,7 +24,7 @@ Signed-off-by: David S. Miller mediatek,hifsys = <&hifsys>; --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c -@@ -3188,7 +3188,7 @@ static int mtk_probe(struct platform_dev +@@ -3181,7 +3181,7 @@ static int mtk_probe(struct platform_dev struct regmap *cci; cci = syscon_regmap_lookup_by_phandle(pdev->dev.of_node, diff --git a/target/linux/generic/backport-5.15/702-v5.19-19-net-ethernet-mtk_eth_soc-add-txd_size-to-mtk_soc_dat.patch b/target/linux/generic/backport-5.15/702-v5.19-19-net-ethernet-mtk_eth_soc-add-txd_size-to-mtk_soc_dat.patch index f5206bba00b..5bf44cc772d 100644 --- a/target/linux/generic/backport-5.15/702-v5.19-19-net-ethernet-mtk_eth_soc-add-txd_size-to-mtk_soc_dat.patch +++ b/target/linux/generic/backport-5.15/702-v5.19-19-net-ethernet-mtk_eth_soc-add-txd_size-to-mtk_soc_dat.patch @@ -85,7 +85,7 @@ Signed-off-by: David S. Miller eth->scratch_ring = NULL; eth->phy_scratch_ring = 0; } -@@ -3391,6 +3394,9 @@ static const struct mtk_soc_data mt2701_ +@@ -3384,6 +3387,9 @@ static const struct mtk_soc_data mt2701_ .hw_features = MTK_HW_FEATURES, .required_clks = MT7623_CLKS_BITMAP, .required_pctl = true, @@ -95,7 +95,7 @@ Signed-off-by: David S. Miller }; static const struct mtk_soc_data mt7621_data = { -@@ -3399,6 +3405,9 @@ static const struct mtk_soc_data mt7621_ +@@ -3392,6 +3398,9 @@ static const struct mtk_soc_data mt7621_ .required_clks = MT7621_CLKS_BITMAP, .required_pctl = false, .offload_version = 2, @@ -105,7 +105,7 @@ Signed-off-by: David S. Miller }; static const struct mtk_soc_data mt7622_data = { -@@ -3408,6 +3417,9 @@ static const struct mtk_soc_data mt7622_ +@@ -3401,6 +3410,9 @@ static const struct mtk_soc_data mt7622_ .required_clks = MT7622_CLKS_BITMAP, .required_pctl = false, .offload_version = 2, @@ -115,7 +115,7 @@ Signed-off-by: David S. Miller }; static const struct mtk_soc_data mt7623_data = { -@@ -3416,6 +3428,9 @@ static const struct mtk_soc_data mt7623_ +@@ -3409,6 +3421,9 @@ static const struct mtk_soc_data mt7623_ .required_clks = MT7623_CLKS_BITMAP, .required_pctl = true, .offload_version = 2, @@ -125,7 +125,7 @@ Signed-off-by: David S. Miller }; static const struct mtk_soc_data mt7629_data = { -@@ -3424,6 +3439,9 @@ static const struct mtk_soc_data mt7629_ +@@ -3417,6 +3432,9 @@ static const struct mtk_soc_data mt7629_ .hw_features = MTK_HW_FEATURES, .required_clks = MT7629_CLKS_BITMAP, .required_pctl = false, @@ -135,7 +135,7 @@ Signed-off-by: David S. Miller }; static const struct mtk_soc_data rt5350_data = { -@@ -3431,6 +3449,9 @@ static const struct mtk_soc_data rt5350_ +@@ -3424,6 +3442,9 @@ static const struct mtk_soc_data rt5350_ .hw_features = MTK_HW_FEATURES_MT7628, .required_clks = MT7628_CLKS_BITMAP, .required_pctl = false, diff --git a/target/linux/generic/backport-5.15/702-v5.19-23-net-ethernet-mtk_eth_soc-add-rxd_size-to-mtk_soc_dat.patch b/target/linux/generic/backport-5.15/702-v5.19-23-net-ethernet-mtk_eth_soc-add-rxd_size-to-mtk_soc_dat.patch index ec206f28d64..127312baeca 100644 --- a/target/linux/generic/backport-5.15/702-v5.19-23-net-ethernet-mtk_eth_soc-add-rxd_size-to-mtk_soc_dat.patch +++ b/target/linux/generic/backport-5.15/702-v5.19-23-net-ethernet-mtk_eth_soc-add-rxd_size-to-mtk_soc_dat.patch @@ -34,7 +34,7 @@ Signed-off-by: David S. Miller ring->dma = NULL; } } -@@ -3406,6 +3405,7 @@ static const struct mtk_soc_data mt2701_ +@@ -3399,6 +3398,7 @@ static const struct mtk_soc_data mt2701_ .required_pctl = true, .txrx = { .txd_size = sizeof(struct mtk_tx_dma), @@ -42,7 +42,7 @@ Signed-off-by: David S. Miller }, }; -@@ -3417,6 +3417,7 @@ static const struct mtk_soc_data mt7621_ +@@ -3410,6 +3410,7 @@ static const struct mtk_soc_data mt7621_ .offload_version = 2, .txrx = { .txd_size = sizeof(struct mtk_tx_dma), @@ -50,7 +50,7 @@ Signed-off-by: David S. Miller }, }; -@@ -3429,6 +3430,7 @@ static const struct mtk_soc_data mt7622_ +@@ -3422,6 +3423,7 @@ static const struct mtk_soc_data mt7622_ .offload_version = 2, .txrx = { .txd_size = sizeof(struct mtk_tx_dma), @@ -58,7 +58,7 @@ Signed-off-by: David S. Miller }, }; -@@ -3440,6 +3442,7 @@ static const struct mtk_soc_data mt7623_ +@@ -3433,6 +3435,7 @@ static const struct mtk_soc_data mt7623_ .offload_version = 2, .txrx = { .txd_size = sizeof(struct mtk_tx_dma), @@ -66,7 +66,7 @@ Signed-off-by: David S. Miller }, }; -@@ -3451,6 +3454,7 @@ static const struct mtk_soc_data mt7629_ +@@ -3444,6 +3447,7 @@ static const struct mtk_soc_data mt7629_ .required_pctl = false, .txrx = { .txd_size = sizeof(struct mtk_tx_dma), @@ -74,7 +74,7 @@ Signed-off-by: David S. Miller }, }; -@@ -3461,6 +3465,7 @@ static const struct mtk_soc_data rt5350_ +@@ -3454,6 +3458,7 @@ static const struct mtk_soc_data rt5350_ .required_pctl = false, .txrx = { .txd_size = sizeof(struct mtk_tx_dma), diff --git a/target/linux/generic/backport-5.15/702-v5.19-26-net-ethernet-mtk_eth_soc-introduce-device-register-m.patch b/target/linux/generic/backport-5.15/702-v5.19-26-net-ethernet-mtk_eth_soc-introduce-device-register-m.patch index 272f782877f..d694578b33e 100644 --- a/target/linux/generic/backport-5.15/702-v5.19-26-net-ethernet-mtk_eth_soc-introduce-device-register-m.patch +++ b/target/linux/generic/backport-5.15/702-v5.19-26-net-ethernet-mtk_eth_soc-introduce-device-register-m.patch @@ -507,7 +507,7 @@ Signed-off-by: David S. Miller mtk_w32(eth, 0x21021000, MTK_FE_INT_GRP); return 0; -@@ -3171,14 +3234,6 @@ static int mtk_probe(struct platform_dev +@@ -3164,14 +3227,6 @@ static int mtk_probe(struct platform_dev if (IS_ERR(eth->base)) return PTR_ERR(eth->base); @@ -522,7 +522,7 @@ Signed-off-by: David S. Miller if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628)) { eth->rx_dma_l4_valid = RX_DMA_L4_VALID_PDMA; eth->ip_align = NET_IP_ALIGN; -@@ -3412,6 +3467,7 @@ static int mtk_remove(struct platform_de +@@ -3405,6 +3460,7 @@ static int mtk_remove(struct platform_de } static const struct mtk_soc_data mt2701_data = { @@ -530,7 +530,7 @@ Signed-off-by: David S. Miller .caps = MT7623_CAPS | MTK_HWLRO, .hw_features = MTK_HW_FEATURES, .required_clks = MT7623_CLKS_BITMAP, -@@ -3423,6 +3479,7 @@ static const struct mtk_soc_data mt2701_ +@@ -3416,6 +3472,7 @@ static const struct mtk_soc_data mt2701_ }; static const struct mtk_soc_data mt7621_data = { @@ -538,7 +538,7 @@ Signed-off-by: David S. Miller .caps = MT7621_CAPS, .hw_features = MTK_HW_FEATURES, .required_clks = MT7621_CLKS_BITMAP, -@@ -3435,6 +3492,7 @@ static const struct mtk_soc_data mt7621_ +@@ -3428,6 +3485,7 @@ static const struct mtk_soc_data mt7621_ }; static const struct mtk_soc_data mt7622_data = { @@ -546,7 +546,7 @@ Signed-off-by: David S. Miller .ana_rgc3 = 0x2028, .caps = MT7622_CAPS | MTK_HWLRO, .hw_features = MTK_HW_FEATURES, -@@ -3448,6 +3506,7 @@ static const struct mtk_soc_data mt7622_ +@@ -3441,6 +3499,7 @@ static const struct mtk_soc_data mt7622_ }; static const struct mtk_soc_data mt7623_data = { @@ -554,7 +554,7 @@ Signed-off-by: David S. Miller .caps = MT7623_CAPS | MTK_HWLRO, .hw_features = MTK_HW_FEATURES, .required_clks = MT7623_CLKS_BITMAP, -@@ -3460,6 +3519,7 @@ static const struct mtk_soc_data mt7623_ +@@ -3453,6 +3512,7 @@ static const struct mtk_soc_data mt7623_ }; static const struct mtk_soc_data mt7629_data = { @@ -562,7 +562,7 @@ Signed-off-by: David S. Miller .ana_rgc3 = 0x128, .caps = MT7629_CAPS | MTK_HWLRO, .hw_features = MTK_HW_FEATURES, -@@ -3472,6 +3532,7 @@ static const struct mtk_soc_data mt7629_ +@@ -3465,6 +3525,7 @@ static const struct mtk_soc_data mt7629_ }; static const struct mtk_soc_data rt5350_data = { diff --git a/target/linux/generic/backport-5.15/702-v5.19-27-net-ethernet-mtk_eth_soc-introduce-MTK_NETSYS_V2-sup.patch b/target/linux/generic/backport-5.15/702-v5.19-27-net-ethernet-mtk_eth_soc-introduce-MTK_NETSYS_V2-sup.patch index 4d6c94b13b8..548d62a0271 100644 --- a/target/linux/generic/backport-5.15/702-v5.19-27-net-ethernet-mtk_eth_soc-introduce-MTK_NETSYS_V2-sup.patch +++ b/target/linux/generic/backport-5.15/702-v5.19-27-net-ethernet-mtk_eth_soc-introduce-MTK_NETSYS_V2-sup.patch @@ -568,7 +568,7 @@ Signed-off-by: David S. Miller return 0; err_disable_pm: -@@ -3234,12 +3403,8 @@ static int mtk_probe(struct platform_dev +@@ -3227,12 +3396,8 @@ static int mtk_probe(struct platform_dev if (IS_ERR(eth->base)) return PTR_ERR(eth->base); @@ -582,7 +582,7 @@ Signed-off-by: David S. Miller spin_lock_init(ð->page_lock); spin_lock_init(ð->tx_irq_lock); -@@ -3475,6 +3640,10 @@ static const struct mtk_soc_data mt2701_ +@@ -3468,6 +3633,10 @@ static const struct mtk_soc_data mt2701_ .txrx = { .txd_size = sizeof(struct mtk_tx_dma), .rxd_size = sizeof(struct mtk_rx_dma), @@ -593,7 +593,7 @@ Signed-off-by: David S. Miller }, }; -@@ -3488,6 +3657,10 @@ static const struct mtk_soc_data mt7621_ +@@ -3481,6 +3650,10 @@ static const struct mtk_soc_data mt7621_ .txrx = { .txd_size = sizeof(struct mtk_tx_dma), .rxd_size = sizeof(struct mtk_rx_dma), @@ -604,7 +604,7 @@ Signed-off-by: David S. Miller }, }; -@@ -3502,6 +3675,10 @@ static const struct mtk_soc_data mt7622_ +@@ -3495,6 +3668,10 @@ static const struct mtk_soc_data mt7622_ .txrx = { .txd_size = sizeof(struct mtk_tx_dma), .rxd_size = sizeof(struct mtk_rx_dma), @@ -615,7 +615,7 @@ Signed-off-by: David S. Miller }, }; -@@ -3515,6 +3692,10 @@ static const struct mtk_soc_data mt7623_ +@@ -3508,6 +3685,10 @@ static const struct mtk_soc_data mt7623_ .txrx = { .txd_size = sizeof(struct mtk_tx_dma), .rxd_size = sizeof(struct mtk_rx_dma), @@ -626,7 +626,7 @@ Signed-off-by: David S. Miller }, }; -@@ -3528,6 +3709,10 @@ static const struct mtk_soc_data mt7629_ +@@ -3521,6 +3702,10 @@ static const struct mtk_soc_data mt7629_ .txrx = { .txd_size = sizeof(struct mtk_tx_dma), .rxd_size = sizeof(struct mtk_rx_dma), @@ -637,7 +637,7 @@ Signed-off-by: David S. Miller }, }; -@@ -3540,6 +3725,10 @@ static const struct mtk_soc_data rt5350_ +@@ -3533,6 +3718,10 @@ static const struct mtk_soc_data rt5350_ .txrx = { .txd_size = sizeof(struct mtk_tx_dma), .rxd_size = sizeof(struct mtk_rx_dma), diff --git a/target/linux/generic/backport-5.15/702-v5.19-30-net-ethernet-mtk_eth_soc-introduce-support-for-mt798.patch b/target/linux/generic/backport-5.15/702-v5.19-30-net-ethernet-mtk_eth_soc-introduce-support-for-mt798.patch index a4698d7814d..2df4b265a9b 100644 --- a/target/linux/generic/backport-5.15/702-v5.19-30-net-ethernet-mtk_eth_soc-introduce-support-for-mt798.patch +++ b/target/linux/generic/backport-5.15/702-v5.19-30-net-ethernet-mtk_eth_soc-introduce-support-for-mt798.patch @@ -65,7 +65,7 @@ Signed-off-by: David S. Miller }; void mtk_w32(struct mtk_eth *eth, u32 val, unsigned reg) -@@ -3712,6 +3749,21 @@ static const struct mtk_soc_data mt7629_ +@@ -3705,6 +3742,21 @@ static const struct mtk_soc_data mt7629_ }, }; @@ -87,7 +87,7 @@ Signed-off-by: David S. Miller static const struct mtk_soc_data rt5350_data = { .reg_map = &mt7628_reg_map, .caps = MT7628_CAPS, -@@ -3734,6 +3786,7 @@ const struct of_device_id of_mtk_match[] +@@ -3727,6 +3779,7 @@ const struct of_device_id of_mtk_match[] { .compatible = "mediatek,mt7622-eth", .data = &mt7622_data}, { .compatible = "mediatek,mt7623-eth", .data = &mt7623_data}, { .compatible = "mediatek,mt7629-eth", .data = &mt7629_data}, diff --git a/target/linux/generic/backport-5.15/702-v5.19-33-net-ethernet-mtk_eth_soc-enable-rx-cksum-offload-for.patch b/target/linux/generic/backport-5.15/702-v5.19-33-net-ethernet-mtk_eth_soc-enable-rx-cksum-offload-for.patch index d76df75dda8..2ad7b5792e9 100644 --- a/target/linux/generic/backport-5.15/702-v5.19-33-net-ethernet-mtk_eth_soc-enable-rx-cksum-offload-for.patch +++ b/target/linux/generic/backport-5.15/702-v5.19-33-net-ethernet-mtk_eth_soc-enable-rx-cksum-offload-for.patch @@ -37,7 +37,7 @@ Signed-off-by: Jakub Kicinski skb->ip_summed = CHECKSUM_UNNECESSARY; else skb_checksum_none_assert(skb); -@@ -3759,6 +3765,7 @@ static const struct mtk_soc_data mt7986_ +@@ -3752,6 +3758,7 @@ static const struct mtk_soc_data mt7986_ .txd_size = sizeof(struct mtk_tx_dma_v2), .rxd_size = sizeof(struct mtk_rx_dma_v2), .rx_irq_done_mask = MTK_RX_DONE_INT_V2, diff --git a/target/linux/generic/backport-5.15/704-01-v5.17-net-mtk_eth_soc-populate-supported_interfaces-member.patch b/target/linux/generic/backport-5.15/704-01-v5.17-net-mtk_eth_soc-populate-supported_interfaces-member.patch index b6fe0dad4c8..f6279bf13d8 100644 --- a/target/linux/generic/backport-5.15/704-01-v5.17-net-mtk_eth_soc-populate-supported_interfaces-member.patch +++ b/target/linux/generic/backport-5.15/704-01-v5.17-net-mtk_eth_soc-populate-supported_interfaces-member.patch @@ -14,7 +14,7 @@ Signed-off-by: David S. Miller --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c -@@ -3355,6 +3355,26 @@ static int mtk_add_mac(struct mtk_eth *e +@@ -3348,6 +3348,26 @@ static int mtk_add_mac(struct mtk_eth *e mac->phylink_config.dev = ð->netdev[id]->dev; mac->phylink_config.type = PHYLINK_NETDEV; diff --git a/target/linux/generic/backport-5.15/704-04-v5.17-net-mtk_eth_soc-use-phylink_generic_validate.patch b/target/linux/generic/backport-5.15/704-04-v5.17-net-mtk_eth_soc-use-phylink_generic_validate.patch index f695991ec1f..84c02992122 100644 --- a/target/linux/generic/backport-5.15/704-04-v5.17-net-mtk_eth_soc-use-phylink_generic_validate.patch +++ b/target/linux/generic/backport-5.15/704-04-v5.17-net-mtk_eth_soc-use-phylink_generic_validate.patch @@ -72,7 +72,7 @@ Signed-off-by: David S. Miller .mac_pcs_get_state = mtk_mac_pcs_get_state, .mac_an_restart = mtk_mac_an_restart, .mac_config = mtk_mac_config, -@@ -3317,6 +3269,9 @@ static int mtk_add_mac(struct mtk_eth *e +@@ -3310,6 +3262,9 @@ static int mtk_add_mac(struct mtk_eth *e mac->phylink_config.dev = ð->netdev[id]->dev; mac->phylink_config.type = PHYLINK_NETDEV; diff --git a/target/linux/generic/backport-5.15/704-05-v5.17-net-mtk_eth_soc-mark-as-a-legacy_pre_march2020-drive.patch b/target/linux/generic/backport-5.15/704-05-v5.17-net-mtk_eth_soc-mark-as-a-legacy_pre_march2020-drive.patch index cbff1bfbbc4..a6fbde5c892 100644 --- a/target/linux/generic/backport-5.15/704-05-v5.17-net-mtk_eth_soc-mark-as-a-legacy_pre_march2020-drive.patch +++ b/target/linux/generic/backport-5.15/704-05-v5.17-net-mtk_eth_soc-mark-as-a-legacy_pre_march2020-drive.patch @@ -16,7 +16,7 @@ Signed-off-by: Jakub Kicinski --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c -@@ -3269,6 +3269,10 @@ static int mtk_add_mac(struct mtk_eth *e +@@ -3262,6 +3262,10 @@ static int mtk_add_mac(struct mtk_eth *e mac->phylink_config.dev = ð->netdev[id]->dev; mac->phylink_config.type = PHYLINK_NETDEV; diff --git a/target/linux/generic/backport-5.15/704-06-v5.19-eth-mtk_eth_soc-remove-a-copy-of-the-NAPI_POLL_WEIGH.patch b/target/linux/generic/backport-5.15/704-06-v5.19-eth-mtk_eth_soc-remove-a-copy-of-the-NAPI_POLL_WEIGH.patch index c0b4a61cb6e..63f4ef13e12 100644 --- a/target/linux/generic/backport-5.15/704-06-v5.19-eth-mtk_eth_soc-remove-a-copy-of-the-NAPI_POLL_WEIGH.patch +++ b/target/linux/generic/backport-5.15/704-06-v5.19-eth-mtk_eth_soc-remove-a-copy-of-the-NAPI_POLL_WEIGH.patch @@ -16,7 +16,7 @@ Signed-off-by: David S. Miller --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c -@@ -3568,9 +3568,9 @@ static int mtk_probe(struct platform_dev +@@ -3561,9 +3561,9 @@ static int mtk_probe(struct platform_dev */ init_dummy_netdev(ð->dummy_dev); netif_napi_add(ð->dummy_dev, ð->tx_napi, mtk_napi_tx, diff --git a/target/linux/generic/backport-5.15/704-07-v5.19-mtk_eth_soc-remove-unused-mac-mode.patch b/target/linux/generic/backport-5.15/704-07-v5.19-mtk_eth_soc-remove-unused-mac-mode.patch index 5940ac27df9..ff3c422f26e 100644 --- a/target/linux/generic/backport-5.15/704-07-v5.19-mtk_eth_soc-remove-unused-mac-mode.patch +++ b/target/linux/generic/backport-5.15/704-07-v5.19-mtk_eth_soc-remove-unused-mac-mode.patch @@ -15,7 +15,7 @@ Signed-off-by: Jakub Kicinski --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c -@@ -3264,7 +3264,6 @@ static int mtk_add_mac(struct mtk_eth *e +@@ -3257,7 +3257,6 @@ static int mtk_add_mac(struct mtk_eth *e /* mac config is not set */ mac->interface = PHY_INTERFACE_MODE_NA; diff --git a/target/linux/generic/backport-5.15/704-11-v5.19-net-mtk_eth_soc-correct-802.3z-duplex-setting.patch b/target/linux/generic/backport-5.15/704-11-v5.19-net-mtk_eth_soc-correct-802.3z-duplex-setting.patch index 78444903a8c..e9e3e1f7452 100644 --- a/target/linux/generic/backport-5.15/704-11-v5.19-net-mtk_eth_soc-correct-802.3z-duplex-setting.patch +++ b/target/linux/generic/backport-5.15/704-11-v5.19-net-mtk_eth_soc-correct-802.3z-duplex-setting.patch @@ -38,7 +38,7 @@ Signed-off-by: Jakub Kicinski mcr &= ~(MAC_MCR_SPEED_100 | MAC_MCR_SPEED_1000 | MAC_MCR_FORCE_DPX | MAC_MCR_FORCE_TX_FC | MAC_MCR_FORCE_RX_FC); -@@ -3268,9 +3278,7 @@ static int mtk_add_mac(struct mtk_eth *e +@@ -3261,9 +3271,7 @@ static int mtk_add_mac(struct mtk_eth *e mac->phylink_config.dev = ð->netdev[id]->dev; mac->phylink_config.type = PHYLINK_NETDEV; diff --git a/target/linux/generic/backport-5.15/706-01-v6.0-net-ethernet-mtk_eth_soc-add-basic-XDP-support.patch b/target/linux/generic/backport-5.15/706-01-v6.0-net-ethernet-mtk_eth_soc-add-basic-XDP-support.patch index d94bdabd714..60e83a16513 100644 --- a/target/linux/generic/backport-5.15/706-01-v6.0-net-ethernet-mtk_eth_soc-add-basic-XDP-support.patch +++ b/target/linux/generic/backport-5.15/706-01-v6.0-net-ethernet-mtk_eth_soc-add-basic-XDP-support.patch @@ -257,7 +257,7 @@ Signed-off-by: David S. Miller static void ethsys_reset(struct mtk_eth *eth, u32 reset_bits) { regmap_update_bits(eth->ethsys, ETHSYS_RSTCTRL, -@@ -3005,6 +3122,12 @@ static int mtk_change_mtu(struct net_dev +@@ -2988,6 +3105,12 @@ static int mtk_change_mtu(struct net_dev struct mtk_eth *eth = mac->hw; u32 mcr_cur, mcr_new; @@ -270,7 +270,7 @@ Signed-off-by: David S. Miller if (!MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628)) { mcr_cur = mtk_r32(mac->hw, MTK_MAC_MCR(mac->id)); mcr_new = mcr_cur & ~MAC_MCR_MAX_RX_MASK; -@@ -3332,6 +3455,7 @@ static const struct net_device_ops mtk_n +@@ -3314,6 +3437,7 @@ static const struct net_device_ops mtk_n .ndo_poll_controller = mtk_poll_controller, #endif .ndo_setup_tc = mtk_eth_setup_tc, diff --git a/target/linux/generic/backport-5.15/706-03-v6.0-net-ethernet-mtk_eth_soc-add-xmit-XDP-support.patch b/target/linux/generic/backport-5.15/706-03-v6.0-net-ethernet-mtk_eth_soc-add-xmit-XDP-support.patch index 58b49f28a25..8c134500117 100644 --- a/target/linux/generic/backport-5.15/706-03-v6.0-net-ethernet-mtk_eth_soc-add-xmit-XDP-support.patch +++ b/target/linux/generic/backport-5.15/706-03-v6.0-net-ethernet-mtk_eth_soc-add-xmit-XDP-support.patch @@ -304,7 +304,7 @@ Signed-off-by: David S. Miller } mtk_tx_unmap(eth, tx_buf, true); -@@ -3478,6 +3627,7 @@ static const struct net_device_ops mtk_n +@@ -3460,6 +3609,7 @@ static const struct net_device_ops mtk_n #endif .ndo_setup_tc = mtk_eth_setup_tc, .ndo_bpf = mtk_xdp, diff --git a/target/linux/generic/backport-5.15/706-04-v6.0-net-ethernet-mtk_eth_soc-add-support-for-page_pool_g.patch b/target/linux/generic/backport-5.15/706-04-v6.0-net-ethernet-mtk_eth_soc-add-support-for-page_pool_g.patch index e93e0df544a..3108d67da49 100644 --- a/target/linux/generic/backport-5.15/706-04-v6.0-net-ethernet-mtk_eth_soc-add-support-for-page_pool_g.patch +++ b/target/linux/generic/backport-5.15/706-04-v6.0-net-ethernet-mtk_eth_soc-add-support-for-page_pool_g.patch @@ -26,7 +26,7 @@ Signed-off-by: David S. Miller MediaTek SoC family. --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c -@@ -3488,11 +3488,18 @@ static void mtk_get_strings(struct net_d +@@ -3471,11 +3471,18 @@ static void mtk_get_strings(struct net_d int i; switch (stringset) { @@ -46,7 +46,7 @@ Signed-off-by: David S. Miller break; } } -@@ -3500,13 +3507,35 @@ static void mtk_get_strings(struct net_d +@@ -3483,13 +3490,35 @@ static void mtk_get_strings(struct net_d static int mtk_get_sset_count(struct net_device *dev, int sset) { switch (sset) { @@ -84,7 +84,7 @@ Signed-off-by: David S. Miller static void mtk_get_ethtool_stats(struct net_device *dev, struct ethtool_stats *stats, u64 *data) { -@@ -3534,6 +3563,8 @@ static void mtk_get_ethtool_stats(struct +@@ -3517,6 +3546,8 @@ static void mtk_get_ethtool_stats(struct for (i = 0; i < ARRAY_SIZE(mtk_ethtool_stats); i++) *data_dst++ = *(data_src + mtk_ethtool_stats[i].offset); diff --git a/target/linux/generic/backport-5.15/713-v6.0-net-ethernet-mtk_eth_soc-move-gdma_to_ppe-and-ppe_ba.patch b/target/linux/generic/backport-5.15/713-v6.0-net-ethernet-mtk_eth_soc-move-gdma_to_ppe-and-ppe_ba.patch index f8bbea6c858..dbc338cf351 100644 --- a/target/linux/generic/backport-5.15/713-v6.0-net-ethernet-mtk_eth_soc-move-gdma_to_ppe-and-ppe_ba.patch +++ b/target/linux/generic/backport-5.15/713-v6.0-net-ethernet-mtk_eth_soc-move-gdma_to_ppe-and-ppe_ba.patch @@ -84,7 +84,7 @@ Signed-off-by: Lorenzo Bianconi refcount_set(ð->dma_refcnt, 1); } else -@@ -4048,7 +4053,9 @@ static int mtk_probe(struct platform_dev +@@ -4041,7 +4046,9 @@ static int mtk_probe(struct platform_dev } if (eth->soc->offload_version) { diff --git a/target/linux/generic/backport-5.15/714-v6.0-net-ethernet-mtk_eth_soc-move-ppe-table-hash-offset-.patch b/target/linux/generic/backport-5.15/714-v6.0-net-ethernet-mtk_eth_soc-move-ppe-table-hash-offset-.patch index 7bed2785c99..7cc0ab225eb 100644 --- a/target/linux/generic/backport-5.15/714-v6.0-net-ethernet-mtk_eth_soc-move-ppe-table-hash-offset-.patch +++ b/target/linux/generic/backport-5.15/714-v6.0-net-ethernet-mtk_eth_soc-move-ppe-table-hash-offset-.patch @@ -44,7 +44,7 @@ Signed-off-by: Lorenzo Bianconi --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c -@@ -4151,6 +4151,7 @@ static const struct mtk_soc_data mt7621_ +@@ -4144,6 +4144,7 @@ static const struct mtk_soc_data mt7621_ .required_clks = MT7621_CLKS_BITMAP, .required_pctl = false, .offload_version = 2, @@ -52,7 +52,7 @@ Signed-off-by: Lorenzo Bianconi .txrx = { .txd_size = sizeof(struct mtk_tx_dma), .rxd_size = sizeof(struct mtk_rx_dma), -@@ -4169,6 +4170,7 @@ static const struct mtk_soc_data mt7622_ +@@ -4162,6 +4163,7 @@ static const struct mtk_soc_data mt7622_ .required_clks = MT7622_CLKS_BITMAP, .required_pctl = false, .offload_version = 2, @@ -60,7 +60,7 @@ Signed-off-by: Lorenzo Bianconi .txrx = { .txd_size = sizeof(struct mtk_tx_dma), .rxd_size = sizeof(struct mtk_rx_dma), -@@ -4186,6 +4188,7 @@ static const struct mtk_soc_data mt7623_ +@@ -4179,6 +4181,7 @@ static const struct mtk_soc_data mt7623_ .required_clks = MT7623_CLKS_BITMAP, .required_pctl = true, .offload_version = 2, @@ -68,7 +68,7 @@ Signed-off-by: Lorenzo Bianconi .txrx = { .txd_size = sizeof(struct mtk_tx_dma), .rxd_size = sizeof(struct mtk_rx_dma), -@@ -4219,6 +4222,7 @@ static const struct mtk_soc_data mt7986_ +@@ -4212,6 +4215,7 @@ static const struct mtk_soc_data mt7986_ .caps = MT7986_CAPS, .required_clks = MT7986_CLKS_BITMAP, .required_pctl = false, diff --git a/target/linux/generic/backport-5.15/715-v6.0-net-ethernet-mtk_eth_soc-add-the-capability-to-run-m.patch b/target/linux/generic/backport-5.15/715-v6.0-net-ethernet-mtk_eth_soc-add-the-capability-to-run-m.patch index 93860e41457..6b21a82352e 100644 --- a/target/linux/generic/backport-5.15/715-v6.0-net-ethernet-mtk_eth_soc-add-the-capability-to-run-m.patch +++ b/target/linux/generic/backport-5.15/715-v6.0-net-ethernet-mtk_eth_soc-add-the-capability-to-run-m.patch @@ -100,7 +100,7 @@ Signed-off-by: Lorenzo Bianconi return 0; } -@@ -4053,12 +4058,19 @@ static int mtk_probe(struct platform_dev +@@ -4046,12 +4051,19 @@ static int mtk_probe(struct platform_dev } if (eth->soc->offload_version) { diff --git a/target/linux/generic/backport-5.15/716-v6.0-net-ethernet-mtk_eth_soc-move-wdma_base-definitions-.patch b/target/linux/generic/backport-5.15/716-v6.0-net-ethernet-mtk_eth_soc-move-wdma_base-definitions-.patch index a4b285632e1..92de6e79637 100644 --- a/target/linux/generic/backport-5.15/716-v6.0-net-ethernet-mtk_eth_soc-move-wdma_base-definitions-.patch +++ b/target/linux/generic/backport-5.15/716-v6.0-net-ethernet-mtk_eth_soc-move-wdma_base-definitions-.patch @@ -39,7 +39,7 @@ Signed-off-by: Lorenzo Bianconi }; /* strings used by ethtool */ -@@ -3970,16 +3978,12 @@ static int mtk_probe(struct platform_dev +@@ -3963,16 +3971,12 @@ static int mtk_probe(struct platform_dev for (i = 0;; i++) { struct device_node *np = of_parse_phandle(pdev->dev.of_node, "mediatek,wed", i); diff --git a/target/linux/generic/backport-5.15/717-v6.0-net-ethernet-mtk_eth_soc-add-foe_entry_size-to-mtk_e.patch b/target/linux/generic/backport-5.15/717-v6.0-net-ethernet-mtk_eth_soc-add-foe_entry_size-to-mtk_e.patch index 2bce63c4c01..fdafba43d81 100644 --- a/target/linux/generic/backport-5.15/717-v6.0-net-ethernet-mtk_eth_soc-add-foe_entry_size-to-mtk_e.patch +++ b/target/linux/generic/backport-5.15/717-v6.0-net-ethernet-mtk_eth_soc-add-foe_entry_size-to-mtk_e.patch @@ -21,7 +21,7 @@ Signed-off-by: Lorenzo Bianconi --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c -@@ -4168,6 +4168,7 @@ static const struct mtk_soc_data mt7621_ +@@ -4161,6 +4161,7 @@ static const struct mtk_soc_data mt7621_ .required_pctl = false, .offload_version = 2, .hash_offset = 2, @@ -29,7 +29,7 @@ Signed-off-by: Lorenzo Bianconi .txrx = { .txd_size = sizeof(struct mtk_tx_dma), .rxd_size = sizeof(struct mtk_rx_dma), -@@ -4187,6 +4188,7 @@ static const struct mtk_soc_data mt7622_ +@@ -4180,6 +4181,7 @@ static const struct mtk_soc_data mt7622_ .required_pctl = false, .offload_version = 2, .hash_offset = 2, @@ -37,7 +37,7 @@ Signed-off-by: Lorenzo Bianconi .txrx = { .txd_size = sizeof(struct mtk_tx_dma), .rxd_size = sizeof(struct mtk_rx_dma), -@@ -4205,6 +4207,7 @@ static const struct mtk_soc_data mt7623_ +@@ -4198,6 +4200,7 @@ static const struct mtk_soc_data mt7623_ .required_pctl = true, .offload_version = 2, .hash_offset = 2, diff --git a/target/linux/generic/backport-5.15/721-v6.0-net-ethernet-mtk_eth_wed-add-wed-support-for-mt7986-.patch b/target/linux/generic/backport-5.15/721-v6.0-net-ethernet-mtk_eth_wed-add-wed-support-for-mt7986-.patch index bfca7b20e45..f87fc4c451a 100644 --- a/target/linux/generic/backport-5.15/721-v6.0-net-ethernet-mtk_eth_wed-add-wed-support-for-mt7986-.patch +++ b/target/linux/generic/backport-5.15/721-v6.0-net-ethernet-mtk_eth_wed-add-wed-support-for-mt7986-.patch @@ -26,7 +26,7 @@ Signed-off-by: Lorenzo Bianconi --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c -@@ -3895,6 +3895,7 @@ void mtk_eth_set_dma_device(struct mtk_e +@@ -3888,6 +3888,7 @@ void mtk_eth_set_dma_device(struct mtk_e static int mtk_probe(struct platform_device *pdev) { @@ -34,7 +34,7 @@ Signed-off-by: Lorenzo Bianconi struct device_node *mac_np; struct mtk_eth *eth; int err, i; -@@ -3975,16 +3976,31 @@ static int mtk_probe(struct platform_dev +@@ -3968,16 +3969,31 @@ static int mtk_probe(struct platform_dev } } diff --git a/target/linux/generic/backport-5.15/723-v6.0-net-ethernet-mtk_eth_soc-introduce-flow-offloading-s.patch b/target/linux/generic/backport-5.15/723-v6.0-net-ethernet-mtk_eth_soc-introduce-flow-offloading-s.patch index fedcb6ccd89..50ea41240b8 100644 --- a/target/linux/generic/backport-5.15/723-v6.0-net-ethernet-mtk_eth_soc-introduce-flow-offloading-s.patch +++ b/target/linux/generic/backport-5.15/723-v6.0-net-ethernet-mtk_eth_soc-introduce-flow-offloading-s.patch @@ -49,7 +49,7 @@ Signed-off-by: Lorenzo Bianconi if (reason == MTK_PPE_CPU_REASON_HIT_UNBIND_RATE_REACHED) mtk_ppe_check_skb(eth->ppe[0], skb, hash); -@@ -4184,7 +4185,7 @@ static const struct mtk_soc_data mt7621_ +@@ -4177,7 +4178,7 @@ static const struct mtk_soc_data mt7621_ .required_pctl = false, .offload_version = 2, .hash_offset = 2, @@ -58,7 +58,7 @@ Signed-off-by: Lorenzo Bianconi .txrx = { .txd_size = sizeof(struct mtk_tx_dma), .rxd_size = sizeof(struct mtk_rx_dma), -@@ -4204,7 +4205,7 @@ static const struct mtk_soc_data mt7622_ +@@ -4197,7 +4198,7 @@ static const struct mtk_soc_data mt7622_ .required_pctl = false, .offload_version = 2, .hash_offset = 2, @@ -67,7 +67,7 @@ Signed-off-by: Lorenzo Bianconi .txrx = { .txd_size = sizeof(struct mtk_tx_dma), .rxd_size = sizeof(struct mtk_rx_dma), -@@ -4223,7 +4224,7 @@ static const struct mtk_soc_data mt7623_ +@@ -4216,7 +4217,7 @@ static const struct mtk_soc_data mt7623_ .required_pctl = true, .offload_version = 2, .hash_offset = 2, @@ -76,7 +76,7 @@ Signed-off-by: Lorenzo Bianconi .txrx = { .txd_size = sizeof(struct mtk_tx_dma), .rxd_size = sizeof(struct mtk_rx_dma), -@@ -4255,9 +4256,11 @@ static const struct mtk_soc_data mt7986_ +@@ -4248,9 +4249,11 @@ static const struct mtk_soc_data mt7986_ .reg_map = &mt7986_reg_map, .ana_rgc3 = 0x128, .caps = MT7986_CAPS, diff --git a/target/linux/generic/backport-5.15/724-v6.0-net-ethernet-mtk_eth_soc-enable-flow-offloading-supp.patch b/target/linux/generic/backport-5.15/724-v6.0-net-ethernet-mtk_eth_soc-enable-flow-offloading-supp.patch index e8bb85ac940..cd4747672de 100644 --- a/target/linux/generic/backport-5.15/724-v6.0-net-ethernet-mtk_eth_soc-enable-flow-offloading-supp.patch +++ b/target/linux/generic/backport-5.15/724-v6.0-net-ethernet-mtk_eth_soc-enable-flow-offloading-supp.patch @@ -16,7 +16,7 @@ Signed-off-by: Lorenzo Bianconi --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c -@@ -4259,6 +4259,7 @@ static const struct mtk_soc_data mt7986_ +@@ -4252,6 +4252,7 @@ static const struct mtk_soc_data mt7986_ .hw_features = MTK_HW_FEATURES, .required_clks = MT7986_CLKS_BITMAP, .required_pctl = false, diff --git a/target/linux/generic/backport-5.15/728-v6.1-01-net-ethernet-mtk_eth_soc-fix-possible-memory-leak-in.patch b/target/linux/generic/backport-5.15/728-v6.1-01-net-ethernet-mtk_eth_soc-fix-possible-memory-leak-in.patch index b41318afd76..624e0178bf8 100644 --- a/target/linux/generic/backport-5.15/728-v6.1-01-net-ethernet-mtk_eth_soc-fix-possible-memory-leak-in.patch +++ b/target/linux/generic/backport-5.15/728-v6.1-01-net-ethernet-mtk_eth_soc-fix-possible-memory-leak-in.patch @@ -17,7 +17,7 @@ Signed-off-by: David S. Miller --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c -@@ -4011,19 +4011,23 @@ static int mtk_probe(struct platform_dev +@@ -4004,19 +4004,23 @@ static int mtk_probe(struct platform_dev eth->irq[i] = platform_get_irq(pdev, i); if (eth->irq[i] < 0) { dev_err(&pdev->dev, "no IRQ%d resource found\n", i); @@ -45,7 +45,7 @@ Signed-off-by: David S. Miller } eth->clks[i] = NULL; } -@@ -4034,7 +4038,7 @@ static int mtk_probe(struct platform_dev +@@ -4027,7 +4031,7 @@ static int mtk_probe(struct platform_dev err = mtk_hw_init(eth); if (err) @@ -54,7 +54,7 @@ Signed-off-by: David S. Miller eth->hwlro = MTK_HAS_CAPS(eth->soc->caps, MTK_HWLRO); -@@ -4132,6 +4136,8 @@ err_free_dev: +@@ -4125,6 +4129,8 @@ err_free_dev: mtk_free_dev(eth); err_deinit_hw: mtk_hw_deinit(eth); @@ -63,7 +63,7 @@ Signed-off-by: David S. Miller return err; } -@@ -4151,6 +4157,7 @@ static int mtk_remove(struct platform_de +@@ -4144,6 +4150,7 @@ static int mtk_remove(struct platform_de phylink_disconnect_phy(mac->phylink); } diff --git a/target/linux/generic/backport-5.15/729-06-v6.1-net-ethernet-mtk_eth_soc-do-not-overwrite-mtu-config.patch b/target/linux/generic/backport-5.15/729-06-v6.1-net-ethernet-mtk_eth_soc-do-not-overwrite-mtu-config.patch index 003ca9bae69..78f5f1859e4 100644 --- a/target/linux/generic/backport-5.15/729-06-v6.1-net-ethernet-mtk_eth_soc-do-not-overwrite-mtu-config.patch +++ b/target/linux/generic/backport-5.15/729-06-v6.1-net-ethernet-mtk_eth_soc-do-not-overwrite-mtu-config.patch @@ -63,7 +63,7 @@ Signed-off-by: David S. Miller /* Indicates CDM to parse the MTK special tag from CPU * which also is working out for untag packets. -@@ -3367,7 +3399,6 @@ static int mtk_change_mtu(struct net_dev +@@ -3350,7 +3382,6 @@ static int mtk_change_mtu(struct net_dev int length = new_mtu + MTK_RX_ETH_HLEN; struct mtk_mac *mac = netdev_priv(dev); struct mtk_eth *eth = mac->hw; @@ -71,7 +71,7 @@ Signed-off-by: David S. Miller if (rcu_access_pointer(eth->prog) && length > MTK_PP_MAX_BUF_SIZE) { -@@ -3375,23 +3406,7 @@ static int mtk_change_mtu(struct net_dev +@@ -3358,23 +3389,7 @@ static int mtk_change_mtu(struct net_dev return -EINVAL; } diff --git a/target/linux/generic/backport-5.15/729-07-v6.1-net-ethernet-mtk_eth_soc-remove-cpu_relax-in-mtk_pen.patch b/target/linux/generic/backport-5.15/729-07-v6.1-net-ethernet-mtk_eth_soc-remove-cpu_relax-in-mtk_pen.patch index 342ffb99d2f..5b8768899dd 100644 --- a/target/linux/generic/backport-5.15/729-07-v6.1-net-ethernet-mtk_eth_soc-remove-cpu_relax-in-mtk_pen.patch +++ b/target/linux/generic/backport-5.15/729-07-v6.1-net-ethernet-mtk_eth_soc-remove-cpu_relax-in-mtk_pen.patch @@ -12,7 +12,7 @@ Signed-off-by: David S. Miller --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c -@@ -3437,11 +3437,8 @@ static void mtk_pending_work(struct work +@@ -3420,11 +3420,8 @@ static void mtk_pending_work(struct work rtnl_lock(); dev_dbg(eth->dev, "[%s][%d] reset\n", __func__, __LINE__); @@ -25,7 +25,7 @@ Signed-off-by: David S. Miller /* stop all devices to make sure that dma is properly shut down */ for (i = 0; i < MTK_MAC_COUNT; i++) { if (!eth->netdev[i]) -@@ -3475,7 +3472,7 @@ static void mtk_pending_work(struct work +@@ -3458,7 +3455,7 @@ static void mtk_pending_work(struct work dev_dbg(eth->dev, "[%s][%d] reset done\n", __func__, __LINE__); diff --git a/target/linux/generic/backport-5.15/729-19-v6.3-net-ethernet-mtk_eth_soc-introduce-mtk_hw_warm_reset.patch b/target/linux/generic/backport-5.15/729-19-v6.3-net-ethernet-mtk_eth_soc-introduce-mtk_hw_warm_reset.patch index c34e30c773e..35004462d25 100644 --- a/target/linux/generic/backport-5.15/729-19-v6.3-net-ethernet-mtk_eth_soc-introduce-mtk_hw_warm_reset.patch +++ b/target/linux/generic/backport-5.15/729-19-v6.3-net-ethernet-mtk_eth_soc-introduce-mtk_hw_warm_reset.patch @@ -87,7 +87,7 @@ Signed-off-by: Paolo Abeni if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) { /* Set FE to PDMAv2 if necessary */ -@@ -3465,7 +3517,7 @@ static void mtk_pending_work(struct work +@@ -3448,7 +3500,7 @@ static void mtk_pending_work(struct work if (eth->dev->pins) pinctrl_select_state(eth->dev->pins->p, eth->dev->pins->default_state); @@ -96,7 +96,7 @@ Signed-off-by: Paolo Abeni /* restart DMA and enable IRQs */ for (i = 0; i < MTK_MAC_COUNT; i++) { -@@ -4057,7 +4109,7 @@ static int mtk_probe(struct platform_dev +@@ -4050,7 +4102,7 @@ static int mtk_probe(struct platform_dev eth->msg_enable = netif_msg_init(mtk_msg_level, MTK_DEFAULT_MSG_ENABLE); INIT_WORK(ð->pending_work, mtk_pending_work); diff --git a/target/linux/generic/backport-5.15/729-20-v6.3-net-ethernet-mtk_eth_soc-align-reset-procedure-to-ve.patch b/target/linux/generic/backport-5.15/729-20-v6.3-net-ethernet-mtk_eth_soc-align-reset-procedure-to-ve.patch index 29a5b627390..f87b4c9e5b1 100644 --- a/target/linux/generic/backport-5.15/729-20-v6.3-net-ethernet-mtk_eth_soc-align-reset-procedure-to-ve.patch +++ b/target/linux/generic/backport-5.15/729-20-v6.3-net-ethernet-mtk_eth_soc-align-reset-procedure-to-ve.patch @@ -85,7 +85,7 @@ Signed-off-by: Paolo Abeni return ret; } -@@ -3489,30 +3508,53 @@ static int mtk_do_ioctl(struct net_devic +@@ -3472,30 +3491,53 @@ static int mtk_do_ioctl(struct net_devic return -EOPNOTSUPP; } @@ -148,7 +148,7 @@ Signed-off-by: Paolo Abeni if (eth->dev->pins) pinctrl_select_state(eth->dev->pins->p, -@@ -3523,15 +3565,19 @@ static void mtk_pending_work(struct work +@@ -3506,15 +3548,19 @@ static void mtk_pending_work(struct work for (i = 0; i < MTK_MAC_COUNT; i++) { if (!test_bit(i, &restart)) continue; diff --git a/target/linux/generic/backport-5.15/729-21-v6.3-net-ethernet-mtk_eth_soc-add-dma-checks-to-mtk_hw_re.patch b/target/linux/generic/backport-5.15/729-21-v6.3-net-ethernet-mtk_eth_soc-add-dma-checks-to-mtk_hw_re.patch index cebb750bf64..bc8b9a33274 100644 --- a/target/linux/generic/backport-5.15/729-21-v6.3-net-ethernet-mtk_eth_soc-add-dma-checks-to-mtk_hw_re.patch +++ b/target/linux/generic/backport-5.15/729-21-v6.3-net-ethernet-mtk_eth_soc-add-dma-checks-to-mtk_hw_re.patch @@ -152,7 +152,7 @@ Signed-off-by: Paolo Abeni static int mtk_hw_init(struct mtk_eth *eth, bool reset) { u32 dma_mask = ETHSYS_DMA_AG_MAP_PDMA | ETHSYS_DMA_AG_MAP_QDMA | -@@ -3615,6 +3717,7 @@ static int mtk_cleanup(struct mtk_eth *e +@@ -3598,6 +3700,7 @@ static int mtk_cleanup(struct mtk_eth *e mtk_unreg_dev(eth); mtk_free_dev(eth); cancel_work_sync(ð->pending_work); @@ -160,7 +160,7 @@ Signed-off-by: Paolo Abeni return 0; } -@@ -4042,6 +4145,7 @@ static int mtk_probe(struct platform_dev +@@ -4035,6 +4138,7 @@ static int mtk_probe(struct platform_dev eth->rx_dim.mode = DIM_CQ_PERIOD_MODE_START_FROM_EQE; INIT_WORK(ð->rx_dim.work, mtk_dim_rx); @@ -168,7 +168,7 @@ Signed-off-by: Paolo Abeni eth->tx_dim.mode = DIM_CQ_PERIOD_MODE_START_FROM_EQE; INIT_WORK(ð->tx_dim.work, mtk_dim_tx); -@@ -4246,6 +4350,8 @@ static int mtk_probe(struct platform_dev +@@ -4239,6 +4343,8 @@ static int mtk_probe(struct platform_dev NAPI_POLL_WEIGHT); platform_set_drvdata(pdev, eth); diff --git a/target/linux/generic/backport-5.15/729-22-v6.3-net-ethernet-mtk_wed-add-reset-reset_complete-callba.patch b/target/linux/generic/backport-5.15/729-22-v6.3-net-ethernet-mtk_wed-add-reset-reset_complete-callba.patch index 2eca2686708..ae0e0e95910 100644 --- a/target/linux/generic/backport-5.15/729-22-v6.3-net-ethernet-mtk_wed-add-reset-reset_complete-callba.patch +++ b/target/linux/generic/backport-5.15/729-22-v6.3-net-ethernet-mtk_wed-add-reset-reset_complete-callba.patch @@ -14,7 +14,7 @@ Signed-off-by: Paolo Abeni --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c -@@ -3646,6 +3646,11 @@ static void mtk_pending_work(struct work +@@ -3629,6 +3629,11 @@ static void mtk_pending_work(struct work set_bit(MTK_RESETTING, ð->state); mtk_prepare_for_reset(eth); @@ -26,7 +26,7 @@ Signed-off-by: Paolo Abeni /* stop all devices to make sure that dma is properly shut down */ for (i = 0; i < MTK_MAC_COUNT; i++) { -@@ -3683,6 +3688,8 @@ static void mtk_pending_work(struct work +@@ -3666,6 +3671,8 @@ static void mtk_pending_work(struct work clear_bit(MTK_RESETTING, ð->state); diff --git a/target/linux/generic/backport-5.15/730-03-v6.3-net-ethernet-mtk_eth_soc-avoid-port_mg-assignment-on.patch b/target/linux/generic/backport-5.15/730-03-v6.3-net-ethernet-mtk_eth_soc-avoid-port_mg-assignment-on.patch index 32dc5c37832..1e1ac560db7 100644 --- a/target/linux/generic/backport-5.15/730-03-v6.3-net-ethernet-mtk_eth_soc-avoid-port_mg-assignment-on.patch +++ b/target/linux/generic/backport-5.15/730-03-v6.3-net-ethernet-mtk_eth_soc-avoid-port_mg-assignment-on.patch @@ -12,7 +12,7 @@ Signed-off-by: Felix Fietkau --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c -@@ -4428,7 +4428,7 @@ static const struct mtk_soc_data mt7621_ +@@ -4421,7 +4421,7 @@ static const struct mtk_soc_data mt7621_ .hw_features = MTK_HW_FEATURES, .required_clks = MT7621_CLKS_BITMAP, .required_pctl = false, @@ -21,7 +21,7 @@ Signed-off-by: Felix Fietkau .hash_offset = 2, .foe_entry_size = sizeof(struct mtk_foe_entry) - 16, .txrx = { -@@ -4467,7 +4467,7 @@ static const struct mtk_soc_data mt7623_ +@@ -4460,7 +4460,7 @@ static const struct mtk_soc_data mt7623_ .hw_features = MTK_HW_FEATURES, .required_clks = MT7623_CLKS_BITMAP, .required_pctl = true, diff --git a/target/linux/generic/backport-5.15/730-04-v6.3-net-ethernet-mtk_eth_soc-implement-multi-queue-suppo.patch b/target/linux/generic/backport-5.15/730-04-v6.3-net-ethernet-mtk_eth_soc-implement-multi-queue-suppo.patch index cfbd510c8f2..2e2299c932f 100644 --- a/target/linux/generic/backport-5.15/730-04-v6.3-net-ethernet-mtk_eth_soc-implement-multi-queue-suppo.patch +++ b/target/linux/generic/backport-5.15/730-04-v6.3-net-ethernet-mtk_eth_soc-implement-multi-queue-suppo.patch @@ -489,7 +489,7 @@ Signed-off-by: Felix Fietkau return 0; } -@@ -3717,8 +3873,12 @@ static int mtk_unreg_dev(struct mtk_eth +@@ -3700,8 +3856,12 @@ static int mtk_unreg_dev(struct mtk_eth int i; for (i = 0; i < MTK_MAC_COUNT; i++) { @@ -502,7 +502,7 @@ Signed-off-by: Felix Fietkau unregister_netdev(eth->netdev[i]); } -@@ -3935,6 +4095,23 @@ static int mtk_set_rxnfc(struct net_devi +@@ -3918,6 +4078,23 @@ static int mtk_set_rxnfc(struct net_devi return ret; } @@ -526,7 +526,7 @@ Signed-off-by: Felix Fietkau static const struct ethtool_ops mtk_ethtool_ops = { .get_link_ksettings = mtk_get_link_ksettings, .set_link_ksettings = mtk_set_link_ksettings, -@@ -3970,6 +4147,7 @@ static const struct net_device_ops mtk_n +@@ -3952,6 +4129,7 @@ static const struct net_device_ops mtk_n .ndo_setup_tc = mtk_eth_setup_tc, .ndo_bpf = mtk_xdp, .ndo_xdp_xmit = mtk_xdp_xmit, @@ -534,7 +534,7 @@ Signed-off-by: Felix Fietkau }; static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np) -@@ -3979,6 +4157,7 @@ static int mtk_add_mac(struct mtk_eth *e +@@ -3961,6 +4139,7 @@ static int mtk_add_mac(struct mtk_eth *e struct phylink *phylink; struct mtk_mac *mac; int id, err; @@ -542,7 +542,7 @@ Signed-off-by: Felix Fietkau if (!_id) { dev_err(eth->dev, "missing mac id\n"); -@@ -3996,7 +4175,10 @@ static int mtk_add_mac(struct mtk_eth *e +@@ -3978,7 +4157,10 @@ static int mtk_add_mac(struct mtk_eth *e return -EINVAL; } @@ -554,7 +554,7 @@ Signed-off-by: Felix Fietkau if (!eth->netdev[id]) { dev_err(eth->dev, "alloc_etherdev failed\n"); return -ENOMEM; -@@ -4093,6 +4275,11 @@ static int mtk_add_mac(struct mtk_eth *e +@@ -4086,6 +4268,11 @@ static int mtk_add_mac(struct mtk_eth *e else eth->netdev[id]->max_mtu = MTK_MAX_RX_LENGTH_2K - MTK_RX_ETH_HLEN; diff --git a/target/linux/generic/backport-5.15/730-09-v6.3-net-ethernet-mtk_eth_soc-fix-VLAN-rx-hardware-accele.patch b/target/linux/generic/backport-5.15/730-09-v6.3-net-ethernet-mtk_eth_soc-fix-VLAN-rx-hardware-accele.patch index beba07238fd..6ebd1abcd0f 100644 --- a/target/linux/generic/backport-5.15/730-09-v6.3-net-ethernet-mtk_eth_soc-fix-VLAN-rx-hardware-accele.patch +++ b/target/linux/generic/backport-5.15/730-09-v6.3-net-ethernet-mtk_eth_soc-fix-VLAN-rx-hardware-accele.patch @@ -146,7 +146,7 @@ Signed-off-by: Felix Fietkau /* Enable RX VLan Offloading */ mtk_w32(eth, 1, MTK_CDMP_EG_CTRL); -@@ -3865,6 +3925,12 @@ static int mtk_free_dev(struct mtk_eth * +@@ -3848,6 +3908,12 @@ static int mtk_free_dev(struct mtk_eth * free_netdev(eth->netdev[i]); } diff --git a/target/linux/generic/backport-5.15/733-v6.3-18-net-ethernet-mtk_eth_soc-add-support-for-MT7981.patch b/target/linux/generic/backport-5.15/733-v6.3-18-net-ethernet-mtk_eth_soc-add-support-for-MT7981.patch index c1cf323800c..36fa94a7905 100644 --- a/target/linux/generic/backport-5.15/733-v6.3-18-net-ethernet-mtk_eth_soc-add-support-for-MT7981.patch +++ b/target/linux/generic/backport-5.15/733-v6.3-18-net-ethernet-mtk_eth_soc-add-support-for-MT7981.patch @@ -51,7 +51,7 @@ Signed-off-by: Jakub Kicinski mtk_eth_path_name(path), __func__, updated); --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c -@@ -4755,6 +4755,26 @@ static const struct mtk_soc_data mt7629_ +@@ -4748,6 +4748,26 @@ static const struct mtk_soc_data mt7629_ }, }; @@ -78,7 +78,7 @@ Signed-off-by: Jakub Kicinski static const struct mtk_soc_data mt7986_data = { .reg_map = &mt7986_reg_map, .ana_rgc3 = 0x128, -@@ -4797,6 +4817,7 @@ const struct of_device_id of_mtk_match[] +@@ -4790,6 +4810,7 @@ const struct of_device_id of_mtk_match[] { .compatible = "mediatek,mt7622-eth", .data = &mt7622_data}, { .compatible = "mediatek,mt7623-eth", .data = &mt7623_data}, { .compatible = "mediatek,mt7629-eth", .data = &mt7629_data}, diff --git a/target/linux/generic/backport-5.15/733-v6.3-20-net-ethernet-mtk_eth_soc-switch-to-external-PCS-driv.patch b/target/linux/generic/backport-5.15/733-v6.3-20-net-ethernet-mtk_eth_soc-switch-to-external-PCS-driv.patch index 203c5dc48bb..2e6a70d7255 100644 --- a/target/linux/generic/backport-5.15/733-v6.3-20-net-ethernet-mtk_eth_soc-switch-to-external-PCS-driv.patch +++ b/target/linux/generic/backport-5.15/733-v6.3-20-net-ethernet-mtk_eth_soc-switch-to-external-PCS-driv.patch @@ -60,7 +60,7 @@ Signed-off-by: Jakub Kicinski } return NULL; -@@ -3977,8 +3978,17 @@ static int mtk_unreg_dev(struct mtk_eth +@@ -3960,8 +3961,17 @@ static int mtk_unreg_dev(struct mtk_eth return 0; } @@ -78,7 +78,7 @@ Signed-off-by: Jakub Kicinski mtk_unreg_dev(eth); mtk_free_dev(eth); cancel_work_sync(ð->pending_work); -@@ -4408,6 +4418,36 @@ void mtk_eth_set_dma_device(struct mtk_e +@@ -4401,6 +4411,36 @@ void mtk_eth_set_dma_device(struct mtk_e rtnl_unlock(); } @@ -115,7 +115,7 @@ Signed-off-by: Jakub Kicinski static int mtk_probe(struct platform_device *pdev) { struct resource *res = NULL; -@@ -4471,13 +4511,7 @@ static int mtk_probe(struct platform_dev +@@ -4464,13 +4504,7 @@ static int mtk_probe(struct platform_dev } if (MTK_HAS_CAPS(eth->soc->caps, MTK_SGMII)) { @@ -130,7 +130,7 @@ Signed-off-by: Jakub Kicinski if (err) return err; -@@ -4488,14 +4522,17 @@ static int mtk_probe(struct platform_dev +@@ -4481,14 +4515,17 @@ static int mtk_probe(struct platform_dev "mediatek,pctl"); if (IS_ERR(eth->pctl)) { dev_err(&pdev->dev, "no pctl regmap found\n"); @@ -151,7 +151,7 @@ Signed-off-by: Jakub Kicinski } if (eth->soc->offload_version) { -@@ -4655,6 +4692,8 @@ err_deinit_hw: +@@ -4648,6 +4685,8 @@ err_deinit_hw: mtk_hw_deinit(eth); err_wed_exit: mtk_wed_exit(); diff --git a/target/linux/generic/backport-5.15/735-v6.5-net-bgmac-postpone-turning-IRQs-off-to-avoid-SoC-han.patch b/target/linux/generic/backport-5.15/735-v6.5-net-bgmac-postpone-turning-IRQs-off-to-avoid-SoC-han.patch deleted file mode 100644 index 26e9ae3bcd2..00000000000 --- a/target/linux/generic/backport-5.15/735-v6.5-net-bgmac-postpone-turning-IRQs-off-to-avoid-SoC-han.patch +++ /dev/null @@ -1,45 +0,0 @@ -From e7731194fdf085f46d58b1adccfddbd0dfee4873 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= -Date: Fri, 7 Jul 2023 08:53:25 +0200 -Subject: [PATCH] net: bgmac: postpone turning IRQs off to avoid SoC hangs -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Turning IRQs off is done by accessing Ethernet controller registers. -That can't be done until device's clock is enabled. It results in a SoC -hang otherwise. - -This bug remained unnoticed for years as most bootloaders keep all -Ethernet interfaces turned on. It seems to only affect a niche SoC -family BCM47189. It has two Ethernet controllers but CFE bootloader uses -only the first one. - -Fixes: 34322615cbaa ("net: bgmac: Mask interrupts during probe") -Signed-off-by: Rafał Miłecki -Reviewed-by: Michal Kubiak -Signed-off-by: David S. Miller ---- - drivers/net/ethernet/broadcom/bgmac.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - ---- a/drivers/net/ethernet/broadcom/bgmac.c -+++ b/drivers/net/ethernet/broadcom/bgmac.c -@@ -1492,8 +1492,6 @@ int bgmac_enet_probe(struct bgmac *bgmac - - bgmac->in_init = true; - -- bgmac_chip_intrs_off(bgmac); -- - net_dev->irq = bgmac->irq; - SET_NETDEV_DEV(net_dev, bgmac->dev); - dev_set_drvdata(bgmac->dev, bgmac); -@@ -1511,6 +1509,8 @@ int bgmac_enet_probe(struct bgmac *bgmac - */ - bgmac_clk_enable(bgmac, 0); - -+ bgmac_chip_intrs_off(bgmac); -+ - /* This seems to be fixing IRQ by assigning OOB #6 to the core */ - if (!(bgmac->feature_flags & BGMAC_FEAT_IDM_MASK)) { - if (bgmac->feature_flags & BGMAC_FEAT_IRQ_ID_OOB_6) diff --git a/target/linux/generic/backport-5.15/775-v6.0-01-net-ethernet-stmicro-stmmac-move-queue-reset-to-dedi.patch b/target/linux/generic/backport-5.15/775-v6.0-01-net-ethernet-stmicro-stmmac-move-queue-reset-to-dedi.patch index 9b9ab04af6c..3c9d4e72e85 100644 --- a/target/linux/generic/backport-5.15/775-v6.0-01-net-ethernet-stmicro-stmmac-move-queue-reset-to-dedi.patch +++ b/target/linux/generic/backport-5.15/775-v6.0-01-net-ethernet-stmicro-stmmac-move-queue-reset-to-dedi.patch @@ -87,7 +87,7 @@ Signed-off-by: Jakub Kicinski stmmac_clear_tx_descriptors(priv, queue); stmmac_init_tx_chan(priv, priv->ioaddr, priv->plat->dma_cfg, -@@ -7417,6 +7412,25 @@ int stmmac_suspend(struct device *dev) +@@ -7411,6 +7406,25 @@ int stmmac_suspend(struct device *dev) } EXPORT_SYMBOL_GPL(stmmac_suspend); @@ -113,7 +113,7 @@ Signed-off-by: Jakub Kicinski /** * stmmac_reset_queues_param - reset queue parameters * @priv: device pointer -@@ -7427,22 +7441,11 @@ static void stmmac_reset_queues_param(st +@@ -7421,22 +7435,11 @@ static void stmmac_reset_queues_param(st u32 tx_cnt = priv->plat->tx_queues_to_use; u32 queue; diff --git a/target/linux/generic/backport-5.15/775-v6.0-03-net-ethernet-stmicro-stmmac-move-dma-conf-to-dedicat.patch b/target/linux/generic/backport-5.15/775-v6.0-03-net-ethernet-stmicro-stmmac-move-dma-conf-to-dedicat.patch index d4c2567a1fd..34b7e1fd8d1 100644 --- a/target/linux/generic/backport-5.15/775-v6.0-03-net-ethernet-stmicro-stmmac-move-dma-conf-to-dedicat.patch +++ b/target/linux/generic/backport-5.15/775-v6.0-03-net-ethernet-stmicro-stmmac-move-dma-conf-to-dedicat.patch @@ -1210,7 +1210,7 @@ Signed-off-by: Jakub Kicinski if (netif_running(dev)) ret = stmmac_open(dev); -@@ -7363,7 +7367,7 @@ int stmmac_suspend(struct device *dev) +@@ -7357,7 +7361,7 @@ int stmmac_suspend(struct device *dev) stmmac_disable_all_queues(priv); for (chan = 0; chan < priv->plat->tx_queues_to_use; chan++) @@ -1219,7 +1219,7 @@ Signed-off-by: Jakub Kicinski if (priv->eee_enabled) { priv->tx_path_in_lpi_mode = false; -@@ -7414,7 +7418,7 @@ EXPORT_SYMBOL_GPL(stmmac_suspend); +@@ -7408,7 +7412,7 @@ EXPORT_SYMBOL_GPL(stmmac_suspend); static void stmmac_reset_rx_queue(struct stmmac_priv *priv, u32 queue) { @@ -1228,7 +1228,7 @@ Signed-off-by: Jakub Kicinski rx_q->cur_rx = 0; rx_q->dirty_rx = 0; -@@ -7422,7 +7426,7 @@ static void stmmac_reset_rx_queue(struct +@@ -7416,7 +7420,7 @@ static void stmmac_reset_rx_queue(struct static void stmmac_reset_tx_queue(struct stmmac_priv *priv, u32 queue) { diff --git a/target/linux/generic/backport-5.15/775-v6.0-04-net-ethernet-stmicro-stmmac-generate-stmmac-dma-conf.patch b/target/linux/generic/backport-5.15/775-v6.0-04-net-ethernet-stmicro-stmmac-generate-stmmac-dma-conf.patch index e84373b4718..a7ee50ddd02 100644 --- a/target/linux/generic/backport-5.15/775-v6.0-04-net-ethernet-stmicro-stmmac-generate-stmmac-dma-conf.patch +++ b/target/linux/generic/backport-5.15/775-v6.0-04-net-ethernet-stmicro-stmmac-generate-stmmac-dma-conf.patch @@ -1150,7 +1150,7 @@ Signed-off-by: Jakub Kicinski dma_desc_error: return ret; } -@@ -7509,7 +7625,7 @@ int stmmac_resume(struct device *dev) +@@ -7503,7 +7619,7 @@ int stmmac_resume(struct device *dev) stmmac_reset_queues_param(priv); stmmac_free_tx_skbufs(priv); diff --git a/target/linux/generic/backport-5.15/817-v6.5-01-leds-trigger-netdev-Recheck-NETDEV_LED_MODE_LINKUP-o.patch b/target/linux/generic/backport-5.15/817-v6.5-01-leds-trigger-netdev-Recheck-NETDEV_LED_MODE_LINKUP-o.patch deleted file mode 100644 index 3385023168d..00000000000 --- a/target/linux/generic/backport-5.15/817-v6.5-01-leds-trigger-netdev-Recheck-NETDEV_LED_MODE_LINKUP-o.patch +++ /dev/null @@ -1,35 +0,0 @@ -From cee4bd16c3195a701be683f7da9e88c6e11acb73 Mon Sep 17 00:00:00 2001 -From: Christian Marangi -Date: Wed, 19 Apr 2023 23:07:39 +0200 -Subject: [PATCH 1/5] leds: trigger: netdev: Recheck NETDEV_LED_MODE_LINKUP on - dev rename - -Dev can be renamed also while up for supported device. We currently -wrongly clear the NETDEV_LED_MODE_LINKUP flag on NETDEV_CHANGENAME -event. - -Fix this by rechecking if the carrier is ok on NETDEV_CHANGENAME and -correctly set the NETDEV_LED_MODE_LINKUP bit. - -Fixes: 5f820ed52371 ("leds: trigger: netdev: fix handling on interface rename") -Cc: stable@vger.kernel.org # v5.5+ -Signed-off-by: Christian Marangi -Reviewed-by: Andrew Lunn -Signed-off-by: Lee Jones -Link: https://lore.kernel.org/r/20230419210743.3594-2-ansuelsmth@gmail.com ---- - drivers/leds/trigger/ledtrig-netdev.c | 3 +++ - 1 file changed, 3 insertions(+) - ---- a/drivers/leds/trigger/ledtrig-netdev.c -+++ b/drivers/leds/trigger/ledtrig-netdev.c -@@ -318,6 +318,9 @@ static int netdev_trig_notify(struct not - clear_bit(NETDEV_LED_MODE_LINKUP, &trigger_data->mode); - switch (evt) { - case NETDEV_CHANGENAME: -+ if (netif_carrier_ok(dev)) -+ set_bit(NETDEV_LED_MODE_LINKUP, &trigger_data->mode); -+ fallthrough; - case NETDEV_REGISTER: - if (trigger_data->net_dev) - dev_put(trigger_data->net_dev); diff --git a/target/linux/generic/backport-6.1/729-07-v6.1-net-ethernet-mtk_eth_soc-remove-cpu_relax-in-mtk_pen.patch b/target/linux/generic/backport-6.1/729-07-v6.1-net-ethernet-mtk_eth_soc-remove-cpu_relax-in-mtk_pen.patch index 83e015cc6bf..7d05eb8ee8b 100644 --- a/target/linux/generic/backport-6.1/729-07-v6.1-net-ethernet-mtk_eth_soc-remove-cpu_relax-in-mtk_pen.patch +++ b/target/linux/generic/backport-6.1/729-07-v6.1-net-ethernet-mtk_eth_soc-remove-cpu_relax-in-mtk_pen.patch @@ -12,7 +12,7 @@ Signed-off-by: David S. Miller --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c -@@ -3495,11 +3495,8 @@ static void mtk_pending_work(struct work +@@ -3478,11 +3478,8 @@ static void mtk_pending_work(struct work rtnl_lock(); dev_dbg(eth->dev, "[%s][%d] reset\n", __func__, __LINE__); @@ -25,7 +25,7 @@ Signed-off-by: David S. Miller /* stop all devices to make sure that dma is properly shut down */ for (i = 0; i < MTK_MAC_COUNT; i++) { if (!eth->netdev[i]) -@@ -3533,7 +3530,7 @@ static void mtk_pending_work(struct work +@@ -3516,7 +3513,7 @@ static void mtk_pending_work(struct work dev_dbg(eth->dev, "[%s][%d] reset done\n", __func__, __LINE__); diff --git a/target/linux/generic/backport-6.1/729-19-v6.3-net-ethernet-mtk_eth_soc-introduce-mtk_hw_warm_reset.patch b/target/linux/generic/backport-6.1/729-19-v6.3-net-ethernet-mtk_eth_soc-introduce-mtk_hw_warm_reset.patch index 09ee03706b7..652623493b6 100644 --- a/target/linux/generic/backport-6.1/729-19-v6.3-net-ethernet-mtk_eth_soc-introduce-mtk_hw_warm_reset.patch +++ b/target/linux/generic/backport-6.1/729-19-v6.3-net-ethernet-mtk_eth_soc-introduce-mtk_hw_warm_reset.patch @@ -87,7 +87,7 @@ Signed-off-by: Paolo Abeni if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) { /* Set FE to PDMAv2 if necessary */ -@@ -3522,7 +3574,7 @@ static void mtk_pending_work(struct work +@@ -3505,7 +3557,7 @@ static void mtk_pending_work(struct work if (eth->dev->pins) pinctrl_select_state(eth->dev->pins->p, eth->dev->pins->default_state); @@ -96,7 +96,7 @@ Signed-off-by: Paolo Abeni /* restart DMA and enable IRQs */ for (i = 0; i < MTK_MAC_COUNT; i++) { -@@ -4114,7 +4166,7 @@ static int mtk_probe(struct platform_dev +@@ -4107,7 +4159,7 @@ static int mtk_probe(struct platform_dev eth->msg_enable = netif_msg_init(mtk_msg_level, MTK_DEFAULT_MSG_ENABLE); INIT_WORK(ð->pending_work, mtk_pending_work); diff --git a/target/linux/generic/backport-6.1/729-20-v6.3-net-ethernet-mtk_eth_soc-align-reset-procedure-to-ve.patch b/target/linux/generic/backport-6.1/729-20-v6.3-net-ethernet-mtk_eth_soc-align-reset-procedure-to-ve.patch index 963235cd92b..17c168a6c05 100644 --- a/target/linux/generic/backport-6.1/729-20-v6.3-net-ethernet-mtk_eth_soc-align-reset-procedure-to-ve.patch +++ b/target/linux/generic/backport-6.1/729-20-v6.3-net-ethernet-mtk_eth_soc-align-reset-procedure-to-ve.patch @@ -85,7 +85,7 @@ Signed-off-by: Paolo Abeni return ret; } -@@ -3546,30 +3565,53 @@ static int mtk_do_ioctl(struct net_devic +@@ -3529,30 +3548,53 @@ static int mtk_do_ioctl(struct net_devic return -EOPNOTSUPP; } @@ -148,7 +148,7 @@ Signed-off-by: Paolo Abeni if (eth->dev->pins) pinctrl_select_state(eth->dev->pins->p, -@@ -3580,15 +3622,19 @@ static void mtk_pending_work(struct work +@@ -3563,15 +3605,19 @@ static void mtk_pending_work(struct work for (i = 0; i < MTK_MAC_COUNT; i++) { if (!test_bit(i, &restart)) continue; diff --git a/target/linux/generic/backport-6.1/729-21-v6.3-net-ethernet-mtk_eth_soc-add-dma-checks-to-mtk_hw_re.patch b/target/linux/generic/backport-6.1/729-21-v6.3-net-ethernet-mtk_eth_soc-add-dma-checks-to-mtk_hw_re.patch index 5fa2500a41e..d682bee89a6 100644 --- a/target/linux/generic/backport-6.1/729-21-v6.3-net-ethernet-mtk_eth_soc-add-dma-checks-to-mtk_hw_re.patch +++ b/target/linux/generic/backport-6.1/729-21-v6.3-net-ethernet-mtk_eth_soc-add-dma-checks-to-mtk_hw_re.patch @@ -152,7 +152,7 @@ Signed-off-by: Paolo Abeni static int mtk_hw_init(struct mtk_eth *eth, bool reset) { u32 dma_mask = ETHSYS_DMA_AG_MAP_PDMA | ETHSYS_DMA_AG_MAP_QDMA | -@@ -3672,6 +3774,7 @@ static int mtk_cleanup(struct mtk_eth *e +@@ -3655,6 +3757,7 @@ static int mtk_cleanup(struct mtk_eth *e mtk_unreg_dev(eth); mtk_free_dev(eth); cancel_work_sync(ð->pending_work); @@ -160,7 +160,7 @@ Signed-off-by: Paolo Abeni return 0; } -@@ -4099,6 +4202,7 @@ static int mtk_probe(struct platform_dev +@@ -4092,6 +4195,7 @@ static int mtk_probe(struct platform_dev eth->rx_dim.mode = DIM_CQ_PERIOD_MODE_START_FROM_EQE; INIT_WORK(ð->rx_dim.work, mtk_dim_rx); @@ -168,7 +168,7 @@ Signed-off-by: Paolo Abeni eth->tx_dim.mode = DIM_CQ_PERIOD_MODE_START_FROM_EQE; INIT_WORK(ð->tx_dim.work, mtk_dim_tx); -@@ -4301,6 +4405,8 @@ static int mtk_probe(struct platform_dev +@@ -4294,6 +4398,8 @@ static int mtk_probe(struct platform_dev netif_napi_add(ð->dummy_dev, ð->rx_napi, mtk_napi_rx); platform_set_drvdata(pdev, eth); diff --git a/target/linux/generic/backport-6.1/729-22-v6.3-net-ethernet-mtk_wed-add-reset-reset_complete-callba.patch b/target/linux/generic/backport-6.1/729-22-v6.3-net-ethernet-mtk_wed-add-reset-reset_complete-callba.patch index 2f816af7e22..b8b3a1a181c 100644 --- a/target/linux/generic/backport-6.1/729-22-v6.3-net-ethernet-mtk_wed-add-reset-reset_complete-callba.patch +++ b/target/linux/generic/backport-6.1/729-22-v6.3-net-ethernet-mtk_wed-add-reset-reset_complete-callba.patch @@ -14,7 +14,7 @@ Signed-off-by: Paolo Abeni --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c -@@ -3703,6 +3703,11 @@ static void mtk_pending_work(struct work +@@ -3686,6 +3686,11 @@ static void mtk_pending_work(struct work set_bit(MTK_RESETTING, ð->state); mtk_prepare_for_reset(eth); @@ -26,7 +26,7 @@ Signed-off-by: Paolo Abeni /* stop all devices to make sure that dma is properly shut down */ for (i = 0; i < MTK_MAC_COUNT; i++) { -@@ -3740,6 +3745,8 @@ static void mtk_pending_work(struct work +@@ -3723,6 +3728,8 @@ static void mtk_pending_work(struct work clear_bit(MTK_RESETTING, ð->state); diff --git a/target/linux/generic/backport-6.1/730-03-v6.3-net-ethernet-mtk_eth_soc-avoid-port_mg-assignment-on.patch b/target/linux/generic/backport-6.1/730-03-v6.3-net-ethernet-mtk_eth_soc-avoid-port_mg-assignment-on.patch index f5124ee6d8f..d91d7932080 100644 --- a/target/linux/generic/backport-6.1/730-03-v6.3-net-ethernet-mtk_eth_soc-avoid-port_mg-assignment-on.patch +++ b/target/linux/generic/backport-6.1/730-03-v6.3-net-ethernet-mtk_eth_soc-avoid-port_mg-assignment-on.patch @@ -12,7 +12,7 @@ Signed-off-by: Felix Fietkau --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c -@@ -4484,7 +4484,7 @@ static const struct mtk_soc_data mt7621_ +@@ -4477,7 +4477,7 @@ static const struct mtk_soc_data mt7621_ .hw_features = MTK_HW_FEATURES, .required_clks = MT7621_CLKS_BITMAP, .required_pctl = false, @@ -21,7 +21,7 @@ Signed-off-by: Felix Fietkau .hash_offset = 2, .foe_entry_size = sizeof(struct mtk_foe_entry) - 16, .txrx = { -@@ -4523,7 +4523,7 @@ static const struct mtk_soc_data mt7623_ +@@ -4516,7 +4516,7 @@ static const struct mtk_soc_data mt7623_ .hw_features = MTK_HW_FEATURES, .required_clks = MT7623_CLKS_BITMAP, .required_pctl = true, diff --git a/target/linux/generic/backport-6.1/730-04-v6.3-net-ethernet-mtk_eth_soc-implement-multi-queue-suppo.patch b/target/linux/generic/backport-6.1/730-04-v6.3-net-ethernet-mtk_eth_soc-implement-multi-queue-suppo.patch index 655faa2452e..be2d78911e4 100644 --- a/target/linux/generic/backport-6.1/730-04-v6.3-net-ethernet-mtk_eth_soc-implement-multi-queue-suppo.patch +++ b/target/linux/generic/backport-6.1/730-04-v6.3-net-ethernet-mtk_eth_soc-implement-multi-queue-suppo.patch @@ -489,7 +489,7 @@ Signed-off-by: Felix Fietkau return 0; } -@@ -3774,8 +3930,12 @@ static int mtk_unreg_dev(struct mtk_eth +@@ -3757,8 +3913,12 @@ static int mtk_unreg_dev(struct mtk_eth int i; for (i = 0; i < MTK_MAC_COUNT; i++) { @@ -502,7 +502,7 @@ Signed-off-by: Felix Fietkau unregister_netdev(eth->netdev[i]); } -@@ -3992,6 +4152,23 @@ static int mtk_set_rxnfc(struct net_devi +@@ -3975,6 +4135,23 @@ static int mtk_set_rxnfc(struct net_devi return ret; } @@ -526,7 +526,7 @@ Signed-off-by: Felix Fietkau static const struct ethtool_ops mtk_ethtool_ops = { .get_link_ksettings = mtk_get_link_ksettings, .set_link_ksettings = mtk_set_link_ksettings, -@@ -4027,6 +4204,7 @@ static const struct net_device_ops mtk_n +@@ -4009,6 +4186,7 @@ static const struct net_device_ops mtk_n .ndo_setup_tc = mtk_eth_setup_tc, .ndo_bpf = mtk_xdp, .ndo_xdp_xmit = mtk_xdp_xmit, @@ -534,7 +534,7 @@ Signed-off-by: Felix Fietkau }; static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np) -@@ -4036,6 +4214,7 @@ static int mtk_add_mac(struct mtk_eth *e +@@ -4018,6 +4196,7 @@ static int mtk_add_mac(struct mtk_eth *e struct phylink *phylink; struct mtk_mac *mac; int id, err; @@ -542,7 +542,7 @@ Signed-off-by: Felix Fietkau if (!_id) { dev_err(eth->dev, "missing mac id\n"); -@@ -4053,7 +4232,10 @@ static int mtk_add_mac(struct mtk_eth *e +@@ -4035,7 +4214,10 @@ static int mtk_add_mac(struct mtk_eth *e return -EINVAL; } @@ -554,7 +554,7 @@ Signed-off-by: Felix Fietkau if (!eth->netdev[id]) { dev_err(eth->dev, "alloc_etherdev failed\n"); return -ENOMEM; -@@ -4150,6 +4332,11 @@ static int mtk_add_mac(struct mtk_eth *e +@@ -4143,6 +4325,11 @@ static int mtk_add_mac(struct mtk_eth *e else eth->netdev[id]->max_mtu = MTK_MAX_RX_LENGTH_2K - MTK_RX_ETH_HLEN; diff --git a/target/linux/generic/backport-6.1/730-09-v6.3-net-ethernet-mtk_eth_soc-fix-VLAN-rx-hardware-accele.patch b/target/linux/generic/backport-6.1/730-09-v6.3-net-ethernet-mtk_eth_soc-fix-VLAN-rx-hardware-accele.patch index 8c368868e48..3a2780aff63 100644 --- a/target/linux/generic/backport-6.1/730-09-v6.3-net-ethernet-mtk_eth_soc-fix-VLAN-rx-hardware-accele.patch +++ b/target/linux/generic/backport-6.1/730-09-v6.3-net-ethernet-mtk_eth_soc-fix-VLAN-rx-hardware-accele.patch @@ -146,7 +146,7 @@ Signed-off-by: Felix Fietkau /* Enable RX VLan Offloading */ mtk_w32(eth, 1, MTK_CDMP_EG_CTRL); -@@ -3922,6 +3982,12 @@ static int mtk_free_dev(struct mtk_eth * +@@ -3905,6 +3965,12 @@ static int mtk_free_dev(struct mtk_eth * free_netdev(eth->netdev[i]); } diff --git a/target/linux/generic/backport-6.1/733-v6.3-18-net-ethernet-mtk_eth_soc-add-support-for-MT7981.patch b/target/linux/generic/backport-6.1/733-v6.3-18-net-ethernet-mtk_eth_soc-add-support-for-MT7981.patch index 1e3f2fb2947..dae1c6de452 100644 --- a/target/linux/generic/backport-6.1/733-v6.3-18-net-ethernet-mtk_eth_soc-add-support-for-MT7981.patch +++ b/target/linux/generic/backport-6.1/733-v6.3-18-net-ethernet-mtk_eth_soc-add-support-for-MT7981.patch @@ -51,7 +51,7 @@ Signed-off-by: Jakub Kicinski mtk_eth_path_name(path), __func__, updated); --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c -@@ -4808,6 +4808,26 @@ static const struct mtk_soc_data mt7629_ +@@ -4801,6 +4801,26 @@ static const struct mtk_soc_data mt7629_ }, }; @@ -78,7 +78,7 @@ Signed-off-by: Jakub Kicinski static const struct mtk_soc_data mt7986_data = { .reg_map = &mt7986_reg_map, .ana_rgc3 = 0x128, -@@ -4849,6 +4869,7 @@ const struct of_device_id of_mtk_match[] +@@ -4842,6 +4862,7 @@ const struct of_device_id of_mtk_match[] { .compatible = "mediatek,mt7622-eth", .data = &mt7622_data}, { .compatible = "mediatek,mt7623-eth", .data = &mt7623_data}, { .compatible = "mediatek,mt7629-eth", .data = &mt7629_data}, diff --git a/target/linux/generic/backport-6.1/733-v6.3-20-net-ethernet-mtk_eth_soc-switch-to-external-PCS-driv.patch b/target/linux/generic/backport-6.1/733-v6.3-20-net-ethernet-mtk_eth_soc-switch-to-external-PCS-driv.patch index 7a04753ceb3..95647835fa8 100644 --- a/target/linux/generic/backport-6.1/733-v6.3-20-net-ethernet-mtk_eth_soc-switch-to-external-PCS-driv.patch +++ b/target/linux/generic/backport-6.1/733-v6.3-20-net-ethernet-mtk_eth_soc-switch-to-external-PCS-driv.patch @@ -60,7 +60,7 @@ Signed-off-by: Jakub Kicinski } return NULL; -@@ -4031,8 +4032,17 @@ static int mtk_unreg_dev(struct mtk_eth +@@ -4014,8 +4015,17 @@ static int mtk_unreg_dev(struct mtk_eth return 0; } @@ -78,7 +78,7 @@ Signed-off-by: Jakub Kicinski mtk_unreg_dev(eth); mtk_free_dev(eth); cancel_work_sync(ð->pending_work); -@@ -4462,6 +4472,36 @@ void mtk_eth_set_dma_device(struct mtk_e +@@ -4455,6 +4465,36 @@ void mtk_eth_set_dma_device(struct mtk_e rtnl_unlock(); } @@ -115,7 +115,7 @@ Signed-off-by: Jakub Kicinski static int mtk_probe(struct platform_device *pdev) { struct resource *res = NULL; -@@ -4525,13 +4565,7 @@ static int mtk_probe(struct platform_dev +@@ -4518,13 +4558,7 @@ static int mtk_probe(struct platform_dev } if (MTK_HAS_CAPS(eth->soc->caps, MTK_SGMII)) { @@ -130,7 +130,7 @@ Signed-off-by: Jakub Kicinski if (err) return err; -@@ -4542,14 +4576,17 @@ static int mtk_probe(struct platform_dev +@@ -4535,14 +4569,17 @@ static int mtk_probe(struct platform_dev "mediatek,pctl"); if (IS_ERR(eth->pctl)) { dev_err(&pdev->dev, "no pctl regmap found\n"); @@ -151,7 +151,7 @@ Signed-off-by: Jakub Kicinski } if (eth->soc->offload_version) { -@@ -4708,6 +4745,8 @@ err_deinit_hw: +@@ -4701,6 +4738,8 @@ err_deinit_hw: mtk_hw_deinit(eth); err_wed_exit: mtk_wed_exit(); diff --git a/target/linux/generic/hack-5.15/204-module_strip.patch b/target/linux/generic/hack-5.15/204-module_strip.patch index dd5d93e2267..31bfe07c78c 100644 --- a/target/linux/generic/hack-5.15/204-module_strip.patch +++ b/target/linux/generic/hack-5.15/204-module_strip.patch @@ -143,7 +143,7 @@ Signed-off-by: Felix Fietkau --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c -@@ -2036,7 +2036,9 @@ static void read_symbols(const char *mod +@@ -2000,7 +2000,9 @@ static void read_symbols(const char *mod symname = remove_dot(info.strtab + sym->st_name); handle_symbol(mod, &info, sym, symname); @@ -153,7 +153,7 @@ Signed-off-by: Felix Fietkau } for (sym = info.symtab_start; sym < info.symtab_stop; sym++) { -@@ -2215,8 +2217,10 @@ static void add_header(struct buffer *b, +@@ -2179,8 +2181,10 @@ static void add_header(struct buffer *b, buf_printf(b, "BUILD_SALT;\n"); buf_printf(b, "BUILD_LTO_INFO;\n"); buf_printf(b, "\n"); @@ -164,7 +164,7 @@ Signed-off-by: Felix Fietkau buf_printf(b, "\n"); buf_printf(b, "__visible struct module __this_module\n"); buf_printf(b, "__section(\".gnu.linkonce.this_module\") = {\n"); -@@ -2233,8 +2237,10 @@ static void add_header(struct buffer *b, +@@ -2197,8 +2201,10 @@ static void add_header(struct buffer *b, static void add_intree_flag(struct buffer *b, int is_intree) { @@ -175,7 +175,7 @@ Signed-off-by: Felix Fietkau } /* Cannot check for assembler */ -@@ -2247,8 +2253,10 @@ static void add_retpoline(struct buffer +@@ -2211,8 +2217,10 @@ static void add_retpoline(struct buffer static void add_staging_flag(struct buffer *b, const char *name) { @@ -186,7 +186,7 @@ Signed-off-by: Felix Fietkau } /** -@@ -2328,11 +2336,13 @@ static void add_depends(struct buffer *b +@@ -2292,11 +2300,13 @@ static void add_depends(struct buffer *b static void add_srcversion(struct buffer *b, struct module *mod) { @@ -200,7 +200,7 @@ Signed-off-by: Felix Fietkau } static void write_buf(struct buffer *b, const char *fname) -@@ -2581,7 +2591,9 @@ int main(int argc, char **argv) +@@ -2545,7 +2555,9 @@ int main(int argc, char **argv) add_staging_flag(&buf, mod->name); add_versions(&buf, mod); add_depends(&buf, mod); diff --git a/target/linux/generic/hack-5.15/259-regmap_dynamic.patch b/target/linux/generic/hack-5.15/259-regmap_dynamic.patch index e0820ccfc0d..76a5ace6f31 100644 --- a/target/linux/generic/hack-5.15/259-regmap_dynamic.patch +++ b/target/linux/generic/hack-5.15/259-regmap_dynamic.patch @@ -125,7 +125,7 @@ Signed-off-by: Felix Fietkau #include #include #include -@@ -3360,3 +3361,5 @@ static int __init regmap_initcall(void) +@@ -3358,3 +3359,5 @@ static int __init regmap_initcall(void) return 0; } postcore_initcall(regmap_initcall); diff --git a/target/linux/generic/hack-5.15/780-usb-net-MeigLink_modem_support.patch b/target/linux/generic/hack-5.15/780-usb-net-MeigLink_modem_support.patch index 96d800669a8..a44a5b6d89c 100644 --- a/target/linux/generic/hack-5.15/780-usb-net-MeigLink_modem_support.patch +++ b/target/linux/generic/hack-5.15/780-usb-net-MeigLink_modem_support.patch @@ -29,7 +29,7 @@ Subject: [PATCH] net/usb/qmi_wwan: add MeigLink modem support #define QUECTEL_VENDOR_ID 0x2c7c /* These Quectel products use Quectel's vendor ID */ -@@ -1173,6 +1175,11 @@ static const struct usb_device_id option +@@ -1177,6 +1179,11 @@ static const struct usb_device_id option .driver_info = ZLP }, { USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_BG96), .driver_info = RSVD(4) }, diff --git a/target/linux/generic/hack-5.15/902-debloat_proc.patch b/target/linux/generic/hack-5.15/902-debloat_proc.patch index 12e99280289..b1c1c8171c1 100644 --- a/target/linux/generic/hack-5.15/902-debloat_proc.patch +++ b/target/linux/generic/hack-5.15/902-debloat_proc.patch @@ -330,7 +330,7 @@ Signed-off-by: Felix Fietkau --- a/net/core/sock.c +++ b/net/core/sock.c -@@ -3866,6 +3866,8 @@ static __net_initdata struct pernet_oper +@@ -3877,6 +3877,8 @@ static __net_initdata struct pernet_oper static int __init proto_init(void) { diff --git a/target/linux/generic/hack-6.1/259-regmap_dynamic.patch b/target/linux/generic/hack-6.1/259-regmap_dynamic.patch index 8d25f59ce28..407bc72ac8d 100644 --- a/target/linux/generic/hack-6.1/259-regmap_dynamic.patch +++ b/target/linux/generic/hack-6.1/259-regmap_dynamic.patch @@ -125,7 +125,7 @@ Signed-off-by: Felix Fietkau #include #include #include -@@ -3513,3 +3514,5 @@ static int __init regmap_initcall(void) +@@ -3511,3 +3512,5 @@ static int __init regmap_initcall(void) return 0; } postcore_initcall(regmap_initcall); diff --git a/target/linux/generic/hack-6.1/711-net-dsa-mv88e6xxx-disable-ATU-violation.patch b/target/linux/generic/hack-6.1/711-net-dsa-mv88e6xxx-disable-ATU-violation.patch index 25a3f83b242..59235ea00a2 100644 --- a/target/linux/generic/hack-6.1/711-net-dsa-mv88e6xxx-disable-ATU-violation.patch +++ b/target/linux/generic/hack-6.1/711-net-dsa-mv88e6xxx-disable-ATU-violation.patch @@ -9,7 +9,7 @@ Subject: [PATCH] net/dsa/mv88e6xxx: disable ATU violation --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c -@@ -3465,6 +3465,9 @@ static int mv88e6xxx_setup_port(struct m +@@ -3472,6 +3472,9 @@ static int mv88e6xxx_setup_port(struct m else reg = 1 << port; diff --git a/target/linux/generic/pending-5.15/143-jffs2-reduce-stack-usage-in-jffs2_build_xattr_subsys.patch b/target/linux/generic/pending-5.15/143-jffs2-reduce-stack-usage-in-jffs2_build_xattr_subsys.patch deleted file mode 100644 index e5a86dd29fe..00000000000 --- a/target/linux/generic/pending-5.15/143-jffs2-reduce-stack-usage-in-jffs2_build_xattr_subsys.patch +++ /dev/null @@ -1,121 +0,0 @@ -From eee53f6eb7561f516b9c4bac829ce31c48096130 Mon Sep 17 00:00:00 2001 -From: Fabian Frederick -Date: Tue, 9 May 2017 22:30:03 +0200 -Subject: [PATCH] jffs2: reduce stack usage in jffs2_build_xattr_subsystem() - -Use kcalloc() for allocation/flush of 128 pointers table to -reduce stack usage. - -Function now returns -ENOMEM or 0 on success. - -stackusage -Before: -./fs/jffs2/xattr.c:775 jffs2_build_xattr_subsystem 1208 -dynamic,bounded - -After: -./fs/jffs2/xattr.c:775 jffs2_build_xattr_subsystem 192 -dynamic,bounded - -Also update definition when CONFIG_JFFS2_FS_XATTR is not enabled - -Tested with an MTD mount point and some user set/getfattr. - -Many current target on OpenWRT also suffer from a compilation warning -(that become an error with CONFIG_WERROR) with the following output: - -fs/jffs2/xattr.c: In function 'jffs2_build_xattr_subsystem': -fs/jffs2/xattr.c:887:1: error: the frame size of 1088 bytes is larger than 1024 bytes [-Werror=frame-larger-than=] - 887 | } - | ^ - -Using dynamic allocation fix this compilation warning. - -Fixes: c9f700f840bd ("[JFFS2][XATTR] using 'delete marker' for xdatum/xref deletion") -Reported-by: Tim Gardner -Reported-by: kernel test robot -Reported-by: Ron Economos -Reported-by: Nathan Chancellor -Reviewed-by: Nick Desaulniers -Signed-off-by: Fabian Frederick -Signed-off-by: Christian Marangi -Cc: stable@vger.kernel.org ---- - fs/jffs2/build.c | 5 ++++- - fs/jffs2/xattr.c | 13 +++++++++---- - fs/jffs2/xattr.h | 4 ++-- - 3 files changed, 15 insertions(+), 7 deletions(-) - ---- a/fs/jffs2/build.c -+++ b/fs/jffs2/build.c -@@ -211,7 +211,10 @@ static int jffs2_build_filesystem(struct - ic->scan_dents = NULL; - cond_resched(); - } -- jffs2_build_xattr_subsystem(c); -+ ret = jffs2_build_xattr_subsystem(c); -+ if (ret) -+ goto exit; -+ - c->flags &= ~JFFS2_SB_FLAG_BUILDING; - - dbg_fsbuild("FS build complete\n"); ---- a/fs/jffs2/xattr.c -+++ b/fs/jffs2/xattr.c -@@ -772,10 +772,10 @@ void jffs2_clear_xattr_subsystem(struct - } - - #define XREF_TMPHASH_SIZE (128) --void jffs2_build_xattr_subsystem(struct jffs2_sb_info *c) -+int jffs2_build_xattr_subsystem(struct jffs2_sb_info *c) - { - struct jffs2_xattr_ref *ref, *_ref; -- struct jffs2_xattr_ref *xref_tmphash[XREF_TMPHASH_SIZE]; -+ struct jffs2_xattr_ref **xref_tmphash; - struct jffs2_xattr_datum *xd, *_xd; - struct jffs2_inode_cache *ic; - struct jffs2_raw_node_ref *raw; -@@ -784,9 +784,12 @@ void jffs2_build_xattr_subsystem(struct - - BUG_ON(!(c->flags & JFFS2_SB_FLAG_BUILDING)); - -+ xref_tmphash = kcalloc(XREF_TMPHASH_SIZE, -+ sizeof(struct jffs2_xattr_ref *), GFP_KERNEL); -+ if (!xref_tmphash) -+ return -ENOMEM; -+ - /* Phase.1 : Merge same xref */ -- for (i=0; i < XREF_TMPHASH_SIZE; i++) -- xref_tmphash[i] = NULL; - for (ref=c->xref_temp; ref; ref=_ref) { - struct jffs2_xattr_ref *tmp; - -@@ -884,6 +887,8 @@ void jffs2_build_xattr_subsystem(struct - "%u of xref (%u dead, %u orphan) found.\n", - xdatum_count, xdatum_unchecked_count, xdatum_orphan_count, - xref_count, xref_dead_count, xref_orphan_count); -+ kfree(xref_tmphash); -+ return 0; - } - - struct jffs2_xattr_datum *jffs2_setup_xattr_datum(struct jffs2_sb_info *c, ---- a/fs/jffs2/xattr.h -+++ b/fs/jffs2/xattr.h -@@ -71,7 +71,7 @@ static inline int is_xattr_ref_dead(stru - #ifdef CONFIG_JFFS2_FS_XATTR - - extern void jffs2_init_xattr_subsystem(struct jffs2_sb_info *c); --extern void jffs2_build_xattr_subsystem(struct jffs2_sb_info *c); -+extern int jffs2_build_xattr_subsystem(struct jffs2_sb_info *c); - extern void jffs2_clear_xattr_subsystem(struct jffs2_sb_info *c); - - extern struct jffs2_xattr_datum *jffs2_setup_xattr_datum(struct jffs2_sb_info *c, -@@ -103,7 +103,7 @@ extern ssize_t jffs2_listxattr(struct de - #else - - #define jffs2_init_xattr_subsystem(c) --#define jffs2_build_xattr_subsystem(c) -+#define jffs2_build_xattr_subsystem(c) (0) - #define jffs2_clear_xattr_subsystem(c) - - #define jffs2_xattr_do_crccheck_inode(c, ic) diff --git a/target/linux/generic/pending-5.15/160-workqueue-fix-enum-type-for-gcc-13.patch b/target/linux/generic/pending-5.15/160-workqueue-fix-enum-type-for-gcc-13.patch deleted file mode 100644 index 82076121ac3..00000000000 --- a/target/linux/generic/pending-5.15/160-workqueue-fix-enum-type-for-gcc-13.patch +++ /dev/null @@ -1,44 +0,0 @@ -From 525ff9c2965770762b81d679820552a208070d59 Mon Sep 17 00:00:00 2001 -From: Arnd Bergmann -Date: Tue, 17 Jan 2023 17:40:35 +0100 -Subject: workqueue: fix enum type for gcc-13 - -In gcc-13, the WORK_STRUCT_WQ_DATA_MASK constant is a signed 64-bit -type on 32-bit architectures because the enum definition has both -negative numbers and numbers above LONG_MAX in it: - -kernel/workqueue.c: In function 'get_work_pwq': -kernel/workqueue.c:709:24: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast] - 709 | return (void *)(data & WORK_STRUCT_WQ_DATA_MASK); - | ^ -kernel/workqueue.c: In function 'get_work_pool': -kernel/workqueue.c:737:25: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast] - 737 | return ((struct pool_workqueue *) - | ^ -kernel/workqueue.c: In function 'get_work_pool_id': -kernel/workqueue.c:759:25: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast] - 759 | return ((struct pool_workqueue *) - | ^ - -Change the enum definition to ensure all values can fit into -the range of 'unsigned long' on all architectures. - -Signed-off-by: Arnd Bergmann -Tested-by: Thierry Reding -Tested-by: Lai Jiangshan -Signed-off-by: Tejun Heo ---- - include/linux/workqueue.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - ---- a/include/linux/workqueue.h -+++ b/include/linux/workqueue.h -@@ -83,7 +83,7 @@ enum { - - /* convenience constants */ - WORK_STRUCT_FLAG_MASK = (1UL << WORK_STRUCT_FLAG_BITS) - 1, -- WORK_STRUCT_WQ_DATA_MASK = ~WORK_STRUCT_FLAG_MASK, -+ WORK_STRUCT_WQ_DATA_MASK = (unsigned long)~WORK_STRUCT_FLAG_MASK, - WORK_STRUCT_NO_POOL = (unsigned long)WORK_OFFQ_POOL_NONE << WORK_OFFQ_POOL_SHIFT, - - /* bit mask for work_busy() return values */ diff --git a/target/linux/generic/pending-5.15/682-of_net-add-mac-address-increment-support.patch b/target/linux/generic/pending-5.15/682-of_net-add-mac-address-increment-support.patch index fe6faddc7d7..f6ae9f31f1f 100644 --- a/target/linux/generic/pending-5.15/682-of_net-add-mac-address-increment-support.patch +++ b/target/linux/generic/pending-5.15/682-of_net-add-mac-address-increment-support.patch @@ -20,7 +20,7 @@ Signed-off-by: Ansuel Smith --- a/net/core/of_net.c +++ b/net/core/of_net.c -@@ -119,27 +119,62 @@ static int of_get_mac_addr_nvmem(struct +@@ -119,28 +119,63 @@ static int of_get_mac_addr_nvmem(struct * this case, the real MAC is in 'local-mac-address', and 'mac-address' exists * but is all zeros. * @@ -87,3 +87,4 @@ Signed-off-by: Ansuel Smith + return ret; } EXPORT_SYMBOL(of_get_mac_address); + diff --git a/target/linux/generic/pending-5.15/702-net-ethernet-mtk_eth_soc-enable-threaded-NAPI.patch b/target/linux/generic/pending-5.15/702-net-ethernet-mtk_eth_soc-enable-threaded-NAPI.patch index a4e3d265033..2bc78fa05e5 100644 --- a/target/linux/generic/pending-5.15/702-net-ethernet-mtk_eth_soc-enable-threaded-NAPI.patch +++ b/target/linux/generic/pending-5.15/702-net-ethernet-mtk_eth_soc-enable-threaded-NAPI.patch @@ -30,7 +30,7 @@ Signed-off-by: Felix Fietkau } return IRQ_HANDLED; -@@ -4673,6 +4673,8 @@ static int mtk_probe(struct platform_dev +@@ -4666,6 +4666,8 @@ static int mtk_probe(struct platform_dev * for NAPI to work */ init_dummy_netdev(ð->dummy_dev); diff --git a/target/linux/generic/pending-5.15/710-bridge-add-knob-for-filtering-rx-tx-BPDU-pack.patch b/target/linux/generic/pending-5.15/710-bridge-add-knob-for-filtering-rx-tx-BPDU-pack.patch index 7e8ed5455d9..8e335967eae 100644 --- a/target/linux/generic/pending-5.15/710-bridge-add-knob-for-filtering-rx-tx-BPDU-pack.patch +++ b/target/linux/generic/pending-5.15/710-bridge-add-knob-for-filtering-rx-tx-BPDU-pack.patch @@ -161,7 +161,7 @@ Signed-off-by: Felix Fietkau struct rtnl_link { rtnl_doit_func doit; -@@ -4706,7 +4706,9 @@ int ndo_dflt_bridge_getlink(struct sk_bu +@@ -4712,7 +4712,9 @@ int ndo_dflt_bridge_getlink(struct sk_bu brport_nla_put_flag(skb, flags, mask, IFLA_BRPORT_MCAST_FLOOD, BR_MCAST_FLOOD) || brport_nla_put_flag(skb, flags, mask, diff --git a/target/linux/generic/pending-5.15/731-net-ethernet-mediatek-ppe-add-support-for-flow-accou.patch b/target/linux/generic/pending-5.15/731-net-ethernet-mediatek-ppe-add-support-for-flow-accou.patch index 60c32b67057..91ffd65c6cb 100644 --- a/target/linux/generic/pending-5.15/731-net-ethernet-mediatek-ppe-add-support-for-flow-accou.patch +++ b/target/linux/generic/pending-5.15/731-net-ethernet-mediatek-ppe-add-support-for-flow-accou.patch @@ -53,7 +53,7 @@ v2: fix wrong variable name in return value check spotted by Denis Kirjanov --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c -@@ -4642,8 +4642,8 @@ static int mtk_probe(struct platform_dev +@@ -4635,8 +4635,8 @@ static int mtk_probe(struct platform_dev for (i = 0; i < num_ppe; i++) { u32 ppe_addr = eth->soc->reg_map->ppe_base + i * 0x400; @@ -64,7 +64,7 @@ v2: fix wrong variable name in return value check spotted by Denis Kirjanov if (!eth->ppe[i]) { err = -ENOMEM; goto err_free_dev; -@@ -4770,6 +4770,7 @@ static const struct mtk_soc_data mt7622_ +@@ -4763,6 +4763,7 @@ static const struct mtk_soc_data mt7622_ .required_pctl = false, .offload_version = 2, .hash_offset = 2, @@ -72,7 +72,7 @@ v2: fix wrong variable name in return value check spotted by Denis Kirjanov .foe_entry_size = sizeof(struct mtk_foe_entry) - 16, .txrx = { .txd_size = sizeof(struct mtk_tx_dma), -@@ -4807,6 +4808,7 @@ static const struct mtk_soc_data mt7629_ +@@ -4800,6 +4801,7 @@ static const struct mtk_soc_data mt7629_ .hw_features = MTK_HW_FEATURES, .required_clks = MT7629_CLKS_BITMAP, .required_pctl = false, @@ -80,7 +80,7 @@ v2: fix wrong variable name in return value check spotted by Denis Kirjanov .txrx = { .txd_size = sizeof(struct mtk_tx_dma), .rxd_size = sizeof(struct mtk_rx_dma), -@@ -4827,6 +4829,7 @@ static const struct mtk_soc_data mt7981_ +@@ -4820,6 +4822,7 @@ static const struct mtk_soc_data mt7981_ .offload_version = 2, .hash_offset = 4, .foe_entry_size = sizeof(struct mtk_foe_entry), @@ -88,7 +88,7 @@ v2: fix wrong variable name in return value check spotted by Denis Kirjanov .txrx = { .txd_size = sizeof(struct mtk_tx_dma_v2), .rxd_size = sizeof(struct mtk_rx_dma_v2), -@@ -4847,6 +4850,7 @@ static const struct mtk_soc_data mt7986_ +@@ -4840,6 +4843,7 @@ static const struct mtk_soc_data mt7986_ .offload_version = 2, .hash_offset = 4, .foe_entry_size = sizeof(struct mtk_foe_entry), diff --git a/target/linux/generic/pending-5.15/732-00-net-ethernet-mtk_eth_soc-drop-generic-vlan-rx-offloa.patch b/target/linux/generic/pending-5.15/732-00-net-ethernet-mtk_eth_soc-drop-generic-vlan-rx-offloa.patch index 35b296a2553..f6c70e7e6af 100644 --- a/target/linux/generic/pending-5.15/732-00-net-ethernet-mtk_eth_soc-drop-generic-vlan-rx-offloa.patch +++ b/target/linux/generic/pending-5.15/732-00-net-ethernet-mtk_eth_soc-drop-generic-vlan-rx-offloa.patch @@ -180,7 +180,7 @@ Signed-off-by: Felix Fietkau /* set interrupt delays based on current Net DIM sample */ mtk_dim_rx(ð->rx_dim.work); -@@ -4365,7 +4334,7 @@ static int mtk_add_mac(struct mtk_eth *e +@@ -4358,7 +4327,7 @@ static int mtk_add_mac(struct mtk_eth *e eth->netdev[id]->hw_features |= NETIF_F_LRO; eth->netdev[id]->vlan_features = eth->soc->hw_features & diff --git a/target/linux/generic/pending-5.15/737-02-net-ethernet-mtk_eth_soc-move-MAX_DEVS-in-mtk_soc_da.patch b/target/linux/generic/pending-5.15/737-02-net-ethernet-mtk_eth_soc-move-MAX_DEVS-in-mtk_soc_da.patch index a8debc41bfb..837a8bf0ad2 100644 --- a/target/linux/generic/pending-5.15/737-02-net-ethernet-mtk_eth_soc-move-MAX_DEVS-in-mtk_soc_da.patch +++ b/target/linux/generic/pending-5.15/737-02-net-ethernet-mtk_eth_soc-move-MAX_DEVS-in-mtk_soc_da.patch @@ -15,7 +15,7 @@ Signed-off-by: Daniel Golle --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c -@@ -3989,7 +3989,10 @@ static void mtk_sgmii_destroy(struct mtk +@@ -3972,7 +3972,10 @@ static void mtk_sgmii_destroy(struct mtk { int i; @@ -27,7 +27,7 @@ Signed-off-by: Daniel Golle mtk_pcs_lynxi_destroy(eth->sgmii_pcs[i]); } -@@ -4432,7 +4435,12 @@ static int mtk_sgmii_init(struct mtk_eth +@@ -4425,7 +4428,12 @@ static int mtk_sgmii_init(struct mtk_eth u32 flags; int i; @@ -41,7 +41,7 @@ Signed-off-by: Daniel Golle np = of_parse_phandle(eth->dev->of_node, "mediatek,sgmiisys", i); if (!np) break; -@@ -4477,6 +4485,18 @@ static int mtk_probe(struct platform_dev +@@ -4470,6 +4478,18 @@ static int mtk_probe(struct platform_dev if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628)) eth->ip_align = NET_IP_ALIGN; @@ -60,7 +60,7 @@ Signed-off-by: Daniel Golle spin_lock_init(ð->page_lock); spin_lock_init(ð->tx_irq_lock); spin_lock_init(ð->rx_irq_lock); -@@ -4662,7 +4682,7 @@ static int mtk_probe(struct platform_dev +@@ -4655,7 +4675,7 @@ static int mtk_probe(struct platform_dev goto err_free_dev; } @@ -69,7 +69,7 @@ Signed-off-by: Daniel Golle if (!eth->netdev[i]) continue; -@@ -4739,6 +4759,7 @@ static const struct mtk_soc_data mt2701_ +@@ -4732,6 +4752,7 @@ static const struct mtk_soc_data mt2701_ .hw_features = MTK_HW_FEATURES, .required_clks = MT7623_CLKS_BITMAP, .required_pctl = true, @@ -77,7 +77,7 @@ Signed-off-by: Daniel Golle .txrx = { .txd_size = sizeof(struct mtk_tx_dma), .rxd_size = sizeof(struct mtk_rx_dma), -@@ -4757,6 +4778,7 @@ static const struct mtk_soc_data mt7621_ +@@ -4750,6 +4771,7 @@ static const struct mtk_soc_data mt7621_ .required_pctl = false, .offload_version = 1, .hash_offset = 2, @@ -85,7 +85,7 @@ Signed-off-by: Daniel Golle .foe_entry_size = sizeof(struct mtk_foe_entry) - 16, .txrx = { .txd_size = sizeof(struct mtk_tx_dma), -@@ -4778,6 +4800,7 @@ static const struct mtk_soc_data mt7622_ +@@ -4771,6 +4793,7 @@ static const struct mtk_soc_data mt7622_ .offload_version = 2, .hash_offset = 2, .has_accounting = true, @@ -93,7 +93,7 @@ Signed-off-by: Daniel Golle .foe_entry_size = sizeof(struct mtk_foe_entry) - 16, .txrx = { .txd_size = sizeof(struct mtk_tx_dma), -@@ -4797,6 +4820,7 @@ static const struct mtk_soc_data mt7623_ +@@ -4790,6 +4813,7 @@ static const struct mtk_soc_data mt7623_ .required_pctl = true, .offload_version = 1, .hash_offset = 2, @@ -101,7 +101,7 @@ Signed-off-by: Daniel Golle .foe_entry_size = sizeof(struct mtk_foe_entry) - 16, .txrx = { .txd_size = sizeof(struct mtk_tx_dma), -@@ -4816,6 +4840,7 @@ static const struct mtk_soc_data mt7629_ +@@ -4809,6 +4833,7 @@ static const struct mtk_soc_data mt7629_ .required_clks = MT7629_CLKS_BITMAP, .required_pctl = false, .has_accounting = true, @@ -109,7 +109,7 @@ Signed-off-by: Daniel Golle .txrx = { .txd_size = sizeof(struct mtk_tx_dma), .rxd_size = sizeof(struct mtk_rx_dma), -@@ -4837,6 +4862,7 @@ static const struct mtk_soc_data mt7981_ +@@ -4830,6 +4855,7 @@ static const struct mtk_soc_data mt7981_ .hash_offset = 4, .foe_entry_size = sizeof(struct mtk_foe_entry), .has_accounting = true, @@ -117,7 +117,7 @@ Signed-off-by: Daniel Golle .txrx = { .txd_size = sizeof(struct mtk_tx_dma_v2), .rxd_size = sizeof(struct mtk_rx_dma_v2), -@@ -4856,6 +4882,7 @@ static const struct mtk_soc_data mt7986_ +@@ -4849,6 +4875,7 @@ static const struct mtk_soc_data mt7986_ .required_pctl = false, .offload_version = 2, .hash_offset = 4, @@ -125,7 +125,7 @@ Signed-off-by: Daniel Golle .foe_entry_size = sizeof(struct mtk_foe_entry), .has_accounting = true, .txrx = { -@@ -4874,6 +4901,7 @@ static const struct mtk_soc_data rt5350_ +@@ -4867,6 +4894,7 @@ static const struct mtk_soc_data rt5350_ .hw_features = MTK_HW_FEATURES_MT7628, .required_clks = MT7628_CLKS_BITMAP, .required_pctl = false, diff --git a/target/linux/generic/pending-5.15/737-03-net-ethernet-mtk_eth_soc-rely-on-num_devs-and-remove.patch b/target/linux/generic/pending-5.15/737-03-net-ethernet-mtk_eth_soc-rely-on-num_devs-and-remove.patch index d6b36bf6368..b11915ec104 100644 --- a/target/linux/generic/pending-5.15/737-03-net-ethernet-mtk_eth_soc-rely-on-num_devs-and-remove.patch +++ b/target/linux/generic/pending-5.15/737-03-net-ethernet-mtk_eth_soc-rely-on-num_devs-and-remove.patch @@ -78,7 +78,7 @@ Signed-off-by: Daniel Golle struct net_device *dev = eth->netdev[i]; mtk_w32(eth, MAC_MCR_FORCE_LINK_DOWN, MTK_MAC_MCR(i)); -@@ -3909,7 +3909,7 @@ static void mtk_pending_work(struct work +@@ -3892,7 +3892,7 @@ static void mtk_pending_work(struct work mtk_prepare_for_reset(eth); /* stop all devices to make sure that dma is properly shut down */ @@ -87,7 +87,7 @@ Signed-off-by: Daniel Golle if (!eth->netdev[i] || !netif_running(eth->netdev[i])) continue; -@@ -3925,7 +3925,7 @@ static void mtk_pending_work(struct work +@@ -3908,7 +3908,7 @@ static void mtk_pending_work(struct work mtk_hw_init(eth, true); /* restart DMA and enable IRQs */ @@ -96,7 +96,7 @@ Signed-off-by: Daniel Golle if (!test_bit(i, &restart)) continue; -@@ -3953,7 +3953,7 @@ static int mtk_free_dev(struct mtk_eth * +@@ -3936,7 +3936,7 @@ static int mtk_free_dev(struct mtk_eth * { int i; @@ -105,7 +105,7 @@ Signed-off-by: Daniel Golle if (!eth->netdev[i]) continue; free_netdev(eth->netdev[i]); -@@ -3972,7 +3972,7 @@ static int mtk_unreg_dev(struct mtk_eth +@@ -3955,7 +3955,7 @@ static int mtk_unreg_dev(struct mtk_eth { int i; @@ -114,7 +114,7 @@ Signed-off-by: Daniel Golle struct mtk_mac *mac; if (!eth->netdev[i]) continue; -@@ -4277,7 +4277,7 @@ static int mtk_add_mac(struct mtk_eth *e +@@ -4259,7 +4259,7 @@ static int mtk_add_mac(struct mtk_eth *e } id = be32_to_cpup(_id); @@ -123,7 +123,7 @@ Signed-off-by: Daniel Golle dev_err(eth->dev, "%d is not a valid mac id\n", id); return -EINVAL; } -@@ -4407,7 +4407,7 @@ void mtk_eth_set_dma_device(struct mtk_e +@@ -4400,7 +4400,7 @@ void mtk_eth_set_dma_device(struct mtk_e rtnl_lock(); @@ -132,7 +132,7 @@ Signed-off-by: Daniel Golle dev = eth->netdev[i]; if (!dev || !(dev->flags & IFF_UP)) -@@ -4734,7 +4734,7 @@ static int mtk_remove(struct platform_de +@@ -4727,7 +4727,7 @@ static int mtk_remove(struct platform_de int i; /* stop all devices to make sure that dma is properly shut down */ diff --git a/target/linux/generic/pending-5.15/737-04-net-ethernet-mtk_eth_soc-add-MTK_NETSYS_V3-capabilit.patch b/target/linux/generic/pending-5.15/737-04-net-ethernet-mtk_eth_soc-add-MTK_NETSYS_V3-capabilit.patch index 80d729db17f..54b3fd024a4 100644 --- a/target/linux/generic/pending-5.15/737-04-net-ethernet-mtk_eth_soc-add-MTK_NETSYS_V3-capabilit.patch +++ b/target/linux/generic/pending-5.15/737-04-net-ethernet-mtk_eth_soc-add-MTK_NETSYS_V3-capabilit.patch @@ -182,7 +182,7 @@ Signed-off-by: Daniel Golle /* PSE should not drop port8 and port9 packets from WDMA Tx */ mtk_w32(eth, 0x00000300, PSE_DROP_CFG); -@@ -4314,7 +4379,11 @@ static int mtk_add_mac(struct mtk_eth *e +@@ -4307,7 +4372,11 @@ static int mtk_add_mac(struct mtk_eth *e } spin_lock_init(&mac->hw_stats->stats_lock); u64_stats_init(&mac->hw_stats->syncp); diff --git a/target/linux/generic/pending-5.15/737-06-net-ethernet-mtk_eth_soc-add-support-for-MT7988-SoC.patch b/target/linux/generic/pending-5.15/737-06-net-ethernet-mtk_eth_soc-add-support-for-MT7988-SoC.patch index 504d2ea2266..e8402c0974c 100644 --- a/target/linux/generic/pending-5.15/737-06-net-ethernet-mtk_eth_soc-add-support-for-MT7988-SoC.patch +++ b/target/linux/generic/pending-5.15/737-06-net-ethernet-mtk_eth_soc-add-support-for-MT7988-SoC.patch @@ -150,7 +150,7 @@ mtk_eth_soc driver. data |= TX_DMA_SWC_V2 | QID_BITS_V2(info->qid); WRITE_ONCE(desc->txd4, data); -@@ -4964,6 +5065,25 @@ static const struct mtk_soc_data mt7986_ +@@ -4957,6 +5058,25 @@ static const struct mtk_soc_data mt7986_ }, }; @@ -176,7 +176,7 @@ mtk_eth_soc driver. static const struct mtk_soc_data rt5350_data = { .reg_map = &mt7628_reg_map, .caps = MT7628_CAPS, -@@ -4982,14 +5102,15 @@ static const struct mtk_soc_data rt5350_ +@@ -4975,14 +5095,15 @@ static const struct mtk_soc_data rt5350_ }; const struct of_device_id of_mtk_match[] = { diff --git a/target/linux/generic/pending-5.15/737-07-net-ethernet-mtk_eth_soc-add-paths-and-SerDes-modes-.patch b/target/linux/generic/pending-5.15/737-07-net-ethernet-mtk_eth_soc-add-paths-and-SerDes-modes-.patch index 0185bed0897..4518bcb510a 100644 --- a/target/linux/generic/pending-5.15/737-07-net-ethernet-mtk_eth_soc-add-paths-and-SerDes-modes-.patch +++ b/target/linux/generic/pending-5.15/737-07-net-ethernet-mtk_eth_soc-add-paths-and-SerDes-modes-.patch @@ -607,7 +607,7 @@ Signed-off-by: Daniel Golle mtk_w32(eth, val, MTK_PPSC); dev_dbg(eth->dev, "MDC is running on %d Hz\n", MDC_MAX_FREQ / divider); -@@ -4433,8 +4636,8 @@ static int mtk_add_mac(struct mtk_eth *e +@@ -4415,8 +4618,8 @@ static int mtk_add_mac(struct mtk_eth *e const __be32 *_id = of_get_property(np, "reg", NULL); phy_interface_t phy_mode; struct phylink *phylink; @@ -617,7 +617,7 @@ Signed-off-by: Daniel Golle int txqs = 1; if (!_id) { -@@ -4525,6 +4728,32 @@ static int mtk_add_mac(struct mtk_eth *e +@@ -4518,6 +4721,32 @@ static int mtk_add_mac(struct mtk_eth *e mac->phylink_config.supported_interfaces); } @@ -650,7 +650,7 @@ Signed-off-by: Daniel Golle phylink = phylink_create(&mac->phylink_config, of_fwnode_handle(mac->of_node), phy_mode, &mtk_phylink_ops); -@@ -4712,6 +4941,13 @@ static int mtk_probe(struct platform_dev +@@ -4705,6 +4934,13 @@ static int mtk_probe(struct platform_dev if (err) return err; diff --git a/target/linux/generic/pending-5.15/750-skb-Do-mix-page-pool-and-page-referenced-frags-in-GR.patch b/target/linux/generic/pending-5.15/750-skb-Do-mix-page-pool-and-page-referenced-frags-in-GR.patch index 6f28e19a483..f2bfd14b18d 100644 --- a/target/linux/generic/pending-5.15/750-skb-Do-mix-page-pool-and-page-referenced-frags-in-GR.patch +++ b/target/linux/generic/pending-5.15/750-skb-Do-mix-page-pool-and-page-referenced-frags-in-GR.patch @@ -17,7 +17,7 @@ Signed-off-by: Alexander Duyck --- a/net/core/skbuff.c +++ b/net/core/skbuff.c -@@ -4347,6 +4347,15 @@ int skb_gro_receive(struct sk_buff *p, s +@@ -4352,6 +4352,15 @@ int skb_gro_receive(struct sk_buff *p, s if (unlikely(p->len + len >= 65536 || NAPI_GRO_CB(skb)->flush)) return -E2BIG; diff --git a/target/linux/generic/pending-6.1/203-kallsyms_uncompressed.patch b/target/linux/generic/pending-6.1/203-kallsyms_uncompressed.patch index 7b7aea06016..e066ad3cf30 100644 --- a/target/linux/generic/pending-6.1/203-kallsyms_uncompressed.patch +++ b/target/linux/generic/pending-6.1/203-kallsyms_uncompressed.patch @@ -57,17 +57,17 @@ Signed-off-by: Felix Fietkau * and return the first char from this token. --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c -@@ -75,6 +75,7 @@ static struct addr_range percpu_range = +@@ -77,6 +77,7 @@ static struct addr_range percpu_range = static struct sym_entry **table; static unsigned int table_size, table_cnt; static int all_symbols; +static int uncompressed; static int absolute_percpu; static int base_relative; - -@@ -535,6 +536,9 @@ static void write_src(void) - - free(markers); + static int lto_clang; +@@ -605,6 +606,9 @@ static void write_src(void) + printf("\t.long\t%u\n", table[i]->seq); + printf("\n"); + if (uncompressed) + return; @@ -75,7 +75,7 @@ Signed-off-by: Felix Fietkau output_label("kallsyms_token_table"); off = 0; for (i = 0; i < 256; i++) { -@@ -586,6 +590,9 @@ static unsigned char *find_token(unsigne +@@ -656,6 +660,9 @@ static unsigned char *find_token(unsigne { int i; @@ -85,7 +85,7 @@ Signed-off-by: Felix Fietkau for (i = 0; i < len - 1; i++) { if (str[i] == token[0] && str[i+1] == token[1]) return &str[i]; -@@ -658,6 +665,9 @@ static void optimize_result(void) +@@ -728,6 +735,9 @@ static void optimize_result(void) { int i, best; @@ -95,18 +95,18 @@ Signed-off-by: Felix Fietkau /* using the '\0' symbol last allows compress_symbols to use standard * fast string functions */ for (i = 255; i >= 0; i--) { -@@ -818,6 +828,7 @@ int main(int argc, char **argv) - {"all-symbols", no_argument, &all_symbols, 1}, +@@ -889,6 +899,7 @@ int main(int argc, char **argv) {"absolute-percpu", no_argument, &absolute_percpu, 1}, {"base-relative", no_argument, &base_relative, 1}, + {"lto-clang", no_argument, <o_clang, 1}, + {"uncompressed", no_argument, &uncompressed, 1}, {}, }; --- a/scripts/link-vmlinux.sh +++ b/scripts/link-vmlinux.sh -@@ -156,6 +156,10 @@ kallsyms() - kallsymopt="${kallsymopt} --base-relative" +@@ -160,6 +160,10 @@ kallsyms() + kallsymopt="${kallsymopt} --lto-clang" fi + if is_enabled CONFIG_KALLSYMS_UNCOMPRESSED; then diff --git a/target/linux/generic/pending-6.1/702-net-ethernet-mtk_eth_soc-enable-threaded-NAPI.patch b/target/linux/generic/pending-6.1/702-net-ethernet-mtk_eth_soc-enable-threaded-NAPI.patch index 7d603f5de3a..269c639d6c3 100644 --- a/target/linux/generic/pending-6.1/702-net-ethernet-mtk_eth_soc-enable-threaded-NAPI.patch +++ b/target/linux/generic/pending-6.1/702-net-ethernet-mtk_eth_soc-enable-threaded-NAPI.patch @@ -30,7 +30,7 @@ Signed-off-by: Felix Fietkau } return IRQ_HANDLED; -@@ -4727,6 +4727,8 @@ static int mtk_probe(struct platform_dev +@@ -4720,6 +4720,8 @@ static int mtk_probe(struct platform_dev * for NAPI to work */ init_dummy_netdev(ð->dummy_dev); diff --git a/target/linux/generic/pending-6.1/731-net-ethernet-mediatek-ppe-add-support-for-flow-accou.patch b/target/linux/generic/pending-6.1/731-net-ethernet-mediatek-ppe-add-support-for-flow-accou.patch index e18b1d0ee8e..f942512e11c 100644 --- a/target/linux/generic/pending-6.1/731-net-ethernet-mediatek-ppe-add-support-for-flow-accou.patch +++ b/target/linux/generic/pending-6.1/731-net-ethernet-mediatek-ppe-add-support-for-flow-accou.patch @@ -53,7 +53,7 @@ v2: fix wrong variable name in return value check spotted by Denis Kirjanov --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c -@@ -4696,8 +4696,8 @@ static int mtk_probe(struct platform_dev +@@ -4689,8 +4689,8 @@ static int mtk_probe(struct platform_dev for (i = 0; i < num_ppe; i++) { u32 ppe_addr = eth->soc->reg_map->ppe_base + i * 0x400; @@ -64,7 +64,7 @@ v2: fix wrong variable name in return value check spotted by Denis Kirjanov if (!eth->ppe[i]) { err = -ENOMEM; goto err_deinit_ppe; -@@ -4823,6 +4823,7 @@ static const struct mtk_soc_data mt7622_ +@@ -4816,6 +4816,7 @@ static const struct mtk_soc_data mt7622_ .required_pctl = false, .offload_version = 2, .hash_offset = 2, @@ -72,7 +72,7 @@ v2: fix wrong variable name in return value check spotted by Denis Kirjanov .foe_entry_size = sizeof(struct mtk_foe_entry) - 16, .txrx = { .txd_size = sizeof(struct mtk_tx_dma), -@@ -4860,6 +4861,7 @@ static const struct mtk_soc_data mt7629_ +@@ -4853,6 +4854,7 @@ static const struct mtk_soc_data mt7629_ .hw_features = MTK_HW_FEATURES, .required_clks = MT7629_CLKS_BITMAP, .required_pctl = false, @@ -80,7 +80,7 @@ v2: fix wrong variable name in return value check spotted by Denis Kirjanov .txrx = { .txd_size = sizeof(struct mtk_tx_dma), .rxd_size = sizeof(struct mtk_rx_dma), -@@ -4880,6 +4882,7 @@ static const struct mtk_soc_data mt7981_ +@@ -4873,6 +4875,7 @@ static const struct mtk_soc_data mt7981_ .offload_version = 2, .hash_offset = 4, .foe_entry_size = sizeof(struct mtk_foe_entry), @@ -88,7 +88,7 @@ v2: fix wrong variable name in return value check spotted by Denis Kirjanov .txrx = { .txd_size = sizeof(struct mtk_tx_dma_v2), .rxd_size = sizeof(struct mtk_rx_dma_v2), -@@ -4899,6 +4902,7 @@ static const struct mtk_soc_data mt7986_ +@@ -4892,6 +4895,7 @@ static const struct mtk_soc_data mt7986_ .required_pctl = false, .hash_offset = 4, .foe_entry_size = sizeof(struct mtk_foe_entry), diff --git a/target/linux/generic/pending-6.1/732-00-net-ethernet-mtk_eth_soc-drop-generic-vlan-rx-offloa.patch b/target/linux/generic/pending-6.1/732-00-net-ethernet-mtk_eth_soc-drop-generic-vlan-rx-offloa.patch index e55375f3a2a..3a4cc910b05 100644 --- a/target/linux/generic/pending-6.1/732-00-net-ethernet-mtk_eth_soc-drop-generic-vlan-rx-offloa.patch +++ b/target/linux/generic/pending-6.1/732-00-net-ethernet-mtk_eth_soc-drop-generic-vlan-rx-offloa.patch @@ -180,7 +180,7 @@ Signed-off-by: Felix Fietkau /* set interrupt delays based on current Net DIM sample */ mtk_dim_rx(ð->rx_dim.work); -@@ -4419,7 +4388,7 @@ static int mtk_add_mac(struct mtk_eth *e +@@ -4412,7 +4381,7 @@ static int mtk_add_mac(struct mtk_eth *e eth->netdev[id]->hw_features |= NETIF_F_LRO; eth->netdev[id]->vlan_features = eth->soc->hw_features & diff --git a/target/linux/generic/pending-6.1/737-02-net-ethernet-mtk_eth_soc-move-MAX_DEVS-in-mtk_soc_da.patch b/target/linux/generic/pending-6.1/737-02-net-ethernet-mtk_eth_soc-move-MAX_DEVS-in-mtk_soc_da.patch index 82848a7c972..e509663fa0e 100644 --- a/target/linux/generic/pending-6.1/737-02-net-ethernet-mtk_eth_soc-move-MAX_DEVS-in-mtk_soc_da.patch +++ b/target/linux/generic/pending-6.1/737-02-net-ethernet-mtk_eth_soc-move-MAX_DEVS-in-mtk_soc_da.patch @@ -15,7 +15,7 @@ Signed-off-by: Daniel Golle --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c -@@ -4043,7 +4043,10 @@ static void mtk_sgmii_destroy(struct mtk +@@ -4026,7 +4026,10 @@ static void mtk_sgmii_destroy(struct mtk { int i; @@ -27,7 +27,7 @@ Signed-off-by: Daniel Golle mtk_pcs_lynxi_destroy(eth->sgmii_pcs[i]); } -@@ -4486,7 +4489,12 @@ static int mtk_sgmii_init(struct mtk_eth +@@ -4479,7 +4482,12 @@ static int mtk_sgmii_init(struct mtk_eth u32 flags; int i; @@ -41,7 +41,7 @@ Signed-off-by: Daniel Golle np = of_parse_phandle(eth->dev->of_node, "mediatek,sgmiisys", i); if (!np) break; -@@ -4531,6 +4539,18 @@ static int mtk_probe(struct platform_dev +@@ -4524,6 +4532,18 @@ static int mtk_probe(struct platform_dev if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628)) eth->ip_align = NET_IP_ALIGN; @@ -60,7 +60,7 @@ Signed-off-by: Daniel Golle spin_lock_init(ð->page_lock); spin_lock_init(ð->tx_irq_lock); spin_lock_init(ð->rx_irq_lock); -@@ -4716,7 +4736,7 @@ static int mtk_probe(struct platform_dev +@@ -4709,7 +4729,7 @@ static int mtk_probe(struct platform_dev goto err_deinit_ppe; } @@ -69,7 +69,7 @@ Signed-off-by: Daniel Golle if (!eth->netdev[i]) continue; -@@ -4792,6 +4812,7 @@ static const struct mtk_soc_data mt2701_ +@@ -4785,6 +4805,7 @@ static const struct mtk_soc_data mt2701_ .hw_features = MTK_HW_FEATURES, .required_clks = MT7623_CLKS_BITMAP, .required_pctl = true, @@ -77,7 +77,7 @@ Signed-off-by: Daniel Golle .txrx = { .txd_size = sizeof(struct mtk_tx_dma), .rxd_size = sizeof(struct mtk_rx_dma), -@@ -4810,6 +4831,7 @@ static const struct mtk_soc_data mt7621_ +@@ -4803,6 +4824,7 @@ static const struct mtk_soc_data mt7621_ .required_pctl = false, .offload_version = 1, .hash_offset = 2, @@ -85,7 +85,7 @@ Signed-off-by: Daniel Golle .foe_entry_size = sizeof(struct mtk_foe_entry) - 16, .txrx = { .txd_size = sizeof(struct mtk_tx_dma), -@@ -4831,6 +4853,7 @@ static const struct mtk_soc_data mt7622_ +@@ -4824,6 +4846,7 @@ static const struct mtk_soc_data mt7622_ .offload_version = 2, .hash_offset = 2, .has_accounting = true, @@ -93,7 +93,7 @@ Signed-off-by: Daniel Golle .foe_entry_size = sizeof(struct mtk_foe_entry) - 16, .txrx = { .txd_size = sizeof(struct mtk_tx_dma), -@@ -4850,6 +4873,7 @@ static const struct mtk_soc_data mt7623_ +@@ -4843,6 +4866,7 @@ static const struct mtk_soc_data mt7623_ .required_pctl = true, .offload_version = 1, .hash_offset = 2, @@ -101,7 +101,7 @@ Signed-off-by: Daniel Golle .foe_entry_size = sizeof(struct mtk_foe_entry) - 16, .txrx = { .txd_size = sizeof(struct mtk_tx_dma), -@@ -4869,6 +4893,7 @@ static const struct mtk_soc_data mt7629_ +@@ -4862,6 +4886,7 @@ static const struct mtk_soc_data mt7629_ .required_clks = MT7629_CLKS_BITMAP, .required_pctl = false, .has_accounting = true, @@ -109,7 +109,7 @@ Signed-off-by: Daniel Golle .txrx = { .txd_size = sizeof(struct mtk_tx_dma), .rxd_size = sizeof(struct mtk_rx_dma), -@@ -4890,6 +4915,7 @@ static const struct mtk_soc_data mt7981_ +@@ -4883,6 +4908,7 @@ static const struct mtk_soc_data mt7981_ .hash_offset = 4, .foe_entry_size = sizeof(struct mtk_foe_entry), .has_accounting = true, @@ -117,7 +117,7 @@ Signed-off-by: Daniel Golle .txrx = { .txd_size = sizeof(struct mtk_tx_dma_v2), .rxd_size = sizeof(struct mtk_rx_dma_v2), -@@ -4908,6 +4934,7 @@ static const struct mtk_soc_data mt7986_ +@@ -4901,6 +4927,7 @@ static const struct mtk_soc_data mt7986_ .required_clks = MT7986_CLKS_BITMAP, .required_pctl = false, .hash_offset = 4, @@ -125,7 +125,7 @@ Signed-off-by: Daniel Golle .foe_entry_size = sizeof(struct mtk_foe_entry), .has_accounting = true, .txrx = { -@@ -4926,6 +4953,7 @@ static const struct mtk_soc_data rt5350_ +@@ -4919,6 +4946,7 @@ static const struct mtk_soc_data rt5350_ .hw_features = MTK_HW_FEATURES_MT7628, .required_clks = MT7628_CLKS_BITMAP, .required_pctl = false, diff --git a/target/linux/generic/pending-6.1/737-03-net-ethernet-mtk_eth_soc-rely-on-num_devs-and-remove.patch b/target/linux/generic/pending-6.1/737-03-net-ethernet-mtk_eth_soc-rely-on-num_devs-and-remove.patch index be12aa5c066..1989eb677a3 100644 --- a/target/linux/generic/pending-6.1/737-03-net-ethernet-mtk_eth_soc-rely-on-num_devs-and-remove.patch +++ b/target/linux/generic/pending-6.1/737-03-net-ethernet-mtk_eth_soc-rely-on-num_devs-and-remove.patch @@ -78,7 +78,7 @@ Signed-off-by: Daniel Golle struct net_device *dev = eth->netdev[i]; mtk_w32(eth, MAC_MCR_FORCE_LINK_DOWN, MTK_MAC_MCR(i)); -@@ -3963,7 +3963,7 @@ static void mtk_pending_work(struct work +@@ -3946,7 +3946,7 @@ static void mtk_pending_work(struct work mtk_prepare_for_reset(eth); /* stop all devices to make sure that dma is properly shut down */ @@ -87,7 +87,7 @@ Signed-off-by: Daniel Golle if (!eth->netdev[i] || !netif_running(eth->netdev[i])) continue; -@@ -3979,7 +3979,7 @@ static void mtk_pending_work(struct work +@@ -3962,7 +3962,7 @@ static void mtk_pending_work(struct work mtk_hw_init(eth, true); /* restart DMA and enable IRQs */ @@ -96,7 +96,7 @@ Signed-off-by: Daniel Golle if (!test_bit(i, &restart)) continue; -@@ -4007,7 +4007,7 @@ static int mtk_free_dev(struct mtk_eth * +@@ -3990,7 +3990,7 @@ static int mtk_free_dev(struct mtk_eth * { int i; @@ -105,7 +105,7 @@ Signed-off-by: Daniel Golle if (!eth->netdev[i]) continue; free_netdev(eth->netdev[i]); -@@ -4026,7 +4026,7 @@ static int mtk_unreg_dev(struct mtk_eth +@@ -4009,7 +4009,7 @@ static int mtk_unreg_dev(struct mtk_eth { int i; @@ -114,7 +114,7 @@ Signed-off-by: Daniel Golle struct mtk_mac *mac; if (!eth->netdev[i]) continue; -@@ -4331,7 +4331,7 @@ static int mtk_add_mac(struct mtk_eth *e +@@ -4313,7 +4313,7 @@ static int mtk_add_mac(struct mtk_eth *e } id = be32_to_cpup(_id); @@ -123,7 +123,7 @@ Signed-off-by: Daniel Golle dev_err(eth->dev, "%d is not a valid mac id\n", id); return -EINVAL; } -@@ -4461,7 +4461,7 @@ void mtk_eth_set_dma_device(struct mtk_e +@@ -4454,7 +4454,7 @@ void mtk_eth_set_dma_device(struct mtk_e rtnl_lock(); @@ -132,7 +132,7 @@ Signed-off-by: Daniel Golle dev = eth->netdev[i]; if (!dev || !(dev->flags & IFF_UP)) -@@ -4787,7 +4787,7 @@ static int mtk_remove(struct platform_de +@@ -4780,7 +4780,7 @@ static int mtk_remove(struct platform_de int i; /* stop all devices to make sure that dma is properly shut down */ diff --git a/target/linux/generic/pending-6.1/737-04-net-ethernet-mtk_eth_soc-add-MTK_NETSYS_V3-capabilit.patch b/target/linux/generic/pending-6.1/737-04-net-ethernet-mtk_eth_soc-add-MTK_NETSYS_V3-capabilit.patch index a383a5e4ef8..9c7b47f15b6 100644 --- a/target/linux/generic/pending-6.1/737-04-net-ethernet-mtk_eth_soc-add-MTK_NETSYS_V3-capabilit.patch +++ b/target/linux/generic/pending-6.1/737-04-net-ethernet-mtk_eth_soc-add-MTK_NETSYS_V3-capabilit.patch @@ -182,7 +182,7 @@ Signed-off-by: Daniel Golle /* PSE should not drop port8 and port9 packets from WDMA Tx */ mtk_w32(eth, 0x00000300, PSE_DROP_CFG); -@@ -4368,7 +4433,11 @@ static int mtk_add_mac(struct mtk_eth *e +@@ -4361,7 +4426,11 @@ static int mtk_add_mac(struct mtk_eth *e } spin_lock_init(&mac->hw_stats->stats_lock); u64_stats_init(&mac->hw_stats->syncp); diff --git a/target/linux/generic/pending-6.1/737-06-net-ethernet-mtk_eth_soc-add-support-for-MT7988-SoC.patch b/target/linux/generic/pending-6.1/737-06-net-ethernet-mtk_eth_soc-add-support-for-MT7988-SoC.patch index 4e52e0da547..f1a3df2181a 100644 --- a/target/linux/generic/pending-6.1/737-06-net-ethernet-mtk_eth_soc-add-support-for-MT7988-SoC.patch +++ b/target/linux/generic/pending-6.1/737-06-net-ethernet-mtk_eth_soc-add-support-for-MT7988-SoC.patch @@ -150,7 +150,7 @@ mtk_eth_soc driver. data |= TX_DMA_SWC_V2 | QID_BITS_V2(info->qid); WRITE_ONCE(desc->txd4, data); -@@ -5016,6 +5117,25 @@ static const struct mtk_soc_data mt7986_ +@@ -5009,6 +5110,25 @@ static const struct mtk_soc_data mt7986_ }, }; @@ -176,7 +176,7 @@ mtk_eth_soc driver. static const struct mtk_soc_data rt5350_data = { .reg_map = &mt7628_reg_map, .caps = MT7628_CAPS, -@@ -5034,14 +5154,15 @@ static const struct mtk_soc_data rt5350_ +@@ -5027,14 +5147,15 @@ static const struct mtk_soc_data rt5350_ }; const struct of_device_id of_mtk_match[] = { diff --git a/target/linux/generic/pending-6.1/737-07-net-ethernet-mtk_eth_soc-add-paths-and-SerDes-modes-.patch b/target/linux/generic/pending-6.1/737-07-net-ethernet-mtk_eth_soc-add-paths-and-SerDes-modes-.patch index abde00cf617..81b0d2e3f5f 100644 --- a/target/linux/generic/pending-6.1/737-07-net-ethernet-mtk_eth_soc-add-paths-and-SerDes-modes-.patch +++ b/target/linux/generic/pending-6.1/737-07-net-ethernet-mtk_eth_soc-add-paths-and-SerDes-modes-.patch @@ -607,7 +607,7 @@ Signed-off-by: Daniel Golle mtk_w32(eth, val, MTK_PPSC); dev_dbg(eth->dev, "MDC is running on %d Hz\n", MDC_MAX_FREQ / divider); -@@ -4487,8 +4690,8 @@ static int mtk_add_mac(struct mtk_eth *e +@@ -4469,8 +4672,8 @@ static int mtk_add_mac(struct mtk_eth *e const __be32 *_id = of_get_property(np, "reg", NULL); phy_interface_t phy_mode; struct phylink *phylink; @@ -617,7 +617,7 @@ Signed-off-by: Daniel Golle int txqs = 1; if (!_id) { -@@ -4579,6 +4782,32 @@ static int mtk_add_mac(struct mtk_eth *e +@@ -4572,6 +4775,32 @@ static int mtk_add_mac(struct mtk_eth *e mac->phylink_config.supported_interfaces); } @@ -650,7 +650,7 @@ Signed-off-by: Daniel Golle phylink = phylink_create(&mac->phylink_config, of_fwnode_handle(mac->of_node), phy_mode, &mtk_phylink_ops); -@@ -4766,6 +4995,13 @@ static int mtk_probe(struct platform_dev +@@ -4759,6 +4988,13 @@ static int mtk_probe(struct platform_dev if (err) return err; diff --git a/target/linux/generic/pending-6.1/768-net-dsa-mv88e6xxx-Request-assisted-learning-on-CPU-port.patch b/target/linux/generic/pending-6.1/768-net-dsa-mv88e6xxx-Request-assisted-learning-on-CPU-port.patch index c2f48627fb3..230ad2d036a 100644 --- a/target/linux/generic/pending-6.1/768-net-dsa-mv88e6xxx-Request-assisted-learning-on-CPU-port.patch +++ b/target/linux/generic/pending-6.1/768-net-dsa-mv88e6xxx-Request-assisted-learning-on-CPU-port.patch @@ -17,7 +17,7 @@ Signed-off-by: Tobias Waldekranz --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c -@@ -6973,6 +6973,7 @@ static int mv88e6xxx_register_switch(str +@@ -6980,6 +6980,7 @@ static int mv88e6xxx_register_switch(str ds->ops = &mv88e6xxx_switch_ops; ds->ageing_time_min = chip->info->age_time_coeff; ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX; diff --git a/target/linux/ipq40xx/patches-5.15/902-dts-ipq4019-ap-dk04.1.patch b/target/linux/ipq40xx/patches-5.15/902-dts-ipq4019-ap-dk04.1.patch index 05778a638f8..c7688de7e89 100644 --- a/target/linux/ipq40xx/patches-5.15/902-dts-ipq4019-ap-dk04.1.patch +++ b/target/linux/ipq40xx/patches-5.15/902-dts-ipq4019-ap-dk04.1.patch @@ -116,21 +116,17 @@ spi-max-frequency = <24000000>; }; }; -@@ -103,9 +129,48 @@ +@@ -102,6 +128,45 @@ + status = "okay"; perst-gpio = <&tlmm 38 0x1>; }; - ++ + i2c0: i2c@78b7000 { /* BLSP1 QUP2 */ + pinctrl-0 = <&i2c_0_pins>; + pinctrl-names = "default"; + + status = "okay"; + }; -+ - qpic-nand@79b0000 { - pinctrl-0 = <&nand_pins>; - pinctrl-names = "default"; - }; + + usb3_ss_phy: ssphy@9a000 { + status = "okay"; @@ -165,3 +161,4 @@ + }; }; }; + diff --git a/target/linux/mediatek/filogic/config-5.15 b/target/linux/mediatek/filogic/config-5.15 index 4cae8c50ac7..2ffc466b7c3 100644 --- a/target/linux/mediatek/filogic/config-5.15 +++ b/target/linux/mediatek/filogic/config-5.15 @@ -306,7 +306,7 @@ CONFIG_PHYLINK=y CONFIG_PHYS_ADDR_T_64BIT=y CONFIG_PHY_MTK_TPHY=y # CONFIG_PHY_MTK_UFS is not set -# CONFIG_PHY_MTK_XSPHY is not set +CONFIG_PHY_MTK_XSPHY=y CONFIG_PINCTRL=y # CONFIG_PINCTRL_MT2712 is not set # CONFIG_PINCTRL_MT6765 is not set diff --git a/target/linux/mediatek/filogic/config-6.1 b/target/linux/mediatek/filogic/config-6.1 index 96a75667354..334dfa8502b 100644 --- a/target/linux/mediatek/filogic/config-6.1 +++ b/target/linux/mediatek/filogic/config-6.1 @@ -330,7 +330,7 @@ CONFIG_PHYS_ADDR_T_64BIT=y # CONFIG_PHY_MTK_PCIE is not set CONFIG_PHY_MTK_TPHY=y # CONFIG_PHY_MTK_UFS is not set -# CONFIG_PHY_MTK_XSPHY is not set +CONFIG_PHY_MTK_XSPHY=y CONFIG_PINCTRL=y # CONFIG_PINCTRL_MT2712 is not set # CONFIG_PINCTRL_MT6765 is not set diff --git a/target/linux/mediatek/patches-5.15/410-bt-mtk-serial-fix.patch b/target/linux/mediatek/patches-5.15/410-bt-mtk-serial-fix.patch index 3f4597c65d6..bfa90f3849c 100644 --- a/target/linux/mediatek/patches-5.15/410-bt-mtk-serial-fix.patch +++ b/target/linux/mediatek/patches-5.15/410-bt-mtk-serial-fix.patch @@ -19,7 +19,7 @@ }, [PORT_NPCM] = { .name = "Nuvoton 16550", -@@ -2766,6 +2766,11 @@ serial8250_do_set_termios(struct uart_po +@@ -2763,6 +2763,11 @@ serial8250_do_set_termios(struct uart_po unsigned long flags; unsigned int baud, quot, frac = 0; diff --git a/target/linux/mediatek/patches-5.15/850-v6.0-i2c-move-drivers-from-strlcpy-to-strscpy.patch b/target/linux/mediatek/patches-5.15/850-v6.0-i2c-move-drivers-from-strlcpy-to-strscpy.patch index 1520a6cbe6d..44d3753b142 100644 --- a/target/linux/mediatek/patches-5.15/850-v6.0-i2c-move-drivers-from-strlcpy-to-strscpy.patch +++ b/target/linux/mediatek/patches-5.15/850-v6.0-i2c-move-drivers-from-strlcpy-to-strscpy.patch @@ -425,7 +425,7 @@ Signed-off-by: Wolfram Sang if (ret) --- a/drivers/i2c/busses/i2c-qup.c +++ b/drivers/i2c/busses/i2c-qup.c -@@ -1878,7 +1878,7 @@ nodma: +@@ -1885,7 +1885,7 @@ nodma: qup->adap.dev.of_node = pdev->dev.of_node; qup->is_last = true; diff --git a/target/linux/mediatek/patches-5.15/901-arm-add-cmdline-override.patch b/target/linux/mediatek/patches-5.15/901-arm-add-cmdline-override.patch index 6016128bd4a..636452bebb8 100644 --- a/target/linux/mediatek/patches-5.15/901-arm-add-cmdline-override.patch +++ b/target/linux/mediatek/patches-5.15/901-arm-add-cmdline-override.patch @@ -37,7 +37,7 @@ * managed to set the command line, unless CONFIG_CMDLINE_FORCE --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig -@@ -1942,6 +1942,14 @@ config CMDLINE_FORCE +@@ -1983,6 +1983,14 @@ config CMDLINE_FORCE endchoice diff --git a/target/linux/octeontx/patches-5.15/0004-PCI-add-quirk-for-Gateworks-PLX-PEX860x-switch-with-.patch b/target/linux/octeontx/patches-5.15/0004-PCI-add-quirk-for-Gateworks-PLX-PEX860x-switch-with-.patch index 5b0db92d9e4..842bed4c427 100644 --- a/target/linux/octeontx/patches-5.15/0004-PCI-add-quirk-for-Gateworks-PLX-PEX860x-switch-with-.patch +++ b/target/linux/octeontx/patches-5.15/0004-PCI-add-quirk-for-Gateworks-PLX-PEX860x-switch-with-.patch @@ -22,7 +22,7 @@ Signed-off-by: Tim Harvey #include #include #include -@@ -5854,3 +5855,34 @@ static void nvidia_ion_ahci_fixup(struct +@@ -5856,3 +5857,34 @@ static void nvidia_ion_ahci_fixup(struct pdev->dev_flags |= PCI_DEV_FLAGS_HAS_MSI_MASKING; } DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_NVIDIA, 0x0ab8, nvidia_ion_ahci_fixup); diff --git a/target/linux/qualcommax/patches-6.1/0134-PCI-qcom-Fixing-broken-pcie-enumeration-for-2_3_3-co.patch b/target/linux/qualcommax/patches-6.1/0134-PCI-qcom-Fixing-broken-pcie-enumeration-for-2_3_3-co.patch new file mode 100644 index 00000000000..1b34cdda461 --- /dev/null +++ b/target/linux/qualcommax/patches-6.1/0134-PCI-qcom-Fixing-broken-pcie-enumeration-for-2_3_3-co.patch @@ -0,0 +1,44 @@ +From f92c2f22197b7beed59b81f2aa179e16987c02e4 Mon Sep 17 00:00:00 2001 +From: Sricharan Ramabadhran +Date: Mon, 24 Jul 2023 12:04:29 +0530 +Subject: [PATCH] PCI: qcom: Fixing broken pcie enumeration for 2_3_3 configs + ops + +PARF_SLV_ADDR_SPACE_SIZE_2_3_3 macro is used for IPQ8074 2_3_3 post_init. +PCIe slave addr register offset is 0x358, but was wrongly changed to +0x168 as a part of commit 39171b33f652 ("PCI: qcom: Remove PCIE20_ prefix +from register definitions"). Fixing it, by using the right macro and remove +the unused PARF_SLV_ADDR_SPACE_SIZE_2_3_3. + +Without this access to the registers of slave addr space like iATU etc +are broken leading to pcie enumeration failure. + +Fixes: 39171b33f652 ("PCI: qcom: Remove PCIE20_ prefix from register definitions") +Cc: +Reviewed-by: Manivannan Sadhasivam +Reviewed-by: Konrad Dybcio +Signed-off-by: Sricharan Ramabadhran +--- + drivers/pci/controller/dwc/pcie-qcom.c | 4 +--- + 1 file changed, 1 insertion(+), 3 deletions(-) + +--- a/drivers/pci/controller/dwc/pcie-qcom.c ++++ b/drivers/pci/controller/dwc/pcie-qcom.c +@@ -40,7 +40,6 @@ + #define PARF_PHY_REFCLK 0x4c + #define PARF_CONFIG_BITS 0x50 + #define PARF_DBI_BASE_ADDR 0x168 +-#define PARF_SLV_ADDR_SPACE_SIZE_2_3_3 0x16c /* Register offset specific to IP ver 2.3.3 */ + #define PARF_MHI_CLOCK_RESET_CTRL 0x174 + #define PARF_AXI_MSTR_WR_ADDR_HALT 0x178 + #define PARF_AXI_MSTR_WR_ADDR_HALT_V2 0x1a8 +@@ -1148,8 +1147,7 @@ static int qcom_pcie_post_init_2_3_3(str + u16 offset = dw_pcie_find_capability(pci, PCI_CAP_ID_EXP); + u32 val; + +- writel(SLV_ADDR_SPACE_SZ, +- pcie->parf + PARF_SLV_ADDR_SPACE_SIZE_2_3_3); ++ writel(SLV_ADDR_SPACE_SZ, pcie->parf + PARF_SLV_ADDR_SPACE_SIZE); + + val = readl(pcie->parf + PARF_PHY_CTRL); + val &= ~BIT(0); diff --git a/target/linux/ramips/dts/mt7620a.dtsi b/target/linux/ramips/dts/mt7620a.dtsi index 4b6fa60dc8b..87cd119792b 100644 --- a/target/linux/ramips/dts/mt7620a.dtsi +++ b/target/linux/ramips/dts/mt7620a.dtsi @@ -40,15 +40,19 @@ #address-cells = <1>; #size-cells = <1>; - sysc: sysc@0 { - compatible = "ralink,mt7620a-sysc", "ralink,rt3050-sysc", "syscon"; + sysc: syscon@0 { + compatible = "ralink,mt7620-sysc", "syscon"; reg = <0x0 0x100>; + #clock-cells = <1>; + #reset-cells = <1>; }; timer: timer@100 { compatible = "ralink,mt7620a-timer", "ralink,rt2880-timer"; reg = <0x100 0x20>; + clocks = <&sysc 5>; + interrupt-parent = <&intc>; interrupts = <1>; }; @@ -57,7 +61,9 @@ compatible = "ralink,mt7620a-wdt", "ralink,rt2880-wdt"; reg = <0x120 0x10>; - resets = <&rstctrl 8>; + clocks = <&sysc 6>; + + resets = <&sysc 8>; reset-names = "wdt"; interrupt-parent = <&intc>; @@ -68,7 +74,7 @@ compatible = "ralink,mt7620a-intc", "ralink,rt2880-intc"; reg = <0x200 0x100>; - resets = <&rstctrl 19>; + resets = <&sysc 19>; reset-names = "intc"; interrupt-controller; @@ -82,7 +88,7 @@ compatible = "ralink,mt7620a-memc", "ralink,rt3050-memc"; reg = <0x300 0x100>; - resets = <&rstctrl 20>; + resets = <&sysc 20>; reset-names = "mc"; interrupt-parent = <&intc>; @@ -93,8 +99,9 @@ compatible = "ralink,mt7620a-uart", "ralink,rt2880-uart", "ns16550a"; reg = <0x500 0x100>; - resets = <&rstctrl 12>; - reset-names = "uart"; + clocks = <&sysc 7>; + + resets = <&sysc 12>; interrupt-parent = <&intc>; interrupts = <5>; @@ -108,7 +115,7 @@ compatible = "ralink,mt7620a-gpio", "ralink,rt2880-gpio"; reg = <0x600 0x34>; - resets = <&rstctrl 13>; + resets = <&sysc 13>; reset-names = "pio"; interrupt-parent = <&intc>; @@ -185,7 +192,9 @@ compatible = "ralink,rt2880-i2c"; reg = <0x900 0x100>; - resets = <&rstctrl 16>; + clocks = <&sysc 8>; + + resets = <&sysc 16>; reset-names = "i2c"; #address-cells = <1>; @@ -201,7 +210,9 @@ compatible = "mediatek,mt7620-i2s"; reg = <0xa00 0x100>; - resets = <&rstctrl 17>; + clocks = <&sysc 9>; + + resets = <&sysc 17>; reset-names = "i2s"; interrupt-parent = <&intc>; @@ -221,7 +232,9 @@ compatible = "ralink,mt7620a-spi", "ralink,rt2880-spi"; reg = <0xb00 0x40>; - resets = <&rstctrl 18>; + clocks = <&sysc 10>; + + resets = <&sysc 18>; reset-names = "spi"; #address-cells = <1>; @@ -237,7 +250,9 @@ compatible = "ralink,rt2880-spi"; reg = <0xb40 0x60>; - resets = <&rstctrl 18>; + clocks = <&sysc 11>; + + resets = <&sysc 18>; reset-names = "spi"; #address-cells = <1>; @@ -253,8 +268,9 @@ compatible = "ralink,mt7620a-uart", "ralink,rt2880-uart", "ns16550a"; reg = <0xc00 0x100>; - resets = <&rstctrl 19>; - reset-names = "uartl"; + clocks = <&sysc 12>; + + resets = <&sysc 19>; interrupt-parent = <&intc>; interrupts = <12>; @@ -269,7 +285,7 @@ compatible = "ralink,mt7620a-systick", "ralink,cevt-systick"; reg = <0xd00 0x10>; - resets = <&rstctrl 28>; + resets = <&sysc 28>; reset-names = "intc"; interrupt-parent = <&cpuintc>; @@ -280,7 +296,7 @@ compatible = "ralink,mt7620a-pcm"; reg = <0x2000 0x800>; - resets = <&rstctrl 11>; + resets = <&sysc 11>; reset-names = "pcm"; interrupt-parent = <&intc>; @@ -293,7 +309,7 @@ compatible = "ralink,mt7620a-gdma", "ralink,rt3883-gdma"; reg = <0x2800 0x800>; - resets = <&rstctrl 14>; + resets = <&sysc 14>; reset-names = "dma"; interrupt-parent = <&intc>; @@ -435,26 +451,14 @@ }; }; - rstctrl: rstctrl { - compatible = "ralink,mt7620a-reset", "ralink,rt2880-reset"; - #reset-cells = <1>; - }; - - clkctrl: clkctrl { - compatible = "ralink,rt2880-clock"; - #clock-cells = <1>; - }; - usbphy: usbphy { compatible = "mediatek,mt7620-usbphy"; #phy-cells = <0>; ralink,sysctl = <&sysc>; - resets = <&rstctrl 22 &rstctrl 25>; + /* usb phy reset is only controled by RSTCTRL bit 25 */ + resets = <&sysc 25>, <&sysc 22>; reset-names = "host", "device"; - - clocks = <&clkctrl 22 &clkctrl 25>; - clock-names = "host", "device"; }; ethernet: ethernet@10100000 { @@ -467,7 +471,7 @@ interrupt-parent = <&cpuintc>; interrupts = <5>; - resets = <&rstctrl 21 &rstctrl 23>; + resets = <&sysc 21>, <&sysc 23>; reset-names = "fe", "esw"; mediatek,switch = <&gsw>; @@ -498,7 +502,7 @@ compatible = "mediatek,mt7620-gsw"; reg = <0x10110000 0x8000>; - resets = <&rstctrl 23>; + resets = <&sysc 23>; reset-names = "esw"; interrupt-parent = <&intc>; @@ -566,12 +570,9 @@ #address-cells = <3>; #size-cells = <2>; - resets = <&rstctrl 26>; + resets = <&sysc 26>; reset-names = "pcie0"; - clocks = <&clkctrl 26>; - clock-names = "pcie0"; - interrupt-parent = <&cpuintc>; interrupts = <4>; @@ -604,6 +605,8 @@ compatible = "ralink,rt7620-wmac", "ralink,rt2880-wmac"; reg = <0x10180000 0x40000>; + clocks = <&sysc 13>; + interrupt-parent = <&cpuintc>; interrupts = <6>; diff --git a/target/linux/ramips/dts/mt7620n.dtsi b/target/linux/ramips/dts/mt7620n.dtsi index 276bc137333..3299dea0f0d 100644 --- a/target/linux/ramips/dts/mt7620n.dtsi +++ b/target/linux/ramips/dts/mt7620n.dtsi @@ -40,15 +40,19 @@ #address-cells = <1>; #size-cells = <1>; - sysc: sysc@0 { - compatible = "ralink,mt7620a-sysc", "ralink,rt3050-sysc", "syscon"; + sysc: syscon@0 { + compatible = "ralink,mt7620-sysc", "syscon"; reg = <0x0 0x100>; + #clock-cells = <1>; + #reset-cells = <1>; }; timer: timer@100 { compatible = "ralink,mt7620a-timer", "ralink,rt2880-timer"; reg = <0x100 0x20>; + clocks = <&sysc 5>; + interrupt-parent = <&intc>; interrupts = <1>; }; @@ -57,7 +61,9 @@ compatible = "ralink,mt7620a-wdt", "ralink,rt2880-wdt"; reg = <0x120 0x10>; - resets = <&rstctrl 8>; + clocks = <&sysc 6>; + + resets = <&sysc 8>; reset-names = "wdt"; interrupt-parent = <&intc>; @@ -68,7 +74,7 @@ compatible = "ralink,mt7620a-intc", "ralink,rt2880-intc"; reg = <0x200 0x100>; - resets = <&rstctrl 19>; + resets = <&sysc 19>; reset-names = "intc"; interrupt-controller; @@ -82,7 +88,7 @@ compatible = "ralink,mt7620a-memc", "ralink,rt3050-memc"; reg = <0x300 0x100>; - resets = <&rstctrl 20>; + resets = <&sysc 20>; reset-names = "mc"; interrupt-parent = <&intc>; @@ -93,7 +99,7 @@ compatible = "ralink,mt7620a-gpio", "ralink,rt2880-gpio"; reg = <0x600 0x34>; - resets = <&rstctrl 13>; + resets = <&sysc 13>; reset-names = "pio"; interrupt-parent = <&intc>; @@ -170,7 +176,9 @@ compatible = "ralink,rt2880-i2c"; reg = <0x900 0x100>; - resets = <&rstctrl 16>; + clocks = <&sysc 8>; + + resets = <&sysc 16>; reset-names = "i2c"; #address-cells = <1>; @@ -186,7 +194,9 @@ compatible = "ralink,mt7620a-spi", "ralink,rt2880-spi"; reg = <0xb00 0x40>; - resets = <&rstctrl 18>; + clocks = <&sysc 10>; + + resets = <&sysc 18>; reset-names = "spi"; #address-cells = <1>; @@ -202,7 +212,9 @@ compatible = "ralink,rt2880-spi"; reg = <0xb40 0x60>; - resets = <&rstctrl 18>; + clocks = <&sysc 11>; + + resets = <&sysc 18>; reset-names = "spi"; #address-cells = <1>; @@ -218,8 +230,9 @@ compatible = "ralink,mt7620a-uart", "ralink,rt2880-uart", "ns16550a"; reg = <0xc00 0x100>; - resets = <&rstctrl 19>; - reset-names = "uartl"; + clocks = <&sysc 12>; + + resets = <&sysc 19>; interrupt-parent = <&intc>; interrupts = <12>; @@ -234,7 +247,7 @@ compatible = "ralink,mt7620a-systick", "ralink,cevt-systick"; reg = <0xd00 0x10>; - resets = <&rstctrl 28>; + resets = <&sysc 28>; reset-names = "intc"; interrupt-parent = <&cpuintc>; @@ -286,26 +299,14 @@ }; }; - rstctrl: rstctrl { - compatible = "ralink,mt7620a-reset", "ralink,rt2880-reset"; - #reset-cells = <1>; - }; - - clkctrl: clkctrl { - compatible = "ralink,rt2880-clock"; - #clock-cells = <1>; - }; - usbphy: usbphy { compatible = "mediatek,mt7620-usbphy"; #phy-cells = <0>; ralink,sysctl = <&sysc>; - resets = <&rstctrl 22 &rstctrl 25>; + /* usb phy reset is only controled by RSTCTRL bit 25 */ + resets = <&sysc 25>, <&sysc 22>; reset-names = "host", "device"; - - clocks = <&clkctrl 22 &clkctrl 25>; - clock-names = "host", "device"; }; ethernet: ethernet@10100000 { @@ -318,7 +319,7 @@ interrupt-parent = <&cpuintc>; interrupts = <5>; - resets = <&rstctrl 21 &rstctrl 23>; + resets = <&sysc 21>, <&sysc 23>; reset-names = "fe", "esw"; mediatek,switch = <&gsw>; @@ -328,7 +329,7 @@ compatible = "mediatek,mt7620-gsw"; reg = <0x10110000 0x8000>; - resets = <&rstctrl 23>; + resets = <&sysc 23>; reset-names = "esw"; interrupt-parent = <&intc>; @@ -379,6 +380,8 @@ compatible = "ralink,rt7620-wmac", "ralink,rt2880-wmac"; reg = <0x10180000 0x40000>; + clocks = <&sysc 13>; + interrupt-parent = <&cpuintc>; interrupts = <6>; diff --git a/target/linux/ramips/dts/mt7621.dtsi b/target/linux/ramips/dts/mt7621.dtsi index 3e076741a91..f1f77282b24 100644 --- a/target/linux/ramips/dts/mt7621.dtsi +++ b/target/linux/ramips/dts/mt7621.dtsi @@ -1,8 +1,9 @@ /dts-v1/; -#include #include #include +#include +#include / { #address-cells = <1>; @@ -41,14 +42,6 @@ bootargs = "console=ttyS0,57600"; }; - sysclock: sysclock { - #clock-cells = <0>; - compatible = "fixed-clock"; - - /* FIXME: there should be way to detect this */ - clock-frequency = <50000000>; - }; - palmbus: palmbus@1e000000 { compatible = "palmbus"; reg = <0x1e000000 0x100000>; @@ -60,6 +53,7 @@ sysc: syscon@0 { compatible = "mediatek,mt7621-sysc", "syscon"; #clock-cells = <1>; + #reset-cells = <1>; ralink,memctl = <&memc>; clock-output-names = "xtal", "cpu", "bus", "50m", "125m", "150m", @@ -67,9 +61,10 @@ reg = <0x0 0x100>; }; - wdt: wdt@100 { + wdt: watchdog@100 { compatible = "mediatek,mt7621-wdt"; reg = <0x100 0x100>; + mediatek,sysctl = <&sysc>; }; gpio: gpio@600 { @@ -88,9 +83,10 @@ compatible = "mediatek,mt7621-i2c"; reg = <0x900 0x100>; - clocks = <&sysclock>; + clocks = <&sysc MT7621_CLK_I2C>; + clock-names = "i2c"; - resets = <&rstctrl 16>; + resets = <&sysc MT7621_RST_I2C>; reset-names = "i2c"; #address-cells = <1>; @@ -106,9 +102,9 @@ compatible = "mediatek,mt7621-i2s"; reg = <0xa00 0x100>; - clocks = <&sysclock>; + clocks = <&sysc MT7621_CLK_I2S>; - resets = <&rstctrl 17>; + resets = <&sysc MT7621_RST_I2S>; reset-names = "i2s"; interrupt-parent = <&gic>; @@ -128,14 +124,14 @@ compatible = "ralink,mt7621-systick", "ralink,cevt-systick"; reg = <0x500 0x10>; - resets = <&rstctrl 28>; + resets = <&sysc MT7621_RST_AUX_STCK>; reset-names = "intc"; interrupt-parent = <&gic>; interrupts = ; }; - memc: syscon@5000 { + memc: memory-controller@5000 { compatible = "mediatek,mt7621-memc", "syscon"; reg = <0x5000 0x1000>; }; @@ -144,7 +140,9 @@ compatible = "ns16550a"; reg = <0xc00 0x100>; - clock-frequency = <50000000>; + clocks = <&sysc MT7621_CLK_UART1>; + + resets = <&sysc MT7621_RST_UART1>; interrupt-parent = <&gic>; interrupts = ; @@ -158,7 +156,9 @@ compatible = "ns16550a"; reg = <0xd00 0x100>; - clock-frequency = <50000000>; + clocks = <&sysc MT7621_CLK_UART2>; + + resets = <&sysc MT7621_RST_UART2>; interrupt-parent = <&gic>; interrupts = ; @@ -176,7 +176,9 @@ compatible = "ns16550a"; reg = <0xe00 0x100>; - clock-frequency = <50000000>; + clocks = <&sysc MT7621_CLK_UART3>; + + resets = <&sysc MT7621_RST_UART3>; interrupt-parent = <&gic>; interrupts = ; @@ -196,9 +198,10 @@ compatible = "ralink,mt7621-spi"; reg = <0xb00 0x100>; - clocks = <&sysc MT7621_CLK_BUS>; + clocks = <&sysc MT7621_CLK_SPI>; + clock-names = "spi"; - resets = <&rstctrl 18>; + resets = <&sysc MT7621_RST_SPI>; reset-names = "spi"; #address-cells = <1>; @@ -212,7 +215,7 @@ compatible = "ralink,rt3883-gdma"; reg = <0x2800 0x800>; - resets = <&rstctrl 14>; + resets = <&sysc MT7621_RST_GDMA>; reset-names = "dma"; interrupt-parent = <&gic>; @@ -229,7 +232,7 @@ compatible = "mediatek,mt7621-hsdma"; reg = <0x7000 0x1000>; - resets = <&rstctrl 5>; + resets = <&sysc MT7621_RST_HSDMA>; reset-names = "hsdma"; interrupt-parent = <&gic>; @@ -334,16 +337,6 @@ }; }; - rstctrl: rstctrl { - compatible = "ralink,rt2880-reset"; - #reset-cells = <1>; - }; - - clkctrl: clkctrl { - compatible = "ralink,rt2880-clock"; - #clock-cells = <1>; - }; - sdhci: sdhci@1e130000 { status = "disabled"; @@ -366,7 +359,7 @@ 0x1e1d0700 0x0100>; reg-names = "mac", "ippc"; - clocks = <&sysclock>; + clocks = <&sysc MT7621_CLK_XTAL>; clock-names = "sys_ck"; interrupt-parent = <&gic>; @@ -408,13 +401,6 @@ }; }; - nficlock: nficlock { - #clock-cells = <0>; - compatible = "fixed-clock"; - - clock-frequency = <125000000>; - }; - cpc: cpc@1fbf0000 { compatible = "mti,mips-cpc"; reg = <0x1fbf0000 0x8000>; @@ -433,7 +419,7 @@ 0x1e003800 0x800>; reg-names = "nfi", "ecc"; - clocks = <&nficlock>; + clocks = <&sysc MT7621_CLK_NAND>; clock-names = "nfi_clk"; }; @@ -441,14 +427,13 @@ compatible = "mediatek,mt7621-eth"; reg = <0x1e100000 0x10000>; - clocks = <&sysc MT7621_CLK_FE>, - <&sysc MT7621_CLK_ETH>; + clocks = <&sysc MT7621_CLK_FE>, <&sysc MT7621_CLK_ETH>; clock-names = "fe", "ethif"; #address-cells = <1>; #size-cells = <0>; - resets = <&rstctrl 6>, <&rstctrl 23>; + resets = <&sysc MT7621_RST_FE>, <&sysc MT7621_RST_ETH>; reset-names = "fe", "eth"; interrupt-parent = <&gic>; @@ -486,7 +471,7 @@ compatible = "mediatek,mt7621"; reg = <0x1f>; mediatek,mcm; - resets = <&rstctrl 2>; + resets = <&sysc MT7621_RST_MCM>; reset-names = "mcm"; interrupt-controller; #interrupt-cells = <1>; @@ -578,7 +563,7 @@ #interrupt-cells = <1>; interrupt-map-mask = <0 0 0 0>; interrupt-map = <0 0 0 0 &gic GIC_SHARED 4 IRQ_TYPE_LEVEL_HIGH>; - resets = <&rstctrl 24>; + resets = <&sysc MT7621_RST_PCIE0>; clocks = <&sysc MT7621_CLK_PCIE0>; phys = <&pcie0_phy 1>; phy-names = "pcie-phy0"; @@ -593,7 +578,7 @@ #interrupt-cells = <1>; interrupt-map-mask = <0 0 0 0>; interrupt-map = <0 0 0 0 &gic GIC_SHARED 24 IRQ_TYPE_LEVEL_HIGH>; - resets = <&rstctrl 25>; + resets = <&sysc MT7621_RST_PCIE1>; clocks = <&sysc MT7621_CLK_PCIE1>; phys = <&pcie0_phy 1>; phy-names = "pcie-phy1"; @@ -608,7 +593,7 @@ #interrupt-cells = <1>; interrupt-map-mask = <0 0 0 0>; interrupt-map = <0 0 0 0 &gic GIC_SHARED 25 IRQ_TYPE_LEVEL_HIGH>; - resets = <&rstctrl 26>; + resets = <&sysc MT7621_RST_PCIE2>; clocks = <&sysc MT7621_CLK_PCIE2>; phys = <&pcie2_phy 0>; phy-names = "pcie-phy2"; diff --git a/target/linux/ramips/dts/mt7628an.dtsi b/target/linux/ramips/dts/mt7628an.dtsi index 8ef73dce80a..d6c3a47b0b4 100644 --- a/target/linux/ramips/dts/mt7628an.dtsi +++ b/target/linux/ramips/dts/mt7628an.dtsi @@ -38,27 +38,24 @@ #address-cells = <1>; #size-cells = <1>; - sysc: sysc@0 { - compatible = "ralink,mt7620a-sysc", "syscon"; + sysc: syscon@0 { + compatible = "ralink,mt7628-sysc", "syscon"; reg = <0x0 0x100>; + #clock-cells = <1>; + #reset-cells = <1>; }; watchdog: watchdog@100 { - compatible = "ralink,mt7628an-wdt", "mediatek,mt7621-wdt"; - reg = <0x100 0x30>; - - resets = <&rstctrl 8>; - reset-names = "wdt"; - - interrupt-parent = <&intc>; - interrupts = <24>; + compatible = "mediatek,mt7621-wdt"; + reg = <0x100 0x100>; + mediatek,sysctl = <&sysc>; }; intc: intc@200 { compatible = "ralink,mt7628an-intc", "ralink,rt2880-intc"; reg = <0x200 0x100>; - resets = <&rstctrl 9>; + resets = <&sysc 9>; reset-names = "intc"; interrupt-controller; @@ -76,7 +73,7 @@ compatible = "ralink,mt7620a-memc", "ralink,rt3050-memc"; reg = <0x300 0x100>; - resets = <&rstctrl 10>; + resets = <&sysc 10>; reset-names = "mc"; interrupt-parent = <&intc>; @@ -101,7 +98,10 @@ compatible = "mediatek,mt7621-i2c"; reg = <0x900 0x100>; - resets = <&rstctrl 16>; + clocks = <&sysc 7>; + clock-names = "i2c"; + + resets = <&sysc 16>; reset-names = "i2c"; #address-cells = <1>; @@ -117,7 +117,9 @@ compatible = "mediatek,mt7628-i2s"; reg = <0xa00 0x100>; - resets = <&rstctrl 17>; + clocks = <&sysc 8>; + + resets = <&sysc 17>; reset-names = "i2s"; interrupt-parent = <&intc>; @@ -137,7 +139,10 @@ compatible = "ralink,mt7621-spi"; reg = <0xb00 0x100>; - resets = <&rstctrl 18>; + clocks = <&sysc 9>; + clock-names = "spi"; + + resets = <&sysc 18>; reset-names = "spi"; #address-cells = <1>; @@ -149,7 +154,7 @@ status = "disabled"; }; - uartlite: uartlite@c00 { + uartlite: uart0@c00 { compatible = "ns16550a"; reg = <0xc00 0x100>; @@ -157,10 +162,9 @@ reg-io-width = <4>; no-loopback-test; - clock-frequency = <40000000>; + clocks = <&sysc 11>; - resets = <&rstctrl 12>; - reset-names = "uartl"; + resets = <&sysc 12>; interrupt-parent = <&intc>; interrupts = <20>; @@ -177,10 +181,9 @@ reg-io-width = <4>; no-loopback-test; - clock-frequency = <40000000>; + clocks = <&sysc 12>; - resets = <&rstctrl 19>; - reset-names = "uart1"; + resets = <&sysc 19>; interrupt-parent = <&intc>; interrupts = <21>; @@ -199,10 +202,9 @@ reg-io-width = <4>; no-loopback-test; - clock-frequency = <40000000>; + clocks = <&sysc 13>; - resets = <&rstctrl 20>; - reset-names = "uart2"; + resets = <&sysc 20>; interrupt-parent = <&intc>; interrupts = <22>; @@ -218,7 +220,7 @@ reg = <0x5000 0x1000>; #pwm-cells = <2>; - resets = <&rstctrl 31>; + resets = <&sysc 31>; reset-names = "pwm"; pinctrl-names = "default"; @@ -231,7 +233,7 @@ compatible = "ralink,mt7620a-pcm"; reg = <0x2000 0x800>; - resets = <&rstctrl 11>; + resets = <&sysc 11>; reset-names = "pcm"; interrupt-parent = <&intc>; @@ -244,7 +246,7 @@ compatible = "ralink,rt3883-gdma"; reg = <0x2800 0x800>; - resets = <&rstctrl 14>; + resets = <&sysc 14>; reset-names = "dma"; interrupt-parent = <&intc>; @@ -351,26 +353,15 @@ }; }; - rstctrl: rstctrl { - compatible = "ralink,mt7620a-reset", "ralink,rt2880-reset"; - #reset-cells = <1>; - }; - - clkctrl: clkctrl { - compatible = "ralink,rt2880-clock"; - #clock-cells = <1>; - }; - usbphy: usbphy@10120000 { compatible = "mediatek,mt7628-usbphy", "mediatek,mt7620-usbphy"; reg = <0x10120000 0x1000>; #phy-cells = <0>; ralink,sysctl = <&sysc>; - resets = <&rstctrl 22 &rstctrl 25>; + /* usb phy reset is only controled by RSTCTRL bit 22 */ + resets = <&sysc 22>, <&sysc 25>; reset-names = "host", "device"; - clocks = <&clkctrl 22 &clkctrl 25>; - clock-names = "host", "device"; }; sdhci: sdhci@10130000 { @@ -429,7 +420,7 @@ interrupt-parent = <&cpuintc>; interrupts = <5>; - resets = <&rstctrl 21>; + resets = <&sysc 21>; reset-names = "fe"; mediatek,switch = <&esw>; @@ -439,7 +430,7 @@ compatible = "mediatek,mt7628-esw", "ralink,rt3050-esw"; reg = <0x10110000 0x8000>; - resets = <&rstctrl 23 &rstctrl 24>; + resets = <&sysc 23>, <&sysc 24>; reset-names = "esw", "ephy"; interrupt-parent = <&intc>; @@ -457,10 +448,8 @@ interrupt-parent = <&cpuintc>; interrupts = <4>; - resets = <&rstctrl 26 &rstctrl 27>; - reset-names = "pcie0", "pcie1"; - clocks = <&clkctrl 26 &clkctrl 27>; - clock-names = "pcie0", "pcie1"; + resets = <&sysc 26>; + reset-names = "pcie0"; status = "disabled"; @@ -488,6 +477,8 @@ compatible = "mediatek,mt7628-wmac"; reg = <0x10300000 0x100000>; + clocks = <&sysc 14>; + interrupt-parent = <&cpuintc>; interrupts = <6>; diff --git a/target/linux/ramips/dts/rt2880.dtsi b/target/linux/ramips/dts/rt2880.dtsi index 9dd8f3c6e38..998b49a2770 100644 --- a/target/linux/ramips/dts/rt2880.dtsi +++ b/target/linux/ramips/dts/rt2880.dtsi @@ -38,15 +38,19 @@ #address-cells = <1>; #size-cells = <1>; - sysc: sysc@0 { - compatible = "ralink,rt2880-sysc"; - reg = <0x000 0x100>; + sysc: syscon@0 { + compatible = "ralink,rt2880-sysc", "syscon"; + reg = <0x0 0x100>; + #clock-cells = <1>; + #reset-cells = <1>; }; timer: timer@100 { compatible = "ralink,rt2880-timer"; reg = <0x100 0x20>; + clocks = <&sysc 3>; + interrupt-parent = <&intc>; interrupts = <1>; @@ -56,6 +60,8 @@ watchdog: watchdog@120 { compatible = "ralink,rt2880-wdt"; reg = <0x120 0x10>; + + clocks = <&sysc 4>; }; intc: intc@200 { @@ -124,7 +130,9 @@ compatible = "ralink,rt2880-i2c"; reg = <0x900 0x100>; - resets = <&rstctrl 9>; + clocks = <&sysc 6>; + + resets = <&sysc 9>; reset-names = "i2c"; #address-cells = <1>; @@ -140,6 +148,8 @@ compatible = "ralink,rt2880-uart", "ns16550a"; reg = <0xc00 0x100>; + clocks = <&sysc 7>; + interrupt-parent = <&intc>; interrupts = <8>; @@ -182,16 +192,6 @@ }; }; - rstctrl: rstctrl { - compatible = "ralink,rt2880-reset"; - #reset-cells = <1>; - }; - - clkctrl: clkctrl { - compatible = "ralink,rt2880-clock"; - #clock-cells = <1>; - }; - pci: pci@440000 { compatible = "ralink,rt288x-pci"; reg = <0x00440000 0x20000>; @@ -207,7 +207,9 @@ #address-cells = <1>; #size-cells = <0>; - resets = <&rstctrl 18>; + clocks = <&sysc 8>; + + resets = <&sysc 18>; reset-names = "fe"; interrupt-parent = <&cpuintc>; @@ -232,6 +234,8 @@ compatible = "ralink,rt2880-wmac"; reg = <0x480000 0x40000>; + clocks = <&sysc 9>; + interrupt-parent = <&cpuintc>; interrupts = <6>; diff --git a/target/linux/ramips/dts/rt3050.dtsi b/target/linux/ramips/dts/rt3050.dtsi index 492474fdc43..eb508ed9d34 100644 --- a/target/linux/ramips/dts/rt3050.dtsi +++ b/target/linux/ramips/dts/rt3050.dtsi @@ -39,15 +39,19 @@ #address-cells = <1>; #size-cells = <1>; - sysc: sysc@0 { + sysc: syscon@0 { compatible = "ralink,rt3050-sysc", "syscon"; reg = <0x0 0x100>; + #clock-cells = <1>; + #reset-cells = <1>; }; timer: timer@100 { compatible = "ralink,rt3050-timer", "ralink,rt2880-timer"; reg = <0x100 0x20>; + clocks = <&sysc 3>; + interrupt-parent = <&intc>; interrupts = <1>; }; @@ -56,7 +60,9 @@ compatible = "ralink,rt3050-wdt", "ralink,rt2880-wdt"; reg = <0x120 0x10>; - resets = <&rstctrl 8>; + clocks = <&sysc 4>; + + resets = <&sysc 8>; reset-names = "wdt"; interrupt-parent = <&intc>; @@ -67,7 +73,7 @@ compatible = "ralink,rt3050-intc", "ralink,rt2880-intc"; reg = <0x200 0x100>; - resets = <&rstctrl 19>; + resets = <&sysc 19>; reset-names = "intc"; interrupt-controller; @@ -81,7 +87,7 @@ compatible = "ralink,rt3050-memc"; reg = <0x300 0x100>; - resets = <&rstctrl 20>; + resets = <&sysc 20>; reset-names = "mc"; interrupt-parent = <&intc>; @@ -92,8 +98,9 @@ compatible = "ralink,rt3050-uart", "ralink,rt2880-uart", "ns16550a"; reg = <0x500 0x100>; - resets = <&rstctrl 12>; - reset-names = "uart"; + clocks = <&sysc 5>; + + resets = <&sysc 12>; interrupt-parent = <&intc>; interrupts = <5>; @@ -116,7 +123,7 @@ 20 24 28 2c 30 34 ]; - resets = <&rstctrl 13>; + resets = <&sysc 13>; reset-names = "pio"; interrupt-parent = <&intc>; @@ -159,7 +166,7 @@ compatible = "ralink,rt305x-gdma"; reg = <0x700 0x100>; - resets = <&rstctrl 14>; + resets = <&sysc 14>; reset-names = "dma"; interrupt-parent = <&intc>; @@ -176,7 +183,9 @@ compatible = "ralink,rt2880-i2c"; reg = <0x900 0x100>; - resets = <&rstctrl 16>; + clocks = <&sysc 6>; + + resets = <&sysc 16>; reset-names = "i2c"; #address-cells = <1>; @@ -192,7 +201,9 @@ compatible = "ralink,rt3050-i2s"; reg = <0xa00 0x100>; - resets = <&rstctrl 17>; + clocks = <&sysc 7>; + + resets = <&sysc 17>; reset-names = "i2s"; interrupt-parent = <&intc>; @@ -210,9 +221,11 @@ compatible = "ralink,rt3050-spi", "ralink,rt2880-spi"; reg = <0xb00 0x100>; - resets = <&rstctrl 18>; + resets = <&sysc 18>; reset-names = "spi"; + clocks = <&sysc 8>; + #address-cells = <1>; #size-cells = <0>; @@ -226,8 +239,9 @@ compatible = "ralink,rt3050-uart", "ralink,rt2880-uart", "ns16550a"; reg = <0xc00 0x100>; - resets = <&rstctrl 19>; - reset-names = "uartl"; + clocks = <&sysc 10>; + + resets = <&sysc 19>; interrupt-parent = <&intc>; interrupts = <12>; @@ -281,32 +295,22 @@ }; }; - rstctrl: rstctrl { - compatible = "ralink,rt3050-reset", "ralink,rt2880-reset"; - #reset-cells = <1>; - }; - - clkctrl: clkctrl { - compatible = "ralink,rt2880-clock"; - #clock-cells = <1>; - }; - usbphy: usbphy { compatible = "ralink,rt3050-usbphy"; #phy-cells = <0>; ralink,sysctl = <&sysc>; - resets = <&rstctrl 22>; + resets = <&sysc 22>; reset-names = "host"; - clocks = <&clkctrl 18>; - clock-names = "host"; }; ethernet: ethernet@10100000 { compatible = "ralink,rt3050-eth"; reg = <0x10100000 0x10000>; - resets = <&rstctrl 21>; + clocks = <&sysc 11>; + + resets = <&sysc 21>; reset-names = "fe"; interrupt-parent = <&cpuintc>; @@ -319,7 +323,7 @@ compatible = "ralink,rt3050-esw"; reg = <0x10110000 0x8000>; - resets = <&rstctrl 23 &rstctrl 24>; + resets = <&sysc 23>, <&sysc 24>; reset-names = "esw", "ephy"; interrupt-parent = <&intc>; @@ -330,6 +334,8 @@ compatible = "ralink,rt3050-wmac", "ralink,rt2880-wmac"; reg = <0x10180000 0x40000>; + clocks = <&sysc 12>; + interrupt-parent = <&cpuintc>; interrupts = <6>; @@ -345,7 +351,7 @@ interrupt-parent = <&intc>; interrupts = <18>; - resets = <&rstctrl 22>; + resets = <&sysc 22>; reset-names = "otg"; status = "disabled"; diff --git a/target/linux/ramips/dts/rt3352.dtsi b/target/linux/ramips/dts/rt3352.dtsi index 608222cb5c9..df077767237 100644 --- a/target/linux/ramips/dts/rt3352.dtsi +++ b/target/linux/ramips/dts/rt3352.dtsi @@ -40,15 +40,19 @@ #address-cells = <1>; #size-cells = <1>; - sysc: sysc@0 { - compatible = "ralink,rt3352-sysc", "ralink,rt3050-sysc", "syscon"; + sysc: syscon@0 { + compatible = "ralink,rt3352-sysc", "syscon"; reg = <0x0 0x100>; + #clock-cells = <1>; + #reset-cells = <1>; }; timer: timer@100 { compatible = "ralink,rt3352-timer", "ralink,rt2880-timer"; reg = <0x100 0x20>; + clocks = <&sysc 4>; + interrupt-parent = <&intc>; interrupts = <1>; }; @@ -57,7 +61,9 @@ compatible = "ralink,rt3352-wdt", "ralink,rt2880-wdt"; reg = <0x120 0x10>; - resets = <&rstctrl 8>; + clocks = <&sysc 5>; + + resets = <&sysc 8>; reset-names = "wdt"; interrupt-parent = <&intc>; @@ -79,7 +85,7 @@ compatible = "ralink,rt3352-memc", "ralink,rt3050-memc"; reg = <0x300 0x100>; - resets = <&rstctrl 20>; + resets = <&sysc 20>; reset-names = "mc"; interrupt-parent = <&intc>; @@ -90,8 +96,9 @@ compatible = "ralink,rt3352-uart", "ralink,rt2880-uart", "ns16550a"; reg = <0x500 0x100>; - resets = <&rstctrl 12>; - reset-names = "uart"; + clocks = <&sysc 6>; + + resets = <&sysc 12>; interrupt-parent = <&intc>; interrupts = <5>; @@ -113,7 +120,7 @@ ralink,register-map = [ 00 04 08 0c 20 24 28 2c 30 34 ]; - resets = <&rstctrl 13>; + resets = <&sysc 13>; reset-names = "pio"; interrupt-parent = <&intc>; @@ -156,7 +163,9 @@ compatible = "ralink,rt2880-i2c"; reg = <0x900 0x100>; - resets = <&rstctrl 16>; + clocks = <&sysc 7>; + + resets = <&sysc 16>; reset-names = "i2c"; #address-cells = <1>; @@ -172,7 +181,9 @@ compatible = "ralink,rt3352-i2s"; reg = <0xa00 0x100>; - resets = <&rstctrl 17>; + clocks = <&sysc 8>; + + resets = <&sysc 17>; reset-names = "i2s"; interrupt-parent = <&intc>; @@ -194,7 +205,9 @@ #address-cells = <1>; #size-cells = <0>; - resets = <&rstctrl 18>; + clocks = <&sysc 9>; + + resets = <&sysc 18>; reset-names = "spi"; pinctrl-names = "default"; @@ -209,7 +222,7 @@ #address-cells = <1>; #size-cells = <0>; - resets = <&rstctrl 18>; + resets = <&sysc 18>; reset-names = "spi"; pinctrl-names = "default"; @@ -222,8 +235,9 @@ compatible = "ralink,rt3352-uart", "ralink,rt2880-uart", "ns16550a"; reg = <0xc00 0x100>; - resets = <&rstctrl 19>; - reset-names = "uartl"; + clocks = <&sysc 11>; + + resets = <&sysc 19>; interrupt-parent = <&intc>; interrupts = <12>; @@ -238,7 +252,7 @@ compatible = "ralink,rt3883-gdma"; reg = <0x2800 0x800>; - resets = <&rstctrl 14>; + resets = <&sysc 14>; reset-names = "dma"; interrupt-parent = <&intc>; @@ -304,21 +318,13 @@ }; }; - rstctrl: rstctrl { - compatible = "ralink,rt3352-reset", "ralink,rt2880-reset"; - #reset-cells = <1>; - }; - - clkctrl: clkctrl { - compatible = "ralink,rt2880-clock"; - #clock-cells = <1>; - }; - ethernet: ethernet@10100000 { compatible = "ralink,rt3352-eth", "ralink,rt3050-eth"; reg = <0x10100000 0x10000>; - resets = <&rstctrl 21>; + clocks = <&sysc 12>; + + resets = <&sysc 21>; reset-names = "fe"; interrupt-parent = <&cpuintc>; @@ -331,7 +337,7 @@ compatible = "ralink,rt3352-esw", "ralink,rt3050-esw"; reg = <0x10110000 0x8000>; - resets = <&rstctrl 23 &rstctrl 24>; + resets = <&sysc 23>, <&sysc 24>; reset-names = "esw", "ephy"; interrupt-parent = <&intc>; @@ -343,16 +349,16 @@ #phy-cells = <0>; ralink,sysctl = <&sysc>; - resets = <&rstctrl 22 &rstctrl 25>; + resets = <&sysc 22>, <&sysc 25>; reset-names = "host", "device"; - clocks = <&clkctrl 18 &clkctrl 20>; - clock-names = "host", "device"; }; wmac: wmac@10180000 { compatible = "ralink,rt3352-wmac", "ralink,rt2880-wmac"; reg = <0x10180000 0x40000>; + clocks = <&sysc 13>; + interrupt-parent = <&cpuintc>; interrupts = <6>; diff --git a/target/linux/ramips/dts/rt3883.dtsi b/target/linux/ramips/dts/rt3883.dtsi index 158640bf925..d490d700d60 100644 --- a/target/linux/ramips/dts/rt3883.dtsi +++ b/target/linux/ramips/dts/rt3883.dtsi @@ -40,15 +40,19 @@ #address-cells = <1>; #size-cells = <1>; - sysc: sysc@0 { - compatible = "ralink,rt3883-sysc", "ralink,rt3050-sysc", "syscon"; + sysc: syscon@0 { + compatible = "ralink,rt3883-sysc", "syscon"; reg = <0x0 0x100>; + #clock-cells = <1>; + #reset-cells = <1>; }; timer: timer@100 { compatible = "ralink,rt3883-timer", "ralink,rt2880-timer"; reg = <0x100 0x20>; + clocks = <&sysc 3>; + interrupt-parent = <&intc>; interrupts = <1>; }; @@ -57,7 +61,9 @@ compatible = "ralink,rt3883-wdt", "ralink,rt2880-wdt"; reg = <0x120 0x10>; - resets = <&rstctrl 8>; + clocks = <&sysc 4>; + + resets = <&sysc 8>; reset-names = "wdt"; interrupt-parent = <&intc>; @@ -68,7 +74,7 @@ compatible = "ralink,rt3883-intc", "ralink,rt2880-intc"; reg = <0x200 0x100>; - resets = <&rstctrl 19>; + resets = <&sysc 19>; reset-names = "intc"; interrupt-controller; @@ -82,7 +88,7 @@ compatible = "ralink,rt3883-memc", "ralink,rt3050-memc"; reg = <0x300 0x100>; - resets = <&rstctrl 20>; + resets = <&sysc 20>; reset-names = "mc"; interrupt-parent = <&intc>; @@ -93,8 +99,9 @@ compatible = "ralink,rt3883-uart", "ralink,rt2880-uart", "ns16550a"; reg = <0x500 0x100>; - resets = <&rstctrl 12>; - reset-names = "uart"; + clocks = <&sysc 5>; + + resets = <&sysc 12>; interrupt-parent = <&intc>; interrupts = <5>; @@ -108,7 +115,7 @@ compatible = "ralink,rt3883-gpio", "ralink,rt2880-gpio"; reg = <0x600 0x34>; - resets = <&rstctrl 13>; + resets = <&sysc 13>; reset-names = "pio"; interrupt-parent = <&intc>; @@ -176,7 +183,9 @@ compatible = "ralink,rt2880-i2c"; reg = <0x900 0x100>; - resets = <&rstctrl 16>; + clocks = <&sysc 6>; + + resets = <&sysc 16>; reset-names = "i2c"; #address-cells = <1>; @@ -192,7 +201,9 @@ compatible = "ralink,rt3883-i2s"; reg = <0xa00 0x100>; - resets = <&rstctrl 17>; + clocks = <&sysc 7>; + + resets = <&sysc 17>; reset-names = "i2s"; interrupt-parent = <&intc>; @@ -214,7 +225,9 @@ #address-cells = <1>; #size-cells = <0>; - resets = <&rstctrl 18>; + clocks = <&sysc 8>; + + resets = <&sysc 18>; reset-names = "spi"; pinctrl-names = "default"; @@ -229,7 +242,9 @@ #address-cells = <1>; #size-cells = <0>; - resets = <&rstctrl 18>; + clocks = <&sysc 9>; + + resets = <&sysc 18>; reset-names = "spi"; pinctrl-names = "default"; @@ -242,8 +257,9 @@ compatible = "ralink,rt3883-uart", "ralink,rt2880-uart", "ns16550a"; reg = <0xc00 0x100>; - resets = <&rstctrl 19>; - reset-names = "uartl"; + clocks = <&sysc 10>; + + resets = <&sysc 19>; interrupt-parent = <&intc>; interrupts = <12>; @@ -258,7 +274,7 @@ compatible = "ralink,rt3883-gdma"; reg = <0x2800 0x800>; - resets = <&rstctrl 14>; + resets = <&sysc 14>; reset-names = "dma"; interrupt-parent = <&intc>; @@ -323,7 +339,9 @@ #size-cells = <0>; reg = <0x10100000 0x10000>; - resets = <&rstctrl 21>; + clocks = <&sysc 11>; + + resets = <&sysc 21>; reset-names = "fe"; interrupt-parent = <&cpuintc>; @@ -342,16 +360,6 @@ }; }; - rstctrl: rstctrl { - compatible = "ralink,rt3883-reset", "ralink,rt2880-reset"; - #reset-cells = <1>; - }; - - clkctrl: clkctrl { - compatible = "ralink,rt2880-clock"; - #clock-cells = <1>; - }; - pci: pci@10140000 { compatible = "ralink,rt3883-pci"; reg = <0x10140000 0x20000>; @@ -441,16 +449,16 @@ #phy-cells = <0>; ralink,sysctl = <&sysc>; - resets = <&rstctrl 22 &rstctrl 25>; + resets = <&sysc 22>, <&sysc 25>; reset-names = "host", "device"; - clocks = <&clkctrl 22 &clkctrl 25>; - clock-names = "host", "device"; }; wmac: wmac@10180000 { compatible = "ralink,rt3883-wmac", "ralink,rt2880-wmac"; reg = <0x10180000 0x40000>; + clocks = <&sysc 12>; + interrupt-parent = <&cpuintc>; interrupts = <6>; diff --git a/target/linux/ramips/dts/rt5350.dtsi b/target/linux/ramips/dts/rt5350.dtsi index 090e755743b..1286dec9d88 100644 --- a/target/linux/ramips/dts/rt5350.dtsi +++ b/target/linux/ramips/dts/rt5350.dtsi @@ -40,15 +40,19 @@ #address-cells = <1>; #size-cells = <1>; - sysc: sysc@0 { - compatible = "ralink,rt5350-sysc", "ralink,rt3050-sysc", "syscon"; + sysc: syscon@0 { + compatible = "ralink,rt5350-sysc", "syscon"; reg = <0x0 0x100>; + #clock-cells = <1>; + #reset-cells = <1>; }; timer: timer@100 { compatible = "ralink,rt5350-timer", "ralink,rt2880-timer"; reg = <0x100 0x20>; + clocks = <&sysc 4>; + interrupt-parent = <&intc>; interrupts = <1>; }; @@ -57,7 +61,9 @@ compatible = "ralink,rt5350-wdt", "ralink,rt2880-wdt"; reg = <0x120 0x10>; - resets = <&rstctrl 8>; + clocks = <&sysc 5>; + + resets = <&sysc 8>; reset-names = "wdt"; interrupt-parent = <&intc>; @@ -68,7 +74,7 @@ compatible = "ralink,rt5350-intc", "ralink,rt2880-intc"; reg = <0x200 0x100>; - resets = <&rstctrl 19>; + resets = <&sysc 19>; reset-names = "intc"; interrupt-controller; @@ -82,7 +88,7 @@ compatible = "ralink,rt5350-memc", "ralink,rt3050-memc"; reg = <0x300 0x100>; - resets = <&rstctrl 20>; + resets = <&sysc 20>; reset-names = "mc"; interrupt-parent = <&intc>; @@ -93,8 +99,9 @@ compatible = "ralink,rt5350-uart", "ralink,rt2880-uart", "ns16550a"; reg = <0x500 0x100>; - resets = <&rstctrl 12>; - reset-names = "uart"; + clocks = <&sysc 6>; + + resets = <&sysc 12>; interrupt-parent = <&intc>; interrupts = <5>; @@ -108,7 +115,7 @@ compatible = "ralink,rt5350-gpio", "ralink,rt2880-gpio"; reg = <0x600 0x34>; - resets = <&rstctrl 13>; + resets = <&sysc 13>; reset-names = "pio"; interrupt-parent = <&intc>; @@ -147,7 +154,9 @@ compatible = "ralink,rt2880-i2c"; reg = <0x900 0x100>; - resets = <&rstctrl 16>; + clocks = <&sysc 7>; + + resets = <&sysc 16>; reset-names = "i2c"; #address-cells = <1>; @@ -163,7 +172,9 @@ compatible = "ralink,rt3352-i2s"; reg = <0xa00 0x100>; - resets = <&rstctrl 17>; + clocks = <&sysc 8>; + + resets = <&sysc 17>; reset-names = "i2s"; interrupt-parent = <&intc>; @@ -183,7 +194,9 @@ compatible = "ralink,rt5350-spi", "ralink,rt2880-spi"; reg = <0xb00 0x40>; - resets = <&rstctrl 18>; + clocks = <&sysc 9>; + + resets = <&sysc 18>; reset-names = "spi"; #address-cells = <1>; @@ -199,7 +212,9 @@ compatible = "ralink,rt5350-spi", "ralink,rt2880-spi"; reg = <0xb40 0x60>; - resets = <&rstctrl 18>; + clocks = <&sysc 10>; + + resets = <&sysc 18>; reset-names = "spi"; #address-cells = <1>; @@ -215,8 +230,9 @@ compatible = "ralink,rt5350-uart", "ralink,rt2880-uart", "ns16550a"; reg = <0xc00 0x100>; - resets = <&rstctrl 19>; - reset-names = "uartl"; + clocks = <&sysc 11>; + + resets = <&sysc 19>; interrupt-parent = <&intc>; interrupts = <12>; @@ -239,7 +255,7 @@ compatible = "ralink,rt5350-pcm"; reg = <0x2000 0x800>; - resets = <&rstctrl 11>; + resets = <&sysc 11>; reset-names = "pcm"; interrupt-parent = <&intc>; @@ -252,7 +268,7 @@ compatible = "ralink,rt3883-gdma"; reg = <0x2800 0x800>; - resets = <&rstctrl 14>; + resets = <&sysc 14>; reset-names = "dma"; interrupt-parent = <&intc>; @@ -318,32 +334,22 @@ }; }; - rstctrl: rstctrl { - compatible = "ralink,rt5350-reset", "ralink,rt2880-reset"; - #reset-cells = <1>; - }; - - clkctrl: clkctrl { - compatible = "ralink,rt2880-clock"; - #clock-cells = <1>; - }; - usbphy: usbphy { compatible = "ralink,rt3352-usbphy"; #phy-cells = <0>; ralink,sysctl = <&sysc>; - resets = <&rstctrl 22 &rstctrl 25>; + resets = <&sysc 22>, <&sysc 25>; reset-names = "host", "device"; - clocks = <&clkctrl 18>; - clock-names = "host"; }; ethernet: ethernet@10100000 { compatible = "ralink,rt5350-eth"; reg = <0x10100000 0x10000>; - resets = <&rstctrl 21>; + clocks = <&sysc 12>; + + resets = <&sysc 21>; reset-names = "fe"; interrupt-parent = <&cpuintc>; @@ -356,7 +362,7 @@ compatible = "ralink,rt5350-esw", "ralink,rt3050-esw"; reg = <0x10110000 0x8000>; - resets = <&rstctrl 23 &rstctrl 24>; + resets = <&sysc 23>, <&sysc 24>; reset-names = "esw", "ephy"; interrupt-parent = <&intc>; @@ -367,6 +373,8 @@ compatible = "ralink,rt5350-wmac", "ralink,rt2880-wmac"; reg = <0x10180000 0x40000>; + clocks = <&sysc 13>; + interrupt-parent = <&cpuintc>; interrupts = <6>; diff --git a/target/linux/ramips/mt7620/config-5.15 b/target/linux/ramips/mt7620/config-5.15 index fdca30fecbf..641b93e5826 100644 --- a/target/linux/ramips/mt7620/config-5.15 +++ b/target/linux/ramips/mt7620/config-5.15 @@ -10,6 +10,7 @@ CONFIG_CEVT_R4K=y CONFIG_CEVT_SYSTICK_QUIRK=y CONFIG_CLKEVT_RT3352=y CONFIG_CLKSRC_MMIO=y +CONFIG_CLK_MTMIPS=y CONFIG_CLONE_BACKWARDS=y CONFIG_CMDLINE="rootfstype=squashfs,jffs2" CONFIG_CMDLINE_BOOL=y diff --git a/target/linux/ramips/mt76x8/config-5.15 b/target/linux/ramips/mt76x8/config-5.15 index 7248aa66332..bd1d3688b82 100644 --- a/target/linux/ramips/mt76x8/config-5.15 +++ b/target/linux/ramips/mt76x8/config-5.15 @@ -10,6 +10,7 @@ CONFIG_CEVT_R4K=y CONFIG_CEVT_SYSTICK_QUIRK=y CONFIG_CLKEVT_RT3352=y CONFIG_CLKSRC_MMIO=y +CONFIG_CLK_MTMIPS=y CONFIG_CLONE_BACKWARDS=y CONFIG_CMDLINE="rootfstype=squashfs,jffs2" CONFIG_CMDLINE_BOOL=y diff --git a/target/linux/ramips/patches-5.15/000-v5.18-01-dt-bindings-reset-add-dt-binding-header-for-Mediatek.patch b/target/linux/ramips/patches-5.15/000-v5.18-01-dt-bindings-reset-add-dt-binding-header-for-Mediatek.patch new file mode 100644 index 00000000000..a102c607b6d --- /dev/null +++ b/target/linux/ramips/patches-5.15/000-v5.18-01-dt-bindings-reset-add-dt-binding-header-for-Mediatek.patch @@ -0,0 +1,60 @@ +From f383b0770612838e78986231710c0a3afee4db42 Mon Sep 17 00:00:00 2001 +From: Sergio Paracuellos +Date: Mon, 10 Jan 2022 12:49:27 +0100 +Subject: [PATCH 1/2] dt-bindings: reset: add dt binding header for Mediatek MT7621 resets +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Add dt binding header for resets lines in Mediatek MT7621 SoCs. + +Acked-by: Rob Herring +Tested-by: Arınç ÜNAL +Signed-off-by: Sergio Paracuellos +Link: https://lore.kernel.org/r/20220110114930.1406665-2-sergio.paracuellos@gmail.com +Signed-off-by: Greg Kroah-Hartman +--- + include/dt-bindings/reset/mt7621-reset.h | 37 ++++++++++++++++++++++++++++++++ + 1 file changed, 37 insertions(+) + create mode 100644 include/dt-bindings/reset/mt7621-reset.h + +--- /dev/null ++++ b/include/dt-bindings/reset/mt7621-reset.h +@@ -0,0 +1,37 @@ ++/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */ ++/* ++ * Copyright (c) 2021 Sergio Paracuellos ++ * Author: Sergio Paracuellos ++ */ ++ ++#ifndef DT_BINDING_MT7621_RESET_H ++#define DT_BINDING_MT7621_RESET_H ++ ++#define MT7621_RST_SYS 0 ++#define MT7621_RST_MCM 2 ++#define MT7621_RST_HSDMA 5 ++#define MT7621_RST_FE 6 ++#define MT7621_RST_SPDIFTX 7 ++#define MT7621_RST_TIMER 8 ++#define MT7621_RST_INT 9 ++#define MT7621_RST_MC 10 ++#define MT7621_RST_PCM 11 ++#define MT7621_RST_PIO 13 ++#define MT7621_RST_GDMA 14 ++#define MT7621_RST_NFI 15 ++#define MT7621_RST_I2C 16 ++#define MT7621_RST_I2S 17 ++#define MT7621_RST_SPI 18 ++#define MT7621_RST_UART1 19 ++#define MT7621_RST_UART2 20 ++#define MT7621_RST_UART3 21 ++#define MT7621_RST_ETH 23 ++#define MT7621_RST_PCIE0 24 ++#define MT7621_RST_PCIE1 25 ++#define MT7621_RST_PCIE2 26 ++#define MT7621_RST_AUX_STCK 28 ++#define MT7621_RST_CRYPTO 29 ++#define MT7621_RST_SDXC 30 ++#define MT7621_RST_PPE 31 ++ ++#endif /* DT_BINDING_MT7621_RESET_H */ diff --git a/target/linux/ramips/patches-5.15/000-v5.18-02-staging-mt7621-dts-align-resets-with-binding-documen.patch b/target/linux/ramips/patches-5.15/000-v5.18-02-staging-mt7621-dts-align-resets-with-binding-documen.patch new file mode 100644 index 00000000000..e4fd34b28cf --- /dev/null +++ b/target/linux/ramips/patches-5.15/000-v5.18-02-staging-mt7621-dts-align-resets-with-binding-documen.patch @@ -0,0 +1,114 @@ +From 64b2d6ffff862c0e7278198b4229e42e1abb3bb1 Mon Sep 17 00:00:00 2001 +From: Sergio Paracuellos +Date: Mon, 10 Jan 2022 12:49:30 +0100 +Subject: [PATCH 2/2] staging: mt7621-dts: align resets with binding documentation +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Binding documentation for compatible 'mediatek,mt7621-sysc' has been updated +to be used as a reset provider. Align reset related bits and system controller +node with binding documentation along the dtsi file. + +Tested-by: Arınç ÜNAL +Reviewed-by: Philipp Zabel +Signed-off-by: Sergio Paracuellos +Link: https://lore.kernel.org/r/20220110114930.1406665-5-sergio.paracuellos@gmail.com +Signed-off-by: Greg Kroah-Hartman +--- + drivers/staging/mt7621-dts/mt7621.dtsi | 21 +++++++++------------ + 1 file changed, 9 insertions(+), 12 deletions(-) + +--- a/drivers/staging/mt7621-dts/mt7621.dtsi ++++ b/drivers/staging/mt7621-dts/mt7621.dtsi +@@ -1,6 +1,7 @@ + #include + #include + #include ++#include + + / { + #address-cells = <1>; +@@ -59,6 +60,7 @@ + compatible = "mediatek,mt7621-sysc", "syscon"; + reg = <0x0 0x100>; + #clock-cells = <1>; ++ #reset-cells = <1>; + ralink,memctl = <&memc>; + clock-output-names = "xtal", "cpu", "bus", + "50m", "125m", "150m", +@@ -88,7 +90,7 @@ + + clocks = <&sysc MT7621_CLK_I2C>; + clock-names = "i2c"; +- resets = <&rstctrl 16>; ++ resets = <&sysc MT7621_RST_I2C>; + reset-names = "i2c"; + + #address-cells = <1>; +@@ -161,7 +163,7 @@ + clocks = <&sysc MT7621_CLK_SPI>; + clock-names = "spi"; + +- resets = <&rstctrl 18>; ++ resets = <&sysc MT7621_RST_SPI>; + reset-names = "spi"; + + #address-cells = <1>; +@@ -296,11 +298,6 @@ + }; + }; + +- rstctrl: rstctrl { +- compatible = "ralink,rt2880-reset"; +- #reset-cells = <1>; +- }; +- + sdhci: sdhci@1e130000 { + status = "disabled"; + +@@ -383,7 +380,7 @@ + #address-cells = <1>; + #size-cells = <0>; + +- resets = <&rstctrl 6 &rstctrl 23>; ++ resets = <&sysc MT7621_RST_FE &sysc MT7621_RST_ETH>; + reset-names = "fe", "eth"; + + interrupt-parent = <&gic>; +@@ -423,7 +420,7 @@ + #size-cells = <0>; + reg = <0>; + mediatek,mcm; +- resets = <&rstctrl 2>; ++ resets = <&sysc MT7621_RST_MCM>; + reset-names = "mcm"; + interrupt-controller; + #interrupt-cells = <1>; +@@ -516,7 +513,7 @@ + #interrupt-cells = <1>; + interrupt-map-mask = <0 0 0 0>; + interrupt-map = <0 0 0 0 &gic GIC_SHARED 4 IRQ_TYPE_LEVEL_HIGH>; +- resets = <&rstctrl 24>; ++ resets = <&sysc MT7621_RST_PCIE0>; + clocks = <&sysc MT7621_CLK_PCIE0>; + phys = <&pcie0_phy 1>; + phy-names = "pcie-phy0"; +@@ -531,7 +528,7 @@ + #interrupt-cells = <1>; + interrupt-map-mask = <0 0 0 0>; + interrupt-map = <0 0 0 0 &gic GIC_SHARED 24 IRQ_TYPE_LEVEL_HIGH>; +- resets = <&rstctrl 25>; ++ resets = <&sysc MT7621_RST_PCIE1>; + clocks = <&sysc MT7621_CLK_PCIE1>; + phys = <&pcie0_phy 1>; + phy-names = "pcie-phy1"; +@@ -546,7 +543,7 @@ + #interrupt-cells = <1>; + interrupt-map-mask = <0 0 0 0>; + interrupt-map = <0 0 0 0 &gic GIC_SHARED 25 IRQ_TYPE_LEVEL_HIGH>; +- resets = <&rstctrl 26>; ++ resets = <&sysc MT7621_RST_PCIE2>; + clocks = <&sysc MT7621_CLK_PCIE2>; + phys = <&pcie2_phy 0>; + phy-names = "pcie-phy2"; diff --git a/target/linux/ramips/patches-5.15/001-v5.18-01-dt-bindings-clock-mediatek-mt7621-sysc-add-reset-cel.patch b/target/linux/ramips/patches-5.15/001-v5.18-01-dt-bindings-clock-mediatek-mt7621-sysc-add-reset-cel.patch new file mode 100644 index 00000000000..7fb95064f08 --- /dev/null +++ b/target/linux/ramips/patches-5.15/001-v5.18-01-dt-bindings-clock-mediatek-mt7621-sysc-add-reset-cel.patch @@ -0,0 +1,52 @@ +From 478b09fa2c00cbc40d25bc061befdf11f04a27ad Mon Sep 17 00:00:00 2001 +From: Sergio Paracuellos +Date: Thu, 10 Feb 2022 10:48:58 +0100 +Subject: [PATCH 1/2] dt-bindings: clock: mediatek,mt7621-sysc: add '#reset-cells' property + +Make system controller a reset provider for all the peripherals in the +MT7621 SoC adding '#reset-cells' property. + +Acked-by: Rob Herring +Acked-by: Stephen Boyd +Signed-off-by: Sergio Paracuellos +Link: https://lore.kernel.org/r/20220210094859.927868-2-sergio.paracuellos@gmail.com +Signed-off-by: Greg Kroah-Hartman +--- + .../devicetree/bindings/clock/mediatek,mt7621-sysc.yaml | 12 ++++++++++++ + 1 file changed, 12 insertions(+) + +--- a/Documentation/devicetree/bindings/clock/mediatek,mt7621-sysc.yaml ++++ b/Documentation/devicetree/bindings/clock/mediatek,mt7621-sysc.yaml +@@ -22,6 +22,11 @@ description: | + + The clocks are provided inside a system controller node. + ++ This node is also a reset provider for all the peripherals. ++ ++ Reset related bits are defined in: ++ [2]: . ++ + properties: + compatible: + items: +@@ -37,6 +42,12 @@ properties: + clocks. + const: 1 + ++ "#reset-cells": ++ description: ++ The first cell indicates the reset bit within the register, see ++ [2] for available resets. ++ const: 1 ++ + ralink,memctl: + $ref: /schemas/types.yaml#/definitions/phandle + description: +@@ -61,6 +72,7 @@ examples: + compatible = "mediatek,mt7621-sysc", "syscon"; + reg = <0x0 0x100>; + #clock-cells = <1>; ++ #reset-cells = <1>; + ralink,memctl = <&memc>; + clock-output-names = "xtal", "cpu", "bus", + "50m", "125m", "150m", diff --git a/target/linux/ramips/patches-5.15/001-v5.18-02-clk-ralink-make-system-controller-node-a-reset-provi.patch b/target/linux/ramips/patches-5.15/001-v5.18-02-clk-ralink-make-system-controller-node-a-reset-provi.patch new file mode 100644 index 00000000000..c70a1c9bbcb --- /dev/null +++ b/target/linux/ramips/patches-5.15/001-v5.18-02-clk-ralink-make-system-controller-node-a-reset-provi.patch @@ -0,0 +1,148 @@ +From 38a8553b0a22ed54f014d8402fedd268b529175c Mon Sep 17 00:00:00 2001 +From: Sergio Paracuellos +Date: Thu, 10 Feb 2022 10:48:59 +0100 +Subject: [PATCH 2/2] clk: ralink: make system controller node a reset provider + +MT7621 system controller node is already providing the clocks for the whole +system but must also serve as a reset provider. Hence, add reset controller +related code to the clock driver itself. To get resets properly ready for +the rest of the world we need to move platform driver initialization process +to 'arch_initcall'. + +CC: Philipp Zabel +Reviewed-by: Philipp Zabel +Acked-by: Stephen Boyd +Signed-off-by: Sergio Paracuellos +Link: https://lore.kernel.org/r/20220210094859.927868-3-sergio.paracuellos@gmail.com +Signed-off-by: Greg Kroah-Hartman +--- + drivers/clk/ralink/clk-mt7621.c | 92 ++++++++++++++++++++++++++++++++++++++++- + 1 file changed, 91 insertions(+), 1 deletion(-) + +--- a/drivers/clk/ralink/clk-mt7621.c ++++ b/drivers/clk/ralink/clk-mt7621.c +@@ -11,14 +11,17 @@ + #include + #include + #include ++#include + #include + #include ++#include + + /* Configuration registers */ + #define SYSC_REG_SYSTEM_CONFIG0 0x10 + #define SYSC_REG_SYSTEM_CONFIG1 0x14 + #define SYSC_REG_CLKCFG0 0x2c + #define SYSC_REG_CLKCFG1 0x30 ++#define SYSC_REG_RESET_CTRL 0x34 + #define SYSC_REG_CUR_CLK_STS 0x44 + #define MEMC_REG_CPU_PLL 0x648 + +@@ -398,6 +401,82 @@ free_clk_priv: + } + CLK_OF_DECLARE_DRIVER(mt7621_clk, "mediatek,mt7621-sysc", mt7621_clk_init); + ++struct mt7621_rst { ++ struct reset_controller_dev rcdev; ++ struct regmap *sysc; ++}; ++ ++static struct mt7621_rst *to_mt7621_rst(struct reset_controller_dev *dev) ++{ ++ return container_of(dev, struct mt7621_rst, rcdev); ++} ++ ++static int mt7621_assert_device(struct reset_controller_dev *rcdev, ++ unsigned long id) ++{ ++ struct mt7621_rst *data = to_mt7621_rst(rcdev); ++ struct regmap *sysc = data->sysc; ++ ++ return regmap_update_bits(sysc, SYSC_REG_RESET_CTRL, BIT(id), BIT(id)); ++} ++ ++static int mt7621_deassert_device(struct reset_controller_dev *rcdev, ++ unsigned long id) ++{ ++ struct mt7621_rst *data = to_mt7621_rst(rcdev); ++ struct regmap *sysc = data->sysc; ++ ++ return regmap_update_bits(sysc, SYSC_REG_RESET_CTRL, BIT(id), 0); ++} ++ ++static int mt7621_reset_device(struct reset_controller_dev *rcdev, ++ unsigned long id) ++{ ++ int ret; ++ ++ ret = mt7621_assert_device(rcdev, id); ++ if (ret < 0) ++ return ret; ++ ++ return mt7621_deassert_device(rcdev, id); ++} ++ ++static int mt7621_rst_xlate(struct reset_controller_dev *rcdev, ++ const struct of_phandle_args *reset_spec) ++{ ++ unsigned long id = reset_spec->args[0]; ++ ++ if (id == MT7621_RST_SYS || id >= rcdev->nr_resets) ++ return -EINVAL; ++ ++ return id; ++} ++ ++static const struct reset_control_ops reset_ops = { ++ .reset = mt7621_reset_device, ++ .assert = mt7621_assert_device, ++ .deassert = mt7621_deassert_device ++}; ++ ++static int mt7621_reset_init(struct device *dev, struct regmap *sysc) ++{ ++ struct mt7621_rst *rst_data; ++ ++ rst_data = devm_kzalloc(dev, sizeof(*rst_data), GFP_KERNEL); ++ if (!rst_data) ++ return -ENOMEM; ++ ++ rst_data->sysc = sysc; ++ rst_data->rcdev.ops = &reset_ops; ++ rst_data->rcdev.owner = THIS_MODULE; ++ rst_data->rcdev.nr_resets = 32; ++ rst_data->rcdev.of_reset_n_cells = 1; ++ rst_data->rcdev.of_xlate = mt7621_rst_xlate; ++ rst_data->rcdev.of_node = dev_of_node(dev); ++ ++ return devm_reset_controller_register(dev, &rst_data->rcdev); ++} ++ + static int mt7621_clk_probe(struct platform_device *pdev) + { + struct device_node *np = pdev->dev.of_node; +@@ -424,6 +503,12 @@ static int mt7621_clk_probe(struct platf + return ret; + } + ++ ret = mt7621_reset_init(dev, priv->sysc); ++ if (ret) { ++ dev_err(dev, "Could not init reset controller\n"); ++ return ret; ++ } ++ + count = ARRAY_SIZE(mt7621_clks_base) + + ARRAY_SIZE(mt7621_fixed_clks) + ARRAY_SIZE(mt7621_gates); + clk_data = devm_kzalloc(dev, struct_size(clk_data, hws, count), +@@ -485,4 +570,9 @@ static struct platform_driver mt7621_clk + .of_match_table = mt7621_clk_of_match, + }, + }; +-builtin_platform_driver(mt7621_clk_driver); ++ ++static int __init mt7621_clk_reset_init(void) ++{ ++ return platform_driver_register(&mt7621_clk_driver); ++} ++arch_initcall(mt7621_clk_reset_init); diff --git a/target/linux/ramips/patches-5.15/002-v6.0-MIPS-ralink-mt7621-avoid-to-init-common-ralink-reset.patch b/target/linux/ramips/patches-5.15/002-v6.0-MIPS-ralink-mt7621-avoid-to-init-common-ralink-reset.patch new file mode 100644 index 00000000000..cef73c6eae9 --- /dev/null +++ b/target/linux/ramips/patches-5.15/002-v6.0-MIPS-ralink-mt7621-avoid-to-init-common-ralink-reset.patch @@ -0,0 +1,43 @@ +From bb3ababe7f986900672e0048153c31aa4a21f96b Mon Sep 17 00:00:00 2001 +From: Sergio Paracuellos +Date: Sat, 17 Dec 2022 08:48:06 +0100 +Subject: [PATCH] MIPS: ralink: mt7621: avoid to init common ralink reset controller + +[ Upstream commit 76ce51798cb16738a4a28a6662e7344aaf7ef769 ] + +Commit 38a8553b0a22 ("clk: ralink: make system controller node a reset provider") +make system controller a reset provider for mt7621 ralink SoCs. Ralink init code +also tries to start previous common reset controller which at the end tries to +find device tree node 'ralink,rt2880-reset'. mt7621 device tree file is not +using at all this node anymore. Hence avoid to init this common reset controller +for mt7621 ralink SoCs to avoid 'Failed to find reset controller node' boot +error trace error. + +Fixes: 64b2d6ffff86 ("staging: mt7621-dts: align resets with binding documentation") +Signed-off-by: Sergio Paracuellos +Signed-off-by: Thomas Bogendoerfer +Signed-off-by: Sasha Levin +--- + arch/mips/ralink/of.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +--- a/arch/mips/ralink/of.c ++++ b/arch/mips/ralink/of.c +@@ -21,6 +21,7 @@ + #include + #include + #include ++#include + + #include "common.h" + +@@ -95,7 +96,8 @@ static int __init plat_of_setup(void) + __dt_register_buses(soc_info.compatible, "palmbus"); + + /* make sure that the reset controller is setup early */ +- ralink_rst_init(); ++ if (ralink_soc != MT762X_SOC_MT7621AT) ++ ralink_rst_init(); + + return 0; + } diff --git a/target/linux/ramips/patches-5.15/003-v6.3-clk-ralink-fix-mt7621_gate_is_enabled-function.patch b/target/linux/ramips/patches-5.15/003-v6.3-clk-ralink-fix-mt7621_gate_is_enabled-function.patch new file mode 100644 index 00000000000..4574f7977fa --- /dev/null +++ b/target/linux/ramips/patches-5.15/003-v6.3-clk-ralink-fix-mt7621_gate_is_enabled-function.patch @@ -0,0 +1,77 @@ +From 35dcae535afc153fa83f2fe51c0812536c192c58 Mon Sep 17 00:00:00 2001 +From: Sergio Paracuellos +Date: Mon, 6 Feb 2023 09:33:05 +0100 +Subject: [PATCH] clk: ralink: fix 'mt7621_gate_is_enabled()' function + +Compiling clock driver with CONFIG_UBSAN enabled shows the following trace: + +UBSAN: shift-out-of-bounds in drivers/clk/ralink/clk-mt7621.c:121:15 +shift exponent 131072 is too large for 32-bit type 'long unsigned int' +CPU: 1 PID: 1 Comm: swapper/0 Not tainted 5.15.86 #0 +Stack : ... + +Call Trace: +[<80009a58>] show_stack+0x38/0x118 +[<8045ce04>] dump_stack_lvl+0x60/0x80 +[<80458868>] ubsan_epilogue+0x10/0x54 +[<804590e0>] __ubsan_handle_shift_out_of_bounds+0x118/0x190 +[<804c9a10>] mt7621_gate_is_enabled+0x98/0xa0 +[<804bb774>] clk_core_is_enabled+0x34/0x90 +[<80aad73c>] clk_disable_unused_subtree+0x98/0x1e4 +[<80aad6d4>] clk_disable_unused_subtree+0x30/0x1e4 +[<80aad6d4>] clk_disable_unused_subtree+0x30/0x1e4 +[<80aad900>] clk_disable_unused+0x78/0x120 +[<80002030>] do_one_initcall+0x54/0x1f0 +[<80a922a4>] kernel_init_freeable+0x280/0x31c +[<808047c4>] kernel_init+0x20/0x118 +[<80003e58>] ret_from_kernel_thread+0x14/0x1c + +Shifting a value (131032) larger than the type (32 bit unsigned integer) +is undefined behaviour in C. + +The problem is in 'mt7621_gate_is_enabled()' function which is using the +'BIT()' kernel macro with the bit index for the clock gate to check if the +bit is set. When the clock gates structure is created driver is already +setting 'bit_idx' using 'BIT()' macro, so we are wrongly applying an extra +'BIT()' mask here. Removing it solve the problem and makes this function +correct. However when clock gating is correctly working, the kernel starts +disabling those clocks that are not requested. Some drivers for this SoC +are older than this clock driver itself. So to avoid the kernel to disable +clocks that have been enabled until now, we must apply 'CLK_IS_CRITICAL' +flag on gates initialization code. + +Fixes: 48df7a26f470 ("clk: ralink: add clock driver for mt7621 SoC") +Signed-off-by: Sergio Paracuellos +Link: https://lore.kernel.org/r/20230206083305.147582-1-sergio.paracuellos@gmail.com +Signed-off-by: Stephen Boyd +--- + drivers/clk/ralink/clk-mt7621.c | 10 ++++++++-- + 1 file changed, 8 insertions(+), 2 deletions(-) + +--- a/drivers/clk/ralink/clk-mt7621.c ++++ b/drivers/clk/ralink/clk-mt7621.c +@@ -121,7 +121,7 @@ static int mt7621_gate_is_enabled(struct + if (regmap_read(sysc, SYSC_REG_CLKCFG1, &val)) + return 0; + +- return val & BIT(clk_gate->bit_idx); ++ return val & clk_gate->bit_idx; + } + + static const struct clk_ops mt7621_gate_ops = { +@@ -133,8 +133,14 @@ static const struct clk_ops mt7621_gate_ + static int mt7621_gate_ops_init(struct device *dev, + struct mt7621_gate *sclk) + { ++ /* ++ * There are drivers for this SoC that are older ++ * than clock driver and are not prepared for the clock. ++ * We don't want the kernel to disable anything so we ++ * add CLK_IS_CRITICAL flag here. ++ */ + struct clk_init_data init = { +- .flags = CLK_SET_RATE_PARENT, ++ .flags = CLK_SET_RATE_PARENT | CLK_IS_CRITICAL, + .num_parents = 1, + .parent_names = &sclk->parent_name, + .ops = &mt7621_gate_ops, diff --git a/target/linux/ramips/patches-5.15/005-v6.5-01-dt-bindings-clock-add-mtmips-SoCs-system-controller.patch b/target/linux/ramips/patches-5.15/005-v6.5-01-dt-bindings-clock-add-mtmips-SoCs-system-controller.patch new file mode 100644 index 00000000000..94784f7885d --- /dev/null +++ b/target/linux/ramips/patches-5.15/005-v6.5-01-dt-bindings-clock-add-mtmips-SoCs-system-controller.patch @@ -0,0 +1,86 @@ +From 612616e6381929e7f9e303f8b8ad3655cc101516 Mon Sep 17 00:00:00 2001 +From: Sergio Paracuellos +Date: Mon, 19 Jun 2023 06:09:33 +0200 +Subject: [PATCH 1/9] dt-bindings: clock: add mtmips SoCs system controller + +Adds device tree binding documentation for system controller node present +in Mediatek MIPS and Ralink SOCs. This node is a clock and reset provider +for the rest of the world. This covers RT2880, RT3050, RT3052, RT3350, +RT3883, RT5350, MT7620, MT7628 and MT7688 SoCs. + +Reviewed-by: Rob Herring +Acked-by: Stephen Boyd +Signed-off-by: Sergio Paracuellos +Signed-off-by: Thomas Bogendoerfer +--- + .../bindings/clock/mediatek,mtmips-sysc.yaml | 64 ++++++++++++++++++++++ + 1 file changed, 64 insertions(+) + create mode 100644 Documentation/devicetree/bindings/clock/mediatek,mtmips-sysc.yaml + +--- /dev/null ++++ b/Documentation/devicetree/bindings/clock/mediatek,mtmips-sysc.yaml +@@ -0,0 +1,64 @@ ++# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) ++%YAML 1.2 ++--- ++$id: http://devicetree.org/schemas/clock/mediatek,mtmips-sysc.yaml# ++$schema: http://devicetree.org/meta-schemas/core.yaml# ++ ++title: MTMIPS SoCs System Controller ++ ++maintainers: ++ - Sergio Paracuellos ++ ++description: | ++ MediaTek MIPS and Ralink SoCs provides a system controller to allow ++ to access to system control registers. These registers include clock ++ and reset related ones so this node is both clock and reset provider ++ for the rest of the world. ++ ++ These SoCs have an XTAL from where the cpu clock is ++ provided as well as derived clocks for the bus and the peripherals. ++ ++properties: ++ compatible: ++ items: ++ - enum: ++ - ralink,mt7620-sysc ++ - ralink,mt7628-sysc ++ - ralink,mt7688-sysc ++ - ralink,rt2880-sysc ++ - ralink,rt3050-sysc ++ - ralink,rt3052-sysc ++ - ralink,rt3352-sysc ++ - ralink,rt3883-sysc ++ - ralink,rt5350-sysc ++ - const: syscon ++ ++ reg: ++ maxItems: 1 ++ ++ '#clock-cells': ++ description: ++ The first cell indicates the clock number. ++ const: 1 ++ ++ '#reset-cells': ++ description: ++ The first cell indicates the reset bit within the register. ++ const: 1 ++ ++required: ++ - compatible ++ - reg ++ - '#clock-cells' ++ - '#reset-cells' ++ ++additionalProperties: false ++ ++examples: ++ - | ++ syscon@0 { ++ compatible = "ralink,rt5350-sysc", "syscon"; ++ reg = <0x0 0x100>; ++ #clock-cells = <1>; ++ #reset-cells = <1>; ++ }; diff --git a/target/linux/ramips/patches-5.15/005-v6.5-02-clk-ralink-add-clock-and-reset-driver-for-MTMIPS-SoC.patch b/target/linux/ramips/patches-5.15/005-v6.5-02-clk-ralink-add-clock-and-reset-driver-for-MTMIPS-SoC.patch new file mode 100644 index 00000000000..cef39978e03 --- /dev/null +++ b/target/linux/ramips/patches-5.15/005-v6.5-02-clk-ralink-add-clock-and-reset-driver-for-MTMIPS-SoC.patch @@ -0,0 +1,1221 @@ +From 6f3b15586eef736831abe6a14f2a6906bc0dc074 Mon Sep 17 00:00:00 2001 +From: Sergio Paracuellos +Date: Mon, 19 Jun 2023 06:09:34 +0200 +Subject: [PATCH 2/9] clk: ralink: add clock and reset driver for MTMIPS SoCs + +Until now, clock related code for old ralink SoCs was based in fixed clocks +using 'clk_register_fixed_rate' and 'clkdev_create' directly doing in code +and not using device tree at all for their definition. Including this driver +is an effort to be able to define proper clocks using device tree and also +cleaning all the clock and reset related code from 'arch/mips/ralink' dir. +This clock and reset driver covers all the ralink SoCs but MT7621 which is +the newest and provides gating and some differences that make it different +from its predecesors. It has its own driver since some time ago. The ralink +SoCs we are taking about are RT2880, RT3050, RT3052, RT3350, RT3352, RT3883, +RT5350, MT7620, MT7628 and MT7688. Mostly the code in this new driver has +been extracted from 'arch/mips/ralink' and cleanly put using kernel clock +driver APIs. The clock plans for this SoCs only talks about relation between +CPU frequency and BUS frequency. This relation is different depending on the +particular SoC. CPU clock is derived from XTAL frequencies. + +Depending on the SoC we have the following frequencies: +* RT2880 SoC: + - XTAL: 40 MHz. + - CPU: 250, 266, 280 or 300 MHz. + - BUS: CPU / 2 MHz. +* RT3050, RT3052, RT3350: + - XTAL: 40 MHz. + - CPU: 320 or 384 MHz. + - BUS: CPU / 3 MHz. +* RT3352: + - XTAL: 40 MHz. + - CPU: 384 or 400 MHz. + - BUS: CPU / 3 MHz. + - PERIPH: 40 MHz. +* RT3383: + - XTAL: 40 MHz. + - CPU: 250, 384, 480 or 500 MHz. + - BUS: Depends on RAM Type and CPU: + + RAM DDR2: 125. ELSE 83 MHz. + + RAM DDR2: 128. ELSE 96 MHz. + + RAM DDR2: 160. ELSE 120 MHz. + + RAM DDR2: 166. ELSE 125 MHz. +* RT5350: + - XTAL: 40 MHz. + - CPU: 300, 320 or 360 MHz. + - BUS: CPU / 3, CPU / 4, CPU / 3 MHz. + - PERIPH: 40 MHz. +* MT7628 and MT7688: + - XTAL: 20 MHz or 40 MHz. + - CPU: 575 or 580 MHz. + - BUS: CPU / 3. + - PCMI2S: 480 MHz. + - PERIPH: 40 MHz. +* MT7620: + - XTAL: 20 MHz or 40 MHz. + - PLL: XTAL, 480, 600 MHz. + - CPU: depends on PLL and some mult and dividers. + - BUS: depends on PLL and some mult and dividers. + - PERIPH: 40 or XTAL MHz. + +MT7620 is a bit more complex deriving CPU clock from a PLL and an bunch of +register reads and predividers. To derive CPU and BUS frequencies in the +MT7620 SoC 'mt7620_calc_rate()' helper is used. + +In the case XTAL can have different frequencies and we need a different +clock frequency for peripherals 'periph' clock in introduced. + +The rest of the peripherals present in the SoC just follow their parent +frequencies. + +With this information the clk driver will provide all the clock and reset +functionality from a set of hardcoded clocks allowing to define a nice +device tree without fixed clocks. + +Acked-by: Stephen Boyd +Signed-off-by: Sergio Paracuellos +Signed-off-by: Thomas Bogendoerfer +--- + drivers/clk/ralink/Kconfig | 7 + + drivers/clk/ralink/Makefile | 1 + + drivers/clk/ralink/clk-mtmips.c | 1115 +++++++++++++++++++++++++++++++++++++++ + 3 files changed, 1123 insertions(+) + create mode 100644 drivers/clk/ralink/clk-mtmips.c + +--- a/drivers/clk/ralink/Kconfig ++++ b/drivers/clk/ralink/Kconfig +@@ -9,3 +9,10 @@ config CLK_MT7621 + select MFD_SYSCON + help + This driver supports MediaTek MT7621 basic clocks. ++ ++config CLK_MTMIPS ++ bool "Clock driver for MTMIPS SoCs" ++ depends on SOC_RT305X || SOC_RT288X || SOC_RT3883 || SOC_MT7620 || COMPILE_TEST ++ select MFD_SYSCON ++ help ++ This driver supports MTMIPS basic clocks. +--- a/drivers/clk/ralink/Makefile ++++ b/drivers/clk/ralink/Makefile +@@ -1,2 +1,3 @@ + # SPDX-License-Identifier: GPL-2.0 + obj-$(CONFIG_CLK_MT7621) += clk-mt7621.o ++obj-$(CONFIG_CLK_MTMIPS) += clk-mtmips.o +--- /dev/null ++++ b/drivers/clk/ralink/clk-mtmips.c +@@ -0,0 +1,1115 @@ ++// SPDX-License-Identifier: GPL-2.0 ++/* ++ * MTMIPS SoCs Clock Driver ++ * Author: Sergio Paracuellos ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++/* Configuration registers */ ++#define SYSC_REG_SYSTEM_CONFIG 0x10 ++#define SYSC_REG_CLKCFG0 0x2c ++#define SYSC_REG_RESET_CTRL 0x34 ++#define SYSC_REG_CPU_SYS_CLKCFG 0x3c ++#define SYSC_REG_CPLL_CONFIG0 0x54 ++#define SYSC_REG_CPLL_CONFIG1 0x58 ++ ++/* RT2880 SoC */ ++#define RT2880_CONFIG_CPUCLK_SHIFT 20 ++#define RT2880_CONFIG_CPUCLK_MASK 0x3 ++#define RT2880_CONFIG_CPUCLK_250 0x0 ++#define RT2880_CONFIG_CPUCLK_266 0x1 ++#define RT2880_CONFIG_CPUCLK_280 0x2 ++#define RT2880_CONFIG_CPUCLK_300 0x3 ++ ++/* RT305X SoC */ ++#define RT305X_SYSCFG_CPUCLK_SHIFT 18 ++#define RT305X_SYSCFG_CPUCLK_MASK 0x1 ++#define RT305X_SYSCFG_CPUCLK_LOW 0x0 ++#define RT305X_SYSCFG_CPUCLK_HIGH 0x1 ++ ++/* RT3352 SoC */ ++#define RT3352_SYSCFG0_CPUCLK_SHIFT 8 ++#define RT3352_SYSCFG0_CPUCLK_MASK 0x1 ++#define RT3352_SYSCFG0_CPUCLK_LOW 0x0 ++#define RT3352_SYSCFG0_CPUCLK_HIGH 0x1 ++ ++/* RT3383 SoC */ ++#define RT3883_SYSCFG0_DRAM_TYPE_DDR2 BIT(17) ++#define RT3883_SYSCFG0_CPUCLK_SHIFT 8 ++#define RT3883_SYSCFG0_CPUCLK_MASK 0x3 ++#define RT3883_SYSCFG0_CPUCLK_250 0x0 ++#define RT3883_SYSCFG0_CPUCLK_384 0x1 ++#define RT3883_SYSCFG0_CPUCLK_480 0x2 ++#define RT3883_SYSCFG0_CPUCLK_500 0x3 ++ ++/* RT5350 SoC */ ++#define RT5350_CLKCFG0_XTAL_SEL BIT(20) ++#define RT5350_SYSCFG0_CPUCLK_SHIFT 8 ++#define RT5350_SYSCFG0_CPUCLK_MASK 0x3 ++#define RT5350_SYSCFG0_CPUCLK_360 0x0 ++#define RT5350_SYSCFG0_CPUCLK_320 0x2 ++#define RT5350_SYSCFG0_CPUCLK_300 0x3 ++ ++/* MT7620 and MT76x8 SoCs */ ++#define MT7620_XTAL_FREQ_SEL BIT(6) ++#define CPLL_CFG0_SW_CFG BIT(31) ++#define CPLL_CFG0_PLL_MULT_RATIO_SHIFT 16 ++#define CPLL_CFG0_PLL_MULT_RATIO_MASK 0x7 ++#define CPLL_CFG0_LC_CURFCK BIT(15) ++#define CPLL_CFG0_BYPASS_REF_CLK BIT(14) ++#define CPLL_CFG0_PLL_DIV_RATIO_SHIFT 10 ++#define CPLL_CFG0_PLL_DIV_RATIO_MASK 0x3 ++#define CPLL_CFG1_CPU_AUX1 BIT(25) ++#define CPLL_CFG1_CPU_AUX0 BIT(24) ++#define CLKCFG0_PERI_CLK_SEL BIT(4) ++#define CPU_SYS_CLKCFG_OCP_RATIO_SHIFT 16 ++#define CPU_SYS_CLKCFG_OCP_RATIO_MASK 0xf ++#define CPU_SYS_CLKCFG_OCP_RATIO_1 0 /* 1:1 (Reserved) */ ++#define CPU_SYS_CLKCFG_OCP_RATIO_1_5 1 /* 1:1.5 (Reserved) */ ++#define CPU_SYS_CLKCFG_OCP_RATIO_2 2 /* 1:2 */ ++#define CPU_SYS_CLKCFG_OCP_RATIO_2_5 3 /* 1:2.5 (Reserved) */ ++#define CPU_SYS_CLKCFG_OCP_RATIO_3 4 /* 1:3 */ ++#define CPU_SYS_CLKCFG_OCP_RATIO_3_5 5 /* 1:3.5 (Reserved) */ ++#define CPU_SYS_CLKCFG_OCP_RATIO_4 6 /* 1:4 */ ++#define CPU_SYS_CLKCFG_OCP_RATIO_5 7 /* 1:5 */ ++#define CPU_SYS_CLKCFG_OCP_RATIO_10 8 /* 1:10 */ ++#define CPU_SYS_CLKCFG_CPU_FDIV_SHIFT 8 ++#define CPU_SYS_CLKCFG_CPU_FDIV_MASK 0x1f ++#define CPU_SYS_CLKCFG_CPU_FFRAC_SHIFT 0 ++#define CPU_SYS_CLKCFG_CPU_FFRAC_MASK 0x1f ++ ++/* clock scaling */ ++#define CLKCFG_FDIV_MASK 0x1f00 ++#define CLKCFG_FDIV_USB_VAL 0x0300 ++#define CLKCFG_FFRAC_MASK 0x001f ++#define CLKCFG_FFRAC_USB_VAL 0x0003 ++ ++struct mtmips_clk; ++struct mtmips_clk_fixed; ++struct mtmips_clk_factor; ++ ++struct mtmips_clk_data { ++ struct mtmips_clk *clk_base; ++ size_t num_clk_base; ++ struct mtmips_clk_fixed *clk_fixed; ++ size_t num_clk_fixed; ++ struct mtmips_clk_factor *clk_factor; ++ size_t num_clk_factor; ++ struct mtmips_clk *clk_periph; ++ size_t num_clk_periph; ++}; ++ ++struct mtmips_clk_priv { ++ struct regmap *sysc; ++ const struct mtmips_clk_data *data; ++}; ++ ++struct mtmips_clk { ++ struct clk_hw hw; ++ struct mtmips_clk_priv *priv; ++}; ++ ++struct mtmips_clk_fixed { ++ const char *name; ++ const char *parent; ++ unsigned long rate; ++ struct clk_hw *hw; ++}; ++ ++struct mtmips_clk_factor { ++ const char *name; ++ const char *parent; ++ int mult; ++ int div; ++ unsigned long flags; ++ struct clk_hw *hw; ++}; ++ ++static unsigned long mtmips_pherip_clk_rate(struct clk_hw *hw, ++ unsigned long parent_rate) ++{ ++ return parent_rate; ++} ++ ++static const struct clk_ops mtmips_periph_clk_ops = { ++ .recalc_rate = mtmips_pherip_clk_rate, ++}; ++ ++#define CLK_PERIPH(_name, _parent) { \ ++ .init = &(const struct clk_init_data) { \ ++ .name = _name, \ ++ .ops = &mtmips_periph_clk_ops, \ ++ .parent_data = &(const struct clk_parent_data) {\ ++ .name = _parent, \ ++ .fw_name = _parent \ ++ }, \ ++ .num_parents = 1, \ ++ /* \ ++ * There are drivers for these SoCs that are \ ++ * older than clock driver and are not prepared \ ++ * for the clock. We don't want the kernel to \ ++ * disable anything so we add CLK_IS_CRITICAL \ ++ * flag here. \ ++ */ \ ++ .flags = CLK_SET_RATE_PARENT | CLK_IS_CRITICAL \ ++ }, \ ++} ++ ++static struct mtmips_clk rt2880_pherip_clks[] = { ++ { CLK_PERIPH("300100.timer", "bus") }, ++ { CLK_PERIPH("300120.watchdog", "bus") }, ++ { CLK_PERIPH("300500.uart", "bus") }, ++ { CLK_PERIPH("300900.i2c", "bus") }, ++ { CLK_PERIPH("300c00.uartlite", "bus") }, ++ { CLK_PERIPH("400000.ethernet", "bus") }, ++ { CLK_PERIPH("480000.wmac", "xtal") } ++}; ++ ++static struct mtmips_clk rt305x_pherip_clks[] = { ++ { CLK_PERIPH("10000100.timer", "bus") }, ++ { CLK_PERIPH("10000120.watchdog", "bus") }, ++ { CLK_PERIPH("10000500.uart", "bus") }, ++ { CLK_PERIPH("10000900.i2c", "bus") }, ++ { CLK_PERIPH("10000a00.i2s", "bus") }, ++ { CLK_PERIPH("10000b00.spi", "bus") }, ++ { CLK_PERIPH("10000b40.spi", "bus") }, ++ { CLK_PERIPH("10000c00.uartlite", "bus") }, ++ { CLK_PERIPH("10100000.ethernet", "bus") }, ++ { CLK_PERIPH("10180000.wmac", "xtal") } ++}; ++ ++static struct mtmips_clk rt5350_pherip_clks[] = { ++ { CLK_PERIPH("10000100.timer", "bus") }, ++ { CLK_PERIPH("10000120.watchdog", "bus") }, ++ { CLK_PERIPH("10000500.uart", "periph") }, ++ { CLK_PERIPH("10000900.i2c", "periph") }, ++ { CLK_PERIPH("10000a00.i2s", "periph") }, ++ { CLK_PERIPH("10000b00.spi", "bus") }, ++ { CLK_PERIPH("10000b40.spi", "bus") }, ++ { CLK_PERIPH("10000c00.uartlite", "periph") }, ++ { CLK_PERIPH("10100000.ethernet", "bus") }, ++ { CLK_PERIPH("10180000.wmac", "xtal") } ++}; ++ ++static struct mtmips_clk mt7620_pherip_clks[] = { ++ { CLK_PERIPH("10000100.timer", "periph") }, ++ { CLK_PERIPH("10000120.watchdog", "periph") }, ++ { CLK_PERIPH("10000500.uart", "periph") }, ++ { CLK_PERIPH("10000900.i2c", "periph") }, ++ { CLK_PERIPH("10000a00.i2s", "periph") }, ++ { CLK_PERIPH("10000b00.spi", "bus") }, ++ { CLK_PERIPH("10000b40.spi", "bus") }, ++ { CLK_PERIPH("10000c00.uartlite", "periph") }, ++ { CLK_PERIPH("10180000.wmac", "xtal") } ++}; ++ ++static struct mtmips_clk mt76x8_pherip_clks[] = { ++ { CLK_PERIPH("10000100.timer", "periph") }, ++ { CLK_PERIPH("10000120.watchdog", "periph") }, ++ { CLK_PERIPH("10000900.i2c", "periph") }, ++ { CLK_PERIPH("10000a00.i2s", "pcmi2s") }, ++ { CLK_PERIPH("10000b00.spi", "bus") }, ++ { CLK_PERIPH("10000b40.spi", "bus") }, ++ { CLK_PERIPH("10000c00.uart0", "periph") }, ++ { CLK_PERIPH("10000d00.uart1", "periph") }, ++ { CLK_PERIPH("10000e00.uart2", "periph") }, ++ { CLK_PERIPH("10300000.wmac", "xtal") } ++}; ++ ++static int mtmips_register_pherip_clocks(struct device_node *np, ++ struct clk_hw_onecell_data *clk_data, ++ struct mtmips_clk_priv *priv) ++{ ++ struct clk_hw **hws = clk_data->hws; ++ struct mtmips_clk *sclk; ++ size_t idx_start = priv->data->num_clk_base + priv->data->num_clk_fixed + ++ priv->data->num_clk_factor; ++ int ret, i; ++ ++ for (i = 0; i < priv->data->num_clk_periph; i++) { ++ int idx = idx_start + i; ++ ++ sclk = &priv->data->clk_periph[i]; ++ ret = of_clk_hw_register(np, &sclk->hw); ++ if (ret) { ++ pr_err("Couldn't register peripheral clock %d\n", idx); ++ goto err_clk_unreg; ++ } ++ ++ hws[idx] = &sclk->hw; ++ } ++ ++ return 0; ++ ++err_clk_unreg: ++ while (--i >= 0) { ++ sclk = &priv->data->clk_periph[i]; ++ clk_hw_unregister(&sclk->hw); ++ } ++ return ret; ++} ++ ++#define CLK_FIXED(_name, _parent, _rate) \ ++ { \ ++ .name = _name, \ ++ .parent = _parent, \ ++ .rate = _rate \ ++ } ++ ++static struct mtmips_clk_fixed rt305x_fixed_clocks[] = { ++ CLK_FIXED("xtal", NULL, 40000000) ++}; ++ ++static struct mtmips_clk_fixed rt3352_fixed_clocks[] = { ++ CLK_FIXED("periph", "xtal", 40000000) ++}; ++ ++static struct mtmips_clk_fixed mt76x8_fixed_clocks[] = { ++ CLK_FIXED("pcmi2s", "xtal", 480000000), ++ CLK_FIXED("periph", "xtal", 40000000) ++}; ++ ++static int mtmips_register_fixed_clocks(struct clk_hw_onecell_data *clk_data, ++ struct mtmips_clk_priv *priv) ++{ ++ struct clk_hw **hws = clk_data->hws; ++ struct mtmips_clk_fixed *sclk; ++ size_t idx_start = priv->data->num_clk_base; ++ int ret, i; ++ ++ for (i = 0; i < priv->data->num_clk_fixed; i++) { ++ int idx = idx_start + i; ++ ++ sclk = &priv->data->clk_fixed[i]; ++ sclk->hw = clk_hw_register_fixed_rate(NULL, sclk->name, ++ sclk->parent, 0, ++ sclk->rate); ++ if (IS_ERR(sclk->hw)) { ++ pr_err("Couldn't register fixed clock %d\n", idx); ++ goto err_clk_unreg; ++ } ++ ++ hws[idx] = sclk->hw; ++ } ++ ++ return 0; ++ ++err_clk_unreg: ++ while (--i >= 0) { ++ sclk = &priv->data->clk_fixed[i]; ++ clk_hw_unregister_fixed_rate(sclk->hw); ++ } ++ return ret; ++} ++ ++#define CLK_FACTOR(_name, _parent, _mult, _div) \ ++ { \ ++ .name = _name, \ ++ .parent = _parent, \ ++ .mult = _mult, \ ++ .div = _div, \ ++ .flags = CLK_SET_RATE_PARENT \ ++ } ++ ++static struct mtmips_clk_factor rt2880_factor_clocks[] = { ++ CLK_FACTOR("bus", "cpu", 1, 2) ++}; ++ ++static struct mtmips_clk_factor rt305x_factor_clocks[] = { ++ CLK_FACTOR("bus", "cpu", 1, 3) ++}; ++ ++static int mtmips_register_factor_clocks(struct clk_hw_onecell_data *clk_data, ++ struct mtmips_clk_priv *priv) ++{ ++ struct clk_hw **hws = clk_data->hws; ++ struct mtmips_clk_factor *sclk; ++ size_t idx_start = priv->data->num_clk_base + priv->data->num_clk_fixed; ++ int ret, i; ++ ++ for (i = 0; i < priv->data->num_clk_factor; i++) { ++ int idx = idx_start + i; ++ ++ sclk = &priv->data->clk_factor[i]; ++ sclk->hw = clk_hw_register_fixed_factor(NULL, sclk->name, ++ sclk->parent, sclk->flags, ++ sclk->mult, sclk->div); ++ if (IS_ERR(sclk->hw)) { ++ pr_err("Couldn't register factor clock %d\n", idx); ++ goto err_clk_unreg; ++ } ++ ++ hws[idx] = sclk->hw; ++ } ++ ++ return 0; ++ ++err_clk_unreg: ++ while (--i >= 0) { ++ sclk = &priv->data->clk_factor[i]; ++ clk_hw_unregister_fixed_factor(sclk->hw); ++ } ++ return ret; ++} ++ ++static inline struct mtmips_clk *to_mtmips_clk(struct clk_hw *hw) ++{ ++ return container_of(hw, struct mtmips_clk, hw); ++} ++ ++static unsigned long rt5350_xtal_recalc_rate(struct clk_hw *hw, ++ unsigned long parent_rate) ++{ ++ struct mtmips_clk *clk = to_mtmips_clk(hw); ++ struct regmap *sysc = clk->priv->sysc; ++ u32 val; ++ ++ regmap_read(sysc, SYSC_REG_SYSTEM_CONFIG, &val); ++ if (!(val & RT5350_CLKCFG0_XTAL_SEL)) ++ return 20000000; ++ ++ return 40000000; ++} ++ ++static unsigned long rt5350_cpu_recalc_rate(struct clk_hw *hw, ++ unsigned long xtal_clk) ++{ ++ struct mtmips_clk *clk = to_mtmips_clk(hw); ++ struct regmap *sysc = clk->priv->sysc; ++ u32 t; ++ ++ regmap_read(sysc, SYSC_REG_SYSTEM_CONFIG, &t); ++ t = (t >> RT5350_SYSCFG0_CPUCLK_SHIFT) & RT5350_SYSCFG0_CPUCLK_MASK; ++ ++ switch (t) { ++ case RT5350_SYSCFG0_CPUCLK_360: ++ return 360000000; ++ case RT5350_SYSCFG0_CPUCLK_320: ++ return 320000000; ++ case RT5350_SYSCFG0_CPUCLK_300: ++ return 300000000; ++ default: ++ BUG(); ++ } ++} ++ ++static unsigned long rt5350_bus_recalc_rate(struct clk_hw *hw, ++ unsigned long parent_rate) ++{ ++ if (parent_rate == 320000000) ++ return parent_rate / 4; ++ ++ return parent_rate / 3; ++} ++ ++static unsigned long rt3352_cpu_recalc_rate(struct clk_hw *hw, ++ unsigned long xtal_clk) ++{ ++ struct mtmips_clk *clk = to_mtmips_clk(hw); ++ struct regmap *sysc = clk->priv->sysc; ++ u32 t; ++ ++ regmap_read(sysc, SYSC_REG_SYSTEM_CONFIG, &t); ++ t = (t >> RT3352_SYSCFG0_CPUCLK_SHIFT) & RT3352_SYSCFG0_CPUCLK_MASK; ++ ++ switch (t) { ++ case RT3352_SYSCFG0_CPUCLK_LOW: ++ return 384000000; ++ case RT3352_SYSCFG0_CPUCLK_HIGH: ++ return 400000000; ++ default: ++ BUG(); ++ } ++} ++ ++static unsigned long rt305x_cpu_recalc_rate(struct clk_hw *hw, ++ unsigned long xtal_clk) ++{ ++ struct mtmips_clk *clk = to_mtmips_clk(hw); ++ struct regmap *sysc = clk->priv->sysc; ++ u32 t; ++ ++ regmap_read(sysc, SYSC_REG_SYSTEM_CONFIG, &t); ++ t = (t >> RT305X_SYSCFG_CPUCLK_SHIFT) & RT305X_SYSCFG_CPUCLK_MASK; ++ ++ switch (t) { ++ case RT305X_SYSCFG_CPUCLK_LOW: ++ return 320000000; ++ case RT305X_SYSCFG_CPUCLK_HIGH: ++ return 384000000; ++ default: ++ BUG(); ++ } ++} ++ ++static unsigned long rt3883_cpu_recalc_rate(struct clk_hw *hw, ++ unsigned long xtal_clk) ++{ ++ struct mtmips_clk *clk = to_mtmips_clk(hw); ++ struct regmap *sysc = clk->priv->sysc; ++ u32 t; ++ ++ regmap_read(sysc, SYSC_REG_SYSTEM_CONFIG, &t); ++ t = (t >> RT3883_SYSCFG0_CPUCLK_SHIFT) & RT3883_SYSCFG0_CPUCLK_MASK; ++ ++ switch (t) { ++ case RT3883_SYSCFG0_CPUCLK_250: ++ return 250000000; ++ case RT3883_SYSCFG0_CPUCLK_384: ++ return 384000000; ++ case RT3883_SYSCFG0_CPUCLK_480: ++ return 480000000; ++ case RT3883_SYSCFG0_CPUCLK_500: ++ return 500000000; ++ default: ++ BUG(); ++ } ++} ++ ++static unsigned long rt3883_bus_recalc_rate(struct clk_hw *hw, ++ unsigned long parent_rate) ++{ ++ struct mtmips_clk *clk = to_mtmips_clk(hw); ++ struct regmap *sysc = clk->priv->sysc; ++ u32 ddr2; ++ u32 t; ++ ++ regmap_read(sysc, SYSC_REG_SYSTEM_CONFIG, &t); ++ ddr2 = t & RT3883_SYSCFG0_DRAM_TYPE_DDR2; ++ ++ switch (parent_rate) { ++ case 250000000: ++ return (ddr2) ? 125000000 : 83000000; ++ case 384000000: ++ return (ddr2) ? 128000000 : 96000000; ++ case 480000000: ++ return (ddr2) ? 160000000 : 120000000; ++ case 500000000: ++ return (ddr2) ? 166000000 : 125000000; ++ default: ++ WARN_ON_ONCE(parent_rate == 0); ++ return parent_rate / 4; ++ } ++} ++ ++static unsigned long rt2880_cpu_recalc_rate(struct clk_hw *hw, ++ unsigned long xtal_clk) ++{ ++ struct mtmips_clk *clk = to_mtmips_clk(hw); ++ struct regmap *sysc = clk->priv->sysc; ++ u32 t; ++ ++ regmap_read(sysc, SYSC_REG_SYSTEM_CONFIG, &t); ++ t = (t >> RT2880_CONFIG_CPUCLK_SHIFT) & RT2880_CONFIG_CPUCLK_MASK; ++ ++ switch (t) { ++ case RT2880_CONFIG_CPUCLK_250: ++ return 250000000; ++ case RT2880_CONFIG_CPUCLK_266: ++ return 266000000; ++ case RT2880_CONFIG_CPUCLK_280: ++ return 280000000; ++ case RT2880_CONFIG_CPUCLK_300: ++ return 300000000; ++ default: ++ BUG(); ++ } ++} ++ ++static u32 mt7620_calc_rate(u32 ref_rate, u32 mul, u32 div) ++{ ++ u64 t; ++ ++ t = ref_rate; ++ t *= mul; ++ t = div_u64(t, div); ++ ++ return t; ++} ++ ++static unsigned long mt7620_pll_recalc_rate(struct clk_hw *hw, ++ unsigned long parent_rate) ++{ ++ static const u32 clk_divider[] = { 2, 3, 4, 8 }; ++ struct mtmips_clk *clk = to_mtmips_clk(hw); ++ struct regmap *sysc = clk->priv->sysc; ++ unsigned long cpu_pll; ++ u32 t; ++ u32 mul; ++ u32 div; ++ ++ regmap_read(sysc, SYSC_REG_CPLL_CONFIG0, &t); ++ if (t & CPLL_CFG0_BYPASS_REF_CLK) { ++ cpu_pll = parent_rate; ++ } else if ((t & CPLL_CFG0_SW_CFG) == 0) { ++ cpu_pll = 600000000; ++ } else { ++ mul = (t >> CPLL_CFG0_PLL_MULT_RATIO_SHIFT) & ++ CPLL_CFG0_PLL_MULT_RATIO_MASK; ++ mul += 24; ++ if (t & CPLL_CFG0_LC_CURFCK) ++ mul *= 2; ++ ++ div = (t >> CPLL_CFG0_PLL_DIV_RATIO_SHIFT) & ++ CPLL_CFG0_PLL_DIV_RATIO_MASK; ++ ++ WARN_ON_ONCE(div >= ARRAY_SIZE(clk_divider)); ++ ++ cpu_pll = mt7620_calc_rate(parent_rate, mul, clk_divider[div]); ++ } ++ ++ regmap_read(sysc, SYSC_REG_CPLL_CONFIG1, &t); ++ if (t & CPLL_CFG1_CPU_AUX1) ++ return parent_rate; ++ ++ if (t & CPLL_CFG1_CPU_AUX0) ++ return 480000000; ++ ++ return cpu_pll; ++} ++ ++static unsigned long mt7620_cpu_recalc_rate(struct clk_hw *hw, ++ unsigned long parent_rate) ++{ ++ struct mtmips_clk *clk = to_mtmips_clk(hw); ++ struct regmap *sysc = clk->priv->sysc; ++ u32 t; ++ u32 mul; ++ u32 div; ++ ++ regmap_read(sysc, SYSC_REG_CPU_SYS_CLKCFG, &t); ++ mul = t & CPU_SYS_CLKCFG_CPU_FFRAC_MASK; ++ div = (t >> CPU_SYS_CLKCFG_CPU_FDIV_SHIFT) & ++ CPU_SYS_CLKCFG_CPU_FDIV_MASK; ++ ++ return mt7620_calc_rate(parent_rate, mul, div); ++} ++ ++static unsigned long mt7620_bus_recalc_rate(struct clk_hw *hw, ++ unsigned long parent_rate) ++{ ++ static const u32 ocp_dividers[16] = { ++ [CPU_SYS_CLKCFG_OCP_RATIO_2] = 2, ++ [CPU_SYS_CLKCFG_OCP_RATIO_3] = 3, ++ [CPU_SYS_CLKCFG_OCP_RATIO_4] = 4, ++ [CPU_SYS_CLKCFG_OCP_RATIO_5] = 5, ++ [CPU_SYS_CLKCFG_OCP_RATIO_10] = 10, ++ }; ++ struct mtmips_clk *clk = to_mtmips_clk(hw); ++ struct regmap *sysc = clk->priv->sysc; ++ u32 t; ++ u32 ocp_ratio; ++ u32 div; ++ ++ regmap_read(sysc, SYSC_REG_CPU_SYS_CLKCFG, &t); ++ ocp_ratio = (t >> CPU_SYS_CLKCFG_OCP_RATIO_SHIFT) & ++ CPU_SYS_CLKCFG_OCP_RATIO_MASK; ++ ++ if (WARN_ON_ONCE(ocp_ratio >= ARRAY_SIZE(ocp_dividers))) ++ return parent_rate; ++ ++ div = ocp_dividers[ocp_ratio]; ++ ++ if (WARN(!div, "invalid divider for OCP ratio %u", ocp_ratio)) ++ return parent_rate; ++ ++ return parent_rate / div; ++} ++ ++static unsigned long mt7620_periph_recalc_rate(struct clk_hw *hw, ++ unsigned long parent_rate) ++{ ++ struct mtmips_clk *clk = to_mtmips_clk(hw); ++ struct regmap *sysc = clk->priv->sysc; ++ u32 t; ++ ++ regmap_read(sysc, SYSC_REG_CLKCFG0, &t); ++ if (t & CLKCFG0_PERI_CLK_SEL) ++ return parent_rate; ++ ++ return 40000000; ++} ++ ++static unsigned long mt76x8_xtal_recalc_rate(struct clk_hw *hw, ++ unsigned long parent_rate) ++{ ++ struct mtmips_clk *clk = to_mtmips_clk(hw); ++ struct regmap *sysc = clk->priv->sysc; ++ u32 t; ++ ++ regmap_read(sysc, SYSC_REG_SYSTEM_CONFIG, &t); ++ if (t & MT7620_XTAL_FREQ_SEL) ++ return 40000000; ++ ++ return 20000000; ++} ++ ++static unsigned long mt76x8_cpu_recalc_rate(struct clk_hw *hw, ++ unsigned long xtal_clk) ++{ ++ if (xtal_clk == 40000000) ++ return 580000000; ++ ++ return 575000000; ++} ++ ++#define CLK_BASE(_name, _parent, _recalc) { \ ++ .init = &(const struct clk_init_data) { \ ++ .name = _name, \ ++ .ops = &(const struct clk_ops) { \ ++ .recalc_rate = _recalc, \ ++ }, \ ++ .parent_data = &(const struct clk_parent_data) { \ ++ .name = _parent, \ ++ .fw_name = _parent \ ++ }, \ ++ .num_parents = _parent ? 1 : 0 \ ++ }, \ ++} ++ ++static struct mtmips_clk rt2880_clks_base[] = { ++ { CLK_BASE("cpu", "xtal", rt2880_cpu_recalc_rate) } ++}; ++ ++static struct mtmips_clk rt305x_clks_base[] = { ++ { CLK_BASE("cpu", "xtal", rt305x_cpu_recalc_rate) } ++}; ++ ++static struct mtmips_clk rt3352_clks_base[] = { ++ { CLK_BASE("xtal", NULL, rt5350_xtal_recalc_rate) }, ++ { CLK_BASE("cpu", "xtal", rt3352_cpu_recalc_rate) } ++}; ++ ++static struct mtmips_clk rt3883_clks_base[] = { ++ { CLK_BASE("cpu", "xtal", rt3883_cpu_recalc_rate) }, ++ { CLK_BASE("bus", "cpu", rt3883_bus_recalc_rate) } ++}; ++ ++static struct mtmips_clk rt5350_clks_base[] = { ++ { CLK_BASE("xtal", NULL, rt5350_xtal_recalc_rate) }, ++ { CLK_BASE("cpu", "xtal", rt5350_cpu_recalc_rate) }, ++ { CLK_BASE("bus", "cpu", rt5350_bus_recalc_rate) } ++}; ++ ++static struct mtmips_clk mt7620_clks_base[] = { ++ { CLK_BASE("xtal", NULL, mt76x8_xtal_recalc_rate) }, ++ { CLK_BASE("pll", "xtal", mt7620_pll_recalc_rate) }, ++ { CLK_BASE("cpu", "pll", mt7620_cpu_recalc_rate) }, ++ { CLK_BASE("periph", "xtal", mt7620_periph_recalc_rate) }, ++ { CLK_BASE("bus", "cpu", mt7620_bus_recalc_rate) } ++}; ++ ++static struct mtmips_clk mt76x8_clks_base[] = { ++ { CLK_BASE("xtal", NULL, mt76x8_xtal_recalc_rate) }, ++ { CLK_BASE("cpu", "xtal", mt76x8_cpu_recalc_rate) } ++}; ++ ++static int mtmips_register_clocks(struct device_node *np, ++ struct clk_hw_onecell_data *clk_data, ++ struct mtmips_clk_priv *priv) ++{ ++ struct clk_hw **hws = clk_data->hws; ++ struct mtmips_clk *sclk; ++ int ret, i; ++ ++ for (i = 0; i < priv->data->num_clk_base; i++) { ++ sclk = &priv->data->clk_base[i]; ++ sclk->priv = priv; ++ ret = of_clk_hw_register(np, &sclk->hw); ++ if (ret) { ++ pr_err("Couldn't register top clock %i\n", i); ++ goto err_clk_unreg; ++ } ++ ++ hws[i] = &sclk->hw; ++ } ++ ++ return 0; ++ ++err_clk_unreg: ++ while (--i >= 0) { ++ sclk = &priv->data->clk_base[i]; ++ clk_hw_unregister(&sclk->hw); ++ } ++ return ret; ++} ++ ++static const struct mtmips_clk_data rt2880_clk_data = { ++ .clk_base = rt2880_clks_base, ++ .num_clk_base = ARRAY_SIZE(rt2880_clks_base), ++ .clk_fixed = rt305x_fixed_clocks, ++ .num_clk_fixed = ARRAY_SIZE(rt305x_fixed_clocks), ++ .clk_factor = rt2880_factor_clocks, ++ .num_clk_factor = ARRAY_SIZE(rt2880_factor_clocks), ++ .clk_periph = rt2880_pherip_clks, ++ .num_clk_periph = ARRAY_SIZE(rt2880_pherip_clks), ++}; ++ ++static const struct mtmips_clk_data rt305x_clk_data = { ++ .clk_base = rt305x_clks_base, ++ .num_clk_base = ARRAY_SIZE(rt305x_clks_base), ++ .clk_fixed = rt305x_fixed_clocks, ++ .num_clk_fixed = ARRAY_SIZE(rt305x_fixed_clocks), ++ .clk_factor = rt305x_factor_clocks, ++ .num_clk_factor = ARRAY_SIZE(rt305x_factor_clocks), ++ .clk_periph = rt305x_pherip_clks, ++ .num_clk_periph = ARRAY_SIZE(rt305x_pherip_clks), ++}; ++ ++static const struct mtmips_clk_data rt3352_clk_data = { ++ .clk_base = rt3352_clks_base, ++ .num_clk_base = ARRAY_SIZE(rt3352_clks_base), ++ .clk_fixed = rt3352_fixed_clocks, ++ .num_clk_fixed = ARRAY_SIZE(rt3352_fixed_clocks), ++ .clk_factor = rt305x_factor_clocks, ++ .num_clk_factor = ARRAY_SIZE(rt305x_factor_clocks), ++ .clk_periph = rt5350_pherip_clks, ++ .num_clk_periph = ARRAY_SIZE(rt5350_pherip_clks), ++}; ++ ++static const struct mtmips_clk_data rt3883_clk_data = { ++ .clk_base = rt3883_clks_base, ++ .num_clk_base = ARRAY_SIZE(rt3883_clks_base), ++ .clk_fixed = rt305x_fixed_clocks, ++ .num_clk_fixed = ARRAY_SIZE(rt305x_fixed_clocks), ++ .clk_factor = NULL, ++ .num_clk_factor = 0, ++ .clk_periph = rt5350_pherip_clks, ++ .num_clk_periph = ARRAY_SIZE(rt5350_pherip_clks), ++}; ++ ++static const struct mtmips_clk_data rt5350_clk_data = { ++ .clk_base = rt5350_clks_base, ++ .num_clk_base = ARRAY_SIZE(rt5350_clks_base), ++ .clk_fixed = rt3352_fixed_clocks, ++ .num_clk_fixed = ARRAY_SIZE(rt3352_fixed_clocks), ++ .clk_factor = NULL, ++ .num_clk_factor = 0, ++ .clk_periph = rt5350_pherip_clks, ++ .num_clk_periph = ARRAY_SIZE(rt5350_pherip_clks), ++}; ++ ++static const struct mtmips_clk_data mt7620_clk_data = { ++ .clk_base = mt7620_clks_base, ++ .num_clk_base = ARRAY_SIZE(mt7620_clks_base), ++ .clk_fixed = NULL, ++ .num_clk_fixed = 0, ++ .clk_factor = NULL, ++ .num_clk_factor = 0, ++ .clk_periph = mt7620_pherip_clks, ++ .num_clk_periph = ARRAY_SIZE(mt7620_pherip_clks), ++}; ++ ++static const struct mtmips_clk_data mt76x8_clk_data = { ++ .clk_base = mt76x8_clks_base, ++ .num_clk_base = ARRAY_SIZE(mt76x8_clks_base), ++ .clk_fixed = mt76x8_fixed_clocks, ++ .num_clk_fixed = ARRAY_SIZE(mt76x8_fixed_clocks), ++ .clk_factor = rt305x_factor_clocks, ++ .num_clk_factor = ARRAY_SIZE(rt305x_factor_clocks), ++ .clk_periph = mt76x8_pherip_clks, ++ .num_clk_periph = ARRAY_SIZE(mt76x8_pherip_clks), ++}; ++ ++static const struct of_device_id mtmips_of_match[] = { ++ { ++ .compatible = "ralink,rt2880-sysc", ++ .data = &rt2880_clk_data, ++ }, ++ { ++ .compatible = "ralink,rt3050-sysc", ++ .data = &rt305x_clk_data, ++ }, ++ { ++ .compatible = "ralink,rt3052-sysc", ++ .data = &rt305x_clk_data, ++ }, ++ { ++ .compatible = "ralink,rt3352-sysc", ++ .data = &rt3352_clk_data, ++ }, ++ { ++ .compatible = "ralink,rt3883-sysc", ++ .data = &rt3883_clk_data, ++ }, ++ { ++ .compatible = "ralink,rt5350-sysc", ++ .data = &rt5350_clk_data, ++ }, ++ { ++ .compatible = "ralink,mt7620-sysc", ++ .data = &mt7620_clk_data, ++ }, ++ { ++ .compatible = "ralink,mt7628-sysc", ++ .data = &mt76x8_clk_data, ++ }, ++ { ++ .compatible = "ralink,mt7688-sysc", ++ .data = &mt76x8_clk_data, ++ }, ++ {} ++}; ++ ++static void __init mtmips_clk_regs_init(struct device_node *node, ++ struct mtmips_clk_priv *priv) ++{ ++ u32 t; ++ ++ if (!of_device_is_compatible(node, "ralink,mt7620-sysc")) ++ return; ++ ++ /* ++ * When the CPU goes into sleep mode, the BUS ++ * clock will be too low for USB to function properly. ++ * Adjust the busses fractional divider to fix this ++ */ ++ regmap_read(priv->sysc, SYSC_REG_CPU_SYS_CLKCFG, &t); ++ t &= ~(CLKCFG_FDIV_MASK | CLKCFG_FFRAC_MASK); ++ t |= CLKCFG_FDIV_USB_VAL | CLKCFG_FFRAC_USB_VAL; ++ regmap_write(priv->sysc, SYSC_REG_CPU_SYS_CLKCFG, t); ++} ++ ++static void __init mtmips_clk_init(struct device_node *node) ++{ ++ const struct of_device_id *match; ++ const struct mtmips_clk_data *data; ++ struct mtmips_clk_priv *priv; ++ struct clk_hw_onecell_data *clk_data; ++ int ret, i, count; ++ ++ priv = kzalloc(sizeof(*priv), GFP_KERNEL); ++ if (!priv) ++ return; ++ ++ priv->sysc = syscon_node_to_regmap(node); ++ if (IS_ERR(priv->sysc)) { ++ pr_err("Could not get sysc syscon regmap\n"); ++ goto free_clk_priv; ++ } ++ ++ mtmips_clk_regs_init(node, priv); ++ ++ match = of_match_node(mtmips_of_match, node); ++ if (WARN_ON(!match)) ++ return; ++ ++ data = match->data; ++ priv->data = data; ++ count = priv->data->num_clk_base + priv->data->num_clk_fixed + ++ priv->data->num_clk_factor + priv->data->num_clk_periph; ++ clk_data = kzalloc(struct_size(clk_data, hws, count), GFP_KERNEL); ++ if (!clk_data) ++ goto free_clk_priv; ++ ++ ret = mtmips_register_clocks(node, clk_data, priv); ++ if (ret) { ++ pr_err("Couldn't register top clocks\n"); ++ goto free_clk_data; ++ } ++ ++ ret = mtmips_register_fixed_clocks(clk_data, priv); ++ if (ret) { ++ pr_err("Couldn't register fixed clocks\n"); ++ goto unreg_clk_top; ++ } ++ ++ ret = mtmips_register_factor_clocks(clk_data, priv); ++ if (ret) { ++ pr_err("Couldn't register factor clocks\n"); ++ goto unreg_clk_fixed; ++ } ++ ++ ret = mtmips_register_pherip_clocks(node, clk_data, priv); ++ if (ret) { ++ pr_err("Couldn't register peripheral clocks\n"); ++ goto unreg_clk_factor; ++ } ++ ++ clk_data->num = count; ++ ++ ret = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); ++ if (ret) { ++ pr_err("Couldn't add clk hw provider\n"); ++ goto unreg_clk_periph; ++ } ++ ++ return; ++ ++unreg_clk_periph: ++ for (i = 0; i < priv->data->num_clk_periph; i++) { ++ struct mtmips_clk *sclk = &priv->data->clk_periph[i]; ++ ++ clk_hw_unregister(&sclk->hw); ++ } ++ ++unreg_clk_factor: ++ for (i = 0; i < priv->data->num_clk_factor; i++) { ++ struct mtmips_clk_factor *sclk = &priv->data->clk_factor[i]; ++ ++ clk_hw_unregister_fixed_factor(sclk->hw); ++ } ++ ++unreg_clk_fixed: ++ for (i = 0; i < priv->data->num_clk_fixed; i++) { ++ struct mtmips_clk_fixed *sclk = &priv->data->clk_fixed[i]; ++ ++ clk_hw_unregister_fixed_rate(sclk->hw); ++ } ++ ++unreg_clk_top: ++ for (i = 0; i < priv->data->num_clk_base; i++) { ++ struct mtmips_clk *sclk = &priv->data->clk_base[i]; ++ ++ clk_hw_unregister(&sclk->hw); ++ } ++ ++free_clk_data: ++ kfree(clk_data); ++ ++free_clk_priv: ++ kfree(priv); ++} ++CLK_OF_DECLARE_DRIVER(rt2880_clk, "ralink,rt2880-sysc", mtmips_clk_init); ++CLK_OF_DECLARE_DRIVER(rt3050_clk, "ralink,rt3050-sysc", mtmips_clk_init); ++CLK_OF_DECLARE_DRIVER(rt3052_clk, "ralink,rt3052-sysc", mtmips_clk_init); ++CLK_OF_DECLARE_DRIVER(rt3352_clk, "ralink,rt3352-sysc", mtmips_clk_init); ++CLK_OF_DECLARE_DRIVER(rt3883_clk, "ralink,rt3883-sysc", mtmips_clk_init); ++CLK_OF_DECLARE_DRIVER(rt5350_clk, "ralink,rt5350-sysc", mtmips_clk_init); ++CLK_OF_DECLARE_DRIVER(mt7620_clk, "ralink,mt7620-sysc", mtmips_clk_init); ++CLK_OF_DECLARE_DRIVER(mt7628_clk, "ralink,mt7628-sysc", mtmips_clk_init); ++CLK_OF_DECLARE_DRIVER(mt7688_clk, "ralink,mt7688-sysc", mtmips_clk_init); ++ ++struct mtmips_rst { ++ struct reset_controller_dev rcdev; ++ struct regmap *sysc; ++}; ++ ++static struct mtmips_rst *to_mtmips_rst(struct reset_controller_dev *dev) ++{ ++ return container_of(dev, struct mtmips_rst, rcdev); ++} ++ ++static int mtmips_assert_device(struct reset_controller_dev *rcdev, ++ unsigned long id) ++{ ++ struct mtmips_rst *data = to_mtmips_rst(rcdev); ++ struct regmap *sysc = data->sysc; ++ ++ return regmap_update_bits(sysc, SYSC_REG_RESET_CTRL, BIT(id), BIT(id)); ++} ++ ++static int mtmips_deassert_device(struct reset_controller_dev *rcdev, ++ unsigned long id) ++{ ++ struct mtmips_rst *data = to_mtmips_rst(rcdev); ++ struct regmap *sysc = data->sysc; ++ ++ return regmap_update_bits(sysc, SYSC_REG_RESET_CTRL, BIT(id), 0); ++} ++ ++static int mtmips_reset_device(struct reset_controller_dev *rcdev, ++ unsigned long id) ++{ ++ int ret; ++ ++ ret = mtmips_assert_device(rcdev, id); ++ if (ret < 0) ++ return ret; ++ ++ return mtmips_deassert_device(rcdev, id); ++} ++ ++static int mtmips_rst_xlate(struct reset_controller_dev *rcdev, ++ const struct of_phandle_args *reset_spec) ++{ ++ unsigned long id = reset_spec->args[0]; ++ ++ if (id == 0 || id >= rcdev->nr_resets) ++ return -EINVAL; ++ ++ return id; ++} ++ ++static const struct reset_control_ops reset_ops = { ++ .reset = mtmips_reset_device, ++ .assert = mtmips_assert_device, ++ .deassert = mtmips_deassert_device ++}; ++ ++static int mtmips_reset_init(struct device *dev, struct regmap *sysc) ++{ ++ struct mtmips_rst *rst_data; ++ ++ rst_data = devm_kzalloc(dev, sizeof(*rst_data), GFP_KERNEL); ++ if (!rst_data) ++ return -ENOMEM; ++ ++ rst_data->sysc = sysc; ++ rst_data->rcdev.ops = &reset_ops; ++ rst_data->rcdev.owner = THIS_MODULE; ++ rst_data->rcdev.nr_resets = 32; ++ rst_data->rcdev.of_reset_n_cells = 1; ++ rst_data->rcdev.of_xlate = mtmips_rst_xlate; ++ rst_data->rcdev.of_node = dev_of_node(dev); ++ ++ return devm_reset_controller_register(dev, &rst_data->rcdev); ++} ++ ++static int mtmips_clk_probe(struct platform_device *pdev) ++{ ++ struct device_node *np = pdev->dev.of_node; ++ struct device *dev = &pdev->dev; ++ struct mtmips_clk_priv *priv; ++ int ret; ++ ++ priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); ++ if (!priv) ++ return -ENOMEM; ++ ++ priv->sysc = syscon_node_to_regmap(np); ++ if (IS_ERR(priv->sysc)) ++ return dev_err_probe(dev, PTR_ERR(priv->sysc), ++ "Could not get sysc syscon regmap\n"); ++ ++ ret = mtmips_reset_init(dev, priv->sysc); ++ if (ret) ++ return dev_err_probe(dev, ret, "Could not init reset controller\n"); ++ ++ return 0; ++} ++ ++static const struct of_device_id mtmips_clk_of_match[] = { ++ { .compatible = "ralink,rt2880-reset" }, ++ { .compatible = "ralink,rt2880-sysc" }, ++ { .compatible = "ralink,rt3050-sysc" }, ++ { .compatible = "ralink,rt3052-sysc" }, ++ { .compatible = "ralink,rt3352-sysc" }, ++ { .compatible = "ralink,rt3883-sysc" }, ++ { .compatible = "ralink,rt5350-sysc" }, ++ { .compatible = "ralink,mt7620-sysc" }, ++ { .compatible = "ralink,mt7628-sysc" }, ++ { .compatible = "ralink,mt7688-sysc" }, ++ {} ++}; ++ ++static struct platform_driver mtmips_clk_driver = { ++ .probe = mtmips_clk_probe, ++ .driver = { ++ .name = "mtmips-clk", ++ .of_match_table = mtmips_clk_of_match, ++ }, ++}; ++ ++static int __init mtmips_clk_reset_init(void) ++{ ++ return platform_driver_register(&mtmips_clk_driver); ++} ++arch_initcall(mtmips_clk_reset_init); diff --git a/target/linux/ramips/patches-5.15/005-v6.5-03-mips-ralink-rt288x-remove-clock-related-code.patch b/target/linux/ramips/patches-5.15/005-v6.5-03-mips-ralink-rt288x-remove-clock-related-code.patch new file mode 100644 index 00000000000..df4208b23da --- /dev/null +++ b/target/linux/ramips/patches-5.15/005-v6.5-03-mips-ralink-rt288x-remove-clock-related-code.patch @@ -0,0 +1,81 @@ +From ffcdf47379eae86dc8f8f02c62994dacf2c9038e Mon Sep 17 00:00:00 2001 +From: Sergio Paracuellos +Date: Mon, 19 Jun 2023 06:09:35 +0200 +Subject: [PATCH 3/9] mips: ralink: rt288x: remove clock related code + +A properly clock driver for ralink SoCs has been added. Hence there is no +need to have clock related code in 'arch/mips/ralink' folder anymore. + +Signed-off-by: Sergio Paracuellos +Signed-off-by: Thomas Bogendoerfer +--- + arch/mips/include/asm/mach-ralink/rt288x.h | 10 ---------- + arch/mips/ralink/rt288x.c | 31 ------------------------------ + 2 files changed, 41 deletions(-) + +--- a/arch/mips/include/asm/mach-ralink/rt288x.h ++++ b/arch/mips/include/asm/mach-ralink/rt288x.h +@@ -17,7 +17,6 @@ + #define SYSC_REG_CHIP_NAME1 0x04 + #define SYSC_REG_CHIP_ID 0x0c + #define SYSC_REG_SYSTEM_CONFIG 0x10 +-#define SYSC_REG_CLKCFG 0x30 + + #define RT2880_CHIP_NAME0 0x38325452 + #define RT2880_CHIP_NAME1 0x20203038 +@@ -26,15 +25,6 @@ + #define CHIP_ID_ID_SHIFT 8 + #define CHIP_ID_REV_MASK 0xff + +-#define SYSTEM_CONFIG_CPUCLK_SHIFT 20 +-#define SYSTEM_CONFIG_CPUCLK_MASK 0x3 +-#define SYSTEM_CONFIG_CPUCLK_250 0x0 +-#define SYSTEM_CONFIG_CPUCLK_266 0x1 +-#define SYSTEM_CONFIG_CPUCLK_280 0x2 +-#define SYSTEM_CONFIG_CPUCLK_300 0x3 +- +-#define CLKCFG_SRAM_CS_N_WDT BIT(9) +- + #define RT2880_SDRAM_BASE 0x08000000 + #define RT2880_MEM_SIZE_MIN 2 + #define RT2880_MEM_SIZE_MAX 128 +--- a/arch/mips/ralink/rt288x.c ++++ b/arch/mips/ralink/rt288x.c +@@ -17,37 +17,6 @@ + + #include "common.h" + +-void __init ralink_clk_init(void) +-{ +- unsigned long cpu_rate, wmac_rate = 40000000; +- u32 t = rt_sysc_r32(SYSC_REG_SYSTEM_CONFIG); +- t = ((t >> SYSTEM_CONFIG_CPUCLK_SHIFT) & SYSTEM_CONFIG_CPUCLK_MASK); +- +- switch (t) { +- case SYSTEM_CONFIG_CPUCLK_250: +- cpu_rate = 250000000; +- break; +- case SYSTEM_CONFIG_CPUCLK_266: +- cpu_rate = 266666667; +- break; +- case SYSTEM_CONFIG_CPUCLK_280: +- cpu_rate = 280000000; +- break; +- case SYSTEM_CONFIG_CPUCLK_300: +- cpu_rate = 300000000; +- break; +- } +- +- ralink_clk_add("cpu", cpu_rate); +- ralink_clk_add("300100.timer", cpu_rate / 2); +- ralink_clk_add("300120.watchdog", cpu_rate / 2); +- ralink_clk_add("300500.uart", cpu_rate / 2); +- ralink_clk_add("300900.i2c", cpu_rate / 2); +- ralink_clk_add("300c00.uartlite", cpu_rate / 2); +- ralink_clk_add("400000.ethernet", cpu_rate / 2); +- ralink_clk_add("480000.wmac", wmac_rate); +-} +- + void __init ralink_of_remap(void) + { + rt_sysc_membase = plat_of_remap_node("ralink,rt2880-sysc"); diff --git a/target/linux/ramips/patches-5.15/005-v6.5-04-mips-ralink-rt305x-remove-clock-related-code.patch b/target/linux/ramips/patches-5.15/005-v6.5-04-mips-ralink-rt305x-remove-clock-related-code.patch new file mode 100644 index 00000000000..12b4623b73e --- /dev/null +++ b/target/linux/ramips/patches-5.15/005-v6.5-04-mips-ralink-rt305x-remove-clock-related-code.patch @@ -0,0 +1,145 @@ +From daf73c70f69386fb15960526772ef584a4efcaf2 Mon Sep 17 00:00:00 2001 +From: Sergio Paracuellos +Date: Mon, 19 Jun 2023 06:09:36 +0200 +Subject: [PATCH 4/9] mips: ralink: rt305x: remove clock related code + +A properly clock driver for ralink SoCs has been added. Hence there is no +need to have clock related code in 'arch/mips/ralink' folder anymore. + +Signed-off-by: Sergio Paracuellos +Signed-off-by: Thomas Bogendoerfer +--- + arch/mips/include/asm/mach-ralink/rt305x.h | 21 -------- + arch/mips/ralink/rt305x.c | 78 ------------------------------ + 2 files changed, 99 deletions(-) + +--- a/arch/mips/include/asm/mach-ralink/rt305x.h ++++ b/arch/mips/include/asm/mach-ralink/rt305x.h +@@ -66,26 +66,9 @@ static inline int soc_is_rt5350(void) + #define CHIP_ID_ID_SHIFT 8 + #define CHIP_ID_REV_MASK 0xff + +-#define RT305X_SYSCFG_CPUCLK_SHIFT 18 +-#define RT305X_SYSCFG_CPUCLK_MASK 0x1 +-#define RT305X_SYSCFG_CPUCLK_LOW 0x0 +-#define RT305X_SYSCFG_CPUCLK_HIGH 0x1 +- + #define RT305X_SYSCFG_SRAM_CS0_MODE_SHIFT 2 +-#define RT305X_SYSCFG_CPUCLK_MASK 0x1 + #define RT305X_SYSCFG_SRAM_CS0_MODE_WDT 0x1 + +-#define RT3352_SYSCFG0_CPUCLK_SHIFT 8 +-#define RT3352_SYSCFG0_CPUCLK_MASK 0x1 +-#define RT3352_SYSCFG0_CPUCLK_LOW 0x0 +-#define RT3352_SYSCFG0_CPUCLK_HIGH 0x1 +- +-#define RT5350_SYSCFG0_CPUCLK_SHIFT 8 +-#define RT5350_SYSCFG0_CPUCLK_MASK 0x3 +-#define RT5350_SYSCFG0_CPUCLK_360 0x0 +-#define RT5350_SYSCFG0_CPUCLK_320 0x2 +-#define RT5350_SYSCFG0_CPUCLK_300 0x3 +- + #define RT5350_SYSCFG0_DRAM_SIZE_SHIFT 12 + #define RT5350_SYSCFG0_DRAM_SIZE_MASK 7 + #define RT5350_SYSCFG0_DRAM_SIZE_2M 0 +@@ -116,13 +99,9 @@ static inline int soc_is_rt5350(void) + + #define RT3352_SYSC_REG_SYSCFG0 0x010 + #define RT3352_SYSC_REG_SYSCFG1 0x014 +-#define RT3352_SYSC_REG_CLKCFG1 0x030 + #define RT3352_SYSC_REG_RSTCTRL 0x034 + #define RT3352_SYSC_REG_USB_PS 0x05c + +-#define RT3352_CLKCFG0_XTAL_SEL BIT(20) +-#define RT3352_CLKCFG1_UPHY0_CLK_EN BIT(18) +-#define RT3352_CLKCFG1_UPHY1_CLK_EN BIT(20) + #define RT3352_RSTCTRL_UHST BIT(22) + #define RT3352_RSTCTRL_UDEV BIT(25) + #define RT3352_SYSCFG1_USB0_HOST_MODE BIT(10) +--- a/arch/mips/ralink/rt305x.c ++++ b/arch/mips/ralink/rt305x.c +@@ -53,84 +53,6 @@ static unsigned long rt5350_get_mem_size + return ret; + } + +-void __init ralink_clk_init(void) +-{ +- unsigned long cpu_rate, sys_rate, wdt_rate, uart_rate; +- unsigned long wmac_rate = 40000000; +- +- u32 t = rt_sysc_r32(SYSC_REG_SYSTEM_CONFIG); +- +- if (soc_is_rt305x() || soc_is_rt3350()) { +- t = (t >> RT305X_SYSCFG_CPUCLK_SHIFT) & +- RT305X_SYSCFG_CPUCLK_MASK; +- switch (t) { +- case RT305X_SYSCFG_CPUCLK_LOW: +- cpu_rate = 320000000; +- break; +- case RT305X_SYSCFG_CPUCLK_HIGH: +- cpu_rate = 384000000; +- break; +- } +- sys_rate = uart_rate = wdt_rate = cpu_rate / 3; +- } else if (soc_is_rt3352()) { +- t = (t >> RT3352_SYSCFG0_CPUCLK_SHIFT) & +- RT3352_SYSCFG0_CPUCLK_MASK; +- switch (t) { +- case RT3352_SYSCFG0_CPUCLK_LOW: +- cpu_rate = 384000000; +- break; +- case RT3352_SYSCFG0_CPUCLK_HIGH: +- cpu_rate = 400000000; +- break; +- } +- sys_rate = wdt_rate = cpu_rate / 3; +- uart_rate = 40000000; +- } else if (soc_is_rt5350()) { +- t = (t >> RT5350_SYSCFG0_CPUCLK_SHIFT) & +- RT5350_SYSCFG0_CPUCLK_MASK; +- switch (t) { +- case RT5350_SYSCFG0_CPUCLK_360: +- cpu_rate = 360000000; +- sys_rate = cpu_rate / 3; +- break; +- case RT5350_SYSCFG0_CPUCLK_320: +- cpu_rate = 320000000; +- sys_rate = cpu_rate / 4; +- break; +- case RT5350_SYSCFG0_CPUCLK_300: +- cpu_rate = 300000000; +- sys_rate = cpu_rate / 3; +- break; +- default: +- BUG(); +- } +- uart_rate = 40000000; +- wdt_rate = sys_rate; +- } else { +- BUG(); +- } +- +- if (soc_is_rt3352() || soc_is_rt5350()) { +- u32 val = rt_sysc_r32(RT3352_SYSC_REG_SYSCFG0); +- +- if (!(val & RT3352_CLKCFG0_XTAL_SEL)) +- wmac_rate = 20000000; +- } +- +- ralink_clk_add("cpu", cpu_rate); +- ralink_clk_add("sys", sys_rate); +- ralink_clk_add("10000900.i2c", uart_rate); +- ralink_clk_add("10000a00.i2s", uart_rate); +- ralink_clk_add("10000b00.spi", sys_rate); +- ralink_clk_add("10000b40.spi", sys_rate); +- ralink_clk_add("10000100.timer", wdt_rate); +- ralink_clk_add("10000120.watchdog", wdt_rate); +- ralink_clk_add("10000500.uart", uart_rate); +- ralink_clk_add("10000c00.uartlite", uart_rate); +- ralink_clk_add("10100000.ethernet", sys_rate); +- ralink_clk_add("10180000.wmac", wmac_rate); +-} +- + void __init ralink_of_remap(void) + { + rt_sysc_membase = plat_of_remap_node("ralink,rt3050-sysc"); diff --git a/target/linux/ramips/patches-5.15/005-v6.5-05-mips-ralink-rt3883-remove-clock-related-code.patch b/target/linux/ramips/patches-5.15/005-v6.5-05-mips-ralink-rt3883-remove-clock-related-code.patch new file mode 100644 index 00000000000..c13c4215f3a --- /dev/null +++ b/target/linux/ramips/patches-5.15/005-v6.5-05-mips-ralink-rt3883-remove-clock-related-code.patch @@ -0,0 +1,85 @@ +From 7cd1bb48885449a9323c7ff0f10012925e93b4e1 Mon Sep 17 00:00:00 2001 +From: Sergio Paracuellos +Date: Mon, 19 Jun 2023 06:09:37 +0200 +Subject: [PATCH 5/9] mips: ralink: rt3883: remove clock related code + +A properly clock driver for ralink SoCs has been added. Hence there is no +need to have clock related code in 'arch/mips/ralink' folder anymore. + +Signed-off-by: Sergio Paracuellos +Signed-off-by: Thomas Bogendoerfer +--- + arch/mips/include/asm/mach-ralink/rt3883.h | 8 ------ + arch/mips/ralink/rt3883.c | 44 ------------------------------ + 2 files changed, 52 deletions(-) + +--- a/arch/mips/include/asm/mach-ralink/rt3883.h ++++ b/arch/mips/include/asm/mach-ralink/rt3883.h +@@ -90,14 +90,6 @@ + #define RT3883_REVID_VER_ID_SHIFT 8 + #define RT3883_REVID_ECO_ID_MASK 0x0f + +-#define RT3883_SYSCFG0_DRAM_TYPE_DDR2 BIT(17) +-#define RT3883_SYSCFG0_CPUCLK_SHIFT 8 +-#define RT3883_SYSCFG0_CPUCLK_MASK 0x3 +-#define RT3883_SYSCFG0_CPUCLK_250 0x0 +-#define RT3883_SYSCFG0_CPUCLK_384 0x1 +-#define RT3883_SYSCFG0_CPUCLK_480 0x2 +-#define RT3883_SYSCFG0_CPUCLK_500 0x3 +- + #define RT3883_SYSCFG1_USB0_HOST_MODE BIT(10) + #define RT3883_SYSCFG1_PCIE_RC_MODE BIT(8) + #define RT3883_SYSCFG1_PCI_HOST_MODE BIT(7) +--- a/arch/mips/ralink/rt3883.c ++++ b/arch/mips/ralink/rt3883.c +@@ -17,50 +17,6 @@ + + #include "common.h" + +-void __init ralink_clk_init(void) +-{ +- unsigned long cpu_rate, sys_rate; +- u32 syscfg0; +- u32 clksel; +- u32 ddr2; +- +- syscfg0 = rt_sysc_r32(RT3883_SYSC_REG_SYSCFG0); +- clksel = ((syscfg0 >> RT3883_SYSCFG0_CPUCLK_SHIFT) & +- RT3883_SYSCFG0_CPUCLK_MASK); +- ddr2 = syscfg0 & RT3883_SYSCFG0_DRAM_TYPE_DDR2; +- +- switch (clksel) { +- case RT3883_SYSCFG0_CPUCLK_250: +- cpu_rate = 250000000; +- sys_rate = (ddr2) ? 125000000 : 83000000; +- break; +- case RT3883_SYSCFG0_CPUCLK_384: +- cpu_rate = 384000000; +- sys_rate = (ddr2) ? 128000000 : 96000000; +- break; +- case RT3883_SYSCFG0_CPUCLK_480: +- cpu_rate = 480000000; +- sys_rate = (ddr2) ? 160000000 : 120000000; +- break; +- case RT3883_SYSCFG0_CPUCLK_500: +- cpu_rate = 500000000; +- sys_rate = (ddr2) ? 166000000 : 125000000; +- break; +- } +- +- ralink_clk_add("cpu", cpu_rate); +- ralink_clk_add("10000100.timer", sys_rate); +- ralink_clk_add("10000120.watchdog", sys_rate); +- ralink_clk_add("10000500.uart", 40000000); +- ralink_clk_add("10000900.i2c", 40000000); +- ralink_clk_add("10000a00.i2s", 40000000); +- ralink_clk_add("10000b00.spi", sys_rate); +- ralink_clk_add("10000b40.spi", sys_rate); +- ralink_clk_add("10000c00.uartlite", 40000000); +- ralink_clk_add("10100000.ethernet", sys_rate); +- ralink_clk_add("10180000.wmac", 40000000); +-} +- + void __init ralink_of_remap(void) + { + rt_sysc_membase = plat_of_remap_node("ralink,rt3883-sysc"); diff --git a/target/linux/ramips/patches-5.15/005-v6.5-06-mips-ralink-mt7620-remove-clock-related-code.patch b/target/linux/ramips/patches-5.15/005-v6.5-06-mips-ralink-mt7620-remove-clock-related-code.patch new file mode 100644 index 00000000000..7b83cf54b49 --- /dev/null +++ b/target/linux/ramips/patches-5.15/005-v6.5-06-mips-ralink-mt7620-remove-clock-related-code.patch @@ -0,0 +1,327 @@ +From 04b153abdfcbaba70ceef5a846067d4447fd0078 Mon Sep 17 00:00:00 2001 +From: Sergio Paracuellos +Date: Mon, 19 Jun 2023 06:09:38 +0200 +Subject: [PATCH 6/9] mips: ralink: mt7620: remove clock related code + +A proper clock driver for ralink SoCs has been added. Hence there is no +need to have clock related code in 'arch/mips/ralink' folder anymore. +Since this is the last clock related code removal, remove also remaining +prototypes in 'common.h' header file. + +Signed-off-by: Sergio Paracuellos +Signed-off-by: Thomas Bogendoerfer +--- + arch/mips/include/asm/mach-ralink/mt7620.h | 35 ----- + arch/mips/ralink/common.h | 3 - + arch/mips/ralink/mt7620.c | 226 ----------------------------- + 3 files changed, 264 deletions(-) + +--- a/arch/mips/include/asm/mach-ralink/mt7620.h ++++ b/arch/mips/include/asm/mach-ralink/mt7620.h +@@ -19,52 +19,17 @@ + #define SYSC_REG_CHIP_REV 0x0c + #define SYSC_REG_SYSTEM_CONFIG0 0x10 + #define SYSC_REG_SYSTEM_CONFIG1 0x14 +-#define SYSC_REG_CLKCFG0 0x2c +-#define SYSC_REG_CPU_SYS_CLKCFG 0x3c +-#define SYSC_REG_CPLL_CONFIG0 0x54 +-#define SYSC_REG_CPLL_CONFIG1 0x58 + + #define MT7620_CHIP_NAME0 0x3637544d + #define MT7620_CHIP_NAME1 0x20203032 + #define MT7628_CHIP_NAME1 0x20203832 + +-#define SYSCFG0_XTAL_FREQ_SEL BIT(6) +- + #define CHIP_REV_PKG_MASK 0x1 + #define CHIP_REV_PKG_SHIFT 16 + #define CHIP_REV_VER_MASK 0xf + #define CHIP_REV_VER_SHIFT 8 + #define CHIP_REV_ECO_MASK 0xf + +-#define CLKCFG0_PERI_CLK_SEL BIT(4) +- +-#define CPU_SYS_CLKCFG_OCP_RATIO_SHIFT 16 +-#define CPU_SYS_CLKCFG_OCP_RATIO_MASK 0xf +-#define CPU_SYS_CLKCFG_OCP_RATIO_1 0 /* 1:1 (Reserved) */ +-#define CPU_SYS_CLKCFG_OCP_RATIO_1_5 1 /* 1:1.5 (Reserved) */ +-#define CPU_SYS_CLKCFG_OCP_RATIO_2 2 /* 1:2 */ +-#define CPU_SYS_CLKCFG_OCP_RATIO_2_5 3 /* 1:2.5 (Reserved) */ +-#define CPU_SYS_CLKCFG_OCP_RATIO_3 4 /* 1:3 */ +-#define CPU_SYS_CLKCFG_OCP_RATIO_3_5 5 /* 1:3.5 (Reserved) */ +-#define CPU_SYS_CLKCFG_OCP_RATIO_4 6 /* 1:4 */ +-#define CPU_SYS_CLKCFG_OCP_RATIO_5 7 /* 1:5 */ +-#define CPU_SYS_CLKCFG_OCP_RATIO_10 8 /* 1:10 */ +-#define CPU_SYS_CLKCFG_CPU_FDIV_SHIFT 8 +-#define CPU_SYS_CLKCFG_CPU_FDIV_MASK 0x1f +-#define CPU_SYS_CLKCFG_CPU_FFRAC_SHIFT 0 +-#define CPU_SYS_CLKCFG_CPU_FFRAC_MASK 0x1f +- +-#define CPLL_CFG0_SW_CFG BIT(31) +-#define CPLL_CFG0_PLL_MULT_RATIO_SHIFT 16 +-#define CPLL_CFG0_PLL_MULT_RATIO_MASK 0x7 +-#define CPLL_CFG0_LC_CURFCK BIT(15) +-#define CPLL_CFG0_BYPASS_REF_CLK BIT(14) +-#define CPLL_CFG0_PLL_DIV_RATIO_SHIFT 10 +-#define CPLL_CFG0_PLL_DIV_RATIO_MASK 0x3 +- +-#define CPLL_CFG1_CPU_AUX1 BIT(25) +-#define CPLL_CFG1_CPU_AUX0 BIT(24) +- + #define SYSCFG0_DRAM_TYPE_MASK 0x3 + #define SYSCFG0_DRAM_TYPE_SHIFT 4 + #define SYSCFG0_DRAM_TYPE_SDRAM 0 +--- a/arch/mips/ralink/common.h ++++ b/arch/mips/ralink/common.h +@@ -23,9 +23,6 @@ extern struct ralink_soc_info soc_info; + + extern void ralink_of_remap(void); + +-extern void ralink_clk_init(void); +-extern void ralink_clk_add(const char *dev, unsigned long rate); +- + extern void ralink_rst_init(void); + + extern void __init prom_soc_init(struct ralink_soc_info *soc_info); +--- a/arch/mips/ralink/mt7620.c ++++ b/arch/mips/ralink/mt7620.c +@@ -34,12 +34,6 @@ + #define PMU1_CFG 0x8C + #define DIG_SW_SEL BIT(25) + +-/* clock scaling */ +-#define CLKCFG_FDIV_MASK 0x1f00 +-#define CLKCFG_FDIV_USB_VAL 0x0300 +-#define CLKCFG_FFRAC_MASK 0x001f +-#define CLKCFG_FFRAC_USB_VAL 0x0003 +- + /* EFUSE bits */ + #define EFUSE_MT7688 0x100000 + +@@ -49,226 +43,6 @@ + /* does the board have sdram or ddram */ + static int dram_type; + +-static __init u32 +-mt7620_calc_rate(u32 ref_rate, u32 mul, u32 div) +-{ +- u64 t; +- +- t = ref_rate; +- t *= mul; +- do_div(t, div); +- +- return t; +-} +- +-#define MHZ(x) ((x) * 1000 * 1000) +- +-static __init unsigned long +-mt7620_get_xtal_rate(void) +-{ +- u32 reg; +- +- reg = rt_sysc_r32(SYSC_REG_SYSTEM_CONFIG0); +- if (reg & SYSCFG0_XTAL_FREQ_SEL) +- return MHZ(40); +- +- return MHZ(20); +-} +- +-static __init unsigned long +-mt7620_get_periph_rate(unsigned long xtal_rate) +-{ +- u32 reg; +- +- reg = rt_sysc_r32(SYSC_REG_CLKCFG0); +- if (reg & CLKCFG0_PERI_CLK_SEL) +- return xtal_rate; +- +- return MHZ(40); +-} +- +-static const u32 mt7620_clk_divider[] __initconst = { 2, 3, 4, 8 }; +- +-static __init unsigned long +-mt7620_get_cpu_pll_rate(unsigned long xtal_rate) +-{ +- u32 reg; +- u32 mul; +- u32 div; +- +- reg = rt_sysc_r32(SYSC_REG_CPLL_CONFIG0); +- if (reg & CPLL_CFG0_BYPASS_REF_CLK) +- return xtal_rate; +- +- if ((reg & CPLL_CFG0_SW_CFG) == 0) +- return MHZ(600); +- +- mul = (reg >> CPLL_CFG0_PLL_MULT_RATIO_SHIFT) & +- CPLL_CFG0_PLL_MULT_RATIO_MASK; +- mul += 24; +- if (reg & CPLL_CFG0_LC_CURFCK) +- mul *= 2; +- +- div = (reg >> CPLL_CFG0_PLL_DIV_RATIO_SHIFT) & +- CPLL_CFG0_PLL_DIV_RATIO_MASK; +- +- WARN_ON(div >= ARRAY_SIZE(mt7620_clk_divider)); +- +- return mt7620_calc_rate(xtal_rate, mul, mt7620_clk_divider[div]); +-} +- +-static __init unsigned long +-mt7620_get_pll_rate(unsigned long xtal_rate, unsigned long cpu_pll_rate) +-{ +- u32 reg; +- +- reg = rt_sysc_r32(SYSC_REG_CPLL_CONFIG1); +- if (reg & CPLL_CFG1_CPU_AUX1) +- return xtal_rate; +- +- if (reg & CPLL_CFG1_CPU_AUX0) +- return MHZ(480); +- +- return cpu_pll_rate; +-} +- +-static __init unsigned long +-mt7620_get_cpu_rate(unsigned long pll_rate) +-{ +- u32 reg; +- u32 mul; +- u32 div; +- +- reg = rt_sysc_r32(SYSC_REG_CPU_SYS_CLKCFG); +- +- mul = reg & CPU_SYS_CLKCFG_CPU_FFRAC_MASK; +- div = (reg >> CPU_SYS_CLKCFG_CPU_FDIV_SHIFT) & +- CPU_SYS_CLKCFG_CPU_FDIV_MASK; +- +- return mt7620_calc_rate(pll_rate, mul, div); +-} +- +-static const u32 mt7620_ocp_dividers[16] __initconst = { +- [CPU_SYS_CLKCFG_OCP_RATIO_2] = 2, +- [CPU_SYS_CLKCFG_OCP_RATIO_3] = 3, +- [CPU_SYS_CLKCFG_OCP_RATIO_4] = 4, +- [CPU_SYS_CLKCFG_OCP_RATIO_5] = 5, +- [CPU_SYS_CLKCFG_OCP_RATIO_10] = 10, +-}; +- +-static __init unsigned long +-mt7620_get_dram_rate(unsigned long pll_rate) +-{ +- if (dram_type == SYSCFG0_DRAM_TYPE_SDRAM) +- return pll_rate / 4; +- +- return pll_rate / 3; +-} +- +-static __init unsigned long +-mt7620_get_sys_rate(unsigned long cpu_rate) +-{ +- u32 reg; +- u32 ocp_ratio; +- u32 div; +- +- reg = rt_sysc_r32(SYSC_REG_CPU_SYS_CLKCFG); +- +- ocp_ratio = (reg >> CPU_SYS_CLKCFG_OCP_RATIO_SHIFT) & +- CPU_SYS_CLKCFG_OCP_RATIO_MASK; +- +- if (WARN_ON(ocp_ratio >= ARRAY_SIZE(mt7620_ocp_dividers))) +- return cpu_rate; +- +- div = mt7620_ocp_dividers[ocp_ratio]; +- if (WARN(!div, "invalid divider for OCP ratio %u", ocp_ratio)) +- return cpu_rate; +- +- return cpu_rate / div; +-} +- +-void __init ralink_clk_init(void) +-{ +- unsigned long xtal_rate; +- unsigned long cpu_pll_rate; +- unsigned long pll_rate; +- unsigned long cpu_rate; +- unsigned long sys_rate; +- unsigned long dram_rate; +- unsigned long periph_rate; +- unsigned long pcmi2s_rate; +- +- xtal_rate = mt7620_get_xtal_rate(); +- +-#define RFMT(label) label ":%lu.%03luMHz " +-#define RINT(x) ((x) / 1000000) +-#define RFRAC(x) (((x) / 1000) % 1000) +- +- if (is_mt76x8()) { +- if (xtal_rate == MHZ(40)) +- cpu_rate = MHZ(580); +- else +- cpu_rate = MHZ(575); +- dram_rate = sys_rate = cpu_rate / 3; +- periph_rate = MHZ(40); +- pcmi2s_rate = MHZ(480); +- +- ralink_clk_add("10000d00.uartlite", periph_rate); +- ralink_clk_add("10000e00.uartlite", periph_rate); +- } else { +- cpu_pll_rate = mt7620_get_cpu_pll_rate(xtal_rate); +- pll_rate = mt7620_get_pll_rate(xtal_rate, cpu_pll_rate); +- +- cpu_rate = mt7620_get_cpu_rate(pll_rate); +- dram_rate = mt7620_get_dram_rate(pll_rate); +- sys_rate = mt7620_get_sys_rate(cpu_rate); +- periph_rate = mt7620_get_periph_rate(xtal_rate); +- pcmi2s_rate = periph_rate; +- +- pr_debug(RFMT("XTAL") RFMT("CPU_PLL") RFMT("PLL"), +- RINT(xtal_rate), RFRAC(xtal_rate), +- RINT(cpu_pll_rate), RFRAC(cpu_pll_rate), +- RINT(pll_rate), RFRAC(pll_rate)); +- +- ralink_clk_add("10000500.uart", periph_rate); +- } +- +- pr_debug(RFMT("CPU") RFMT("DRAM") RFMT("SYS") RFMT("PERIPH"), +- RINT(cpu_rate), RFRAC(cpu_rate), +- RINT(dram_rate), RFRAC(dram_rate), +- RINT(sys_rate), RFRAC(sys_rate), +- RINT(periph_rate), RFRAC(periph_rate)); +-#undef RFRAC +-#undef RINT +-#undef RFMT +- +- ralink_clk_add("cpu", cpu_rate); +- ralink_clk_add("10000100.timer", periph_rate); +- ralink_clk_add("10000120.watchdog", periph_rate); +- ralink_clk_add("10000900.i2c", periph_rate); +- ralink_clk_add("10000a00.i2s", pcmi2s_rate); +- ralink_clk_add("10000b00.spi", sys_rate); +- ralink_clk_add("10000b40.spi", sys_rate); +- ralink_clk_add("10000c00.uartlite", periph_rate); +- ralink_clk_add("10000d00.uart1", periph_rate); +- ralink_clk_add("10000e00.uart2", periph_rate); +- ralink_clk_add("10180000.wmac", xtal_rate); +- +- if (IS_ENABLED(CONFIG_USB) && !is_mt76x8()) { +- /* +- * When the CPU goes into sleep mode, the BUS clock will be +- * too low for USB to function properly. Adjust the busses +- * fractional divider to fix this +- */ +- u32 val = rt_sysc_r32(SYSC_REG_CPU_SYS_CLKCFG); +- +- val &= ~(CLKCFG_FDIV_MASK | CLKCFG_FFRAC_MASK); +- val |= CLKCFG_FDIV_USB_VAL | CLKCFG_FFRAC_USB_VAL; +- +- rt_sysc_w32(val, SYSC_REG_CPU_SYS_CLKCFG); +- } +-} +- + void __init ralink_of_remap(void) + { + rt_sysc_membase = plat_of_remap_node("ralink,mt7620a-sysc"); diff --git a/target/linux/ramips/patches-5.15/005-v6.5-07-mips-ralink-remove-reset-related-code.patch b/target/linux/ramips/patches-5.15/005-v6.5-07-mips-ralink-remove-reset-related-code.patch new file mode 100644 index 00000000000..bdd9fcfd336 --- /dev/null +++ b/target/linux/ramips/patches-5.15/005-v6.5-07-mips-ralink-remove-reset-related-code.patch @@ -0,0 +1,121 @@ +From 201ddc05777cd8e084b508bcdda22214bfe2895e Mon Sep 17 00:00:00 2001 +From: Sergio Paracuellos +Date: Mon, 19 Jun 2023 06:09:39 +0200 +Subject: [PATCH 7/9] mips: ralink: remove reset related code + +A proper clock driver for ralink SoCs has been added. This driver is also +a reset provider for the SoC. Hence there is no need to have reset related +code in 'arch/mips/ralink' folder anymore. The only code that remains is +the one related with mips_reboot_setup where a PCI reset is performed. +We maintain this because I cannot test old ralink board with PCI to be +sure all works if we remove also this code. + +Signed-off-by: Sergio Paracuellos +Signed-off-by: Thomas Bogendoerfer +--- + arch/mips/ralink/common.h | 2 -- + arch/mips/ralink/of.c | 4 ---- + arch/mips/ralink/reset.c | 61 ----------------------------------------------- + 3 files changed, 67 deletions(-) + +--- a/arch/mips/ralink/common.h ++++ b/arch/mips/ralink/common.h +@@ -23,8 +23,6 @@ extern struct ralink_soc_info soc_info; + + extern void ralink_of_remap(void); + +-extern void ralink_rst_init(void); +- + extern void __init prom_soc_init(struct ralink_soc_info *soc_info); + + __iomem void *plat_of_remap_node(const char *node); +--- a/arch/mips/ralink/of.c ++++ b/arch/mips/ralink/of.c +@@ -95,10 +95,6 @@ static int __init plat_of_setup(void) + { + __dt_register_buses(soc_info.compatible, "palmbus"); + +- /* make sure that the reset controller is setup early */ +- if (ralink_soc != MT762X_SOC_MT7621AT) +- ralink_rst_init(); +- + return 0; + } + +--- a/arch/mips/ralink/reset.c ++++ b/arch/mips/ralink/reset.c +@@ -10,7 +10,6 @@ + #include + #include + #include +-#include + + #include + +@@ -22,66 +21,6 @@ + #define RSTCTL_RESET_PCI BIT(26) + #define RSTCTL_RESET_SYSTEM BIT(0) + +-static int ralink_assert_device(struct reset_controller_dev *rcdev, +- unsigned long id) +-{ +- u32 val; +- +- if (id == 0) +- return -1; +- +- val = rt_sysc_r32(SYSC_REG_RESET_CTRL); +- val |= BIT(id); +- rt_sysc_w32(val, SYSC_REG_RESET_CTRL); +- +- return 0; +-} +- +-static int ralink_deassert_device(struct reset_controller_dev *rcdev, +- unsigned long id) +-{ +- u32 val; +- +- if (id == 0) +- return -1; +- +- val = rt_sysc_r32(SYSC_REG_RESET_CTRL); +- val &= ~BIT(id); +- rt_sysc_w32(val, SYSC_REG_RESET_CTRL); +- +- return 0; +-} +- +-static int ralink_reset_device(struct reset_controller_dev *rcdev, +- unsigned long id) +-{ +- ralink_assert_device(rcdev, id); +- return ralink_deassert_device(rcdev, id); +-} +- +-static const struct reset_control_ops reset_ops = { +- .reset = ralink_reset_device, +- .assert = ralink_assert_device, +- .deassert = ralink_deassert_device, +-}; +- +-static struct reset_controller_dev reset_dev = { +- .ops = &reset_ops, +- .owner = THIS_MODULE, +- .nr_resets = 32, +- .of_reset_n_cells = 1, +-}; +- +-void ralink_rst_init(void) +-{ +- reset_dev.of_node = of_find_compatible_node(NULL, NULL, +- "ralink,rt2880-reset"); +- if (!reset_dev.of_node) +- pr_err("Failed to find reset controller node"); +- else +- reset_controller_register(&reset_dev); +-} +- + static void ralink_restart(char *command) + { + if (IS_ENABLED(CONFIG_PCI)) { diff --git a/target/linux/ramips/patches-5.15/005-v6.5-08-mips-ralink-get-cpu-rate-from-new-driver-code.patch b/target/linux/ramips/patches-5.15/005-v6.5-08-mips-ralink-get-cpu-rate-from-new-driver-code.patch new file mode 100644 index 00000000000..2430c1f3753 --- /dev/null +++ b/target/linux/ramips/patches-5.15/005-v6.5-08-mips-ralink-get-cpu-rate-from-new-driver-code.patch @@ -0,0 +1,102 @@ +From ad38c17b0c26ae2108b50ac1eb0281a2e1ce08e9 Mon Sep 17 00:00:00 2001 +From: Sergio Paracuellos +Date: Mon, 19 Jun 2023 06:09:40 +0200 +Subject: [PATCH 8/9] mips: ralink: get cpu rate from new driver code + +At very early stage on boot, there is a need to set 'mips_hpt_frequency'. +This timer frequency is a half of the CPU frequency. To get clocks properly +set we need to call to 'of_clk_init()' and properly get cpu clock frequency +afterwards. Depending on the SoC, CPU clock index and compatible differs, so +use them to get the proper clock frm the clock provider. Hence, adapt code +to be aligned with new clock driver. + +Signed-off-by: Sergio Paracuellos +Signed-off-by: Thomas Bogendoerfer +--- + arch/mips/ralink/clk.c | 61 ++++++++++++++++++++++++++++++++++++++++++-------- + 1 file changed, 52 insertions(+), 9 deletions(-) + +--- a/arch/mips/ralink/clk.c ++++ b/arch/mips/ralink/clk.c +@@ -11,29 +11,72 @@ + #include + #include + #include ++#include + + #include + + #include "common.h" + +-void ralink_clk_add(const char *dev, unsigned long rate) ++static const char *clk_cpu(int *idx) + { +- struct clk *clk = clk_register_fixed_rate(NULL, dev, NULL, 0, rate); +- +- if (!clk) +- panic("failed to add clock"); +- +- clkdev_create(clk, NULL, "%s", dev); ++ switch (ralink_soc) { ++ case RT2880_SOC: ++ *idx = 0; ++ return "ralink,rt2880-sysc"; ++ case RT3883_SOC: ++ *idx = 0; ++ return "ralink,rt3883-sysc"; ++ case RT305X_SOC_RT3050: ++ *idx = 0; ++ return "ralink,rt3050-sysc"; ++ case RT305X_SOC_RT3052: ++ *idx = 0; ++ return "ralink,rt3052-sysc"; ++ case RT305X_SOC_RT3350: ++ *idx = 1; ++ return "ralink,rt3350-sysc"; ++ case RT305X_SOC_RT3352: ++ *idx = 1; ++ return "ralink,rt3352-sysc"; ++ case RT305X_SOC_RT5350: ++ *idx = 1; ++ return "ralink,rt5350-sysc"; ++ case MT762X_SOC_MT7620A: ++ *idx = 2; ++ return "ralink,mt7620-sysc"; ++ case MT762X_SOC_MT7620N: ++ *idx = 2; ++ return "ralink,mt7620-sysc"; ++ case MT762X_SOC_MT7628AN: ++ *idx = 1; ++ return "ralink,mt7628-sysc"; ++ case MT762X_SOC_MT7688: ++ *idx = 1; ++ return "ralink,mt7688-sysc"; ++ default: ++ *idx = -1; ++ return "invalid"; ++ } + } + + void __init plat_time_init(void) + { ++ struct of_phandle_args clkspec; ++ const char *compatible; + struct clk *clk; ++ int cpu_clk_idx; + + ralink_of_remap(); + +- ralink_clk_init(); +- clk = clk_get_sys("cpu", NULL); ++ compatible = clk_cpu(&cpu_clk_idx); ++ if (cpu_clk_idx == -1) ++ panic("unable to get CPU clock index"); ++ ++ of_clk_init(NULL); ++ clkspec.np = of_find_compatible_node(NULL, NULL, compatible); ++ clkspec.args_count = 1; ++ clkspec.args[0] = cpu_clk_idx; ++ clk = of_clk_get_from_provider(&clkspec); + if (IS_ERR(clk)) + panic("unable to get CPU clock, err=%ld", PTR_ERR(clk)); + pr_info("CPU Clock: %ldMHz\n", clk_get_rate(clk) / 1000000); diff --git a/target/linux/ramips/patches-5.15/005-v6.5-09-MAINTAINERS-add-Mediatek-MTMIPS-Clock-maintainer.patch b/target/linux/ramips/patches-5.15/005-v6.5-09-MAINTAINERS-add-Mediatek-MTMIPS-Clock-maintainer.patch new file mode 100644 index 00000000000..3c9a5982af7 --- /dev/null +++ b/target/linux/ramips/patches-5.15/005-v6.5-09-MAINTAINERS-add-Mediatek-MTMIPS-Clock-maintainer.patch @@ -0,0 +1,28 @@ +From fc15a7193a4d37d79e873fa06cc423180ddd2ddf Mon Sep 17 00:00:00 2001 +From: Sergio Paracuellos +Date: Mon, 19 Jun 2023 06:09:41 +0200 +Subject: [PATCH 9/9] MAINTAINERS: add Mediatek MTMIPS Clock maintainer + +Adding myself as maintainer for Mediatek MTMIPS clock driver. + +Signed-off-by: Sergio Paracuellos +Signed-off-by: Thomas Bogendoerfer +--- + MAINTAINERS | 6 ++++++ + 1 file changed, 6 insertions(+) + +--- a/MAINTAINERS ++++ b/MAINTAINERS +@@ -11858,6 +11858,12 @@ S: Maintained + F: Documentation/devicetree/bindings/clock/mediatek,mt7621-sysc.yaml + F: drivers/clk/ralink/clk-mt7621.c + ++MEDIATEK MTMIPS CLOCK DRIVER ++M: Sergio Paracuellos ++S: Maintained ++F: Documentation/devicetree/bindings/clock/mediatek,mtmips-sysc.yaml ++F: drivers/clk/ralink/clk-mtmips.c ++ + MEDIATEK MT7621/28/88 I2C DRIVER + M: Stefan Roese + L: linux-i2c@vger.kernel.org diff --git a/target/linux/ramips/patches-5.15/006-v6.5-mips-ralink-introduce-commonly-used-remap-node-funct.patch b/target/linux/ramips/patches-5.15/006-v6.5-mips-ralink-introduce-commonly-used-remap-node-funct.patch new file mode 100644 index 00000000000..429b9feb9da --- /dev/null +++ b/target/linux/ramips/patches-5.15/006-v6.5-mips-ralink-introduce-commonly-used-remap-node-funct.patch @@ -0,0 +1,189 @@ +From fd99ac5055d4705e91c73d1adba18bc71c8511a8 Mon Sep 17 00:00:00 2001 +From: Shiji Yang +Date: Tue, 20 Jun 2023 19:44:32 +0800 +Subject: [PATCH] mips: ralink: introduce commonly used remap node function + +The ralink_of_remap() function is repeated several times on SoC specific +source files. They have the same structure, but just differ in compatible +strings. In order to make commonly use of these codes, this patch +introduces a newly designed mtmips_of_remap_node() function to match and +remap all supported system controller and memory controller nodes. + +Build and run tested on MT7620 and MT7628. + +Signed-off-by: Shiji Yang +Reviewed-by: Sergio Paracuellos +Signed-off-by: Thomas Bogendoerfer +--- + arch/mips/ralink/common.h | 2 -- + arch/mips/ralink/mt7620.c | 9 --------- + arch/mips/ralink/mt7621.c | 9 --------- + arch/mips/ralink/of.c | 42 +++++++++++++++++++++++++++++++++++------- + arch/mips/ralink/rt288x.c | 9 --------- + arch/mips/ralink/rt305x.c | 9 --------- + arch/mips/ralink/rt3883.c | 9 --------- + 7 files changed, 35 insertions(+), 54 deletions(-) + +--- a/arch/mips/ralink/common.h ++++ b/arch/mips/ralink/common.h +@@ -25,6 +25,4 @@ extern void ralink_of_remap(void); + + extern void __init prom_soc_init(struct ralink_soc_info *soc_info); + +-__iomem void *plat_of_remap_node(const char *node); +- + #endif /* _RALINK_COMMON_H__ */ +--- a/arch/mips/ralink/mt7620.c ++++ b/arch/mips/ralink/mt7620.c +@@ -43,15 +43,6 @@ + /* does the board have sdram or ddram */ + static int dram_type; + +-void __init ralink_of_remap(void) +-{ +- rt_sysc_membase = plat_of_remap_node("ralink,mt7620a-sysc"); +- rt_memc_membase = plat_of_remap_node("ralink,mt7620a-memc"); +- +- if (!rt_sysc_membase || !rt_memc_membase) +- panic("Failed to remap core resources"); +-} +- + static __init void + mt7620_dram_init(struct ralink_soc_info *soc_info) + { +--- a/arch/mips/ralink/mt7621.c ++++ b/arch/mips/ralink/mt7621.c +@@ -58,15 +58,6 @@ static void __init mt7621_memory_detect( + memblock_add(MT7621_HIGHMEM_BASE, MT7621_HIGHMEM_SIZE); + } + +-void __init ralink_of_remap(void) +-{ +- rt_sysc_membase = plat_of_remap_node("mediatek,mt7621-sysc"); +- rt_memc_membase = plat_of_remap_node("mediatek,mt7621-memc"); +- +- if (!rt_sysc_membase || !rt_memc_membase) +- panic("Failed to remap core resources"); +-} +- + static unsigned int __init mt7621_get_soc_name0(void) + { + return __raw_readl(MT7621_SYSC_BASE + SYSC_REG_CHIP_NAME0); +--- a/arch/mips/ralink/of.c ++++ b/arch/mips/ralink/of.c +@@ -29,26 +29,56 @@ __iomem void *rt_sysc_membase; + __iomem void *rt_memc_membase; + EXPORT_SYMBOL_GPL(rt_sysc_membase); + +-__iomem void *plat_of_remap_node(const char *node) ++static const struct of_device_id mtmips_memc_match[] = { ++ { .compatible = "mediatek,mt7621-memc" }, ++ { .compatible = "ralink,mt7620a-memc" }, ++ { .compatible = "ralink,rt2880-memc" }, ++ { .compatible = "ralink,rt3050-memc" }, ++ { .compatible = "ralink,rt3883-memc" }, ++ {} ++}; ++ ++static const struct of_device_id mtmips_sysc_match[] = { ++ { .compatible = "mediatek,mt7621-sysc" }, ++ { .compatible = "ralink,mt7620a-sysc" }, ++ { .compatible = "ralink,rt2880-sysc" }, ++ { .compatible = "ralink,rt3050-sysc" }, ++ { .compatible = "ralink,rt3883-sysc" }, ++ {} ++}; ++ ++static __iomem void * ++mtmips_of_remap_node(const struct of_device_id *match, const char *type) + { + struct resource res; + struct device_node *np; + +- np = of_find_compatible_node(NULL, NULL, node); ++ np = of_find_matching_node(NULL, match); + if (!np) +- panic("Failed to find %s node", node); ++ panic("Failed to find %s controller node", type); + + if (of_address_to_resource(np, 0, &res)) +- panic("Failed to get resource for %s", node); ++ panic("Failed to get resource for %s node", np->name); + + if (!request_mem_region(res.start, + resource_size(&res), + res.name)) +- panic("Failed to request resources for %s", node); ++ panic("Failed to request resources for %s node", np->name); ++ ++ of_node_put(np); + + return ioremap(res.start, resource_size(&res)); + } + ++void __init ralink_of_remap(void) ++{ ++ rt_sysc_membase = mtmips_of_remap_node(mtmips_sysc_match, "system"); ++ rt_memc_membase = mtmips_of_remap_node(mtmips_memc_match, "memory"); ++ ++ if (!rt_sysc_membase || !rt_memc_membase) ++ panic("Failed to remap core resources"); ++} ++ + void __init device_tree_init(void) + { + unflatten_and_copy_device_tree(); +--- a/arch/mips/ralink/rt288x.c ++++ b/arch/mips/ralink/rt288x.c +@@ -17,15 +17,6 @@ + + #include "common.h" + +-void __init ralink_of_remap(void) +-{ +- rt_sysc_membase = plat_of_remap_node("ralink,rt2880-sysc"); +- rt_memc_membase = plat_of_remap_node("ralink,rt2880-memc"); +- +- if (!rt_sysc_membase || !rt_memc_membase) +- panic("Failed to remap core resources"); +-} +- + void __init prom_soc_init(struct ralink_soc_info *soc_info) + { + void __iomem *sysc = (void __iomem *) KSEG1ADDR(RT2880_SYSC_BASE); +--- a/arch/mips/ralink/rt305x.c ++++ b/arch/mips/ralink/rt305x.c +@@ -53,15 +53,6 @@ static unsigned long rt5350_get_mem_size + return ret; + } + +-void __init ralink_of_remap(void) +-{ +- rt_sysc_membase = plat_of_remap_node("ralink,rt3050-sysc"); +- rt_memc_membase = plat_of_remap_node("ralink,rt3050-memc"); +- +- if (!rt_sysc_membase || !rt_memc_membase) +- panic("Failed to remap core resources"); +-} +- + void __init prom_soc_init(struct ralink_soc_info *soc_info) + { + void __iomem *sysc = (void __iomem *) KSEG1ADDR(RT305X_SYSC_BASE); +--- a/arch/mips/ralink/rt3883.c ++++ b/arch/mips/ralink/rt3883.c +@@ -17,15 +17,6 @@ + + #include "common.h" + +-void __init ralink_of_remap(void) +-{ +- rt_sysc_membase = plat_of_remap_node("ralink,rt3883-sysc"); +- rt_memc_membase = plat_of_remap_node("ralink,rt3883-memc"); +- +- if (!rt_sysc_membase || !rt_memc_membase) +- panic("Failed to remap core resources"); +-} +- + void __init prom_soc_init(struct ralink_soc_info *soc_info) + { + void __iomem *sysc = (void __iomem *) KSEG1ADDR(RT3883_SYSC_BASE); diff --git a/target/linux/ramips/patches-5.15/007-v6.5-clk-ralink-mtmips-Fix-uninitialized-use-of-ret-in-mt.patch b/target/linux/ramips/patches-5.15/007-v6.5-clk-ralink-mtmips-Fix-uninitialized-use-of-ret-in-mt.patch new file mode 100644 index 00000000000..c0c2a6e204f --- /dev/null +++ b/target/linux/ramips/patches-5.15/007-v6.5-clk-ralink-mtmips-Fix-uninitialized-use-of-ret-in-mt.patch @@ -0,0 +1,56 @@ +From 6e68dae946e3a0333fbde5487ce163142ca10ae0 Mon Sep 17 00:00:00 2001 +From: Nathan Chancellor +Date: Thu, 22 Jun 2023 15:56:19 +0000 +Subject: clk: ralink: mtmips: Fix uninitialized use of ret in + mtmips_register_{fixed,factor}_clocks() + +Clang warns: + + drivers/clk/ralink/clk-mtmips.c:309:9: error: variable 'ret' is uninitialized when used here [-Werror,-Wuninitialized] + 309 | return ret; + | ^~~ + drivers/clk/ralink/clk-mtmips.c:285:9: note: initialize the variable 'ret' to silence this warning + 285 | int ret, i; + | ^ + | = 0 + drivers/clk/ralink/clk-mtmips.c:359:9: error: variable 'ret' is uninitialized when used here [-Werror,-Wuninitialized] + 359 | return ret; + | ^~~ + drivers/clk/ralink/clk-mtmips.c:335:9: note: initialize the variable 'ret' to silence this warning + 335 | int ret, i; + | ^ + | = 0 + 2 errors generated. + +Set ret to the return value of clk_hw_register_fixed_rate() using the +PTR_ERR() macro, which ensures ret is not used uninitialized, clearing +up the warning. + +Fixes: 6f3b15586eef ("clk: ralink: add clock and reset driver for MTMIPS SoCs") +Closes: https://github.com/ClangBuiltLinux/linux/issues/1879 +Signed-off-by: Nathan Chancellor +Reviewed-by: Nick Desaulniers +Acked-by: Sergio Paracuellos +Signed-off-by: Thomas Bogendoerfer +--- + drivers/clk/ralink/clk-mtmips.c | 2 ++ + 1 file changed, 2 insertions(+) + +--- a/drivers/clk/ralink/clk-mtmips.c ++++ b/drivers/clk/ralink/clk-mtmips.c +@@ -292,6 +292,7 @@ static int mtmips_register_fixed_clocks( + sclk->parent, 0, + sclk->rate); + if (IS_ERR(sclk->hw)) { ++ ret = PTR_ERR(sclk->hw); + pr_err("Couldn't register fixed clock %d\n", idx); + goto err_clk_unreg; + } +@@ -342,6 +343,7 @@ static int mtmips_register_factor_clocks + sclk->parent, sclk->flags, + sclk->mult, sclk->div); + if (IS_ERR(sclk->hw)) { ++ ret = PTR_ERR(sclk->hw); + pr_err("Couldn't register factor clock %d\n", idx); + goto err_clk_unreg; + } diff --git a/target/linux/ramips/patches-5.15/008-v6.5-mips-ralink-match-all-supported-system-controller-co.patch b/target/linux/ramips/patches-5.15/008-v6.5-mips-ralink-match-all-supported-system-controller-co.patch new file mode 100644 index 00000000000..6940a2b4b98 --- /dev/null +++ b/target/linux/ramips/patches-5.15/008-v6.5-mips-ralink-match-all-supported-system-controller-co.patch @@ -0,0 +1,40 @@ +From 670f77f76f650b1b341d31d009cc2fb03a4d1fcf Mon Sep 17 00:00:00 2001 +From: Shiji Yang +Date: Fri, 23 Jun 2023 08:17:48 +0800 +Subject: mips: ralink: match all supported system controller compatible + strings + +Recently, A new clock and reset controller driver has been introduced to +the ralink mips target[1]. It provides proper system control and adds more +SoC specific compatible strings. In order to better initialize CPUs, this +patch removes the outdated "ralink,mt7620a-sysc" and add all dt-binding +documented compatible strings to the system controller match table. + +[1] https://lore.kernel.org/all/20230619040941.1340372-1-sergio.paracuellos@gmail.com/ + +Signed-off-by: Shiji Yang +Reviewed-by: Sergio Paracuellos +Signed-off-by: Thomas Bogendoerfer +--- + arch/mips/ralink/of.c | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +--- a/arch/mips/ralink/of.c ++++ b/arch/mips/ralink/of.c +@@ -40,10 +40,15 @@ static const struct of_device_id mtmips_ + + static const struct of_device_id mtmips_sysc_match[] = { + { .compatible = "mediatek,mt7621-sysc" }, +- { .compatible = "ralink,mt7620a-sysc" }, ++ { .compatible = "ralink,mt7620-sysc" }, ++ { .compatible = "ralink,mt7628-sysc" }, ++ { .compatible = "ralink,mt7688-sysc" }, + { .compatible = "ralink,rt2880-sysc" }, + { .compatible = "ralink,rt3050-sysc" }, ++ { .compatible = "ralink,rt3052-sysc" }, ++ { .compatible = "ralink,rt3352-sysc" }, + { .compatible = "ralink,rt3883-sysc" }, ++ { .compatible = "ralink,rt5350-sysc" }, + {} + }; + diff --git a/target/linux/ramips/patches-5.15/009-v6.3-01-watchdog-mt7621-wdt-avoid-static-global-declarations.patch b/target/linux/ramips/patches-5.15/009-v6.3-01-watchdog-mt7621-wdt-avoid-static-global-declarations.patch new file mode 100644 index 00000000000..e06d5621e10 --- /dev/null +++ b/target/linux/ramips/patches-5.15/009-v6.3-01-watchdog-mt7621-wdt-avoid-static-global-declarations.patch @@ -0,0 +1,213 @@ +From 783c7cb4659b53b5e1b809dac5e8cdf250145919 Mon Sep 17 00:00:00 2001 +From: Sergio Paracuellos +Date: Tue, 14 Feb 2023 11:39:35 +0100 +Subject: [PATCH 1/2] watchdog: mt7621-wdt: avoid static global declarations + +Instead of using static global definitions in driver code, refactor code +introducing a new watchdog driver data structure and use it along the +code. + +Reviewed-by: Guenter Roeck +Signed-off-by: Sergio Paracuellos +Link: https://lore.kernel.org/r/20230214103936.1061078-5-sergio.paracuellos@gmail.com +[groeck: unsigned -> unsigned int] +Signed-off-by: Guenter Roeck +Signed-off-by: Wim Van Sebroeck +--- + drivers/watchdog/mt7621_wdt.c | 102 +++++++++++++++++++++++++++--------------- + 1 file changed, 65 insertions(+), 37 deletions(-) + +--- a/drivers/watchdog/mt7621_wdt.c ++++ b/drivers/watchdog/mt7621_wdt.c +@@ -31,8 +31,11 @@ + #define TMR1CTL_RESTART BIT(9) + #define TMR1CTL_PRESCALE_SHIFT 16 + +-static void __iomem *mt7621_wdt_base; +-static struct reset_control *mt7621_wdt_reset; ++struct mt7621_wdt_data { ++ void __iomem *base; ++ struct reset_control *rst; ++ struct watchdog_device wdt; ++}; + + static bool nowayout = WATCHDOG_NOWAYOUT; + module_param(nowayout, bool, 0); +@@ -40,27 +43,31 @@ MODULE_PARM_DESC(nowayout, + "Watchdog cannot be stopped once started (default=" + __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); + +-static inline void rt_wdt_w32(unsigned reg, u32 val) ++static inline void rt_wdt_w32(void __iomem *base, unsigned int reg, u32 val) + { +- iowrite32(val, mt7621_wdt_base + reg); ++ iowrite32(val, base + reg); + } + +-static inline u32 rt_wdt_r32(unsigned reg) ++static inline u32 rt_wdt_r32(void __iomem *base, unsigned int reg) + { +- return ioread32(mt7621_wdt_base + reg); ++ return ioread32(base + reg); + } + + static int mt7621_wdt_ping(struct watchdog_device *w) + { +- rt_wdt_w32(TIMER_REG_TMRSTAT, TMR1CTL_RESTART); ++ struct mt7621_wdt_data *drvdata = watchdog_get_drvdata(w); ++ ++ rt_wdt_w32(drvdata->base, TIMER_REG_TMRSTAT, TMR1CTL_RESTART); + + return 0; + } + + static int mt7621_wdt_set_timeout(struct watchdog_device *w, unsigned int t) + { ++ struct mt7621_wdt_data *drvdata = watchdog_get_drvdata(w); ++ + w->timeout = t; +- rt_wdt_w32(TIMER_REG_TMR1LOAD, t * 1000); ++ rt_wdt_w32(drvdata->base, TIMER_REG_TMR1LOAD, t * 1000); + mt7621_wdt_ping(w); + + return 0; +@@ -68,29 +75,31 @@ static int mt7621_wdt_set_timeout(struct + + static int mt7621_wdt_start(struct watchdog_device *w) + { ++ struct mt7621_wdt_data *drvdata = watchdog_get_drvdata(w); + u32 t; + + /* set the prescaler to 1ms == 1000us */ +- rt_wdt_w32(TIMER_REG_TMR1CTL, 1000 << TMR1CTL_PRESCALE_SHIFT); ++ rt_wdt_w32(drvdata->base, TIMER_REG_TMR1CTL, 1000 << TMR1CTL_PRESCALE_SHIFT); + + mt7621_wdt_set_timeout(w, w->timeout); + +- t = rt_wdt_r32(TIMER_REG_TMR1CTL); ++ t = rt_wdt_r32(drvdata->base, TIMER_REG_TMR1CTL); + t |= TMR1CTL_ENABLE; +- rt_wdt_w32(TIMER_REG_TMR1CTL, t); ++ rt_wdt_w32(drvdata->base, TIMER_REG_TMR1CTL, t); + + return 0; + } + + static int mt7621_wdt_stop(struct watchdog_device *w) + { ++ struct mt7621_wdt_data *drvdata = watchdog_get_drvdata(w); + u32 t; + + mt7621_wdt_ping(w); + +- t = rt_wdt_r32(TIMER_REG_TMR1CTL); ++ t = rt_wdt_r32(drvdata->base, TIMER_REG_TMR1CTL); + t &= ~TMR1CTL_ENABLE; +- rt_wdt_w32(TIMER_REG_TMR1CTL, t); ++ rt_wdt_w32(drvdata->base, TIMER_REG_TMR1CTL, t); + + return 0; + } +@@ -105,7 +114,9 @@ static int mt7621_wdt_bootcause(void) + + static int mt7621_wdt_is_running(struct watchdog_device *w) + { +- return !!(rt_wdt_r32(TIMER_REG_TMR1CTL) & TMR1CTL_ENABLE); ++ struct mt7621_wdt_data *drvdata = watchdog_get_drvdata(w); ++ ++ return !!(rt_wdt_r32(drvdata->base, TIMER_REG_TMR1CTL) & TMR1CTL_ENABLE); + } + + static const struct watchdog_info mt7621_wdt_info = { +@@ -121,30 +132,39 @@ static const struct watchdog_ops mt7621_ + .set_timeout = mt7621_wdt_set_timeout, + }; + +-static struct watchdog_device mt7621_wdt_dev = { +- .info = &mt7621_wdt_info, +- .ops = &mt7621_wdt_ops, +- .min_timeout = 1, +- .max_timeout = 0xfffful / 1000, +-}; +- + static int mt7621_wdt_probe(struct platform_device *pdev) + { + struct device *dev = &pdev->dev; +- mt7621_wdt_base = devm_platform_ioremap_resource(pdev, 0); +- if (IS_ERR(mt7621_wdt_base)) +- return PTR_ERR(mt7621_wdt_base); +- +- mt7621_wdt_reset = devm_reset_control_get_exclusive(dev, NULL); +- if (!IS_ERR(mt7621_wdt_reset)) +- reset_control_deassert(mt7621_wdt_reset); +- +- mt7621_wdt_dev.bootstatus = mt7621_wdt_bootcause(); +- +- watchdog_init_timeout(&mt7621_wdt_dev, mt7621_wdt_dev.max_timeout, +- dev); +- watchdog_set_nowayout(&mt7621_wdt_dev, nowayout); +- if (mt7621_wdt_is_running(&mt7621_wdt_dev)) { ++ struct watchdog_device *mt7621_wdt; ++ struct mt7621_wdt_data *drvdata; ++ int err; ++ ++ drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); ++ if (!drvdata) ++ return -ENOMEM; ++ ++ drvdata->base = devm_platform_ioremap_resource(pdev, 0); ++ if (IS_ERR(drvdata->base)) ++ return PTR_ERR(drvdata->base); ++ ++ drvdata->rst = devm_reset_control_get_exclusive(dev, NULL); ++ if (!IS_ERR(drvdata->rst)) ++ reset_control_deassert(drvdata->rst); ++ ++ mt7621_wdt = &drvdata->wdt; ++ mt7621_wdt->info = &mt7621_wdt_info; ++ mt7621_wdt->ops = &mt7621_wdt_ops; ++ mt7621_wdt->min_timeout = 1; ++ mt7621_wdt->max_timeout = 0xfffful / 1000; ++ mt7621_wdt->parent = dev; ++ ++ mt7621_wdt->bootstatus = mt7621_wdt_bootcause(); ++ ++ watchdog_init_timeout(mt7621_wdt, mt7621_wdt->max_timeout, dev); ++ watchdog_set_nowayout(mt7621_wdt, nowayout); ++ watchdog_set_drvdata(mt7621_wdt, drvdata); ++ ++ if (mt7621_wdt_is_running(mt7621_wdt)) { + /* + * Make sure to apply timeout from watchdog core, taking + * the prescaler of this driver here into account (the +@@ -154,17 +174,25 @@ static int mt7621_wdt_probe(struct platf + * we first disable the watchdog, set the new prescaler + * and timeout, and then re-enable the watchdog. + */ +- mt7621_wdt_stop(&mt7621_wdt_dev); +- mt7621_wdt_start(&mt7621_wdt_dev); +- set_bit(WDOG_HW_RUNNING, &mt7621_wdt_dev.status); ++ mt7621_wdt_stop(mt7621_wdt); ++ mt7621_wdt_start(mt7621_wdt); ++ set_bit(WDOG_HW_RUNNING, &mt7621_wdt->status); + } + +- return devm_watchdog_register_device(dev, &mt7621_wdt_dev); ++ err = devm_watchdog_register_device(dev, &drvdata->wdt); ++ if (err) ++ return err; ++ ++ platform_set_drvdata(pdev, drvdata); ++ ++ return 0; + } + + static void mt7621_wdt_shutdown(struct platform_device *pdev) + { +- mt7621_wdt_stop(&mt7621_wdt_dev); ++ struct mt7621_wdt_data *drvdata = platform_get_drvdata(pdev); ++ ++ mt7621_wdt_stop(&drvdata->wdt); + } + + static const struct of_device_id mt7621_wdt_match[] = { diff --git a/target/linux/ramips/patches-5.15/009-v6.3-02-watchdog-mt7621-wdt-avoid-ralink-architecture-depend.patch b/target/linux/ramips/patches-5.15/009-v6.3-02-watchdog-mt7621-wdt-avoid-ralink-architecture-depend.patch new file mode 100644 index 00000000000..8e6265404b7 --- /dev/null +++ b/target/linux/ramips/patches-5.15/009-v6.3-02-watchdog-mt7621-wdt-avoid-ralink-architecture-depend.patch @@ -0,0 +1,104 @@ +From ff8ec4ac39ad413b580d611dbf68e1d8a82eba56 Mon Sep 17 00:00:00 2001 +From: Sergio Paracuellos +Date: Tue, 14 Feb 2023 11:39:36 +0100 +Subject: [PATCH 2/2] watchdog: mt7621-wdt: avoid ralink architecture dependent code + +MT7621 SoC has a system controller node. Watchdog need to access to reset +status register. Ralink architecture and related driver are old and from +the beggining they are using some architecture dependent operations for +accessing this shared registers through 'asm/mach-ralink/ralink_regs.h' +header file. However this is not ideal from a driver perspective which can +just access to the system controller registers in an arch independent way +using regmap syscon APIs. Update Kconfig accordingly to select new added +dependencies and allow driver to be compile tested. + +Signed-off-by: Sergio Paracuellos +Reviewed-by: Guenter Roeck +Link: https://lore.kernel.org/r/20230214103936.1061078-6-sergio.paracuellos@gmail.com +Signed-off-by: Guenter Roeck +Signed-off-by: Wim Van Sebroeck +--- + drivers/watchdog/Kconfig | 4 +++- + drivers/watchdog/mt7621_wdt.c | 22 +++++++++++++++++----- + 2 files changed, 20 insertions(+), 6 deletions(-) + +--- a/drivers/watchdog/Kconfig ++++ b/drivers/watchdog/Kconfig +@@ -1799,7 +1799,9 @@ config RALINK_WDT + config MT7621_WDT + tristate "Mediatek SoC watchdog" + select WATCHDOG_CORE +- depends on SOC_MT7620 || SOC_MT7621 ++ select REGMAP_MMIO ++ select MFD_SYSCON ++ depends on SOC_MT7620 || SOC_MT7621 || COMPILE_TEST + help + Hardware driver for the Mediatek/Ralink MT7621/8 SoC Watchdog Timer. + +--- a/drivers/watchdog/mt7621_wdt.c ++++ b/drivers/watchdog/mt7621_wdt.c +@@ -15,8 +15,8 @@ + #include + #include + #include +- +-#include ++#include ++#include + + #define SYSC_RSTSTAT 0x38 + #define WDT_RST_CAUSE BIT(1) +@@ -34,6 +34,7 @@ + struct mt7621_wdt_data { + void __iomem *base; + struct reset_control *rst; ++ struct regmap *sysc; + struct watchdog_device wdt; + }; + +@@ -104,9 +105,12 @@ static int mt7621_wdt_stop(struct watchd + return 0; + } + +-static int mt7621_wdt_bootcause(void) ++static int mt7621_wdt_bootcause(struct mt7621_wdt_data *d) + { +- if (rt_sysc_r32(SYSC_RSTSTAT) & WDT_RST_CAUSE) ++ u32 val; ++ ++ regmap_read(d->sysc, SYSC_RSTSTAT, &val); ++ if (val & WDT_RST_CAUSE) + return WDIOF_CARDRESET; + + return 0; +@@ -134,6 +138,7 @@ static const struct watchdog_ops mt7621_ + + static int mt7621_wdt_probe(struct platform_device *pdev) + { ++ struct device_node *np = pdev->dev.of_node; + struct device *dev = &pdev->dev; + struct watchdog_device *mt7621_wdt; + struct mt7621_wdt_data *drvdata; +@@ -143,6 +148,13 @@ static int mt7621_wdt_probe(struct platf + if (!drvdata) + return -ENOMEM; + ++ drvdata->sysc = syscon_regmap_lookup_by_phandle(np, "mediatek,sysctl"); ++ if (IS_ERR(drvdata->sysc)) { ++ drvdata->sysc = syscon_regmap_lookup_by_compatible("mediatek,mt7621-sysc"); ++ if (IS_ERR(drvdata->sysc)) ++ return PTR_ERR(drvdata->sysc); ++ } ++ + drvdata->base = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(drvdata->base)) + return PTR_ERR(drvdata->base); +@@ -158,7 +170,7 @@ static int mt7621_wdt_probe(struct platf + mt7621_wdt->max_timeout = 0xfffful / 1000; + mt7621_wdt->parent = dev; + +- mt7621_wdt->bootstatus = mt7621_wdt_bootcause(); ++ mt7621_wdt->bootstatus = mt7621_wdt_bootcause(drvdata); + + watchdog_init_timeout(mt7621_wdt, mt7621_wdt->max_timeout, dev); + watchdog_set_nowayout(mt7621_wdt, nowayout); diff --git a/target/linux/ramips/patches-5.15/110-reset_controller_driver.patch b/target/linux/ramips/patches-5.15/110-reset_controller_driver.patch deleted file mode 100644 index 6c923d70c3b..00000000000 --- a/target/linux/ramips/patches-5.15/110-reset_controller_driver.patch +++ /dev/null @@ -1,61 +0,0 @@ ---- a/arch/mips/ralink/reset.c -+++ b/arch/mips/ralink/reset.c -@@ -11,6 +11,7 @@ - #include - #include - #include -+#include - - #include - -@@ -65,21 +66,39 @@ static const struct reset_control_ops re - .deassert = ralink_deassert_device, - }; - --static struct reset_controller_dev reset_dev = { -- .ops = &reset_ops, -- .owner = THIS_MODULE, -- .nr_resets = 32, -- .of_reset_n_cells = 1, -+static int ralink_reset_probe(struct platform_device *pdev) -+{ -+ struct reset_controller_dev *rcdev; -+ -+ rcdev = devm_kzalloc(&pdev->dev, sizeof(*rcdev), GFP_KERNEL); -+ if (!rcdev) -+ return -ENOMEM; -+ -+ rcdev->ops = &reset_ops; -+ rcdev->owner = THIS_MODULE; -+ rcdev->nr_resets = 32; -+ rcdev->of_reset_n_cells = 1; -+ rcdev->of_node = pdev->dev.of_node; -+ -+ return devm_reset_controller_register(&pdev->dev, rcdev); -+} -+ -+static const struct of_device_id ralink_reset_dt_ids[] = { -+ { .compatible = "ralink,rt2880-reset" }, -+ {} -+}; -+ -+static struct platform_driver ralink_reset_driver = { -+ .probe = ralink_reset_probe, -+ .driver = { -+ .name = "ralink-reset", -+ .of_match_table = ralink_reset_dt_ids, -+ } - }; - - void ralink_rst_init(void) - { -- reset_dev.of_node = of_find_compatible_node(NULL, NULL, -- "ralink,rt2880-reset"); -- if (!reset_dev.of_node) -- pr_err("Failed to find reset controller node"); -- else -- reset_controller_register(&reset_dev); -+ platform_driver_register(&ralink_reset_driver); - } - - static void ralink_restart(char *command) diff --git a/target/linux/ramips/patches-5.15/300-mt7620-export-chip-version-and-pkg.patch b/target/linux/ramips/patches-5.15/300-mt7620-export-chip-version-and-pkg.patch index c31be4a5dfc..4f4fe9018a1 100644 --- a/target/linux/ramips/patches-5.15/300-mt7620-export-chip-version-and-pkg.patch +++ b/target/linux/ramips/patches-5.15/300-mt7620-export-chip-version-and-pkg.patch @@ -1,6 +1,6 @@ --- a/arch/mips/include/asm/mach-ralink/mt7620.h +++ b/arch/mips/include/asm/mach-ralink/mt7620.h -@@ -96,4 +96,16 @@ static inline int mt7620_get_eco(void) +@@ -61,4 +61,16 @@ static inline int mt7620_get_eco(void) return rt_sysc_r32(SYSC_REG_CHIP_REV) & CHIP_REV_ECO_MASK; } diff --git a/target/linux/ramips/patches-5.15/700-net-ethernet-mediatek-support-net-labels.patch b/target/linux/ramips/patches-5.15/700-net-ethernet-mediatek-support-net-labels.patch index e57e6fa83b2..fce5fc856f4 100644 --- a/target/linux/ramips/patches-5.15/700-net-ethernet-mediatek-support-net-labels.patch +++ b/target/linux/ramips/patches-5.15/700-net-ethernet-mediatek-support-net-labels.patch @@ -14,7 +14,7 @@ Signed-off-by: René van Dorst --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c -@@ -4633,6 +4633,7 @@ static const struct net_device_ops mtk_n +@@ -4615,6 +4615,7 @@ static const struct net_device_ops mtk_n static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np) { @@ -22,7 +22,7 @@ Signed-off-by: René van Dorst const __be32 *_id = of_get_property(np, "reg", NULL); phy_interface_t phy_mode; struct phylink *phylink; -@@ -4791,6 +4792,9 @@ static int mtk_add_mac(struct mtk_eth *e +@@ -4784,6 +4785,9 @@ static int mtk_add_mac(struct mtk_eth *e register_netdevice_notifier(&mac->device_notifier); } diff --git a/target/linux/ramips/patches-5.15/850-awake-rt305x-dwc2-controller.patch b/target/linux/ramips/patches-5.15/850-awake-rt305x-dwc2-controller.patch index 3f2a524a75b..5fb3664ae53 100644 --- a/target/linux/ramips/patches-5.15/850-awake-rt305x-dwc2-controller.patch +++ b/target/linux/ramips/patches-5.15/850-awake-rt305x-dwc2-controller.patch @@ -1,6 +1,6 @@ --- a/drivers/usb/dwc2/platform.c +++ b/drivers/usb/dwc2/platform.c -@@ -498,6 +498,12 @@ static int dwc2_driver_probe(struct plat +@@ -508,6 +508,12 @@ static int dwc2_driver_probe(struct plat if (retval) return retval; diff --git a/target/linux/ramips/rt288x/config-5.15 b/target/linux/ramips/rt288x/config-5.15 index 0e4afe367ef..9f502c220fe 100644 --- a/target/linux/ramips/rt288x/config-5.15 +++ b/target/linux/ramips/rt288x/config-5.15 @@ -6,6 +6,7 @@ CONFIG_ARCH_MMAP_RND_COMPAT_BITS_MAX=15 CONFIG_ARCH_SUSPEND_POSSIBLE=y CONFIG_BLK_MQ_PCI=y CONFIG_CEVT_R4K=y +CONFIG_CLK_MTMIPS=y CONFIG_CLONE_BACKWARDS=y CONFIG_CMDLINE="rootfstype=squashfs,jffs2" CONFIG_CMDLINE_BOOL=y @@ -82,6 +83,7 @@ CONFIG_MDIO_BUS=y CONFIG_MDIO_DEVICE=y CONFIG_MDIO_DEVRES=y CONFIG_MEMFD_CREATE=y +CONFIG_MFD_SYSCON=y CONFIG_MIGRATION=y CONFIG_MIPS=y CONFIG_MIPS_ASID_BITS=8 @@ -143,6 +145,8 @@ CONFIG_PTP_1588_CLOCK_OPTIONAL=y CONFIG_RALINK=y CONFIG_RALINK_WDT=y CONFIG_RATIONAL=y +CONFIG_REGMAP=y +CONFIG_REGMAP_MMIO=y CONFIG_RESET_CONTROLLER=y CONFIG_SERIAL_8250_RT288X=y CONFIG_SERIAL_MCTRL_GPIO=y diff --git a/target/linux/ramips/rt305x/config-5.15 b/target/linux/ramips/rt305x/config-5.15 index fccc7370a50..5af80adca65 100644 --- a/target/linux/ramips/rt305x/config-5.15 +++ b/target/linux/ramips/rt305x/config-5.15 @@ -8,6 +8,7 @@ CONFIG_CEVT_R4K=y CONFIG_CEVT_SYSTICK_QUIRK=y CONFIG_CLKEVT_RT3352=y CONFIG_CLKSRC_MMIO=y +CONFIG_CLK_MTMIPS=y CONFIG_CLONE_BACKWARDS=y CONFIG_CMDLINE="rootfstype=squashfs,jffs2" CONFIG_CMDLINE_BOOL=y @@ -19,7 +20,7 @@ CONFIG_CPU_HAS_DIEI=y CONFIG_CPU_HAS_PREFETCH=y CONFIG_CPU_HAS_RIXI=y CONFIG_CPU_HAS_SYNC=y -CONFIG_CPU_LITTLE_ENDIAN=y` +CONFIG_CPU_LITTLE_ENDIAN=y CONFIG_CPU_MIPS32=y # CONFIG_CPU_MIPS32_R1 is not set CONFIG_CPU_MIPS32_R2=y diff --git a/target/linux/ramips/rt3883/config-5.15 b/target/linux/ramips/rt3883/config-5.15 index 3d412e8b9d9..2977a3b5310 100644 --- a/target/linux/ramips/rt3883/config-5.15 +++ b/target/linux/ramips/rt3883/config-5.15 @@ -7,6 +7,7 @@ CONFIG_ARCH_MMAP_RND_COMPAT_BITS_MAX=15 CONFIG_ARCH_SUSPEND_POSSIBLE=y CONFIG_BLK_MQ_PCI=y CONFIG_CEVT_R4K=y +CONFIG_CLK_MTMIPS=y CONFIG_CLONE_BACKWARDS=y CONFIG_CMDLINE="rootfstype=squashfs,jffs2" CONFIG_CMDLINE_BOOL=y diff --git a/toolchain/gcc/Config.version b/toolchain/gcc/Config.version index 7126a0c883f..a7e55eb5caf 100644 --- a/toolchain/gcc/Config.version +++ b/toolchain/gcc/Config.version @@ -9,5 +9,5 @@ config GCC_VERSION_13 config GCC_VERSION string default "11.3.0" if GCC_VERSION_11 - default "13.1.0" if GCC_VERSION_13 + default "13.2.0" if GCC_VERSION_13 default "12.3.0" diff --git a/toolchain/gcc/common.mk b/toolchain/gcc/common.mk index 677fb253818..dcc79133ea3 100644 --- a/toolchain/gcc/common.mk +++ b/toolchain/gcc/common.mk @@ -37,8 +37,8 @@ ifeq ($(PKG_VERSION),12.3.0) PKG_HASH:=949a5d4f99e786421a93b532b22ffab5578de7321369975b91aec97adfda8c3b endif -ifeq ($(PKG_VERSION),13.1.0) - PKG_HASH:=61d684f0aa5e76ac6585ad8898a2427aade8979ed5e7f85492286c4dfc13ee86 +ifeq ($(PKG_VERSION),13.2.0) + PKG_HASH:=e275e76442a6067341a27f04c5c6b83d8613144004c0413528863dc6b5c743da endif PATCH_DIR=../patches-$(GCC_MAJOR_VERSION).x diff --git a/toolchain/gcc/patches-13.x/001-rtl-optimization-109585-alias-analysis-typo.patch b/toolchain/gcc/patches-13.x/001-rtl-optimization-109585-alias-analysis-typo.patch deleted file mode 100644 index 7f73be43253..00000000000 --- a/toolchain/gcc/patches-13.x/001-rtl-optimization-109585-alias-analysis-typo.patch +++ /dev/null @@ -1,69 +0,0 @@ -From bb406a6aea336966681927a27f54ee89c4fd4ea1 Mon Sep 17 00:00:00 2001 -From: Richard Biener -Date: Mon, 24 Apr 2023 13:31:07 +0200 -Subject: [PATCH] rtl-optimization/109585 - alias analysis typo - -When r10-514-gc6b84edb6110dd2b4fb improved access path analysis -it introduced a typo that triggers when there's an access to a -trailing array in the first access path leading to false -disambiguation. - - PR rtl-optimization/109585 - * tree-ssa-alias.cc (aliasing_component_refs_p): Fix typo. - - * gcc.dg/torture/pr109585.c: New testcase. - -(cherry picked from commit 6d4bd27a60447c7505cb4783e675e98a191a8904) ---- - gcc/testsuite/gcc.dg/torture/pr109585.c | 33 +++++++++++++++++++++++++ - gcc/tree-ssa-alias.cc | 2 +- - 2 files changed, 34 insertions(+), 1 deletion(-) - create mode 100644 gcc/testsuite/gcc.dg/torture/pr109585.c - ---- /dev/null -+++ b/gcc/testsuite/gcc.dg/torture/pr109585.c -@@ -0,0 +1,33 @@ -+/* { dg-do run } */ -+ -+#include -+ -+struct P { -+ long v; -+ struct P *n; -+}; -+ -+struct F { -+ long x; -+ struct P fam[]; -+}; -+ -+int __attribute__((noipa)) -+f(struct F *f, int i) -+{ -+ struct P *p = f->fam; -+ asm("" : "+r"(f): "r"(p)); -+ p->v = 0; -+ p->n = 0; -+ return f->fam->n != 0; -+} -+ -+int -+main() -+{ -+ struct F *m = malloc (sizeof (long) + 2 * sizeof (struct P)); -+ m->fam[0].n = &m->fam[1]; -+ if (f (m, 0)) -+ abort (); -+ return 0; -+} ---- a/gcc/tree-ssa-alias.cc -+++ b/gcc/tree-ssa-alias.cc -@@ -1330,7 +1330,7 @@ aliasing_component_refs_p (tree ref1, - /* If we didn't find a common base, try the other way around. */ - if (cmp_outer <= 0 - || (end_struct_ref1 -- && compare_type_sizes (TREE_TYPE (end_struct_ref1), type1) <= 0)) -+ && compare_type_sizes (TREE_TYPE (end_struct_ref1), type2) <= 0)) - { - int res = aliasing_component_refs_walk (ref2, type2, base2, - offset2, max_size2, diff --git a/toolchain/gcc/patches-13.x/700-RISCV-Inline-subword-atomic-ops.patch b/toolchain/gcc/patches-13.x/700-RISCV-Inline-subword-atomic-ops.patch deleted file mode 100644 index 752480bc4c5..00000000000 --- a/toolchain/gcc/patches-13.x/700-RISCV-Inline-subword-atomic-ops.patch +++ /dev/null @@ -1,2021 +0,0 @@ -From f797260adaf52bee0ec0e16190bbefbe1bfc3692 Mon Sep 17 00:00:00 2001 -From: Patrick O'Neill -Date: Tue, 18 Apr 2023 14:33:13 -0700 -Subject: [PATCH] RISCV: Inline subword atomic ops - -RISC-V has no support for subword atomic operations; code currently -generates libatomic library calls. - -This patch changes the default behavior to inline subword atomic calls -(using the same logic as the existing library call). -Behavior can be specified using the -minline-atomics and --mno-inline-atomics command line flags. - -gcc/libgcc/config/riscv/atomic.c has the same logic implemented in asm. -This will need to stay for backwards compatibility and the --mno-inline-atomics flag. - -2023-04-18 Patrick O'Neill - -gcc/ChangeLog: - PR target/104338 - * config/riscv/riscv-protos.h: Add helper function stubs. - * config/riscv/riscv.cc: Add helper functions for subword masking. - * config/riscv/riscv.opt: Add command-line flag. - * config/riscv/sync.md: Add masking logic and inline asm for fetch_and_op, - fetch_and_nand, CAS, and exchange ops. - * doc/invoke.texi: Add blurb regarding command-line flag. - -libgcc/ChangeLog: - PR target/104338 - * config/riscv/atomic.c: Add reference to duplicate logic. - -gcc/testsuite/ChangeLog: - PR target/104338 - * gcc.target/riscv/inline-atomics-1.c: New test. - * gcc.target/riscv/inline-atomics-2.c: New test. - * gcc.target/riscv/inline-atomics-3.c: New test. - * gcc.target/riscv/inline-atomics-4.c: New test. - * gcc.target/riscv/inline-atomics-5.c: New test. - * gcc.target/riscv/inline-atomics-6.c: New test. - * gcc.target/riscv/inline-atomics-7.c: New test. - * gcc.target/riscv/inline-atomics-8.c: New test. - -Signed-off-by: Patrick O'Neill -Signed-off-by: Palmer Dabbelt ---- - gcc/config/riscv/riscv-protos.h | 2 + - gcc/config/riscv/riscv.cc | 49 ++ - gcc/config/riscv/riscv.opt | 4 + - gcc/config/riscv/sync.md | 301 +++++++++ - gcc/doc/invoke.texi | 10 +- - .../gcc.target/riscv/inline-atomics-1.c | 18 + - .../gcc.target/riscv/inline-atomics-2.c | 9 + - .../gcc.target/riscv/inline-atomics-3.c | 569 ++++++++++++++++++ - .../gcc.target/riscv/inline-atomics-4.c | 566 +++++++++++++++++ - .../gcc.target/riscv/inline-atomics-5.c | 87 +++ - .../gcc.target/riscv/inline-atomics-6.c | 87 +++ - .../gcc.target/riscv/inline-atomics-7.c | 69 +++ - .../gcc.target/riscv/inline-atomics-8.c | 69 +++ - libgcc/config/riscv/atomic.c | 2 + - 14 files changed, 1841 insertions(+), 1 deletion(-) - create mode 100644 gcc/testsuite/gcc.target/riscv/inline-atomics-1.c - create mode 100644 gcc/testsuite/gcc.target/riscv/inline-atomics-2.c - create mode 100644 gcc/testsuite/gcc.target/riscv/inline-atomics-3.c - create mode 100644 gcc/testsuite/gcc.target/riscv/inline-atomics-4.c - create mode 100644 gcc/testsuite/gcc.target/riscv/inline-atomics-5.c - create mode 100644 gcc/testsuite/gcc.target/riscv/inline-atomics-6.c - create mode 100644 gcc/testsuite/gcc.target/riscv/inline-atomics-7.c - create mode 100644 gcc/testsuite/gcc.target/riscv/inline-atomics-8.c - ---- a/gcc/config/riscv/riscv-protos.h -+++ b/gcc/config/riscv/riscv-protos.h -@@ -79,6 +79,8 @@ extern void riscv_reinit (void); - extern poly_uint64 riscv_regmode_natural_size (machine_mode); - extern bool riscv_v_ext_vector_mode_p (machine_mode); - extern bool riscv_shamt_matches_mask_p (int, HOST_WIDE_INT); -+extern void riscv_subword_address (rtx, rtx *, rtx *, rtx *, rtx *); -+extern void riscv_lshift_subword (machine_mode, rtx, rtx, rtx *); - - /* Routines implemented in riscv-c.cc. */ - void riscv_cpu_cpp_builtins (cpp_reader *); ---- a/gcc/config/riscv/riscv.cc -+++ b/gcc/config/riscv/riscv.cc -@@ -7143,6 +7143,55 @@ riscv_zero_call_used_regs (HARD_REG_SET - & ~zeroed_hardregs); - } - -+/* Given memory reference MEM, expand code to compute the aligned -+ memory address, shift and mask values and store them into -+ *ALIGNED_MEM, *SHIFT, *MASK and *NOT_MASK. */ -+ -+void -+riscv_subword_address (rtx mem, rtx *aligned_mem, rtx *shift, rtx *mask, -+ rtx *not_mask) -+{ -+ /* Align the memory address to a word. */ -+ rtx addr = force_reg (Pmode, XEXP (mem, 0)); -+ -+ rtx addr_mask = gen_int_mode (-4, Pmode); -+ -+ rtx aligned_addr = gen_reg_rtx (Pmode); -+ emit_move_insn (aligned_addr, gen_rtx_AND (Pmode, addr, addr_mask)); -+ -+ *aligned_mem = change_address (mem, SImode, aligned_addr); -+ -+ /* Calculate the shift amount. */ -+ emit_move_insn (*shift, gen_rtx_AND (SImode, gen_lowpart (SImode, addr), -+ gen_int_mode (3, SImode))); -+ emit_move_insn (*shift, gen_rtx_ASHIFT (SImode, *shift, -+ gen_int_mode (3, SImode))); -+ -+ /* Calculate the mask. */ -+ int unshifted_mask = GET_MODE_MASK (GET_MODE (mem)); -+ -+ emit_move_insn (*mask, gen_int_mode (unshifted_mask, SImode)); -+ -+ emit_move_insn (*mask, gen_rtx_ASHIFT (SImode, *mask, -+ gen_lowpart (QImode, *shift))); -+ -+ emit_move_insn (*not_mask, gen_rtx_NOT(SImode, *mask)); -+} -+ -+/* Leftshift a subword within an SImode register. */ -+ -+void -+riscv_lshift_subword (machine_mode mode, rtx value, rtx shift, -+ rtx *shifted_value) -+{ -+ rtx value_reg = gen_reg_rtx (SImode); -+ emit_move_insn (value_reg, simplify_gen_subreg (SImode, value, -+ mode, 0)); -+ -+ emit_move_insn(*shifted_value, gen_rtx_ASHIFT (SImode, value_reg, -+ gen_lowpart (QImode, shift))); -+} -+ - /* Initialize the GCC target structure. */ - #undef TARGET_ASM_ALIGNED_HI_OP - #define TARGET_ASM_ALIGNED_HI_OP "\t.half\t" ---- a/gcc/config/riscv/riscv.opt -+++ b/gcc/config/riscv/riscv.opt -@@ -238,6 +238,10 @@ int riscv_sv_subext - TargetVariable - int riscv_xthead_subext - -+minline-atomics -+Target Var(TARGET_INLINE_SUBWORD_ATOMIC) Init(1) -+Always inline subword atomic operations. -+ - Enum - Name(isa_spec_class) Type(enum riscv_isa_spec_class) - Supported ISA specs (for use with the -misa-spec= option): ---- a/gcc/config/riscv/sync.md -+++ b/gcc/config/riscv/sync.md -@@ -21,8 +21,11 @@ - - (define_c_enum "unspec" [ - UNSPEC_COMPARE_AND_SWAP -+ UNSPEC_COMPARE_AND_SWAP_SUBWORD - UNSPEC_SYNC_OLD_OP -+ UNSPEC_SYNC_OLD_OP_SUBWORD - UNSPEC_SYNC_EXCHANGE -+ UNSPEC_SYNC_EXCHANGE_SUBWORD - UNSPEC_ATOMIC_STORE - UNSPEC_MEMORY_BARRIER - ]) -@@ -91,6 +94,135 @@ - [(set_attr "type" "atomic") - (set (attr "length") (const_int 8))]) - -+(define_insn "subword_atomic_fetch_strong_" -+ [(set (match_operand:SI 0 "register_operand" "=&r") ;; old value at mem -+ (match_operand:SI 1 "memory_operand" "+A")) ;; mem location -+ (set (match_dup 1) -+ (unspec_volatile:SI -+ [(any_atomic:SI (match_dup 1) -+ (match_operand:SI 2 "register_operand" "rI")) ;; value for op -+ (match_operand:SI 3 "register_operand" "rI")] ;; mask -+ UNSPEC_SYNC_OLD_OP_SUBWORD)) -+ (match_operand:SI 4 "register_operand" "rI") ;; not_mask -+ (clobber (match_scratch:SI 5 "=&r")) ;; tmp_1 -+ (clobber (match_scratch:SI 6 "=&r"))] ;; tmp_2 -+ "TARGET_ATOMIC && TARGET_INLINE_SUBWORD_ATOMIC" -+ { -+ return "1:\;" -+ "lr.w.aq\t%0, %1\;" -+ "\t%5, %0, %2\;" -+ "and\t%5, %5, %3\;" -+ "and\t%6, %0, %4\;" -+ "or\t%6, %6, %5\;" -+ "sc.w.rl\t%5, %6, %1\;" -+ "bnez\t%5, 1b"; -+ } -+ [(set (attr "length") (const_int 28))]) -+ -+(define_expand "atomic_fetch_nand" -+ [(match_operand:SHORT 0 "register_operand") ;; old value at mem -+ (not:SHORT (and:SHORT (match_operand:SHORT 1 "memory_operand") ;; mem location -+ (match_operand:SHORT 2 "reg_or_0_operand"))) ;; value for op -+ (match_operand:SI 3 "const_int_operand")] ;; model -+ "TARGET_ATOMIC && TARGET_INLINE_SUBWORD_ATOMIC" -+{ -+ /* We have no QImode/HImode atomics, so form a mask, then use -+ subword_atomic_fetch_strong_nand to implement a LR/SC version of the -+ operation. */ -+ -+ /* Logic duplicated in gcc/libgcc/config/riscv/atomic.c for use when inlining -+ is disabled */ -+ -+ rtx old = gen_reg_rtx (SImode); -+ rtx mem = operands[1]; -+ rtx value = operands[2]; -+ rtx aligned_mem = gen_reg_rtx (SImode); -+ rtx shift = gen_reg_rtx (SImode); -+ rtx mask = gen_reg_rtx (SImode); -+ rtx not_mask = gen_reg_rtx (SImode); -+ -+ riscv_subword_address (mem, &aligned_mem, &shift, &mask, ¬_mask); -+ -+ rtx shifted_value = gen_reg_rtx (SImode); -+ riscv_lshift_subword (mode, value, shift, &shifted_value); -+ -+ emit_insn (gen_subword_atomic_fetch_strong_nand (old, aligned_mem, -+ shifted_value, -+ mask, not_mask)); -+ -+ emit_move_insn (old, gen_rtx_ASHIFTRT (SImode, old, -+ gen_lowpart (QImode, shift))); -+ -+ emit_move_insn (operands[0], gen_lowpart (mode, old)); -+ -+ DONE; -+}) -+ -+(define_insn "subword_atomic_fetch_strong_nand" -+ [(set (match_operand:SI 0 "register_operand" "=&r") ;; old value at mem -+ (match_operand:SI 1 "memory_operand" "+A")) ;; mem location -+ (set (match_dup 1) -+ (unspec_volatile:SI -+ [(not:SI (and:SI (match_dup 1) -+ (match_operand:SI 2 "register_operand" "rI"))) ;; value for op -+ (match_operand:SI 3 "register_operand" "rI")] ;; mask -+ UNSPEC_SYNC_OLD_OP_SUBWORD)) -+ (match_operand:SI 4 "register_operand" "rI") ;; not_mask -+ (clobber (match_scratch:SI 5 "=&r")) ;; tmp_1 -+ (clobber (match_scratch:SI 6 "=&r"))] ;; tmp_2 -+ "TARGET_ATOMIC && TARGET_INLINE_SUBWORD_ATOMIC" -+ { -+ return "1:\;" -+ "lr.w.aq\t%0, %1\;" -+ "and\t%5, %0, %2\;" -+ "not\t%5, %5\;" -+ "and\t%5, %5, %3\;" -+ "and\t%6, %0, %4\;" -+ "or\t%6, %6, %5\;" -+ "sc.w.rl\t%5, %6, %1\;" -+ "bnez\t%5, 1b"; -+ } -+ [(set (attr "length") (const_int 32))]) -+ -+(define_expand "atomic_fetch_" -+ [(match_operand:SHORT 0 "register_operand") ;; old value at mem -+ (any_atomic:SHORT (match_operand:SHORT 1 "memory_operand") ;; mem location -+ (match_operand:SHORT 2 "reg_or_0_operand")) ;; value for op -+ (match_operand:SI 3 "const_int_operand")] ;; model -+ "TARGET_ATOMIC && TARGET_INLINE_SUBWORD_ATOMIC" -+{ -+ /* We have no QImode/HImode atomics, so form a mask, then use -+ subword_atomic_fetch_strong_ to implement a LR/SC version of the -+ operation. */ -+ -+ /* Logic duplicated in gcc/libgcc/config/riscv/atomic.c for use when inlining -+ is disabled */ -+ -+ rtx old = gen_reg_rtx (SImode); -+ rtx mem = operands[1]; -+ rtx value = operands[2]; -+ rtx aligned_mem = gen_reg_rtx (SImode); -+ rtx shift = gen_reg_rtx (SImode); -+ rtx mask = gen_reg_rtx (SImode); -+ rtx not_mask = gen_reg_rtx (SImode); -+ -+ riscv_subword_address (mem, &aligned_mem, &shift, &mask, ¬_mask); -+ -+ rtx shifted_value = gen_reg_rtx (SImode); -+ riscv_lshift_subword (mode, value, shift, &shifted_value); -+ -+ emit_insn (gen_subword_atomic_fetch_strong_ (old, aligned_mem, -+ shifted_value, -+ mask, not_mask)); -+ -+ emit_move_insn (old, gen_rtx_ASHIFTRT (SImode, old, -+ gen_lowpart (QImode, shift))); -+ -+ emit_move_insn (operands[0], gen_lowpart (mode, old)); -+ -+ DONE; -+}) -+ - (define_insn "atomic_exchange" - [(set (match_operand:GPR 0 "register_operand" "=&r") - (unspec_volatile:GPR -@@ -104,6 +236,56 @@ - [(set_attr "type" "atomic") - (set (attr "length") (const_int 8))]) - -+(define_expand "atomic_exchange" -+ [(match_operand:SHORT 0 "register_operand") ;; old value at mem -+ (match_operand:SHORT 1 "memory_operand") ;; mem location -+ (match_operand:SHORT 2 "register_operand") ;; value -+ (match_operand:SI 3 "const_int_operand")] ;; model -+ "TARGET_ATOMIC && TARGET_INLINE_SUBWORD_ATOMIC" -+{ -+ rtx old = gen_reg_rtx (SImode); -+ rtx mem = operands[1]; -+ rtx value = operands[2]; -+ rtx aligned_mem = gen_reg_rtx (SImode); -+ rtx shift = gen_reg_rtx (SImode); -+ rtx mask = gen_reg_rtx (SImode); -+ rtx not_mask = gen_reg_rtx (SImode); -+ -+ riscv_subword_address (mem, &aligned_mem, &shift, &mask, ¬_mask); -+ -+ rtx shifted_value = gen_reg_rtx (SImode); -+ riscv_lshift_subword (mode, value, shift, &shifted_value); -+ -+ emit_insn (gen_subword_atomic_exchange_strong (old, aligned_mem, -+ shifted_value, not_mask)); -+ -+ emit_move_insn (old, gen_rtx_ASHIFTRT (SImode, old, -+ gen_lowpart (QImode, shift))); -+ -+ emit_move_insn (operands[0], gen_lowpart (mode, old)); -+ DONE; -+}) -+ -+(define_insn "subword_atomic_exchange_strong" -+ [(set (match_operand:SI 0 "register_operand" "=&r") ;; old value at mem -+ (match_operand:SI 1 "memory_operand" "+A")) ;; mem location -+ (set (match_dup 1) -+ (unspec_volatile:SI -+ [(match_operand:SI 2 "reg_or_0_operand" "rI") ;; value -+ (match_operand:SI 3 "reg_or_0_operand" "rI")] ;; not_mask -+ UNSPEC_SYNC_EXCHANGE_SUBWORD)) -+ (clobber (match_scratch:SI 4 "=&r"))] ;; tmp_1 -+ "TARGET_ATOMIC && TARGET_INLINE_SUBWORD_ATOMIC" -+ { -+ return "1:\;" -+ "lr.w.aq\t%0, %1\;" -+ "and\t%4, %0, %3\;" -+ "or\t%4, %4, %2\;" -+ "sc.w.rl\t%4, %4, %1\;" -+ "bnez\t%4, 1b"; -+ } -+ [(set (attr "length") (const_int 20))]) -+ - (define_insn "atomic_cas_value_strong" - [(set (match_operand:GPR 0 "register_operand" "=&r") - (match_operand:GPR 1 "memory_operand" "+A")) -@@ -153,6 +335,125 @@ - DONE; - }) - -+(define_expand "atomic_compare_and_swap" -+ [(match_operand:SI 0 "register_operand") ;; bool output -+ (match_operand:SHORT 1 "register_operand") ;; val output -+ (match_operand:SHORT 2 "memory_operand") ;; memory -+ (match_operand:SHORT 3 "reg_or_0_operand") ;; expected value -+ (match_operand:SHORT 4 "reg_or_0_operand") ;; desired value -+ (match_operand:SI 5 "const_int_operand") ;; is_weak -+ (match_operand:SI 6 "const_int_operand") ;; mod_s -+ (match_operand:SI 7 "const_int_operand")] ;; mod_f -+ "TARGET_ATOMIC && TARGET_INLINE_SUBWORD_ATOMIC" -+{ -+ emit_insn (gen_atomic_cas_value_strong (operands[1], operands[2], -+ operands[3], operands[4], -+ operands[6], operands[7])); -+ -+ rtx val = gen_reg_rtx (SImode); -+ if (operands[1] != const0_rtx) -+ emit_move_insn (val, gen_rtx_SIGN_EXTEND (SImode, operands[1])); -+ else -+ emit_move_insn (val, const0_rtx); -+ -+ rtx exp = gen_reg_rtx (SImode); -+ if (operands[3] != const0_rtx) -+ emit_move_insn (exp, gen_rtx_SIGN_EXTEND (SImode, operands[3])); -+ else -+ emit_move_insn (exp, const0_rtx); -+ -+ rtx compare = val; -+ if (exp != const0_rtx) -+ { -+ rtx difference = gen_rtx_MINUS (SImode, val, exp); -+ compare = gen_reg_rtx (SImode); -+ emit_move_insn (compare, difference); -+ } -+ -+ if (word_mode != SImode) -+ { -+ rtx reg = gen_reg_rtx (word_mode); -+ emit_move_insn (reg, gen_rtx_SIGN_EXTEND (word_mode, compare)); -+ compare = reg; -+ } -+ -+ emit_move_insn (operands[0], gen_rtx_EQ (SImode, compare, const0_rtx)); -+ DONE; -+}) -+ -+(define_expand "atomic_cas_value_strong" -+ [(match_operand:SHORT 0 "register_operand") ;; val output -+ (match_operand:SHORT 1 "memory_operand") ;; memory -+ (match_operand:SHORT 2 "reg_or_0_operand") ;; expected value -+ (match_operand:SHORT 3 "reg_or_0_operand") ;; desired value -+ (match_operand:SI 4 "const_int_operand") ;; mod_s -+ (match_operand:SI 5 "const_int_operand") ;; mod_f -+ (match_scratch:SHORT 6)] -+ "TARGET_ATOMIC && TARGET_INLINE_SUBWORD_ATOMIC" -+{ -+ /* We have no QImode/HImode atomics, so form a mask, then use -+ subword_atomic_cas_strong to implement a LR/SC version of the -+ operation. */ -+ -+ /* Logic duplicated in gcc/libgcc/config/riscv/atomic.c for use when inlining -+ is disabled */ -+ -+ rtx old = gen_reg_rtx (SImode); -+ rtx mem = operands[1]; -+ rtx aligned_mem = gen_reg_rtx (SImode); -+ rtx shift = gen_reg_rtx (SImode); -+ rtx mask = gen_reg_rtx (SImode); -+ rtx not_mask = gen_reg_rtx (SImode); -+ -+ riscv_subword_address (mem, &aligned_mem, &shift, &mask, ¬_mask); -+ -+ rtx o = operands[2]; -+ rtx n = operands[3]; -+ rtx shifted_o = gen_reg_rtx (SImode); -+ rtx shifted_n = gen_reg_rtx (SImode); -+ -+ riscv_lshift_subword (mode, o, shift, &shifted_o); -+ riscv_lshift_subword (mode, n, shift, &shifted_n); -+ -+ emit_move_insn (shifted_o, gen_rtx_AND (SImode, shifted_o, mask)); -+ emit_move_insn (shifted_n, gen_rtx_AND (SImode, shifted_n, mask)); -+ -+ emit_insn (gen_subword_atomic_cas_strong (old, aligned_mem, -+ shifted_o, shifted_n, -+ mask, not_mask)); -+ -+ emit_move_insn (old, gen_rtx_ASHIFTRT (SImode, old, -+ gen_lowpart (QImode, shift))); -+ -+ emit_move_insn (operands[0], gen_lowpart (mode, old)); -+ -+ DONE; -+}) -+ -+(define_insn "subword_atomic_cas_strong" -+ [(set (match_operand:SI 0 "register_operand" "=&r") ;; old value at mem -+ (match_operand:SI 1 "memory_operand" "+A")) ;; mem location -+ (set (match_dup 1) -+ (unspec_volatile:SI [(match_operand:SI 2 "reg_or_0_operand" "rJ") ;; expected value -+ (match_operand:SI 3 "reg_or_0_operand" "rJ")] ;; desired value -+ UNSPEC_COMPARE_AND_SWAP_SUBWORD)) -+ (match_operand:SI 4 "register_operand" "rI") ;; mask -+ (match_operand:SI 5 "register_operand" "rI") ;; not_mask -+ (clobber (match_scratch:SI 6 "=&r"))] ;; tmp_1 -+ "TARGET_ATOMIC && TARGET_INLINE_SUBWORD_ATOMIC" -+ { -+ return "1:\;" -+ "lr.w.aq\t%0, %1\;" -+ "and\t%6, %0, %4\;" -+ "bne\t%6, %z2, 1f\;" -+ "and\t%6, %0, %5\;" -+ "or\t%6, %6, %3\;" -+ "sc.w.rl\t%6, %6, %1\;" -+ "bnez\t%6, 1b\;" -+ "1:"; -+ } -+ [(set (attr "length") (const_int 28))]) -+ - (define_expand "atomic_test_and_set" - [(match_operand:QI 0 "register_operand" "") ;; bool output - (match_operand:QI 1 "memory_operand" "+A") ;; memory ---- a/gcc/doc/invoke.texi -+++ b/gcc/doc/invoke.texi -@@ -1226,7 +1226,8 @@ See RS/6000 and PowerPC Options. - -mbig-endian -mlittle-endian - -mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{reg} - -mstack-protector-guard-offset=@var{offset} ---mcsr-check -mno-csr-check} -+-mcsr-check -mno-csr-check -+-minline-atomics -mno-inline-atomics} - - @emph{RL78 Options} - @gccoptlist{-msim -mmul=none -mmul=g13 -mmul=g14 -mallregs -@@ -29006,6 +29007,13 @@ Do or don't use smaller but slower prolo - library function calls. The default is to use fast inline prologues and - epilogues. - -+@opindex minline-atomics -+@item -minline-atomics -+@itemx -mno-inline-atomics -+Do or don't use smaller but slower subword atomic emulation code that uses -+libatomic function calls. The default is to use fast inline subword atomics -+that do not require libatomic. -+ - @opindex mshorten-memrefs - @item -mshorten-memrefs - @itemx -mno-shorten-memrefs ---- /dev/null -+++ b/gcc/testsuite/gcc.target/riscv/inline-atomics-1.c -@@ -0,0 +1,18 @@ -+/* { dg-do compile } */ -+/* { dg-options "-mno-inline-atomics" } */ -+/* { dg-message "note: '__sync_fetch_and_nand' changed semantics in GCC 4.4" "fetch_and_nand" { target *-*-* } 0 } */ -+/* { dg-final { scan-assembler "\tcall\t__sync_fetch_and_add_1" } } */ -+/* { dg-final { scan-assembler "\tcall\t__sync_fetch_and_nand_1" } } */ -+/* { dg-final { scan-assembler "\tcall\t__sync_bool_compare_and_swap_1" } } */ -+ -+char foo; -+char bar; -+char baz; -+ -+int -+main () -+{ -+ __sync_fetch_and_add(&foo, 1); -+ __sync_fetch_and_nand(&bar, 1); -+ __sync_bool_compare_and_swap (&baz, 1, 2); -+} ---- /dev/null -+++ b/gcc/testsuite/gcc.target/riscv/inline-atomics-2.c -@@ -0,0 +1,9 @@ -+/* { dg-do compile } */ -+/* Verify that subword atomics do not generate calls. */ -+/* { dg-options "-minline-atomics" } */ -+/* { dg-message "note: '__sync_fetch_and_nand' changed semantics in GCC 4.4" "fetch_and_nand" { target *-*-* } 0 } */ -+/* { dg-final { scan-assembler-not "\tcall\t__sync_fetch_and_add_1" } } */ -+/* { dg-final { scan-assembler-not "\tcall\t__sync_fetch_and_nand_1" } } */ -+/* { dg-final { scan-assembler-not "\tcall\t__sync_bool_compare_and_swap_1" } } */ -+ -+#include "inline-atomics-1.c" -\ No newline at end of file ---- /dev/null -+++ b/gcc/testsuite/gcc.target/riscv/inline-atomics-3.c -@@ -0,0 +1,569 @@ -+/* Check all char alignments. */ -+/* Duplicate logic as libatomic/testsuite/libatomic.c/atomic-op-1.c */ -+/* Test __atomic routines for existence and proper execution on 1 byte -+ values with each valid memory model. */ -+/* { dg-do run } */ -+/* { dg-options "-minline-atomics -Wno-address-of-packed-member" } */ -+ -+/* Test the execution of the __atomic_*OP builtin routines for a char. */ -+ -+extern void abort(void); -+ -+char count, res; -+const char init = ~0; -+ -+struct A -+{ -+ char a; -+ char b; -+ char c; -+ char d; -+} __attribute__ ((packed)) A; -+ -+/* The fetch_op routines return the original value before the operation. */ -+ -+void -+test_fetch_add (char* v) -+{ -+ *v = 0; -+ count = 1; -+ -+ if (__atomic_fetch_add (v, count, __ATOMIC_RELAXED) != 0) -+ abort (); -+ -+ if (__atomic_fetch_add (v, 1, __ATOMIC_CONSUME) != 1) -+ abort (); -+ -+ if (__atomic_fetch_add (v, count, __ATOMIC_ACQUIRE) != 2) -+ abort (); -+ -+ if (__atomic_fetch_add (v, 1, __ATOMIC_RELEASE) != 3) -+ abort (); -+ -+ if (__atomic_fetch_add (v, count, __ATOMIC_ACQ_REL) != 4) -+ abort (); -+ -+ if (__atomic_fetch_add (v, 1, __ATOMIC_SEQ_CST) != 5) -+ abort (); -+} -+ -+ -+void -+test_fetch_sub (char* v) -+{ -+ *v = res = 20; -+ count = 0; -+ -+ if (__atomic_fetch_sub (v, count + 1, __ATOMIC_RELAXED) != res--) -+ abort (); -+ -+ if (__atomic_fetch_sub (v, 1, __ATOMIC_CONSUME) != res--) -+ abort (); -+ -+ if (__atomic_fetch_sub (v, count + 1, __ATOMIC_ACQUIRE) != res--) -+ abort (); -+ -+ if (__atomic_fetch_sub (v, 1, __ATOMIC_RELEASE) != res--) -+ abort (); -+ -+ if (__atomic_fetch_sub (v, count + 1, __ATOMIC_ACQ_REL) != res--) -+ abort (); -+ -+ if (__atomic_fetch_sub (v, 1, __ATOMIC_SEQ_CST) != res--) -+ abort (); -+} -+ -+void -+test_fetch_and (char* v) -+{ -+ *v = init; -+ -+ if (__atomic_fetch_and (v, 0, __ATOMIC_RELAXED) != init) -+ abort (); -+ -+ if (__atomic_fetch_and (v, init, __ATOMIC_CONSUME) != 0) -+ abort (); -+ -+ if (__atomic_fetch_and (v, 0, __ATOMIC_ACQUIRE) != 0) -+ abort (); -+ -+ *v = ~*v; -+ if (__atomic_fetch_and (v, init, __ATOMIC_RELEASE) != init) -+ abort (); -+ -+ if (__atomic_fetch_and (v, 0, __ATOMIC_ACQ_REL) != init) -+ abort (); -+ -+ if (__atomic_fetch_and (v, 0, __ATOMIC_SEQ_CST) != 0) -+ abort (); -+} -+ -+void -+test_fetch_nand (char* v) -+{ -+ *v = init; -+ -+ if (__atomic_fetch_nand (v, 0, __ATOMIC_RELAXED) != init) -+ abort (); -+ -+ if (__atomic_fetch_nand (v, init, __ATOMIC_CONSUME) != init) -+ abort (); -+ -+ if (__atomic_fetch_nand (v, 0, __ATOMIC_ACQUIRE) != 0 ) -+ abort (); -+ -+ if (__atomic_fetch_nand (v, init, __ATOMIC_RELEASE) != init) -+ abort (); -+ -+ if (__atomic_fetch_nand (v, init, __ATOMIC_ACQ_REL) != 0) -+ abort (); -+ -+ if (__atomic_fetch_nand (v, 0, __ATOMIC_SEQ_CST) != init) -+ abort (); -+} -+ -+void -+test_fetch_xor (char* v) -+{ -+ *v = init; -+ count = 0; -+ -+ if (__atomic_fetch_xor (v, count, __ATOMIC_RELAXED) != init) -+ abort (); -+ -+ if (__atomic_fetch_xor (v, ~count, __ATOMIC_CONSUME) != init) -+ abort (); -+ -+ if (__atomic_fetch_xor (v, 0, __ATOMIC_ACQUIRE) != 0) -+ abort (); -+ -+ if (__atomic_fetch_xor (v, ~count, __ATOMIC_RELEASE) != 0) -+ abort (); -+ -+ if (__atomic_fetch_xor (v, 0, __ATOMIC_ACQ_REL) != init) -+ abort (); -+ -+ if (__atomic_fetch_xor (v, ~count, __ATOMIC_SEQ_CST) != init) -+ abort (); -+} -+ -+void -+test_fetch_or (char* v) -+{ -+ *v = 0; -+ count = 1; -+ -+ if (__atomic_fetch_or (v, count, __ATOMIC_RELAXED) != 0) -+ abort (); -+ -+ count *= 2; -+ if (__atomic_fetch_or (v, 2, __ATOMIC_CONSUME) != 1) -+ abort (); -+ -+ count *= 2; -+ if (__atomic_fetch_or (v, count, __ATOMIC_ACQUIRE) != 3) -+ abort (); -+ -+ count *= 2; -+ if (__atomic_fetch_or (v, 8, __ATOMIC_RELEASE) != 7) -+ abort (); -+ -+ count *= 2; -+ if (__atomic_fetch_or (v, count, __ATOMIC_ACQ_REL) != 15) -+ abort (); -+ -+ count *= 2; -+ if (__atomic_fetch_or (v, count, __ATOMIC_SEQ_CST) != 31) -+ abort (); -+} -+ -+/* The OP_fetch routines return the new value after the operation. */ -+ -+void -+test_add_fetch (char* v) -+{ -+ *v = 0; -+ count = 1; -+ -+ if (__atomic_add_fetch (v, count, __ATOMIC_RELAXED) != 1) -+ abort (); -+ -+ if (__atomic_add_fetch (v, 1, __ATOMIC_CONSUME) != 2) -+ abort (); -+ -+ if (__atomic_add_fetch (v, count, __ATOMIC_ACQUIRE) != 3) -+ abort (); -+ -+ if (__atomic_add_fetch (v, 1, __ATOMIC_RELEASE) != 4) -+ abort (); -+ -+ if (__atomic_add_fetch (v, count, __ATOMIC_ACQ_REL) != 5) -+ abort (); -+ -+ if (__atomic_add_fetch (v, count, __ATOMIC_SEQ_CST) != 6) -+ abort (); -+} -+ -+ -+void -+test_sub_fetch (char* v) -+{ -+ *v = res = 20; -+ count = 0; -+ -+ if (__atomic_sub_fetch (v, count + 1, __ATOMIC_RELAXED) != --res) -+ abort (); -+ -+ if (__atomic_sub_fetch (v, 1, __ATOMIC_CONSUME) != --res) -+ abort (); -+ -+ if (__atomic_sub_fetch (v, count + 1, __ATOMIC_ACQUIRE) != --res) -+ abort (); -+ -+ if (__atomic_sub_fetch (v, 1, __ATOMIC_RELEASE) != --res) -+ abort (); -+ -+ if (__atomic_sub_fetch (v, count + 1, __ATOMIC_ACQ_REL) != --res) -+ abort (); -+ -+ if (__atomic_sub_fetch (v, count + 1, __ATOMIC_SEQ_CST) != --res) -+ abort (); -+} -+ -+void -+test_and_fetch (char* v) -+{ -+ *v = init; -+ -+ if (__atomic_and_fetch (v, 0, __ATOMIC_RELAXED) != 0) -+ abort (); -+ -+ *v = init; -+ if (__atomic_and_fetch (v, init, __ATOMIC_CONSUME) != init) -+ abort (); -+ -+ if (__atomic_and_fetch (v, 0, __ATOMIC_ACQUIRE) != 0) -+ abort (); -+ -+ *v = ~*v; -+ if (__atomic_and_fetch (v, init, __ATOMIC_RELEASE) != init) -+ abort (); -+ -+ if (__atomic_and_fetch (v, 0, __ATOMIC_ACQ_REL) != 0) -+ abort (); -+ -+ *v = ~*v; -+ if (__atomic_and_fetch (v, 0, __ATOMIC_SEQ_CST) != 0) -+ abort (); -+} -+ -+void -+test_nand_fetch (char* v) -+{ -+ *v = init; -+ -+ if (__atomic_nand_fetch (v, 0, __ATOMIC_RELAXED) != init) -+ abort (); -+ -+ if (__atomic_nand_fetch (v, init, __ATOMIC_CONSUME) != 0) -+ abort (); -+ -+ if (__atomic_nand_fetch (v, 0, __ATOMIC_ACQUIRE) != init) -+ abort (); -+ -+ if (__atomic_nand_fetch (v, init, __ATOMIC_RELEASE) != 0) -+ abort (); -+ -+ if (__atomic_nand_fetch (v, init, __ATOMIC_ACQ_REL) != init) -+ abort (); -+ -+ if (__atomic_nand_fetch (v, 0, __ATOMIC_SEQ_CST) != init) -+ abort (); -+} -+ -+ -+ -+void -+test_xor_fetch (char* v) -+{ -+ *v = init; -+ count = 0; -+ -+ if (__atomic_xor_fetch (v, count, __ATOMIC_RELAXED) != init) -+ abort (); -+ -+ if (__atomic_xor_fetch (v, ~count, __ATOMIC_CONSUME) != 0) -+ abort (); -+ -+ if (__atomic_xor_fetch (v, 0, __ATOMIC_ACQUIRE) != 0) -+ abort (); -+ -+ if (__atomic_xor_fetch (v, ~count, __ATOMIC_RELEASE) != init) -+ abort (); -+ -+ if (__atomic_xor_fetch (v, 0, __ATOMIC_ACQ_REL) != init) -+ abort (); -+ -+ if (__atomic_xor_fetch (v, ~count, __ATOMIC_SEQ_CST) != 0) -+ abort (); -+} -+ -+void -+test_or_fetch (char* v) -+{ -+ *v = 0; -+ count = 1; -+ -+ if (__atomic_or_fetch (v, count, __ATOMIC_RELAXED) != 1) -+ abort (); -+ -+ count *= 2; -+ if (__atomic_or_fetch (v, 2, __ATOMIC_CONSUME) != 3) -+ abort (); -+ -+ count *= 2; -+ if (__atomic_or_fetch (v, count, __ATOMIC_ACQUIRE) != 7) -+ abort (); -+ -+ count *= 2; -+ if (__atomic_or_fetch (v, 8, __ATOMIC_RELEASE) != 15) -+ abort (); -+ -+ count *= 2; -+ if (__atomic_or_fetch (v, count, __ATOMIC_ACQ_REL) != 31) -+ abort (); -+ -+ count *= 2; -+ if (__atomic_or_fetch (v, count, __ATOMIC_SEQ_CST) != 63) -+ abort (); -+} -+ -+ -+/* Test the OP routines with a result which isn't used. Use both variations -+ within each function. */ -+ -+void -+test_add (char* v) -+{ -+ *v = 0; -+ count = 1; -+ -+ __atomic_add_fetch (v, count, __ATOMIC_RELAXED); -+ if (*v != 1) -+ abort (); -+ -+ __atomic_fetch_add (v, count, __ATOMIC_CONSUME); -+ if (*v != 2) -+ abort (); -+ -+ __atomic_add_fetch (v, 1 , __ATOMIC_ACQUIRE); -+ if (*v != 3) -+ abort (); -+ -+ __atomic_fetch_add (v, 1, __ATOMIC_RELEASE); -+ if (*v != 4) -+ abort (); -+ -+ __atomic_add_fetch (v, count, __ATOMIC_ACQ_REL); -+ if (*v != 5) -+ abort (); -+ -+ __atomic_fetch_add (v, count, __ATOMIC_SEQ_CST); -+ if (*v != 6) -+ abort (); -+} -+ -+ -+void -+test_sub (char* v) -+{ -+ *v = res = 20; -+ count = 0; -+ -+ __atomic_sub_fetch (v, count + 1, __ATOMIC_RELAXED); -+ if (*v != --res) -+ abort (); -+ -+ __atomic_fetch_sub (v, count + 1, __ATOMIC_CONSUME); -+ if (*v != --res) -+ abort (); -+ -+ __atomic_sub_fetch (v, 1, __ATOMIC_ACQUIRE); -+ if (*v != --res) -+ abort (); -+ -+ __atomic_fetch_sub (v, 1, __ATOMIC_RELEASE); -+ if (*v != --res) -+ abort (); -+ -+ __atomic_sub_fetch (v, count + 1, __ATOMIC_ACQ_REL); -+ if (*v != --res) -+ abort (); -+ -+ __atomic_fetch_sub (v, count + 1, __ATOMIC_SEQ_CST); -+ if (*v != --res) -+ abort (); -+} -+ -+void -+test_and (char* v) -+{ -+ *v = init; -+ -+ __atomic_and_fetch (v, 0, __ATOMIC_RELAXED); -+ if (*v != 0) -+ abort (); -+ -+ *v = init; -+ __atomic_fetch_and (v, init, __ATOMIC_CONSUME); -+ if (*v != init) -+ abort (); -+ -+ __atomic_and_fetch (v, 0, __ATOMIC_ACQUIRE); -+ if (*v != 0) -+ abort (); -+ -+ *v = ~*v; -+ __atomic_fetch_and (v, init, __ATOMIC_RELEASE); -+ if (*v != init) -+ abort (); -+ -+ __atomic_and_fetch (v, 0, __ATOMIC_ACQ_REL); -+ if (*v != 0) -+ abort (); -+ -+ *v = ~*v; -+ __atomic_fetch_and (v, 0, __ATOMIC_SEQ_CST); -+ if (*v != 0) -+ abort (); -+} -+ -+void -+test_nand (char* v) -+{ -+ *v = init; -+ -+ __atomic_fetch_nand (v, 0, __ATOMIC_RELAXED); -+ if (*v != init) -+ abort (); -+ -+ __atomic_fetch_nand (v, init, __ATOMIC_CONSUME); -+ if (*v != 0) -+ abort (); -+ -+ __atomic_nand_fetch (v, 0, __ATOMIC_ACQUIRE); -+ if (*v != init) -+ abort (); -+ -+ __atomic_nand_fetch (v, init, __ATOMIC_RELEASE); -+ if (*v != 0) -+ abort (); -+ -+ __atomic_fetch_nand (v, init, __ATOMIC_ACQ_REL); -+ if (*v != init) -+ abort (); -+ -+ __atomic_nand_fetch (v, 0, __ATOMIC_SEQ_CST); -+ if (*v != init) -+ abort (); -+} -+ -+ -+ -+void -+test_xor (char* v) -+{ -+ *v = init; -+ count = 0; -+ -+ __atomic_xor_fetch (v, count, __ATOMIC_RELAXED); -+ if (*v != init) -+ abort (); -+ -+ __atomic_fetch_xor (v, ~count, __ATOMIC_CONSUME); -+ if (*v != 0) -+ abort (); -+ -+ __atomic_xor_fetch (v, 0, __ATOMIC_ACQUIRE); -+ if (*v != 0) -+ abort (); -+ -+ __atomic_fetch_xor (v, ~count, __ATOMIC_RELEASE); -+ if (*v != init) -+ abort (); -+ -+ __atomic_fetch_xor (v, 0, __ATOMIC_ACQ_REL); -+ if (*v != init) -+ abort (); -+ -+ __atomic_xor_fetch (v, ~count, __ATOMIC_SEQ_CST); -+ if (*v != 0) -+ abort (); -+} -+ -+void -+test_or (char* v) -+{ -+ *v = 0; -+ count = 1; -+ -+ __atomic_or_fetch (v, count, __ATOMIC_RELAXED); -+ if (*v != 1) -+ abort (); -+ -+ count *= 2; -+ __atomic_fetch_or (v, count, __ATOMIC_CONSUME); -+ if (*v != 3) -+ abort (); -+ -+ count *= 2; -+ __atomic_or_fetch (v, 4, __ATOMIC_ACQUIRE); -+ if (*v != 7) -+ abort (); -+ -+ count *= 2; -+ __atomic_fetch_or (v, 8, __ATOMIC_RELEASE); -+ if (*v != 15) -+ abort (); -+ -+ count *= 2; -+ __atomic_or_fetch (v, count, __ATOMIC_ACQ_REL); -+ if (*v != 31) -+ abort (); -+ -+ count *= 2; -+ __atomic_fetch_or (v, count, __ATOMIC_SEQ_CST); -+ if (*v != 63) -+ abort (); -+} -+ -+int -+main () -+{ -+ char* V[] = {&A.a, &A.b, &A.c, &A.d}; -+ -+ for (int i = 0; i < 4; i++) { -+ test_fetch_add (V[i]); -+ test_fetch_sub (V[i]); -+ test_fetch_and (V[i]); -+ test_fetch_nand (V[i]); -+ test_fetch_xor (V[i]); -+ test_fetch_or (V[i]); -+ -+ test_add_fetch (V[i]); -+ test_sub_fetch (V[i]); -+ test_and_fetch (V[i]); -+ test_nand_fetch (V[i]); -+ test_xor_fetch (V[i]); -+ test_or_fetch (V[i]); -+ -+ test_add (V[i]); -+ test_sub (V[i]); -+ test_and (V[i]); -+ test_nand (V[i]); -+ test_xor (V[i]); -+ test_or (V[i]); -+ } -+ -+ return 0; -+} ---- /dev/null -+++ b/gcc/testsuite/gcc.target/riscv/inline-atomics-4.c -@@ -0,0 +1,566 @@ -+/* Check all short alignments. */ -+/* Duplicate logic as libatomic/testsuite/libatomic.c/atomic-op-2.c */ -+/* Test __atomic routines for existence and proper execution on 2 byte -+ values with each valid memory model. */ -+/* { dg-do run } */ -+/* { dg-options "-minline-atomics -Wno-address-of-packed-member" } */ -+ -+/* Test the execution of the __atomic_*OP builtin routines for a short. */ -+ -+extern void abort(void); -+ -+short count, res; -+const short init = ~0; -+ -+struct A -+{ -+ short a; -+ short b; -+} __attribute__ ((packed)) A; -+ -+/* The fetch_op routines return the original value before the operation. */ -+ -+void -+test_fetch_add (short* v) -+{ -+ *v = 0; -+ count = 1; -+ -+ if (__atomic_fetch_add (v, count, __ATOMIC_RELAXED) != 0) -+ abort (); -+ -+ if (__atomic_fetch_add (v, 1, __ATOMIC_CONSUME) != 1) -+ abort (); -+ -+ if (__atomic_fetch_add (v, count, __ATOMIC_ACQUIRE) != 2) -+ abort (); -+ -+ if (__atomic_fetch_add (v, 1, __ATOMIC_RELEASE) != 3) -+ abort (); -+ -+ if (__atomic_fetch_add (v, count, __ATOMIC_ACQ_REL) != 4) -+ abort (); -+ -+ if (__atomic_fetch_add (v, 1, __ATOMIC_SEQ_CST) != 5) -+ abort (); -+} -+ -+ -+void -+test_fetch_sub (short* v) -+{ -+ *v = res = 20; -+ count = 0; -+ -+ if (__atomic_fetch_sub (v, count + 1, __ATOMIC_RELAXED) != res--) -+ abort (); -+ -+ if (__atomic_fetch_sub (v, 1, __ATOMIC_CONSUME) != res--) -+ abort (); -+ -+ if (__atomic_fetch_sub (v, count + 1, __ATOMIC_ACQUIRE) != res--) -+ abort (); -+ -+ if (__atomic_fetch_sub (v, 1, __ATOMIC_RELEASE) != res--) -+ abort (); -+ -+ if (__atomic_fetch_sub (v, count + 1, __ATOMIC_ACQ_REL) != res--) -+ abort (); -+ -+ if (__atomic_fetch_sub (v, 1, __ATOMIC_SEQ_CST) != res--) -+ abort (); -+} -+ -+void -+test_fetch_and (short* v) -+{ -+ *v = init; -+ -+ if (__atomic_fetch_and (v, 0, __ATOMIC_RELAXED) != init) -+ abort (); -+ -+ if (__atomic_fetch_and (v, init, __ATOMIC_CONSUME) != 0) -+ abort (); -+ -+ if (__atomic_fetch_and (v, 0, __ATOMIC_ACQUIRE) != 0) -+ abort (); -+ -+ *v = ~*v; -+ if (__atomic_fetch_and (v, init, __ATOMIC_RELEASE) != init) -+ abort (); -+ -+ if (__atomic_fetch_and (v, 0, __ATOMIC_ACQ_REL) != init) -+ abort (); -+ -+ if (__atomic_fetch_and (v, 0, __ATOMIC_SEQ_CST) != 0) -+ abort (); -+} -+ -+void -+test_fetch_nand (short* v) -+{ -+ *v = init; -+ -+ if (__atomic_fetch_nand (v, 0, __ATOMIC_RELAXED) != init) -+ abort (); -+ -+ if (__atomic_fetch_nand (v, init, __ATOMIC_CONSUME) != init) -+ abort (); -+ -+ if (__atomic_fetch_nand (v, 0, __ATOMIC_ACQUIRE) != 0 ) -+ abort (); -+ -+ if (__atomic_fetch_nand (v, init, __ATOMIC_RELEASE) != init) -+ abort (); -+ -+ if (__atomic_fetch_nand (v, init, __ATOMIC_ACQ_REL) != 0) -+ abort (); -+ -+ if (__atomic_fetch_nand (v, 0, __ATOMIC_SEQ_CST) != init) -+ abort (); -+} -+ -+void -+test_fetch_xor (short* v) -+{ -+ *v = init; -+ count = 0; -+ -+ if (__atomic_fetch_xor (v, count, __ATOMIC_RELAXED) != init) -+ abort (); -+ -+ if (__atomic_fetch_xor (v, ~count, __ATOMIC_CONSUME) != init) -+ abort (); -+ -+ if (__atomic_fetch_xor (v, 0, __ATOMIC_ACQUIRE) != 0) -+ abort (); -+ -+ if (__atomic_fetch_xor (v, ~count, __ATOMIC_RELEASE) != 0) -+ abort (); -+ -+ if (__atomic_fetch_xor (v, 0, __ATOMIC_ACQ_REL) != init) -+ abort (); -+ -+ if (__atomic_fetch_xor (v, ~count, __ATOMIC_SEQ_CST) != init) -+ abort (); -+} -+ -+void -+test_fetch_or (short* v) -+{ -+ *v = 0; -+ count = 1; -+ -+ if (__atomic_fetch_or (v, count, __ATOMIC_RELAXED) != 0) -+ abort (); -+ -+ count *= 2; -+ if (__atomic_fetch_or (v, 2, __ATOMIC_CONSUME) != 1) -+ abort (); -+ -+ count *= 2; -+ if (__atomic_fetch_or (v, count, __ATOMIC_ACQUIRE) != 3) -+ abort (); -+ -+ count *= 2; -+ if (__atomic_fetch_or (v, 8, __ATOMIC_RELEASE) != 7) -+ abort (); -+ -+ count *= 2; -+ if (__atomic_fetch_or (v, count, __ATOMIC_ACQ_REL) != 15) -+ abort (); -+ -+ count *= 2; -+ if (__atomic_fetch_or (v, count, __ATOMIC_SEQ_CST) != 31) -+ abort (); -+} -+ -+/* The OP_fetch routines return the new value after the operation. */ -+ -+void -+test_add_fetch (short* v) -+{ -+ *v = 0; -+ count = 1; -+ -+ if (__atomic_add_fetch (v, count, __ATOMIC_RELAXED) != 1) -+ abort (); -+ -+ if (__atomic_add_fetch (v, 1, __ATOMIC_CONSUME) != 2) -+ abort (); -+ -+ if (__atomic_add_fetch (v, count, __ATOMIC_ACQUIRE) != 3) -+ abort (); -+ -+ if (__atomic_add_fetch (v, 1, __ATOMIC_RELEASE) != 4) -+ abort (); -+ -+ if (__atomic_add_fetch (v, count, __ATOMIC_ACQ_REL) != 5) -+ abort (); -+ -+ if (__atomic_add_fetch (v, count, __ATOMIC_SEQ_CST) != 6) -+ abort (); -+} -+ -+ -+void -+test_sub_fetch (short* v) -+{ -+ *v = res = 20; -+ count = 0; -+ -+ if (__atomic_sub_fetch (v, count + 1, __ATOMIC_RELAXED) != --res) -+ abort (); -+ -+ if (__atomic_sub_fetch (v, 1, __ATOMIC_CONSUME) != --res) -+ abort (); -+ -+ if (__atomic_sub_fetch (v, count + 1, __ATOMIC_ACQUIRE) != --res) -+ abort (); -+ -+ if (__atomic_sub_fetch (v, 1, __ATOMIC_RELEASE) != --res) -+ abort (); -+ -+ if (__atomic_sub_fetch (v, count + 1, __ATOMIC_ACQ_REL) != --res) -+ abort (); -+ -+ if (__atomic_sub_fetch (v, count + 1, __ATOMIC_SEQ_CST) != --res) -+ abort (); -+} -+ -+void -+test_and_fetch (short* v) -+{ -+ *v = init; -+ -+ if (__atomic_and_fetch (v, 0, __ATOMIC_RELAXED) != 0) -+ abort (); -+ -+ *v = init; -+ if (__atomic_and_fetch (v, init, __ATOMIC_CONSUME) != init) -+ abort (); -+ -+ if (__atomic_and_fetch (v, 0, __ATOMIC_ACQUIRE) != 0) -+ abort (); -+ -+ *v = ~*v; -+ if (__atomic_and_fetch (v, init, __ATOMIC_RELEASE) != init) -+ abort (); -+ -+ if (__atomic_and_fetch (v, 0, __ATOMIC_ACQ_REL) != 0) -+ abort (); -+ -+ *v = ~*v; -+ if (__atomic_and_fetch (v, 0, __ATOMIC_SEQ_CST) != 0) -+ abort (); -+} -+ -+void -+test_nand_fetch (short* v) -+{ -+ *v = init; -+ -+ if (__atomic_nand_fetch (v, 0, __ATOMIC_RELAXED) != init) -+ abort (); -+ -+ if (__atomic_nand_fetch (v, init, __ATOMIC_CONSUME) != 0) -+ abort (); -+ -+ if (__atomic_nand_fetch (v, 0, __ATOMIC_ACQUIRE) != init) -+ abort (); -+ -+ if (__atomic_nand_fetch (v, init, __ATOMIC_RELEASE) != 0) -+ abort (); -+ -+ if (__atomic_nand_fetch (v, init, __ATOMIC_ACQ_REL) != init) -+ abort (); -+ -+ if (__atomic_nand_fetch (v, 0, __ATOMIC_SEQ_CST) != init) -+ abort (); -+} -+ -+ -+ -+void -+test_xor_fetch (short* v) -+{ -+ *v = init; -+ count = 0; -+ -+ if (__atomic_xor_fetch (v, count, __ATOMIC_RELAXED) != init) -+ abort (); -+ -+ if (__atomic_xor_fetch (v, ~count, __ATOMIC_CONSUME) != 0) -+ abort (); -+ -+ if (__atomic_xor_fetch (v, 0, __ATOMIC_ACQUIRE) != 0) -+ abort (); -+ -+ if (__atomic_xor_fetch (v, ~count, __ATOMIC_RELEASE) != init) -+ abort (); -+ -+ if (__atomic_xor_fetch (v, 0, __ATOMIC_ACQ_REL) != init) -+ abort (); -+ -+ if (__atomic_xor_fetch (v, ~count, __ATOMIC_SEQ_CST) != 0) -+ abort (); -+} -+ -+void -+test_or_fetch (short* v) -+{ -+ *v = 0; -+ count = 1; -+ -+ if (__atomic_or_fetch (v, count, __ATOMIC_RELAXED) != 1) -+ abort (); -+ -+ count *= 2; -+ if (__atomic_or_fetch (v, 2, __ATOMIC_CONSUME) != 3) -+ abort (); -+ -+ count *= 2; -+ if (__atomic_or_fetch (v, count, __ATOMIC_ACQUIRE) != 7) -+ abort (); -+ -+ count *= 2; -+ if (__atomic_or_fetch (v, 8, __ATOMIC_RELEASE) != 15) -+ abort (); -+ -+ count *= 2; -+ if (__atomic_or_fetch (v, count, __ATOMIC_ACQ_REL) != 31) -+ abort (); -+ -+ count *= 2; -+ if (__atomic_or_fetch (v, count, __ATOMIC_SEQ_CST) != 63) -+ abort (); -+} -+ -+ -+/* Test the OP routines with a result which isn't used. Use both variations -+ within each function. */ -+ -+void -+test_add (short* v) -+{ -+ *v = 0; -+ count = 1; -+ -+ __atomic_add_fetch (v, count, __ATOMIC_RELAXED); -+ if (*v != 1) -+ abort (); -+ -+ __atomic_fetch_add (v, count, __ATOMIC_CONSUME); -+ if (*v != 2) -+ abort (); -+ -+ __atomic_add_fetch (v, 1 , __ATOMIC_ACQUIRE); -+ if (*v != 3) -+ abort (); -+ -+ __atomic_fetch_add (v, 1, __ATOMIC_RELEASE); -+ if (*v != 4) -+ abort (); -+ -+ __atomic_add_fetch (v, count, __ATOMIC_ACQ_REL); -+ if (*v != 5) -+ abort (); -+ -+ __atomic_fetch_add (v, count, __ATOMIC_SEQ_CST); -+ if (*v != 6) -+ abort (); -+} -+ -+ -+void -+test_sub (short* v) -+{ -+ *v = res = 20; -+ count = 0; -+ -+ __atomic_sub_fetch (v, count + 1, __ATOMIC_RELAXED); -+ if (*v != --res) -+ abort (); -+ -+ __atomic_fetch_sub (v, count + 1, __ATOMIC_CONSUME); -+ if (*v != --res) -+ abort (); -+ -+ __atomic_sub_fetch (v, 1, __ATOMIC_ACQUIRE); -+ if (*v != --res) -+ abort (); -+ -+ __atomic_fetch_sub (v, 1, __ATOMIC_RELEASE); -+ if (*v != --res) -+ abort (); -+ -+ __atomic_sub_fetch (v, count + 1, __ATOMIC_ACQ_REL); -+ if (*v != --res) -+ abort (); -+ -+ __atomic_fetch_sub (v, count + 1, __ATOMIC_SEQ_CST); -+ if (*v != --res) -+ abort (); -+} -+ -+void -+test_and (short* v) -+{ -+ *v = init; -+ -+ __atomic_and_fetch (v, 0, __ATOMIC_RELAXED); -+ if (*v != 0) -+ abort (); -+ -+ *v = init; -+ __atomic_fetch_and (v, init, __ATOMIC_CONSUME); -+ if (*v != init) -+ abort (); -+ -+ __atomic_and_fetch (v, 0, __ATOMIC_ACQUIRE); -+ if (*v != 0) -+ abort (); -+ -+ *v = ~*v; -+ __atomic_fetch_and (v, init, __ATOMIC_RELEASE); -+ if (*v != init) -+ abort (); -+ -+ __atomic_and_fetch (v, 0, __ATOMIC_ACQ_REL); -+ if (*v != 0) -+ abort (); -+ -+ *v = ~*v; -+ __atomic_fetch_and (v, 0, __ATOMIC_SEQ_CST); -+ if (*v != 0) -+ abort (); -+} -+ -+void -+test_nand (short* v) -+{ -+ *v = init; -+ -+ __atomic_fetch_nand (v, 0, __ATOMIC_RELAXED); -+ if (*v != init) -+ abort (); -+ -+ __atomic_fetch_nand (v, init, __ATOMIC_CONSUME); -+ if (*v != 0) -+ abort (); -+ -+ __atomic_nand_fetch (v, 0, __ATOMIC_ACQUIRE); -+ if (*v != init) -+ abort (); -+ -+ __atomic_nand_fetch (v, init, __ATOMIC_RELEASE); -+ if (*v != 0) -+ abort (); -+ -+ __atomic_fetch_nand (v, init, __ATOMIC_ACQ_REL); -+ if (*v != init) -+ abort (); -+ -+ __atomic_nand_fetch (v, 0, __ATOMIC_SEQ_CST); -+ if (*v != init) -+ abort (); -+} -+ -+ -+ -+void -+test_xor (short* v) -+{ -+ *v = init; -+ count = 0; -+ -+ __atomic_xor_fetch (v, count, __ATOMIC_RELAXED); -+ if (*v != init) -+ abort (); -+ -+ __atomic_fetch_xor (v, ~count, __ATOMIC_CONSUME); -+ if (*v != 0) -+ abort (); -+ -+ __atomic_xor_fetch (v, 0, __ATOMIC_ACQUIRE); -+ if (*v != 0) -+ abort (); -+ -+ __atomic_fetch_xor (v, ~count, __ATOMIC_RELEASE); -+ if (*v != init) -+ abort (); -+ -+ __atomic_fetch_xor (v, 0, __ATOMIC_ACQ_REL); -+ if (*v != init) -+ abort (); -+ -+ __atomic_xor_fetch (v, ~count, __ATOMIC_SEQ_CST); -+ if (*v != 0) -+ abort (); -+} -+ -+void -+test_or (short* v) -+{ -+ *v = 0; -+ count = 1; -+ -+ __atomic_or_fetch (v, count, __ATOMIC_RELAXED); -+ if (*v != 1) -+ abort (); -+ -+ count *= 2; -+ __atomic_fetch_or (v, count, __ATOMIC_CONSUME); -+ if (*v != 3) -+ abort (); -+ -+ count *= 2; -+ __atomic_or_fetch (v, 4, __ATOMIC_ACQUIRE); -+ if (*v != 7) -+ abort (); -+ -+ count *= 2; -+ __atomic_fetch_or (v, 8, __ATOMIC_RELEASE); -+ if (*v != 15) -+ abort (); -+ -+ count *= 2; -+ __atomic_or_fetch (v, count, __ATOMIC_ACQ_REL); -+ if (*v != 31) -+ abort (); -+ -+ count *= 2; -+ __atomic_fetch_or (v, count, __ATOMIC_SEQ_CST); -+ if (*v != 63) -+ abort (); -+} -+ -+int -+main () { -+ short* V[] = {&A.a, &A.b}; -+ -+ for (int i = 0; i < 2; i++) { -+ test_fetch_add (V[i]); -+ test_fetch_sub (V[i]); -+ test_fetch_and (V[i]); -+ test_fetch_nand (V[i]); -+ test_fetch_xor (V[i]); -+ test_fetch_or (V[i]); -+ -+ test_add_fetch (V[i]); -+ test_sub_fetch (V[i]); -+ test_and_fetch (V[i]); -+ test_nand_fetch (V[i]); -+ test_xor_fetch (V[i]); -+ test_or_fetch (V[i]); -+ -+ test_add (V[i]); -+ test_sub (V[i]); -+ test_and (V[i]); -+ test_nand (V[i]); -+ test_xor (V[i]); -+ test_or (V[i]); -+ } -+ -+ return 0; -+} ---- /dev/null -+++ b/gcc/testsuite/gcc.target/riscv/inline-atomics-5.c -@@ -0,0 +1,87 @@ -+/* Test __atomic routines for existence and proper execution on 1 byte -+ values with each valid memory model. */ -+/* Duplicate logic as libatomic/testsuite/libatomic.c/atomic-compare-exchange-1.c */ -+/* { dg-do run } */ -+/* { dg-options "-minline-atomics" } */ -+ -+/* Test the execution of the __atomic_compare_exchange_n builtin for a char. */ -+ -+extern void abort(void); -+ -+char v = 0; -+char expected = 0; -+char max = ~0; -+char desired = ~0; -+char zero = 0; -+ -+#define STRONG 0 -+#define WEAK 1 -+ -+int -+main () -+{ -+ -+ if (!__atomic_compare_exchange_n (&v, &expected, max, STRONG , __ATOMIC_RELAXED, __ATOMIC_RELAXED)) -+ abort (); -+ if (expected != 0) -+ abort (); -+ -+ if (__atomic_compare_exchange_n (&v, &expected, 0, STRONG , __ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) -+ abort (); -+ if (expected != max) -+ abort (); -+ -+ if (!__atomic_compare_exchange_n (&v, &expected, 0, STRONG , __ATOMIC_RELEASE, __ATOMIC_ACQUIRE)) -+ abort (); -+ if (expected != max) -+ abort (); -+ if (v != 0) -+ abort (); -+ -+ if (__atomic_compare_exchange_n (&v, &expected, desired, WEAK, __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE)) -+ abort (); -+ if (expected != 0) -+ abort (); -+ -+ if (!__atomic_compare_exchange_n (&v, &expected, desired, STRONG , __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) -+ abort (); -+ if (expected != 0) -+ abort (); -+ if (v != max) -+ abort (); -+ -+ /* Now test the generic version. */ -+ -+ v = 0; -+ -+ if (!__atomic_compare_exchange (&v, &expected, &max, STRONG, __ATOMIC_RELAXED, __ATOMIC_RELAXED)) -+ abort (); -+ if (expected != 0) -+ abort (); -+ -+ if (__atomic_compare_exchange (&v, &expected, &zero, STRONG , __ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) -+ abort (); -+ if (expected != max) -+ abort (); -+ -+ if (!__atomic_compare_exchange (&v, &expected, &zero, STRONG , __ATOMIC_RELEASE, __ATOMIC_ACQUIRE)) -+ abort (); -+ if (expected != max) -+ abort (); -+ if (v != 0) -+ abort (); -+ -+ if (__atomic_compare_exchange (&v, &expected, &desired, WEAK, __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE)) -+ abort (); -+ if (expected != 0) -+ abort (); -+ -+ if (!__atomic_compare_exchange (&v, &expected, &desired, STRONG , __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) -+ abort (); -+ if (expected != 0) -+ abort (); -+ if (v != max) -+ abort (); -+ -+ return 0; -+} ---- /dev/null -+++ b/gcc/testsuite/gcc.target/riscv/inline-atomics-6.c -@@ -0,0 +1,87 @@ -+/* Test __atomic routines for existence and proper execution on 2 byte -+ values with each valid memory model. */ -+/* Duplicate logic as libatomic/testsuite/libatomic.c/atomic-compare-exchange-2.c */ -+/* { dg-do run } */ -+/* { dg-options "-minline-atomics" } */ -+ -+/* Test the execution of the __atomic_compare_exchange_n builtin for a short. */ -+ -+extern void abort(void); -+ -+short v = 0; -+short expected = 0; -+short max = ~0; -+short desired = ~0; -+short zero = 0; -+ -+#define STRONG 0 -+#define WEAK 1 -+ -+int -+main () -+{ -+ -+ if (!__atomic_compare_exchange_n (&v, &expected, max, STRONG , __ATOMIC_RELAXED, __ATOMIC_RELAXED)) -+ abort (); -+ if (expected != 0) -+ abort (); -+ -+ if (__atomic_compare_exchange_n (&v, &expected, 0, STRONG , __ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) -+ abort (); -+ if (expected != max) -+ abort (); -+ -+ if (!__atomic_compare_exchange_n (&v, &expected, 0, STRONG , __ATOMIC_RELEASE, __ATOMIC_ACQUIRE)) -+ abort (); -+ if (expected != max) -+ abort (); -+ if (v != 0) -+ abort (); -+ -+ if (__atomic_compare_exchange_n (&v, &expected, desired, WEAK, __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE)) -+ abort (); -+ if (expected != 0) -+ abort (); -+ -+ if (!__atomic_compare_exchange_n (&v, &expected, desired, STRONG , __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) -+ abort (); -+ if (expected != 0) -+ abort (); -+ if (v != max) -+ abort (); -+ -+ /* Now test the generic version. */ -+ -+ v = 0; -+ -+ if (!__atomic_compare_exchange (&v, &expected, &max, STRONG, __ATOMIC_RELAXED, __ATOMIC_RELAXED)) -+ abort (); -+ if (expected != 0) -+ abort (); -+ -+ if (__atomic_compare_exchange (&v, &expected, &zero, STRONG , __ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) -+ abort (); -+ if (expected != max) -+ abort (); -+ -+ if (!__atomic_compare_exchange (&v, &expected, &zero, STRONG , __ATOMIC_RELEASE, __ATOMIC_ACQUIRE)) -+ abort (); -+ if (expected != max) -+ abort (); -+ if (v != 0) -+ abort (); -+ -+ if (__atomic_compare_exchange (&v, &expected, &desired, WEAK, __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE)) -+ abort (); -+ if (expected != 0) -+ abort (); -+ -+ if (!__atomic_compare_exchange (&v, &expected, &desired, STRONG , __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) -+ abort (); -+ if (expected != 0) -+ abort (); -+ if (v != max) -+ abort (); -+ -+ return 0; -+} ---- /dev/null -+++ b/gcc/testsuite/gcc.target/riscv/inline-atomics-7.c -@@ -0,0 +1,69 @@ -+/* Test __atomic routines for existence and proper execution on 1 byte -+ values with each valid memory model. */ -+/* Duplicate logic as libatomic/testsuite/libatomic.c/atomic-exchange-1.c */ -+/* { dg-do run } */ -+/* { dg-options "-minline-atomics" } */ -+ -+/* Test the execution of the __atomic_exchange_n builtin for a char. */ -+ -+extern void abort(void); -+ -+char v, count, ret; -+ -+int -+main () -+{ -+ v = 0; -+ count = 0; -+ -+ if (__atomic_exchange_n (&v, count + 1, __ATOMIC_RELAXED) != count) -+ abort (); -+ count++; -+ -+ if (__atomic_exchange_n (&v, count + 1, __ATOMIC_ACQUIRE) != count) -+ abort (); -+ count++; -+ -+ if (__atomic_exchange_n (&v, count + 1, __ATOMIC_RELEASE) != count) -+ abort (); -+ count++; -+ -+ if (__atomic_exchange_n (&v, count + 1, __ATOMIC_ACQ_REL) != count) -+ abort (); -+ count++; -+ -+ if (__atomic_exchange_n (&v, count + 1, __ATOMIC_SEQ_CST) != count) -+ abort (); -+ count++; -+ -+ /* Now test the generic version. */ -+ -+ count++; -+ -+ __atomic_exchange (&v, &count, &ret, __ATOMIC_RELAXED); -+ if (ret != count - 1 || v != count) -+ abort (); -+ count++; -+ -+ __atomic_exchange (&v, &count, &ret, __ATOMIC_ACQUIRE); -+ if (ret != count - 1 || v != count) -+ abort (); -+ count++; -+ -+ __atomic_exchange (&v, &count, &ret, __ATOMIC_RELEASE); -+ if (ret != count - 1 || v != count) -+ abort (); -+ count++; -+ -+ __atomic_exchange (&v, &count, &ret, __ATOMIC_ACQ_REL); -+ if (ret != count - 1 || v != count) -+ abort (); -+ count++; -+ -+ __atomic_exchange (&v, &count, &ret, __ATOMIC_SEQ_CST); -+ if (ret != count - 1 || v != count) -+ abort (); -+ count++; -+ -+ return 0; -+} ---- /dev/null -+++ b/gcc/testsuite/gcc.target/riscv/inline-atomics-8.c -@@ -0,0 +1,69 @@ -+/* Test __atomic routines for existence and proper execution on 2 byte -+ values with each valid memory model. */ -+/* Duplicate logic as libatomic/testsuite/libatomic.c/atomic-exchange-2.c */ -+/* { dg-do run } */ -+/* { dg-options "-minline-atomics" } */ -+ -+/* Test the execution of the __atomic_X builtin for a short. */ -+ -+extern void abort(void); -+ -+short v, count, ret; -+ -+int -+main () -+{ -+ v = 0; -+ count = 0; -+ -+ if (__atomic_exchange_n (&v, count + 1, __ATOMIC_RELAXED) != count) -+ abort (); -+ count++; -+ -+ if (__atomic_exchange_n (&v, count + 1, __ATOMIC_ACQUIRE) != count) -+ abort (); -+ count++; -+ -+ if (__atomic_exchange_n (&v, count + 1, __ATOMIC_RELEASE) != count) -+ abort (); -+ count++; -+ -+ if (__atomic_exchange_n (&v, count + 1, __ATOMIC_ACQ_REL) != count) -+ abort (); -+ count++; -+ -+ if (__atomic_exchange_n (&v, count + 1, __ATOMIC_SEQ_CST) != count) -+ abort (); -+ count++; -+ -+ /* Now test the generic version. */ -+ -+ count++; -+ -+ __atomic_exchange (&v, &count, &ret, __ATOMIC_RELAXED); -+ if (ret != count - 1 || v != count) -+ abort (); -+ count++; -+ -+ __atomic_exchange (&v, &count, &ret, __ATOMIC_ACQUIRE); -+ if (ret != count - 1 || v != count) -+ abort (); -+ count++; -+ -+ __atomic_exchange (&v, &count, &ret, __ATOMIC_RELEASE); -+ if (ret != count - 1 || v != count) -+ abort (); -+ count++; -+ -+ __atomic_exchange (&v, &count, &ret, __ATOMIC_ACQ_REL); -+ if (ret != count - 1 || v != count) -+ abort (); -+ count++; -+ -+ __atomic_exchange (&v, &count, &ret, __ATOMIC_SEQ_CST); -+ if (ret != count - 1 || v != count) -+ abort (); -+ count++; -+ -+ return 0; -+} ---- a/libgcc/config/riscv/atomic.c -+++ b/libgcc/config/riscv/atomic.c -@@ -30,6 +30,8 @@ see the files COPYING3 and COPYING.RUNTI - #define INVERT "not %[tmp1], %[tmp1]\n\t" - #define DONT_INVERT "" - -+/* Logic duplicated in gcc/gcc/config/riscv/sync.md for use when inlining is enabled */ -+ - #define GENERATE_FETCH_AND_OP(type, size, opname, insn, invert, cop) \ - type __sync_fetch_and_ ## opname ## _ ## size (type *p, type v) \ - { \ diff --git a/toolchain/gcc/patches-13.x/701-riscv-linux-Don-t-add-latomic-with-pthread.patch b/toolchain/gcc/patches-13.x/701-riscv-linux-Don-t-add-latomic-with-pthread.patch deleted file mode 100644 index 328c7be9ce8..00000000000 --- a/toolchain/gcc/patches-13.x/701-riscv-linux-Don-t-add-latomic-with-pthread.patch +++ /dev/null @@ -1,36 +0,0 @@ -From 203f3060dd363361b172f7295f42bb6bf5ac0b3b Mon Sep 17 00:00:00 2001 -From: Andreas Schwab -Date: Sat, 23 Apr 2022 15:48:42 +0200 -Subject: [PATCH] riscv/linux: Don't add -latomic with -pthread - -Now that we have support for inline subword atomic operations, it is no -longer necessary to link against libatomic. This also fixes testsuite -failures because the framework does not properly set up the linker flags -for finding libatomic. -The use of atomic operations is also independent of the use of libpthread. - -gcc/ - * config/riscv/linux.h (LIB_SPEC): Don't redefine. ---- - gcc/config/riscv/linux.h | 10 ---------- - 1 file changed, 10 deletions(-) - ---- a/gcc/config/riscv/linux.h -+++ b/gcc/config/riscv/linux.h -@@ -35,16 +35,6 @@ along with GCC; see the file COPYING3. - #undef MUSL_DYNAMIC_LINKER - #define MUSL_DYNAMIC_LINKER "/lib/ld-musl-riscv" XLEN_SPEC MUSL_ABI_SUFFIX ".so.1" - --/* Because RISC-V only has word-sized atomics, it requries libatomic where -- others do not. So link libatomic by default, as needed. */ --#undef LIB_SPEC --#ifdef LD_AS_NEEDED_OPTION --#define LIB_SPEC GNU_USER_TARGET_LIB_SPEC \ -- " %{pthread:" LD_AS_NEEDED_OPTION " -latomic " LD_NO_AS_NEEDED_OPTION "}" --#else --#define LIB_SPEC GNU_USER_TARGET_LIB_SPEC " -latomic " --#endif -- - #define ICACHE_FLUSH_FUNC "__riscv_flush_icache" - - #define CPP_SPEC "%{pthread:-D_REENTRANT}" diff --git a/toolchain/gcc/patches-13.x/910-mbsd_multi.patch b/toolchain/gcc/patches-13.x/910-mbsd_multi.patch index 8af05c99946..4138e79bcc8 100644 --- a/toolchain/gcc/patches-13.x/910-mbsd_multi.patch +++ b/toolchain/gcc/patches-13.x/910-mbsd_multi.patch @@ -114,7 +114,7 @@ Date: Tue Jul 31 00:52:27 2007 +0000 ; On SVR4 targets, it also controls whether or not to emit a --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi -@@ -10062,6 +10062,17 @@ This option is only supported for C and +@@ -10065,6 +10065,17 @@ This option is only supported for C and @option{-Wall} and by @option{-Wpedantic}, which can be disabled with @option{-Wno-pointer-sign}.