ipq806x: convert to dt-based board-detection

Use the generic board detection method:
- Board name: First compatible string from the device tree
- Board model: Model property from the device tree

Change occurrences of board name in userspace by the compatible
string, and removed target specific board detection script

Replace the definition of SUPPORTED_DEVICES in Device/Default
to extract the dt compatible string from each device definition.
Additionally, for devices supported by lede-17.01, append
the value of BOARD_NAME to SUPPORTED_DEVICES in the device
definition.

Signed-off-by: Luis Araneda <luaraneda@gmail.com>
This commit is contained in:
Luis Araneda 2018-01-05 10:00:11 -03:00 committed by Mathias Kresin
parent 3cbdae2421
commit 33f09cf151
11 changed files with 91 additions and 156 deletions

View File

@ -31,13 +31,14 @@ ubootenv_mtdinfo () {
}
case "$board" in
ap148 | db149)
qcom,ipq8064-ap148 |\
qcom,ipq8064-db149)
ubootenv_add_uci_config $(ubootenv_mtdinfo)
;;
ea8500)
linksys,ea8500)
ubootenv_add_uci_config "/dev/mtd10" "0x0" "0x20000" "0x20000"
;;
nbg6817)
zyxel,nbg6817)
ubootenv_add_uci_config "/dev/mtdblock9" "0x0" "0x10000" "0x10000"
;;
esac

View File

@ -11,37 +11,37 @@ board=$(board_name)
boardname="${board##*,}"
case "$board" in
c2600)
ucidef_set_led_usbport "usb1" "USB 1" "${board}:white:usb_2" "usb1-port1" "usb2-port1"
ucidef_set_led_usbport "usb2" "USB 2" "${board}:white:usb_4" "usb3-port1" "usb4-port1"
ucidef_set_led_switch "wan" "wan" "${board}:white:wan" "switch0" "0x20"
ucidef_set_led_switch "lan" "lan" "${board}:white:lan" "switch0" "0x1e"
tplink,c2600)
ucidef_set_led_usbport "usb1" "USB 1" "${boardname}:white:usb_2" "usb1-port1" "usb2-port1"
ucidef_set_led_usbport "usb2" "USB 2" "${boardname}:white:usb_4" "usb3-port1" "usb4-port1"
ucidef_set_led_switch "wan" "wan" "${boardname}:white:wan" "switch0" "0x20"
ucidef_set_led_switch "lan" "lan" "${boardname}:white:lan" "switch0" "0x1e"
;;
d7800 |\
r7500 |\
r7500v2 |\
r7800)
ucidef_set_led_usbport "usb1" "USB 1" "${board}:white:usb1" "usb1-port1" "usb2-port1"
ucidef_set_led_usbport "usb2" "USB 2" "${board}:white:usb2" "usb3-port1" "usb4-port1"
ucidef_set_led_netdev "wan" "WAN" "${board}:white:wan" "eth0"
ucidef_set_led_ide "esata" "eSATA" "${board}:white:esata"
netgear,d7800 |\
netgear,r7500 |\
netgear,r7500v2 |\
netgear,r7800)
ucidef_set_led_usbport "usb1" "USB 1" "${boardname}:white:usb1" "usb1-port1" "usb2-port1"
ucidef_set_led_usbport "usb2" "USB 2" "${boardname}:white:usb2" "usb3-port1" "usb4-port1"
ucidef_set_led_netdev "wan" "WAN" "${boardname}:white:wan" "eth0"
ucidef_set_led_ide "esata" "eSATA" "${boardname}:white:esata"
;;
fritz4040)
ucidef_set_led_wlan "wlan" "WLAN" "$board:green:wlan" "phy0tpt" "phy1tpt"
ucidef_set_led_netdev "wan" "WAN" "$board:green:wan" "eth1"
ucidef_set_led_switch "lan" "LAN" "${board}:green:lan" "switch0" "0x1e"
avm,fritzbox-4040)
ucidef_set_led_wlan "wlan" "WLAN" "fritz4040:green:wlan" "phy0tpt" "phy1tpt"
ucidef_set_led_netdev "wan" "WAN" "fritz4040:green:wan" "eth1"
ucidef_set_led_switch "lan" "LAN" "fritz4040:green:lan" "switch0" "0x1e"
;;
nbg6817)
ucidef_set_led_wlan "wlan2g" "WLAN2G" "$board:amber:wifi2g" "phy1tpt"
ucidef_set_led_wlan "wlan5g" "WLAN5G" "$board:amber:wifi5g" "phy0tpt"
ucidef_set_led_netdev "wan" "WAN" "$board:white:internet" "eth1"
zyxel,nbg6817)
ucidef_set_led_wlan "wlan2g" "WLAN2G" "${boardname}:amber:wifi2g" "phy1tpt"
ucidef_set_led_wlan "wlan5g" "WLAN5G" "${boardname}:amber:wifi5g" "phy0tpt"
ucidef_set_led_netdev "wan" "WAN" "${boardname}:white:internet" "eth1"
;;
vr2600v)
ucidef_set_led_usbport "usb" "USB" "${board}:white:usb" "usb1-port1" "usb2-port1" "usb3-port1" "usb4-port1"
ucidef_set_led_switch "lan" "lan" "${board}:white:lan" "switch0" "0x1e"
ucidef_set_led_wlan "wlan2g" "WLAN2G" "${board}:white:wlan2g" "phy0tpt"
ucidef_set_led_wlan "wlan5g" "WLAN5G" "${board}:white:wlan5g" "phy1tpt"
ucidef_set_led_switch "wan" "wan" "${board}:white:wan" "switch0" "0x20"
tplink,vr2600v)
ucidef_set_led_usbport "usb" "USB" "${boardname}:white:usb" "usb1-port1" "usb2-port1" "usb3-port1" "usb4-port1"
ucidef_set_led_switch "lan" "lan" "${boardname}:white:lan" "switch0" "0x1e"
ucidef_set_led_wlan "wlan2g" "WLAN2G" "${boardname}:white:wlan2g" "phy0tpt"
ucidef_set_led_wlan "wlan5g" "WLAN5G" "${boardname}:white:wlan5g" "phy1tpt"
ucidef_set_led_switch "wan" "wan" "${boardname}:white:wan" "switch0" "0x20"
;;
*)
;;

View File

@ -12,25 +12,25 @@ board_config_update
board=$(board_name)
case "$board" in
ap148 |\
d7800 |\
r7500 |\
r7500v2 |\
r7800 |\
vr2600v)
netgear,d7800 |\
netgear,r7500 |\
netgear,r7500v2 |\
netgear,r7800 |\
qcom,ipq8064-ap148 |\
tplink,vr2600v)
ucidef_add_switch "switch0" \
"1:lan" "2:lan" "3:lan" "4:lan" "6@eth1" "5:wan" "0@eth0"
;;
c2600)
tplink,c2600)
ucidef_add_switch "switch0" \
"1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "6@eth1" "5:wan" "0@eth0"
;;
db149)
qcom,ipq8064-db149)
ucidef_set_interface_lan "eth1 eth2 eth3"
ucidef_add_switch "switch0" \
"1:lan" "2:lan" "3:lan" "4:lan" "6u@eth1" "5:wan" "0u@eth0"
;;
ea8500)
linksys,ea8500)
hw_mac_addr=$(mtd_get_mac_ascii devinfo hw_mac_addr)
ucidef_add_switch "switch0" \
@ -38,12 +38,12 @@ ea8500)
ucidef_set_interface_macaddr "lan" "$hw_mac_addr"
ucidef_set_interface_macaddr "wan" "$hw_mac_addr"
;;
fritz4040)
avm,fritzbox-4040)
ucidef_set_interfaces_lan_wan "eth0" "eth1"
ucidef_add_switch "switch0" \
"0@eth0" "1:lan" "2:lan" "3:lan" "4:lan"
;;
nbg6817)
zyxel,nbg6817)
hw_mac_addr=$(mtd_get_mac_ascii 0:APPSBLENV ethaddr)
ucidef_add_switch "switch0" \
"1:lan" "2:lan" "3:lan" "4:lan" "6@eth1" "5:wan" "0@eth0"

View File

@ -47,20 +47,20 @@ board=$(board_name)
case "$FIRMWARE" in
"ath10k/pre-cal-ahb-a000000.wifi.bin")
case "$board" in
ap-dk01.1-c1)
qcom,ap-dk01.1-c1)
ath10kcal_extract "ART" 4096 12064
;;
fritz4040)
avm,fritzbox-4040)
/usr/bin/fritz_cal_extract -i 1 -s 0x400 -e 0x207 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader_config")
;;
esac
;;
"ath10k/pre-cal-ahb-a800000.wifi.bin")
case "$board" in
ap-dk01.1-c1)
qcom,ap-dk01.1-c1)
ath10kcal_extract "ART" 20480 12064
;;
fritz4040)
avm,fritzbox-4040)
/usr/bin/fritz_cal_extract -i 1 -s 0x400 -e 0x208 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader_config")
;;
esac
@ -68,46 +68,46 @@ case "$FIRMWARE" in
"ath10k/pre-cal-pci-0000:01:00.0.bin")
case $board in
c2600)
tplink,c2600)
ath10kcal_extract "radio" 4096 12064
# ath10kcal_patch_mac $(macaddr_add $(mtd_get_mac_binary default-mac 8) -1)
;;
d7800 |\
r7500v2 |\
r7800)
netgear,d7800 |\
netgear,r7500v2 |\
netgear,r7800)
ath10kcal_extract "art" 4096 12064
;;
ea8500)
linksys,ea8500)
hw_mac_addr=$(mtd_get_mac_ascii devinfo hw_mac_addr)
ath10kcal_extract "art" 4096 12064
;;
nbg6817)
zyxel,nbg6817)
ath10kcal_extract "0:ART" 4096 12064
;;
vr2600v)
tplink,vr2600v)
ath10kcal_extract "ART" 4096 12064
;;
esac
;;
"ath10k/pre-cal-pci-0001:01:00.0.bin")
case $board in
c2600)
tplink,c2600)
ath10kcal_extract "radio" 20480 12064
# ath10kcal_patch_mac $(macaddr_add $(mtd_get_mac_binary default-mac 8) -2)
;;
d7800 |\
r7500v2 |\
r7800)
netgear,d7800 |\
netgear,r7500v2 |\
netgear,r7800)
ath10kcal_extract "art" 20480 12064
;;
ea8500)
linksys,ea8500)
hw_mac_addr=$(mtd_get_mac_ascii devinfo hw_mac_addr)
ath10kcal_extract "art" 20480 12064
;;
nbg6817)
zyxel,nbg6817)
ath10kcal_extract "0:ART" 20480 12064
;;
vr2600v)
tplink,vr2600v)
ath10kcal_extract "ART" 20480 12064
;;
esac

View File

@ -12,21 +12,21 @@ PHYNBR=${DEVPATH##*/phy}
board=$(board_name)
case "$board" in
c2600)
tplink,c2600)
echo $(macaddr_add $(mtd_get_mac_binary default-mac 8) $(($PHYNBR - 1)) ) > /sys${DEVPATH}/macaddress
;;
d7800 |\
r7500v2 |\
r7800)
netgear,d7800 |\
netgear,r7500v2 |\
netgear,r7800)
echo $(macaddr_add $(mtd_get_mac_binary art 6) $(($PHYNBR + 1)) ) > /sys${DEVPATH}/macaddress
;;
ea8500)
linksys,ea8500)
echo $(macaddr_add $(mtd_get_mac_ascii devinfo hw_mac_addr) $(($PHYNBR + 1)) ) > /sys${DEVPATH}/macaddress
;;
nbg6817)
zyxel,nbg6817)
echo $(macaddr_add $(mtd_get_mac_ascii 0:APPSBLENV ethaddr) $((1 - $PHYNBR)) ) > /sys${DEVPATH}/macaddress
;;
vr2600v)
tplink,vr2600v)
echo $(macaddr_add $(mtd_get_mac_binary default-mac 0) $(($PHYNBR - 1)) ) > /sys${DEVPATH}/macaddress
;;
*)

View File

@ -6,7 +6,7 @@ boot() {
. /lib/functions.sh
case $(board_name) in
ea8500)
linksys,ea8500)
# make sure auto_recovery in uboot is always on
AUTO_RECOVERY_ENA="`fw_printenv -n auto_recovery`"
if [ "$AUTO_RECOVERY_ENA" != "yes" ] ; then

View File

@ -1,64 +0,0 @@
#!/bin/sh
#
# Copyright (c) 2014 The Linux Foundation. All rights reserved.
# Copyright (C) 2011 OpenWrt.org
#
IPQ806X_BOARD_NAME=
IPQ806X_MODEL=
ipq806x_board_detect() {
local machine
local name
machine=$(cat /proc/device-tree/model)
case "$machine" in
*"AP-DK01.1-C1")
name="ap-dk01.1-c1"
;;
*"AP148")
name="ap148"
;;
*"4040")
name="fritz4040"
;;
*"C2600")
name="c2600"
;;
*"D7800")
name="d7800"
;;
*"DB149")
name="db149"
;;
*"NBG6817")
name="nbg6817"
;;
*"R7500")
name="r7500"
;;
*"R7500v2")
name="r7500v2"
;;
*"Linksys EA8500"*)
name="ea8500"
;;
*"R7800")
name="r7800"
;;
*"VR2600v")
name="vr2600v"
;;
esac
[ -z "$name" ] && name="unknown"
[ -z "$IPQ806X_BOARD_NAME" ] && IPQ806X_BOARD_NAME="$name"
[ -z "$IPQ806X_MODEL" ] && IPQ806X_MODEL="$machine"
[ -e "/tmp/sysinfo/" ] || mkdir -p "/tmp/sysinfo/"
echo "$IPQ806X_BOARD_NAME" > /tmp/sysinfo/board_name
echo "$IPQ806X_MODEL" > /tmp/sysinfo/model
}

View File

@ -1,12 +0,0 @@
#!/bin/sh
#
# Copyright (c) 2014 The Linux Foundation. All rights reserved.
#
do_ipq806x() {
. /lib/ipq806x.sh
ipq806x_board_detect
}
boot_hook_add preinit_main do_ipq806x

View File

@ -10,24 +10,24 @@ platform_check_image() {
platform_do_upgrade() {
case "$(board_name)" in
ap148 |\
ap-dk04.1-c1 |\
d7800 |\
nbg6817 |\
r7500 |\
r7500v2 |\
r7800)
netgear,d7800 |\
netgear,r7500 |\
netgear,r7500v2 |\
netgear,r7800 |\
qcom,ap-dk04.1-c1 |\
qcom,ipq8064-ap148 |\
zyxel,nbg6817)
nand_do_upgrade "$ARGV"
;;
c2600)
tplink,c2600)
PART_NAME="os-image:rootfs"
MTD_CONFIG_ARGS="-s 0x200000"
default_do_upgrade "$ARGV"
;;
ea8500)
linksys,ea8500)
platform_do_upgrade_linksys "$ARGV"
;;
vr2600v)
tplink,vr2600v)
PART_NAME="kernel:rootfs"
MTD_CONFIG_ARGS="-s 0x200000"
default_do_upgrade "$ARGV"
@ -40,7 +40,7 @@ platform_do_upgrade() {
platform_nand_pre_upgrade() {
case "$(board_name)" in
nbg6817)
zyxel,nbg6817)
zyxel_do_upgrade "$1"
;;
esac

View File

@ -74,7 +74,7 @@ zyxel_do_upgrade() {
[ -b "${rootfs}" ] || return 1
case "$board" in
nbg6817)
zyxel,nbg6817)
case "$rootfs" in
"/dev/mmcblk0p5")
kernel=mmcblk0p4

View File

@ -29,7 +29,7 @@ define Device/Default
KERNEL_INITRAMFS_PREFIX := $$(IMG_PREFIX)-$(1)-initramfs
KERNEL_PREFIX := $$(IMAGE_PREFIX)
KERNEL_LOADADDR = 0x42208000
SUPPORTED_DEVICES = $$(BOARD_NAME)
SUPPORTED_DEVICES := $(subst _,$(comma),$(1))
IMAGE/sysupgrade.tar = sysupgrade-tar | append-metadata
endef
@ -106,6 +106,7 @@ define Device/qcom_ipq8064-ap148
BLOCKSIZE := 128k
PAGESIZE := 2048
BOARD_NAME := ap148
SUPPORTED_DEVICES += ap148
DEVICE_TITLE := Qualcomm AP148
DEVICE_PACKAGES := ath10k-firmware-qca99x0
endef
@ -118,6 +119,7 @@ define Device/qcom_ipq8064-ap148-legacy
BLOCKSIZE := 128k
PAGESIZE := 2048
BOARD_NAME := ap148
SUPPORTED_DEVICES := qcom,ipq8064-ap148 ap148
DEVICE_TITLE := Qualcomm AP148 (legacy)
DEVICE_PACKAGES := ath10k-firmware-qca99x0
endef
@ -129,6 +131,7 @@ define Device/tplink_c2600
BLOCKSIZE := 128k
PAGESIZE := 2048
BOARD_NAME := c2600
SUPPORTED_DEVICES += c2600
TPLINK_BOARD_ID := C2600
DEVICE_TITLE := TP-Link Archer C2600
DEVICE_PACKAGES := ath10k-firmware-qca99x0
@ -144,6 +147,7 @@ define Device/netgear_d7800
BLOCKSIZE := 128k
PAGESIZE := 2048
BOARD_NAME := d7800
SUPPORTED_DEVICES += d7800
DEVICE_TITLE := Netgear Nighthawk X4 D7800
DEVICE_PACKAGES := ath10k-firmware-qca99x0
endef
@ -169,6 +173,7 @@ define Device/linksys_ea8500
KERNEL = kernel-bin | append-dtb | uImage none | append-uImage-fakeroot-hdr
PROFILES += $$(DEVICE_NAME)
BOARD_NAME := ea8500
SUPPORTED_DEVICES += ea8500
UBINIZE_OPTS := -E 5
IMAGES := factory.bin sysupgrade.tar
IMAGE/factory.bin := append-kernel | pad-to $$$${KERNEL_SIZE} | append-ubi
@ -201,6 +206,7 @@ define Device/netgear_r7500
BLOCKSIZE := 128k
PAGESIZE := 2048
BOARD_NAME := r7500
SUPPORTED_DEVICES += r7500
DEVICE_TITLE := Netgear Nighthawk X4 R7500
DEVICE_PACKAGES := ath10k-firmware-qca988x
endef
@ -215,6 +221,7 @@ define Device/netgear_r7500v2
BLOCKSIZE := 128k
PAGESIZE := 2048
BOARD_NAME := r7500v2
SUPPORTED_DEVICES += r7500v2
DEVICE_TITLE := Netgear Nighthawk X4 R7500v2
DEVICE_PACKAGES := ath10k-firmware-qca99x0 ath10k-firmware-qca988x
endef
@ -229,6 +236,7 @@ define Device/netgear_r7800
BLOCKSIZE := 128k
PAGESIZE := 2048
BOARD_NAME := r7800
SUPPORTED_DEVICES += r7800
DEVICE_TITLE := Netgear Nighthawk X4S R7800
DEVICE_PACKAGES := ath10k-firmware-qca9984
endef
@ -239,6 +247,7 @@ define Device/zyxel_nbg6817
KERNEL_SIZE := 4096k
BLOCKSIZE := 64k
BOARD_NAME := nbg6817
SUPPORTED_DEVICES += nbg6817
DEVICE_TITLE := ZyXEL NBG6817
DEVICE_PACKAGES := ath10k-firmware-qca9984 e2fsprogs kmod-fs-ext4 losetup
$(call Device/ZyXELImage)
@ -256,6 +265,7 @@ define Device/tplink_vr2600v
BLOCKSIZE := 128k
PAGESIZE := 2048
BOARD_NAME := vr2600v
SUPPORTED_DEVICES += vr2600v
DEVICE_TITLE := TP-Link Archer VR2600v
DEVICE_PACKAGES := ath10k-firmware-qca99x0
IMAGES := sysupgrade.bin