Skip to content

Commit

Permalink
ELBERT: Enhance pim_enable.sh (#105)
Browse files Browse the repository at this point in the history
Summary:
ELBERT: Fix PIM8DDM gpio mapping

The UCD pins on pim8ddm and pim16q are different, so fixing our pim_enable scripts to toggle this.
Also, setting FULL_POWER to 0 currently does nothing, so removing this for now. power_off_pim will simply turn FPGA off. We are tracking investigating improvements to this separately to assess if we need to control power domain as well to reduce power.

Testing:

pimreset many times pim8ddm/pim16q mixed card system.

Pull Request resolved: facebookexternal/openbmc.arista#105

Reviewed By: mikechoifb

fbshipit-source-id: 313fbf2e1b
  • Loading branch information
joancaneus authored and facebook-github-bot committed Nov 4, 2020
1 parent fa614ff commit f2258b4
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,34 @@ wedge_power_off_board() {

power_on_pim() {
pim=$1
old_pwr_value=$(gpio_get PIM"${pim}"_FULL_POWER_EN keepdirection)
old_rst_value=$(gpio_get PIM"${pim}"_FPGA_RESET_L keepdirection)
if [ "$old_pwr_value" -eq 1 ] && [ "$old_rst_value" -eq 1 ]; then
logger pim_enable: PIM"${pim}" already powered on
if [ "$old_rst_value" -eq 1 ]; then
# already powered on, skip
return
fi
gpio_set PIM"${pim}"_FULL_POWER_EN 1 # full power on

# Skip power_on if we are still powercycling
if [ "$(head -n 1 "$SMBCPLD_SYSFS_DIR"/pim_reset)" != '0x0' ]; then
logger pim_enable: skipping power_on_pim. PIM"$pim" is still powercycling
return
fi

# Skip power_on if the FPGA is still being programmed
pim_major=$(head -n 1 "$SMBCPLD_SYSFS_DIR"/pim"$pim"_fpga_rev_major)
if [ "$((pim_major))" -eq 255 ]; then
logger pim_enable: skipping power_on_pim. PIM"$pim" is fpga loading is not complete
return
fi

fpga_done_value=$(gpio_get PIM"${pim}"_FPGA_DONE keepdirection)
if [ "$fpga_done_value" -eq 0 ]; then
logger pim_enable: skipping power_on_pim. PIM"$pim" is FPGA_DONE is not ready
return
fi

sleep 0.5 # Give FPGA some time to finish initialization
gpio_set PIM"${pim}"_FPGA_RESET_L 1 # FPGA out of reset
sleep 0.1

skip_pim_off_cache=$2
pim_off_cache="/tmp/.pim${pim}_powered_off"
Expand All @@ -121,15 +140,14 @@ power_on_pim() {

power_off_pim() {
pim=$1
old_pwr_value=$(gpio_get PIM"${pim}"_FULL_POWER_EN keepdirection)
old_rst_value=$(gpio_get PIM"${pim}"_FPGA_RESET_L keepdirection)
if [ "$old_pwr_value" -eq 0 ] && [ "$old_rst_value" -eq 0 ]; then
logger pim_enable: PIM"${pim}" already powered off
if [ "$old_rst_value" -eq 0 ]; then
# already powered off, skip
return
fi

gpio_set PIM"${pim}"_FPGA_RESET_L 0 # FPGA in reset
gpio_set PIM"${pim}"_FULL_POWER_EN 0 # full power off
sleep 0.1

skip_pim_off_cache=$2
pim_off_cache="/tmp/.pim${pim}_powered_off"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,41 @@ pim_found=(0 0 0 0 0 0 0 0)
pim_bus=(16 17 18 23 20 21 22 19)
dpm_addr=4e

try_create_gpio() {
chip="$1"
pin_id="$2"
gpioname="$3"

# Export GPIO if it doesn't exist
gpio_num=$(gpio_name2value "$gpioname")
if ! [[ "$gpio_num" =~ ^[0-9]+$ ]]; then
gpio_export_by_offset "${chip}" "$pin_id" "$gpioname"
fi
}

create_pim_gpio() {
local pim
pim=$1
chip=$2

# Check if GPIO name has already been exported
gpio_num=$(gpio_name2value PIM"${pim}"_FULL_POWER_EN)
if ! [[ "$gpio_num" =~ ^[0-9]+$ ]]; then
gpio_export_by_offset "${chip}" 4 PIM"${pim}"_FULL_POWER_EN
fru="$(peutil "$pim" 2>&1)"
if echo "$fru" | grep -q '88-16CD'; then
pim_type='PIM16Q'
try_create_gpio "$chip" 22 PIM"$pim"_FPGA_RESET_L # GPIO17 PIN26
try_create_gpio "$chip" 4 PIM"$pim"_FULL_POWER_EN # GPIO9 PIN14
try_create_gpio "$chip" 20 PIM"$pim"_FPGA_DONE # GPIO15 PIN24
try_create_gpio "$chip" 21 PIM"$pim"_FPGA_INIT # GPIO16 PIN25
elif echo "$fru" | grep -q '88-8D'; then
pim_type='PIM8DDM'
try_create_gpio "$chip" 22 PIM"$pim"_FPGA_RESET_L # GPIO17 PIN26
try_create_gpio "$chip" 8 PIM"$pim"_FULL_POWER_EN # GPI1 PIN22
try_create_gpio "$chip" 20 PIM"$pim"_FPGA_DONE # GPIO15 PIN24
try_create_gpio "$chip" 21 PIM"$pim"_FPGA_INIT # GPIO16 PIN25
else
logger pim_enable: Could not identify PIM"${pim}" model
return
fi

gpio_num=$(gpio_name2value PIM"${pim}"_FPGA_RESET_L)
if ! [[ "$gpio_num" =~ ^[0-9]+$ ]]; then
gpio_export_by_offset "${chip}" 22 PIM"${pim}"_FPGA_RESET_L
fi

logger pim_enable: registered PIM"${pim}" with GPIO chip "${chip}"
logger pim_enable: registered "${pim_type}" PIM"${pim}" with GPIO chip "${chip}"
}

# Clear pimserial endpoint cache if pim doesn't exist but the pimserial file does
Expand Down Expand Up @@ -83,6 +101,7 @@ while true; do
fi
fi
done

# 2. For discovered gpios, try turning it on
for i in "${pim_index[@]}"
do
Expand Down

0 comments on commit f2258b4

Please sign in to comment.