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