diff options
Diffstat (limited to 'meta-facebook/meta-yosemite/recipes-yosemite/fbutils')
10 files changed, 431 insertions, 12 deletions
diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/fbutils_0.1.bb b/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/fbutils_0.1.bb index 9a9f5fe..e00f558 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/fbutils_0.1.bb +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/fbutils_0.1.bb @@ -83,7 +83,7 @@ do_install() { install -m 0755 ${WORKDIR}/rc.early ${D}${sysconfdir}/init.d/rc.early update-rc.d -r ${D} rc.early start 04 S . install -m 755 setup-gpio.sh ${D}${sysconfdir}/init.d/setup-gpio.sh - update-rc.d -r ${D} setup-gpio.sh start 59 S . + update-rc.d -r ${D} setup-gpio.sh start 59 5 . # create VLAN intf automatically #install -d ${D}/${sysconfdir}/network/if-up.d #install -m 755 create_vlan_intf ${D}${sysconfdir}/network/if-up.d/create_vlan_intf @@ -92,7 +92,7 @@ do_install() { #install -m 755 eth0_mac_fixup.sh ${D}${sysconfdir}/init.d/eth0_mac_fixup.sh #update-rc.d -r ${D} eth0_mac_fixup.sh start 70 S . install -m 755 power-on.sh ${D}${sysconfdir}/init.d/power-on.sh - update-rc.d -r ${D} power-on.sh start 85 S . + update-rc.d -r ${D} power-on.sh start 85 5 . #install -m 755 fcswitcher.sh ${D}${sysconfdir}/init.d/fcswitcher.sh #update-rc.d -r ${D} fcswitcher.sh start 90 S . install -m 0755 ${WORKDIR}/rc.local ${D}${sysconfdir}/init.d/rc.local diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/bic-util/bic-util.c b/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/bic-util/bic-util.c index 4a8966d..3ebc3f1 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/bic-util/bic-util.c +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/bic-util/bic-util.c @@ -55,6 +55,19 @@ util_get_device_id(uint8_t slot_id) { printf("Aux. FW Rev: 0x%X:0x%X:0x%X:0x%X\n", id.aux_fw_rev[0], id.aux_fw_rev[1],id.aux_fw_rev[2],id.aux_fw_rev[3]); } +static void +util_get_fw_ver(uint8_t slot_id) { + int i, j, ret; + uint8_t buf[16] = {0}; + for (i = 1; i <= 8; i++) { + ret = bic_get_fw_ver(slot_id, i, buf); + printf("version of comp: %d is", i); + for (j = 0; j < 10; j++) + printf("%02X:", buf[j]); + printf("\n"); + } +} + // Tests for reading GPIO values and configuration static void util_get_gpio(uint8_t slot_id) { @@ -363,6 +376,9 @@ main(int argc, char **argv) { slot_id = atoi(argv[1]); + util_get_fw_ver(slot_id); + +#if 0 util_get_device_id(slot_id); util_get_gpio(slot_id); @@ -381,4 +397,5 @@ main(int argc, char **argv) { util_get_sdr_info(slot_id); util_get_sdr(slot_id); util_read_sensor(slot_id); +#endif } diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/fpc-util/Makefile b/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/fpc-util/Makefile new file mode 100644 index 0000000..cb90045 --- /dev/null +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/fpc-util/Makefile @@ -0,0 +1,10 @@ +# Copyright 2015-present Facebook. All Rights Reserved. +all: fpc-util + +fpc-util: fpc-util.c + $(CC) -pthread -lipmi -lipmb -lbic -lpal -std=c99 -o $@ $^ $(LDFLAGS) + +.PHONY: clean + +clean: + rm -rf *.o fpc-util diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/fpc-util/fpc-util.c b/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/fpc-util/fpc-util.c new file mode 100644 index 0000000..93c1166 --- /dev/null +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/fpc-util/fpc-util.c @@ -0,0 +1,85 @@ +/* + * fpc-util + * + * Copyright 2015-present Facebook. All Rights Reserved. + * + * This program 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; either version 2 of the License, or + * (at your option) any later version. + * + * 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; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <errno.h> +#include <syslog.h> +#include <stdint.h> +#include <pthread.h> +#include <facebook/bic.h> +#include <openbmc/pal.h> +#include <openbmc/ipmi.h> + +static void +print_usage_help(void) { + printf("Usage: fpc-util <slot1|slot2|slot3|slot4> --usb\n"); + printf(" fpc-util <slot1|slot2|slot3|slot4|all> --identify <on/off>\n"); +} + +int +main(int argc, char **argv) { + + uint8_t slot_id; + char tstr[64] = {0}; + + if (argc < 3) { + goto err_exit; + } + + if (!strcmp(argv[1], "slot1")) { + slot_id = 1; + } else if (!strcmp(argv[1] , "slot2")) { + slot_id = 2; + } else if (!strcmp(argv[1] , "slot3")) { + slot_id = 3; + } else if (!strcmp(argv[1] , "slot4")) { + slot_id = 4; + } else if (!strcmp(argv[1] , "all")) { + slot_id = 0; + } else { + goto err_exit; + } + + if (!strcmp(argv[2], "--usb")) { + printf("fpc-util: switching USB channel to slot%d\n", slot_id); + return pal_switch_usb_mux(slot_id); + } else if (!strcmp(argv[2], "--identify")) { + if (argc != 4) { + goto err_exit; + } + printf("fpc-util: identication for %s is %s\n", argv[1], argv[3]); + if (slot_id == 0) { + sprintf(tstr, "identify_sled"); + } else { + sprintf(tstr, "identify_slot%d", slot_id); + } + + return pal_set_key_value(tstr, argv[3]); + } else { + goto err_exit; + } + + return 0; +err_exit: + print_usage_help(); + return -1; +} diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/fw-util/Makefile b/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/fw-util/Makefile new file mode 100644 index 0000000..b56fca9 --- /dev/null +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/fw-util/Makefile @@ -0,0 +1,10 @@ +# Copyright 2015-present Facebook. All Rights Reserved. +all: fw-util + +fw-util: fw-util.c + $(CC) -pthread -lipmi -lipmb -lbic -lpal -std=c99 -o $@ $^ $(LDFLAGS) + +.PHONY: clean + +clean: + rm -rf *.o fw-util diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/fw-util/fw-util.c b/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/fw-util/fw-util.c new file mode 100644 index 0000000..2b472b3 --- /dev/null +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/fw-util/fw-util.c @@ -0,0 +1,161 @@ +/* + * fw-util + * + * Copyright 2015-present Facebook. All Rights Reserved. + * + * This program 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; either version 2 of the License, or + * (at your option) any later version. + * + * 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; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <errno.h> +#include <syslog.h> +#include <stdint.h> +#include <pthread.h> +#include <facebook/bic.h> +#include <openbmc/pal.h> +#include <openbmc/ipmi.h> + +static void +print_usage_help(void) { + printf("Usage: fw_util <slot1|slot2|slot3|slot4> <--version>\n"); + printf(" fw_util <slot1|slot2|slot3|slot4> <--update> <--cpld> <path>\n"); +} + +// TODO: Need to confirm the interpretation of firmware version for print +// Right now using decimal to print the versions +static void +print_fw_ver(uint8_t slot_id) { + int i; + uint8_t ver[32] = {0}; + + // Print CPLD Version + if (bic_get_fw_ver(slot_id, FW_CPLD, ver)) { + return; + } + + printf("CPLD Version: 0x%02x%02x%02x%02x\n", ver[0], ver[1], ver[2], ver[3]); + + // Print Bridge-IC Version + if (bic_get_fw_ver(slot_id, FW_BIC, ver)) { + return; + } + + printf("Bridge-IC Version: v%x.%x\n", ver[0], ver[1]); + + // Print ME Version + if (bic_get_fw_ver(slot_id, FW_ME, ver)){ + return; + } + + printf("ME Version: %x.%x.%x.%x%x\n", ver[0], ver[1], ver[2], ver[3], ver[4]); + + // Print PVCCIN VR Version + if (bic_get_fw_ver(slot_id, FW_PVCCIN_VR, ver)){ + return; + } + + printf("PVCCIN VR Version: 0x%02x%02x, 0x%02x%02x\n", ver[0], ver[1], ver[2], ver[3]); + + // Print DDRAB VR Version + if (bic_get_fw_ver(slot_id, FW_DDRAB_VR, ver)){ + return; + } + + printf("DDRAB VR Version: 0x%02x%02x, 0x%02x%02x\n", ver[0], ver[1], ver[2], ver[3]); + + // Print P1V05 VR Version + if (bic_get_fw_ver(slot_id, FW_P1V05_VR, ver)){ + return; + } + + printf("P1V05 VR Version: 0x%02x%02x, 0x%02x%02x\n", ver[0], ver[1], ver[2], ver[3]); + + // Print PVCCGBE VR Version + if (bic_get_fw_ver(slot_id, FW_PVCCGBE_VR, ver)){ + return; + } + + printf("PVCCGBE VR Version: 0x%02x%02x, 0x%02x%02x\n", ver[0], ver[1], ver[2], ver[3]); + + // Print PVCCSCSUS VR Version + if (bic_get_fw_ver(slot_id, FW_PVCCSCSUS_VR, ver)){ + return; + } + + printf("PVCCSCSUS VR Version: 0x%02x%02x, 0x%02x%02x\n", ver[0], ver[1], ver[2], ver[3]); + + // Print BIOS version + if (pal_get_sysfw_ver(slot_id, ver)) { + return; + } + + // BIOS version response contains the length at offset 2 followed by ascii string + printf("BIOS Version: "); + for (i = 3; i < 3+ver[2]; i++) { + printf("%c", ver[i]); + } + printf("\n"); +} + +int +main(int argc, char **argv) { + + uint8_t slot_id; + + // Check for border conditions + if ((argc != 3) && (argc != 5)) { + goto err_exit; + } + + // Derive slot_id from first parameter + if (!strcmp(argv[1], "slot1")) { + slot_id = 1; + } else if (!strcmp(argv[1] , "slot2")) { + slot_id =2; + } else if (!strcmp(argv[1] , "slot3")) { + slot_id =3; + } else if (!strcmp(argv[1] , "slot4")) { + slot_id =4; + } else { + goto err_exit; + } + + // check operation to perform + if (!strcmp(argv[2], "--version")) { + // handle printing versions of f/w components + print_fw_ver(slot_id); + } else if (!strcmp(argv[2], "--update")) { + // handle firmware update + if (argc != 5) { + goto err_exit; + } + + if (!strcmp(argv[3], "--cpld")) { + return bic_update_fw(slot_id, UPDATE_CPLD, argv[4]); + } else { + goto err_exit; + } + } else { + goto err_exit; + } + + return 0; + +err_exit: + print_usage_help(); + return -1; +} diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/setup-gpio.sh b/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/setup-gpio.sh index 91797c5..10aad30 100755 --- a/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/setup-gpio.sh +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/setup-gpio.sh @@ -106,6 +106,20 @@ devmem_clear_bit $(scu_addr 80) 8 gpio_export B0 +# Enable P3V3: GPIOS1(145) +# To use GPIOS1 (145), SCU8C[1], SCU94[0], and SCU94[1] must be 0 +devmem_clear_bit $(scu_addr 8C) 1 +devmem_clear_bit $(scu_addr 94) 0 +devmem_clear_bit $(scu_addr 94) 1 + +gpio_set S1 1 + +# PWRGD_P3V3: GPIOS2(146) +# To use GPIOS2 (146), SCU8C[2], SCU94[0], and SCU94[1] must be 0 +devmem_clear_bit $(scu_addr 8C) 2 +devmem_clear_bit $(scu_addr 94) 0 +devmem_clear_bit $(scu_addr 94) 1 + # Setup GPIOs to Mux Enable: GPIOS3(147), Channel Select: GPIOE4(36), GPIOE5(37) # To use GPIOS3 (147), SCU8C[3], SCU94[0], and SCU94[1] must be 0 @@ -123,11 +137,11 @@ devmem_clear_bit $(scu_addr 80) 21 devmem_clear_bit $(scu_addr 8C) 14 devmem_clear_bit $(scu_addr 70) 22 -gpio_export S3 -gpio_export E4 -gpio_export E5 +gpio_set S3 0 +gpio_set E4 1 +gpio_set E5 0 -# BMC_HEARTBEAT_N, heartbeat LED, GPIO Q7 +# BMC_HEARTBEAT_N, heartbeat LED, GPIO Q7(135) devmem_clear_bit $(scu_addr 90) 28 gpio_export Q7 @@ -204,6 +218,34 @@ devmem_clear_bit $(scu_addr 84) 27 gpio_set M3 1 + +# Identify LED for Slot#2: +# To use GPIOF0 (40), SCU80[24] must be 0 +devmem_clear_bit $(scu_addr 80) 24 + +gpio_set F0 1 + +# Identify LED for Slot#1: +# To use GPIOF1 (41), SCU80[25], SCUA4[12], must be 0 +devmem_clear_bit $(scu_addr 80) 25 +devmem_clear_bit $(scu_addr A4) 12 + +gpio_set F1 1 + +# Identify LED for Slot#4: +# To use GPIOF2 (42), SCU80[26], SCUA4[13], must be 0 +devmem_clear_bit $(scu_addr 80) 26 +devmem_clear_bit $(scu_addr A4) 13 + +gpio_set F2 1 + +# Identify LED for Slot#3: +# To use GPIOF3 (43), SCU80[27], SCUA4[14], must be 0 +devmem_clear_bit $(scu_addr 80) 27 +devmem_clear_bit $(scu_addr A4) 14 + +gpio_set F3 1 + # Front Panel Hand Switch GPIO setup # HAND_SW_ID1: GPIOR2(138) # To use GPIOR2, SCU88[26] must be 0 @@ -305,3 +347,55 @@ gpio_set H3 1 # RST_SLOT4_SYS_RESET_N: GPIOH2 (58) # To use GPIOH2, SCU90[6], SCU90[7] must be 0 gpio_set H2 1 + +# 12V_STBY Enable for Slots + +# P12V_STBY_SLOT1_EN: GPIOO5 (117) +# To use GPIOO5, SCU88[13] must be 0 +devmem_clear_bit $(scu_addr 88) 13 + +gpio_set O5 1 + +# P12V_STBY_SLOT2_EN: GPIOO4 (116) +# To use GPIOO4, SCU88[12] must be 0 +devmem_clear_bit $(scu_addr 88) 12 + +gpio_set O4 1 + +# P12V_STBY_SLOT3_EN: GPIOO7 (119) +# To use GPIOO7, SCU88[15] must be 0 +devmem_clear_bit $(scu_addr 88) 15 + +gpio_set O7 1 + +# P12V_STBY_SLOT4_EN: GPIOO6 (118) +# To use GPIOO6, SCU88[13] must be 0 +devmem_clear_bit $(scu_addr 88) 14 + +gpio_set O6 1 + +# PWRGD_P12V_STBY_SLOT1: GPIOP1 (121) +# To use GPIOP1, SCU88[17] must be 0 +devmem_clear_bit $(scu_addr 88) 17 +gpio_export P1 + +# PWRGD_P12V_STBY_SLOT2: GPIOP0 (120) +# To use GPIOP0, SCU88[16] must be 0 +devmem_clear_bit $(scu_addr 88) 16 +gpio_export P0 + +# PWRGD_P12V_STBY_SLOT3: GPIOP3 (123) +# To use GPIOP3, SCU88[19] must be 0 +devmem_clear_bit $(scu_addr 88) 19 +gpio_export P3 + +# PWRGD_P12V_STBY_SLOT4: GPIOP2 (122) +# To use GPIOP2, SCU88[18] must be 0 +devmem_clear_bit $(scu_addr 88) 18 +gpio_export P2 + +# TODO: Enable this pin after the HW issue is fixed +# Enable the the EXTRST functionality of GPIOB7 +#devmem_set_bit $(scu_addr 80) 15 +#devmem_clear_bit $(scu_addr 90) 31 +#devmem_set_bit $(scu_addr 3c) 3 diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/yosemite-sensors/yosemite-sensors.c b/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/yosemite-sensors/yosemite-sensors.c index aa921db..8eb772b 100644 --- a/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/yosemite-sensors/yosemite-sensors.c +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/files/yosemite-sensors/yosemite-sensors.c @@ -79,12 +79,6 @@ main(int argc, char **argv) { printf("SP_SENSOR_P3V3_STBY: %.2f Volts\n", fvalue); } - if (yosemite_sensor_read(slot_id, SP_SENSOR_P12V_SLOT0, &fvalue)) { - printf("yosemite_sensor_read failed: SP_SENSOR_P12V_SLOT0\n"); - } else { - printf("SP_SENSOR_P12V_SLOT0: %.2f Volts\n", fvalue); - } - if (yosemite_sensor_read(slot_id, SP_SENSOR_P12V_SLOT1, &fvalue)) { printf("yosemite_sensor_read failed: SP_SENSOR_P12V_SLOT1\n"); } else { @@ -103,6 +97,12 @@ main(int argc, char **argv) { printf("SP_SENSOR_P12V_SLOT3: %.2f Volts\n", fvalue); } + if (yosemite_sensor_read(slot_id, SP_SENSOR_P12V_SLOT4, &fvalue)) { + printf("yosemite_sensor_read failed: SP_SENSOR_P12V_SLOT4\n"); + } else { + printf("SP_SENSOR_P12V_SLOT4: %.2f Volts\n", fvalue); + } + if (yosemite_sensor_read(slot_id, SP_SENSOR_P3V3, &fvalue)) { printf("yosemite_sensor_read failed: SP_SENSOR_P3V3\n"); } else { diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/fpc-util_0.1.bb b/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/fpc-util_0.1.bb new file mode 100644 index 0000000..04665f1 --- /dev/null +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/fpc-util_0.1.bb @@ -0,0 +1,21 @@ +# Copyright 2015-present Facebook. All Rights Reserved. +SUMMARY = "Front Panel Control Utility" +DESCRIPTION = "Util to override the front panel control remotely" +SECTION = "base" +PR = "r1" +LICENSE = "GPLv2" +LIC_FILES_CHKSUM = "file://fpc-util.c;beginline=4;endline=16;md5=b395943ba8a0717a83e62ca123a8d238" + +SRC_URI = "file://fpc-util \ + " + +S = "${WORKDIR}/fpc-util" + +do_install() { + install -d ${D}${bindir} + install -m 0755 fpc-util ${D}${bindir}/fpc-util +} + +DEPENDS += "libpal" + +FILES_${PN} = "${bindir}" diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/fw-util_0.1.bb b/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/fw-util_0.1.bb new file mode 100644 index 0000000..80c3064 --- /dev/null +++ b/meta-facebook/meta-yosemite/recipes-yosemite/fbutils/fw-util_0.1.bb @@ -0,0 +1,21 @@ +# Copyright 2015-present Facebook. All Rights Reserved. +SUMMARY = "Firmware Utility" +DESCRIPTION = "Util for printing or updating firmware images" +SECTION = "base" +PR = "r1" +LICENSE = "GPLv2" +LIC_FILES_CHKSUM = "file://fw-util.c;beginline=4;endline=16;md5=b395943ba8a0717a83e62ca123a8d238" + +SRC_URI = "file://fw-util \ + " + +S = "${WORKDIR}/fw-util" + +do_install() { + install -d ${D}${bindir} + install -m 0755 fw-util ${D}${bindir}/fw-util +} + +DEPENDS += " libbic libpal" + +FILES_${PN} = "${bindir}" |