add feeds.conf to .gitignore
[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 $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() {
54 # Make sure configfs is mounted
55 mount_configfs
56 [ $? -eq 0 ] || return 1
57
58 #FIXME we should use a config file, but I dunno how that parser works.
59 add_device "default" 5 4 3 7 0
60 }
61
62 stop() {
63 remove_device "default"
64 }
This page took 0.057908 seconds and 5 git commands to generate.