blob: 2ea02ef8de8eb04738f53b820aa270f01c6408dc [file] [log] [blame]
Samuel Jiangabda5612019-03-21 13:47:13 +08001#!/bin/bash
2
3function set_gpio() {
4 #$1 gpio pin
5 echo $1 > /sys/class/gpio/export
6}
7
8function set_gpio_direction(){
9 #$1 gpio pin, $2 'in','high','low'
10 echo $2 > /sys/class/gpio/gpio$1/direction
11}
12
13function read_gpio_input(){
14 #$1 read input gpio pin
15 cat /sys/class/gpio/gpio$1/value
16}
17
18function read_present_set_related_power(){
19 #$1 read present gpio, $2 output power gpio,$3 output direction
20 var=$(cat /sys/class/gpio/gpio$1/value)
21 # present 0 is plugged,present 1 is removal
22 if [ "$var" == "0" ];then
23 set_gpio_direction $2 "high"
24 else
25 set_gpio_direction $2 "low"
26 fi
27}
28
29
30## Initial U2_PRESNET_N
31U2_PRESENT=( 148 149 150 151 152 153 154 155 )
32for i in "${U2_PRESENT[@]}";
33do
34 set_gpio $i;
35 set_gpio_direction $i 'in';
36done
37
38## Initial POWER_U2_EN
39POWER_U2=( 195 196 202 199 198 197 127 126 )
40for i in "${POWER_U2[@]}";
41do
42 set_gpio $i;
43done
44
45## Initial PWRGD_U2
46PWRGD_U2=( 161 162 163 164 165 166 167 168 )
47for i in "${PWRGD_U2[@]}";
48do
49 set_gpio $i;
50 set_gpio_direction $i 'in';
51done
52
53### Initial SSD Power reference U2_PRESNET_N
54for i in {0..7};
55do
56 read_present_set_related_power "${U2_PRESENT[$i]}" "${POWER_U2[$i]}";
57done
58
59
60exit 0;