diff --git a/package/base-files/files/bin/config_generate b/package/base-files/files/bin/config_generate index 0b26afe57f..3ca035ca8b 100755 --- a/package/base-files/files/bin/config_generate +++ b/package/base-files/files/bin/config_generate @@ -260,11 +260,6 @@ generate_static_system() { uci -q set "system.@system[-1].hostname=$hostname" fi - local label_macaddr - if json_get_var label_macaddr label_macaddr; then - uci -q set "system.@system[-1].label_macaddr=$label_macaddr" - fi - if json_is_a ntpserver array; then local keys key json_get_keys keys ntpserver diff --git a/package/base-files/files/lib/functions/system.sh b/package/base-files/files/lib/functions/system.sh index cb0508fe9c..c4dc3cc3a9 100644 --- a/package/base-files/files/lib/functions/system.sh +++ b/package/base-files/files/lib/functions/system.sh @@ -1,5 +1,7 @@ # Copyright (C) 2006-2013 OpenWrt.org +. /usr/share/libubox/jshn.sh + get_mac_binary() { local path="$1" local offset="$2" @@ -12,14 +14,41 @@ get_mac_binary() { hexdump -v -n 6 -s $offset -e '5/1 "%02x:" 1/1 "%02x"' $path 2>/dev/null } -get_mac_label() { +get_mac_label_dt() { local basepath="/proc/device-tree" local macdevice="$(cat "$basepath/aliases/label-mac-device" 2>/dev/null)" local macaddr - [ -n "$macdevice" ] && macaddr=$(get_mac_binary "$basepath/$macdevice/mac-address" 0 2>/dev/null) + [ -n "$macdevice" ] || return + + macaddr=$(get_mac_binary "$basepath/$macdevice/mac-address" 0 2>/dev/null) [ -n "$macaddr" ] || macaddr=$(get_mac_binary "$basepath/$macdevice/local-mac-address" 0 2>/dev/null) - [ -n "$macaddr" ] || macaddr=$(uci -q get system.@system[0].label_macaddr) + + echo $macaddr +} + +get_mac_label_json() { + local cfg="/etc/board.json" + local macaddr + + [ -s "$cfg" ] || return + + json_init + json_load "$(cat $cfg)" + if json_is_a system object; then + json_select system + json_get_var macaddr label_macaddr + json_select .. + fi + + echo $macaddr +} + +get_mac_label() { + local macaddr=$(get_mac_label_dt) + + [ -n "$macaddr" ] || macaddr=$(get_mac_label_json) + echo $macaddr } @@ -115,6 +144,13 @@ macaddr_add() { echo $oui:$nic } +macaddr_geteui() { + local mac=$1 + local sep=$2 + + echo ${mac:9:2}$sep${mac:12:2}$sep${mac:15:2} +} + macaddr_setbit_la() { local mac=$1 diff --git a/package/utils/busybox/Config-defaults.in b/package/utils/busybox/Config-defaults.in index 37238f05c3..c0aaecbb30 100644 --- a/package/utils/busybox/Config-defaults.in +++ b/package/utils/busybox/Config-defaults.in @@ -60,7 +60,7 @@ config BUSYBOX_DEFAULT_INSTALL_NO_USR default n config BUSYBOX_DEFAULT_FEATURE_SUID bool - default y + default n config BUSYBOX_DEFAULT_FEATURE_SUID_CONFIG bool default n diff --git a/package/utils/busybox/Makefile b/package/utils/busybox/Makefile index 1e1712fe71..1046d68d3e 100644 --- a/package/utils/busybox/Makefile +++ b/package/utils/busybox/Makefile @@ -113,6 +113,9 @@ endif ifneq ($(CONFIG_BUSYBOX_$(BUSYBOX_SYM)_NTPD),) $(INSTALL_BIN) ./files/sysntpd $(1)/etc/init.d/sysntpd $(INSTALL_BIN) ./files/ntpd-hotplug $(1)/usr/sbin/ntpd-hotplug +endif +ifneq ($(CONFIG_BUSYBOX_$(BUSYBOX_SYM)_FEATURE_SUID),) + $(INSTALL_SUID) $(PKG_INSTALL_DIR)/bin/busybox $(1)/bin/busybox endif -rm -rf $(1)/lib64 endef diff --git a/target/linux/ath79/dts/ar7242_buffalo_wzr-hp-g302h-a1a0.dts b/target/linux/ath79/dts/ar7242_buffalo_wzr-hp-g302h-a1a0.dts index e3971d1e95..71769ef9f7 100644 --- a/target/linux/ath79/dts/ar7242_buffalo_wzr-hp-g302h-a1a0.dts +++ b/target/linux/ath79/dts/ar7242_buffalo_wzr-hp-g302h-a1a0.dts @@ -32,7 +32,7 @@ debounce-interval = <60>; }; - button_usb { + usb { label = "usb"; linux,code = ; gpios = <&gpio 7 GPIO_ACTIVE_LOW>; diff --git a/target/linux/ath79/dts/ar9132_tplink_tl-wr1043nd-v1.dts b/target/linux/ath79/dts/ar9132_tplink_tl-wr1043nd-v1.dts index 3728b682c8..846e517de8 100644 --- a/target/linux/ath79/dts/ar9132_tplink_tl-wr1043nd-v1.dts +++ b/target/linux/ath79/dts/ar9132_tplink_tl-wr1043nd-v1.dts @@ -27,14 +27,14 @@ keys { compatible = "gpio-keys"; - button0 { + reset { label = "reset"; linux,code = ; gpios = <&gpio 3 GPIO_ACTIVE_LOW>; debounce-interval = <60>; }; - button1 { + qss { label = "qss"; linux,code = ; gpios = <&gpio 7 GPIO_ACTIVE_LOW>; diff --git a/target/linux/ath79/dts/ar9132_tplink_tl-wr941-v2.dts b/target/linux/ath79/dts/ar9132_tplink_tl-wr941-v2.dts index 80677fa894..1be4d6183a 100644 --- a/target/linux/ath79/dts/ar9132_tplink_tl-wr941-v2.dts +++ b/target/linux/ath79/dts/ar9132_tplink_tl-wr941-v2.dts @@ -21,14 +21,14 @@ keys { compatible = "gpio-keys"; - button0 { + reset { label = "reset"; linux,code = ; gpios = <&gpio 3 GPIO_ACTIVE_LOW>; debounce-interval = <60>; }; - button1 { + qss { label = "qss"; linux,code = ; gpios = <&gpio 7 GPIO_ACTIVE_LOW>; diff --git a/target/linux/ath79/dts/ar9331_tplink_tl-mr3020-v1.dts b/target/linux/ath79/dts/ar9331_tplink_tl-mr3020-v1.dts index 9b222904e1..3cd5c130c8 100644 --- a/target/linux/ath79/dts/ar9331_tplink_tl-mr3020-v1.dts +++ b/target/linux/ath79/dts/ar9331_tplink_tl-mr3020-v1.dts @@ -49,14 +49,14 @@ keys { compatible = "gpio-keys"; - button0 { + reset { label = "reset"; linux,code = ; gpios = <&gpio 11 GPIO_ACTIVE_HIGH>; debounce-interval = <60>; }; - button1 { + sw1 { label = "sw1"; linux,input-type = ; linux,code = ; @@ -64,7 +64,7 @@ debounce-interval = <60>; }; - button2 { + sw2 { label = "sw2"; linux,input-type = ; linux,code = ; diff --git a/target/linux/ath79/dts/qca9531_comfast_cf-e5.dts b/target/linux/ath79/dts/qca9531_comfast_cf-e5.dts index fb32923213..74a3554bcb 100644 --- a/target/linux/ath79/dts/qca9531_comfast_cf-e5.dts +++ b/target/linux/ath79/dts/qca9531_comfast_cf-e5.dts @@ -17,7 +17,7 @@ keys { compatible = "gpio-keys"; - button0 { + reset { label = "reset"; linux,code = ; gpios = <&gpio 17 GPIO_ACTIVE_LOW>; diff --git a/target/linux/ath79/dts/qca9531_glinet_gl-ar300m.dtsi b/target/linux/ath79/dts/qca9531_glinet_gl-ar300m.dtsi index 67a3331ab3..78961bf71b 100644 --- a/target/linux/ath79/dts/qca9531_glinet_gl-ar300m.dtsi +++ b/target/linux/ath79/dts/qca9531_glinet_gl-ar300m.dtsi @@ -20,19 +20,19 @@ pinctrl-names = "default"; pinctrl-0 = <&jtag_disable_pins>; - button0 { + reset { label = "reset"; linux,code = ; gpios = <&gpio 3 GPIO_ACTIVE_LOW>; }; - button1 { + right { label = "button right"; linux,code = ; gpios = <&gpio 0 GPIO_ACTIVE_HIGH>; }; - button3 { + left { label = "button left"; linux,code = ; gpios = <&gpio 1 GPIO_ACTIVE_HIGH>; diff --git a/target/linux/ath79/dts/qca9531_glinet_gl-x750.dts b/target/linux/ath79/dts/qca9531_glinet_gl-x750.dts index ae4553a207..c845b5465a 100644 --- a/target/linux/ath79/dts/qca9531_glinet_gl-x750.dts +++ b/target/linux/ath79/dts/qca9531_glinet_gl-x750.dts @@ -16,7 +16,7 @@ pinctrl-names = "default"; pinctrl-0 = <&jtag_disable_pins>; - button0 { + reset { label = "reset"; linux,code = ; gpios = <&gpio 3 GPIO_ACTIVE_LOW>; diff --git a/target/linux/ath79/dts/qca9533_tplink_cpexxx.dtsi b/target/linux/ath79/dts/qca9533_tplink_cpexxx.dtsi index 8f0a86334e..50d34c7c90 100644 --- a/target/linux/ath79/dts/qca9533_tplink_cpexxx.dtsi +++ b/target/linux/ath79/dts/qca9533_tplink_cpexxx.dtsi @@ -46,7 +46,7 @@ keys { compatible = "gpio-keys"; - reset_button { + reset { label = "Reset button"; linux,code = ; gpios = <&gpio 17 GPIO_ACTIVE_LOW>; diff --git a/target/linux/ath79/dts/qca9558_comfast_cf-wr650ac.dtsi b/target/linux/ath79/dts/qca9558_comfast_cf-wr650ac.dtsi index 5f7498a06e..39fae74b83 100644 --- a/target/linux/ath79/dts/qca9558_comfast_cf-wr650ac.dtsi +++ b/target/linux/ath79/dts/qca9558_comfast_cf-wr650ac.dtsi @@ -14,7 +14,7 @@ keys { compatible = "gpio-keys"; - button0 { + reset { label = "reset"; linux,code = ; gpios = <&gpio 19 GPIO_ACTIVE_LOW>; diff --git a/target/linux/ath79/dts/qca9558_librerouter_librerouter-v1.dts b/target/linux/ath79/dts/qca9558_librerouter_librerouter-v1.dts index 8d3d5c58a6..5c01126bc4 100644 --- a/target/linux/ath79/dts/qca9558_librerouter_librerouter-v1.dts +++ b/target/linux/ath79/dts/qca9558_librerouter_librerouter-v1.dts @@ -42,7 +42,7 @@ }; }; - button { + keys { compatible = "gpio-keys"; reset { diff --git a/target/linux/ath79/dts/qca9558_openmesh_om5p-ac-v2.dts b/target/linux/ath79/dts/qca9558_openmesh_om5p-ac-v2.dts index 7d7433d44e..83e76e463e 100644 --- a/target/linux/ath79/dts/qca9558_openmesh_om5p-ac-v2.dts +++ b/target/linux/ath79/dts/qca9558_openmesh_om5p-ac-v2.dts @@ -44,7 +44,7 @@ keys { compatible = "gpio-keys"; - button0 { + reset { label = "reset"; linux,code = ; gpios = <&gpio 1 GPIO_ACTIVE_LOW>; diff --git a/target/linux/ath79/dts/qca9558_zyxel_nbg6716.dts b/target/linux/ath79/dts/qca9558_zyxel_nbg6716.dts index d81d9c54f5..5a896d52bc 100644 --- a/target/linux/ath79/dts/qca9558_zyxel_nbg6716.dts +++ b/target/linux/ath79/dts/qca9558_zyxel_nbg6716.dts @@ -76,7 +76,7 @@ debounce-interval = <60>; }; - wifi_button { + wifi { label = "WiFi button"; linux,code = ; gpios = <&gpio 1 GPIO_ACTIVE_LOW>; diff --git a/target/linux/ath79/dts/qca9561_avm_fritz4020.dts b/target/linux/ath79/dts/qca9561_avm_fritz4020.dts index 2bb135eaff..6412252590 100644 --- a/target/linux/ath79/dts/qca9561_avm_fritz4020.dts +++ b/target/linux/ath79/dts/qca9561_avm_fritz4020.dts @@ -86,13 +86,13 @@ keys { compatible = "gpio-keys"; - wps_button { + wps { label = "WPS button"; linux,code = ; gpios = <&gpio 2 GPIO_ACTIVE_LOW>; }; - wlan_button { + wlan { label = "WLAN button"; linux,code = ; gpios = <&gpio 21 GPIO_ACTIVE_LOW>; diff --git a/target/linux/ath79/dts/qca9561_tplink_archer-c25-v1.dts b/target/linux/ath79/dts/qca9561_tplink_archer-c25-v1.dts index 351e37519d..f894fc8672 100644 --- a/target/linux/ath79/dts/qca9561_tplink_archer-c25-v1.dts +++ b/target/linux/ath79/dts/qca9561_tplink_archer-c25-v1.dts @@ -45,13 +45,13 @@ keys { compatible = "gpio-keys"; - wifi_button { + wifi { label = "WiFi button"; linux,code = ; gpios = <&gpio 22 GPIO_ACTIVE_LOW>; }; - reset_button { + reset { label = "Reset button"; linux,code = ; gpios = <&gpio 1 GPIO_ACTIVE_LOW>; diff --git a/target/linux/ath79/dts/qca9561_tplink_archer-c5x.dtsi b/target/linux/ath79/dts/qca9561_tplink_archer-c5x.dtsi index 26cc9ec2e8..00cd413bd2 100644 --- a/target/linux/ath79/dts/qca9561_tplink_archer-c5x.dtsi +++ b/target/linux/ath79/dts/qca9561_tplink_archer-c5x.dtsi @@ -85,19 +85,19 @@ keys { compatible = "gpio-keys"; - wps_button { + wps { label = "WPS button"; linux,code = ; gpios = <&gpio 1 GPIO_ACTIVE_LOW>; }; - wifi_button { + wifi { label = "WiFi button"; linux,code = ; gpios = <&gpio 2 GPIO_ACTIVE_LOW>; }; - reset_button { + reset { label = "Reset button"; linux,code = ; gpios = <&gpio 21 GPIO_ACTIVE_LOW>; diff --git a/target/linux/ath79/dts/qca9561_tplink_archer-c6x.dtsi b/target/linux/ath79/dts/qca9561_tplink_archer-c6x.dtsi index 21a470961f..719a9d065a 100644 --- a/target/linux/ath79/dts/qca9561_tplink_archer-c6x.dtsi +++ b/target/linux/ath79/dts/qca9561_tplink_archer-c6x.dtsi @@ -22,13 +22,13 @@ keys { compatible = "gpio-keys"; - wifi_button { + wifi { label = "WiFi button"; linux,code = ; gpios = <&gpio 1 GPIO_ACTIVE_LOW>; }; - reset_button { + reset { label = "Reset button"; linux,code = ; gpios = <&gpio 21 GPIO_ACTIVE_LOW>; diff --git a/target/linux/ath79/dts/qca9563_elecom_wrc-ghbk2-i.dtsi b/target/linux/ath79/dts/qca9563_elecom_wrc-ghbk2-i.dtsi index 028c1747d2..f04304ee4c 100644 --- a/target/linux/ath79/dts/qca9563_elecom_wrc-ghbk2-i.dtsi +++ b/target/linux/ath79/dts/qca9563_elecom_wrc-ghbk2-i.dtsi @@ -37,7 +37,7 @@ debounce-interval = <60>; }; - button_wps { + wps { label = "wps"; gpios = <&gpio 5 GPIO_ACTIVE_LOW>; linux,code = ; diff --git a/target/linux/ath79/dts/tp9343_tplink_tl-wr94x.dtsi b/target/linux/ath79/dts/tp9343_tplink_tl-wr94x.dtsi index 21c16be36d..c6bb8a2417 100644 --- a/target/linux/ath79/dts/tp9343_tplink_tl-wr94x.dtsi +++ b/target/linux/ath79/dts/tp9343_tplink_tl-wr94x.dtsi @@ -18,13 +18,13 @@ keys { compatible = "gpio-keys"; - wifi_button { + wifi { label = "WiFi button"; linux,code = ; gpios = <&gpio 2 GPIO_ACTIVE_LOW>; }; - reset_button { + reset { label = "Reset button"; linux,code = ; gpios = <&gpio 1 GPIO_ACTIVE_LOW>; diff --git a/target/linux/ipq40xx/files-4.19/arch/arm/boot/dts/qcom-ipq4019-unielec-u4019.dtsi b/target/linux/ipq40xx/files-4.19/arch/arm/boot/dts/qcom-ipq4019-unielec-u4019.dtsi index cf67fddd2b..c768e25ca0 100644 --- a/target/linux/ipq40xx/files-4.19/arch/arm/boot/dts/qcom-ipq4019-unielec-u4019.dtsi +++ b/target/linux/ipq40xx/files-4.19/arch/arm/boot/dts/qcom-ipq4019-unielec-u4019.dtsi @@ -17,7 +17,8 @@ status = "okay"; pinctrl-0 = <&mdio_pins>; pinctrl-names = "default"; - phy-reset-gpio = <&tlmm 47 0>; + reset-gpios = <&tlmm 47 GPIO_ACTIVE_LOW>; + reset-delay-us = <2000>; }; ess-psgmii@98000 { diff --git a/target/linux/ipq40xx/files-4.19/arch/arm/boot/dts/qcom-ipq4019-wpj419.dts b/target/linux/ipq40xx/files-4.19/arch/arm/boot/dts/qcom-ipq4019-wpj419.dts index b6eb99278b..e75d07606a 100644 --- a/target/linux/ipq40xx/files-4.19/arch/arm/boot/dts/qcom-ipq4019-wpj419.dts +++ b/target/linux/ipq40xx/files-4.19/arch/arm/boot/dts/qcom-ipq4019-wpj419.dts @@ -236,9 +236,10 @@ mdio@90000 { status = "okay"; - phy-reset-gpio = <&tlmm 47 0>; pinctrl-0 = <&mdio_pins>; pinctrl-names = "default"; + reset-gpios = <&tlmm 47 GPIO_ACTIVE_LOW>; + reset-delay-us = <5000>; }; ess-psgmii@98000 { diff --git a/target/linux/ipq40xx/patches-4.19/700-net-add-qualcomm-mdio.patch b/target/linux/ipq40xx/patches-4.19/700-net-add-qualcomm-mdio.patch index c27d19fc16..e939597b8e 100644 --- a/target/linux/ipq40xx/patches-4.19/700-net-add-qualcomm-mdio.patch +++ b/target/linux/ipq40xx/patches-4.19/700-net-add-qualcomm-mdio.patch @@ -1,15 +1,3 @@ -From 234d6f40fb4b771b396b45a9492aab463771bd0b Mon Sep 17 00:00:00 2001 -From: Kristian Evensen -Date: Tue, 6 Aug 2019 11:42:57 +0200 -Subject: [PATCH] phy: Add ipq40xx mdio driver - ---- - drivers/net/phy/Kconfig | 7 + - drivers/net/phy/Makefile | 1 + - drivers/net/phy/mdio-ipq40xx.c | 247 +++++++++++++++++++++++++++++++++ - 3 files changed, 255 insertions(+) - create mode 100644 drivers/net/phy/mdio-ipq40xx.c - --- a/drivers/net/phy/Kconfig +++ b/drivers/net/phy/Kconfig @@ -519,6 +519,13 @@ config XILINX_GMII2RGMII @@ -38,7 +26,7 @@ Subject: [PATCH] phy: Add ipq40xx mdio driver obj-$(CONFIG_MDIO_OCTEON) += mdio-octeon.o --- /dev/null +++ b/drivers/net/phy/mdio-ipq40xx.c -@@ -0,0 +1,247 @@ +@@ -0,0 +1,196 @@ +/* + * Copyright (c) 2015-2016, The Linux Foundation. All rights reserved. + * @@ -61,10 +49,8 @@ Subject: [PATCH] phy: Add ipq40xx mdio driver +#include +#include +#include -+#include +#include +#include -+#include + +#define MDIO_CTRL_0_REG 0x40 +#define MDIO_CTRL_1_REG 0x44 @@ -164,60 +150,11 @@ Subject: [PATCH] phy: Add ipq40xx mdio driver + return 0; +} + -+static int ipq40xx_phy_reset(struct platform_device *pdev) -+{ -+ struct device_node *mdio_node; -+ int phy_reset_gpio_number; -+ int ret; -+ -+ mdio_node = of_find_node_by_name(NULL, "mdio"); -+ if (!mdio_node) { -+ dev_err(&pdev->dev, "Could not find mdio node\n"); -+ return 0; -+ } -+ -+ ret = of_get_named_gpio(mdio_node, "phy-reset-gpio", 0); -+ if (ret < 0) { -+ dev_err(&pdev->dev, "Could not find phy-reset-gpio\n"); -+ return 0; -+ } -+ -+ phy_reset_gpio_number = ret; -+ -+ ret = gpio_request(phy_reset_gpio_number, "phy-reset-gpio"); -+ if (ret) { -+ dev_err(&pdev->dev, "Can't get phy-reset-gpio %d\n", ret); -+ return ret; -+ } -+ -+ ret = gpio_direction_output(phy_reset_gpio_number, 0x0); -+ if (ret) { -+ dev_err(&pdev->dev, -+ "Can't set direction for phy-reset-gpio %d\n", ret); -+ goto phy_reset_out; -+ } -+ -+ usleep_range(1000, 10005); -+ -+ gpio_set_value(phy_reset_gpio_number, 0x01); -+ -+phy_reset_out: -+ gpio_free(phy_reset_gpio_number); -+ -+ return ret; -+} -+ +static int ipq40xx_mdio_probe(struct platform_device *pdev) +{ + struct ipq40xx_mdio_data *am; + struct resource *res; -+ int i, ret; -+ -+ ret = ipq40xx_phy_reset(pdev); -+ if (ret) { -+ dev_err(&pdev->dev, "Could not find qca8075 reset gpio\n"); -+ return -ENODEV; -+ } ++ int i; + + am = devm_kzalloc(&pdev->dev, sizeof(*am), GFP_KERNEL); + if (!am) diff --git a/target/linux/ramips/dts/mt7621_xiaomi_mir3g-v2.dts b/target/linux/ramips/dts/mt7621_xiaomi_mir3g-v2.dts index 58da88a862..757e487bcb 100644 --- a/target/linux/ramips/dts/mt7621_xiaomi_mir3g-v2.dts +++ b/target/linux/ramips/dts/mt7621_xiaomi_mir3g-v2.dts @@ -35,7 +35,7 @@ }; }; - button { + keys { compatible = "gpio-keys"; reset { diff --git a/target/linux/ramips/dts/mt7621_xiaomi_mir3g.dts b/target/linux/ramips/dts/mt7621_xiaomi_mir3g.dts index 5044890d6c..29ac019899 100644 --- a/target/linux/ramips/dts/mt7621_xiaomi_mir3g.dts +++ b/target/linux/ramips/dts/mt7621_xiaomi_mir3g.dts @@ -54,7 +54,7 @@ }; }; - button { + keys { compatible = "gpio-keys"; reset { diff --git a/target/linux/ramips/dts/mt7621_xiaomi_mir3p.dts b/target/linux/ramips/dts/mt7621_xiaomi_mir3p.dts index f36a920b6b..9482889b8a 100644 --- a/target/linux/ramips/dts/mt7621_xiaomi_mir3p.dts +++ b/target/linux/ramips/dts/mt7621_xiaomi_mir3p.dts @@ -60,7 +60,7 @@ }; }; - button { + keys { compatible = "gpio-keys"; reset {