Generate OCC Sensor mapping during build time
Change-Id: Ieb0ba06bc8875af382b1f8e9ed38ec36eeaece48
Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>
diff --git a/meta-openbmc-machines/meta-openpower/classes/openpower-occ-control.bbclass b/meta-openbmc-machines/meta-openpower/classes/openpower-occ-control.bbclass
new file mode 100644
index 0000000..4294e93
--- /dev/null
+++ b/meta-openbmc-machines/meta-openpower/classes/openpower-occ-control.bbclass
@@ -0,0 +1 @@
+YAML_DEST="${D}${datadir}/openpower-occ-control"
diff --git a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/occ/openpower-occ-control-config-example-native.bb b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/occ/openpower-occ-control-config-example-native.bb
new file mode 100644
index 0000000..842d53e
--- /dev/null
+++ b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/occ/openpower-occ-control-config-example-native.bb
@@ -0,0 +1,18 @@
+SUMMARY = "OpenPower OCC Control with example occ sensor IDs"
+PR = "r1"
+
+inherit native
+inherit obmc-phosphor-utils
+require openpower-occ-control.inc
+inherit openpower-occ-control
+
+PROVIDES += "virtual/openpower-occ-control-config-native"
+
+S = "${WORKDIR}/git"
+
+# Copies example occ sensor ID yaml file
+do_install() {
+ SRC=${S}
+ install -d ${YAML_DEST}/
+ install -D ${SRC}/example/occ_sensor.yaml ${YAML_DEST}/occ_sensor.yaml
+}
diff --git a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/occ/openpower-occ-control-config-mrw-native.bb b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/occ/openpower-occ-control-config-mrw-native.bb
new file mode 100644
index 0000000..aa831a5
--- /dev/null
+++ b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/occ/openpower-occ-control-config-mrw-native.bb
@@ -0,0 +1,19 @@
+SUMMARY = "OpenPower OCC Control with MRW generated sensor IDs"
+PR = "r1"
+
+inherit native
+inherit obmc-phosphor-utils
+inherit obmc-phosphor-license
+inherit openpower-occ-control
+
+PROVIDES += "virtual/openpower-occ-control-config-native"
+DEPENDS += "mrw-native mrw-perl-tools-native"
+
+# Generate a YAML files based on MRW input
+do_install_append() {
+ install -d ${YAML_DEST}/
+ ${STAGING_BINDIR_NATIVE}/perl-native/perl \
+ ${STAGING_BINDIR_NATIVE}/gen_occ_map.pl \
+ -i ${STAGING_DATADIR_NATIVE}/obmc-mrw/${MACHINE}.xml \
+ -o ${YAML_DEST}/occ_sensor.yaml
+}
diff --git a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/occ/openpower-occ-control.bb b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/occ/openpower-occ-control.bb
index e1823fe..390ea72 100644
--- a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/occ/openpower-occ-control.bb
+++ b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/occ/openpower-occ-control.bb
@@ -12,6 +12,7 @@
DBUS_SERVICE_${PN} += "org.open_power.OCC.Control.service"
+DEPENDS += "virtual/${PN}-config-native"
DEPENDS += " \
sdbusplus \
sdbusplus-native \
@@ -29,6 +30,7 @@
phosphor-dbus-interfaces \
"
+EXTRA_OECONF = "YAML_PATH=${STAGING_DATADIR_NATIVE}/${PN}"
EXTRA_OECONF_append = "${@bb.utils.contains('OBMC_MACHINE_FEATURES', 'i2c-occ', ' --enable-i2c-occ', '', d)}"
S = "${WORKDIR}/git"
diff --git a/meta-openbmc-machines/meta-openpower/conf/machine/include/openpower.inc b/meta-openbmc-machines/meta-openpower/conf/machine/include/openpower.inc
index 984a377..cc92027 100644
--- a/meta-openbmc-machines/meta-openpower/conf/machine/include/openpower.inc
+++ b/meta-openbmc-machines/meta-openpower/conf/machine/include/openpower.inc
@@ -24,3 +24,11 @@
"${@cf_enabled(d, 'obmc-mrw', 'openpower-fru-inventory-mrw-native', 'openpower-fru-inventory-example-native')}"
PREFERRED_PROVIDER_virtual/openpower-fru-properties ?= \
"${@cf_enabled(d, 'obmc-mrw', 'openpower-fru-properties-mrw-native', 'openpower-fru-properties-example-native')}"
+
+# The openpower-occ-control application is data-driven and requires an input
+# yaml of OCC instance numbers to sensor IDs.
+# This virtual is a native recipe that provides that mapping by installing
+# configuration files in the format and native sysroot location expected by
+# the openpower-occ-control build process in the native sysroot.
+PREFERRED_PROVIDER_virtual/openpower-occ-control-config-native ?= \
+ "${@cf_enabled(d, 'obmc-mrw', 'openpower-occ-control-config-mrw-native', 'openpower-occ-control-config-example-native')}"