From 39d68d4071b8e9b61210e8bbe65d68a9662d0f34 Mon Sep 17 00:00:00 2001 From: Alexander Filippov Date: Thu, 2 Dec 2021 19:16:20 +0300 Subject: Remove BBLAYERS_NON_REMOVABLE variable `BBLAYERS_NON_REMOVABLE` is obsolete and no longer required. As it said by Yocto documentation it can be used by `Hob` https://www.yoctoproject.org/docs/1.5.2/ref-manual/ref-manual.html#var-BBLAYERS_NON_REMOVABLE that already removed since Yocto-2.1 https://www.yoctoproject.org/tools-resources/projects/hob Change-Id: Ibc2d8268a9d837a81e9cf6b0131dba8d0a030a3f Signed-off-by: Alexander Filippov --- meta-facebook/meta-bletchley/conf/bblayers.conf.sample | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'meta-facebook/meta-bletchley') diff --git a/meta-facebook/meta-bletchley/conf/bblayers.conf.sample b/meta-facebook/meta-bletchley/conf/bblayers.conf.sample index 3b24ed861..84dcddfbb 100644 --- a/meta-facebook/meta-bletchley/conf/bblayers.conf.sample +++ b/meta-facebook/meta-bletchley/conf/bblayers.conf.sample @@ -20,18 +20,3 @@ BBLAYERS ?= " \ ##OEROOT##/meta-facebook \ ##OEROOT##/meta-facebook/meta-bletchley \ " -BBLAYERS_NON_REMOVABLE ?= " \ - ##OEROOT##/meta \ - ##OEROOT##/meta-poky \ - ##OEROOT##/meta-openembedded/meta-oe \ - ##OEROOT##/meta-openembedded/meta-networking \ - ##OEROOT##/meta-openembedded/meta-perl \ - ##OEROOT##/meta-openembedded/meta-python \ - ##OEROOT##/meta-openembedded/meta-webserver \ - ##OEROOT##/meta-security \ - ##OEROOT##/meta-security/meta-tpm \ - ##OEROOT##/meta-phosphor \ - ##OEROOT##/meta-aspeed \ - ##OEROOT##/meta-facebook \ - ##OEROOT##/meta-facebook/meta-bletchley \ - " -- cgit v1.2.3 From 21f28927c175a417b4e4eaaa5295ee7b572e0009 Mon Sep 17 00:00:00 2001 From: Howard Chiu Date: Thu, 9 Dec 2021 13:33:54 +0800 Subject: meta-bletchley: add phosphor-nvme Use phosphor-nvme to monitor the temperature of NVMe SSD on each sled Signed-off-by: Howard Chiu Change-Id: Ib61dca1742f66b93cab7bee86b27b33cc7dce969 --- .../images/obmc-phosphor-image.bbappend | 1 + .../sensors/phosphor-nvme/nvme_config.json | 36 ++++++++++++++++++++++ .../sensors/phosphor-nvme_%.bbappend | 8 +++++ 3 files changed, 45 insertions(+) create mode 100644 meta-facebook/meta-bletchley/recipes-phosphor/images/obmc-phosphor-image.bbappend create mode 100644 meta-facebook/meta-bletchley/recipes-phosphor/sensors/phosphor-nvme/nvme_config.json create mode 100644 meta-facebook/meta-bletchley/recipes-phosphor/sensors/phosphor-nvme_%.bbappend (limited to 'meta-facebook/meta-bletchley') diff --git a/meta-facebook/meta-bletchley/recipes-phosphor/images/obmc-phosphor-image.bbappend b/meta-facebook/meta-bletchley/recipes-phosphor/images/obmc-phosphor-image.bbappend new file mode 100644 index 000000000..11096e1c4 --- /dev/null +++ b/meta-facebook/meta-bletchley/recipes-phosphor/images/obmc-phosphor-image.bbappend @@ -0,0 +1 @@ +OBMC_IMAGE_EXTRA_INSTALL:append = " phosphor-nvme" diff --git a/meta-facebook/meta-bletchley/recipes-phosphor/sensors/phosphor-nvme/nvme_config.json b/meta-facebook/meta-bletchley/recipes-phosphor/sensors/phosphor-nvme/nvme_config.json new file mode 100644 index 000000000..f64382e9c --- /dev/null +++ b/meta-facebook/meta-bletchley/recipes-phosphor/sensors/phosphor-nvme/nvme_config.json @@ -0,0 +1,36 @@ +{ + "config": [ + { + "NVMeDriveIndex": 0, + "NVMeDriveBusID": 0 + }, + { + "NVMeDriveIndex": 1, + "NVMeDriveBusID": 1 + }, + { + "NVMeDriveIndex": 2, + "NVMeDriveBusID": 2 + }, + { + "NVMeDriveIndex": 3, + "NVMeDriveBusID": 3 + }, + { + "NVMeDriveIndex": 4, + "NVMeDriveBusID": 4 + }, + { + "NVMeDriveIndex": 5, + "NVMeDriveBusID": 5 + } + ], + "threshold": [ + { + "criticalHigh": 75, + "criticalLow": 0, + "maxValue": 127, + "minValue": -127 + } + ] +} diff --git a/meta-facebook/meta-bletchley/recipes-phosphor/sensors/phosphor-nvme_%.bbappend b/meta-facebook/meta-bletchley/recipes-phosphor/sensors/phosphor-nvme_%.bbappend new file mode 100644 index 000000000..919cef113 --- /dev/null +++ b/meta-facebook/meta-bletchley/recipes-phosphor/sensors/phosphor-nvme_%.bbappend @@ -0,0 +1,8 @@ +FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:" + +SRC_URI += "file://nvme_config.json" + +do_install:append() { + install -d ${D}/${sysconfdir}/nvme/ + install -m 0644 ${WORKDIR}/nvme_config.json ${D}/${sysconfdir}/nvme/ +} -- cgit v1.2.3 From 5abb7ee32973c3959f5f498f9f6396017b2f3622 Mon Sep 17 00:00:00 2001 From: Howard Chiu Date: Thu, 9 Dec 2021 13:43:50 +0800 Subject: meta-bletchley: Enable kernel configs for platform-specific devices 1. AST26xx ADC driver 2. AST26xx PWM v14 driver 3. AST26xx Tach driver from Aspeed-linux 4. Enable driver for PHY fixed link 5. HDC1080 humidity sensor driver 6. PCF85363 RTC driver 7. FUSB302 USB-PD PHY driver 8. MP5023 HSC driver 9. DEVMEM driver for early debug purpose Signed-off-by: Howard Chiu Change-Id: Ib87de12cabd5aef4ef8bd25ac3451a1df56d3fc1 --- .../linux/linux-aspeed/bletchley.cfg | 27 ++++++++++++++++++++++ .../recipes-kernel/linux/linux-aspeed_%.bbappend | 2 ++ 2 files changed, 29 insertions(+) create mode 100644 meta-facebook/meta-bletchley/recipes-kernel/linux/linux-aspeed/bletchley.cfg create mode 100644 meta-facebook/meta-bletchley/recipes-kernel/linux/linux-aspeed_%.bbappend (limited to 'meta-facebook/meta-bletchley') diff --git a/meta-facebook/meta-bletchley/recipes-kernel/linux/linux-aspeed/bletchley.cfg b/meta-facebook/meta-bletchley/recipes-kernel/linux/linux-aspeed/bletchley.cfg new file mode 100644 index 000000000..c77b942a1 --- /dev/null +++ b/meta-facebook/meta-bletchley/recipes-kernel/linux/linux-aspeed/bletchley.cfg @@ -0,0 +1,27 @@ +# aspeed-pwm driver +CONFIG_HAVE_CLK=y +CONFIG_PWM=y +CONFIG_OF=y +CONFIG_PWM_ASPEED_AST2600=y +# pwm-fan driver +CONFIG_SENSORS_PWM_FAN=y +# aspeed-tach driver +CONFIG_SENSORS_TACH_ASPEED_AST2600=y +# aspeed-adc driver +CONFIG_COMMON_CLK=y +CONFIG_ASPEED_ADC=y +# devmem +CONFIG_DEVMEM=y +# fixed-link feature +CONFIG_PHYLIB=y +CONFIG_FIXED_PHY=y +# humidity and temperature sensor +CONFIG_HDC100X=y +# interposer HSC driver +CONFIG_SENSORS_MP5023=y +# RTC +CONFIG_RTC_DRV_PCF85363=y +# FUSB302 driver +CONFIG_TYPEC=y +CONFIG_TYPEC_TCPM=y +CONFIG_TYPEC_FUSB302=y diff --git a/meta-facebook/meta-bletchley/recipes-kernel/linux/linux-aspeed_%.bbappend b/meta-facebook/meta-bletchley/recipes-kernel/linux/linux-aspeed_%.bbappend new file mode 100644 index 000000000..4727bdf73 --- /dev/null +++ b/meta-facebook/meta-bletchley/recipes-kernel/linux/linux-aspeed_%.bbappend @@ -0,0 +1,2 @@ +FILESEXTRAPATHS:prepend := "${THISDIR}/linux-aspeed:" +SRC_URI += "file://bletchley.cfg" -- cgit v1.2.3 From 538683f3af153b0a3381790a7bfbd2696b17f9d5 Mon Sep 17 00:00:00 2001 From: Potin Lai Date: Fri, 17 Dec 2021 00:47:35 +0800 Subject: meta-bletchley: add led manager add support of phosphor-led-manager for Bletchley Signed-off-by: Potin Lai Change-Id: I4c27fb1a7658b89ff20f8f2ee4c38ae5bd17ffc0 --- .../meta-bletchley/conf/machine/bletchley.conf | 2 + .../leds/bletchley-led-manager-config-native.bb | 18 +++++ .../leds/bletchley-led-manager-config/led.yaml | 89 ++++++++++++++++++++++ 3 files changed, 109 insertions(+) create mode 100644 meta-facebook/meta-bletchley/recipes-phosphor/leds/bletchley-led-manager-config-native.bb create mode 100644 meta-facebook/meta-bletchley/recipes-phosphor/leds/bletchley-led-manager-config/led.yaml (limited to 'meta-facebook/meta-bletchley') diff --git a/meta-facebook/meta-bletchley/conf/machine/bletchley.conf b/meta-facebook/meta-bletchley/conf/machine/bletchley.conf index 9427df28a..b3480f5c5 100644 --- a/meta-facebook/meta-bletchley/conf/machine/bletchley.conf +++ b/meta-facebook/meta-bletchley/conf/machine/bletchley.conf @@ -12,3 +12,5 @@ require conf/machine/include/obmc-bsp-common.inc require conf/machine/include/facebook-tpm2.inc FLASH_SIZE = "131072" + +PREFERRED_PROVIDER_virtual/phosphor-led-manager-config-native = "bletchley-led-manager-config-native" diff --git a/meta-facebook/meta-bletchley/recipes-phosphor/leds/bletchley-led-manager-config-native.bb b/meta-facebook/meta-bletchley/recipes-phosphor/leds/bletchley-led-manager-config-native.bb new file mode 100644 index 000000000..d06ec861e --- /dev/null +++ b/meta-facebook/meta-bletchley/recipes-phosphor/leds/bletchley-led-manager-config-native.bb @@ -0,0 +1,18 @@ +SUMMARY = "Phosphor LED Group Management for Bletchley" +PR = "r1" +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10" + +inherit native + +PROVIDES += "virtual/phosphor-led-manager-config-native" + +SRC_URI += "file://led.yaml" +S = "${WORKDIR}" + +# Copies example led layout yaml file +do_install() { + SRC=${S} + DEST=${D}${datadir}/phosphor-led-manager + install -D ${SRC}/led.yaml ${DEST}/led.yaml +} diff --git a/meta-facebook/meta-bletchley/recipes-phosphor/leds/bletchley-led-manager-config/led.yaml b/meta-facebook/meta-bletchley/recipes-phosphor/leds/bletchley-led-manager-config/led.yaml new file mode 100644 index 000000000..4fb482cca --- /dev/null +++ b/meta-facebook/meta-bletchley/recipes-phosphor/leds/bletchley-led-manager-config/led.yaml @@ -0,0 +1,89 @@ +bmc_booted: + sys_log_id: + Action: 'On' + +sys_identify: + sys_log_id: + Action: 'Blink' + DutyOn: 50 + Period: 1000 + +fan0_fault: + fan0_amber: + Action: 'On' + +fan0_good: + fan0_blue: + Action: 'On' + +fan1_fault: + fan1_amber: + Action: 'On' + +fan1_good: + fan1_blue: + Action: 'On' + +fan2_fault: + fan2_amber: + Action: 'On' + +fan2_good: + fan2_blue: + Action: 'On' + +fan3_fault: + fan3_amber: + Action: 'On' + +fan3_good: + fan3_blue: + Action: 'On' + +sled0_fault: + sled0_amber: + Action: 'On' + +sled0_good: + sled0_blue: + Action: 'On' + +sled1_fault: + sled1_amber: + Action: 'On' + +sled1_good: + sled1_blue: + Action: 'On' + +sled2_fault: + sled2_amber: + Action: 'On' + +sled2_good: + sled2_blue: + Action: 'On' + +sled3_fault: + sled3_amber: + Action: 'On' + +sled3_good: + sled3_blue: + Action: 'On' + +sled4_fault: + sled4_amber: + Action: 'On' + +sled4_good: + sled4_blue: + Action: 'On' + +sled5_fault: + sled5_amber: + Action: 'On' + +sled5_good: + sled5_blue: + Action: 'On' -- cgit v1.2.3 From af3c30e591e6dd38541969ff201087f46d68f864 Mon Sep 17 00:00:00 2001 From: Potin Lai Date: Wed, 22 Dec 2021 14:17:40 +0800 Subject: meta-bletchley: kernel: enable SPI_GPIO config enable SPI_GPIO feature Signed-off-by: Potin Lai Change-Id: I24bb13acfbddcff14c5f15fbd9262ba1b019d9f7 --- .../meta-bletchley/recipes-kernel/linux/linux-aspeed/bletchley.cfg | 3 +++ 1 file changed, 3 insertions(+) (limited to 'meta-facebook/meta-bletchley') diff --git a/meta-facebook/meta-bletchley/recipes-kernel/linux/linux-aspeed/bletchley.cfg b/meta-facebook/meta-bletchley/recipes-kernel/linux/linux-aspeed/bletchley.cfg index c77b942a1..49e07a291 100644 --- a/meta-facebook/meta-bletchley/recipes-kernel/linux/linux-aspeed/bletchley.cfg +++ b/meta-facebook/meta-bletchley/recipes-kernel/linux/linux-aspeed/bletchley.cfg @@ -25,3 +25,6 @@ CONFIG_RTC_DRV_PCF85363=y CONFIG_TYPEC=y CONFIG_TYPEC_TCPM=y CONFIG_TYPEC_FUSB302=y +# SPI GPIO +CONFIG_SPI_GPIO=y +CONFIG_SPI_BITBANG=y -- cgit v1.2.3 From da05a16b41d429bd7c1229b377b8bfa948d61281 Mon Sep 17 00:00:00 2001 From: Potin Lai Date: Fri, 17 Dec 2021 13:30:28 +0800 Subject: meta-bletchley: enable bletchley dts select aspeed-bmc-facebook-bletchley.dts for build Signed-off-by: Potin Lai Change-Id: I85503d876b959a2f220ad84b6a9ddba047e89c80 --- meta-facebook/meta-bletchley/conf/machine/bletchley.conf | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'meta-facebook/meta-bletchley') diff --git a/meta-facebook/meta-bletchley/conf/machine/bletchley.conf b/meta-facebook/meta-bletchley/conf/machine/bletchley.conf index b3480f5c5..d69357b0c 100644 --- a/meta-facebook/meta-bletchley/conf/machine/bletchley.conf +++ b/meta-facebook/meta-bletchley/conf/machine/bletchley.conf @@ -1,6 +1,5 @@ -#KMACHINE = "aspeed" -#KERNEL_DEVICETREE = "${KMACHINE}-bmc-facebook-${MACHINE}.dtb" -KERNEL_DEVICETREE = "aspeed-ast2600-evb.dtb" +KMACHINE = "aspeed" +KERNEL_DEVICETREE = "${KMACHINE}-bmc-facebook-${MACHINE}.dtb" UBOOT_MACHINE = "ast2600_openbmc_spl_defconfig" UBOOT_DEVICETREE = "ast2600a1-evb" -- cgit v1.2.3 From 0eb09a13b1e395c0ff09d794cc11bd1513a6b935 Mon Sep 17 00:00:00 2001 From: Howard Chiu Date: Thu, 9 Dec 2021 13:27:04 +0800 Subject: meta-bletchley: Add init service to setup system To setup GPIOs and set fan speed to 70% Signed-off-by: Howard Chiu Signed-off-by: Potin Lai Change-Id: I7a64e19b6e34bcab7013b382d19d7be6156bf87a --- .../plat-svc/files/bletchley-early-sys-init | 82 ++++++++++++++++++++++ .../plat-svc/files/bletchley-sys-init.service | 11 +++ .../recipes-bletchley/plat-svc/plat-svc_0.1.bb | 25 +++++++ .../images/obmc-phosphor-image.bbappend | 5 +- 4 files changed, 122 insertions(+), 1 deletion(-) create mode 100755 meta-facebook/meta-bletchley/recipes-bletchley/plat-svc/files/bletchley-early-sys-init create mode 100644 meta-facebook/meta-bletchley/recipes-bletchley/plat-svc/files/bletchley-sys-init.service create mode 100644 meta-facebook/meta-bletchley/recipes-bletchley/plat-svc/plat-svc_0.1.bb (limited to 'meta-facebook/meta-bletchley') diff --git a/meta-facebook/meta-bletchley/recipes-bletchley/plat-svc/files/bletchley-early-sys-init b/meta-facebook/meta-bletchley/recipes-bletchley/plat-svc/files/bletchley-early-sys-init new file mode 100755 index 000000000..90a3f72af --- /dev/null +++ b/meta-facebook/meta-bletchley/recipes-bletchley/plat-svc/files/bletchley-early-sys-init @@ -0,0 +1,82 @@ +#!/bin/bash -e + +set_gpio() +{ + NET_NAME=$1 + OUT_VAL=$2 + mapfile -t -d " " GPIO_INFO < <(gpiofind "$NET_NAME") + if [ "${#GPIO_INFO[@]}" -ne 2 ]; then + echo "set_gpio: can not find gpio, $NET_NAME" + return 1 + fi + + echo -n "set_gpio: set $NET_NAME = $OUT_VAL" + if ! gpioset "${GPIO_INFO[0]}" "${GPIO_INFO[1]%$'\n'}"="$OUT_VAL"; then + echo " failed" + return 1 + fi + + echo " success" + return 0 +} + +set_fan() +{ + FAN_ID=$1 + FAN_DUTY=$2 + SYSFA_PWM_PATH="" + + for file in /sys/devices/platform/pwm-fan"$FAN_ID"/hwmon/hwmon*/pwm1 + do + if [ -e "$file" ]; then + SYSFA_PWM_PATH="$file" + break + fi + done + + if [ -z "$SYSFA_PWM_PATH" ]; then + echo "set_fan: pwm file not found, chekc fan id ($FAN_ID)" + return 1 + fi + + if [ "$FAN_DUTY" -lt 0 ] || [ "$FAN_DUTY" -gt 100 ]; then + echo "set_fan: incorrect fan duty, $FAN_DUTY" + return 1 + fi + + # convert duty (0-100) to pwm value (0-255) + PWM_VAL=$(printf "%.0f" $((FAN_DUTY*255/100))) + + echo -n "set_fan: set fan$FAN_ID = $FAN_DUTY" + if ! echo "$PWM_VAL" > "$SYSFA_PWM_PATH"; then + echo " failed" + return 1 + fi + + echo " success" + return 0 +} + +# set initial value for GPIO output pins +set_gpio SEL_SPI2_MUX 1 +set_gpio SPI2_MUX1 1 +set_gpio SPI2_MUX2 1 +set_gpio SPI2_MUX3 1 +set_gpio SWITCH_FRU_MUX 1 +set_gpio BAT_DETECT 1 +set_gpio BMC_BT_WP0 1 +set_gpio BMC_BT_WP1 1 +set_gpio USB2_SEL0_A 1 +set_gpio USB2_SEL1_A 1 +set_gpio USB2_SEL0_B 1 +set_gpio USB2_SEL1_B 1 +set_gpio RST_FRONT_IOEXP 1 +set_gpio BSM_FLASH_LATCH 1 + +# set initial duty value for each fan +set_fan 0 70 +set_fan 1 70 +set_fan 2 70 +set_fan 3 70 + +exit 0; diff --git a/meta-facebook/meta-bletchley/recipes-bletchley/plat-svc/files/bletchley-sys-init.service b/meta-facebook/meta-bletchley/recipes-bletchley/plat-svc/files/bletchley-sys-init.service new file mode 100644 index 000000000..481225990 --- /dev/null +++ b/meta-facebook/meta-bletchley/recipes-bletchley/plat-svc/files/bletchley-sys-init.service @@ -0,0 +1,11 @@ +[Unit] +Description=Bletchley Early System Init +Before=phosphor-pid-control.service + +[Service] +Type=oneshot +ExecStart=/usr/libexec/bletchley-early-sys-init +SyslogIdentifier=Bletchley Early Init + +[Install] +WantedBy=multi-user.target diff --git a/meta-facebook/meta-bletchley/recipes-bletchley/plat-svc/plat-svc_0.1.bb b/meta-facebook/meta-bletchley/recipes-bletchley/plat-svc/plat-svc_0.1.bb new file mode 100644 index 000000000..dcbf6e88a --- /dev/null +++ b/meta-facebook/meta-bletchley/recipes-bletchley/plat-svc/plat-svc_0.1.bb @@ -0,0 +1,25 @@ +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10" + +inherit allarch systemd + +RDEPENDS:${PN} += "bash" +RDEPENDS:${PN} += "libgpiod-tools" + +SRC_URI += " \ + file://bletchley-early-sys-init \ + file://bletchley-sys-init.service \ + " + +SYSTEMD_PACKAGES = "${PN}" +SYSTEMD_SERVICE:${PN}:append = " \ + bletchley-sys-init.service \ + " + +do_install() { + install -d ${D}${libexecdir} + install -m 0755 ${WORKDIR}/bletchley-early-sys-init ${D}${libexecdir} + + install -d ${D}${systemd_system_unitdir} + install -m 0644 ${WORKDIR}/bletchley-sys-init.service ${D}${systemd_system_unitdir} +} diff --git a/meta-facebook/meta-bletchley/recipes-phosphor/images/obmc-phosphor-image.bbappend b/meta-facebook/meta-bletchley/recipes-phosphor/images/obmc-phosphor-image.bbappend index 11096e1c4..a13903c39 100644 --- a/meta-facebook/meta-bletchley/recipes-phosphor/images/obmc-phosphor-image.bbappend +++ b/meta-facebook/meta-bletchley/recipes-phosphor/images/obmc-phosphor-image.bbappend @@ -1 +1,4 @@ -OBMC_IMAGE_EXTRA_INSTALL:append = " phosphor-nvme" +OBMC_IMAGE_EXTRA_INSTALL:append = " \ + phosphor-nvme \ + plat-svc \ +" -- cgit v1.2.3 From a3021266199a66d65d5d43f8fbea0bc6ac81d834 Mon Sep 17 00:00:00 2001 From: Potin Lai Date: Fri, 24 Dec 2021 14:59:26 +0800 Subject: meta-bletchley: phosphor-network: enable sync-mac 1. Enable sync-mac 2. add inventory mapping config Signed-off-by: Potin Lai Change-Id: I441c00c22d7f1c0e3d0c9f83b9cc149007acd781 --- .../recipes-phosphor/network/phosphor-network/config.json | 3 +++ .../recipes-phosphor/network/phosphor-network_%.bbappend | 10 ++++++++++ 2 files changed, 13 insertions(+) create mode 100644 meta-facebook/meta-bletchley/recipes-phosphor/network/phosphor-network/config.json create mode 100644 meta-facebook/meta-bletchley/recipes-phosphor/network/phosphor-network_%.bbappend (limited to 'meta-facebook/meta-bletchley') diff --git a/meta-facebook/meta-bletchley/recipes-phosphor/network/phosphor-network/config.json b/meta-facebook/meta-bletchley/recipes-phosphor/network/phosphor-network/config.json new file mode 100644 index 000000000..52280a4e6 --- /dev/null +++ b/meta-facebook/meta-bletchley/recipes-phosphor/network/phosphor-network/config.json @@ -0,0 +1,3 @@ +{ + "eth0":"ethernet" +} diff --git a/meta-facebook/meta-bletchley/recipes-phosphor/network/phosphor-network_%.bbappend b/meta-facebook/meta-bletchley/recipes-phosphor/network/phosphor-network_%.bbappend new file mode 100644 index 000000000..ae025bbc6 --- /dev/null +++ b/meta-facebook/meta-bletchley/recipes-phosphor/network/phosphor-network_%.bbappend @@ -0,0 +1,10 @@ +FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:" + +PACKAGECONFIG:append = " sync-mac" +SRC_URI:append = " file://config.json " +FILES:${PN} += "${datadir}/network/*.json" + +do_install:append() { + install -d ${D}${datadir}/network/ + install -m 0644 ${WORKDIR}/config.json ${D}${datadir}/network/ +} -- cgit v1.2.3 From 98bfffe201a3633eab34f86e910c0ba1f78ebeae Mon Sep 17 00:00:00 2001 From: Potin Lai Date: Fri, 24 Dec 2021 13:32:18 +0800 Subject: meta-bletchley: read fru from eeprom and store to inventory area 1. create configuration layer for fru yaml config 2. add fru eeprom path and id config 3. add FRU_YAML_GEN in phosphor-ipmi-host bbappend Test: root@bletchley:~# busctl introspect xyz.openbmc_project.Inventory.Manager /xyz/openbmc_project/inventory/system/chassis/bmc NAME TYPE SIGNATURE RESULT/VALUE FLAGS org.freedesktop.DBus.Introspectable interface - - - .Introspect method - s - org.freedesktop.DBus.Peer interface - - - .GetMachineId method - s - .Ping method - - - org.freedesktop.DBus.Properties interface - - - .Get method ss v - .GetAll method s a{sv} - .Set method ssv - - .PropertiesChanged signal sa{sv}as - - xyz.openbmc_project.Inventory.Decorator.Asset interface - - - .BuildDate property s "2021-12-21 - 07:56:00" emits-change writable .Manufacturer property s "Quanta" emits-change writable .Model property s "" emits-change writable .PartNumber property s "3RL19MA0000" emits-change writable .SerialNumber property s "1234567890123" emits-change writable .SparePartNumber property s "" emits-change writable .SubModel property s "" emits-change writable xyz.openbmc_project.Inventory.Decorator.Revision interface - - - .Version property s "FRU Ver 0.01" emits-change writable xyz.openbmc_project.Inventory.Item interface - - - .Present property b false emits-change writable .PrettyName property s "Bletchley -Class 1" emits-change writable xyz.openbmc_project.Inventory.Item.Bmc interface - - - xyz.openbmc_project.Inventory.Item.Board interface - - - root@bletchley:~# busctl introspect xyz.openbmc_project.Inventory.Manager /xyz/openbmc_project/inventory/system/chassis/bmc/ethernet NAME TYPE SIGNATURE RESULT/VALUE FLAGS org.freedesktop.DBus.Introspectable interface - - - .Introspect method - s - org.freedesktop.DBus.Peer interface - - - .GetMachineId method - s - .Ping method - - - org.freedesktop.DBus.Properties interface - - - .Get method ss v - .GetAll method s a{sv} - .Set method ssv - - .PropertiesChanged signal sa{sv}as - - xyz.openbmc_project.Inventory.Item.Ethernet interface - - - xyz.openbmc_project.Inventory.Item.NetworkInterface interface - - - .MACAddress property s "3AD664F68D3F" emits-change writable Signed-off-by: Potin Lai Change-Id: I70d624885abaa13639a0617b356554aa6c88af57 --- .../configuration/bletchley-yaml-config.bb | 23 +++++++++++++ .../bletchley-yaml-config/bletchley-ipmi-fru.yaml | 38 ++++++++++++++++++++++ .../obmc/eeproms/system/chassis/bmc | 2 ++ .../ipmi/phosphor-ipmi-fru_%.bbappend | 26 +++++++++++++++ .../ipmi/phosphor-ipmi-host_%.bbappend | 5 +++ 5 files changed, 94 insertions(+) create mode 100644 meta-facebook/meta-bletchley/recipes-phosphor/configuration/bletchley-yaml-config.bb create mode 100644 meta-facebook/meta-bletchley/recipes-phosphor/configuration/bletchley-yaml-config/bletchley-ipmi-fru.yaml create mode 100644 meta-facebook/meta-bletchley/recipes-phosphor/ipmi/phosphor-ipmi-fru/obmc/eeproms/system/chassis/bmc create mode 100644 meta-facebook/meta-bletchley/recipes-phosphor/ipmi/phosphor-ipmi-fru_%.bbappend create mode 100644 meta-facebook/meta-bletchley/recipes-phosphor/ipmi/phosphor-ipmi-host_%.bbappend (limited to 'meta-facebook/meta-bletchley') diff --git a/meta-facebook/meta-bletchley/recipes-phosphor/configuration/bletchley-yaml-config.bb b/meta-facebook/meta-bletchley/recipes-phosphor/configuration/bletchley-yaml-config.bb new file mode 100644 index 000000000..7a8f8471c --- /dev/null +++ b/meta-facebook/meta-bletchley/recipes-phosphor/configuration/bletchley-yaml-config.bb @@ -0,0 +1,23 @@ +SUMMARY = "YAML configuration for bletchley" +PR = "r1" +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10" + +inherit allarch + +SRC_URI = " \ + file://bletchley-ipmi-fru.yaml \ + " + +S = "${WORKDIR}" + +do_install() { + install -m 0644 -D bletchley-ipmi-fru.yaml \ + ${D}${datadir}/${BPN}/ipmi-fru-read.yaml +} + +FILES:${PN}-dev = " \ + ${datadir}/${BPN}/ipmi-fru-read.yaml \ + " + +ALLOW_EMPTY:${PN} = "1" diff --git a/meta-facebook/meta-bletchley/recipes-phosphor/configuration/bletchley-yaml-config/bletchley-ipmi-fru.yaml b/meta-facebook/meta-bletchley/recipes-phosphor/configuration/bletchley-yaml-config/bletchley-ipmi-fru.yaml new file mode 100644 index 000000000..8c53a2a7c --- /dev/null +++ b/meta-facebook/meta-bletchley/recipes-phosphor/configuration/bletchley-yaml-config/bletchley-ipmi-fru.yaml @@ -0,0 +1,38 @@ +0: + /system/chassis/bmc: + entityID: 7 + entityInstance: 1 + interfaces: + xyz.openbmc_project.Inventory.Decorator.Asset: + BuildDate: + IPMIFruProperty: Mfg Date + IPMIFruSection: Board + SerialNumber: + IPMIFruProperty: Serial Number + IPMIFruSection: Board + PartNumber: + IPMIFruProperty: Part Number + IPMIFruSection: Board + Manufacturer: + IPMIFruProperty: Manufacturer + IPMIFruSection: Board + xyz.openbmc_project.Inventory.Item: + PrettyName: + IPMIFruProperty: Name + IPMIFruSection: Board + xyz.openbmc_project.Inventory.Decorator.Revision: + Version: + IPMIFruProperty: FRU File ID + IPMIFruSection: Board + xyz.openbmc_project.Inventory.Item.Board: + xyz.openbmc_project.Inventory.Item.Bmc: + + /system/chassis/bmc/ethernet: + entityID: 7 + entityInstance: 1 + interfaces: + xyz.openbmc_project.Inventory.Item.NetworkInterface: + MACAddress: + IPMIFruProperty: Custom Field 3 + IPMIFruSection: Board + xyz.openbmc_project.Inventory.Item.Ethernet: \ No newline at end of file diff --git a/meta-facebook/meta-bletchley/recipes-phosphor/ipmi/phosphor-ipmi-fru/obmc/eeproms/system/chassis/bmc b/meta-facebook/meta-bletchley/recipes-phosphor/ipmi/phosphor-ipmi-fru/obmc/eeproms/system/chassis/bmc new file mode 100644 index 000000000..b1bd018a6 --- /dev/null +++ b/meta-facebook/meta-bletchley/recipes-phosphor/ipmi/phosphor-ipmi-fru/obmc/eeproms/system/chassis/bmc @@ -0,0 +1,2 @@ +SYSFS_PATH=/sys/bus/i2c/devices/7-0054/eeprom +FRUID=0 \ No newline at end of file diff --git a/meta-facebook/meta-bletchley/recipes-phosphor/ipmi/phosphor-ipmi-fru_%.bbappend b/meta-facebook/meta-bletchley/recipes-phosphor/ipmi/phosphor-ipmi-fru_%.bbappend new file mode 100644 index 000000000..0c78a8f52 --- /dev/null +++ b/meta-facebook/meta-bletchley/recipes-phosphor/ipmi/phosphor-ipmi-fru_%.bbappend @@ -0,0 +1,26 @@ +inherit obmc-phosphor-systemd + +FILESEXTRAPATHS:prepend:bletchley := "${THISDIR}/${PN}:" + +DEPENDS:append:bletchley = " bletchley-yaml-config" + +EXTRA_OECONF:bletchley = " \ + YAML_GEN=${STAGING_DIR_HOST}${datadir}/bletchley-yaml-config/ipmi-fru-read.yaml \ + " + +EEPROM_NAMES = "bmc" + +EEPROMFMT = "system/chassis/{0}" +EEPROM_ESCAPEDFMT = "system-chassis-{0}" +EEPROMS = "${@compose_list(d, 'EEPROMFMT', 'EEPROM_NAMES')}" +EEPROMS_ESCAPED = "${@compose_list(d, 'EEPROM_ESCAPEDFMT', 'EEPROM_NAMES')}" + +ENVFMT = "obmc/eeproms/{0}" +SYSTEMD_ENVIRONMENT_FILE:${PN}:append:bletchley := " ${@compose_list(d, 'ENVFMT', 'EEPROMS')}" + +TMPL = "obmc-read-eeprom@.service" +TGT = "${SYSTEMD_DEFAULT_TARGET}" +INSTFMT = "obmc-read-eeprom@{0}.service" +FMT = "../${TMPL}:${TGT}.wants/${INSTFMT}" + +SYSTEMD_LINK:${PN}:append:bletchley := " ${@compose_list(d, 'FMT', 'EEPROMS_ESCAPED')}" diff --git a/meta-facebook/meta-bletchley/recipes-phosphor/ipmi/phosphor-ipmi-host_%.bbappend b/meta-facebook/meta-bletchley/recipes-phosphor/ipmi/phosphor-ipmi-host_%.bbappend new file mode 100644 index 000000000..fd303a04b --- /dev/null +++ b/meta-facebook/meta-bletchley/recipes-phosphor/ipmi/phosphor-ipmi-host_%.bbappend @@ -0,0 +1,5 @@ +DEPENDS:append:bletchley = " bletchley-yaml-config" + +EXTRA_OECONF:bletchley = " \ + FRU_YAML_GEN=${STAGING_DIR_HOST}${datadir}/bletchley-yaml-config/ipmi-fru-read.yaml \ + " -- cgit v1.2.3 From 16657ece7be5e9e59c295b396440db4447e8b48d Mon Sep 17 00:00:00 2001 From: Patrick Williams Date: Tue, 28 Dec 2021 21:19:03 -0600 Subject: meta-bletchley: phosphor-network: use += style for append Signed-off-by: Patrick Williams Change-Id: I19d92019649ba990dcc33ac1bc25c4ebadc933b6 --- .../recipes-phosphor/network/phosphor-network_%.bbappend | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'meta-facebook/meta-bletchley') diff --git a/meta-facebook/meta-bletchley/recipes-phosphor/network/phosphor-network_%.bbappend b/meta-facebook/meta-bletchley/recipes-phosphor/network/phosphor-network_%.bbappend index ae025bbc6..b91e82f91 100644 --- a/meta-facebook/meta-bletchley/recipes-phosphor/network/phosphor-network_%.bbappend +++ b/meta-facebook/meta-bletchley/recipes-phosphor/network/phosphor-network_%.bbappend @@ -1,7 +1,9 @@ FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:" PACKAGECONFIG:append = " sync-mac" -SRC_URI:append = " file://config.json " +SRC_URI += " \ + file://config.json \ + " FILES:${PN} += "${datadir}/network/*.json" do_install:append() { -- cgit v1.2.3 From d58f23c78a2501d4b6ed36a74c23de28595d4f78 Mon Sep 17 00:00:00 2001 From: Patrick Williams Date: Tue, 28 Dec 2021 21:36:33 -0600 Subject: meta-facebook: add fb-phosphor-image.inc Builds done using facebook/openbmc do not use the 'obmc-phosphor-image' image name, but instead use 'MACHINE-image'. This means that bbappend files have no effect and we need a different method to get consistent sets of include files. Introduce 'fb-phosphor-image.inc' and 'fb-MACHINE-phosphor-image.inc' as the replacements for the obmc-phosphor-image.bbappend. Signed-off-by: Patrick Williams Change-Id: I166342c1744d1cd0237f8c75d90d87153fb19b35 --- .../recipes-phosphor/images/fb-bletchley-phosphor-image.inc | 4 ++++ .../recipes-phosphor/images/obmc-phosphor-image.bbappend | 4 ---- meta-facebook/recipes-phosphor/images/fb-phosphor-image.inc | 9 +++++++++ .../recipes-phosphor/images/obmc-phosphor-image.bbappend | 12 ++++-------- 4 files changed, 17 insertions(+), 12 deletions(-) create mode 100644 meta-facebook/meta-bletchley/recipes-phosphor/images/fb-bletchley-phosphor-image.inc delete mode 100644 meta-facebook/meta-bletchley/recipes-phosphor/images/obmc-phosphor-image.bbappend create mode 100644 meta-facebook/recipes-phosphor/images/fb-phosphor-image.inc (limited to 'meta-facebook/meta-bletchley') diff --git a/meta-facebook/meta-bletchley/recipes-phosphor/images/fb-bletchley-phosphor-image.inc b/meta-facebook/meta-bletchley/recipes-phosphor/images/fb-bletchley-phosphor-image.inc new file mode 100644 index 000000000..8fa7252e7 --- /dev/null +++ b/meta-facebook/meta-bletchley/recipes-phosphor/images/fb-bletchley-phosphor-image.inc @@ -0,0 +1,4 @@ +OBMC_IMAGE_EXTRA_INSTALL:append = " \ + phosphor-nvme \ + plat-svc \ + " diff --git a/meta-facebook/meta-bletchley/recipes-phosphor/images/obmc-phosphor-image.bbappend b/meta-facebook/meta-bletchley/recipes-phosphor/images/obmc-phosphor-image.bbappend deleted file mode 100644 index a13903c39..000000000 --- a/meta-facebook/meta-bletchley/recipes-phosphor/images/obmc-phosphor-image.bbappend +++ /dev/null @@ -1,4 +0,0 @@ -OBMC_IMAGE_EXTRA_INSTALL:append = " \ - phosphor-nvme \ - plat-svc \ -" diff --git a/meta-facebook/recipes-phosphor/images/fb-phosphor-image.inc b/meta-facebook/recipes-phosphor/images/fb-phosphor-image.inc new file mode 100644 index 000000000..fbc80809c --- /dev/null +++ b/meta-facebook/recipes-phosphor/images/fb-phosphor-image.inc @@ -0,0 +1,9 @@ +IMAGE_FEATURES:remove:fb-nohost = "obmc-console" + +OBMC_IMAGE_EXTRA_INSTALL:append = "\ + ${@bb.utils.contains('DISTRO_FEATURES', 'tpm', \ + bb.utils.contains('MACHINE_FEATURES', 'tpm2', 'packagegroup-security-tpm2', '', d), \ + '', d)} \ + " + +include recipes-phosphor/images/fb-${MACHINE}-phosphor-image.inc diff --git a/meta-facebook/recipes-phosphor/images/obmc-phosphor-image.bbappend b/meta-facebook/recipes-phosphor/images/obmc-phosphor-image.bbappend index ba9cc1fe8..23979e66d 100644 --- a/meta-facebook/recipes-phosphor/images/obmc-phosphor-image.bbappend +++ b/meta-facebook/recipes-phosphor/images/obmc-phosphor-image.bbappend @@ -1,9 +1,5 @@ -FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:" +require recipes-phosphor/images/fb-phosphor-image.inc -IMAGE_FEATURES:remove:fb-nohost = "obmc-console" - -OBMC_IMAGE_EXTRA_INSTALL:append = "\ - ${@bb.utils.contains('DISTRO_FEATURES', 'tpm', \ - bb.utils.contains('MACHINE_FEATURES', 'tpm2', 'packagegroup-security-tpm2', '', d), \ - '', d)} \ - " +# Please do not add any content directly to this file. Instead add it to +# the corresponding .inc file. Otherwise, builds from facebook/openbmc will +# not be able to pick up your content. -- cgit v1.2.3 From 4a0948d0184e35770ca24cd591e9a29fd5ff44a6 Mon Sep 17 00:00:00 2001 From: "Allen.Wang" Date: Wed, 15 Dec 2021 13:41:18 +0800 Subject: meta-bletchley: Add services to control step motor For Bletchley platform, we can only power on system by step motor to press power key. Add tools and service to initialize step motor and control system power by motor. Signed-off-by: Allen.Wang Change-Id: Ic75352a037566d701b2e362743c527c370b0c2e5 Signed-off-by: Patrick Williams --- .../meta-bletchley/conf/machine/bletchley.conf | 3 + .../motor-ctrl/files/host-poweroff@.service | 10 ++ .../motor-ctrl/files/host-poweron@.service | 10 ++ .../recipes-bletchley/motor-ctrl/files/motor-ctrl | 101 +++++++++++ .../recipes-bletchley/motor-ctrl/files/motor-init | 185 +++++++++++++++++++++ .../files/motor-init-calibration@.service | 11 ++ .../recipes-bletchley/motor-ctrl/files/power-ctrl | 178 ++++++++++++++++++++ .../recipes-bletchley/motor-ctrl/motor-ctrl_0.1.bb | 37 +++++ .../images/fb-bletchley-phosphor-image.inc | 3 +- 9 files changed, 537 insertions(+), 1 deletion(-) create mode 100644 meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/host-poweroff@.service create mode 100644 meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/host-poweron@.service create mode 100755 meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/motor-ctrl create mode 100755 meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/motor-init create mode 100644 meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/motor-init-calibration@.service create mode 100755 meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/power-ctrl create mode 100644 meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/motor-ctrl_0.1.bb (limited to 'meta-facebook/meta-bletchley') diff --git a/meta-facebook/meta-bletchley/conf/machine/bletchley.conf b/meta-facebook/meta-bletchley/conf/machine/bletchley.conf index d69357b0c..6b7711a62 100644 --- a/meta-facebook/meta-bletchley/conf/machine/bletchley.conf +++ b/meta-facebook/meta-bletchley/conf/machine/bletchley.conf @@ -13,3 +13,6 @@ require conf/machine/include/facebook-tpm2.inc FLASH_SIZE = "131072" PREFERRED_PROVIDER_virtual/phosphor-led-manager-config-native = "bletchley-led-manager-config-native" + +OBMC_HOST_INSTANCES = "0 1 2 3 4 5 " + diff --git a/meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/host-poweroff@.service b/meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/host-poweroff@.service new file mode 100644 index 000000000..50cd53283 --- /dev/null +++ b/meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/host-poweroff@.service @@ -0,0 +1,10 @@ +[Unit] +Description=Power off System in Sled%i by Step Motor +Requires=motor-init-calibration@%i.service +After=motor-init-calibration@%i.service + +[Service] +Type=oneshot +ExecStart=/usr/sbin/power-ctrl sled%i off +SyslogIdentifier=power-ctrl + diff --git a/meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/host-poweron@.service b/meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/host-poweron@.service new file mode 100644 index 000000000..6ff11202d --- /dev/null +++ b/meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/host-poweron@.service @@ -0,0 +1,10 @@ +[Unit] +Description=Power on System in Sled%i by Step Motor +Requires=motor-init-calibration@%i.service +After=motor-init-calibration@%i.service + +[Service] +Type=oneshot +ExecStart=/usr/sbin/power-ctrl sled%i on +SyslogIdentifier=power-ctrl + diff --git a/meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/motor-ctrl b/meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/motor-ctrl new file mode 100755 index 000000000..3f8f2ca21 --- /dev/null +++ b/meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/motor-ctrl @@ -0,0 +1,101 @@ +#!/bin/bash -e +# +# Control step motor rotate of sled + +function set_gpio() +{ + NET_NAME=$1 + OUT_VAL=$2 + mapfile -t -d " " GPIO_INFO < <(gpiofind "$NET_NAME") + if [ "${#GPIO_INFO[@]}" -ne 2 ]; then + echo "set_gpio: can not find gpio, $NET_NAME" + return 1 + fi + echo -n "set_gpio: set $NET_NAME = $OUT_VAL" + if ! gpioset "${GPIO_INFO[0]}" "${GPIO_INFO[1]%$'\n'}"="$OUT_VAL"; then + echo " failed" + return 1 + fi + echo " success" + return 0 +} + +#Get i2c bus number for sledN +function get_bus_num() { + SLED_NUM=$1 + local bus=0 + + if [[ "$SLED_NUM" = [0-5] ]]; then + bus="$SLED_NUM" + fi + echo "$bus" +} + +#Enable sledN Motor VRef +function open_vref() { + i2cset -f -y "${1}" 0x67 0x06 0x95 +} + +#Disable sledN Motor VRef +function close_vref() { + i2cset -f -y "${1}" 0x67 0x06 0x55 +} + +####################################### +# Setting step motor control pins to start/stop motor +# Arguments: +# 1. SLED NUMBER +# 2. Value of STBY RESET PIN +# 3. Value of ENABLE PIN +# 4. Value of DIRECTION PIN +####################################### +function set_motor() { + STBY_PIN="SLED${1}_MD_STBY_RESET" + EN_PIN="SLED${1}_MD_IOEXP_EN_FAULT" + DIR_PIN="SLED${1}_MD_DIR" + set_gpio "$STBY_PIN" "$2" + set_gpio "$EN_PIN" "$3" + set_gpio "$DIR_PIN" "$4" +} + +function show_usage(){ + echo "Usage: motor-ctrl [sled0 | sled1 | sled2 | sled3 | sled4 | sled5] [f r s]" + echo " f : Step Motor go forward" + echo " r : Step Motor go reverse" + echo " s : Step Motor stop " +} + +if [ $# -ne 2 ]; then + show_usage + exit 1; +fi + +if [[ "$1" =~ ^(slot[0-5]{1})$ ]] || [[ "$1" =~ ^(sled[0-5]{1})$ ]]; then + SLED=$1 + SLED_NUM=${SLED:4} + I2C_NUM=$(get_bus_num "$SLED_NUM") + ACTION=$2 +else + echo "invalid sled name: $1" + exit 1; +fi + +if [[ "$ACTION" == "s" ]]; then + echo "stop motor" + set_motor "$SLED_NUM" 1 0 0 + close_vref "$I2C_NUM" +elif [[ "$ACTION" == "f" ]];then + echo "start motor, direction:forward" + set_motor "$SLED_NUM" 1 1 0 + open_vref "$I2C_NUM" +elif [[ "$ACTION" == "r" ]];then + echo "start motor, direction:reverse" + set_motor "$SLED_NUM" 1 1 1 + open_vref "$I2C_NUM" +else + echo "Error: Unknown action!" + exit 1 +fi + +exit 0 + diff --git a/meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/motor-init b/meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/motor-init new file mode 100755 index 000000000..cecb99618 --- /dev/null +++ b/meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/motor-init @@ -0,0 +1,185 @@ +#!/bin/bash -e + +# Initialize for step motor of sled: +# Enable pwm and setup pwm duty +# Setup gpio pins for step motor control +# Moving step motor back to initial position + +export PATH=$PATH:/usr/libexec + +PWM_BASE_ADDR="0x1e61" +DEV_FILE="/dev/mem" +CALIBRATE_TIMEOUT=120 + +#Get pwm register address for sledN +function get_pwm_offset() { + local offset=0 + case $1 in + 0) + offset="0080" + ;; + 1) + offset="0090" + ;; + 2) + offset="00a0" + ;; + 3) + offset="00b0" + ;; + 4) + offset="00c0" + ;; + 5) + offset="00d0" + ;; + esac + + echo ${PWM_BASE_ADDR}${offset} +} + +#Get pwm duty register address for sledN +function get_duty_offset() { + local offset=0 + case $1 in + 0) + offset="0084" + ;; + 1) + offset="0094" + ;; + 2) + offset="00a4" + ;; + 3) + offset="00b4" + ;; + 4) + offset="00c4" + ;; + 5) + offset="00d4" + ;; + esac + + echo ${PWM_BASE_ADDR}${offset} +} + +#Enable pwm for sledN +function open_pwm() { + local SLED_NUM="$1" + echo "Open pwm of sled$SLED_NUM" + #enable BMC PWM + if [ ! -c "$DEV_FILE" ]; then + mknod /dev/mem c 1 1 + fi + + PWM_OFFSET=$(get_pwm_offset "$SLED_NUM") + DUTY_OFFSET=$(get_duty_offset "$SLED_NUM") + echo "setting ${PWM_OFFSET} to 0x000113F3" + echo "setting ${DUTY_OFFSET} to 0xFF006400" + devmem "$PWM_OFFSET" 32 0x000113F3 + devmem "$DUTY_OFFSET" 32 0xFF006400 +} + +function set_gpio() +{ + NET_NAME=$1 + OUT_VAL=$2 + mapfile -t -d " " GPIO_INFO < <(gpiofind "$NET_NAME") + if [ "${#GPIO_INFO[@]}" -ne 2 ]; then + echo "set_gpio: can not find gpio, $NET_NAME" + return 1 + fi + echo -n "set_gpio: set $NET_NAME = $OUT_VAL" + if ! gpioset "${GPIO_INFO[0]}" "${GPIO_INFO[1]%$'\n'}"="$OUT_VAL"; then + echo " failed" + return 1 + fi + echo " success" + return 0 +} + +function get_gpio() +{ + NET_NAME=$1 + RET_VAL=2 + + mapfile -t -d " " GPIO_INFO < <(gpiofind "$NET_NAME") + if [ "${#GPIO_INFO[@]}" -ne 2 ]; then + echo "get_gpio: can not find gpio, $NET_NAME" >&2 + return 1 + fi + if ! RET_VAL=$(gpioget "${GPIO_INFO[0]}" "${GPIO_INFO[1]%$'\n'}") ; then + echo "get_gpio: get ${NET_NAME} failed" >&2 + return 1 + fi + echo "${RET_VAL}" + return 0 +} + +#Init gpio pins for step motor control +function init_gpios() { + echo "Init GPIOs:" + motor_ctrl_gpio_pins_names=( "SLED${1}_MD_STBY_RESET" + "SLED${1}_MD_IOEXP_EN_FAULT" + "SLED${1}_MD_DIR" + "SLED${1}_MD_DECAY" + "SLED${1}_MD_MODE1" + "SLED${1}_MD_MODE2" + "SLED${1}_MD_MODE3" ) + + for gpio_name in "${motor_ctrl_gpio_pins_names[@]}"; do + set_gpio "$gpio_name" 0 + done +} + +if [[ "$1" =~ ^(slot[0-5]{1})$ ]] || [[ "$1" =~ ^(sled[0-5]{1})$ ]]; then + SLED=$1 + SLED_NUM=${SLED:4} +else + #show_usage + echo "invalid sled name: ${1}" + exit 1; +fi + +#Check if sled is present +SLED_PRESENT=$(get_gpio "presence-sled${SLED_NUM}") +if [ "$SLED_PRESENT" != 0 ];then + echo "${SLED} is not present, skip motor initialize" + exit 1 +fi + +#Init gpios +init_gpios "$SLED_NUM" + +#enable pwm +open_pwm "$SLED_NUM" + +#SLED{N}_MS_DETECT1 (initial position) +DETECT_PIN1="SLED${SLED_NUM}_MS_DETECT1" +INIT_POS=$(get_gpio "$DETECT_PIN1") + +if [ "$INIT_POS" -eq 1 ];then + time_count=0 + echo "Making motor back to initial position..." + motor-ctrl "$SLED" r >/dev/null + while [ "$INIT_POS" -eq 1 ] ;do + INIT_POS=$(get_gpio "$DETECT_PIN1") + sleep 0.1 + time_count=$(( time_count + 1 )) + if [ $time_count -gt $CALIBRATE_TIMEOUT ];then + echo "Error: Step motor run over 1 cycle but switch never triggered" + break + fi + done + motor-ctrl "$SLED" s >/dev/null +fi + +if [ "$INIT_POS" -eq 0 ];then + echo "Motor calibrated to initial position." + exit 0 +else + echo "Find motor initial position failed" + exit 1 +fi diff --git a/meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/motor-init-calibration@.service b/meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/motor-init-calibration@.service new file mode 100644 index 000000000..aab61b7fe --- /dev/null +++ b/meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/motor-init-calibration@.service @@ -0,0 +1,11 @@ +[Unit] +Description=Motor Initialize for sled%i + +[Service] +ExecStart=/usr/libexec/motor-init sled%i +SyslogIdentifier=Motor Initialize sled%i +Type=oneshot +RemainAfterExit=yes + +[Install] +WantedBy=multi-user.target diff --git a/meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/power-ctrl b/meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/power-ctrl new file mode 100755 index 000000000..111ce8bbc --- /dev/null +++ b/meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/power-ctrl @@ -0,0 +1,178 @@ +#!/bin/bash +# +# Power Control tool +# Enable/disable AC relay +# On/off System by step moter to press power key + +export PATH=$PATH:/usr/sbin:/usr/libexec + +DELAY_POWER_ON="0.5" +DELAY_POWER_OFF="5" +POWER_BTN_TIMEOUT_CNT=60 + +#Switch pull low while it be touched +function wait_for_switch() { + TARGET_PIN=$1 + TARGET_SWITCH=1 + TIME_CNT=0 + while [ "$TARGET_SWITCH" -eq 1 ] ;do + TARGET_SWITCH=$(get_gpio "$TARGET_PIN") + sleep 0.1 + TIME_CNT=$(( TIME_CNT +1)) + if [ $TIME_CNT -gt $POWER_BTN_TIMEOUT_CNT ];then + echo "Error: Too long to get target switch, force exit" >&2 + break + fi + done +} + +function trigger_power_button() { + local sled_num=$1 + local delay_time=$2 + + #SLED{N}_MS_DETECT1 (initial position) + GPIO_DETECT_PIN1="SLED${sled_num}_MS_DETECT1" + #SLED{N}_MS_DETECT0 (MAC position) + GPIO_DETECT_PIN0="SLED${sled_num}_MS_DETECT0" + + echo "Motor go forward to press Power key" + motor-ctrl "sled${sled_num}" f >/dev/null + wait_for_switch "${GPIO_DETECT_PIN0}" + motor-ctrl "sled${sled_num}" s >/dev/null + + if [ "$(get_gpio "$GPIO_DETECT_PIN0")" -eq 0 ];then + echo "Power key switch triggered" + echo "Press power key for Sled${1} ${delay_time} seconds..." + sleep "$delay_time" + else + echo "Power key switch not trigger, back motor to initail position" + fi + + motor-ctrl "sled${sled_num}" r >/dev/null + wait_for_switch "${GPIO_DETECT_PIN1}" + motor-ctrl "sled${sled_num}" s >/dev/null + if [ "$(get_gpio "$GPIO_DETECT_PIN1")" -eq 0 ];then + echo "Motor reverse to initial position successful" + else + echo "Initail position switch not trigger, force stop motor" + fi +} + +#Get i2c bus number for sledN +function get_bus_num() { + SLED_NUM=$1 + local bus=0 + + if [[ "$SLED_NUM" = [0-5] ]]; then + bus="$SLED_NUM" + fi + echo "$bus" +} + +function set_gpio() +{ + NET_NAME=$1 + OUT_VAL=$2 + mapfile -t -d " " GPIO_INFO < <(gpiofind "$NET_NAME") + if [ "${#GPIO_INFO[@]}" -ne 2 ]; then + echo "set_gpio: can not find gpio, $NET_NAME" + return 1 + fi + echo -n "set_gpio: set $NET_NAME = $OUT_VAL" + if ! gpioset "${GPIO_INFO[0]}" "${GPIO_INFO[1]%$'\n'}"="$OUT_VAL"; then + echo " failed" + return 1 + fi + echo " success" + return 0 +} + +function get_gpio() +{ + NET_NAME=$1 + RET_VAL=2 + + mapfile -t -d " " GPIO_INFO < <(gpiofind "$NET_NAME") + if [ "${#GPIO_INFO[@]}" -ne 2 ]; then + echo "get_gpio: can not find gpio, $NET_NAME" >&2 + return 1 + fi + if ! RET_VAL=$(gpioget "${GPIO_INFO[0]}" "${GPIO_INFO[1]%$'\n'}") ; then + echo "get_gpio: get ${NET_NAME} failed" >&2 + return 1 + fi + echo "${RET_VAL}" + return 0 +} + +function get_ac_status(){ + i2c_bus=$(get_bus_num "$1") + p1_output_reg=$(i2cget -f -y "$i2c_bus" 0x76 0x03) + p1_config_reg=$(i2cget -f -y "$i2c_bus" 0x76 0x07) + host_pwr="$(( (p1_output_reg & 0x80)>>7 ))" + is_output="$(( (~p1_config_reg & 0x80)>>7 ))" + + if [ "$(( host_pwr & is_output ))" -eq 1 ];then + echo "AC on" + else + echo "AC off" + fi +} + +function show_usage(){ + echo "Usage: power-ctrl [sled0 | sled1 | sled2 | sled3 | sled4 | sled5] [on off ac-on ac-off status]" + echo " power-ctrl chassis-cycle" +} + +if [ $# -eq 1 ]; then + if [ "$1" = "chassis-cycle" ];then + echo "chassis cycle...." + i2cset -y -f 12 0x11 0xd9 c + exit 0 + else + echo "Invalid argument: [ $1 ]" + show_usage + exit 1; + fi +fi + +if [ $# -gt 2 ]; then + echo "Too many arguments" + show_usage + exit 1; +fi + +if [[ "$1" =~ ^(slot[0-5]{1})$ ]] || [[ "$1" =~ ^(sled[0-5]{1})$ ]]; then + SLED=$1 + ACTION=$2 + SLED_NUM=${SLED:4} +else + echo "invalid sled name: ${1}" + show_usage + exit 1; +fi + +#Check if sled is present +SLED_PRESENT=$(get_gpio "presence-sled${SLED_NUM}") +if [ "$SLED_PRESENT" != 0 ];then + echo "${SLED} is not present!" + exit 1 +fi + +if [[ "$ACTION" == "on" ]]; then + echo "Power on ${SLED}" + trigger_power_button "$SLED_NUM" "$DELAY_POWER_ON" +elif [[ "$ACTION" == "off" ]];then + echo "Power off ${SLED}" + trigger_power_button "$SLED_NUM" "$DELAY_POWER_OFF" +elif [[ "$ACTION" == "status" ]];then + get_ac_status "$SLED_NUM" + #TODO : check or record Host(DC) power status +elif [[ "$ACTION" == "ac-on" ]];then + set_gpio "power-host${SLED_NUM}" 1 +elif [[ "$ACTION" == "ac-off" ]];then + set_gpio "power-host${SLED_NUM}" 0 +else + echo "Unknown action: [ ${ACTION} ]" + show_usage +fi diff --git a/meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/motor-ctrl_0.1.bb b/meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/motor-ctrl_0.1.bb new file mode 100644 index 000000000..2705eb850 --- /dev/null +++ b/meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/motor-ctrl_0.1.bb @@ -0,0 +1,37 @@ +SUMMARY = "Bletchley Motor control" +PR = "r1" +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10" + +inherit obmc-phosphor-systemd + +RDEPENDS:${PN} += "bash" +RDEPENDS:${PN} += "libgpiod-tools" +RDEPENDS:${PN} += "i2c-tools" + +S = "${WORKDIR}" +SRC_URI += "file://motor-init \ + file://motor-ctrl \ + file://power-ctrl " + +do_install() { + install -d ${D}${sbindir} + install -m 0755 ${WORKDIR}/power-ctrl ${D}${sbindir} + + install -d ${D}${libexecdir} + install -m 0755 ${WORKDIR}/motor-init ${D}${libexecdir} + install -m 0755 ${WORKDIR}/motor-ctrl ${D}${libexecdir} +} + +MOTOR_INIT_INSTFMT= "motor-init-calibration@{0}.service" +PWR_ON_INSTFMT="host-poweron@.service:host-poweron@{0}.service" +PWR_OFF_INSTFMT="host-poweroff@.service:host-poweroff@{0}.service" + +SYSTEMD_SERVICE:${PN} ="${@compose_list(d, 'MOTOR_INIT_INSTFMT', 'OBMC_HOST_INSTANCES')}" +FILES:${PN} += "${systemd_system_unitdir}/motor-init-calibration@.service" + +SYSTEMD_SERVICE:${PN} +="host-poweron@.service" +SYSTEMD_LINK:${PN} += "${@compose_list(d, 'PWR_ON_INSTFMT', 'OBMC_HOST_INSTANCES')}" + +SYSTEMD_SERVICE:${PN} +="host-poweroff@.service" +SYSTEMD_LINK:${PN} += "${@compose_list(d, 'PWR_OFF_INSTFMT', 'OBMC_HOST_INSTANCES')}" diff --git a/meta-facebook/meta-bletchley/recipes-phosphor/images/fb-bletchley-phosphor-image.inc b/meta-facebook/meta-bletchley/recipes-phosphor/images/fb-bletchley-phosphor-image.inc index 8fa7252e7..6636f5090 100644 --- a/meta-facebook/meta-bletchley/recipes-phosphor/images/fb-bletchley-phosphor-image.inc +++ b/meta-facebook/meta-bletchley/recipes-phosphor/images/fb-bletchley-phosphor-image.inc @@ -1,4 +1,5 @@ OBMC_IMAGE_EXTRA_INSTALL:append = " \ phosphor-nvme \ plat-svc \ - " + motor-ctrl \ +" -- cgit v1.2.3