summaryrefslogtreecommitdiff
path: root/package/mmc_over_gpio
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2008-11-17 23:22:27 +0000
committerJo-Philipp Wich <jow@openwrt.org>2008-11-17 23:22:27 +0000
commitfad690be31358a29058009746b275b774a070b78 (patch)
treef3f7aebe649a00330a6eb84c17472b3cdf516483 /package/mmc_over_gpio
parentfa3fb7c8090160d5609ae65eeaa0a6d26bf32aa6 (diff)
downloadmtk-20170518-fad690be31358a29058009746b275b774a070b78.zip
mtk-20170518-fad690be31358a29058009746b275b774a070b78.tar.gz
mtk-20170518-fad690be31358a29058009746b275b774a070b78.tar.bz2
make mmc_over_gpio init uci-aware
SVN-Revision: 13273
Diffstat (limited to 'package/mmc_over_gpio')
-rw-r--r--package/mmc_over_gpio/Makefile4
-rw-r--r--package/mmc_over_gpio/files/mmc_over_gpio.config8
-rw-r--r--package/mmc_over_gpio/files/mmc_over_gpio.init27
3 files changed, 34 insertions, 5 deletions
diff --git a/package/mmc_over_gpio/Makefile b/package/mmc_over_gpio/Makefile
index 954ccfa..a3d1787 100644
--- a/package/mmc_over_gpio/Makefile
+++ b/package/mmc_over_gpio/Makefile
@@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk
PKG_NAME:=mmc-over-gpio
-PKG_RELEASE:=2
+PKG_RELEASE:=3
include $(INCLUDE_DIR)/package.mk
@@ -34,6 +34,8 @@ define Build/Compile
endef
define KernelPackage/mmc-over-gpio/install
+ $(INSTALL_DIR) $(1)/etc/config
+ $(INSTALL_DATA) ./files/mmc_over_gpio.config $(1)/etc/config/mmc_over_gpio
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/mmc_over_gpio.init $(1)/etc/init.d/mmc_over_gpio
endef
diff --git a/package/mmc_over_gpio/files/mmc_over_gpio.config b/package/mmc_over_gpio/files/mmc_over_gpio.config
new file mode 100644
index 0000000..77a9e30
--- /dev/null
+++ b/package/mmc_over_gpio/files/mmc_over_gpio.config
@@ -0,0 +1,8 @@
+config 'mmc_over_gpio'
+ option 'name' 'default'
+ option 'enabled' '0'
+ option 'DI_pin' '1'
+ option 'DO_pin' '3'
+ option 'CLK_pin' '4'
+ option 'CS_pin' '7'
+ option 'mode' '0'
diff --git a/package/mmc_over_gpio/files/mmc_over_gpio.init b/package/mmc_over_gpio/files/mmc_over_gpio.init
index e276dfd..121c803 100644
--- a/package/mmc_over_gpio/files/mmc_over_gpio.init
+++ b/package/mmc_over_gpio/files/mmc_over_gpio.init
@@ -8,7 +8,7 @@ CONFIGFS_DIR="/config/gpiommc"
add_device() {
local dir="$CONFIGFS_DIR/$1"
- mkdir $dir
+ mkdir -p $dir
[ $? -eq 0 ] || return 1
echo $2 > $dir/gpio_data_in
[ $? -eq 0 ] || return 1
@@ -50,15 +50,34 @@ mount_configfs() {
return 0
}
+start_service() {
+ local section="$1"
+ config_get "name" "$section" "name"
+ config_get "DI_pin" "$section" "DI_pin"
+ config_get "DO_pin" "$section" "DO_pin"
+ config_get "CLK_pin" "$section" "CLK_pin"
+ config_get "CS_pin" "$section" "CS_pin"
+ config_get "mode" "$section" "mode"
+ config_get_bool "enabled" "$section" "enabled" '1'
+ [ "$enabled" -gt 0 ] && add_device "$name" $DI_pin $DO_pin $CLK_pin $CS_pin $mode &
+}
+
+stop_service() {
+ local section="$1"
+ config_get "name" "$section" "name"
+ remove_device "$name"
+}
+
start() {
# Make sure configfs is mounted
mount_configfs
[ $? -eq 0 ] || return 1
- #FIXME we should use a config file, but I dunno how that parser works.
- add_device "default" 5 4 3 7 0
+ config_load "mmc_over_gpio"
+ config_foreach start_service "mmc_over_gpio"
}
stop() {
- remove_device "default"
+ config_load "mmc_over_gpio"
+ config_foreach stop_service "mmc_over_gpio"
}