summaryrefslogtreecommitdiffstats
path: root/meta-facebook/meta-wedge/recipes-wedge/fbutils/files/power-on.sh
blob: ace3c6a746ab8c7e2dfc3f7630569d05e88db5fb (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
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/sh
#
# Copyright 2014-present Facebook. All Rights Reserved.
#
# This program file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; version 2 of the License.
#
# This program is distributed 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.  See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program in a file named COPYING; if not, write to the
# Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301 USA

### BEGIN INIT INFO
# Provides:          power-on
# Required-Start:
# Required-Stop:
# Default-Start:     S
# Default-Stop:
# Short-Description: Power on micro-server
### END INIT INFO
. /usr/local/bin/openbmc-utils.sh

PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin

echo -n "Checking microserver power status ... "
if wedge_is_us_on 10 "."; then
    echo "on"
    on=1
else
    echo "off"
    on=0
fi

if [ $on -eq 0 ]; then
    # Reset USB hub
    /usr/local/bin/reset_usb.sh
    # Set up ROV
    /usr/local/bin/setup_rov.sh
    # Configure the management switch on LEFT side of FC.
    # Must do so after setup_rov.sh, as setup_rov.sh might reset
    # T2, which also resets the switch.
    if [ "$(wedge_board_type)" = "FC-LEFT" ]; then
        echo -n "Configure management switch ... "
        if [ $(wedge_board_rev) -gt 1 ]; then
            echo "skip. Need new switch setup script!!!"
        else
            # configure MDIO as GPIO output
            gpio_set A6 1
            gpio_set A7 1
            # set the switch to be configured by CPU
            gpio_set E2 1
            # set the switch to be configured by CPU, then reset the switch,
            # which also cause T2 reset in the current board
            gpio_set E2 1
            gpio_set C0 0
            sleep 1
            gpio_set C0 1
            # configure the switch
            setup_switch.py
            echo "done"
        fi
    fi
    # Power on now
    wedge_power.sh on -f
fi
OpenPOWER on IntegriCloud