]> Zhao Yanbai Git Server - minix.git/commitdiff
rc: start drivers for attached BeagleBone Capes 81/781/2
authorThomas Cort <tcort@minix3.org>
Thu, 22 Aug 2013 15:22:01 +0000 (11:22 -0400)
committerThomas Cort <tcort@minix3.org>
Thu, 22 Aug 2013 20:54:10 +0000 (16:54 -0400)
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
etc/Makefile
etc/rc.capes/BB-BONE-WTHR-01 [new file with mode: 0644]
etc/usr/rc

index 95360b4cbee1312df10ed1f4f83a8d967580e293..0c38ead5798d4d2b558c3169586b9bf1222adb50 100644 (file)
@@ -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
index 0092b03c36387e4ca46d2a3309d5540774647514..f070c3a3b6b7a072461c80330abbe3b91bf7238e 100644 (file)
@@ -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 (file)
index 0000000..a8c58f7
--- /dev/null
@@ -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"
+
index 7dfb42ffda07f521752866d4fac96dbb8cfce69c..51f802a98e8a9fcf2877565de4c28be656c5339f 100644 (file)
@@ -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)