#!/bin/sh -e
#
# rc.config-itbp-uGSM-modem v0.22
#
# This script configs the BBB ports for usage with the u-GSM modems [https://itbrainpower.net/u-GSM]  
#
# Tested on BeagleBoard.org Debian Buster IoT Image 2020-04-06, kernel version 4.19.94-ti-r42 - the default image found shipped on new BBB
#
# 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.
#
# itbrainpower.net invests significant time and resources providing those how to and in design phase of our IoT products.
# Support us by purchasing itbrainpower.net modems from https://itbrainpower.net/order#u-GSM
#
# Dragos Iosub, Bucharest 2023.
# http://itbrainpower.net
#

# next 3 lines, config P9_14, P9_16 and P9_12 as input pins WITHOUT pullings. 
# Those pins will be used as CONTROL interface for the ITBP modular modems.
sudo /usr/bin/config-pin P9_16 gpio_input #GPIO_51 ==> u-GSM pin STS
sudo /usr/bin/config-pin P9_14 gpio #GPIO_50 ==> u-GSM pin ENA
sudo /usr/bin/config-pin P9_12 gpio #GPIO_60 ==> u-GSM pin RST
  
#next four lines, config the P9_11 and P9_13 ports to be internally connected to UART4 [will be available under linux as /dev/ttyO4]
cd /sys/devices/platform/ocp/ocp:P9_11_pinmux*/
echo uart > state
cd /sys/devices/platform/ocp/ocp:P9_13_pinmux*/
echo uart > state

exit 0