From e7855d00efd4596ea20a92f711e55813d88e0d28 Mon Sep 17 00:00:00 2001 From: Thomas Cort Date: Thu, 22 Aug 2013 11:22:01 -0400 Subject: [PATCH] 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 --- distrib/sets/lists/minix/md.evbarm | 2 ++ etc/Makefile | 5 +++ etc/rc.capes/BB-BONE-WTHR-01 | 19 ++++++++++++ etc/usr/rc | 49 ++++++++++++++++++++++++++++++ 4 files changed, 75 insertions(+) create mode 100644 etc/rc.capes/BB-BONE-WTHR-01 diff --git a/distrib/sets/lists/minix/md.evbarm b/distrib/sets/lists/minix/md.evbarm index 95360b4cb..0c38ead57 100644 --- a/distrib/sets/lists/minix/md.evbarm +++ b/distrib/sets/lists/minix/md.evbarm @@ -4,6 +4,8 @@ ./boot/minix/.temp/mod10_vm minix-sys ./boot/minix/.temp/mod11_pfs 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 ./multiboot/mod07_log minix-sys ./multiboot/mod08_tty minix-sys diff --git a/etc/Makefile b/etc/Makefile index 0092b03c3..f070c3a3b 100644 --- a/etc/Makefile +++ b/etc/Makefile @@ -458,6 +458,11 @@ install-etc-files-safe: .PHONY .MAKE check_DESTDIR MAKEDEV fi; \ ${INSTALL_FILE} -o ${owner} -g ${group} -m ${mode} ${sdir}${files} ${tdir}; .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 ${MAKEDIRTARGET} ${subdir} configinstall .endfor diff --git a/etc/rc.capes/BB-BONE-WTHR-01 b/etc/rc.capes/BB-BONE-WTHR-01 new file mode 100644 index 000000000..a8c58f790 --- /dev/null +++ b/etc/rc.capes/BB-BONE-WTHR-01 @@ -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" + diff --git a/etc/usr/rc b/etc/usr/rc index 7dfb42ffd..51f802a98 100644 --- a/etc/usr/rc +++ b/etc/usr/rc @@ -112,6 +112,49 @@ get_eth_labels() { 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 case $action in @@ -230,6 +273,9 @@ start) # fb hasn't been ported to AM335X yet. fi + # Detect expansion boards and start drivers. + capemgr + ;; A335BNLT) @@ -255,6 +301,9 @@ start) #up fb -dev /dev/fb0 -args edid.0=tda19988.1.3470 # fb hasn't been ported to AM335X yet. + # Detect expansion boards and start drivers. + capemgr + ;; UNKNOWN)