Update LED Manager recipe to support Palmetto machine

This has the changes that enables LED group manager on Palmetto

Change-Id: Iaf4d4cc4c798c70e557009e9928225facb1d7d86
Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>
diff --git a/common/recipes-phosphor/leds/phosphor-led-manager-config-example-native.bb b/common/recipes-phosphor/leds/phosphor-led-manager-config-example-native.bb
index 8b3703d..139b775 100644
--- a/common/recipes-phosphor/leds/phosphor-led-manager-config-example-native.bb
+++ b/common/recipes-phosphor/leds/phosphor-led-manager-config-example-native.bb
@@ -5,6 +5,8 @@
 inherit obmc-phosphor-utils
 require phosphor-led-manager.inc
 
+PROVIDES += "virtual/phosphor-led-manager-config-native"
+
 S = "${WORKDIR}/git"
 
 # Copies example led layout yaml file
diff --git a/common/recipes-phosphor/leds/phosphor-led-manager-config-mrw-native.bb b/common/recipes-phosphor/leds/phosphor-led-manager-config-mrw-native.bb
index b88dedc..fb3259b 100644
--- a/common/recipes-phosphor/leds/phosphor-led-manager-config-mrw-native.bb
+++ b/common/recipes-phosphor/leds/phosphor-led-manager-config-mrw-native.bb
@@ -5,6 +5,7 @@
 inherit obmc-phosphor-utils
 inherit obmc-phosphor-license
 
+PROVIDES += "virtual/phosphor-led-manager-config-native"
 DEPENDS += "mrw-native mrw-perl-tools-native"
 
 # Generate a YAML files based on MRW input
diff --git a/common/recipes-phosphor/leds/phosphor-led-manager-config-native.bb b/common/recipes-phosphor/leds/phosphor-led-manager-config-native.bb
deleted file mode 100644
index 73812ea..0000000
--- a/common/recipes-phosphor/leds/phosphor-led-manager-config-native.bb
+++ /dev/null
@@ -1,19 +0,0 @@
-SUMMARY = "Phosphor LED Group Management meta data"
-PR = "r1"
-
-inherit obmc-phosphor-utils
-inherit obmc-phosphor-license
-inherit native
-
-# Default is the example set of data.
-PHOSPHOR_LED_MANAGER_CONFIG ??= "${BPN}-example-native"
-
-# Choose appropriate yaml file
-def get_depends(d):
-    if d.getVar('USE_MRW', 'yes'):
-        return "${BPN}-mrw-native"
-    else:
-        return "${PHOSPHOR_LED_MANAGER_CONFIG}"
-
-USE_MRW = "${@cf_enabled(d, 'obmc-mrw', 'yes')}"
-DEPENDS += "${@get_depends(d)}"
diff --git a/common/recipes-phosphor/leds/phosphor-led-manager.bb b/common/recipes-phosphor/leds/phosphor-led-manager.bb
index 54996f9..1787189 100644
--- a/common/recipes-phosphor/leds/phosphor-led-manager.bb
+++ b/common/recipes-phosphor/leds/phosphor-led-manager.bb
@@ -9,11 +9,12 @@
 DEPENDS += "python-pyyaml-native"
 DEPENDS += "autoconf-archive-native"
 DEPENDS += "sdbusplus sdbusplus-native"
-DEPENDS += "${PN}-config-native"
+DEPENDS += "virtual/${PN}-config-native"
 RDEPENDS_${PN} += "libsystemd"
 
 S = "${WORKDIR}/git"
 
 DBUS_SERVICE_${PN} += "xyz.openbmc_project.LED.GroupManager.service"
+SYSTEMD_SERVICE_${PN} += "obmc-led-group-start@.service obmc-led-group-stop@.service"
 
 EXTRA_OECONF = "YAML_PATH=${STAGING_DATADIR_NATIVE}/${PN}"
diff --git a/common/recipes-phosphor/leds/phosphor-led-manager/obmc-led-group-start@.service b/common/recipes-phosphor/leds/phosphor-led-manager/obmc-led-group-start@.service
new file mode 100644
index 0000000..7c0207c
--- /dev/null
+++ b/common/recipes-phosphor/leds/phosphor-led-manager/obmc-led-group-start@.service
@@ -0,0 +1,10 @@
+[Unit]
+Description=Assert %i LED
+Wants=mapper-wait@-xyz-openbmc_project-led-groups-%i.service
+After=mapper-wait@-xyz-openbmc_project-led-groups-%i.service
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+Restart=no
+ExecStart={sbindir}/mapper call /xyz/openbmc_project/led/groups/%i org.freedesktop.DBus.Properties Set ssv xyz.openbmc_project.Led.Group Asserted b true
diff --git a/common/recipes-phosphor/leds/phosphor-led-manager/obmc-led-group-stop@.service b/common/recipes-phosphor/leds/phosphor-led-manager/obmc-led-group-stop@.service
new file mode 100644
index 0000000..4ddf0f8
--- /dev/null
+++ b/common/recipes-phosphor/leds/phosphor-led-manager/obmc-led-group-stop@.service
@@ -0,0 +1,10 @@
+[Unit]
+Description=Assert %i LED
+Wants=mapper-wait@-xyz-openbmc_project-led-groups-%i.service
+After=mapper-wait@-xyz-openbmc_project-led-groups-%i.service
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+Restart=no
+ExecStart={sbindir}/mapper call /xyz/openbmc_project/led/groups/%i org.freedesktop.DBus.Properties Set ssv xyz.openbmc_project.Led.Group Asserted b false
diff --git a/conf/distro/include/phosphor-defaults.inc b/conf/distro/include/phosphor-defaults.inc
index 28e04ef..0577085 100644
--- a/conf/distro/include/phosphor-defaults.inc
+++ b/conf/distro/include/phosphor-defaults.inc
@@ -80,5 +80,13 @@
 PREFERRED_PROVIDER_virtual/phosphor-ipmi-fru-properties ?= \
     "${@cf_enabled(d, 'obmc-mrw', 'phosphor-ipmi-fru-properties-mrw-native', 'phosphor-ipmi-fru-properties-example-native')}"
 
+# The phosphor-led-manager application is data-driven and requires an input
+# yaml of LED group and members.
+# This virtual is a native recipe that provides that mapping by installing
+# configuration files in the format and native sysroot location expected by
+# the phosphor-led-manager build process in the native sysroot.
+PREFERRED_PROVIDER_virtual/phosphor-led-manager-config-native ?= \
+    "${@cf_enabled(d, 'obmc-mrw', 'phosphor-led-manager-config-mrw-native', 'phosphor-led-manager-config-example-native')}"
+
 OBMC_DBUS_PATH_ROOT ?= "/xyz/openbmc_project"
 OBMC_DBUS_IFACE_ROOT ?= "xyz.openbmc_project"