summaryrefslogtreecommitdiffstats
path: root/meta-quanta/meta-gsj/recipes-phosphor/quanta-nvme-powerctrl/files/init_once.sh
blob: 2ea02ef8de8eb04738f53b820aa270f01c6408dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash

function set_gpio() {
  #$1 gpio pin
  echo $1 > /sys/class/gpio/export
}

function set_gpio_direction(){
    #$1 gpio pin, $2 'in','high','low'
    echo $2 > /sys/class/gpio/gpio$1/direction
}

function read_gpio_input(){
    #$1 read input gpio pin
    cat /sys/class/gpio/gpio$1/value
}

function read_present_set_related_power(){
    #$1 read present gpio, $2 output power gpio,$3 output direction
    var=$(cat /sys/class/gpio/gpio$1/value)
    # present 0 is plugged,present 1 is removal
    if [ "$var" == "0" ];then
        set_gpio_direction $2 "high"
    else 
        set_gpio_direction $2 "low"
    fi
}


## Initial U2_PRESNET_N
U2_PRESENT=( 148 149 150 151 152 153 154 155 )
for i in "${U2_PRESENT[@]}";
do 
    set_gpio $i;
    set_gpio_direction $i 'in';
done

## Initial POWER_U2_EN
POWER_U2=( 195 196 202 199 198 197 127 126 )
for i in "${POWER_U2[@]}";
do
    set_gpio $i;
done

## Initial PWRGD_U2
PWRGD_U2=( 161 162 163 164 165 166 167 168 )
for i in "${PWRGD_U2[@]}";
do 
    set_gpio $i;
    set_gpio_direction $i 'in';
done

### Initial SSD Power reference U2_PRESNET_N
for i in {0..7};
do
    read_present_set_related_power "${U2_PRESENT[$i]}" "${POWER_U2[$i]}";
done 


exit 0;
OpenPOWER on IntegriCloud