From 42a15ca378e1bc52f125f894d748c31ce3c52903 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sun, 17 Apr 2022 21:00:03 +0200 Subject: [PATCH 01/23] OpenWrt v21.02.3: adjust config defaults Signed-off-by: Hauke Mehrtens --- feeds.conf.default | 9 ++++----- include/version.mk | 6 +++--- package/base-files/image-config.in | 4 ++-- version | 1 + version.date | 1 + 5 files changed, 11 insertions(+), 10 deletions(-) create mode 100644 version create mode 100644 version.date diff --git a/feeds.conf.default b/feeds.conf.default index 98bf97232d..4af2c73925 100644 --- a/feeds.conf.default +++ b/feeds.conf.default @@ -1,5 +1,4 @@ -src-git packages https://git.openwrt.org/feed/packages.git;openwrt-21.02 -src-git luci https://git.openwrt.org/project/luci.git;openwrt-21.02 -src-git routing https://git.openwrt.org/feed/routing.git;openwrt-21.02 -src-git telephony https://git.openwrt.org/feed/telephony.git;openwrt-21.02 -#src-link custom /usr/src/openwrt/custom-feed +src-git packages https://git.openwrt.org/feed/packages.git^78bcd00c13587571b5c79ed2fc3363aa674aaef7 +src-git luci https://git.openwrt.org/project/luci.git^fe09ab990256d8b63e76cc1ab2435baef921b8b4 +src-git routing https://git.openwrt.org/feed/routing.git^a0d61bddb3ce4ca54bd76af86c28f58feb6cc044 +src-git telephony https://git.openwrt.org/feed/telephony.git^0183c1adda0e7581698b0ea4bff7c08379acf447 diff --git a/include/version.mk b/include/version.mk index a4b47c8a57..578d69d7ab 100644 --- a/include/version.mk +++ b/include/version.mk @@ -23,13 +23,13 @@ PKG_CONFIG_DEPENDS += \ sanitize = $(call tolower,$(subst _,-,$(subst $(space),-,$(1)))) VERSION_NUMBER:=$(call qstrip,$(CONFIG_VERSION_NUMBER)) -VERSION_NUMBER:=$(if $(VERSION_NUMBER),$(VERSION_NUMBER),21.02-SNAPSHOT) +VERSION_NUMBER:=$(if $(VERSION_NUMBER),$(VERSION_NUMBER),21.02.3) VERSION_CODE:=$(call qstrip,$(CONFIG_VERSION_CODE)) -VERSION_CODE:=$(if $(VERSION_CODE),$(VERSION_CODE),$(REVISION)) +VERSION_CODE:=$(if $(VERSION_CODE),$(VERSION_CODE),r16554-1d4dea6d4f) VERSION_REPO:=$(call qstrip,$(CONFIG_VERSION_REPO)) -VERSION_REPO:=$(if $(VERSION_REPO),$(VERSION_REPO),https://downloads.openwrt.org/releases/21.02-SNAPSHOT) +VERSION_REPO:=$(if $(VERSION_REPO),$(VERSION_REPO),https://downloads.openwrt.org/releases/21.02.3) VERSION_DIST:=$(call qstrip,$(CONFIG_VERSION_DIST)) VERSION_DIST:=$(if $(VERSION_DIST),$(VERSION_DIST),OpenWrt) diff --git a/package/base-files/image-config.in b/package/base-files/image-config.in index 1f06332b00..ea4e33481e 100644 --- a/package/base-files/image-config.in +++ b/package/base-files/image-config.in @@ -183,7 +183,7 @@ if VERSIONOPT config VERSION_REPO string prompt "Release repository" - default "https://downloads.openwrt.org/releases/21.02-SNAPSHOT" + default "https://downloads.openwrt.org/releases/21.02.3" help This is the repository address embedded in the image, it defaults to the trunk snapshot repo; the url may contain the following placeholders: @@ -259,7 +259,7 @@ if VERSIONOPT config VERSION_CODE_FILENAMES bool prompt "Revision code in filenames" - default y + default n help Enable this to include the revision identifier or the configured version code into the firmware image, SDK- and Image Builder archive diff --git a/version b/version new file mode 100644 index 0000000000..ff3d8f5cf6 --- /dev/null +++ b/version @@ -0,0 +1 @@ +r16554-1d4dea6d4f diff --git a/version.date b/version.date new file mode 100644 index 0000000000..a0f398bc6d --- /dev/null +++ b/version.date @@ -0,0 +1 @@ +1650113974 From f0f9b7ac5c067102136885a58bca867adffa488c Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sun, 17 Apr 2022 21:00:07 +0200 Subject: [PATCH 02/23] OpenWrt v21.02.3: revert to branch defaults Signed-off-by: Hauke Mehrtens --- feeds.conf.default | 9 +++++---- include/version.mk | 6 +++--- package/base-files/image-config.in | 4 ++-- version | 1 - version.date | 1 - 5 files changed, 10 insertions(+), 11 deletions(-) delete mode 100644 version delete mode 100644 version.date diff --git a/feeds.conf.default b/feeds.conf.default index 4af2c73925..98bf97232d 100644 --- a/feeds.conf.default +++ b/feeds.conf.default @@ -1,4 +1,5 @@ -src-git packages https://git.openwrt.org/feed/packages.git^78bcd00c13587571b5c79ed2fc3363aa674aaef7 -src-git luci https://git.openwrt.org/project/luci.git^fe09ab990256d8b63e76cc1ab2435baef921b8b4 -src-git routing https://git.openwrt.org/feed/routing.git^a0d61bddb3ce4ca54bd76af86c28f58feb6cc044 -src-git telephony https://git.openwrt.org/feed/telephony.git^0183c1adda0e7581698b0ea4bff7c08379acf447 +src-git packages https://git.openwrt.org/feed/packages.git;openwrt-21.02 +src-git luci https://git.openwrt.org/project/luci.git;openwrt-21.02 +src-git routing https://git.openwrt.org/feed/routing.git;openwrt-21.02 +src-git telephony https://git.openwrt.org/feed/telephony.git;openwrt-21.02 +#src-link custom /usr/src/openwrt/custom-feed diff --git a/include/version.mk b/include/version.mk index 578d69d7ab..a4b47c8a57 100644 --- a/include/version.mk +++ b/include/version.mk @@ -23,13 +23,13 @@ PKG_CONFIG_DEPENDS += \ sanitize = $(call tolower,$(subst _,-,$(subst $(space),-,$(1)))) VERSION_NUMBER:=$(call qstrip,$(CONFIG_VERSION_NUMBER)) -VERSION_NUMBER:=$(if $(VERSION_NUMBER),$(VERSION_NUMBER),21.02.3) +VERSION_NUMBER:=$(if $(VERSION_NUMBER),$(VERSION_NUMBER),21.02-SNAPSHOT) VERSION_CODE:=$(call qstrip,$(CONFIG_VERSION_CODE)) -VERSION_CODE:=$(if $(VERSION_CODE),$(VERSION_CODE),r16554-1d4dea6d4f) +VERSION_CODE:=$(if $(VERSION_CODE),$(VERSION_CODE),$(REVISION)) VERSION_REPO:=$(call qstrip,$(CONFIG_VERSION_REPO)) -VERSION_REPO:=$(if $(VERSION_REPO),$(VERSION_REPO),https://downloads.openwrt.org/releases/21.02.3) +VERSION_REPO:=$(if $(VERSION_REPO),$(VERSION_REPO),https://downloads.openwrt.org/releases/21.02-SNAPSHOT) VERSION_DIST:=$(call qstrip,$(CONFIG_VERSION_DIST)) VERSION_DIST:=$(if $(VERSION_DIST),$(VERSION_DIST),OpenWrt) diff --git a/package/base-files/image-config.in b/package/base-files/image-config.in index ea4e33481e..1f06332b00 100644 --- a/package/base-files/image-config.in +++ b/package/base-files/image-config.in @@ -183,7 +183,7 @@ if VERSIONOPT config VERSION_REPO string prompt "Release repository" - default "https://downloads.openwrt.org/releases/21.02.3" + default "https://downloads.openwrt.org/releases/21.02-SNAPSHOT" help This is the repository address embedded in the image, it defaults to the trunk snapshot repo; the url may contain the following placeholders: @@ -259,7 +259,7 @@ if VERSIONOPT config VERSION_CODE_FILENAMES bool prompt "Revision code in filenames" - default n + default y help Enable this to include the revision identifier or the configured version code into the firmware image, SDK- and Image Builder archive diff --git a/version b/version deleted file mode 100644 index ff3d8f5cf6..0000000000 --- a/version +++ /dev/null @@ -1 +0,0 @@ -r16554-1d4dea6d4f diff --git a/version.date b/version.date deleted file mode 100644 index a0f398bc6d..0000000000 --- a/version.date +++ /dev/null @@ -1 +0,0 @@ -1650113974 From 6c44b157e537fc3a3c2aa4732218a5341fd43387 Mon Sep 17 00:00:00 2001 From: Josef Schlehofer Date: Thu, 18 Nov 2021 16:37:17 +0100 Subject: [PATCH 03/23] mvebu: kernel: enable CONFIG_BLK_DEV_NVME CONFIG_BLK_DEV_NVME [1]: - This is a kernel driver for SSD connected to PCI or PCIe bus [1]. By default, it is enabled for targets "ipq807x", "rockchip/armv8" and "x86/64". With miniPCIe adapter, there is a possibility to connect NVMe disk to Turris Omnia (cortex-a9), Turris MOX (cortex-a53). It allows to boot system from NVMe disk, because of that it can not be kmod package as you can not access the disk to be able to boot from it. CONFIG_NVME_CORE [2]: - This is selected by CONFIG_BLK_DEV_NVME It does not need to be explicitly enabled, but it is done for "ipq807", "x64_64" and rockchip/armv8", which has also enabled the previous config option as well. Kernel increase: ~28k KiB on mamba kernel Reference: [1] https://cateee.net/lkddb/web-lkddb/BLK_DEV_NVME.html [2] https://cateee.net/lkddb/web-lkddb/NVME_CORE.html Signed-off-by: Josef Schlehofer (cherry picked from commit 9d530ac4bf6b9804a06dbf5df4631ee86f1304c1) [rebased for config-5.4] --- target/linux/mvebu/config-5.4 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/target/linux/mvebu/config-5.4 b/target/linux/mvebu/config-5.4 index ea73bafe23..742ae29e0b 100644 --- a/target/linux/mvebu/config-5.4 +++ b/target/linux/mvebu/config-5.4 @@ -75,6 +75,7 @@ CONFIG_ATAGS=y CONFIG_AUTO_ZRELADDR=y CONFIG_BINFMT_FLAT_ARGVP_ENVP_ON_STACK=y CONFIG_BLK_DEV_LOOP=y +CONFIG_BLK_DEV_NVME=y CONFIG_BLK_DEV_SD=y CONFIG_BLK_MQ_PCI=y CONFIG_BLK_SCSI_REQUEST=y @@ -361,6 +362,10 @@ CONFIG_NLS=y CONFIG_NOP_USB_XCEIV=y CONFIG_NR_CPUS=4 CONFIG_NVMEM=y +CONFIG_NVME_CORE=y +# CONFIG_NVME_HWMON is not set +# CONFIG_NVME_MULTIPATH is not set +# CONFIG_NVME_TCP is not set CONFIG_OF=y CONFIG_OF_ADDRESS=y CONFIG_OF_EARLY_FLATTREE=y From bea18911826d04b70996335dfaa9874c9f813544 Mon Sep 17 00:00:00 2001 From: DENG Qingfang Date: Tue, 2 Feb 2021 16:10:32 +0800 Subject: [PATCH 04/23] ramips: remove obsolete mx25l25635f compatible hack The kernel bump to 5.4 has removed the mx25l25635f hack, and the mx25l25635f compatible is no longer required. Signed-off-by: DENG Qingfang (cherry picked from commit 06af45ec0502d5cb0529ac46fcb34c4c63394723) --- target/linux/ramips/dts/mt7620a_youku_yk1.dts | 2 +- target/linux/ramips/dts/mt7621_glinet_gl-mt1300.dts | 2 +- target/linux/ramips/dts/mt7621_ubnt_unifi-6-lite.dts | 2 +- target/linux/ramips/dts/mt7621_ubnt_unifi-nanohd.dts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/target/linux/ramips/dts/mt7620a_youku_yk1.dts b/target/linux/ramips/dts/mt7620a_youku_yk1.dts index 61da408f27..d44c9a0dad 100644 --- a/target/linux/ramips/dts/mt7620a_youku_yk1.dts +++ b/target/linux/ramips/dts/mt7620a_youku_yk1.dts @@ -68,7 +68,7 @@ status = "okay"; flash@0 { - compatible = "mx25l25635f", "jedec,spi-nor"; + compatible = "jedec,spi-nor"; reg = <0>; spi-max-frequency = <25000000>; m25p,fast-read; diff --git a/target/linux/ramips/dts/mt7621_glinet_gl-mt1300.dts b/target/linux/ramips/dts/mt7621_glinet_gl-mt1300.dts index a0fd3786ff..e805454bf6 100644 --- a/target/linux/ramips/dts/mt7621_glinet_gl-mt1300.dts +++ b/target/linux/ramips/dts/mt7621_glinet_gl-mt1300.dts @@ -65,7 +65,7 @@ status = "okay"; flash@0 { - compatible = "mx25l25635f", "jedec,spi-nor"; + compatible = "jedec,spi-nor"; reg = <0>; spi-max-frequency = <80000000>; m25p,fast-read; diff --git a/target/linux/ramips/dts/mt7621_ubnt_unifi-6-lite.dts b/target/linux/ramips/dts/mt7621_ubnt_unifi-6-lite.dts index f5425ccfee..d374fd3dde 100644 --- a/target/linux/ramips/dts/mt7621_ubnt_unifi-6-lite.dts +++ b/target/linux/ramips/dts/mt7621_ubnt_unifi-6-lite.dts @@ -15,7 +15,7 @@ status = "okay"; flash@0 { - compatible = "mx25l25635f", "jedec,spi-nor"; + compatible = "jedec,spi-nor"; reg = <0>; spi-max-frequency = <50000000>; diff --git a/target/linux/ramips/dts/mt7621_ubnt_unifi-nanohd.dts b/target/linux/ramips/dts/mt7621_ubnt_unifi-nanohd.dts index 401868362e..7a36ecfa7b 100644 --- a/target/linux/ramips/dts/mt7621_ubnt_unifi-nanohd.dts +++ b/target/linux/ramips/dts/mt7621_ubnt_unifi-nanohd.dts @@ -11,7 +11,7 @@ status = "okay"; flash@0 { - compatible = "mx25l25635f", "jedec,spi-nor"; + compatible = "jedec,spi-nor"; reg = <0>; spi-max-frequency = <50000000>; From 92489b4f828e21cffae977ea77daefec73753e5c Mon Sep 17 00:00:00 2001 From: Shiji Yang Date: Sun, 21 Mar 2021 22:43:59 +0800 Subject: [PATCH 05/23] ramips: speed up spi frequency for Youku YK-L1 Youku YK-L1 has a huge storage space up to 32 MB. It is better to use a higher spi clock to read or write serial nor flash chips. Youku YK-L1 has Winbond w25q256fvfg on board that can support 104 MHz spi clock so 48 MHz is safe enough. The real frequency can only be sysclk(580MHz ) /3 /(2^n) so 80 MHz defined in dts file will set only 48 MHz in spi bus. Signed-off-by: Shiji Yang (cherry picked from commit bf7ddb18f1bfa0b61b4dc43732c114f20900bd4b) --- target/linux/ramips/dts/mt7620a_youku_yk1.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/linux/ramips/dts/mt7620a_youku_yk1.dts b/target/linux/ramips/dts/mt7620a_youku_yk1.dts index d44c9a0dad..721b51db75 100644 --- a/target/linux/ramips/dts/mt7620a_youku_yk1.dts +++ b/target/linux/ramips/dts/mt7620a_youku_yk1.dts @@ -70,7 +70,7 @@ flash@0 { compatible = "jedec,spi-nor"; reg = <0>; - spi-max-frequency = <25000000>; + spi-max-frequency = <80000000>; m25p,fast-read; partitions { From 55f8eb84d2e4a52186a9c6fa4ec67cf60fcb2977 Mon Sep 17 00:00:00 2001 From: Shiji Yang Date: Sun, 4 Apr 2021 11:55:41 +0800 Subject: [PATCH 06/23] ramips: improve pinctrl for Youku YK-L1 1. rename led pin "air" to a more common name "wlan" and use "phy0tpt" to trigger it. 2. led "wan" can be triggered by ethernet pinctrl by default so just drop it. Signed-off-by: Shiji Yang (cherry picked from commit 882a6116d3d6394dd109350287067accebbf6114) --- target/linux/ramips/dts/mt7620a_youku_yk1.dts | 16 ++++------------ .../ramips/mt7620/base-files/etc/board.d/01_leds | 4 ---- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/target/linux/ramips/dts/mt7620a_youku_yk1.dts b/target/linux/ramips/dts/mt7620a_youku_yk1.dts index 721b51db75..2e59e5bf6e 100644 --- a/target/linux/ramips/dts/mt7620a_youku_yk1.dts +++ b/target/linux/ramips/dts/mt7620a_youku_yk1.dts @@ -18,14 +18,10 @@ leds { compatible = "gpio-leds"; - wan { - label = "blue:wan"; - gpios = <&gpio2 4 GPIO_ACTIVE_LOW>; - }; - - air { - label = "blue:air"; + wlan { + label = "blue:wlan"; gpios = <&gpio3 0 GPIO_ACTIVE_LOW>; + linux,default-trigger = "phy0tpt"; }; usb { @@ -56,10 +52,6 @@ status = "okay"; }; -&gpio2 { - status = "okay"; -}; - &gpio3 { status = "okay"; }; @@ -107,7 +99,7 @@ &state_default { default { - groups = "i2c", "rgmii1", "ephy", "wled"; + groups = "i2c", "rgmii1", "wled"; function = "gpio"; }; }; diff --git a/target/linux/ramips/mt7620/base-files/etc/board.d/01_leds b/target/linux/ramips/mt7620/base-files/etc/board.d/01_leds index 292f310d51..7c18b73a9a 100755 --- a/target/linux/ramips/mt7620/base-files/etc/board.d/01_leds +++ b/target/linux/ramips/mt7620/base-files/etc/board.d/01_leds @@ -195,10 +195,6 @@ tplink,archer-mr200) tplink,re200-v1) ucidef_set_led_netdev "lan" "lan" "green:lan" "eth0" ;; -youku,yk1) - ucidef_set_led_switch "wan" "wan" "blue:wan" "switch0" "0x10" - ucidef_set_led_netdev "wifi_led" "wifi" "blue:air" "wlan0" - ;; zbtlink,zbt-ape522ii) ucidef_set_led_netdev "wlan2g4" "wlan1-link" "green:wlan2g4" "wlan1" ucidef_set_led_netdev "sys1" "wlan1" "green:sys1" "wlan1" "tx rx" From 92af15077f37af561ca31e22d7c9bdc2096cc10c Mon Sep 17 00:00:00 2001 From: Shiji Yang Date: Sun, 16 May 2021 21:21:09 +0800 Subject: [PATCH 07/23] ramips: split Youku YK1 to YK-L1 and YK-L1c Device specifications: * Model: Youku YK-L1/L1c * CPU: MT7620A * RAM: 128 MiB * Flash: 32 MiB (YK-L1)/ 16 MiB (YK-L1c) * LAN: 2* 10M/100M Ports * WAN: 1* 10M/100M Port * USB: 1* USB2.0 * SD: 1* MicroSD socket * UART: 1* TTL, Baudrate 57600 Descriptions: Previous supported device YOUKU yk1 is actually Youku YK-L1. Though they look really different, the only hardware difference between the two models is flash size, YK-L1 has 32 MiB flash but YK-L1c has 16MiB. It seems that YK-L1c can compatible with YK-L1's firmware but it's better to split it to different models. It is easy to identify the models by looking at the label on the bottom of the device. The label has the model number "YK-L1" or "YK-L1c". Due to different flash sizes, YK-L1c that using previous YK-L1's firmware needs to apply "force update" to install compatible firmware, so please backup config file before system upgrade. Signed-off-by: Shiji Yang [use more specific name for DTSI] Signed-off-by: Adrian Schmutzler (cherry picked from commit 4a9f389ed2dcee18a5c5e1f0d4e5c406f9290579) --- .../linux/ramips/dts/mt7620a_youku_yk-l1.dts | 12 +++++++++++ ...youku_yk1.dts => mt7620a_youku_yk-l1.dtsi} | 7 ++----- .../linux/ramips/dts/mt7620a_youku_yk-l1c.dts | 12 +++++++++++ target/linux/ramips/image/mt7620.mk | 20 ++++++++++++++----- .../mt7620/base-files/etc/board.d/02_network | 6 ++++-- 5 files changed, 45 insertions(+), 12 deletions(-) create mode 100644 target/linux/ramips/dts/mt7620a_youku_yk-l1.dts rename target/linux/ramips/dts/{mt7620a_youku_yk1.dts => mt7620a_youku_yk-l1.dtsi} (93%) create mode 100644 target/linux/ramips/dts/mt7620a_youku_yk-l1c.dts diff --git a/target/linux/ramips/dts/mt7620a_youku_yk-l1.dts b/target/linux/ramips/dts/mt7620a_youku_yk-l1.dts new file mode 100644 index 0000000000..5155318b0c --- /dev/null +++ b/target/linux/ramips/dts/mt7620a_youku_yk-l1.dts @@ -0,0 +1,12 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "mt7620a_youku_yk-l1.dtsi" + +/ { + compatible = "youku,yk-l1", "ralink,mt7620a-soc"; + model = "Youku YK-L1"; +}; + +&firmware { + reg = <0x50000 0x1fb0000>; +}; diff --git a/target/linux/ramips/dts/mt7620a_youku_yk1.dts b/target/linux/ramips/dts/mt7620a_youku_yk-l1.dtsi similarity index 93% rename from target/linux/ramips/dts/mt7620a_youku_yk1.dts rename to target/linux/ramips/dts/mt7620a_youku_yk-l1.dtsi index 2e59e5bf6e..61062a3179 100644 --- a/target/linux/ramips/dts/mt7620a_youku_yk1.dts +++ b/target/linux/ramips/dts/mt7620a_youku_yk-l1.dtsi @@ -4,9 +4,6 @@ #include / { - compatible = "youku,yk1", "ralink,mt7620a-soc"; - model = "YOUKU YK1"; - aliases { led-boot = &led_power; led-failsafe = &led_power; @@ -88,10 +85,10 @@ read-only; }; - partition@50000 { + firmware: partition@50000 { compatible = "denx,uimage"; label = "firmware"; - reg = <0x50000 0x1fb0000>; + /* reg property is set based on flash size in DTS files */ }; }; }; diff --git a/target/linux/ramips/dts/mt7620a_youku_yk-l1c.dts b/target/linux/ramips/dts/mt7620a_youku_yk-l1c.dts new file mode 100644 index 0000000000..c59f0101bd --- /dev/null +++ b/target/linux/ramips/dts/mt7620a_youku_yk-l1c.dts @@ -0,0 +1,12 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "mt7620a_youku_yk-l1.dtsi" + +/ { + compatible = "youku,yk-l1c", "ralink,mt7620a-soc"; + model = "Youku YK-L1c"; +}; + +&firmware { + reg = <0x50000 0xfb0000>; +}; diff --git a/target/linux/ramips/image/mt7620.mk b/target/linux/ramips/image/mt7620.mk index 56941f2b9c..4f85b82c0e 100644 --- a/target/linux/ramips/image/mt7620.mk +++ b/target/linux/ramips/image/mt7620.mk @@ -1113,16 +1113,26 @@ define Device/xiaomi_miwifi-mini endef TARGET_DEVICES += xiaomi_miwifi-mini -define Device/youku_yk1 +define Device/youku_yk-l1 SOC := mt7620a IMAGE_SIZE := 32448k - DEVICE_VENDOR := YOUKU - DEVICE_MODEL := YK1 + DEVICE_VENDOR := Youku + DEVICE_MODEL := YK-L1 DEVICE_PACKAGES := kmod-usb2 kmod-usb-ohci kmod-sdhci-mt7620 \ kmod-usb-ledtrig-usbport - SUPPORTED_DEVICES += youku-yk1 + SUPPORTED_DEVICES += youku-yk1 youku,yk1 endef -TARGET_DEVICES += youku_yk1 +TARGET_DEVICES += youku_yk-l1 + +define Device/youku_yk-l1c + SOC := mt7620a + IMAGE_SIZE := 16064k + DEVICE_VENDOR := Youku + DEVICE_MODEL := YK-L1c + DEVICE_PACKAGES := kmod-usb2 kmod-usb-ohci kmod-sdhci-mt7620 \ + kmod-usb-ledtrig-usbport +endef +TARGET_DEVICES += youku_yk-l1c define Device/yukai_bocco SOC := mt7620a diff --git a/target/linux/ramips/mt7620/base-files/etc/board.d/02_network b/target/linux/ramips/mt7620/base-files/etc/board.d/02_network index 919102b130..4fd2455f5c 100755 --- a/target/linux/ramips/mt7620/base-files/etc/board.d/02_network +++ b/target/linux/ramips/mt7620/base-files/etc/board.d/02_network @@ -216,7 +216,8 @@ ramips_setup_interfaces() ucidef_add_switch "switch0" \ "0:lan" "4:wan" "6@eth0" ;; - youku,yk1) + youku,yk-l1|\ + youku,yk-l1c) ucidef_add_switch "switch0" \ "0:lan" "1:lan" "4:wan" "6@eth0" ;; @@ -339,7 +340,8 @@ ramips_setup_macs() lenovo,newifi-y1s|\ ohyeah,oy-0001|\ wavlink,wl-wn530hg4|\ - youku,yk1) + youku,yk-l1|\ + youku,yk-l1c) wan_mac=$(mtd_get_mac_binary factory 0x2e) ;; linksys,e1700) From 4123f177f969f6510c4bf92b37f66c55e94bd0ef Mon Sep 17 00:00:00 2001 From: Ben Gainey Date: Sun, 31 Jan 2021 11:15:38 +0000 Subject: [PATCH 08/23] ramips: add support for the Wavlink WL-WN579X3 About the device ---------------- SoC: MediaTek MT7620a @ 580MHz RAM: 64M FLASH: 8MB WiFi: SoC-integrated: MediaTek MT7620a bgn WiFi: MediaTek MT7612EN nac GbE: 2x (RTL8211F) BTN: - WPS - Reset - Router/Repeater/AP (3-way slide-switch) LED: - WPS (blue) - 3-segment Wifi signal representation (blue) - WiFi (blue) - WAN (blue) - LAN (blue) - Power (blue) UART: UART is present as Pads with through-holes on the PCB. They are located next to the reset button and are labelled Vcc/TX/RX/GND as appropriate. Use 3.3V, 57600-8N1. Installation ------------ Using the webcmd interface -------------------------- Warning: Do not update to the latest Wavlink firmware (version 20201201) as this removes the webcmd console and you will need to use the serial port instead. You will need to have built uboot/sqauashfs image for this device, and you will need to provide an HTTP service where the image can be downloaded from that is accessible by the device. You cannot use the device manufacturers firmware upgrade interface as it rejects the OpenWrt image. 1. Log into the device's admin portal. This is necessary to authenticate you as a user in order to be able to access the webcmd interface. 2. Navigate to http:///webcmd.shtml - you can access the console directly through this page, or you may wish to launch the installed `telnetd` and use telnet instead. * Using telnet is recommended since it provides a more convenient shell interface that the web form. * Launch telnetd from the form with the command `telnetd`. * Check the port that telnetd is running on using `netstat -antp|grep telnetd`, it is likely to be 2323. * Connect to the target using `telnet`. The username should be `admin2860`, and the password is your admin password. 3. On the target use `curl` to download the image. e.g. `curl -L -O http:///openwrt-ramips-mt7620-\ wavlink_wl-wn579x3-squashfs-sysupgrade.bin`. Check the hash using `md5sum`. 4. Use the mtd_write command to flash the image. * The flash partition should be mtd4, but check /sys/class/mtd/mtd4/name first. The partition should be called 'Kernel'. * To flash use the following command: `mtd_write -r -e /dev/mtd write /dev/mtd` Where mtd is the Kernel partition, and is the OpenWrt image previously downloaded. * The command above will erase, flash and then reboot the device. Once it reboots it will be running OpenWrt. Connect via ssh to the device at 192.168.1.1 on the LAN port. The WAN port will be configured via DHCP. Using the serial port --------------------- The device uses uboot like many other MT7260a based boards. To use this interface, you will need to connect to the serial interface, and provide a TFTP server. At boot follow the bootloader menu and select option 2 to erase/flash the image. Provide the address and filename details for the tftp server. The bootloader will do the rest. Once the image is flashed, the board will boot into OpenWrt. The console is available over the serial port. Signed-off-by: Ben Gainey (cherry picked from commit a509b80065b6680e3e007203084c147f77b6717f) --- .../ramips/dts/mt7620a_wavlink_wl-wn579x3.dts | 210 ++++++++++++++++++ target/linux/ramips/image/mt7620.mk | 9 + .../mt7620/base-files/etc/board.d/01_leds | 4 + .../mt7620/base-files/etc/board.d/02_network | 4 + 4 files changed, 227 insertions(+) create mode 100644 target/linux/ramips/dts/mt7620a_wavlink_wl-wn579x3.dts diff --git a/target/linux/ramips/dts/mt7620a_wavlink_wl-wn579x3.dts b/target/linux/ramips/dts/mt7620a_wavlink_wl-wn579x3.dts new file mode 100644 index 0000000000..679d9c2150 --- /dev/null +++ b/target/linux/ramips/dts/mt7620a_wavlink_wl-wn579x3.dts @@ -0,0 +1,210 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "mt7620a.dtsi" + +#include +#include + +/ { + compatible = "wavlink,wl-wn579x3", "ralink,mt7620a-soc"; + model = "Wavlink WL-WN579X3"; + + aliases { + led-boot = &led_wps; + led-failsafe = &led_wps; + led-running = &led_wps; + led-upgrade = &led_wps; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + gpios = <&gpio0 1 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + wps { + label = "wps"; + gpios = <&gpio0 2 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + switch_aps { + label = "mode_aps"; + gpios = <&gpio0 11 GPIO_ACTIVE_LOW>; + linux,code = ; + linux,input-type = ; + }; + + switch_repeater { + label = "mode_repeater"; + gpios = <&gpio0 9 GPIO_ACTIVE_LOW>; + linux,code = ; + linux,input-type = ; + }; + }; + + leds { + compatible = "gpio-leds"; + + led_wps: wps { + label = "blue:wps"; + gpios = <&gpio2 2 GPIO_ACTIVE_LOW>; + }; + + lan { + label = "blue:lan"; + gpios = <&gpio2 4 GPIO_ACTIVE_LOW>; + }; + + wan { + label = "blue:wan"; + gpios = <&gpio2 1 GPIO_ACTIVE_LOW>; + }; + + wifi { + label = "blue:wifi"; + gpios = <&gpio3 0 GPIO_ACTIVE_LOW>; + }; + + /* These three form the signal wifi strength segments */ + wifi_high { + label = "blue:wifi_high"; + gpios = <&gpio0 13 GPIO_ACTIVE_LOW>; + }; + + wifi_medium { + label = "blue:wifi_medium"; + gpios = <&gpio0 12 GPIO_ACTIVE_LOW>; + }; + + wifi_low { + label = "blue:wifi_low"; + gpios = <&gpio2 3 GPIO_ACTIVE_LOW>; + }; + }; +}; + +&gpio2 { + status = "okay"; +}; + +&gpio3 { + status = "okay"; +}; + +&spi0 { + status = "okay"; + + flash@0 { + compatible = "jedec,spi-nor"; + reg = <0>; + spi-max-frequency = <50000000>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "u-boot"; + reg = <0x0 0x30000>; + read-only; + }; + + partition@30000 { + label = "config"; + reg = <0x30000 0x10000>; + read-only; + }; + + factory: partition@40000 { + label = "factory"; + reg = <0x40000 0x10000>; + read-only; + }; + + partition@50000 { + compatible = "denx,uimage"; + label = "firmware"; + reg = <0x50000 0x790000>; + }; + + partition@7e0000 { + label = "board_data"; + reg = <0x7e0000 0x10000>; + read-only; + }; + + partition@7f0000 { + label = "nvram"; + reg = <0x7f0000 0x10000>; + read-only; + }; + }; + }; +}; + +&pcie { + status = "okay"; +}; + +&pcie0 { + wifi@0,0 { + reg = <0x0000 0 0 0 0>; + mediatek,mtd-eeprom = <&factory 0x8000>; + ieee80211-freq-limit = <5000000 6000000>; + }; +}; + +ðernet { + pinctrl-names = "default"; + pinctrl-0 = <&rgmii1_pins &rgmii2_pins &mdio_pins>; + + mtd-mac-address = <&factory 0x28>; + + mediatek,portmap = "llllw"; + + port@4 { + status = "okay"; + phy-handle = <&phy4>; + phy-mode = "rgmii"; + }; + + port@5 { + status = "okay"; + phy-handle = <&phy5>; + phy-mode = "rgmii"; + }; + + mdio-bus { + status = "okay"; + + phy4: ethernet-phy@4 { + reg = <4>; + phy-mode = "rgmii"; + }; + + phy5: ethernet-phy@5 { + reg = <5>; + phy-mode = "rgmii"; + }; + }; +}; + +&gsw { + mediatek,port4 = "gmac"; +}; + +&wmac { + ralink,mtd-eeprom = <&factory 0x0>; +}; + +&state_default { + gpio { + groups = "ephy", "i2c", "wled", "uartf"; + function = "gpio"; + }; +}; diff --git a/target/linux/ramips/image/mt7620.mk b/target/linux/ramips/image/mt7620.mk index 4f85b82c0e..93fa8ae48d 100644 --- a/target/linux/ramips/image/mt7620.mk +++ b/target/linux/ramips/image/mt7620.mk @@ -1093,6 +1093,15 @@ define Device/wavlink_wl-wn530hg4 endef TARGET_DEVICES += wavlink_wl-wn530hg4 +define Device/wavlink_wl-wn579x3 + SOC := mt7620a + IMAGE_SIZE := 7744k + DEVICE_VENDOR := Wavlink + DEVICE_MODEL := WL-WN579X3 + DEVICE_PACKAGES := kmod-mt76x2 kmod-phy-realtek +endef +TARGET_DEVICES += wavlink_wl-wn579x3 + define Device/wrtnode_wrtnode SOC := mt7620n IMAGE_SIZE := 16064k diff --git a/target/linux/ramips/mt7620/base-files/etc/board.d/01_leds b/target/linux/ramips/mt7620/base-files/etc/board.d/01_leds index 7c18b73a9a..4fe7d2d076 100755 --- a/target/linux/ramips/mt7620/base-files/etc/board.d/01_leds +++ b/target/linux/ramips/mt7620/base-files/etc/board.d/01_leds @@ -195,6 +195,10 @@ tplink,archer-mr200) tplink,re200-v1) ucidef_set_led_netdev "lan" "lan" "green:lan" "eth0" ;; +wavlink,wl-wn579x3) + ucidef_set_led_switch "lan" "lan" "blue:lan" "switch0" "0x20" + ucidef_set_led_switch "wan" "wan" "blue:wan" "switch0" "0x10" + ;; zbtlink,zbt-ape522ii) ucidef_set_led_netdev "wlan2g4" "wlan1-link" "green:wlan2g4" "wlan1" ucidef_set_led_netdev "sys1" "wlan1" "green:sys1" "wlan1" "tx rx" diff --git a/target/linux/ramips/mt7620/base-files/etc/board.d/02_network b/target/linux/ramips/mt7620/base-files/etc/board.d/02_network index 4fd2455f5c..5ebffbaf7d 100755 --- a/target/linux/ramips/mt7620/base-files/etc/board.d/02_network +++ b/target/linux/ramips/mt7620/base-files/etc/board.d/02_network @@ -216,6 +216,10 @@ ramips_setup_interfaces() ucidef_add_switch "switch0" \ "0:lan" "4:wan" "6@eth0" ;; + wavlink,wl-wn579x3) + ucidef_add_switch "switch0" \ + "5:lan" "4:wan" "6@eth0" + ;; youku,yk-l1|\ youku,yk-l1c) ucidef_add_switch "switch0" \ From 08ec622c465e2c6c0cc4ca577a794342882a0abd Mon Sep 17 00:00:00 2001 From: David Bauer Date: Sun, 6 Jun 2021 19:45:24 +0200 Subject: [PATCH 09/23] ramips: make PHY initialization more descriptive The basic mode control register of the ESW PHYs is modified in this codeblock. Use the respective macros to make this code more readable. Signed-off-by: David Bauer (cherry picked from commit 6a15abbc753ca728d798cec9153fc532fce3791d) --- .../ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.c b/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.c index bd379e6c7d..451881fc73 100644 --- a/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.c +++ b/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.c @@ -13,6 +13,7 @@ */ #include +#include #include #include #include @@ -168,9 +169,9 @@ static void mt7620_hw_init(struct mt7620_gsw *gsw, int mdio_mode) /* turn on all PHYs */ for (i = 0; i <= 4; i++) { - val = _mt7620_mii_read(gsw, gsw->ephy_base + i, 0); - val &= ~BIT(11); - _mt7620_mii_write(gsw, gsw->ephy_base + i, 0, val); + val = _mt7620_mii_read(gsw, gsw->ephy_base + i, MII_BMCR); + val &= ~BMCR_PDOWN; + _mt7620_mii_write(gsw, gsw->ephy_base + i, MII_BMCR, val); } } From c652a06eefc03a69dfc509880313f44e44c7966a Mon Sep 17 00:00:00 2001 From: Gaspare Bruno Date: Wed, 13 Jan 2021 18:03:39 -0300 Subject: [PATCH 10/23] ramips: mt7620: enable autonegotiation for all ports This enables autonegotiation for all ephy ports on probe. Some devices do not configure the ports, particularly port 4. Signed-off-by: Gaspare Bruno [replace magic values ; reword commit message] Signed-off-by: David Bauer (cherry picked from commit 0056ffb468f40f34bea006eb889b70c9a4f562e0) --- .../linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.c | 1 + 1 file changed, 1 insertion(+) diff --git a/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.c b/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.c index 451881fc73..0b09814cc8 100644 --- a/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.c +++ b/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.c @@ -171,6 +171,7 @@ static void mt7620_hw_init(struct mt7620_gsw *gsw, int mdio_mode) for (i = 0; i <= 4; i++) { val = _mt7620_mii_read(gsw, gsw->ephy_base + i, MII_BMCR); val &= ~BMCR_PDOWN; + val |= BMCR_ANRESTART | BMCR_ANENABLE | BMCR_SPEED100; _mt7620_mii_write(gsw, gsw->ephy_base + i, MII_BMCR, val); } } From a14c2d409c44c7562b29b79549fdf51566b59db0 Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Wed, 31 Mar 2021 16:09:37 -0400 Subject: [PATCH 11/23] ramips: mt7620: simplify DTS properties for GMAC There are only 2 options in the driver for the function of mt7620 internal switch port 4: EPHY mode (RJ-45, internal PHY) GMAC mode (RGMII, external PHY) Let the DTS property be boolean instead of string where EPHY mode is the default. Fix how the properties are written for all DTS that use them, and add missing nodes where applicable, and remove useless nodes, and minor DTS formatting. Signed-off-by: Michael Pratt (cherry picked from commit 953bfe2eb3b7236a72fa41ab2204fdaa9fd09f65) --- .../ramips/dts/mt7620a_alfa-network_ac1200rm.dts | 4 ---- .../ramips/dts/mt7620a_alfa-network_r36m-e4g.dts | 4 ---- .../ramips/dts/mt7620a_alfa-network_tube-e4g.dts | 4 ---- target/linux/ramips/dts/mt7620a_asus_rp-n53.dts | 3 +-- .../ramips/dts/mt7620a_buffalo_whr-1166d.dts | 4 ---- .../ramips/dts/mt7620a_buffalo_whr-300hp2.dts | 4 ---- .../linux/ramips/dts/mt7620a_buffalo_whr-600d.dts | 4 ---- target/linux/ramips/dts/mt7620a_cameo_810.dtsi | 4 ---- .../linux/ramips/dts/mt7620a_dlink_dch-m225.dts | 4 ---- .../linux/ramips/dts/mt7620a_dlink_dir-510l.dts | 4 ---- .../linux/ramips/dts/mt7620a_dlink_dwr-118-a1.dts | 2 +- .../linux/ramips/dts/mt7620a_dlink_dwr-118-a2.dts | 2 +- .../linux/ramips/dts/mt7620a_dovado_tiny-ac.dts | 2 +- .../ramips/dts/mt7620a_edimax_br-6478ac-v2.dts | 4 ---- .../ramips/dts/mt7620a_edimax_ew-7478apc.dts | 4 ---- .../linux/ramips/dts/mt7620a_edimax_ew-747x.dtsi | 4 ---- .../linux/ramips/dts/mt7620a_engenius_esr600.dts | 2 +- target/linux/ramips/dts/mt7620a_fon_fon2601.dts | 2 +- .../ramips/dts/mt7620a_head-weblink_hdrm200.dts | 4 ++++ .../ramips/dts/mt7620a_lenovo_newifi-y1s.dts | 2 +- target/linux/ramips/dts/mt7620a_linksys_e1700.dts | 4 ---- .../linux/ramips/dts/mt7620a_ohyeah_oy-0001.dts | 4 ---- .../linux/ramips/dts/mt7620a_planex_cs-qr10.dts | 4 ---- .../linux/ramips/dts/mt7620a_planex_db-wrt01.dts | 4 ---- .../ramips/dts/mt7620a_planex_mzk-750dhp.dts | 4 ---- .../ramips/dts/mt7620a_ralink_mt7620a-evb.dts | 2 +- .../dts/mt7620a_ralink_mt7620a-mt7530-evb.dts | 4 ---- .../dts/mt7620a_ralink_mt7620a-mt7610e-evb.dts | 4 ---- .../dts/mt7620a_ralink_mt7620a-v22sg-evb.dts | 2 +- target/linux/ramips/dts/mt7620a_sercomm_na930.dts | 2 +- .../ramips/dts/mt7620a_tplink_archer-mr200.dts | 4 ---- .../linux/ramips/dts/mt7620a_tplink_archer.dtsi | 4 ---- .../linux/ramips/dts/mt7620a_tplink_re210-v1.dts | 2 +- .../ramips/dts/mt7620a_wavlink_wl-wn579x3.dts | 2 +- target/linux/ramips/dts/mt7620a_yukai_bocco.dts | 4 ---- target/linux/ramips/dts/mt7620a_zte_q7.dts | 4 ---- .../ramips/dts/mt7620a_zyxel_keenetic-viva.dts | 2 +- target/linux/ramips/dts/mt7620n.dtsi | 1 - .../drivers/net/ethernet/ralink/gsw_mt7620.c | 15 ++++----------- .../drivers/net/ethernet/ralink/gsw_mt7620.h | 7 +------ .../drivers/net/ethernet/ralink/soc_mt7620.c | 2 +- 41 files changed, 23 insertions(+), 125 deletions(-) diff --git a/target/linux/ramips/dts/mt7620a_alfa-network_ac1200rm.dts b/target/linux/ramips/dts/mt7620a_alfa-network_ac1200rm.dts index 27b6896cec..752a940cd8 100644 --- a/target/linux/ramips/dts/mt7620a_alfa-network_ac1200rm.dts +++ b/target/linux/ramips/dts/mt7620a_alfa-network_ac1200rm.dts @@ -72,10 +72,6 @@ status = "okay"; }; -&gsw { - mediatek,port4 = "ephy"; -}; - &ohci { status = "okay"; }; diff --git a/target/linux/ramips/dts/mt7620a_alfa-network_r36m-e4g.dts b/target/linux/ramips/dts/mt7620a_alfa-network_r36m-e4g.dts index 58386a9ac7..0991ae8447 100644 --- a/target/linux/ramips/dts/mt7620a_alfa-network_r36m-e4g.dts +++ b/target/linux/ramips/dts/mt7620a_alfa-network_r36m-e4g.dts @@ -141,10 +141,6 @@ status = "okay"; }; -&gsw { - mediatek,port4 = "ephy"; -}; - &i2c { status = "okay"; }; diff --git a/target/linux/ramips/dts/mt7620a_alfa-network_tube-e4g.dts b/target/linux/ramips/dts/mt7620a_alfa-network_tube-e4g.dts index 30a0201c39..ca58d780f4 100644 --- a/target/linux/ramips/dts/mt7620a_alfa-network_tube-e4g.dts +++ b/target/linux/ramips/dts/mt7620a_alfa-network_tube-e4g.dts @@ -114,10 +114,6 @@ status = "okay"; }; -&gsw { - mediatek,port4 = "ephy"; -}; - &ohci { status = "okay"; }; diff --git a/target/linux/ramips/dts/mt7620a_asus_rp-n53.dts b/target/linux/ramips/dts/mt7620a_asus_rp-n53.dts index 3cb9142c38..4c72c64272 100644 --- a/target/linux/ramips/dts/mt7620a_asus_rp-n53.dts +++ b/target/linux/ramips/dts/mt7620a_asus_rp-n53.dts @@ -153,8 +153,7 @@ }; }; -&gsw { - mediatek,port4 = "ephy"; +ðernet { pinctrl-names = "default"; pinctrl-0 = <&ephy_pins>; }; diff --git a/target/linux/ramips/dts/mt7620a_buffalo_whr-1166d.dts b/target/linux/ramips/dts/mt7620a_buffalo_whr-1166d.dts index 196bbde726..93a09f99c3 100644 --- a/target/linux/ramips/dts/mt7620a_buffalo_whr-1166d.dts +++ b/target/linux/ramips/dts/mt7620a_buffalo_whr-1166d.dts @@ -157,10 +157,6 @@ }; }; -&gsw { - mediatek,port4 = "ephy"; -}; - &wmac { ralink,mtd-eeprom = <&factory 0x0>; }; diff --git a/target/linux/ramips/dts/mt7620a_buffalo_whr-300hp2.dts b/target/linux/ramips/dts/mt7620a_buffalo_whr-300hp2.dts index ed2e03d6cf..95152bc41a 100644 --- a/target/linux/ramips/dts/mt7620a_buffalo_whr-300hp2.dts +++ b/target/linux/ramips/dts/mt7620a_buffalo_whr-300hp2.dts @@ -144,10 +144,6 @@ mediatek,portmap = "llllw"; }; -&gsw { - mediatek,port4 = "ephy"; -}; - &wmac { ralink,mtd-eeprom = <&factory 0x0>; pinctrl-names = "default"; diff --git a/target/linux/ramips/dts/mt7620a_buffalo_whr-600d.dts b/target/linux/ramips/dts/mt7620a_buffalo_whr-600d.dts index b799a98e56..226967763b 100644 --- a/target/linux/ramips/dts/mt7620a_buffalo_whr-600d.dts +++ b/target/linux/ramips/dts/mt7620a_buffalo_whr-600d.dts @@ -144,10 +144,6 @@ mediatek,portmap = "llllw"; }; -&gsw { - mediatek,port4 = "ephy"; -}; - &wmac { ralink,mtd-eeprom = <&factory 0x0>; }; diff --git a/target/linux/ramips/dts/mt7620a_cameo_810.dtsi b/target/linux/ramips/dts/mt7620a_cameo_810.dtsi index c3f3267d38..70407449db 100644 --- a/target/linux/ramips/dts/mt7620a_cameo_810.dtsi +++ b/target/linux/ramips/dts/mt7620a_cameo_810.dtsi @@ -132,10 +132,6 @@ mediatek,portmap = "llllw"; }; -&gsw { - mediatek,port4 = "ephy"; -}; - &gpio2 { status = "okay"; }; diff --git a/target/linux/ramips/dts/mt7620a_dlink_dch-m225.dts b/target/linux/ramips/dts/mt7620a_dlink_dch-m225.dts index 63667da281..0c9f56875e 100644 --- a/target/linux/ramips/dts/mt7620a_dlink_dch-m225.dts +++ b/target/linux/ramips/dts/mt7620a_dlink_dch-m225.dts @@ -171,10 +171,6 @@ mtd-mac-address = <&factory 0x4>; }; -&gsw { - ralink,port4 = "ephy"; -}; - &wmac { ralink,mtd-eeprom = <&factory 0x0>; pinctrl-names = "default"; diff --git a/target/linux/ramips/dts/mt7620a_dlink_dir-510l.dts b/target/linux/ramips/dts/mt7620a_dlink_dir-510l.dts index f4db67648a..774d90c79d 100644 --- a/target/linux/ramips/dts/mt7620a_dlink_dir-510l.dts +++ b/target/linux/ramips/dts/mt7620a_dlink_dir-510l.dts @@ -120,10 +120,6 @@ }; }; -&gsw { - mediatek,port4 = "ephy"; -}; - &state_default { default { groups = "i2c", "uartf"; diff --git a/target/linux/ramips/dts/mt7620a_dlink_dwr-118-a1.dts b/target/linux/ramips/dts/mt7620a_dlink_dwr-118-a1.dts index bacebee8e1..71b532fc34 100644 --- a/target/linux/ramips/dts/mt7620a_dlink_dwr-118-a1.dts +++ b/target/linux/ramips/dts/mt7620a_dlink_dwr-118-a1.dts @@ -185,5 +185,5 @@ }; &gsw { - mediatek,port4 = "gmac"; + mediatek,port4-gmac; }; diff --git a/target/linux/ramips/dts/mt7620a_dlink_dwr-118-a2.dts b/target/linux/ramips/dts/mt7620a_dlink_dwr-118-a2.dts index 0b124e67de..9ea28706aa 100644 --- a/target/linux/ramips/dts/mt7620a_dlink_dwr-118-a2.dts +++ b/target/linux/ramips/dts/mt7620a_dlink_dwr-118-a2.dts @@ -173,6 +173,6 @@ }; &gsw { - mediatek,port4 = "gmac"; + mediatek,port4-gmac; mediatek,ephy-base-address = /bits/ 16 < 2 >; }; diff --git a/target/linux/ramips/dts/mt7620a_dovado_tiny-ac.dts b/target/linux/ramips/dts/mt7620a_dovado_tiny-ac.dts index 9450596f1b..068f75bd96 100644 --- a/target/linux/ramips/dts/mt7620a_dovado_tiny-ac.dts +++ b/target/linux/ramips/dts/mt7620a_dovado_tiny-ac.dts @@ -135,7 +135,7 @@ }; &gsw { - mediatek,port4 = "gmac"; + mediatek,port4-gmac; }; &pcie { diff --git a/target/linux/ramips/dts/mt7620a_edimax_br-6478ac-v2.dts b/target/linux/ramips/dts/mt7620a_edimax_br-6478ac-v2.dts index e7af34aa8e..2337c0f9d3 100644 --- a/target/linux/ramips/dts/mt7620a_edimax_br-6478ac-v2.dts +++ b/target/linux/ramips/dts/mt7620a_edimax_br-6478ac-v2.dts @@ -177,10 +177,6 @@ }; }; -&gsw { - mediatek,port4 = "gmac"; -}; - &wmac { ralink,mtd-eeprom = <&factory 0x0>; }; diff --git a/target/linux/ramips/dts/mt7620a_edimax_ew-7478apc.dts b/target/linux/ramips/dts/mt7620a_edimax_ew-7478apc.dts index 77d214e888..09763db388 100644 --- a/target/linux/ramips/dts/mt7620a_edimax_ew-7478apc.dts +++ b/target/linux/ramips/dts/mt7620a_edimax_ew-7478apc.dts @@ -169,10 +169,6 @@ }; }; -&gsw { - mediatek,port4 = "gmac"; -}; - &wmac { ralink,mtd-eeprom = <&factory 0x0>; }; diff --git a/target/linux/ramips/dts/mt7620a_edimax_ew-747x.dtsi b/target/linux/ramips/dts/mt7620a_edimax_ew-747x.dtsi index d17cc090c2..07b03f5c06 100644 --- a/target/linux/ramips/dts/mt7620a_edimax_ew-747x.dtsi +++ b/target/linux/ramips/dts/mt7620a_edimax_ew-747x.dtsi @@ -201,10 +201,6 @@ }; }; -&gsw { - mediatek,port5 = "gmac"; -}; - &wmac { ralink,mtd-eeprom = <&factory 0x0>; }; diff --git a/target/linux/ramips/dts/mt7620a_engenius_esr600.dts b/target/linux/ramips/dts/mt7620a_engenius_esr600.dts index b8fe2f8cdb..35d0b3dbec 100644 --- a/target/linux/ramips/dts/mt7620a_engenius_esr600.dts +++ b/target/linux/ramips/dts/mt7620a_engenius_esr600.dts @@ -155,7 +155,7 @@ 0x7c 0x0000007e /* PORT0 STATUS */ 0x0c 0x05600000 /* PORT6 PAD MODE CTRL */ 0x94 0x0000007e /* PORT6 STATUS */ - >; + >; }; }; }; diff --git a/target/linux/ramips/dts/mt7620a_fon_fon2601.dts b/target/linux/ramips/dts/mt7620a_fon_fon2601.dts index ee61c6e59e..b47d63be85 100644 --- a/target/linux/ramips/dts/mt7620a_fon_fon2601.dts +++ b/target/linux/ramips/dts/mt7620a_fon_fon2601.dts @@ -136,7 +136,7 @@ }; &gsw { - mediatek,port4 = "gmac"; + mediatek,port4-gmac; }; &wmac { diff --git a/target/linux/ramips/dts/mt7620a_head-weblink_hdrm200.dts b/target/linux/ramips/dts/mt7620a_head-weblink_hdrm200.dts index a0ebe4fff5..487f6aaf6e 100644 --- a/target/linux/ramips/dts/mt7620a_head-weblink_hdrm200.dts +++ b/target/linux/ramips/dts/mt7620a_head-weblink_hdrm200.dts @@ -149,6 +149,10 @@ }; }; +&gsw { + mediatek,port4-gmac; +}; + &wmac { ralink,mtd-eeprom = <&factory 0x0>; }; diff --git a/target/linux/ramips/dts/mt7620a_lenovo_newifi-y1s.dts b/target/linux/ramips/dts/mt7620a_lenovo_newifi-y1s.dts index a07683ed4a..0997d8a00e 100644 --- a/target/linux/ramips/dts/mt7620a_lenovo_newifi-y1s.dts +++ b/target/linux/ramips/dts/mt7620a_lenovo_newifi-y1s.dts @@ -111,5 +111,5 @@ }; &gsw { - mediatek,port4 = "gmac"; + mediatek,port4-gmac; }; diff --git a/target/linux/ramips/dts/mt7620a_linksys_e1700.dts b/target/linux/ramips/dts/mt7620a_linksys_e1700.dts index 2619a4653a..2672d54f36 100644 --- a/target/linux/ramips/dts/mt7620a_linksys_e1700.dts +++ b/target/linux/ramips/dts/mt7620a_linksys_e1700.dts @@ -144,10 +144,6 @@ }; }; -&gsw { - mediatek,port4 = "gmac"; -}; - &wmac { ralink,mtd-eeprom = <&factory 0x0>; }; diff --git a/target/linux/ramips/dts/mt7620a_ohyeah_oy-0001.dts b/target/linux/ramips/dts/mt7620a_ohyeah_oy-0001.dts index 07f606fce4..7dabbed9ba 100644 --- a/target/linux/ramips/dts/mt7620a_ohyeah_oy-0001.dts +++ b/target/linux/ramips/dts/mt7620a_ohyeah_oy-0001.dts @@ -103,10 +103,6 @@ mediatek,portmap = "llllw"; }; -&gsw { - mediatek,port4 = "ephy"; -}; - &wmac { ralink,mtd-eeprom = <&factory 0x0>; }; diff --git a/target/linux/ramips/dts/mt7620a_planex_cs-qr10.dts b/target/linux/ramips/dts/mt7620a_planex_cs-qr10.dts index aa7ddb0a25..3edc41ac0d 100644 --- a/target/linux/ramips/dts/mt7620a_planex_cs-qr10.dts +++ b/target/linux/ramips/dts/mt7620a_planex_cs-qr10.dts @@ -122,10 +122,6 @@ mediatek,portmap = "llllw"; }; -&gsw { - ralink,port4 = "ephy"; -}; - &sdhci { status = "okay"; }; diff --git a/target/linux/ramips/dts/mt7620a_planex_db-wrt01.dts b/target/linux/ramips/dts/mt7620a_planex_db-wrt01.dts index eb373e9aa2..8f8f173de3 100644 --- a/target/linux/ramips/dts/mt7620a_planex_db-wrt01.dts +++ b/target/linux/ramips/dts/mt7620a_planex_db-wrt01.dts @@ -94,10 +94,6 @@ mediatek,portmap = "llllw"; }; -&gsw { - mediatek,port4 = "ephy"; -}; - &wmac { ralink,mtd-eeprom = <&factory 0x0>; }; diff --git a/target/linux/ramips/dts/mt7620a_planex_mzk-750dhp.dts b/target/linux/ramips/dts/mt7620a_planex_mzk-750dhp.dts index df9c9689c3..e1c5568ed8 100644 --- a/target/linux/ramips/dts/mt7620a_planex_mzk-750dhp.dts +++ b/target/linux/ramips/dts/mt7620a_planex_mzk-750dhp.dts @@ -114,10 +114,6 @@ mediatek,portmap = "llllw"; }; -&gsw { - mediatek,port4 = "ephy"; -}; - &wmac { ralink,mtd-eeprom = <&factory 0x0>; }; diff --git a/target/linux/ramips/dts/mt7620a_ralink_mt7620a-evb.dts b/target/linux/ramips/dts/mt7620a_ralink_mt7620a-evb.dts index 7743df06fb..4c5baf1e50 100644 --- a/target/linux/ramips/dts/mt7620a_ralink_mt7620a-evb.dts +++ b/target/linux/ramips/dts/mt7620a_ralink_mt7620a-evb.dts @@ -105,7 +105,7 @@ }; &gsw { - mediatek,port4 = "gmac"; + mediatek,port4-gmac; }; &sdhci { diff --git a/target/linux/ramips/dts/mt7620a_ralink_mt7620a-mt7530-evb.dts b/target/linux/ramips/dts/mt7620a_ralink_mt7620a-mt7530-evb.dts index 4a09755967..b76ab2aa59 100644 --- a/target/linux/ramips/dts/mt7620a_ralink_mt7620a-mt7530-evb.dts +++ b/target/linux/ramips/dts/mt7620a_ralink_mt7620a-mt7530-evb.dts @@ -99,10 +99,6 @@ }; }; -&gsw { - mediatek,port4 = "gmac"; -}; - &pcie { status = "okay"; }; diff --git a/target/linux/ramips/dts/mt7620a_ralink_mt7620a-mt7610e-evb.dts b/target/linux/ramips/dts/mt7620a_ralink_mt7620a-mt7610e-evb.dts index ae0d364d3e..b7a71c3e25 100644 --- a/target/linux/ramips/dts/mt7620a_ralink_mt7620a-mt7610e-evb.dts +++ b/target/linux/ramips/dts/mt7620a_ralink_mt7620a-mt7610e-evb.dts @@ -71,10 +71,6 @@ mediatek,portmap = "llllw"; }; -&gsw { - mediatek,port4 = "ephy"; -}; - &sdhci { status = "okay"; }; diff --git a/target/linux/ramips/dts/mt7620a_ralink_mt7620a-v22sg-evb.dts b/target/linux/ramips/dts/mt7620a_ralink_mt7620a-v22sg-evb.dts index bee4ba7fd3..6e8eff50bc 100644 --- a/target/linux/ramips/dts/mt7620a_ralink_mt7620a-v22sg-evb.dts +++ b/target/linux/ramips/dts/mt7620a_ralink_mt7620a-v22sg-evb.dts @@ -99,7 +99,7 @@ }; &gsw { - mediatek,port4 = "gmac"; + mediatek,port4-gmac; }; &pcie { diff --git a/target/linux/ramips/dts/mt7620a_sercomm_na930.dts b/target/linux/ramips/dts/mt7620a_sercomm_na930.dts index 4a91c07ecd..329ecc5ea8 100644 --- a/target/linux/ramips/dts/mt7620a_sercomm_na930.dts +++ b/target/linux/ramips/dts/mt7620a_sercomm_na930.dts @@ -166,7 +166,7 @@ }; &gsw { - mediatek,port4 = "gmac"; + mediatek,port4-gmac; }; &ehci { diff --git a/target/linux/ramips/dts/mt7620a_tplink_archer-mr200.dts b/target/linux/ramips/dts/mt7620a_tplink_archer-mr200.dts index ae92dc85e6..4212a70dc3 100644 --- a/target/linux/ramips/dts/mt7620a_tplink_archer-mr200.dts +++ b/target/linux/ramips/dts/mt7620a_tplink_archer-mr200.dts @@ -178,10 +178,6 @@ status = "okay"; }; -&gsw { - mediatek,port4 = "ephy"; -}; - &wmac { ralink,mtd-eeprom = <&radio 0x0>; }; diff --git a/target/linux/ramips/dts/mt7620a_tplink_archer.dtsi b/target/linux/ramips/dts/mt7620a_tplink_archer.dtsi index 670bad615d..d2fb891433 100644 --- a/target/linux/ramips/dts/mt7620a_tplink_archer.dtsi +++ b/target/linux/ramips/dts/mt7620a_tplink_archer.dtsi @@ -105,10 +105,6 @@ status = "okay"; }; -&gsw { - mediatek,port4 = "ephy"; -}; - &wmac { ralink,mtd-eeprom = <&radio 0x0>; }; diff --git a/target/linux/ramips/dts/mt7620a_tplink_re210-v1.dts b/target/linux/ramips/dts/mt7620a_tplink_re210-v1.dts index 41e56fbe36..247b5752ef 100644 --- a/target/linux/ramips/dts/mt7620a_tplink_re210-v1.dts +++ b/target/linux/ramips/dts/mt7620a_tplink_re210-v1.dts @@ -61,7 +61,7 @@ }; &gsw { - mediatek,port4 = "gmac"; + mediatek,port4-gmac; }; ðernet { diff --git a/target/linux/ramips/dts/mt7620a_wavlink_wl-wn579x3.dts b/target/linux/ramips/dts/mt7620a_wavlink_wl-wn579x3.dts index 679d9c2150..55ab939d15 100644 --- a/target/linux/ramips/dts/mt7620a_wavlink_wl-wn579x3.dts +++ b/target/linux/ramips/dts/mt7620a_wavlink_wl-wn579x3.dts @@ -195,7 +195,7 @@ }; &gsw { - mediatek,port4 = "gmac"; + mediatek,port4-gmac; }; &wmac { diff --git a/target/linux/ramips/dts/mt7620a_yukai_bocco.dts b/target/linux/ramips/dts/mt7620a_yukai_bocco.dts index 9c99a6582e..347c246e2e 100644 --- a/target/linux/ramips/dts/mt7620a_yukai_bocco.dts +++ b/target/linux/ramips/dts/mt7620a_yukai_bocco.dts @@ -141,10 +141,6 @@ mediatek,portmap = "llllw"; }; -&gsw { - ralink,port4 = "ephy"; -}; - &wmac { ralink,mtd-eeprom = <&factory 0x0>; }; diff --git a/target/linux/ramips/dts/mt7620a_zte_q7.dts b/target/linux/ramips/dts/mt7620a_zte_q7.dts index 1ec3ba2e33..550f750c5a 100644 --- a/target/linux/ramips/dts/mt7620a_zte_q7.dts +++ b/target/linux/ramips/dts/mt7620a_zte_q7.dts @@ -111,7 +111,3 @@ &ohci { status = "okay"; }; - -&gsw { - mediatek,port4 = "ephy"; -}; diff --git a/target/linux/ramips/dts/mt7620a_zyxel_keenetic-viva.dts b/target/linux/ramips/dts/mt7620a_zyxel_keenetic-viva.dts index 8c07de4845..506b828ec8 100644 --- a/target/linux/ramips/dts/mt7620a_zyxel_keenetic-viva.dts +++ b/target/linux/ramips/dts/mt7620a_zyxel_keenetic-viva.dts @@ -157,7 +157,7 @@ }; &gsw { - mediatek,port4 = "gmac"; + mediatek,port4-gmac; }; &wmac { diff --git a/target/linux/ramips/dts/mt7620n.dtsi b/target/linux/ramips/dts/mt7620n.dtsi index 2feb411dbc..754d41dd78 100644 --- a/target/linux/ramips/dts/mt7620n.dtsi +++ b/target/linux/ramips/dts/mt7620n.dtsi @@ -347,7 +347,6 @@ interrupt-parent = <&intc>; interrupts = <17>; - mediatek,port4 = "ephy"; }; ehci: ehci@101c0000 { diff --git a/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.c b/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.c index 0b09814cc8..798dc919bc 100644 --- a/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.c +++ b/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.c @@ -40,7 +40,7 @@ static irqreturn_t gsw_interrupt_mt7620(int irq, void *_priv) struct fe_priv *priv = (struct fe_priv *)_priv; struct mt7620_gsw *gsw = (struct mt7620_gsw *)priv->soc->swpriv; u32 status; - int i, max = (gsw->port4 == PORT4_EPHY) ? (4) : (3); + int i, max = (gsw->port4_ephy) ? (4) : (3); status = mtk_switch_r32(gsw, GSW_REG_ISR); if (status & PORT_IRQ_ST_CHG) @@ -202,8 +202,8 @@ static void mt7620_hw_init(struct mt7620_gsw *gsw, int mdio_mode) mtk_switch_w32(gsw, 0x7f7f7fe0, 0x0010); /* setup port 4 */ - if (gsw->port4 == PORT4_EPHY) { - u32 val = rt_sysc_r32(SYSC_REG_CFG1); + if (gsw->port4_ephy) { + val = rt_sysc_r32(SYSC_REG_CFG1); val |= 3 << 14; rt_sysc_w32(val, SYSC_REG_CFG1); @@ -255,7 +255,6 @@ int mtk_gsw_init(struct fe_priv *priv) static int mt7620_gsw_probe(struct platform_device *pdev) { struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - const char *port4 = NULL; struct mt7620_gsw *gsw; struct device_node *np = pdev->dev.of_node; u16 val; @@ -270,13 +269,7 @@ static int mt7620_gsw_probe(struct platform_device *pdev) gsw->dev = &pdev->dev; - of_property_read_string(np, "mediatek,port4", &port4); - if (port4 && !strcmp(port4, "ephy")) - gsw->port4 = PORT4_EPHY; - else if (port4 && !strcmp(port4, "gmac")) - gsw->port4 = PORT4_EXT; - else - gsw->port4 = PORT4_EPHY; + gsw->port4_ephy = !of_property_read_bool(np, "mediatek,port4-gmac"); if (of_property_read_u16(np, "mediatek,ephy-base-address", &val) == 0) gsw->ephy_base = val; diff --git a/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.h b/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.h index f10946a173..91a0399976 100644 --- a/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.h +++ b/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.h @@ -88,16 +88,11 @@ enum { GSW_ATTR_PORT_UNTAG, }; -enum { - PORT4_EPHY = 0, - PORT4_EXT, -}; - struct mt7620_gsw { struct device *dev; void __iomem *base; int irq; - int port4; + bool port4_ephy; unsigned long int autopoll; u16 ephy_base; }; diff --git a/target/linux/ramips/files/drivers/net/ethernet/ralink/soc_mt7620.c b/target/linux/ramips/files/drivers/net/ethernet/ralink/soc_mt7620.c index f442d558e1..0b332ae9d6 100644 --- a/target/linux/ramips/files/drivers/net/ethernet/ralink/soc_mt7620.c +++ b/target/linux/ramips/files/drivers/net/ethernet/ralink/soc_mt7620.c @@ -136,7 +136,7 @@ static void mt7620_port_init(struct fe_priv *priv, struct device_node *np) u32 val, mask = 0; u32 val_delay = 0; u32 mask_delay = GSW_REG_GPCx_TXDELAY | GSW_REG_GPCx_RXDELAY; - int min = (gsw->port4 == PORT4_EPHY) ? (5) : (4); + int min = (gsw->port4_ephy) ? (5) : (4); if (!_id || (be32_to_cpu(*_id) < min) || (be32_to_cpu(*_id) > 5)) { if (_id) From 6491212ea7067bbb4af3873412051c8fae8e477c Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Fri, 11 Jun 2021 14:54:43 -0400 Subject: [PATCH 12/23] ramips: mt7620: remove useless GMAC nodes These nodes are used for configuring a GMAC interface and for defining external PHYs to be accessed with MDIO. None of this is possible on MT7620N, only MT7620A, so remove them from all MT7620N DTS. When the mdio-bus node is missing, the driver returns -NODEV which causes the internal switch to not initialize. Replace that return so that everything works without the DTS node. Also, an extra kernel message to indicate for all error conditions that mdio-bus is disabled. Fixes: d482356322c9 ("ramips: mt7620n: add mdio node and disable port4 by default") Fixes: aa5014dd1a58 ("ramips: mt7620n: enable port 4 as EPHY by default") Signed-off-by: Michael Pratt (cherry picked from commit a2acdf9607045e5669c305c57dd7c77be8351ba0) --- target/linux/ramips/dts/mt7620n.dtsi | 14 -------------- .../linux/ramips/dts/mt7620n_dlink_dwr-921-c1.dts | 6 ------ .../linux/ramips/dts/mt7620n_dlink_dwr-922-e2.dts | 6 ------ .../files/drivers/net/ethernet/ralink/mdio.c | 5 ++++- 4 files changed, 4 insertions(+), 27 deletions(-) diff --git a/target/linux/ramips/dts/mt7620n.dtsi b/target/linux/ramips/dts/mt7620n.dtsi index 754d41dd78..d5d704b025 100644 --- a/target/linux/ramips/dts/mt7620n.dtsi +++ b/target/linux/ramips/dts/mt7620n.dtsi @@ -322,20 +322,6 @@ reset-names = "fe", "esw"; mediatek,switch = <&gsw>; - - mdio-bus { - #address-cells = <1>; - #size-cells = <0>; - - status = "disabled"; - }; - - port@4 { - compatible = "mediatek,mt7620a-gsw-port", "mediatek,eth-port"; - reg = <4>; - - status = "disabled"; - }; }; gsw: gsw@10110000 { diff --git a/target/linux/ramips/dts/mt7620n_dlink_dwr-921-c1.dts b/target/linux/ramips/dts/mt7620n_dlink_dwr-921-c1.dts index c784839c34..d37bdb4013 100644 --- a/target/linux/ramips/dts/mt7620n_dlink_dwr-921-c1.dts +++ b/target/linux/ramips/dts/mt7620n_dlink_dwr-921-c1.dts @@ -133,12 +133,6 @@ status = "okay"; }; -ðernet { - port@4 { - status = "okay"; - }; -}; - &state_default { default { groups = "spi refclk", "i2c", "ephy", "wled"; diff --git a/target/linux/ramips/dts/mt7620n_dlink_dwr-922-e2.dts b/target/linux/ramips/dts/mt7620n_dlink_dwr-922-e2.dts index 9400394d89..d3ca0dd53f 100644 --- a/target/linux/ramips/dts/mt7620n_dlink_dwr-922-e2.dts +++ b/target/linux/ramips/dts/mt7620n_dlink_dwr-922-e2.dts @@ -136,12 +136,6 @@ status = "okay"; }; -ðernet { - port@4 { - status = "okay"; - }; -}; - &state_default { default { groups = "spi refclk", "i2c", "ephy", "wled"; diff --git a/target/linux/ramips/files/drivers/net/ethernet/ralink/mdio.c b/target/linux/ramips/files/drivers/net/ethernet/ralink/mdio.c index 33f973bed3..f5b827e2dc 100644 --- a/target/linux/ramips/files/drivers/net/ethernet/ralink/mdio.c +++ b/target/linux/ramips/files/drivers/net/ethernet/ralink/mdio.c @@ -223,7 +223,8 @@ int fe_mdio_init(struct fe_priv *priv) mii_np = of_get_child_by_name(priv->dev->of_node, "mdio-bus"); if (!mii_np) { dev_err(priv->dev, "no %s child node found", "mdio-bus"); - return -ENODEV; + err = 0; + goto err_no_bus; } if (!of_device_is_available(mii_np)) { @@ -255,6 +256,8 @@ err_free_bus: kfree(priv->mii_bus); err_put_node: of_node_put(mii_np); +err_no_bus: + dev_err(priv->dev, "%s disabled", "mdio-bus"); priv->mii_bus = NULL; return err; } From 01bbed74445f82a0da8c414b132762fe2aed1344 Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Tue, 1 Jun 2021 23:01:26 -0400 Subject: [PATCH 13/23] ramips: mt7620: fix ethernet driver GMAC port init A workaround was added to the switch driver to set SOC port 4 as an RGMII GMAC interface based on the DTS property mediatek,port4-gmac. (previously mediatek,port4) However, the ethernet driver already does this, but is being blocked by a return statement whenever the phy-handle and fixed-link properties are both missing from nodes that define the port properties. Revert the workaround, so that both the switch driver and ethernet driver are not doing the same thing and move the phy-handle related lines down so nothing is ending the function prematurely. While at it, clean up kernel messages and delete useless return statements. Fixes: f6d81e2fa1f1 ("mt7620: gsw: make IntPHY and ExtPHY share mdio addr 4 possible") Signed-off-by: Michael Pratt (cherry picked from commit afd60d650e769e9578eac5bb3647807f683aaf7c) --- .../drivers/net/ethernet/ralink/gsw_mt7620.c | 6 ------ .../drivers/net/ethernet/ralink/soc_mt7620.c | 18 +++++++++--------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.c b/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.c index 798dc919bc..2a34e9417d 100644 --- a/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.c +++ b/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.c @@ -211,12 +211,6 @@ static void mt7620_hw_init(struct mt7620_gsw *gsw, int mdio_mode) _mt7620_mii_write(gsw, gsw->ephy_base + 4, 4, 0x05e1); _mt7620_mii_write(gsw, gsw->ephy_base + 4, 16, 0x1313); pr_info("gsw: setting port4 to ephy mode\n"); - } else if (!mdio_mode) { - u32 val = rt_sysc_r32(SYSC_REG_CFG1); - - val &= ~(3 << 14); - rt_sysc_w32(val, SYSC_REG_CFG1); - pr_info("gsw: setting port4 to gmac mode\n"); } } diff --git a/target/linux/ramips/files/drivers/net/ethernet/ralink/soc_mt7620.c b/target/linux/ramips/files/drivers/net/ethernet/ralink/soc_mt7620.c index 0b332ae9d6..49aa4da507 100644 --- a/target/linux/ramips/files/drivers/net/ethernet/ralink/soc_mt7620.c +++ b/target/linux/ramips/files/drivers/net/ethernet/ralink/soc_mt7620.c @@ -158,7 +158,6 @@ static void mt7620_port_init(struct fe_priv *priv, struct device_node *np) (size != (4 * sizeof(*priv->phy->phy_fixed[id])))) { pr_err("%s: invalid fixed link property\n", np->name); priv->phy->phy_fixed[id] = NULL; - return; } phy_mode = of_get_phy_mode(np); @@ -196,10 +195,6 @@ static void mt7620_port_init(struct fe_priv *priv, struct device_node *np) return; } - priv->phy->phy_node[id] = of_parse_phandle(np, "phy-handle", 0); - if (!priv->phy->phy_node[id] && !priv->phy->phy_fixed[id]) - return; - val = rt_sysc_r32(SYSC_REG_CFG1); val &= ~(3 << shift); val |= mask << shift; @@ -240,8 +235,8 @@ static void mt7620_port_init(struct fe_priv *priv, struct device_node *np) val = 2; break; default: - dev_err(priv->dev, "invalid link speed: %d\n", - priv->phy->speed[id]); + dev_err(priv->dev, "port %d - invalid link speed: %d\n", + id, priv->phy->speed[id]); priv->phy->phy_fixed[id] = 0; return; } @@ -255,7 +250,13 @@ static void mt7620_port_init(struct fe_priv *priv, struct device_node *np) if (priv->phy->duplex[id]) val |= PMCR_DUPLEX; mtk_switch_w32(gsw, val, GSW_REG_PORT_PMCR(id)); - dev_info(priv->dev, "using fixed link parameters\n"); + dev_info(priv->dev, "port %d - using fixed link parameters\n", id); + return; + } + + priv->phy->phy_node[id] = of_parse_phandle(np, "phy-handle", 0); + if (!priv->phy->phy_node[id]) { + dev_err(priv->dev, "port %d - missing phy handle\n", id); return; } @@ -268,7 +269,6 @@ static void mt7620_port_init(struct fe_priv *priv, struct device_node *np) fe_connect_phy_node(priv, priv->phy->phy_node[id], id); gsw->autopoll |= BIT(be32_to_cpup(phy_addr)); mt7620_auto_poll(gsw,id); - return; } } From 5d7805c78b7d8e9f02e53fdb2237971fa3353296 Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Tue, 20 Apr 2021 18:45:15 -0400 Subject: [PATCH 14/23] ramips: mt7620: allow both internal and external PHYs When the new variable ephy_base was introduced, it was not applied to the if block for mdio_mode. The first line in the mdio_mode if block sets the EPHY base address to 12 in the SOC by writing a register, but the corresponding variable in the driver was still set to the default of 0. This causes subsequent lines that write registers with the function _mt7620_mii_write to write to PHY addresses 0 through 4 while internal PHYs have been moved to addresses 12 through 16. All of these lines are intended only for PHYs on the SOC internal switch, however, they are being written to external ethernet switches if they exist at those PHY addresses 0 through 4. This causes some ethernet ports to be broken on boards with AR8327 or QCA8337 switch. Other suggested fixes move those lines to the else block of mdio_mode, but removing the else block completely also fixes it. Therefore, move the lines to the mt7620_hw_init function main block, and have only one instance of the function mtk_switch_w32 for writing the register with the EPHY base address. In theory, this also allows for boards that have both external switches and internal PHYs that lead to ethernet ports to be supported. Fixes: 391df3782914 ("ramips: mt7620: add EPHY base mdio address changing possibility") Signed-off-by: Michael Pratt (cherry picked from commit de5394a29dae9356a830d043e76591698411e97a) --- .../drivers/net/ethernet/ralink/gsw_mt7620.c | 119 +++++++++--------- 1 file changed, 57 insertions(+), 62 deletions(-) diff --git a/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.c b/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.c index 2a34e9417d..4b030f457b 100644 --- a/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.c +++ b/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.c @@ -98,12 +98,8 @@ static void mt7620_hw_init(struct mt7620_gsw *gsw, int mdio_mode) mtk_switch_w32(gsw, mtk_switch_r32(gsw, GSW_REG_MIB_CNT_EN) | (1 << 1), GSW_REG_MIB_CNT_EN); if (mdio_mode) { - u32 val; - - /* turn off ephy and set phy base addr to 12 */ - mtk_switch_w32(gsw, mtk_switch_r32(gsw, GSW_REG_GPC1) | - (0x1f << 24) | (0xc << 16), - GSW_REG_GPC1); + if (!gsw->ephy_base) + gsw->ephy_base = 12; /* set MT7530 central align */ val = mt7530_mdio_r32(gsw, 0x7830); @@ -116,64 +112,63 @@ static void mt7620_hw_init(struct mt7620_gsw *gsw, int mdio_mode) mt7530_mdio_w32(gsw, 0x7a40, val); mt7530_mdio_w32(gsw, 0x7a78, 0x855); + } + + if (gsw->ephy_base) { + /* set phy base addr to ephy_base */ + mtk_switch_w32(gsw, mtk_switch_r32(gsw, GSW_REG_GPC1) | + (gsw->ephy_base << 16), + GSW_REG_GPC1); + fe_reset(BIT(24)); /* Resets the Ethernet PHY block. */ + } + + /* global page 4 */ + _mt7620_mii_write(gsw, gsw->ephy_base + 1, 31, 0x4000); + + _mt7620_mii_write(gsw, gsw->ephy_base + 1, 17, 0x7444); + if (is_BGA) + _mt7620_mii_write(gsw, gsw->ephy_base + 1, 19, 0x0114); + else + _mt7620_mii_write(gsw, gsw->ephy_base + 1, 19, 0x0117); + + _mt7620_mii_write(gsw, gsw->ephy_base + 1, 22, 0x10cf); + _mt7620_mii_write(gsw, gsw->ephy_base + 1, 25, 0x6212); + _mt7620_mii_write(gsw, gsw->ephy_base + 1, 26, 0x0777); + _mt7620_mii_write(gsw, gsw->ephy_base + 1, 29, 0x4000); + _mt7620_mii_write(gsw, gsw->ephy_base + 1, 28, 0xc077); + _mt7620_mii_write(gsw, gsw->ephy_base + 1, 24, 0x0000); + + /* global page 3 */ + _mt7620_mii_write(gsw, gsw->ephy_base + 1, 31, 0x3000); + _mt7620_mii_write(gsw, gsw->ephy_base + 1, 17, 0x4838); + + /* global page 2 */ + _mt7620_mii_write(gsw, gsw->ephy_base + 1, 31, 0x2000); + if (is_BGA) { + _mt7620_mii_write(gsw, gsw->ephy_base + 1, 21, 0x0515); + _mt7620_mii_write(gsw, gsw->ephy_base + 1, 22, 0x0053); + _mt7620_mii_write(gsw, gsw->ephy_base + 1, 23, 0x00bf); + _mt7620_mii_write(gsw, gsw->ephy_base + 1, 24, 0x0aaf); + _mt7620_mii_write(gsw, gsw->ephy_base + 1, 25, 0x0fad); + _mt7620_mii_write(gsw, gsw->ephy_base + 1, 26, 0x0fc1); } else { + _mt7620_mii_write(gsw, gsw->ephy_base + 1, 21, 0x0517); + _mt7620_mii_write(gsw, gsw->ephy_base + 1, 22, 0x0fd2); + _mt7620_mii_write(gsw, gsw->ephy_base + 1, 23, 0x00bf); + _mt7620_mii_write(gsw, gsw->ephy_base + 1, 24, 0x0aab); + _mt7620_mii_write(gsw, gsw->ephy_base + 1, 25, 0x00ae); + _mt7620_mii_write(gsw, gsw->ephy_base + 1, 26, 0x0fff); + } + /* global page 1 */ + _mt7620_mii_write(gsw, gsw->ephy_base + 1, 31, 0x1000); + _mt7620_mii_write(gsw, gsw->ephy_base + 1, 17, 0xe7f8); - if (gsw->ephy_base) { - /* set phy base addr to ephy_base */ - mtk_switch_w32(gsw, mtk_switch_r32(gsw, GSW_REG_GPC1) | - (gsw->ephy_base << 16), - GSW_REG_GPC1); - fe_reset(BIT(24)); /* Resets the Ethernet PHY block. */ - } - - /* global page 4 */ - _mt7620_mii_write(gsw, gsw->ephy_base + 1, 31, 0x4000); - - _mt7620_mii_write(gsw, gsw->ephy_base + 1, 17, 0x7444); - if (is_BGA) - _mt7620_mii_write(gsw, gsw->ephy_base + 1, 19, 0x0114); - else - _mt7620_mii_write(gsw, gsw->ephy_base + 1, 19, 0x0117); - - _mt7620_mii_write(gsw, gsw->ephy_base + 1, 22, 0x10cf); - _mt7620_mii_write(gsw, gsw->ephy_base + 1, 25, 0x6212); - _mt7620_mii_write(gsw, gsw->ephy_base + 1, 26, 0x0777); - _mt7620_mii_write(gsw, gsw->ephy_base + 1, 29, 0x4000); - _mt7620_mii_write(gsw, gsw->ephy_base + 1, 28, 0xc077); - _mt7620_mii_write(gsw, gsw->ephy_base + 1, 24, 0x0000); - - /* global page 3 */ - _mt7620_mii_write(gsw, gsw->ephy_base + 1, 31, 0x3000); - _mt7620_mii_write(gsw, gsw->ephy_base + 1, 17, 0x4838); - - /* global page 2 */ - _mt7620_mii_write(gsw, gsw->ephy_base + 1, 31, 0x2000); - if (is_BGA) { - _mt7620_mii_write(gsw, gsw->ephy_base + 1, 21, 0x0515); - _mt7620_mii_write(gsw, gsw->ephy_base + 1, 22, 0x0053); - _mt7620_mii_write(gsw, gsw->ephy_base + 1, 23, 0x00bf); - _mt7620_mii_write(gsw, gsw->ephy_base + 1, 24, 0x0aaf); - _mt7620_mii_write(gsw, gsw->ephy_base + 1, 25, 0x0fad); - _mt7620_mii_write(gsw, gsw->ephy_base + 1, 26, 0x0fc1); - } else { - _mt7620_mii_write(gsw, gsw->ephy_base + 1, 21, 0x0517); - _mt7620_mii_write(gsw, gsw->ephy_base + 1, 22, 0x0fd2); - _mt7620_mii_write(gsw, gsw->ephy_base + 1, 23, 0x00bf); - _mt7620_mii_write(gsw, gsw->ephy_base + 1, 24, 0x0aab); - _mt7620_mii_write(gsw, gsw->ephy_base + 1, 25, 0x00ae); - _mt7620_mii_write(gsw, gsw->ephy_base + 1, 26, 0x0fff); - } - /* global page 1 */ - _mt7620_mii_write(gsw, gsw->ephy_base + 1, 31, 0x1000); - _mt7620_mii_write(gsw, gsw->ephy_base + 1, 17, 0xe7f8); - - /* turn on all PHYs */ - for (i = 0; i <= 4; i++) { - val = _mt7620_mii_read(gsw, gsw->ephy_base + i, MII_BMCR); - val &= ~BMCR_PDOWN; - val |= BMCR_ANRESTART | BMCR_ANENABLE | BMCR_SPEED100; - _mt7620_mii_write(gsw, gsw->ephy_base + i, MII_BMCR, val); - } + /* turn on all PHYs */ + for (i = 0; i <= 4; i++) { + val = _mt7620_mii_read(gsw, gsw->ephy_base + i, MII_BMCR); + val &= ~BMCR_PDOWN; + val |= BMCR_ANRESTART | BMCR_ANENABLE | BMCR_SPEED100; + _mt7620_mii_write(gsw, gsw->ephy_base + i, MII_BMCR, val); } /* global page 0 */ From 687646587581962572b5b0b805d2088feae36ec8 Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Sat, 3 Apr 2021 14:42:51 -0400 Subject: [PATCH 15/23] ramips: mt7620: use DTS to set PHY base address for external PHYs Set the PHY base address to 12 for mt7530 and 8 for others, which is based on the default setting for some devices from printing the register with the following command after it is written to by uboot during the boot cycle. `md 0x10117014 1` PHY_BASE option only uses 5 bits of the register, bits 16 to 20, so use 8-bit integer type. Set the option using the DTS property mediatek,ephy-base and create the gsw node if missing. Also, added a kernel message to display the EPHY base address. Note: If anything is written to a PHY address that is greater than 1 hex char (greater than 0xf) then there is adverse effects with Atheros switches. Signed-off-by: Michael Pratt (cherry picked from commit 0976b6c4262a11a8d0dab9aeb64f5cdee266c44a) --- target/linux/ramips/dts/mt7620a_dlink_dwr-118-a1.dts | 1 + target/linux/ramips/dts/mt7620a_dlink_dwr-118-a2.dts | 2 +- target/linux/ramips/dts/mt7620a_dovado_tiny-ac.dts | 1 + .../linux/ramips/dts/mt7620a_edimax_br-6478ac-v2.dts | 4 ++++ target/linux/ramips/dts/mt7620a_edimax_ew-7478apc.dts | 4 ++++ target/linux/ramips/dts/mt7620a_edimax_ew-747x.dtsi | 4 ++++ target/linux/ramips/dts/mt7620a_engenius_esr600.dts | 4 ++++ target/linux/ramips/dts/mt7620a_fon_fon2601.dts | 1 + .../linux/ramips/dts/mt7620a_head-weblink_hdrm200.dts | 1 + target/linux/ramips/dts/mt7620a_iodata_wn-ac1167gr.dts | 4 ++++ target/linux/ramips/dts/mt7620a_iptime_a1004ns.dts | 4 ++++ target/linux/ramips/dts/mt7620a_lava_lr-25g001.dts | 4 ++++ target/linux/ramips/dts/mt7620a_lb-link_bl-w1200.dts | 4 ++++ target/linux/ramips/dts/mt7620a_lenovo_newifi-y1s.dts | 1 + target/linux/ramips/dts/mt7620a_linksys_e1700.dts | 4 ++++ target/linux/ramips/dts/mt7620a_netis_wf2770.dts | 4 ++++ target/linux/ramips/dts/mt7620a_ralink_mt7620a-evb.dts | 1 + .../ramips/dts/mt7620a_ralink_mt7620a-mt7530-evb.dts | 4 ++++ .../ramips/dts/mt7620a_ralink_mt7620a-v22sg-evb.dts | 1 + target/linux/ramips/dts/mt7620a_sercomm_na930.dts | 1 + target/linux/ramips/dts/mt7620a_tplink_re210-v1.dts | 1 + target/linux/ramips/dts/mt7620a_wavlink_wl-wn579x3.dts | 1 + .../linux/ramips/dts/mt7620a_zyxel_keenetic-viva.dts | 1 + .../files/drivers/net/ethernet/ralink/gsw_mt7620.c | 10 ++++------ 24 files changed, 60 insertions(+), 7 deletions(-) diff --git a/target/linux/ramips/dts/mt7620a_dlink_dwr-118-a1.dts b/target/linux/ramips/dts/mt7620a_dlink_dwr-118-a1.dts index 71b532fc34..b86ab1449b 100644 --- a/target/linux/ramips/dts/mt7620a_dlink_dwr-118-a1.dts +++ b/target/linux/ramips/dts/mt7620a_dlink_dwr-118-a1.dts @@ -186,4 +186,5 @@ &gsw { mediatek,port4-gmac; + mediatek,ephy-base = /bits/ 8 <8>; }; diff --git a/target/linux/ramips/dts/mt7620a_dlink_dwr-118-a2.dts b/target/linux/ramips/dts/mt7620a_dlink_dwr-118-a2.dts index 9ea28706aa..b0dd31cafc 100644 --- a/target/linux/ramips/dts/mt7620a_dlink_dwr-118-a2.dts +++ b/target/linux/ramips/dts/mt7620a_dlink_dwr-118-a2.dts @@ -174,5 +174,5 @@ &gsw { mediatek,port4-gmac; - mediatek,ephy-base-address = /bits/ 16 < 2 >; + mediatek,ephy-base = /bits/ 8 <2>; }; diff --git a/target/linux/ramips/dts/mt7620a_dovado_tiny-ac.dts b/target/linux/ramips/dts/mt7620a_dovado_tiny-ac.dts index 068f75bd96..ba1a2becda 100644 --- a/target/linux/ramips/dts/mt7620a_dovado_tiny-ac.dts +++ b/target/linux/ramips/dts/mt7620a_dovado_tiny-ac.dts @@ -136,6 +136,7 @@ &gsw { mediatek,port4-gmac; + mediatek,ephy-base = /bits/ 8 <8>; }; &pcie { diff --git a/target/linux/ramips/dts/mt7620a_edimax_br-6478ac-v2.dts b/target/linux/ramips/dts/mt7620a_edimax_br-6478ac-v2.dts index 2337c0f9d3..03a4c96f6b 100644 --- a/target/linux/ramips/dts/mt7620a_edimax_br-6478ac-v2.dts +++ b/target/linux/ramips/dts/mt7620a_edimax_br-6478ac-v2.dts @@ -177,6 +177,10 @@ }; }; +&gsw { + mediatek,ephy-base = /bits/ 8 <12>; +}; + &wmac { ralink,mtd-eeprom = <&factory 0x0>; }; diff --git a/target/linux/ramips/dts/mt7620a_edimax_ew-7478apc.dts b/target/linux/ramips/dts/mt7620a_edimax_ew-7478apc.dts index 09763db388..986b047e47 100644 --- a/target/linux/ramips/dts/mt7620a_edimax_ew-7478apc.dts +++ b/target/linux/ramips/dts/mt7620a_edimax_ew-7478apc.dts @@ -169,6 +169,10 @@ }; }; +&gsw { + mediatek,ephy-base = /bits/ 8 <12>; +}; + &wmac { ralink,mtd-eeprom = <&factory 0x0>; }; diff --git a/target/linux/ramips/dts/mt7620a_edimax_ew-747x.dtsi b/target/linux/ramips/dts/mt7620a_edimax_ew-747x.dtsi index 07b03f5c06..5cb8451547 100644 --- a/target/linux/ramips/dts/mt7620a_edimax_ew-747x.dtsi +++ b/target/linux/ramips/dts/mt7620a_edimax_ew-747x.dtsi @@ -201,6 +201,10 @@ }; }; +&gsw { + mediatek,ephy-base = /bits/ 8 <8>; +}; + &wmac { ralink,mtd-eeprom = <&factory 0x0>; }; diff --git a/target/linux/ramips/dts/mt7620a_engenius_esr600.dts b/target/linux/ramips/dts/mt7620a_engenius_esr600.dts index 35d0b3dbec..2f0f9b256e 100644 --- a/target/linux/ramips/dts/mt7620a_engenius_esr600.dts +++ b/target/linux/ramips/dts/mt7620a_engenius_esr600.dts @@ -160,6 +160,10 @@ }; }; +&gsw { + mediatek,ephy-base = /bits/ 8 <8>; +}; + &state_default { gpio { groups = "i2c", "uartf", "nd_sd", "wled"; diff --git a/target/linux/ramips/dts/mt7620a_fon_fon2601.dts b/target/linux/ramips/dts/mt7620a_fon_fon2601.dts index b47d63be85..373205e725 100644 --- a/target/linux/ramips/dts/mt7620a_fon_fon2601.dts +++ b/target/linux/ramips/dts/mt7620a_fon_fon2601.dts @@ -137,6 +137,7 @@ &gsw { mediatek,port4-gmac; + mediatek,ephy-base = /bits/ 8 <8>; }; &wmac { diff --git a/target/linux/ramips/dts/mt7620a_head-weblink_hdrm200.dts b/target/linux/ramips/dts/mt7620a_head-weblink_hdrm200.dts index 487f6aaf6e..7d807bff4b 100644 --- a/target/linux/ramips/dts/mt7620a_head-weblink_hdrm200.dts +++ b/target/linux/ramips/dts/mt7620a_head-weblink_hdrm200.dts @@ -151,6 +151,7 @@ &gsw { mediatek,port4-gmac; + mediatek,ephy-base = /bits/ 8 <8>; }; &wmac { diff --git a/target/linux/ramips/dts/mt7620a_iodata_wn-ac1167gr.dts b/target/linux/ramips/dts/mt7620a_iodata_wn-ac1167gr.dts index 7044a511bc..d59b481a61 100644 --- a/target/linux/ramips/dts/mt7620a_iodata_wn-ac1167gr.dts +++ b/target/linux/ramips/dts/mt7620a_iodata_wn-ac1167gr.dts @@ -184,6 +184,10 @@ }; }; +&gsw { + mediatek,ephy-base = /bits/ 8 <12>; +}; + &state_default { gpio { groups = "i2c", "uartf"; diff --git a/target/linux/ramips/dts/mt7620a_iptime_a1004ns.dts b/target/linux/ramips/dts/mt7620a_iptime_a1004ns.dts index 20d0557916..6270af3b15 100644 --- a/target/linux/ramips/dts/mt7620a_iptime_a1004ns.dts +++ b/target/linux/ramips/dts/mt7620a_iptime_a1004ns.dts @@ -101,3 +101,7 @@ }; }; }; + +&gsw { + mediatek,ephy-base = /bits/ 8 <12>; +}; diff --git a/target/linux/ramips/dts/mt7620a_lava_lr-25g001.dts b/target/linux/ramips/dts/mt7620a_lava_lr-25g001.dts index 962ef3371d..ee845c7b5e 100644 --- a/target/linux/ramips/dts/mt7620a_lava_lr-25g001.dts +++ b/target/linux/ramips/dts/mt7620a_lava_lr-25g001.dts @@ -150,6 +150,10 @@ }; }; +&gsw { + mediatek,ephy-base = /bits/ 8 <8>; +}; + &pcie { status = "okay"; }; diff --git a/target/linux/ramips/dts/mt7620a_lb-link_bl-w1200.dts b/target/linux/ramips/dts/mt7620a_lb-link_bl-w1200.dts index bb1303d4fb..9e0b817163 100644 --- a/target/linux/ramips/dts/mt7620a_lb-link_bl-w1200.dts +++ b/target/linux/ramips/dts/mt7620a_lb-link_bl-w1200.dts @@ -135,6 +135,10 @@ }; }; +&gsw { + mediatek,ephy-base = /bits/ 8 <12>; +}; + &wmac { ralink,mtd-eeprom = <&factory 0x0>; }; diff --git a/target/linux/ramips/dts/mt7620a_lenovo_newifi-y1s.dts b/target/linux/ramips/dts/mt7620a_lenovo_newifi-y1s.dts index 0997d8a00e..0544550bf9 100644 --- a/target/linux/ramips/dts/mt7620a_lenovo_newifi-y1s.dts +++ b/target/linux/ramips/dts/mt7620a_lenovo_newifi-y1s.dts @@ -112,4 +112,5 @@ &gsw { mediatek,port4-gmac; + mediatek,ephy-base = /bits/ 8 <8>; }; diff --git a/target/linux/ramips/dts/mt7620a_linksys_e1700.dts b/target/linux/ramips/dts/mt7620a_linksys_e1700.dts index 2672d54f36..c38ea8082c 100644 --- a/target/linux/ramips/dts/mt7620a_linksys_e1700.dts +++ b/target/linux/ramips/dts/mt7620a_linksys_e1700.dts @@ -144,6 +144,10 @@ }; }; +&gsw { + mediatek,ephy-base = /bits/ 8 <12>; +}; + &wmac { ralink,mtd-eeprom = <&factory 0x0>; }; diff --git a/target/linux/ramips/dts/mt7620a_netis_wf2770.dts b/target/linux/ramips/dts/mt7620a_netis_wf2770.dts index ab8c61b1d8..f839048865 100644 --- a/target/linux/ramips/dts/mt7620a_netis_wf2770.dts +++ b/target/linux/ramips/dts/mt7620a_netis_wf2770.dts @@ -142,6 +142,10 @@ }; }; +&gsw { + mediatek,ephy-base = /bits/ 8 <12>; +}; + &pcie { status = "okay"; }; diff --git a/target/linux/ramips/dts/mt7620a_ralink_mt7620a-evb.dts b/target/linux/ramips/dts/mt7620a_ralink_mt7620a-evb.dts index 4c5baf1e50..ae35941507 100644 --- a/target/linux/ramips/dts/mt7620a_ralink_mt7620a-evb.dts +++ b/target/linux/ramips/dts/mt7620a_ralink_mt7620a-evb.dts @@ -106,6 +106,7 @@ &gsw { mediatek,port4-gmac; + mediatek,ephy-base = /bits/ 8 <8>; }; &sdhci { diff --git a/target/linux/ramips/dts/mt7620a_ralink_mt7620a-mt7530-evb.dts b/target/linux/ramips/dts/mt7620a_ralink_mt7620a-mt7530-evb.dts index b76ab2aa59..f7d8cae160 100644 --- a/target/linux/ramips/dts/mt7620a_ralink_mt7620a-mt7530-evb.dts +++ b/target/linux/ramips/dts/mt7620a_ralink_mt7620a-mt7530-evb.dts @@ -99,6 +99,10 @@ }; }; +&gsw { + mediatek,ephy-base = /bits/ 8 <12>; +}; + &pcie { status = "okay"; }; diff --git a/target/linux/ramips/dts/mt7620a_ralink_mt7620a-v22sg-evb.dts b/target/linux/ramips/dts/mt7620a_ralink_mt7620a-v22sg-evb.dts index 6e8eff50bc..0e963e1f02 100644 --- a/target/linux/ramips/dts/mt7620a_ralink_mt7620a-v22sg-evb.dts +++ b/target/linux/ramips/dts/mt7620a_ralink_mt7620a-v22sg-evb.dts @@ -100,6 +100,7 @@ &gsw { mediatek,port4-gmac; + mediatek,ephy-base = /bits/ 8 <8>; }; &pcie { diff --git a/target/linux/ramips/dts/mt7620a_sercomm_na930.dts b/target/linux/ramips/dts/mt7620a_sercomm_na930.dts index 329ecc5ea8..1ffc0a2bc8 100644 --- a/target/linux/ramips/dts/mt7620a_sercomm_na930.dts +++ b/target/linux/ramips/dts/mt7620a_sercomm_na930.dts @@ -167,6 +167,7 @@ &gsw { mediatek,port4-gmac; + mediatek,ephy-base = /bits/ 8 <8>; }; &ehci { diff --git a/target/linux/ramips/dts/mt7620a_tplink_re210-v1.dts b/target/linux/ramips/dts/mt7620a_tplink_re210-v1.dts index 247b5752ef..57cd0ed539 100644 --- a/target/linux/ramips/dts/mt7620a_tplink_re210-v1.dts +++ b/target/linux/ramips/dts/mt7620a_tplink_re210-v1.dts @@ -62,6 +62,7 @@ &gsw { mediatek,port4-gmac; + mediatek,ephy-base = /bits/ 8 <8>; }; ðernet { diff --git a/target/linux/ramips/dts/mt7620a_wavlink_wl-wn579x3.dts b/target/linux/ramips/dts/mt7620a_wavlink_wl-wn579x3.dts index 55ab939d15..bfec806c12 100644 --- a/target/linux/ramips/dts/mt7620a_wavlink_wl-wn579x3.dts +++ b/target/linux/ramips/dts/mt7620a_wavlink_wl-wn579x3.dts @@ -196,6 +196,7 @@ &gsw { mediatek,port4-gmac; + mediatek,ephy-base = /bits/ 8 <8>; }; &wmac { diff --git a/target/linux/ramips/dts/mt7620a_zyxel_keenetic-viva.dts b/target/linux/ramips/dts/mt7620a_zyxel_keenetic-viva.dts index 506b828ec8..1a5ff2d0df 100644 --- a/target/linux/ramips/dts/mt7620a_zyxel_keenetic-viva.dts +++ b/target/linux/ramips/dts/mt7620a_zyxel_keenetic-viva.dts @@ -158,6 +158,7 @@ &gsw { mediatek,port4-gmac; + mediatek,ephy-base = /bits/ 8 <8>; }; &wmac { diff --git a/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.c b/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.c index 4b030f457b..54b8b204eb 100644 --- a/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.c +++ b/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.c @@ -98,9 +98,6 @@ static void mt7620_hw_init(struct mt7620_gsw *gsw, int mdio_mode) mtk_switch_w32(gsw, mtk_switch_r32(gsw, GSW_REG_MIB_CNT_EN) | (1 << 1), GSW_REG_MIB_CNT_EN); if (mdio_mode) { - if (!gsw->ephy_base) - gsw->ephy_base = 12; - /* set MT7530 central align */ val = mt7530_mdio_r32(gsw, 0x7830); val &= ~BIT(0); @@ -115,11 +112,12 @@ static void mt7620_hw_init(struct mt7620_gsw *gsw, int mdio_mode) } if (gsw->ephy_base) { - /* set phy base addr to ephy_base */ mtk_switch_w32(gsw, mtk_switch_r32(gsw, GSW_REG_GPC1) | (gsw->ephy_base << 16), GSW_REG_GPC1); fe_reset(BIT(24)); /* Resets the Ethernet PHY block. */ + + pr_info("gsw: ephy base address: %d\n", gsw->ephy_base); } /* global page 4 */ @@ -246,7 +244,7 @@ static int mt7620_gsw_probe(struct platform_device *pdev) struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); struct mt7620_gsw *gsw; struct device_node *np = pdev->dev.of_node; - u16 val; + u8 val; gsw = devm_kzalloc(&pdev->dev, sizeof(struct mt7620_gsw), GFP_KERNEL); if (!gsw) @@ -260,7 +258,7 @@ static int mt7620_gsw_probe(struct platform_device *pdev) gsw->port4_ephy = !of_property_read_bool(np, "mediatek,port4-gmac"); - if (of_property_read_u16(np, "mediatek,ephy-base-address", &val) == 0) + if (of_property_read_u8(np, "mediatek,ephy-base", &val) == 0) gsw->ephy_base = val; else gsw->ephy_base = 0; From 47db830b827c55c7d301f4244d2270e6bd45153d Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Sun, 30 May 2021 02:02:47 -0400 Subject: [PATCH 16/23] ramips: mt7620: move mt7620_mdio_mode() to ethernet driver The function mt7620_mdio_mode is only called once and both the function and mdio_mode block have been named incorrectly, leading to confusion and useless commits. These lines in the mdio_mode block of mt7620_hw_init are only intended for boards with an external mt7530 switch. (see commit 194ca6127ee18cd3a95da4d03f02e43b5428c0bb) Therefore, move lines from mdio_mode to the place in soc_mt7620.c where the type of mt7530 switch is identified, and move lines from mt7620_mdio_mode to a main function. mt7620_mdio_mode was called from mt7620_gsw_init where the priv struct is available, so the lines must stay in mt7620_gsw_init function. In order to keep things as simple as possible, keep the DTS property related function calls together, by moving them from mt7620_gsw_probe to init. Remove the now useless DTS properties and extra phy nodes. Fixes: 5a6229a93df8 ("ramips: remove superfluous & confusing DT binding") Fixes: b85fe43ec8c4 ("ramips: mt7620: add force use of mdio-mode") Signed-off-by: Michael Pratt (cherry picked from commit 6972e498d33ec896c676b7af91e3bfb00aa846a1) --- .../ramips/dts/mt7620a_edimax_ew-747x.dtsi | 2 - .../ramips/dts/mt7620a_engenius_esr600.dts | 1 - .../ramips/dts/mt7620a_lava_lr-25g001.dts | 23 +----- .../drivers/net/ethernet/ralink/gsw_mt7620.c | 71 ++++++------------- .../drivers/net/ethernet/ralink/soc_mt7620.c | 15 ++++ 5 files changed, 38 insertions(+), 74 deletions(-) diff --git a/target/linux/ramips/dts/mt7620a_edimax_ew-747x.dtsi b/target/linux/ramips/dts/mt7620a_edimax_ew-747x.dtsi index 5cb8451547..6060fd99a6 100644 --- a/target/linux/ramips/dts/mt7620a_edimax_ew-747x.dtsi +++ b/target/linux/ramips/dts/mt7620a_edimax_ew-747x.dtsi @@ -155,8 +155,6 @@ mtd-mac-address = <&factory 0x4>; - mediatek,mdio-mode = <1>; - phy-reset-gpios = <&gpio1 15 GPIO_ACTIVE_LOW>; phy-reset-duration = <30>; diff --git a/target/linux/ramips/dts/mt7620a_engenius_esr600.dts b/target/linux/ramips/dts/mt7620a_engenius_esr600.dts index 2f0f9b256e..ea895ac6ea 100644 --- a/target/linux/ramips/dts/mt7620a_engenius_esr600.dts +++ b/target/linux/ramips/dts/mt7620a_engenius_esr600.dts @@ -144,7 +144,6 @@ mdio-bus { status = "okay"; - mediatek,mdio-mode; ethernet-phy@0 { reg = <0>; diff --git a/target/linux/ramips/dts/mt7620a_lava_lr-25g001.dts b/target/linux/ramips/dts/mt7620a_lava_lr-25g001.dts index ee845c7b5e..41d69d009b 100644 --- a/target/linux/ramips/dts/mt7620a_lava_lr-25g001.dts +++ b/target/linux/ramips/dts/mt7620a_lava_lr-25g001.dts @@ -115,9 +115,8 @@ mdio-bus { status = "okay"; - mediatek,mdio-mode = <1>; - phy0: ethernet-phy@0 { + ethernet-phy@0 { reg = <0>; phy-mode = "rgmii"; qca,ar8327-initvals = < @@ -127,26 +126,6 @@ 0x94 0x00000000 /* PORT6_STATUS */ >; }; - - phy1: ethernet-phy@1 { - reg = <1>; - phy-mode = "rgmii"; - }; - - phy2: ethernet-phy@2 { - reg = <2>; - phy-mode = "rgmii"; - }; - - phy3: ethernet-phy@3 { - reg = <3>; - phy-mode = "rgmii"; - }; - - phy4: ethernet-phy@4 { - reg = <4>; - phy-mode = "rgmii"; - }; }; }; diff --git a/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.c b/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.c index 54b8b204eb..67f70f286d 100644 --- a/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.c +++ b/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.c @@ -61,31 +61,7 @@ static irqreturn_t gsw_interrupt_mt7620(int irq, void *_priv) return IRQ_HANDLED; } -static int mt7620_mdio_mode(struct device_node *eth_node) -{ - struct device_node *phy_node, *mdiobus_node; - const __be32 *id; - int ret = 0; - - mdiobus_node = of_get_child_by_name(eth_node, "mdio-bus"); - - if (mdiobus_node) { - if (of_property_read_bool(mdiobus_node, "mediatek,mdio-mode")) - ret = 1; - - for_each_child_of_node(mdiobus_node, phy_node) { - id = of_get_property(phy_node, "reg", NULL); - if (id && (be32_to_cpu(*id) == 0x1f)) - ret = 1; - } - - of_node_put(mdiobus_node); - } - - return ret; -} - -static void mt7620_hw_init(struct mt7620_gsw *gsw, int mdio_mode) +static void mt7620_hw_init(struct mt7620_gsw *gsw) { u32 i; u32 val; @@ -97,20 +73,6 @@ static void mt7620_hw_init(struct mt7620_gsw *gsw, int mdio_mode) /* Enable MIB stats */ mtk_switch_w32(gsw, mtk_switch_r32(gsw, GSW_REG_MIB_CNT_EN) | (1 << 1), GSW_REG_MIB_CNT_EN); - if (mdio_mode) { - /* set MT7530 central align */ - val = mt7530_mdio_r32(gsw, 0x7830); - val &= ~BIT(0); - val |= BIT(1); - mt7530_mdio_w32(gsw, 0x7830, val); - - val = mt7530_mdio_r32(gsw, 0x7a40); - val &= ~BIT(30); - mt7530_mdio_w32(gsw, 0x7a40, val); - - mt7530_mdio_w32(gsw, 0x7a78, 0x855); - } - if (gsw->ephy_base) { mtk_switch_w32(gsw, mtk_switch_r32(gsw, GSW_REG_GPC1) | (gsw->ephy_base << 16), @@ -215,9 +177,13 @@ MODULE_DEVICE_TABLE(of, mediatek_gsw_match); int mtk_gsw_init(struct fe_priv *priv) { + struct device_node *eth_node = priv->dev->of_node; + struct device_node *phy_node, *mdiobus_node; struct device_node *np = priv->switch_np; struct platform_device *pdev = of_find_device_by_node(np); struct mt7620_gsw *gsw; + const __be32 *id; + u8 val; if (!pdev) return -ENODEV; @@ -228,7 +194,23 @@ int mtk_gsw_init(struct fe_priv *priv) gsw = platform_get_drvdata(pdev); priv->soc->swpriv = gsw; - mt7620_hw_init(gsw, mt7620_mdio_mode(priv->dev->of_node)); + mdiobus_node = of_get_child_by_name(eth_node, "mdio-bus"); + if (mdiobus_node) { + for_each_child_of_node(mdiobus_node, phy_node) { + id = of_get_property(phy_node, "reg", NULL); + if (id && (be32_to_cpu(*id) == 0x1f)) + of_node_put(mdiobus_node); + } + } + + gsw->port4_ephy = !of_property_read_bool(np, "mediatek,port4-gmac"); + + if (of_property_read_u8(np, "mediatek,ephy-base", &val) == 0) + gsw->ephy_base = val; + else + gsw->ephy_base = 0; + + mt7620_hw_init(gsw); if (gsw->irq) { request_irq(gsw->irq, gsw_interrupt_mt7620, 0, @@ -243,8 +225,6 @@ static int mt7620_gsw_probe(struct platform_device *pdev) { struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); struct mt7620_gsw *gsw; - struct device_node *np = pdev->dev.of_node; - u8 val; gsw = devm_kzalloc(&pdev->dev, sizeof(struct mt7620_gsw), GFP_KERNEL); if (!gsw) @@ -256,13 +236,6 @@ static int mt7620_gsw_probe(struct platform_device *pdev) gsw->dev = &pdev->dev; - gsw->port4_ephy = !of_property_read_bool(np, "mediatek,port4-gmac"); - - if (of_property_read_u8(np, "mediatek,ephy-base", &val) == 0) - gsw->ephy_base = val; - else - gsw->ephy_base = 0; - gsw->irq = platform_get_irq(pdev, 0); platform_set_drvdata(pdev, gsw); diff --git a/target/linux/ramips/files/drivers/net/ethernet/ralink/soc_mt7620.c b/target/linux/ramips/files/drivers/net/ethernet/ralink/soc_mt7620.c index 49aa4da507..d06e9da586 100644 --- a/target/linux/ramips/files/drivers/net/ethernet/ralink/soc_mt7620.c +++ b/target/linux/ramips/files/drivers/net/ethernet/ralink/soc_mt7620.c @@ -82,11 +82,26 @@ static const u16 mt7620_reg_table[FE_REG_COUNT] = { static int mt7620_gsw_config(struct fe_priv *priv) { struct mt7620_gsw *gsw = (struct mt7620_gsw *) priv->soc->swpriv; + u32 val; /* is the mt7530 internal or external */ if (priv->mii_bus && mdiobus_get_phy(priv->mii_bus, 0x1f)) { mt7530_probe(priv->dev, gsw->base, NULL, 0); mt7530_probe(priv->dev, NULL, priv->mii_bus, 1); + + /* magic values from original SDK */ + val = mt7530_mdio_r32(gsw, 0x7830); + val &= ~BIT(0); + val |= BIT(1); + mt7530_mdio_w32(gsw, 0x7830, val); + + val = mt7530_mdio_r32(gsw, 0x7a40); + val &= ~BIT(30); + mt7530_mdio_w32(gsw, 0x7a40, val); + + mt7530_mdio_w32(gsw, 0x7a78, 0x855); + + pr_info("mt7530: mdio central align\n"); } else { mt7530_probe(priv->dev, gsw->base, NULL, 1); } From 6685eb29e507ee3e6f913290c54767ba63e2ce80 Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Mon, 31 May 2021 03:56:20 -0400 Subject: [PATCH 17/23] ramips: mt7620: add ephy-disable option to switch driver Add back the register write to disable internal PHYs as a separate option in the code that can be set using a DTS property. Set the option to true by default when an external mt7530 switch is identified. This makes the driver more in sync with original SDK code while keeping the lines separated into different options to accommodate any board with any PHY layout. Signed-off-by: Michael Pratt (cherry picked from commit cc6fd6fbb505071e08011f7998afaffefcf08fd3) --- .../files/drivers/net/ethernet/ralink/gsw_mt7620.c | 14 ++++++++++++-- .../files/drivers/net/ethernet/ralink/gsw_mt7620.h | 1 + 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.c b/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.c index 67f70f286d..ae90f0484d 100644 --- a/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.c +++ b/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.c @@ -73,7 +73,13 @@ static void mt7620_hw_init(struct mt7620_gsw *gsw) /* Enable MIB stats */ mtk_switch_w32(gsw, mtk_switch_r32(gsw, GSW_REG_MIB_CNT_EN) | (1 << 1), GSW_REG_MIB_CNT_EN); - if (gsw->ephy_base) { + if (gsw->ephy_disable) { + mtk_switch_w32(gsw, mtk_switch_r32(gsw, GSW_REG_GPC1) | + (gsw->ephy_base << 16) | (0x1f << 24), + GSW_REG_GPC1); + + pr_info("gsw: internal ephy disabled\n"); + } else if (gsw->ephy_base) { mtk_switch_w32(gsw, mtk_switch_r32(gsw, GSW_REG_GPC1) | (gsw->ephy_base << 16), GSW_REG_GPC1); @@ -194,13 +200,17 @@ int mtk_gsw_init(struct fe_priv *priv) gsw = platform_get_drvdata(pdev); priv->soc->swpriv = gsw; + gsw->ephy_disable = of_property_read_bool(np, "mediatek,ephy-disable"); + mdiobus_node = of_get_child_by_name(eth_node, "mdio-bus"); if (mdiobus_node) { for_each_child_of_node(mdiobus_node, phy_node) { id = of_get_property(phy_node, "reg", NULL); if (id && (be32_to_cpu(*id) == 0x1f)) - of_node_put(mdiobus_node); + gsw->ephy_disable = true; } + + of_node_put(mdiobus_node); } gsw->port4_ephy = !of_property_read_bool(np, "mediatek,port4-gmac"); diff --git a/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.h b/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.h index 91a0399976..fde7792c02 100644 --- a/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.h +++ b/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.h @@ -92,6 +92,7 @@ struct mt7620_gsw { struct device *dev; void __iomem *base; int irq; + bool ephy_disable; bool port4_ephy; unsigned long int autopoll; u16 ephy_base; From 3f976d0225c7ba6e645a89ff17e101aede6625b3 Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Sat, 1 May 2021 14:17:11 -0400 Subject: [PATCH 18/23] ramips: mt7620: fix RGMII TXID PHY mode the register bits for TX delay and RX delay are opposites: when TX delay bit is set, delay is enabled when RX delay bit is set, delay is disabled So, when both bits are unset, it is RX delay and when both bits are set, it is TX delay Note: TXID is the default RGMII mode of the SOC Fixes: 5410a8e2959a ("ramips: mt7620: add rgmii delays support") Signed-off-by: Michael Pratt (cherry picked from commit 26c84b2e46caba1ae17bc82a533c99eee65e7004) --- .../linux/ramips/files/drivers/net/ethernet/ralink/soc_mt7620.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/linux/ramips/files/drivers/net/ethernet/ralink/soc_mt7620.c b/target/linux/ramips/files/drivers/net/ethernet/ralink/soc_mt7620.c index d06e9da586..c596de76bd 100644 --- a/target/linux/ramips/files/drivers/net/ethernet/ralink/soc_mt7620.c +++ b/target/linux/ramips/files/drivers/net/ethernet/ralink/soc_mt7620.c @@ -196,7 +196,7 @@ static void mt7620_port_init(struct fe_priv *priv, struct device_node *np) break; case PHY_INTERFACE_MODE_RGMII_TXID: mask = 0; - val_delay &= ~GSW_REG_GPCx_TXDELAY; + val_delay |= GSW_REG_GPCx_TXDELAY; val_delay |= GSW_REG_GPCx_RXDELAY; break; case PHY_INTERFACE_MODE_MII: From 30e47fb1e4f128e76b10fa3e0ff55c0497a9096a Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Sat, 1 May 2021 14:47:01 -0400 Subject: [PATCH 19/23] ramips: mt7620: ethernet: use more macros and bump version Define and use some missing macros, and use them instead of BIT() or numbers for more readable code. Add comment for a bit change that seems unrelated to ethernet but is actually needed (PCIe Root Complex mode). Remove unknown and unused macro RST_CTRL_MCM (probably from MT7621 / MT7622) This is the last of a series of fixes, so bump version. Signed-off-by: Michael Pratt (cherry picked from commit 88a0cebadfecb6ebb9f5f535e74f7f7574f513f3) --- .../ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.c | 8 +++++--- .../ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.h | 2 +- .../files/drivers/net/ethernet/ralink/mtk_eth_soc.h | 6 +++++- .../ramips/files/drivers/net/ethernet/ralink/soc_mt7620.c | 2 -- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.c b/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.c index ae90f0484d..7c91e5840b 100644 --- a/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.c +++ b/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.c @@ -65,9 +65,11 @@ static void mt7620_hw_init(struct mt7620_gsw *gsw) { u32 i; u32 val; - u32 is_BGA = (rt_sysc_r32(0x0c) >> 16) & 1; + u32 is_BGA = (rt_sysc_r32(SYSC_REG_CHIP_REV_ID) >> 16) & 1; + + /* Internal ethernet requires PCIe RC mode */ + rt_sysc_w32(rt_sysc_r32(SYSC_REG_CFG1) | PCIE_RC_MODE, SYSC_REG_CFG1); - rt_sysc_w32(rt_sysc_r32(SYSC_REG_CFG1) | BIT(8), SYSC_REG_CFG1); mtk_switch_w32(gsw, mtk_switch_r32(gsw, GSW_REG_CKGCR) & ~(0x3 << 4), GSW_REG_CKGCR); /* Enable MIB stats */ @@ -83,7 +85,7 @@ static void mt7620_hw_init(struct mt7620_gsw *gsw) mtk_switch_w32(gsw, mtk_switch_r32(gsw, GSW_REG_GPC1) | (gsw->ephy_base << 16), GSW_REG_GPC1); - fe_reset(BIT(24)); /* Resets the Ethernet PHY block. */ + fe_reset(MT7620A_RESET_EPHY); pr_info("gsw: ephy base address: %d\n", gsw->ephy_base); } diff --git a/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.h b/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.h index fde7792c02..cb5d098e9c 100644 --- a/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.h +++ b/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.h @@ -55,7 +55,7 @@ #define SYSC_REG_CHIP_REV_ID 0x0c #define SYSC_REG_CFG1 0x14 -#define RST_CTRL_MCM BIT(2) +#define PCIE_RC_MODE BIT(8) #define SYSC_PAD_RGMII2_MDIO 0x58 #define SYSC_GPIO_MODE 0x60 diff --git a/target/linux/ramips/files/drivers/net/ethernet/ralink/mtk_eth_soc.h b/target/linux/ramips/files/drivers/net/ethernet/ralink/mtk_eth_soc.h index 00f1a0e7e6..c8517f9f9d 100644 --- a/target/linux/ramips/files/drivers/net/ethernet/ralink/mtk_eth_soc.h +++ b/target/linux/ramips/files/drivers/net/ethernet/ralink/mtk_eth_soc.h @@ -49,7 +49,7 @@ enum fe_work_flag { FE_FLAG_MAX }; -#define MTK_FE_DRV_VERSION "0.1.2" +#define MTK_FE_DRV_VERSION "0.2" /* power of 2 to let NEXT_TX_DESP_IDX work */ #define NUM_DMA_DESC BIT(10) @@ -157,6 +157,10 @@ enum fe_work_flag { #define MT7620A_FE_GDMA1_MAC_ADRL (MT7620A_GDMA_OFFSET + 0x0C) #define MT7620A_FE_GDMA1_MAC_ADRH (MT7620A_GDMA_OFFSET + 0x10) +#define MT7620A_RESET_FE BIT(21) +#define MT7620A_RESET_ESW BIT(23) +#define MT7620A_RESET_EPHY BIT(24) + #define RT5350_TX_BASE_PTR0 (RT5350_PDMA_OFFSET + 0x00) #define RT5350_TX_MAX_CNT0 (RT5350_PDMA_OFFSET + 0x04) #define RT5350_TX_CTX_IDX0 (RT5350_PDMA_OFFSET + 0x08) diff --git a/target/linux/ramips/files/drivers/net/ethernet/ralink/soc_mt7620.c b/target/linux/ramips/files/drivers/net/ethernet/ralink/soc_mt7620.c index c596de76bd..2470e7a3c1 100644 --- a/target/linux/ramips/files/drivers/net/ethernet/ralink/soc_mt7620.c +++ b/target/linux/ramips/files/drivers/net/ethernet/ralink/soc_mt7620.c @@ -27,8 +27,6 @@ #define MT7620A_CDMA_CSG_CFG 0x400 #define MT7620_DMA_VID (MT7620A_CDMA_CSG_CFG | 0x30) -#define MT7620A_RESET_FE BIT(21) -#define MT7620A_RESET_ESW BIT(23) #define MT7620_L4_VALID BIT(23) #define MT7620_TX_DMA_UDF BIT(15) From 1769e3162e02ebe372274836ae6ad75a0391f50d Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Tue, 20 Apr 2021 12:35:47 -0400 Subject: [PATCH 20/23] ramips: mt7620: disable SOC VLANs for external switches These boards have AR8327 or QCA8337 external ethernet switch. The SOC also has it's own internal switch where VLAN is now enabled by default. Changes to preinit caused all switches to have VLANs enabled by default even if they are not configured with a topology in uci_defaults (see commit f017f617aecbd47debd4d3a734dc0e471342db96) When both internal and external switches have VLANs, and the external switch has both LAN and WAN, the TX traffic from the SOC cannot flow to the tagged port on the external switch because the VLAN IDs are not matching. So disable the internal switch VLANs by default on these boards. Also, add a topology for the internal switch, so that on LuCI there is not an "unknown topology" warning. In theory, it may be possible to have LAN ports on both switches through internal and external PHYs, but there are no known boards that have this. Signed-off-by: Michael Pratt (cherry picked from commit 2adeada04558848058105cdad8195848d10d1486) --- .../linux/ramips/mt7620/base-files/etc/board.d/02_network | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/target/linux/ramips/mt7620/base-files/etc/board.d/02_network b/target/linux/ramips/mt7620/base-files/etc/board.d/02_network index 5ebffbaf7d..e867b58aed 100755 --- a/target/linux/ramips/mt7620/base-files/etc/board.d/02_network +++ b/target/linux/ramips/mt7620/base-files/etc/board.d/02_network @@ -137,6 +137,9 @@ ramips_setup_interfaces() engenius,esr600) ucidef_add_switch "switch0" \ "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan" "0@eth0" + ucidef_add_switch "switch1" \ + "5:lan" "6@eth0" + ucidef_add_switch_attr "switch1" "enable" "false" ;; fon,fon2601) ucidef_add_switch "switch0" \ @@ -169,6 +172,9 @@ ramips_setup_interfaces() lava,lr-25g001) ucidef_add_switch "switch0" \ "1:lan" "2:lan" "3:lan" "4:lan" "5:wan" "0@eth0" + ucidef_add_switch "switch1" \ + "5:lan" "6@eth0" + ucidef_add_switch_attr "switch1" "enable" "false" ;; lenovo,newifi-y1|\ xiaomi,miwifi-mini) From 39f1815b3eee1a7057d0475c9ac193e7e52e0bb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibaut=20VAR=C3=88NE?= Date: Tue, 19 Apr 2022 10:59:41 +0200 Subject: [PATCH 21/23] mac80211: fix QCA9561 PA bias MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch fixes an invalid TX PA DC bias level on QCA9561, which results in a very low output power and very low throughput as devices are further away from the AP (compared to other 2.4GHz APs), following a suggestion from nbd[1]. This patch has been submitted upstream[2]. [1] https://lore.kernel.org/all/91c58969-c60e-2f41-00ac-737786d435ae@nbd.name [2] https://lore.kernel.org/linux-wireless/20220417145145.1847-1-hacks+kernel@slashdirt.org/ Signed-off-by: Thibaut VARÈNE (cherry-picked from 7dc52a78ae2c2f748a0c0c4adcb13979260b3498) --- .../ath/580-ath9k_ar9561_fix_bias_level.patch | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 package/kernel/mac80211/patches/ath/580-ath9k_ar9561_fix_bias_level.patch diff --git a/package/kernel/mac80211/patches/ath/580-ath9k_ar9561_fix_bias_level.patch b/package/kernel/mac80211/patches/ath/580-ath9k_ar9561_fix_bias_level.patch new file mode 100644 index 0000000000..e4c2e1cd02 --- /dev/null +++ b/package/kernel/mac80211/patches/ath/580-ath9k_ar9561_fix_bias_level.patch @@ -0,0 +1,47 @@ +From 4509e523dba46f789377cfec6f20579adf743416 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Thibaut=20VAR=C3=88NE?= +Date: Sun, 17 Apr 2022 11:31:35 +0200 +Subject: [PATCH v2] ath9k: fix QCA9561 PA bias level +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This patch fixes an invalid TX PA DC bias level on QCA9561, which +results in a very low output power and very low throughput as devices +are further away from the AP (compared to other 2.4GHz APs). + +This patch was suggested by Felix Fietkau, who noted[1]: +"The value written to that register is wrong, because while the mask +definition AR_CH0_TOP2_XPABIASLVL uses a different value for 9561, the +shift definition AR_CH0_TOP2_XPABIASLVL_S is hardcoded to 12, which is +wrong for 9561." + +In real life testing, without this patch the 2.4GHz throughput on +Yuncore XD3200 is around 10Mbps sitting next to the AP, and closer to +practical maximum with the patch applied. + +[1] https://lore.kernel.org/all/91c58969-c60e-2f41-00ac-737786d435ae@nbd.name + +Signed-off-by: Thibaut VARÈNE +--- +v2: Adjust #define per Felix's suggestion +--- + drivers/net/wireless/ath/ath9k/ar9003_phy.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/net/wireless/ath/ath9k/ar9003_phy.h b/drivers/net/wireless/ath/ath9k/ar9003_phy.h +index a171dbb29..ad949eb02 100644 +--- a/drivers/net/wireless/ath/ath9k/ar9003_phy.h ++++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.h +@@ -720,7 +720,7 @@ + #define AR_CH0_TOP2 (AR_SREV_9300(ah) ? 0x1628c : \ + (AR_SREV_9462(ah) ? 0x16290 : 0x16284)) + #define AR_CH0_TOP2_XPABIASLVL (AR_SREV_9561(ah) ? 0x1e00 : 0xf000) +-#define AR_CH0_TOP2_XPABIASLVL_S 12 ++#define AR_CH0_TOP2_XPABIASLVL_S (AR_SREV_9561(ah) ? 9 : 12) + + #define AR_CH0_XTAL (AR_SREV_9300(ah) ? 0x16294 : \ + ((AR_SREV_9462(ah) || AR_SREV_9565(ah)) ? 0x16298 : \ +-- +2.30.2 + From 1418439da9ed2dbd4b097298c51ee70629fe10d3 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Tue, 19 Apr 2022 21:14:42 +0200 Subject: [PATCH 22/23] kernel: add missing config symbols MPLS feature symbols are normally only set when kmod-mpls is enabled, but the CONFIG_MPLS symbol they depend on could also have been selected by openvswitch instead Signed-off-by: Felix Fietkau (cherry-picked from commit 92add80414c2f39ba8fd0d221d0f37e75fb19951) --- target/linux/generic/config-5.4 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/target/linux/generic/config-5.4 b/target/linux/generic/config-5.4 index 73ba6afc6e..3517ece49c 100644 --- a/target/linux/generic/config-5.4 +++ b/target/linux/generic/config-5.4 @@ -3148,6 +3148,8 @@ CONFIG_MODULE_UNLOAD=y # CONFIG_MPL115_SPI is not set # CONFIG_MPL3115 is not set # CONFIG_MPLS is not set +# CONFIG_MPLS_IPTUNNEL is not set +# CONFIG_MPLS_ROUTING is not set # CONFIG_MPU3050_I2C is not set # CONFIG_MQ_IOSCHED_DEADLINE is not set # CONFIG_MQ_IOSCHED_KYBER is not set From 75cbd8de006698a766126da682d8ae621bc7b0d4 Mon Sep 17 00:00:00 2001 From: Eneas U de Queiroz Date: Wed, 13 Apr 2022 10:30:15 -0300 Subject: [PATCH 23/23] wolfssl: fix compilation with /dev/crypto This is trivial fix of a duplicate definition of 'int ret'. Signed-off-by: Eneas U de Queiroz (cherry picked from commit df622768da10f36ceeb20346b4c4ee4eb9a8a9ad) --- ...rt-devcrypto-devcrypto_aes.c-remove-.patch | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 package/libs/wolfssl/patches/400-wolfcrypt-src-port-devcrypto-devcrypto_aes.c-remove-.patch diff --git a/package/libs/wolfssl/patches/400-wolfcrypt-src-port-devcrypto-devcrypto_aes.c-remove-.patch b/package/libs/wolfssl/patches/400-wolfcrypt-src-port-devcrypto-devcrypto_aes.c-remove-.patch new file mode 100644 index 0000000000..3c0c0a07af --- /dev/null +++ b/package/libs/wolfssl/patches/400-wolfcrypt-src-port-devcrypto-devcrypto_aes.c-remove-.patch @@ -0,0 +1,19 @@ +From 096889927d9528d4fbeb3aab56d1fe8225d2e7ec Mon Sep 17 00:00:00 2001 +From: Daniel Pouzzner +Date: Thu, 14 Apr 2022 20:23:31 -0500 +Subject: [PATCH] wolfcrypt/src/port/devcrypto/devcrypto_aes.c: remove + redundant "int ret" in wc_AesCtrEncrypt() (supersedes #5052). + + +diff --git a/wolfcrypt/src/port/devcrypto/devcrypto_aes.c b/wolfcrypt/src/port/devcrypto/devcrypto_aes.c +index 3bc1d5bb1..28e145e27 100644 +--- a/wolfcrypt/src/port/devcrypto/devcrypto_aes.c ++++ b/wolfcrypt/src/port/devcrypto/devcrypto_aes.c +@@ -208,7 +208,6 @@ int wc_AesCtrEncrypt(Aes* aes, byte* out, const byte* in, word32 sz) + int ret; + struct crypt_op crt; + byte* tmp; +- int ret; + + if (aes == NULL || out == NULL || in == NULL) { + return BAD_FUNC_ARG;