Package and install lindi's scripts
authorEnrico Zini <enrico@enricozini.org>
Tue, 13 Oct 2009 09:15:30 +0000 (10:15 +0100)
committerEnrico Zini <enrico@enricozini.org>
Tue, 13 Oct 2009 09:15:30 +0000 (10:15 +0100)
debian/zavai.install
lindi/README [new file with mode: 0644]
lindi/om-device [new file with mode: 0755]
lindi/om-make-sysfsrc [new file with mode: 0755]

index 743c10f5e553e0578e9d55f9298e012e32e96e07..4b5b6a6680ebb670904c0165b25e99719fd045b6 100644 (file)
@@ -3,3 +3,5 @@ icons usr/share/zavai
 src/display usr/share/doc/zavai/examples
 debian/zavai_forever usr/bin
 debian/zavai_launch_kbd usr/bin
+lindi/om-device usr/bin
+lindi/om-make-sysfsrc usr/bin
diff --git a/lindi/README b/lindi/README
new file mode 100644 (file)
index 0000000..d06177c
--- /dev/null
@@ -0,0 +1,3 @@
+These scripts are from Timo Juhani Lindfors.
+
+They are here until they will be split in a separate openmoko-scripts package.
diff --git a/lindi/om-device b/lindi/om-device
new file mode 100755 (executable)
index 0000000..b9a2c25
--- /dev/null
@@ -0,0 +1,91 @@
+#!/bin/sh
+. $HOME/.sysfsrc
+
+mode="$1"
+if [ "$mode" = "" ]; then
+    mode="list"
+fi
+case "$mode" in
+     stop)
+       dev="$2"
+       case "$dev" in
+           bt)
+               sudo sh -c "echo 1 > $sys_pm_bt/reset"
+               sudo sh -c "echo 0 > $sys_pm_bt_power"
+               ;;
+           gsm)
+               sudo sh -c "echo 0 > $sys_pm_gsm_power"
+               ;;
+           gps)
+               sudo sh -c "echo 0 > $sys_pm_gps_power"
+               if [ `cat $sys_pm_gps_power` = 1 ]; then
+                   echo "error, retrying"
+                   sudo sh -c "echo 1 > $sys_pm_gps_power"
+                   sudo sh -c "echo 0 > $sys_pm_gps_power"
+               fi
+               ;;
+           wifi)
+               sudo sh -c "echo s3c2440-sdi > $sys_wlan_driver/unbind"
+               ;;
+           *)
+               echo "unknown device $dev"
+               exit 1
+               ;;
+           esac
+       ;;
+    start)
+       dev="$2"
+       case "$dev" in
+           bt)
+               sudo sh -c "echo 1 > $sys_pm_bt_power"
+               sudo sh -c "echo 0 > $sys_pm_bt/reset"
+               ;;
+           gsm)
+               sudo sh -c "echo 0 > $sys_pm_gsm/power_on"
+               sudo sh -c "echo 1 > $sys_pm_gsm/power_on"
+               sudo sh -c "echo 1 > $sys_pm_gsm/reset"
+               ;;
+           gps)
+               sudo sh -c "echo 1 > $sys_pm_gps_power"
+               ;;
+           wifi)
+               sudo sh -c "echo s3c2440-sdi > $sys_wlan_driver/unbind" 2> /dev/null
+               sudo sh -c "echo s3c2440-sdi > $sys_wlan_driver/bind"
+               ;;
+           *)
+               echo "unknown device $dev"
+               exit 1
+               ;;
+           esac
+       ;;
+       
+     list)
+       echo "bt `cat $sys_pm_bt_power`"
+       echo "gsm `cat $sys_pm_gsm_power`"
+       echo "gps `cat $sys_pm_gps_power`"
+       #echo "wifi ?"
+       wifi 2> /dev/null
+       ;;
+    measure-consumption)
+       echo turning $2 on
+       $0 start $2
+       for i in `seq 1 30`; do
+           echo $i `cat $sys_battery/current_now`
+           sleep 1
+       done
+       start=`cat $sys_battery/current_now`
+       echo turning $2 off
+       $0 stop $2
+       for i in `seq 1 40`; do
+           echo $i `cat $sys_battery/current_now`
+           sleep 1
+       done
+       end=`cat $sys_battery/current_now`
+       diff=`expr $start - $end`
+       echo difference $diff
+       ;;
+    *)
+       echo "unknown operation $mode"
+       exit 1
+       ;;
+esac
diff --git a/lindi/om-make-sysfsrc b/lindi/om-make-sysfsrc
new file mode 100755 (executable)
index 0000000..9e60247
--- /dev/null
@@ -0,0 +1,22 @@
+#!/bin/sh
+sysfsrc="$HOME/.sysfsrc-`uname -r`"
+if [ ! -e "$sysfsrc" ]; then
+  (
+    echo export sys_pm_gps_power=`find /sys -wholename "*pm-gps*/power_on" -o -wholename "*pm-gps*/pwron"`
+    echo export sys_pm_bt_power=`find /sys -wholename "*pm-bt*/power_on" -o -wholename "*pm-bt*/pwron"`
+    echo export sys_pm_gsm=`find /sys -name neo1973-pm-gsm.0 -type d`
+    echo export sys_pm_gsm_power=`find /sys -wholename "*pm-gsm*/power_on" -o -wholename "*pm-gsm*/pwron"`
+    echo export sys_pm_wlan=`find /sys -wholename "*gta02-pm-wlan/gta02-pm-wlan.0"`
+    echo export sys_battery=`find /sys -wholename "*/power_supply/battery" -o -wholename "*/power_supply/bat" -type d`
+    echo export sys_usb_mode=`find /sys -name usb_mode`
+    echo export sys_hostmode=`find /sys -name hostmode`
+    echo export sys_brightness=`find /sys -wholename "*backlight*/brightness"`
+    echo export sys_resume_reason=`find /sys -wholename "*neo1973-resume.0/resume_reason"`
+    echo export sys_resume_reason2=`find /sys -wholename "*/0-0073/resume_reason"`
+    echo export sys_vibrator=`find /sys -name neo1973:vibrator`
+    echo export sys_auxled=`find /sys -name "gta02-aux:red"`
+    echo export sys_force_usb_limit_dangerous=`find /sys -name force_usb_limit_dangerous -o -name usb_curlim`
+    echo export sys_wlan_driver="/sys/bus/platform/drivers/s3c2440-sdi"
+  ) > "$sysfsrc"
+fi
+ln -fs $sysfsrc ~/.sysfsrc