[Subtree] Bring openbmc machines to top level

The new subtree model brings the subtrees up from the openbmc-machines
layer.

Change-Id: I58a03ae1be374bc79ae1438e65e888375d12d0c0
Signed-off-by: Dave Cobbley <david.j.cobbley@linux.intel.com>
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/meta-inventec/meta-lanyang/conf/bblayers.conf.sample b/meta-inventec/meta-lanyang/conf/bblayers.conf.sample
new file mode 100644
index 0000000..fd230c7
--- /dev/null
+++ b/meta-inventec/meta-lanyang/conf/bblayers.conf.sample
@@ -0,0 +1,33 @@
+# LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf
+# changes incompatibly
+LCONF_VERSION = "8"
+
+BBPATH = "${TOPDIR}"
+BBFILES ?= ""
+
+BBLAYERS ?= " \
+  ##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-phosphor \
+  ##OEROOT##/meta-aspeed \
+  ##OEROOT##/meta-openpower \
+  ##OEROOT##/meta-inventec \
+  ##OEROOT##/meta-inventec/meta-lanyang \
+  "
+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-phosphor \
+  ##OEROOT##/meta-aspeed \
+  ##OEROOT##/meta-openpower \
+  ##OEROOT##/meta-inventec \
+  ##OEROOT##/meta-inventec/meta-lanyang \
+  "
diff --git a/meta-inventec/meta-lanyang/conf/conf-notes.txt b/meta-inventec/meta-lanyang/conf/conf-notes.txt
new file mode 100644
index 0000000..9b3c01a
--- /dev/null
+++ b/meta-inventec/meta-lanyang/conf/conf-notes.txt
@@ -0,0 +1,2 @@
+Common targets are:
+     obmc-phosphor-image
diff --git a/meta-inventec/meta-lanyang/conf/layer.conf b/meta-inventec/meta-lanyang/conf/layer.conf
new file mode 100644
index 0000000..64223a2
--- /dev/null
+++ b/meta-inventec/meta-lanyang/conf/layer.conf
@@ -0,0 +1,9 @@
+# We have a conf and classes directory, add to BBPATH
+BBPATH .= ":${LAYERDIR}"
+
+# We have recipes-* directories, add to BBFILES
+BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \
+            ${LAYERDIR}/recipes-*/*/*.bbappend"
+
+BBFILE_COLLECTIONS += "lanyang"
+BBFILE_PATTERN_lanyang = ""
diff --git a/meta-inventec/meta-lanyang/conf/local.conf.sample b/meta-inventec/meta-lanyang/conf/local.conf.sample
new file mode 100644
index 0000000..a4a3343
--- /dev/null
+++ b/meta-inventec/meta-lanyang/conf/local.conf.sample
@@ -0,0 +1,21 @@
+MACHINE ??= "lanyang"
+DISTRO ?= "openbmc-openpower"
+PACKAGE_CLASSES ?= "package_rpm"
+SANITY_TESTED_DISTROS_append ?= " *"
+EXTRA_IMAGE_FEATURES = "debug-tweaks"
+USER_CLASSES ?= "buildstats image-mklibs image-prelink"
+PATCHRESOLVE = "noop"
+BB_DISKMON_DIRS = "\
+    STOPTASKS,${TMPDIR},1G,100K \
+    STOPTASKS,${DL_DIR},1G,100K \
+    STOPTASKS,${SSTATE_DIR},1G,100K \
+    STOPTASKS,/tmp,100M,100K \
+    ABORT,${TMPDIR},100M,1K \
+    ABORT,${DL_DIR},100M,1K \
+    ABORT,${SSTATE_DIR},100M,1K \
+    ABORT,/tmp,10M,1K"
+CONF_VERSION = "1"
+INHERIT += "extrausers"
+EXTRA_USERS_PARAMS = " \
+  usermod -p '\$1\$UGMqyqdG\$FZiylVFmRRfl9Z0Ue8G7e/' root; \
+  "
diff --git a/meta-inventec/meta-lanyang/conf/machine/lanyang.conf b/meta-inventec/meta-lanyang/conf/machine/lanyang.conf
new file mode 100644
index 0000000..4ca08b1
--- /dev/null
+++ b/meta-inventec/meta-lanyang/conf/machine/lanyang.conf
@@ -0,0 +1,14 @@
+KMACHINE = "aspeed"
+KERNEL_DEVICETREE = "${KMACHINE}-bmc-opp-${MACHINE}.dtb"
+
+UBOOT_MACHINE = "ast_g5_ncsi_config"
+
+FLASH_SIZE = "65536"
+
+PREFERRED_PROVIDER_virtual/phosphor-ipmi-fru-inventory = "lanyang-ipmi-inventory-map-native"
+PREFERRED_PROVIDER_virtual/phosphor-led-manager-config-native = "lanyang-led-manager-config-native"
+
+require conf/machine/include/ast2500.inc
+require conf/machine/include/obmc-bsp-common.inc
+require conf/machine/include/inventec.inc
+require conf/machine/include/p9.inc
diff --git a/meta-inventec/meta-lanyang/recipes-phosphor/chassis/avsbus-control.bb b/meta-inventec/meta-lanyang/recipes-phosphor/chassis/avsbus-control.bb
new file mode 100644
index 0000000..ff68f39
--- /dev/null
+++ b/meta-inventec/meta-lanyang/recipes-phosphor/chassis/avsbus-control.bb
@@ -0,0 +1,28 @@
+SUMMARY = "Lanyang AVSBus control"
+DESCRIPTION = "Voltage regulator module (VRM) AVSBus control for Lanyang"
+PR = "r0"
+
+inherit obmc-phosphor-systemd
+inherit obmc-phosphor-license
+
+TMPL_OFF = "avsbus-disable@.service"
+TMPL_ON = "avsbus-enable@.service"
+INSTFMT_OFF = "avsbus-disable@{0}.service"
+INSTFMT_ON = "avsbus-enable@{0}.service"
+TGTFMT_OFF = "obmc-host-stop@{0}.target"
+TGTFMT_ON = "obmc-chassis-poweron@{0}.target"
+FMT_OFF = "../${TMPL_OFF}:${TGTFMT_OFF}.wants/${INSTFMT_OFF}"
+FMT_ON = "../${TMPL_ON}:${TGTFMT_ON}.requires/${INSTFMT_ON}"
+
+SYSTEMD_SERVICE_${PN} += "${TMPL_OFF}"
+SYSTEMD_LINK_${PN} += "${@compose_list(d, 'FMT_OFF', 'OBMC_CHASSIS_INSTANCES')}"
+SYSTEMD_SERVICE_${PN} += "${TMPL_ON}"
+SYSTEMD_LINK_${PN} += "${@compose_list(d, 'FMT_ON', 'OBMC_CHASSIS_INSTANCES')}"
+
+SRC_URI += "file://lanyang_avsbus.sh"
+RDEPENDS_${PN} += "i2c-tools"
+
+do_install() {
+        install -d ${D}${bindir}
+        install -m 0755 ${WORKDIR}/lanyang_avsbus.sh ${D}${bindir}/lanyang_avsbus.sh
+}
diff --git a/meta-inventec/meta-lanyang/recipes-phosphor/chassis/avsbus-control/avsbus-disable@.service b/meta-inventec/meta-lanyang/recipes-phosphor/chassis/avsbus-control/avsbus-disable@.service
new file mode 100644
index 0000000..add5f22
--- /dev/null
+++ b/meta-inventec/meta-lanyang/recipes-phosphor/chassis/avsbus-control/avsbus-disable@.service
@@ -0,0 +1,15 @@
+[Unit]
+Description=Disable AVSBus on VRMs
+Wants=obmc-power-stop-pre@%i.target
+Before=obmc-power-stop-pre@%i.target
+Conflicts=obmc-host-startmin@%i.target
+ConditionPathExists=!/run/openbmc/chassis@%i-on
+
+[Service]
+ExecStart=/usr/bin/env lanyang_avsbus.sh disable
+SyslogIdentifier=lanyang_avsbus.sh
+Type=oneshot
+RemainAfterExit=yes
+
+[Install]
+WantedBy=obmc-host-stop@%i.target
diff --git a/meta-inventec/meta-lanyang/recipes-phosphor/chassis/avsbus-control/avsbus-enable@.service b/meta-inventec/meta-lanyang/recipes-phosphor/chassis/avsbus-control/avsbus-enable@.service
new file mode 100644
index 0000000..787ec4c
--- /dev/null
+++ b/meta-inventec/meta-lanyang/recipes-phosphor/chassis/avsbus-control/avsbus-enable@.service
@@ -0,0 +1,16 @@
+[Unit]
+Description=Enable AVSBus on VRMs
+Wants=obmc-host-start-pre@%i.target
+Before=obmc-host-start-pre@%i.target
+Conflicts=obmc-host-stop@%i.target
+ConditionPathExists=!/run/openbmc/chassis@%i-on
+
+[Service]
+ExecStart=/usr/bin/env lanyang_avsbus.sh vdn_max
+ExecStart=/usr/bin/env lanyang_avsbus.sh enable
+SyslogIdentifier=lanyang_avsbus.sh
+Type=oneshot
+RemainAfterExit=yes
+
+[Install]
+RequiredBy=obmc-chassis-poweron@%i.target
diff --git a/meta-inventec/meta-lanyang/recipes-phosphor/chassis/avsbus-control/lanyang_avsbus.sh b/meta-inventec/meta-lanyang/recipes-phosphor/chassis/avsbus-control/lanyang_avsbus.sh
new file mode 100755
index 0000000..bf58def
--- /dev/null
+++ b/meta-inventec/meta-lanyang/recipes-phosphor/chassis/avsbus-control/lanyang_avsbus.sh
@@ -0,0 +1,98 @@
+#!/bin/sh -e
+# AVSBus control for PMBUS voltage regulator modules (VRMs)
+# Switches output voltage target between
+# - VOUT_COMMAND register (AVSBus disabled, default on Zaius)
+# - AVSBus target output (AVSBus enabled, voltage set by host)
+
+cpu0_i2c_bus="5"
+cpu1_i2c_bus="6"
+busses="$cpu0_i2c_bus $cpu1_i2c_bus"
+vdd_i2c_addr_page="0x60:0x01"
+vdn_i2c_addr_page="0x64:0x01"
+vcs_i2c_addr_page="0x64:0x00"
+addrs_pages="$vdd_i2c_addr_page $vdn_i2c_addr_page $vcs_i2c_addr_page"
+
+# Usage: vrm_set_page <bus> <i2c_address> <page>
+vrm_set_page()
+{
+    i2cset -y $1 $2 0x00 $3 b
+}
+
+# Usage: vrm_avs_enable <bus> <i2c_address> <page>
+# Initializes the AVSBus VOUT setpoint to the value in PMBus VOUT_COMMAND
+# Sets OPERATION PMBUS register to
+# - Enable/Disable: On
+# - VOUT Source: AVSBus Target Rail Voltage
+# - AVSBus Copy: VOUT_COMMAND remains unchanged
+# Writes to VOUT setpoint over AVSBus will persist after the VRM is switched to
+# PMBus control. Switching back to AVSBus control restores this persisted
+# setpoint rather than re-initializing to PMBus VOUT_COMMAND. This behavior is
+# known to Intersil and writing VOUT_COMMAND over PMBus is the only workaround.
+vrm_avs_enable()
+{
+    vrm_set_page "$@"
+    echo Enabling AVSBus on bus $1 VRM @$2 rail $3...
+    local vout_command=`i2cget -y $1 $2 0x21 w`
+    i2cset -y $1 $2 0x21 $vout_command w
+    i2cset -y $1 $2 0x01 0xb0 b
+}
+
+# Usage: vrm_avs_disable <bus> <i2c_address> <page>
+# Sets OPERATION PMBUS register to
+# - Enable/Disable: On
+# - VOUT Source: VOUT_COMMAND
+# - AVSBus Copy: VOUT_COMMAND remains unchanged
+vrm_avs_disable()
+{
+    vrm_set_page "$@"
+    echo Disabling AVSBus on bus $1 VRM @$2 rail $3...
+    i2cset -y $1 $2 0x01 0x80 b
+}
+
+# Usage: vrm_vout_max_1v1 <bus> <i2c_address> <page>
+# Sets VOUT_MAX to 1.1V
+vrm_vout_max_1v1()
+{
+    vrm_set_page "$@"
+    echo Setting VOUT_MAX=[1.1V] on bus $1 VRM @$2 rail $3...
+    i2cset -y $1 $2 0x24 0x44c w
+}
+
+# Usage: vrm_print <bus> <i2c_address> <page>
+vrm_print()
+{
+    vrm_set_page "$@"
+    local operation=`i2cget -y $1 $2 0x01 b`
+    local vout=`i2cget -y $1 $2 0x8b w`
+    local iout=`i2cget -y $1 $2 0x8c w`
+    echo VRM on bus $1 @$2 rail $3: OPERATION=$operation VOUT=$vout IOUT=$iout
+}
+
+# Usage: for_each_rail <command>
+# <command> will be invoked with <bus> <i2c_address> <page>
+for_each_rail()
+{
+    for bus in $busses
+    do
+        for addr_page in $addrs_pages
+        do
+            $1 $bus `echo $addr_page | tr : " "`
+        done
+    done
+}
+
+if [ "$1" == "enable" ]
+then
+    for_each_rail vrm_avs_enable
+elif [ "$1" == "disable" ]
+then
+    for_each_rail vrm_avs_disable
+elif [ "$1" == "vdn_max" ]
+then
+    addrs_pages="$vdn_i2c_addr_page"
+    for_each_rail vrm_vout_max_1v1
+else
+    for_each_rail vrm_print
+    echo "\"$0 <enable|disable>\" to control whether VRMs use AVSBus"
+    echo "\"$0 <vdn_max>\" to set VDN rails VOUT_MAX to 1.1V"
+fi
diff --git a/meta-inventec/meta-lanyang/recipes-phosphor/console/obmc-console/obmc-console.conf b/meta-inventec/meta-lanyang/recipes-phosphor/console/obmc-console/obmc-console.conf
new file mode 100644
index 0000000..a5ba3f3
--- /dev/null
+++ b/meta-inventec/meta-lanyang/recipes-phosphor/console/obmc-console/obmc-console.conf
@@ -0,0 +1,4 @@
+lpc-address = 0x3f8
+sirq = 4
+local-tty = ttyS0
+local-tty-baud = 115200
diff --git a/meta-inventec/meta-lanyang/recipes-phosphor/console/obmc-console_%.bbappend b/meta-inventec/meta-lanyang/recipes-phosphor/console/obmc-console_%.bbappend
new file mode 100644
index 0000000..ab94de8
--- /dev/null
+++ b/meta-inventec/meta-lanyang/recipes-phosphor/console/obmc-console_%.bbappend
@@ -0,0 +1 @@
+FILESEXTRAPATHS_prepend_lanyang := "${THISDIR}/${PN}:"
diff --git a/meta-inventec/meta-lanyang/recipes-phosphor/host/p9-host-start.bbappend b/meta-inventec/meta-lanyang/recipes-phosphor/host/p9-host-start.bbappend
new file mode 100644
index 0000000..e2fe9f2
--- /dev/null
+++ b/meta-inventec/meta-lanyang/recipes-phosphor/host/p9-host-start.bbappend
@@ -0,0 +1,2 @@
+RDEPENDS_${PN} += 'avsbus-control'
+RDEPENDS_${PN}_remove += "p9-vcs-workaround"
diff --git a/meta-inventec/meta-lanyang/recipes-phosphor/image/obmc-phosphor-image.bbappend b/meta-inventec/meta-lanyang/recipes-phosphor/image/obmc-phosphor-image.bbappend
new file mode 100644
index 0000000..aa57bbf
--- /dev/null
+++ b/meta-inventec/meta-lanyang/recipes-phosphor/image/obmc-phosphor-image.bbappend
@@ -0,0 +1 @@
+OBMC_IMAGE_EXTRA_INSTALL_append = " mboxd"
diff --git a/meta-inventec/meta-lanyang/recipes-phosphor/leds/lanyang-led-manager-config-native.bb b/meta-inventec/meta-lanyang/recipes-phosphor/leds/lanyang-led-manager-config-native.bb
new file mode 100644
index 0000000..083002e
--- /dev/null
+++ b/meta-inventec/meta-lanyang/recipes-phosphor/leds/lanyang-led-manager-config-native.bb
@@ -0,0 +1,18 @@
+SUMMARY = "Phosphor LED Group Management for Lanyang"
+PR = "r1"
+
+inherit native
+inherit obmc-phosphor-license
+
+PROVIDES += "virtual/phosphor-led-manager-config-native"
+
+SRC_URI += "file://led.yaml"
+S = "${WORKDIR}"
+
+# Overwrite the example led layout yaml file prior
+# to building the phosphor-led-manager package
+do_install() {
+    SRC=${S}
+    DEST=${D}${datadir}/phosphor-led-manager
+    install -D ${SRC}/led.yaml ${DEST}/led.yaml
+}
diff --git a/meta-inventec/meta-lanyang/recipes-phosphor/leds/lanyang-led-manager-config/led.yaml b/meta-inventec/meta-lanyang/recipes-phosphor/leds/lanyang-led-manager-config/led.yaml
new file mode 100755
index 0000000..5eb11f1
--- /dev/null
+++ b/meta-inventec/meta-lanyang/recipes-phosphor/leds/lanyang-led-manager-config/led.yaml
@@ -0,0 +1,31 @@
+bmc_booted:
+    sys_boot_status:
+        Action: 'Blink'
+        DutyOn: 50
+        Period: 1000
+        Priority: 'On'
+
+power_on:
+    sys_boot_status:
+        Action: 'On'
+        DutyOn: 50
+        Period: 0
+        Priority: 'On'
+
+enclosure_fault:
+    plt_fault:
+        Action: 'On'
+
+enclosure_identify:
+    attention:
+        Action: 'Blink'
+        DutyOn: 50
+        Period: 1000
+
+lamp_test:
+    plt_fault:
+        Action: 'Blink'
+        DutyOn: 50
+        Period: 1000
+    attention:
+        Action: 'On'
diff --git a/meta-inventec/meta-lanyang/recipes-phosphor/mboxd/mboxd.bbappend b/meta-inventec/meta-lanyang/recipes-phosphor/mboxd/mboxd.bbappend
new file mode 100644
index 0000000..8b6248a
--- /dev/null
+++ b/meta-inventec/meta-lanyang/recipes-phosphor/mboxd/mboxd.bbappend
@@ -0,0 +1 @@
+MBOXD_FLASH_SIZE = "64M"
diff --git a/meta-inventec/meta-lanyang/recipes-phosphor/workbook/lanyang-config.bb b/meta-inventec/meta-lanyang/recipes-phosphor/workbook/lanyang-config.bb
new file mode 100644
index 0000000..1798dad
--- /dev/null
+++ b/meta-inventec/meta-lanyang/recipes-phosphor/workbook/lanyang-config.bb
@@ -0,0 +1,5 @@
+SUMMARY = "Lanyang board wiring"
+DESCRIPTION = "Board wiring information for the Lanyang OpenPOWER system."
+PR = "r1"
+
+inherit config-in-skeleton