diff options
Diffstat (limited to 'recipes-bsp/multitech/mt-dt-overlay/init')
-rwxr-xr-x | recipes-bsp/multitech/mt-dt-overlay/init | 63 |
1 files changed, 38 insertions, 25 deletions
diff --git a/recipes-bsp/multitech/mt-dt-overlay/init b/recipes-bsp/multitech/mt-dt-overlay/init index 00af9f8..4c82e12 100755 --- a/recipes-bsp/multitech/mt-dt-overlay/init +++ b/recipes-bsp/multitech/mt-dt-overlay/init @@ -5,41 +5,54 @@ # device tree. sysdir=/sys/devices/platform/mts-io -i2c=/sys/bus/i2c/devices/ -eepromPath="/sys/bus/i2c/devices/0-0056/eeprom" +I2CDIR="/sys/bus/i2c/devices" +eepromPath="${I2CDIR}/0-0056/eeprom" DEVTREE="/sys/kernel/config/device-tree/overlays/" SYSFS="/usr/sbin/mts-io-sysfs" -I2CDIR="/sys/bus/i2c/devices" -AP1_EEPROM=$I2CDIR"/1-0050/eeprom" -AP2_EEPROM=$I2CDIR"/1-0052/eeprom" +AP1_EEPROM=${I2CDIR}"/1-0050/eeprom" +AP2_EEPROM=${I2CDIR}"/1-0052/eeprom" + +install_all_dtbo() { + for f in *.dtbo ; do + if ! [[ -f $f ]] ; then + continue + fi + # f2 is the extracted device name + base=$(basename $f .dtbo) + /bin/mkdir ${DEVTREE}/$base || true + /bin/cat $f >${DEVTREE}/$base/dtbo + done +} install_dtbo_dir() { if ! [[ -d ${DEVTREE} ]] ; then mount configfs fi - if ([ -f "$AP1_EEPROM" ] && grep -q GPIOB "$AP1_EEPROM") || ([ -f "$AP2_EEPROM" ] && grep -q GPIOB "$AP2_EEPROM"); then - for f in *gpiob.dtbo ; do - if ! [[ -f $f ]] ; then - continue - fi - # f2 is the extracted device name - base=$(basename $f .dtbo) - /bin/mkdir ${DEVTREE}/$base || true - /bin/cat $f >${DEVTREE}/$base/dtbo - done - modprobe mt_ac_gpiob + install_all_dtbo + gpiob1=0 + gpiob2=0 + if [[ -f $AP1_EEPROM ]] ; then + eeprom1=$(mts-id-eeprom --accessory-card --in-file "$AP1_EEPROM" 2>/dev/null) + if [[ $eeprom1 =~ [[:space:]]hw-version:[[:space:]]*\"MTAC-GPIOB- ]] ; then + gpiob1=1 + fi + fi + if [[ -f $AP2_EEPROM ]] ; then + eeprom2=$(mts-id-eeprom --accessory-card --in-file "$AP2_EEPROM" 2>/dev/null) + if [[ $eeprom2 =~ [[:space:]]hw-version:[[:space:]]*\"MTAC-GPIOB- ]] ; then + gpiob2=1 + fi + fi + + if ((gpiob1 == 1)) || ((gpiob2 == 1)) ; then + /usr/bin/logger -t "mts-io" -p daemon.info -s 'Loading MTAC-GPIOB Device Tree' + cd gpiob else - for f in *.dtbo ; do - if ! [[ -f $f ]] ; then - continue - fi - # f2 is the extracted device name - base=$(basename $f .dtbo) - /bin/mkdir ${DEVTREE}/$base || true - /bin/cat $f >${DEVTREE}/$base/dtbo - done + /usr/bin/logger -t "mts-io" -p daemon.info -s 'Loading standard SPI Device Tree' + cd lora fi + install_all_dtbo } # Device tree format: |