rc: start drivers for attached BeagleBone Capes

BeagleBone Capes add additional hardware to the BeagleBone to
improve functionality.

This patch probes the third i2c bus for capes and loads the
appropriate drivers for each detected cape. Currently only
the 'BeagleBone Weather' cape is supported.

Change-Id: Id8c133810db6de7c21625c2d5a794b8874673a0f
This commit is contained in:
Thomas Cort 2013-08-22 11:22:01 -04:00
parent 54f7991f4c
commit e7855d00ef
4 changed files with 75 additions and 0 deletions

View file

@ -4,6 +4,8 @@
./boot/minix/.temp/mod10_vm minix-sys ./boot/minix/.temp/mod10_vm minix-sys
./boot/minix/.temp/mod11_pfs minix-sys ./boot/minix/.temp/mod11_pfs minix-sys
./boot/minix/.temp/mod12_init minix-sys ./boot/minix/.temp/mod12_init minix-sys
./etc/rc.capes minix-sys
./etc/rc.capes/BB-BONE-WTHR-01 minix-sys
./etc/system.conf.d/lan8710a minix-sys ./etc/system.conf.d/lan8710a minix-sys
./multiboot/mod07_log minix-sys ./multiboot/mod07_log minix-sys
./multiboot/mod08_tty minix-sys ./multiboot/mod08_tty minix-sys

View file

@ -458,6 +458,11 @@ install-etc-files-safe: .PHONY .MAKE check_DESTDIR MAKEDEV
fi; \ fi; \
${INSTALL_FILE} -o ${owner} -g ${group} -m ${mode} ${sdir}${files} ${tdir}; ${INSTALL_FILE} -o ${owner} -g ${group} -m ${mode} ${sdir}${files} ${tdir};
.endfor .endfor
.if ${MACHINE_ARCH} == "earm"
${_MKMSG_INSTALL} ${DESTDIR}/etc/rc.capes
${INSTALL_DIR} ${DESTDIR}/etc/rc.capes
${INSTALL_FILE} -m ${BINMODE} -o ${BINOWN} -g ${BINGRP} ${NETBSDSRCDIR}/etc/rc.capes/* ${DESTDIR}/etc/rc.capes
.endif # Minix/earm specific
.for subdir in . defaults mtree .for subdir in . defaults mtree
${MAKEDIRTARGET} ${subdir} configinstall ${MAKEDIRTARGET} ${subdir} configinstall
.endfor .endfor

View file

@ -0,0 +1,19 @@
#!/bin/sh
#
# Start-up script for the BeagleBone Weather cape.
# TSL2550 Ambient Light Sensor
test -e /dev/tsl2550b3s39 || (cd /dev && MAKEDEV tsl2550b3s39)
/bin/service up /usr/sbin/tsl2550 -dev /dev/tsl2550b3s39 \
-label tsl2550.3.39 -args 'bus=3 address=0x39' && echo -n " tsl2550"
# SHT21 Temperature and Humidity Sensor
test -e /dev/sht21b3s40 || (cd /dev && MAKEDEV sht21b3s40)
/bin/service up /usr/sbin/sht21 -dev /dev/sht21b3s40 \
-label sht21.3.40 -args 'bus=3 address=0x40' && echo -n " sht21"
# BMP085 Temperature and Pressure Sensor
test -e /dev/bmp085b3s77 || (cd /dev && MAKEDEV bmp085b3s77)
/bin/service up /usr/sbin/bmp085 -dev /dev/bmp085b3s77 \
-label bmp085.3.77 -args 'bus=3 address=0x77' && echo -n " bmp085"

View file

@ -112,6 +112,49 @@ get_eth_labels() {
grep -v '^vlan_' grep -v '^vlan_'
} }
# Detect expansion boards on the BeagleBone and load the proper drivers.
capemgr() {
# Probe each possible cape EEPROM slave address for a BeagleBone cape.
for slave_addr in 54 55 56 57
do
# See if there is a readable EEPROM with address ${slave_addr}.
eepromread -f /dev/i2c-3 -a 0x${slave_addr} > /dev/null 2>&1
RESULT=$?
if [ $RESULT -eq 0 ]
then
# Found an alive EEPROM. Try reading the cape name.
CAPE=`eepromread -i -f /dev/i2c-3 -a 0x${slave_addr} | \
sed -n 's/^PART_NUMBER : \(.*\)$/\1/p' | \
sed -e 's/\.*$//g'` # Strip trailing periods.
# Look for a cape specific RC script.
if [ -x /etc/rc.capes/${CAPE} ]
then
# CAT24C256 EEPROM -- all capes have this chip.
test -e /dev/eepromb3s${slave_addr} || \
(cd /dev && MAKEDEV eepromb3s${slave_addr})
up cat24c256 -dev /dev/eepromb3s${slave_addr} \
-label cat24c256.3.${slave_addr} \
-args "bus=3 address=0x${slave_addr}"
# Load the drivers for the cape and do any other configuration.
. "/etc/rc.capes/${CAPE}"
else
echo ""
echo "** UNSUPPORTED CAPE: ${CAPE}"
echo ""
fi
fi
done
}
DAEMONS=/etc/rc.daemons DAEMONS=/etc/rc.daemons
case $action in case $action in
@ -230,6 +273,9 @@ start)
# fb hasn't been ported to AM335X yet. # fb hasn't been ported to AM335X yet.
fi fi
# Detect expansion boards and start drivers.
capemgr
;; ;;
A335BNLT) A335BNLT)
@ -255,6 +301,9 @@ start)
#up fb -dev /dev/fb0 -args edid.0=tda19988.1.3470 #up fb -dev /dev/fb0 -args edid.0=tda19988.1.3470
# fb hasn't been ported to AM335X yet. # fb hasn't been ported to AM335X yet.
# Detect expansion boards and start drivers.
capemgr
;; ;;
UNKNOWN) UNKNOWN)