#!/bin/sh -e
#
# rc.config-itbp-modem v0.11
#
# This script configs the BBB ports for usage with the ITBP modular modems; Eg.: c-uGSM,  
# h-nanoGSM, d-u3G. More details can be found on http://itbrainpower.net
#
# This SOFTWARE is distributed is provide "AS IS" in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied 
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# Dragos Iosub, Bucharest 2017.
# http://itbrainpower.net
#

# next line loads the universaln cape [no IO port mapped over BBB HDMI] 
# reference: https://github.com/cdsteinkuehler/beaglebone-universal-io
/usr/local/bin/config-pin overlay cape-universaln #> /dev/null 2>&1

# next 3 lines, config P9_14, P9_16 and P9_18 as input pins WITHOUT pullings. 
# Those pins will be used as CONTROL interface for the ITBP modular modems.
/usr/local/bin/config-pin P9_14 in
/usr/local/bin/config-pin P9_16 in
/usr/local/bin/config-pin P9_18 in

#next four lines, config the P9_24 and P9_26 ports to be internally connected to UART1
cd /sys/devices/ocp.*/P9_24_pinmux.*/
echo uart > state
cd /sys/devices/ocp.*/P9_26_pinmux.*/
echo uart > state

#next line, enable the UART1 [will be available under linux as /dev/ttyO1]
/usr/local/bin/config-pin overlay BB-UART1 #> /dev/null 2>&1


exit 0