diff options
Diffstat (limited to 'meta-openbmc-mods/meta-common/recipes-intel/configure-usb-c')
3 files changed, 63 insertions, 0 deletions
diff --git a/meta-openbmc-mods/meta-common/recipes-intel/configure-usb-c/configure-usb-c.bb b/meta-openbmc-mods/meta-common/recipes-intel/configure-usb-c/configure-usb-c.bb new file mode 100644 index 000000000..66481543b --- /dev/null +++ b/meta-openbmc-mods/meta-common/recipes-intel/configure-usb-c/configure-usb-c.bb @@ -0,0 +1,25 @@ +SUMMARY = "Configure USB Type C controller" +DESCRIPTION = "Configure USB Type C CC controller which requires basic initialization on every G3 to S5 cycle" + +S = "${WORKDIR}" +SRC_URI = " \ + file://configure-usb-c.sh \ + file://configure-usb-c.service \ + " + +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://${INTELBASE}/COPYING.apache-2.0;md5=34400b68072d710fecd0a2940a0d1658" +RDEPENDS_${PN} += "bash" + +inherit systemd + +FILES_${PN} += "${systemd_system_unitdir}/configure-usb-c.service" + +do_install_append() { + install -d ${D}${bindir} + install -m 0755 ${S}/configure-usb-c.sh ${D}/${bindir}/configure-usb-c.sh + install -d ${D}${systemd_system_unitdir} + install -m 0644 ${S}/configure-usb-c.service ${D}${base_libdir}/systemd/system +} + +SYSTEMD_SERVICE_${PN} = "configure-usb-c.service" diff --git a/meta-openbmc-mods/meta-common/recipes-intel/configure-usb-c/files/configure-usb-c.service b/meta-openbmc-mods/meta-common/recipes-intel/configure-usb-c/files/configure-usb-c.service new file mode 100644 index 000000000..465ddd77f --- /dev/null +++ b/meta-openbmc-mods/meta-common/recipes-intel/configure-usb-c/files/configure-usb-c.service @@ -0,0 +1,9 @@ +[Unit] +Description=Configure USB Type C controller + +[Service] +ExecStart=/usr/bin/configure-usb-c.sh +Type=oneshot + +[Install] +WantedBy=basic.target diff --git a/meta-openbmc-mods/meta-common/recipes-intel/configure-usb-c/files/configure-usb-c.sh b/meta-openbmc-mods/meta-common/recipes-intel/configure-usb-c/files/configure-usb-c.sh new file mode 100644 index 000000000..c7cc4a231 --- /dev/null +++ b/meta-openbmc-mods/meta-common/recipes-intel/configure-usb-c/files/configure-usb-c.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +I2C_BUS=7 +CHIP_ADDR=0x47 + +read_id() { + local idx=0 + local result=0 + local value=0 + for ((idx=0; idx<6; idx++)) + do + typeset -i value=$(gpioget $(gpiofind "FM_BMC_BOARD_SKU_ID${idx}_N")) + value=$((value << idx)) + result=$((result | value)) + done + echo $result +} + +BOARD_ID=$(read_id) +if grep -q 'CPU part\s*: 0xc07' /proc/cpuinfo; then # AST2600 + if [[ $BOARD_ID == 62 || $BOARD_ID == 61 ]]; then + # Write 0x01 data into General Control Register (offset 0x0A) + # Write 0x21 data into General Control Register (offset 0x0A) + # Write 0x80 data into Connection Status Register (offset 0x08) + # Write 0x20 data into General Control Register (offset 0x0A) + i2cset -y $I2C_BUS $CHIP_ADDR 0x0a 0x01; i2cset -y $I2C_BUS $CHIP_ADDR 0x0a 0x21; i2cset -y $I2C_BUS $CHIP_ADDR 0x08 0x80; i2cset -y $I2C_BUS $CHIP_ADDR 0x0a 0x20 + echo "Configured USB Type C controller" + fi +fi |