Add tusb6010 package and let tahvo-usb select it
[openwrt.git] / package / mmc_over_gpio / files / mmc_over_gpio.init
1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2008 OpenWrt.org
3 START=90
4
5 CONFIGFS_DIR="/config/gpiommc"
6
7 # add_device(name, DI_pin, DO_pin, CLK_pin, CS_pin, mode)
8 add_device() {
9 local dir="$CONFIGFS_DIR/$1"
10
11 mkdir -p $dir
12 [ $? -eq 0 ] || return 1
13 echo $2 > $dir/gpio_data_in
14 [ $? -eq 0 ] || return 1
15 echo $3 > $dir/gpio_data_out
16 [ $? -eq 0 ] || return 1
17 echo $4 > $dir/gpio_clock
18 [ $? -eq 0 ] || return 1
19 echo $5 > $dir/gpio_chipselect
20 [ $? -eq 0 ] || return 1
21 echo $6 > $dir/spi_mode
22 [ $? -eq 0 ] || return 1
23 # XXX We have more config options available. Use defaults for now.
24
25 echo 1 > $dir/register
26 [ $? -eq 0 ] || return 1
27
28 return 0
29 }
30
31 # remove_device(name)
32 remove_device() {
33 local dir="$CONFIGFS_DIR/$1"
34
35 rmdir $dir
36 }
37
38 mount_configfs() {
39 # FIXME: This should probably be done somewhere else.
40 mount | grep configfs
41 if [ $? -eq 0 ]; then
42 # already mounted
43 return 0
44 fi
45 mkdir -p /config
46 [ $? -eq 0 ] || return 1
47 mount configfs -t configfs /config
48 [ $? -eq 0 ] || return 1
49
50 return 0
51 }
52
53 start_service() {
54 local section="$1"
55 config_get "name" "$section" "name"
56 config_get "DI_pin" "$section" "DI_pin"
57 config_get "DO_pin" "$section" "DO_pin"
58 config_get "CLK_pin" "$section" "CLK_pin"
59 config_get "CS_pin" "$section" "CS_pin"
60 config_get "mode" "$section" "mode"
61 config_get_bool "enabled" "$section" "enabled" '1'
62 [ "$enabled" -gt 0 ] && add_device "$name" $DI_pin $DO_pin $CLK_pin $CS_pin $mode &
63 }
64
65 stop_service() {
66 local section="$1"
67 config_get "name" "$section" "name"
68 remove_device "$name"
69 }
70
71 start() {
72 # Make sure configfs is mounted
73 mount_configfs
74 [ $? -eq 0 ] || return 1
75
76 config_load "mmc_over_gpio"
77 config_foreach start_service "mmc_over_gpio"
78 }
79
80 stop() {
81 config_load "mmc_over_gpio"
82 config_foreach stop_service "mmc_over_gpio"
83 }
This page took 0.047841 seconds and 5 git commands to generate.