summaryrefslogtreecommitdiff
path: root/recipes-bsp/multitech/mts-io/mts-io.init
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-bsp/multitech/mts-io/mts-io.init')
-rw-r--r--recipes-bsp/multitech/mts-io/mts-io.init38
1 files changed, 32 insertions, 6 deletions
diff --git a/recipes-bsp/multitech/mts-io/mts-io.init b/recipes-bsp/multitech/mts-io/mts-io.init
index 45d45df..550cc85 100644
--- a/recipes-bsp/multitech/mts-io/mts-io.init
+++ b/recipes-bsp/multitech/mts-io/mts-io.init
@@ -9,10 +9,12 @@
# Conduit features.
### END INIT INFO
+. /etc/default/mts-io
((fail=0))
# To log debug, set LOGDBG to /usr/bin/LOGGER
if ((DEBUG)) ; then
LOGDBG=/usr/bin/logger
+ ${LOGDBG} -t "mts-io" -p daemon.info -s "LOGDBG turned on"
else
LOGDBG=":"
fi
@@ -29,15 +31,38 @@ RST[2]="${sysdir}/ap1/reset"
RST[3]="${sysdir}/ap1/creset"
RST[4]="${sysdir}/ap2/reset"
RST[5]="${sysdir}/ap2/creset"
-RST[6]="${sysdir}/gnss-reset"
-RST[7]="${sysdir}/secure-reset"
-RST[8]="${sysdir}/eth-reset"
-RST[9]="${sysdir}/sm1-reset"
+RST[6]="${sysdir}/secure-reset"
+RST[7]="${sysdir}/eth-reset"
+RST[8]="${sysdir}/sm1-reset"
+if ((GPSGNSSRESET)) ; then
+ RST[9]="${sysdir}/gnss-reset"
+fi
+WPIN[0]="${sysdir}/ap1/cdone"
+WPIN[1]="${sysdir}/ap2/cdone"
USLPTIME=60000 # 30 milliseconds from Redpine Signals Reset Spec
WAIT="/bin/busybox usleep ${USLPTIME}"
+# Wait 10 WAIT intervals for pins to come high
+waitpins() {
+ ((i=0))
+ while((i < ${#WPIN[@]})) ; do
+ ((j=0))
+ while [[ -r ${WPIN[$i]} ]] && ! (($(cat ${WPIN[$i]}))) ; do
+ logger -t "mts-io" -p daemon.error -s "Wait on ${WPIN[$i]}"
+ ${WAIT}
+ ((j++))
+ if ((j > 10)) ; then
+ ((fail++))
+ ${LOGDBG} -t "mts-io" -p daemon.error -s "Ready failure on ${WPIN[$i]}"
+ break
+ fi
+ done
+ ((i++))
+ done
+}
+
reset_path() {
pin=$1
${LOGDBG} -t "mts-io" -p daemon.info Reset $pin
@@ -55,7 +80,6 @@ reset_path() {
return 0
}
reset_array() {
- fail=0
((i=${#RST[@]}-1))
while ((i>=0)) ; do
if [[ -f ${RST[$i]} ]] ; then
@@ -158,7 +182,9 @@ case $1 in
if ! reset_path $RS9113RST ; then
((fail++))
fi
-
+
+ waitpins
+
if ((fail == 0)) ; then
echo "OK"
else