base-files: add helper functions for adding wlan device entries to board.json

These will be used to give WLAN PHYs a specific name based on path specified
in board.json. The platform board.d script can assign a specific order based
on available slots (PCIe slots, WMAC device) and device tree configuration.

This helps with maintaining config compatibility in case the device path
changes due to kernel upgrades.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
Felix Fietkau 2022-09-30 19:19:51 +02:00 committed by AmadeusGhost
parent 99604ea8c8
commit 2f8864218f
2 changed files with 20 additions and 1 deletions

View File

@ -250,4 +250,8 @@ macaddr_canonicalize() {
[ ${#canon} -ne 17 ] && return [ ${#canon} -ne 17 ] && return
printf "%02x:%02x:%02x:%02x:%02x:%02x" 0x${canon// / 0x} 2>/dev/null printf "%02x:%02x:%02x:%02x:%02x:%02x" 0x${canon// / 0x} 2>/dev/null
} }
dt_is_enabled() {
grep -q okay "/proc/device-tree/$1/status"
}

View File

@ -629,6 +629,21 @@ ucidef_set_ntpserver() {
json_select .. json_select ..
} }
ucidef_add_wlan() {
local path="$1"; shift
ucidef_wlan_idx=${ucidef_wlan_idx:-0}
json_select_object wlan
json_select_object "wl$ucidef_wlan_idx"
json_add_string path "$path"
json_add_fields "$@"
json_select ..
json_select ..
ucidef_wlan_idx="$((ucidef_wlan_idx + 1))"
}
board_config_update() { board_config_update() {
json_init json_init
[ -f ${CFG} ] && json_load "$(cat ${CFG})" [ -f ${CFG} ] && json_load "$(cat ${CFG})"