1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2008 OpenWrt.org
5 CONFIGFS_DIR
="/config/gpiommc"
7 # add_device(name, DI_pin, DO_pin, CLK_pin, CS_pin, mode)
9 local dir
="$CONFIGFS_DIR/$1"
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.
25 echo 1 > $dir/register
26 [ $?
-eq 0 ] ||
return 1
33 local dir
="$CONFIGFS_DIR/$1"
39 # FIXME: This should probably be done somewhere else.
46 [ $?
-eq 0 ] ||
return 1
47 mount configfs
-t configfs
/config
48 [ $?
-eq 0 ] ||
return 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 &
67 config_get
"name" "$section" "name"
72 # Make sure configfs is mounted
74 [ $?
-eq 0 ] ||
return 1
76 config_load
"mmc_over_gpio"
77 config_foreach start_service
"mmc_over_gpio"
81 config_load
"mmc_over_gpio"
82 config_foreach stop_service
"mmc_over_gpio"