1#!/bin/sh 2# Select UART Mux: UART Mux for switching between Host and BIC on Slot1 ~ Slot4 3# Usage: select-uart-mux <slot1|slot2|slot3|slot4> <host|bic> 4 5REG_OFFSET="0x01" 6input_slot=$1 7input_target=$2 8i2c_bus_id= 9 10show_usage() { 11 echo "Usage: select-uart-mux [ slot1 | slot2 | slot3 | slot4 ] [ host | bic ]" 12 echo "Select UART Mux" 13} 14 15if [ $# -gt 3 ]; then 16 show_usage 17 exit 255 18fi 19 20case $input_slot in 21 slot1) 22 i2c_bus_id="4" 23 ;; 24 slot2) 25 i2c_bus_id="5" 26 ;; 27 slot3) 28 i2c_bus_id="6" 29 ;; 30 slot4) 31 i2c_bus_id="7" 32 ;; 33 *) 34 echo "Slot must between 1 to 4." 35 show_usage 36 exit 255 37 ;; 38 esac 39 40case $input_target in 41 host) 42 reg_val="0x03" 43 ;; 44 bic) 45 reg_val="0x04" 46 ;; 47 *) 48 echo "Input must be host or bic." 49 show_usage 50 exit 255 51 esac 52 53i2ctransfer -y -f $i2c_bus_id w2@0x0f $REG_OFFSET $reg_val 54 55val=$(i2ctransfer -y -f $i2c_bus_id w1@0x0f $REG_OFFSET r1) 56ret=$? 57 58if [ $ret -ne 0 ] || [ "$val" != $reg_val ]; then 59 echo "Failed to modify the register value, the register value is $val instead of $reg_val." 60 exit 255 61fi 62