summaryrefslogtreecommitdiffstats
path: root/target/device/valka/target_skeleton/etc/rc.d/gpio
blob: 39eb74dcc4c147cf3fbcf431afa54103674f13cd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/ash
. /etc/rc.subr

start() {
	echo -n " * Setting up GPIO: "

	if ! create_gpio "io0" 1 0x03f8802a 0x03f88000; then
		log_error "io0 failed"
		echo "failed"
		return 1
	fi
	if ! create_gpio "io1" 0 0xaa800000 0x00000000; then
		log_error "io1 failed"
		echo "failed"
		return 1
	fi
	echo "Ok"
}

stop() {
	return 0
}

create_gpio() {
	if ! mkdir_fs /config/gpio/${1}; then
		return 1
	fi
	echo "${2}" > /config/gpio/${1}/gpio_id
	echo "${3}" > /config/gpio/${1}/pin_mask
	echo "${4}" > /config/gpio/${1}/oe_mask
	echo "1" > /config/gpio/${1}/enabled
}

rc_run_command "$1" "gpio"