From 45ddd9f782e257c3b9654840f6429b2bcfc44065 Mon Sep 17 00:00:00 2001 From: AmadeusGhost <42570690+AmadeusGhost@users.noreply.github.com> Date: Fri, 3 Jul 2020 17:53:29 +0800 Subject: [PATCH 1/2] ipq40xx: r619ac: fix wan/lan led --- .../ipq40xx/base-files/etc/board.d/01_leds | 7 +++- .../ipq40xx/base-files/etc/board.d/02_network | 9 +++-- .../705-net-add-qualcomm-ar40xx-phy.patch | 35 ++++++++++++++++++- .../705-net-add-qualcomm-ar40xx-phy.patch | 35 ++++++++++++++++++- 4 files changed, 80 insertions(+), 6 deletions(-) diff --git a/target/linux/ipq40xx/base-files/etc/board.d/01_leds b/target/linux/ipq40xx/base-files/etc/board.d/01_leds index 1ce040853..735c61ee3 100755 --- a/target/linux/ipq40xx/base-files/etc/board.d/01_leds +++ b/target/linux/ipq40xx/base-files/etc/board.d/01_leds @@ -22,7 +22,7 @@ asus,rt-acrh17) ucidef_set_led_default "status" "STATUS" "${boardname}:blue:status" "1" ucidef_set_led_wlan "wlan2g" "WLAN2G" "${boardname}:blue:wlan2g" "phy1tpt" ucidef_set_led_wlan "wlan5g" "WLAN5G" "${boardname}:blue:wlan5g" "phy0tpt" - ucidef_set_led_switch "wan" "WAN(blue)" "${boardname}:blue:wan" "switch0" "0x20" + ucidef_set_led_netdev "wan" "WAN" "${boardname}:blue:wan" "eth1" ucidef_set_led_switch "lan1" "LAN1" "${boardname}:blue:lan1" "switch0" "0x02" ucidef_set_led_switch "lan2" "LAN2" "${boardname}:blue:lan2" "switch0" "0x04" ucidef_set_led_switch "lan3" "LAN3" "${boardname}:blue:lan3" "switch0" "0x08" @@ -63,6 +63,11 @@ netgear,ex6150v2) ucidef_set_led_wlan "wlan2g" "WLAN2G" "ex61x0v2:green:router" "phy0tpt" ucidef_set_led_wlan "wlan5g" "WLAN5G" "ex61x0v2:green:client" "phy1tpt" ;; +p2w,r619ac |\ +p2w,r619ac-128m) + ucidef_set_led_wlan "wlan2g" "WLAN2G" "r619ac:blue:wlan2g" "phy0tpt" + ucidef_set_led_wlan "wlan5g" "WLAN5G" "r619ac:blue:wlan5g" "phy1tpt" + ;; qxwlan,e2600ac-c1 |\ qxwlan,e2600ac-c2) ucidef_set_led_wlan "wlan2g" "WLAN0" "e2600ac:green:wlan0" "phy0tpt" diff --git a/target/linux/ipq40xx/base-files/etc/board.d/02_network b/target/linux/ipq40xx/base-files/etc/board.d/02_network index 72b96cd47..06070ee5b 100755 --- a/target/linux/ipq40xx/base-files/etc/board.d/02_network +++ b/target/linux/ipq40xx/base-files/etc/board.d/02_network @@ -117,9 +117,7 @@ ipq40xx_setup_macs() label_mac=$(mtd_get_mac_binary "ART" 0x1006) ;; asus,rt-acrh17|\ - asus,rt-ac58u|\ - p2w,r619ac-128m|\ - p2w,r619ac) + asus,rt-ac58u) CI_UBIPART=UBI_DEV wan_mac=$(mtd_get_mac_binary_ubi Factory 0x1006) lan_mac=$(mtd_get_mac_binary_ubi Factory 0x5006) @@ -153,6 +151,11 @@ ipq40xx_setup_macs() wan_mac=$(mtd_get_mac_ascii devinfo hw_mac_addr) lan_mac=$(macaddr_add "$wan_mac" 1) ;; + p2w,r619ac|\ + p2w,r619ac-128m) + wan_mac=$(cat /sys/class/net/eth0/address) + lan_mac=$(macaddr_add "$wan_mac" 1) + ;; esac [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac diff --git a/target/linux/ipq40xx/patches-4.19/705-net-add-qualcomm-ar40xx-phy.patch b/target/linux/ipq40xx/patches-4.19/705-net-add-qualcomm-ar40xx-phy.patch index 4247ef10c..bc75aab08 100644 --- a/target/linux/ipq40xx/patches-4.19/705-net-add-qualcomm-ar40xx-phy.patch +++ b/target/linux/ipq40xx/patches-4.19/705-net-add-qualcomm-ar40xx-phy.patch @@ -26,7 +26,7 @@ obj-$(CONFIG_BCM63XX_PHY) += bcm63xx.o --- /dev/null +++ b/drivers/net/phy/ar40xx.c -@@ -0,0 +1,2090 @@ +@@ -0,0 +1,2122 @@ +/* + * Copyright (c) 2016, The Linux Foundation. All rights reserved. + * @@ -799,6 +799,37 @@ + return 0; +} + ++static int ++ar40xx_sw_get_port_stats(struct switch_dev *dev, int port, ++ struct switch_port_stats *stats) ++{ ++ struct ar40xx_priv *priv = swdev_to_ar40xx(dev); ++ u32 num_mibs = ARRAY_SIZE(ar40xx_mibs); ++ u64 *mib_stats; ++ int ret = 0; ++ static int last_port = AR40XX_NUM_PORTS - 1; ++ ++ mutex_lock(&priv->mib_lock); ++ ++ /* Avoid unnecessary capture */ ++ if (last_port >= port) { ++ ret = ar40xx_mib_capture(priv); ++ if (ret) ++ goto unlock; ++ } ++ last_port = port; ++ ++ ar40xx_mib_fetch_port_stat(priv, port, false); ++ ++ mib_stats = &priv->mib_stats[port * num_mibs]; ++ /* 15: TXBYTE, 31: RXGOODBYTE */ ++ stats->tx_bytes = mib_stats[15]; ++ stats->rx_bytes = mib_stats[31]; ++unlock: ++ mutex_unlock(&priv->mib_lock); ++ return ret; ++} ++ +static const struct switch_attr ar40xx_sw_attr_globals[] = { + { + .type = SWITCH_TYPE_INT, @@ -1177,6 +1208,7 @@ + /* disable phy internal loopback */ + mdiobus_write(bus, 0x1f, 0x10, 0x6860); + mdiobus_write(bus, 0x1f, 0x0, 0x9040); ++ ar40xx_phy_mmd_write(priv, 0x1f, 7, 0x8076, 0x0670); /* 1000_LED_n */ + + for (phy = 0; phy < AR40XX_NUM_PORTS - 1; phy++) { + /* disable mac loop back */ @@ -1788,6 +1820,7 @@ + .apply_config = ar40xx_sw_hw_apply, + .reset_switch = ar40xx_sw_reset_switch, + .get_port_link = ar40xx_sw_get_port_link, ++ .get_port_stats = ar40xx_sw_get_port_stats, +}; + +/* Start of phy driver support */ diff --git a/target/linux/ipq40xx/patches-5.4/705-net-add-qualcomm-ar40xx-phy.patch b/target/linux/ipq40xx/patches-5.4/705-net-add-qualcomm-ar40xx-phy.patch index 083de038a..d98f3109d 100644 --- a/target/linux/ipq40xx/patches-5.4/705-net-add-qualcomm-ar40xx-phy.patch +++ b/target/linux/ipq40xx/patches-5.4/705-net-add-qualcomm-ar40xx-phy.patch @@ -26,7 +26,7 @@ obj-$(CONFIG_BCM63XX_PHY) += bcm63xx.o --- /dev/null +++ b/drivers/net/phy/ar40xx.c -@@ -0,0 +1,2090 @@ +@@ -0,0 +1,2123 @@ +/* + * Copyright (c) 2016, The Linux Foundation. All rights reserved. + * @@ -799,6 +799,37 @@ + return 0; +} + ++static int ++ar40xx_sw_get_port_stats(struct switch_dev *dev, int port, ++ struct switch_port_stats *stats) ++{ ++ struct ar40xx_priv *priv = swdev_to_ar40xx(dev); ++ u32 num_mibs = ARRAY_SIZE(ar40xx_mibs); ++ u64 *mib_stats; ++ int ret = 0; ++ static int last_port = AR40XX_NUM_PORTS - 1; ++ ++ mutex_lock(&priv->mib_lock); ++ ++ /* Avoid unnecessary capture */ ++ if (last_port >= port) { ++ ret = ar40xx_mib_capture(priv); ++ if (ret) ++ goto unlock; ++ } ++ last_port = port; ++ ++ ar40xx_mib_fetch_port_stat(priv, port, false); ++ ++ mib_stats = &priv->mib_stats[port * num_mibs]; ++ /* 15: TXBYTE, 31: RXGOODBYTE */ ++ stats->tx_bytes = mib_stats[15]; ++ stats->rx_bytes = mib_stats[31]; ++unlock: ++ mutex_unlock(&priv->mib_lock); ++ return ret; ++} ++ +static const struct switch_attr ar40xx_sw_attr_globals[] = { + { + .type = SWITCH_TYPE_INT, @@ -1177,6 +1208,7 @@ + /* disable phy internal loopback */ + mdiobus_write(bus, 0x1f, 0x10, 0x6860); + mdiobus_write(bus, 0x1f, 0x0, 0x9040); ++ ar40xx_phy_mmd_write(priv, 0x1f, 7, 0x8076, 0x0670); /* 1000_LED_n */ + + for (phy = 0; phy < AR40XX_NUM_PORTS - 1; phy++) { + /* disable mac loop back */ @@ -1788,6 +1820,7 @@ + .apply_config = ar40xx_sw_hw_apply, + .reset_switch = ar40xx_sw_reset_switch, + .get_port_link = ar40xx_sw_get_port_link, ++ .get_port_stats = ar40xx_sw_get_port_stats, +}; + +/* Start of phy driver support */ From 0b296d75bc7707bdfcc0df2795dcbc3b0c325a11 Mon Sep 17 00:00:00 2001 From: AmadeusGhost <42570690+AmadeusGhost@users.noreply.github.com> Date: Fri, 3 Jul 2020 17:53:49 +0800 Subject: [PATCH 2/2] ipq40xx: cm520: fix startup with opboot --- .../arm/boot/dts/qcom-ipq4019-cm520-79f.dts | 72 +++---------------- 1 file changed, 9 insertions(+), 63 deletions(-) diff --git a/target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4019-cm520-79f.dts b/target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4019-cm520-79f.dts index f4c1685f4..019a8a191 100644 --- a/target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4019-cm520-79f.dts +++ b/target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4019-cm520-79f.dts @@ -16,6 +16,10 @@ led-upgrade = &led_sys; }; + chosen { + bootargs-append = " ubi.block=0,1 root=/dev/ubiblock0_1"; + }; + soc { rng@22000 { status = "okay"; @@ -110,7 +114,7 @@ led_spi { compatible = "spi-gpio"; #address-cells = <1>; - ranges; + #size-cells = <0>; sck-gpios = <&tlmm 40 GPIO_ACTIVE_HIGH>; mosi-gpios = <&tlmm 36 GPIO_ACTIVE_HIGH>; @@ -129,7 +133,7 @@ leds { compatible = "gpio-leds"; - usb { + led_usb: usb { label = "cm520-79f:blue:usb"; gpios = <&tlmm 10 GPIO_ACTIVE_HIGH>; linux,default-trigger = "usbport"; @@ -216,66 +220,8 @@ #size-cells = <1>; partition@0 { - label = "SBL1"; - reg = <0x0 0x100000>; - read-only; - }; - - partition@100000 { - label = "MIBIB"; - reg = <0x100000 0x100000>; - read-only; - }; - - partition@200000 { - label = "BOOTCONFIG"; - reg = <0x200000 0x100000>; - }; - - partition@300000 { - label = "QSEE"; - reg = <0x300000 0x100000>; - read-only; - }; - - partition@400000 { - label = "QSEE_1"; - reg = <0x400000 0x100000>; - read-only; - }; - - partition@500000 { - label = "CDT"; - reg = <0x500000 0x80000>; - read-only; - }; - - partition@580000 { - label = "CDT_1"; - reg = <0x580000 0x80000>; - read-only; - }; - - partition@600000 { - label = "BOOTCONFIG1"; - reg = <0x600000 0x80000>; - }; - - partition@680000 { - label = "APPSBLENV"; - reg = <0x680000 0x80000>; - }; - - partition@700000 { - label = "APPSBL"; - reg = <0x700000 0x200000>; - read-only; - }; - - partition@900000 { - label = "APPSBL_1"; - reg = <0x900000 0x200000>; - read-only; + label = "Bootloader"; + reg = <0x0 0xb00000>; }; art: partition@b00000 { @@ -285,7 +231,7 @@ }; partition@b80000 { - label = "ubi"; + label = "rootfs"; reg = <0xb80000 0x7480000>; }; };