aboutsummaryrefslogtreecommitdiffstats
path: root/package/base-files
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2015-12-04 15:02:32 +0000
committerJo-Philipp Wich <jow@openwrt.org>2015-12-04 15:02:32 +0000
commita019b6371a15332db8f59362451e682ca0a13c16 (patch)
treeba8cdb825b08122ec6c2e11049e0e4dc2635d439 /package/base-files
parentcacd3d083441694dacbfe9fce595bd3a7d4a4c28 (diff)
downloadmaster-187ad058-a019b6371a15332db8f59362451e682ca0a13c16.tar.gz
master-187ad058-a019b6371a15332db8f59362451e682ca0a13c16.tar.bz2
master-187ad058-a019b6371a15332db8f59362451e682ca0a13c16.zip
board.d: add support for gpio_switch sections
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org> git-svn-id: svn://svn.openwrt.org/openwrt/trunk@47762 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/base-files')
-rwxr-xr-xpackage/base-files/files/bin/config_generate21
-rwxr-xr-xpackage/base-files/files/lib/functions/uci-defaults-new.sh15
2 files changed, 36 insertions, 0 deletions
diff --git a/package/base-files/files/bin/config_generate b/package/base-files/files/bin/config_generate
index 49784ebfae..9218788b5e 100755
--- a/package/base-files/files/bin/config_generate
+++ b/package/base-files/files/bin/config_generate
@@ -312,6 +312,24 @@ generate_led() {
json_select ..
}
+generate_gpioswitch() {
+ local cfg="$1"
+
+ json_select gpioswitch
+ json_select "$cfg"
+ local name pin default
+ json_get_vars name pin default
+ uci -q batch <<-EOF
+ delete system.$cfg
+ set system.$cfg='gpio_switch'
+ set system.$cfg.name='$name'
+ set system.$cfg.gpio_pin='$pin'
+ set system.$cfg.default='$default'
+ EOF
+ json_select ..
+ json_select ..
+}
+
json_init
json_load "$(cat ${CFG})"
@@ -326,6 +344,9 @@ for key in $keys; do generate_switch $key; done
json_get_keys keys rssimon
for key in $keys; do generate_rssimon $key; done
+json_get_keys keys gpioswitch
+for key in $keys; do generate_gpioswitch $key; done
+
json_get_keys keys led
for key in $keys; do generate_led $key; done
diff --git a/package/base-files/files/lib/functions/uci-defaults-new.sh b/package/base-files/files/lib/functions/uci-defaults-new.sh
index 61aa6e168e..de3f180cbb 100755
--- a/package/base-files/files/lib/functions/uci-defaults-new.sh
+++ b/package/base-files/files/lib/functions/uci-defaults-new.sh
@@ -540,6 +540,21 @@ ucidef_set_rssimon() {
}
+ucidef_add_gpio_switch() {
+ local cfg="$1"
+ local name="$2"
+ local pin="$3"
+ local default="${4:-0}"
+
+ json_select_object gpioswitch
+ json_select_object "$cfg"
+ json_add_string name "$name"
+ json_add_int pin "$pin"
+ json_add_int default "$default"
+ json_select ..
+ json_select ..
+}
+
board_config_update() {
json_init
[ -f ${CFG} ] && json_load "$(cat ${CFG})"