Commit e57501df authored by aTc's avatar aTc

Update letux scripts to 4.7 kernel

parent 99816ae2
#!/bin/sh
. /etc/pyra-kpkg.conf
version="$1"
vmlinuz_location="$2"
fdtdir=/usr/lib/linux-image-$version
initrd=/boot/initrd.img-$version
if [ ! -f $extlinux_conf ]
then
echo $extlinux_conf not found, skipping.
exit 0
fi
echo 1>&2 Adding entry to $extlinux_conf
echo >> $extlinux_conf
echo "#Autogenerated by kernel-image $version " >> $extlinux_conf
echo label $version >> $extlinux_conf
echo kernel $vmlinuz_location >> $extlinux_conf
echo append root=$root $options >> $extlinux_conf
echo fdtdir $fdtdir >> $extlinux_conf
if [ "$INITRD" = "Yes" ]; then
echo initrd $initrd >> $extlinux_conf
fi
echo "#End kernel-image $version " >> $extlinux_conf
echo 1>&2 Setting default kernel to $version
sed -i "0,/default/s/default.*/default $version/" $extlinux_conf
#!/bin/sh
. /etc/pyra-kpkg.conf
if [ ! -f $extlinux_conf ]
then
echo $extlinux_conf not found, skipping.
exit 0
fi
if [ -x /bin/mktemp ]; then
TMPFILE=$(mktemp -t kpkg-pyra-kernel.XXXXXX) || \
{ echo 1>&2 "Cannot create temporary file" ; exit 1; }
elif [ -x /bin/tempfile ]; then
TMPFILE=$(tempfile -p kpkg-pyra-kernel -m 0600 )|| \
{ echo 1>&2 "Cannot create temporary file" ; exit 1; };
else
set -e
mkdir /tmp/kpkg-pyra-kernel.$$
TMPFILE=/tmp/kpkg-pyra-kernel.$$/tmpfile
set +e
fi
trap "[ -f $TMPFILE ] && rm -f $TMPFILE; exit 1" 1 2 3 13 15
echo 1>&2 "Removing kernel entry $version from $extlinux_conf"
perl -nle "print unless /^#Autogenerated by kernel-image $version/ .. /^#End kernel-image $version/" < $extlinux_conf > $TMPFILE
mv -f $TMPFILE $extlinux_conf
rm -f $TMPFILE
if [ -d /tmp/kpkg-pyra-kernel.$$ ]; then
rmdir /tmp/kpkg-pyra-kernel.$$
fi
exit 0
# Pyra kernel config
# Settings here are used to generate /boot/extlinux/extlinux.conf entries when a new kernel is installed.
# Any changes made here won't change the existing extlinux.conf
extlinux_conf=/boot/extlinux/extlinux.conf
root=/dev/mmcblk1p1
options="console=ttyO2,115200n8 rw rootwait earlyprintk fixrtc omapdrm.num_crtc=2 consoleblank=0 vram=12M omapfb.vram=0:8M,1:4M omapdss.def_disp=hdmi"
......@@ -2,18 +2,18 @@
# if not in software-controlled charging mode, Vbus (and only that)
# has to be applied before running the script
#MUSB_MODE=/sys/bus/platform/devices/musb-hdrc/mode
#MUSB_MODE=/sys/bus/platform/devices/musb-hdrc.0/mode
MUSB_MODE=/sys/bus/platform/devices/musb-hdrc.1.auto/mode
MUSB_MODE=$(echo /sys/bus/platform/devices/musb-hdrc*/mode)
##MUSB_MODE=/sys/bus/platform/devices/musb-hdrc.1.auto/mode
USB_PHY=$(echo /sys/bus/platform/devices/*twl4030-usb)
MUSB_M=`cat $MUSB_MODE`
echo "$MUSB_M"
if [ "$MUSB_M" != b_idle ] ; then
echo Invalid mode at start
exit
exit
fi
# trigger a transition from b_idle to b_peripheral by simulating
# a connection to a host (enable pull-down resistors)
echo on > /sys/bus/platform/devices/twl4030_usb/fake_host
echo on > $USB_PHY/fake_host
sleep 0.2
cat $MUSB_MODE
# trigger a transition from b_peripheral to b_hnp_enable
......@@ -21,12 +21,12 @@ echo host >$MUSB_MODE
cat $MUSB_MODE
sleep 0.2
# simulate a disconnection from host
echo off > /sys/bus/platform/devices/twl4030_usb/fake_host
echo off > $USB_PHY/fake_host
sleep 0.2
cat $MUSB_MODE
# be a host by ourselfs (if we wouldn't mess with this bit,
# it would be already set here)
echo on > /sys/bus/platform/devices/twl4030_usb/fake_host
echo on > $USB_PHY/fake_host
MUSB_M=`cat $MUSB_MODE`
echo "$MUSB_M"
......
......@@ -9,7 +9,7 @@ CHARGER=/sys/class/power_supply/twl4030_usb
BQ27000=/sys/class/power_supply/bq27000-battery
# Pyra
[ -r "$CHARGER" ] || CHARGER=/sys/class/power_supply/bq24297
[ -r "$BQ27000" ] || BQ27000=/sys/class/power_supply/bq27425-0
[ -r "$BQ27000" ] || BQ27000=/sys/class/power_supply/bq27621-0
while true
do
......
#
# turn on/off backlight
# /root/bl: turn on/off backlight power
# -g: use gpio mode
# 1: turn on
# 0: turn off
#
# intensity can be controlled in non-gpio mode through
# /sys/class/backlight/backlight/brightness
#
BL=/sys/class/backlight/backlight/bl_power # just turn completely on/off instead of writing backlight intensity
ON=0
OFF=1
[ "$(which devmem2)" ] || apt-get install -y --force-yes devmem2
if [ "$1" = -g ]
then
USEGPIO=true
shift
fi
case $(cat /proc/device-tree/model) in
Pyra-Handheld* )
PADCONF=0x4a0028f6 # OMAP5
GPIOMODE=0x011e
PWMMODE=0x0118
GPIO=190
;;
*GTA04* )
PADCONF=0x480020b8 # OMAP3
GPIOMODE=0x011c
PWMMODE=0x011b
GPIO=57
;;
* )
USEGPIO="" # ignore -g
GPIO=none # there is no /sys/class/gpio/gpionone
;;
esac
BL=/sys/class/backlight/$(cd /sys/class/backlight/ && ls -1 | head -1)
if [ "$USEGPIO" ]
then
devmem2 $PADCONF h $GPIOMODE >/dev/null # switch to gpio mode
echo $GPIO > /sys/class/gpio/export 2>/dev/null
echo out > /sys/class/gpio/gpio$GPIO/direction
BL=/sys/class/gpio/gpio$GPIO/value
ON=1
OFF=0
elif [ -r /sys/class/gpio/gpio$GPIO ]
then
echo in > /sys/class/gpio/gpio$GPIO/direction
echo $GPIO > /sys/class/gpio/unexport 2>/dev/null
devmem2 $PADCONF h $PWMMODE >/dev/null # switch to pwm mode
fi
if [ "$1" = 1 ]
then
echo 0 >$BL/bl_power
echo $ON >$BL
else
echo 1 >$BL/bl_power
echo $OFF >$BL
fi
......@@ -30,9 +30,9 @@ int main(int argc, char *argv[])
return 1;
}
#if 1
file="/sys/devices/platform/pwm-backlight/backlight/pwm-backlight/brightness";
file="/sys/class/backlight/backlight/brightness";
#else
file="/sys/devices/platform/pwm-backlight/backlight/pwm-backlight/max_brightness";
file="/sys/class/backlight/backlight/max_brightness";
#endif
out=fopen(file, "w");
if(!out)
......@@ -43,48 +43,32 @@ int main(int argc, char *argv[])
while(1)
{
int i, n;
unsigned short x, y, pressure_raw, pressure, pendown;
unsigned short temperature, temp0, temp1;
unsigned short z1, z2;
unsigned short aux;
unsigned short ambient_light;
unsigned short bl;
file="/sys/bus/i2c/drivers/tsc2007/2-0048/values";
file="/sys/bus/iio/devices/iio:device1/in_voltage4_raw";
in=fopen(file, "r");
if(!in)
{
fprintf(stderr, "%s: %s\n", file, strerror(errno));
return 1;
}
n=fscanf(in, "%hu,%hu,%hu,%hu,%hu,%hu,%hu,%hu,%hu,%hu,%hu",
&x,
&y,
&pressure_raw,
&pendown,
&temperature,
&z1,
&z2,
&temp0,
&temp1,
&aux,
&pressure);
n=fscanf(in, "%hu", &aux);
fclose(in);
if(n == 11)
if(n == 1)
{
if(debug)
fprintf(stderr, "aux=%d", aux);
if(aux <= 4096 && aux > 2048) // max ambient light
if(aux > 2048) // max ambient light
ambient_light = 1;
else if(aux <= 2048 && aux > 1024)
else if(aux > 1024)
ambient_light = 2;
else if(aux <= 1024 && aux > 512)
else if(aux > 512)
ambient_light = 3;
else if(aux <= 512 && aux > 256)
else if(aux > 256)
ambient_light = 4;
else if(aux <= 256 && aux > 0) // min ambient light
ambient_light = 5;
else // something went wrong, go max
else // min ambient light
ambient_light = 5;
bl = ambient_light*20;
......
......@@ -33,6 +33,9 @@ echo reset >dcs # reset panel
sleep .1
echo noreset >dcs # take panel out of reset before starting the clocks
sleep .2
fbset -g 720 1280 720 1280 32
echo start >dcs # start MIPI interface
sleep .2
......@@ -54,10 +57,10 @@ echo g0001 >dcs # write address shift register
echo gff83 >dcs # write FF01h
echo g0002 >dcs # write address shift register
echo gff01 >dcs # write FF02h
shift
else
echo g0000 >dcs # write address shift register
echo gff128301 >dcs # write FF00h
shift
fi
# use address shift to specify lower 8 address bits
......
#
# scan bluetooth
#
case $(cat /proc/device-tree/model) in
*Pyra-Handheld* ) # WL183x
# enables the 32kHz clock
ifconfig wlan0 up
# load firmware if needed
FIRMWARE=/lib/firmware/ti-connectivity/TIInit_11.8.32.bts
[ -r $FIRMWARE ] || wget -O $FIRMWARE https://git.ti.com/ti-bt/service-packs/blobs/raw/5f73abe7c03631bb2596af27e41a94abcc70b009/initscripts/TIInit_12.8.32.bts
# set parameters
UART=/dev/ttyO1 # uart2
BTBAUD=115200 # for firmware download
FLAGS=
MODE=texas
ARGS=
;;
*GTA04A5* | *Neo900* | *GTA04b7* ) # WL183x
FIRMWARE=/lib/firmware/ti-connectivity/TIInit_11.8.32.bts
[ -r $FIRMWARE ] || wget -O $FIRMWARE https://git.ti.com/ti-bt/service-packs/blobs/raw/5f73abe7c03631bb2596af27e41a94abcc70b009/initscripts/TIInit_12.8.32.bts
UART=/dev/ttyO0 # uart1
BTBAUD=115200 # for firmware download
FLAGS=
MODE=texas
ARGS=
;;
*GTA04* ) # W2CBW003
UART=/dev/ttyO0 # uart1
BTBAUD=3000000
FLAGS="-s $BTBAUD"
MODE=any
ARGS=flow
;;
* )
echo "unknown model $(cat /proc/device-tree/model)"
exit 1
;;
esac
rfkill unblock bluetooth
modprobe -r st_drv
# start daemon
killall hciattach 2>/dev/null
if hciattach $FLAGS $UART $MODE $BTBAUD $ARGS
then
hciconfig hci0 up || exit 1
hcitool scan --info
bt-adapter -d
fi
TWL4030_MADC=/sys/devices/platform/68000000.ocp/48070000.i2c/i2c-0/0-0048/48070000.i2c:twl@48:madc/iio:device0
TWL6030_GPADC=/sys/devices/platform/44000000.ocp/48070000.i2c/i2c-0/0-0048/48070000.i2c:twl@48:adc/iio:device0
TWL6037_GPADC=/sys/devices/platform/44000000.ocp/48070000.i2c/i2c-0/0-0048/48070000.i2c:palmas@48:gpadc/iio:device0
#!/bin/bash
TWL4030_MADC=$(/root/findiio "48070000.i2c:twl@48:madc") # OMAP3
TWL6030_GPADC=$(/root/findiio "48070000.i2c:twl@48:adc") # OMAP4
TWL6037_GPADC=$(/root/findiio "palmas-gpadc") # OMAP5
if [ -d $TWL4030_MADC ]
then
function fuel-level { # $1 is mV; $2 is mA charging current; $3 is resistance, return is % [0..100]
# u = 0.001 * (u + mA * resistance)
# u = 0.0387-(1.4523*(3.7835-v))
# if u < 0:
# Formula above gives 19.66% for 3.756, and refuses to
# work below that. Assume 3.3V is empty battery, and provide
# linear dependency below that.
# u = (v - 3.3) * ((3.756 - 3.3) * 19.66)
# return u
# u = (0.1966+math.sqrt(u))*100
# if u > 100 return 100
# return u
expr \( "$VOLT" - 3300 \) \* 100 / 950
}
if [ -d "$TWL4030_MADC" ]
then # OMAP3 with TWL4030 / TPS65950
# enable high charging current if GTA04 is connected to USB
echo 800000 >/sys/class/power_supply/twl4030_usb/input_current_limit
# see http://www.mjmwired.net/kernel/Documentation/hwmon/twl4030-madc-hwmon for a list of channels
echo "Main Battery"
echo "============"
VOLT=$(cat $TWL4030_MADC/in_voltage12_input)
echo volt: ${VOLT}mV ca. $(expr \( "$VOLT" - 3300 \) \* 100 / 950)%
echo current: $(cat $TWL4030_MADC/in_current10_input)mA
echo temp: $(cat $TWL4030_MADC/in_temp1_input)°C
echo type: $(cat $TWL4030_MADC/in_voltage0_input)mV
echo micsense: $(cat $TWL4030_MADC/in_voltage7_input)mV
echo VBUS: $(cat $TWL4030_MADC/in_voltage8_input)mV
echo VCHG: $(cat $TWL4030_MADC/in_voltage11_input)mV
echo "TWL4030 Main Battery"
echo "===================="
VOLT=$(cat "$TWL4030_MADC/in_voltage12_input")
echo volt: ${VOLT}mV
echo current: $(cat "$TWL4030_MADC/in_current10_input")mA
# fixme: subtract 400mA from USB current
echo fuel level: ca. $(fuel-level "$VOLT" $(cat "$TWL4030_MADC/in_current10_input") 0.1)%
echo temp: $(cat "$TWL4030_MADC/in_temp1_input")°C
echo type: $(cat "$TWL4030_MADC/in_voltage0_input")mV
echo micsense: $(cat "$TWL4030_MADC/in_voltage7_input")mV
echo VBUS: $(cat "$TWL4030_MADC/in_voltage8_input")mV
echo VCHG: $(cat "$TWL4030_MADC/in_voltage11_input")mV
echo
echo "Backup battery"
echo "=============="
echo volt: $(cat $TWL4030_MADC/in_voltage9_input)mV
echo "TWL4030 Backup battery"
echo "======================"
echo volt: $(cat "$TWL4030_MADC/in_voltage9_input")mV
echo
fi
if [ -d $TWL6030_GPADC ]
if [ -d "$TWL6030_GPADC" ]
then # OMAP4 with twl6030
# channels (twl6030 only - twl6032 has different channels!)
......@@ -45,14 +69,14 @@ then # OMAP4 with twl6030
# 14 USB ID line voltage
# 15 test network
echo "System Voltage"
echo "=============="
echo "TWL6030 System Voltage"
echo "======================"
echo VSYS: $(cat $TWL6030_GPADC/in_voltage7_input)mV
echo
echo "Main Battery"
echo "============"
echo "TWL6030 Main Battery"
echo "===================="
VOLT=$(cat $TWL6030_GPADC/in_voltage7_input)
echo volt: ${VOLT}mV ca. $(expr \( "$VOLT" - 3300 \) \* 100 / 950)%
echo volt: ${VOLT}mV ca. $(fuel-level "$VOLT" $TWL6030_GPADC/in_voltage11_input 0.1)%
# NOTE: the driver reports mV and not mA or °C!
# NOTE: in_voltage11_input is missing on Pandaboard
# echo current: $(cat $TWL6030_GPADC/in_voltage11_input)mA
......@@ -63,13 +87,15 @@ echo VCHG: $(cat $TWL6030_GPADC/in_voltage9_input)mV
echo audio: $(cat $TWL6030_GPADC/in_voltage2_input)mV
echo usb id: $(cat $TWL6030_GPADC/in_voltage14_input)mV
echo
echo "Backup battery"
echo "=============="
echo "TWL6030 Backup battery"
echo "======================"
echo volt: $(cat $TWL6030_GPADC/in_voltage8_input)mV
echo
elif [ -d $TWL6037_GPADC ]
then # OMAP5 with Palmas
fi
if [ -d "$TWL6037_GPADC" ]
then # OMAP5 with Palmas (TWL6037)
# channels
# 0 battery type (source current 0, 5, 15, 20 uA)
......@@ -89,14 +115,14 @@ then # OMAP5 with Palmas
# 14 USB ID line voltage
# 15 test network
echo "System Voltage"
echo "=============="
echo "Palmas System Voltage"
echo "====================="
echo VSYS: $(cat $TWL6037_GPADC/in_voltage7_input)mV
echo
echo "Main Battery"
echo "============"
echo "Palmas Main Battery"
echo "==================="
VOLT=$(cat $TWL6037_GPADC/in_voltage6_input)
echo volt: ${VOLT}mV ca. $(expr \( "$VOLT" - 3300 \) \* 100 / 950)%
echo volt: ${VOLT}mV ca. $(fuel-level "$VOLT" $(cat "$TWL6037_GPADC/in_voltage11_input") 0.1)%
# NOTE: the driver reports mV and not mA or °C!
echo current: $(cat $TWL6037_GPADC/in_voltage11_input)mA
echo temp: $(cat $TWL6037_GPADC/in_temp1_raw)°C
......@@ -106,8 +132,8 @@ echo VCHG: $(cat $TWL6037_GPADC/in_voltage9_input)mV
echo audio: $(cat $TWL6037_GPADC/in_voltage2_input)mV
echo usb id: $(cat $TWL6037_GPADC/in_voltage14_input)mV
echo
echo "Backup battery"
echo "=============="
echo "Palmas Backup battery"
echo "====================="
echo volt: $(cat $TWL6037_GPADC/in_voltage8_input)mV
echo
......@@ -120,32 +146,32 @@ case "$(cat $SUPPLY/type 2>/dev/null)" in
USB )
echo "USB Charger $SUPPLY"
echo "============"
echo "==================="
echo type: $(cat $SUPPLY/type)
echo online: $(cat $SUPPLY/online 2>/dev/null)
echo status: $(cat $SUPPLY/status 2>/dev/null)
echo volt: $(cat $SUPPLY/voltage_now 2>/dev/null)uV
echo current: $(cat $SUPPLY/current_now 2>/dev/null)uA
echo max_current: $(cat $SUPPLY/max_current 2>/dev/null)uA
echo max_current: $(cat $SUPPLY/input_current_limit 2>/dev/null)uA
echo ID: $(cat /dev/usb_id 2>/dev/null)
echo
;;
Mains )
echo "AC Charger $SUPPLY"
echo "============"
echo "=================="
echo type: $(cat $SUPPLY/type 2>/dev/null)
echo online: $(cat $SUPPLY/online 2>/dev/null)
echo status: $(cat $SUPPLY/status 2>/dev/null)
echo volt: $(cat /sys$SUPPLY/voltage_now 2>/dev/null)uV
echo current: $(cat $SUPPLY/current_now 2>/dev/null)uA
echo max_current: $(cat $SUPPLY/max_current 2>/dev/null)uA
echo max_current: $(cat $SUPPLY/input_current_limit 2>/dev/null)uA
echo
;;
Battery )
echo "Battery $SUPPLY"
echo "======================"
echo "=================="
echo type: $(cat $SUPPLY/type 2>/dev/null)
echo present: $(cat $SUPPLY/present 2>/dev/null)
echo technology: $(cat $SUPPLY/technology 2>/dev/null)
......@@ -170,7 +196,7 @@ echo
* )
echo "Unknown $SUPPLY"
echo "======================"
echo "================="
echo type: $(cat $SUPPLY/type 2>/dev/null)
echo
;;
......
......@@ -124,7 +124,7 @@ case "$IF" in
) | ./femtocom $IF
;;
/dev/ttyACM0 | /dev/ttyUSB[0-4] ) # Neo900 / Pyra
/dev/ttyACM[0-4] | /dev/ttyUSB[0-4] ) # Neo900 / Pyra
# set up voice channel by programming twl4030/6040
......
# find hwmon device by name
LIST=false
if [ "$1" = "-a" ]
then
LIST=true
shift
fi
for dev in /sys/class/hwmon/hwmon*
do
$LIST && cat $dev/name
if [ "$(cat $dev/name 2>/dev/null)" = "$1" ]
then echo $dev
exit 0
fi
done
$LIST || exit 1
\ No newline at end of file
# find iio device by name
LIST=false
if [ "$1" = "-a" ]
then
LIST=true
shift
fi
for dev in /sys/bus/iio/devices/iio:device*
do
$LIST && cat $dev/name
if [ "$(cat $dev/name 2>/dev/null)" = "$1" ]
then echo $dev
exit 0
fi
done
$LIST || exit 1
\ No newline at end of file
# find regulator by name
LIST=false
if [ "$1" = "-a" ]
then
LIST=true
shift
fi
for dev in /sys/class/regulator/regulator.*
do
$LIST && cat $dev/name
if [ "$(cat $dev/name 2>/dev/null)" = "$1" ]
then echo $dev
exit 0
fi
done
$LIST || exit 1
\ No newline at end of file
# find thermal device by type
LIST=false
if [ "$1" = "-a" ]
then
LIST=true
shift
fi
for dev in /sys/class/thermal/thermal_zone*
do
$LIST && cat $dev/type
if [ "$(cat $dev/type 2>/dev/null)" = "$1" ]
then echo $dev
exit 0
fi
done
$LIST || exit 1
\ No newline at end of file
......@@ -3,60 +3,14 @@
# see also http://projects.goldelico.com/p/gta04-kernel/page/GPS/
#
SERIAL=/dev/ttyO1
case "$(uname -r)" in
2.6.* )