ramips: XiaoYu-C5: reuse ralink-eth driver (#5605)

* treewide: remove support for 'DEVICE_COMPAT' variable

This commit removes support for the DEVICE_COMPAT variable due to it
requires relatively few changes.

* Revert "ramips: disable PORT 5 MAC RX/TX flow control by default"

The TX/RX flow control is not the cause of the TX timeouts issue

Signed-off-by: Chen Minqiang <ptpt52@gmail.com>

* ramips: net/mediatek fix logical error

fe_empty_txd() should return `tx_ring_size - 1` on ring empty, and
return 0 on ring full.

Signed-off-by: Chen Minqiang <ptpt52@gmail.com>

* ramips: net/mediatek disable eee

This disable eee for mt7530 ports, it causes the link down/up
issue, which happens when connecting to 100Mbit switch

Fixes: FS#1449

Signed-off-by: Chen Minqiang <ptpt52@gmail.com>

* ramips: XiaoYu-C5: reuse ralink-eth driver

Co-authored-by: Chen Minqiang <ptpt52@gmail.com>
This commit is contained in:
AmadeusGhost 2020-10-07 23:20:11 +08:00 committed by GitHub
parent 71e335c0be
commit 8de358af76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 44 additions and 85 deletions

View File

@ -391,24 +391,13 @@ define Build/tplink-v2-image
rm -rf $@.new
endef
compat_version=$(if $(DEVICE_COMPAT_VERSION),$(DEVICE_COMPAT_VERSION),1.0)
json_quote=$(subst ','\'',$(subst ",\",$(1)))
#")')
legacy_supported_message=$(SUPPORTED_DEVICES) - Image version mismatch: image $(compat_version), \
device 1.0. Please wipe config during upgrade (force required) or reinstall. \
$(if $(DEVICE_COMPAT_MESSAGE),Reason: $(DEVICE_COMPAT_MESSAGE),Please check documentation ...)
metadata_devices=$(if $(1),$(subst "$(space)","$(comma)",$(strip $(foreach v,$(1),"$(call json_quote,$(v))"))))
metadata_json = \
'{ $(if $(IMAGE_METADATA),$(IMAGE_METADATA)$(comma)) \
"metadata_version": "1.1", \
"compat_version": "$(call json_quote,$(compat_version))", \
$(if $(DEVICE_COMPAT_MESSAGE),"compat_message": "$(call json_quote,$(DEVICE_COMPAT_MESSAGE))"$(comma)) \
$(if $(filter-out 1.0,$(compat_version)),"new_supported_devices": \
[$(call metadata_devices,$(SUPPORTED_DEVICES))]$(comma) \
"supported_devices": ["$(call json_quote,$(legacy_supported_message))"]$(comma)) \
$(if $(filter 1.0,$(compat_version)),"supported_devices":[$(call metadata_devices,$(SUPPORTED_DEVICES))]$(comma)) \
"metadata_version": "1.0", \
"supported_devices":[$(call metadata_devices,$(1))], \
"version": { \
"dist": "$(call json_quote,$(VERSION_DIST))", \
"version": "$(call json_quote,$(VERSION_NUMBER))", \
@ -419,7 +408,7 @@ metadata_json = \
}'
define Build/append-metadata
$(if $(SUPPORTED_DEVICES),-echo $(call metadata_json) | fwtool -I - $@)
$(if $(SUPPORTED_DEVICES),-echo $(call metadata_json,$(SUPPORTED_DEVICES)) | fwtool -I - $@)
[ ! -s "$(BUILD_KEY)" -o ! -s "$(BUILD_KEY).ucert" -o ! -s "$@" ] || { \
cp "$(BUILD_KEY).ucert" "$@.ucert" ;\
usign -S -m "$@" -s "$(BUILD_KEY)" -x "$@.sig" ;\

View File

@ -419,8 +419,6 @@ define Device/Init
BOARD_NAME :=
UIMAGE_NAME :=
DEVICE_COMPAT_VERSION := 1.0
DEVICE_COMPAT_MESSAGE :=
SUPPORTED_DEVICES :=
IMAGE_METADATA :=
@ -438,7 +436,6 @@ DEFAULT_DEVICE_VARS := \
VID_HDR_OFFSET UBINIZE_OPTS UBINIZE_PARTS MKUBIFS_OPTS DEVICE_DTS \
DEVICE_DTS_CONFIG DEVICE_DTS_DIR SOC BOARD_NAME UIMAGE_NAME SUPPORTED_DEVICES \
IMAGE_METADATA KERNEL_ENTRY KERNEL_LOADADDR UBOOT_PATH IMAGE_SIZE \
DEVICE_COMPAT_VERSION DEVICE_COMPAT_MESSAGE \
DEVICE_VENDOR DEVICE_MODEL DEVICE_VARIANT \
DEVICE_ALT0_VENDOR DEVICE_ALT0_MODEL DEVICE_ALT0_VARIANT \
DEVICE_ALT1_VENDOR DEVICE_ALT1_MODEL DEVICE_ALT1_VARIANT \

View File

@ -1073,12 +1073,6 @@ define Device/meraki_mr16
IMAGE_SIZE := 15616k
DEVICE_PACKAGES := kmod-owl-loader
SUPPORTED_DEVICES += mr16
DEVICE_COMPAT_VERSION := 2.0
DEVICE_COMPAT_MESSAGE := Partitions differ from ar71xx version of MR16. Image format is incompatible. \
To use sysupgrade, you must change /lib/update/common.sh::get_image to prepend 128K zeroes to this image, \
and change the bootcmd in u-boot to "bootm 0xbf0a0000". After that, you can use "sysupgrade -F". \
For more details, see the OpenWrt Wiki: https://openwrt.org/toh/meraki/mr16, \
or the commit message of the MR16 ath79 port on git.openwrt.org.
endef
TARGET_DEVICES += meraki_mr16

View File

@ -10,11 +10,6 @@ include $(INCLUDE_DIR)/image.mk
KERNEL_LOADADDR:=0x8000
define Device/dsa-migration
DEVICE_COMPAT_VERSION := 1.1
DEVICE_COMPAT_MESSAGE := Config cannot be migrated from swconfig to DSA
endef
define Device/Default
PROFILES := Default
DEVICE_DTS = kirkwood-$(lastword $(subst _, ,$(1)))
@ -107,7 +102,6 @@ endef
define Device/linksys_e4200-v2
$(Device/linksys)
$(Device/dsa-migration)
DEVICE_MODEL := E4200
DEVICE_VARIANT := v2
KERNEL_SIZE := 2688k
@ -117,7 +111,6 @@ TARGET_DEVICES += linksys_e4200-v2
define Device/linksys_ea3500
$(Device/linksys)
$(Device/dsa-migration)
DEVICE_MODEL := EA3500
PAGESIZE := 512
SUBPAGESIZE := 256
@ -129,7 +122,6 @@ TARGET_DEVICES += linksys_ea3500
define Device/linksys_ea4500
$(Device/linksys)
$(Device/dsa-migration)
DEVICE_MODEL := EA4500
KERNEL_SIZE := 2688k
SUPPORTED_DEVICES += linksys,viper linksys-viper

View File

@ -6,11 +6,6 @@
# See /LICENSE for more information.
#
define Device/dsa-migration
DEVICE_COMPAT_VERSION := 1.1
DEVICE_COMPAT_MESSAGE := Config cannot be migrated from swconfig to DSA
endef
define Device/buffalo_ls421de
$(Device/NAND-128K)
DEVICE_VENDOR := Buffalo
@ -82,7 +77,6 @@ endef
define Device/linksys_wrt1200ac
$(call Device/linksys)
$(Device/dsa-migration)
DEVICE_MODEL := WRT1200AC
DEVICE_ALT0_VENDOR := Linksys
DEVICE_ALT0_MODEL := Caiman
@ -94,7 +88,6 @@ TARGET_DEVICES += linksys_wrt1200ac
define Device/linksys_wrt1900acs
$(call Device/linksys)
$(Device/dsa-migration)
DEVICE_MODEL := WRT1900ACS
DEVICE_VARIANT := v1
DEVICE_ALT0_VENDOR := Linksys
@ -110,7 +103,6 @@ TARGET_DEVICES += linksys_wrt1900acs
define Device/linksys_wrt1900ac-v1
$(call Device/linksys)
$(Device/dsa-migration)
DEVICE_MODEL := WRT1900AC
DEVICE_VARIANT := v1
DEVICE_ALT0_VENDOR := Linksys
@ -125,7 +117,6 @@ TARGET_DEVICES += linksys_wrt1900ac-v1
define Device/linksys_wrt1900ac-v2
$(call Device/linksys)
$(Device/dsa-migration)
DEVICE_MODEL := WRT1900AC
DEVICE_VARIANT := v2
DEVICE_ALT0_VENDOR := Linksys
@ -138,7 +129,6 @@ TARGET_DEVICES += linksys_wrt1900ac-v2
define Device/linksys_wrt3200acm
$(call Device/linksys)
$(Device/dsa-migration)
DEVICE_MODEL := WRT3200ACM
DEVICE_ALT0_VENDOR := Linksys
DEVICE_ALT0_MODEL := Rango
@ -150,7 +140,6 @@ TARGET_DEVICES += linksys_wrt3200acm
define Device/linksys_wrt32x
$(call Device/linksys)
$(Device/dsa-migration)
DEVICE_MODEL := WRT32X
DEVICE_ALT0_VENDOR := Linksys
DEVICE_ALT0_MODEL := Venom
@ -247,13 +236,10 @@ define Device/solidrun_clearfog-base-a1
UBOOT := clearfog-u-boot-spl.kwb
BOOT_SCRIPT := clearfog
SUPPORTED_DEVICES += armada-388-clearfog-base
DEVICE_COMPAT_VERSION := 1.1
DEVICE_COMPAT_MESSAGE := Ethernet interface rename has been dropped
endef
TARGET_DEVICES += solidrun_clearfog-base-a1
define Device/solidrun_clearfog-pro-a1
$(Device/dsa-migration)
DEVICE_VENDOR := SolidRun
DEVICE_MODEL := ClearFog Pro
KERNEL_INSTALL := 1

View File

@ -14,7 +14,7 @@
led-failsafe = &led_sys;
led-running = &led_sys;
led-upgrade = &led_sys;
label-mac-device = &gmac0;
label-mac-device = &ethernet;
};
chosen {
@ -90,39 +90,19 @@
status = "okay";
};
&gmac0 {
&ethernet {
compatible = "mediatek,ralink-mt7621-eth";
mediatek,switch = <&gsw>;
mtd-mac-address = <&factory 0x4>;
};
&switch0 {
ports {
port@0 {
status = "okay";
label = "lan1";
};
/delete-property/ compatible;
phy-mode = "rgmii";
};
port@1 {
status = "okay";
label = "lan2";
};
port@2 {
status = "okay";
label = "lan3";
};
port@3 {
status = "okay";
label = "lan4";
};
port@4 {
status = "okay";
label = "wan";
mtd-mac-address = <&factory 0x4>;
mtd-mac-address-increment = <1>;
};
};
&gsw {
compatible = "mediatek,ralink-mt7621-gsw";
};
&state_default {

View File

@ -98,9 +98,15 @@ static void mt7621_hw_init(struct mt7620_gsw *gsw, struct device_node *np)
mt7530_mdio_w32(gsw, 0x7000, 0x3);
usleep_range(10, 20);
/* (GE1, Force 1000M/FD, FC OFF, MAX_RX_LENGTH 1536) */
mtk_switch_w32(gsw, 0x2305e30b, GSW_REG_MAC_P0_MCR);
mt7530_mdio_w32(gsw, 0x3600, 0x5e30b);
if ((rt_sysc_r32(SYSC_REG_CHIP_REV_ID) & 0xFFFF) == 0x0101) {
/* (GE1, Force 1000M/FD, FC ON, MAX_RX_LENGTH 1536) */
mtk_switch_w32(gsw, 0x2305e30b, GSW_REG_MAC_P0_MCR);
mt7530_mdio_w32(gsw, 0x3600, 0x5e30b);
} else {
/* (GE1, Force 1000M/FD, FC ON, MAX_RX_LENGTH 1536) */
mtk_switch_w32(gsw, 0x2305e33b, GSW_REG_MAC_P0_MCR);
mt7530_mdio_w32(gsw, 0x3600, 0x5e33b);
}
/* (GE2, Link down) */
mtk_switch_w32(gsw, 0x8000, GSW_REG_MAC_P1_MCR);
@ -180,6 +186,22 @@ static void mt7621_hw_init(struct mt7620_gsw *gsw, struct device_node *np)
mt7530_mdio_w32(gsw, 0x7a74, 0x44);
mt7530_mdio_w32(gsw, 0x7a7c, 0x44);
/* Disable EEE */
for (i = 0; i <= 4; i++) {
_mt7620_mii_write(gsw, i, 13, 0x7);
_mt7620_mii_write(gsw, i, 14, 0x3C);
_mt7620_mii_write(gsw, i, 13, 0x4007);
_mt7620_mii_write(gsw, i, 14, 0x0);
}
/* Disable EEE 10Base-Te */
for (i = 0; i <= 4; i++) {
_mt7620_mii_write(gsw, i, 13, 0x1f);
_mt7620_mii_write(gsw, i, 14, 0x027b);
_mt7620_mii_write(gsw, i, 13, 0x401f);
_mt7620_mii_write(gsw, i, 14, 0x1177);
}
/* turn on all PHYs */
for (i = 0; i <= 4; i++) {
val = _mt7620_mii_read(gsw, i, 0);

View File

@ -564,7 +564,7 @@ static inline u32 fe_empty_txd(struct fe_tx_ring *ring)
barrier();
return (u32)(ring->tx_ring_size -
((ring->tx_next_idx - ring->tx_free_idx) &
(ring->tx_ring_size - 1)));
(ring->tx_ring_size - 1)) - 1);
}
struct fe_map_state {

View File

@ -58,7 +58,8 @@ ramips_setup_interfaces()
motorola,mr2600)
ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4 ra0 rai0" "wan"
;;
phicomm,k2p)
phicomm,k2p|\
xiaoyu,xy-c5)
ucidef_add_switch "switch0" \
"0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "6@eth0"
ucidef_set_interface_lan "eth0.1 ra0 rax0"
@ -76,7 +77,7 @@ ramips_setup_interfaces()
;;
xiaomi,mir4)
ucidef_add_switch "switch0" \
"1:lan:1" "2:lan:2" "4:wan" "6t@eth0"
"1:lan:2" "2:lan:1" "4:wan" "6t@eth0"
ucidef_set_interface_lan "eth0.1 ra0 rai0"
;;
xiaomi,mi-router-ac2100|\
@ -161,6 +162,9 @@ ramips_setup_macs()
lan_mac=$(mtd_get_mac_binary factory 0xe006)
wan_mac=$(mtd_get_mac_binary factory 0xe000)
;;
xiaoyu,xy-c5)
wan_mac=$(macaddr_add "$(mtd_get_mac_binary factory 0x4)" 1)
;;
zbtlink,zbt-we1326|\
zbtlink,zbt-wg3526-16m|\
zbtlink,zbt-wg3526-32m)

View File

@ -1,5 +0,0 @@
uci -q get network.globals.packet_steering > /dev/null || {
uci set network.globals='globals'
uci set network.globals.packet_steering=1
uci commit network
}