meta-ufispace: Add meta-ufispace layer and meta-ncplite machine

Iniitial submission of meta-layer and meta-machine layer.

Tested: Build and run on our machine successfully.

Change-Id: I4920d8ce6aff119ba5cbc4772d84a6377784f85d
Signed-off-by: Jordan Chang <jordan.chang@ufispace.com>
diff --git a/meta-ufispace/meta-common/recipes-phosphor/network/usb-network.bb b/meta-ufispace/meta-common/recipes-phosphor/network/usb-network.bb
new file mode 100644
index 0000000..14d8486
--- /dev/null
+++ b/meta-ufispace/meta-common/recipes-phosphor/network/usb-network.bb
@@ -0,0 +1,27 @@
+LICENSE = "Apache-2.0"
+LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
+
+FILESEXTRAPATHS:append := "${THISDIR}/${PN}"
+SRC_URI += "file://usb-network.sh \
+           file://usb-network.service \
+           file://00-bmc-usb0.network"
+
+inherit allarch systemd
+
+DEPENDS += "systemd"
+RDEPENDS:${PN} += "libsystemd bash"
+
+FILES:${PN} += "${sysconfdir_native}/systemd/network/00-bmc-usb0.network"
+
+do_install() {
+    install -d ${D}/${sbindir}
+    install -m 0755 ${WORKDIR}/usb-network.sh ${D}/${sbindir}
+
+    install -d ${D}${systemd_unitdir}/system/
+    install -m 0644 ${WORKDIR}/usb-network.service ${D}${systemd_unitdir}/system
+
+    install -d ${D}${sysconfdir_native}/systemd/network/
+    install -m 0644 ${WORKDIR}/00-bmc-usb0.network ${D}${sysconfdir_native}/systemd/network
+}
+
+SYSTEMD_SERVICE:${PN} = "usb-network.service"
diff --git a/meta-ufispace/meta-common/recipes-phosphor/network/usb-network/00-bmc-usb0.network b/meta-ufispace/meta-common/recipes-phosphor/network/usb-network/00-bmc-usb0.network
new file mode 100644
index 0000000..28d1e9a
--- /dev/null
+++ b/meta-ufispace/meta-common/recipes-phosphor/network/usb-network/00-bmc-usb0.network
@@ -0,0 +1,8 @@
+[Match]
+Name=usb0
+[Address]
+Address=169.254.1.2/24
+[Network]
+DHCP=false
+LinkLocalAddressing=no
+IPv6AcceptRA=no
diff --git a/meta-ufispace/meta-common/recipes-phosphor/network/usb-network/usb-network.service b/meta-ufispace/meta-common/recipes-phosphor/network/usb-network/usb-network.service
new file mode 100644
index 0000000..6264153
--- /dev/null
+++ b/meta-ufispace/meta-common/recipes-phosphor/network/usb-network/usb-network.service
@@ -0,0 +1,10 @@
+[Unit]
+Description=Enable USB Network
+After=phosphor-ipmi-host.service
+
+[Service]
+Type=oneshot
+ExecStart=/usr/sbin/usb-network.sh
+
+[Install]
+WantedBy=multi-user.target
diff --git a/meta-ufispace/meta-common/recipes-phosphor/network/usb-network/usb-network.sh b/meta-ufispace/meta-common/recipes-phosphor/network/usb-network/usb-network.sh
new file mode 100644
index 0000000..0ea9bd2
--- /dev/null
+++ b/meta-ufispace/meta-common/recipes-phosphor/network/usb-network/usb-network.sh
@@ -0,0 +1,28 @@
+#!/bin/bash -e
+
+cd /sys/kernel/config/usb_gadget
+
+if [ ! -f "g1" ]; then
+    mkdir g1
+    cd g1
+
+    echo 0x1d6b > idVendor  # Linux foundation
+    echo 0x0104 > idProduct # Multifunction composite gadget
+    mkdir -p strings/0x409
+    echo "Linux" > strings/0x409/manufacturer
+    echo "Ethernet/ECM gadget" > strings/0x409/product
+
+    mkdir -p configs/c.1
+    echo 100 > configs/c.1/MaxPower
+    mkdir -p configs/c.1/strings/0x409
+    echo "ECM" > configs/c.1/strings/0x409/configuration
+
+    mkdir -p functions/ecm.usb0
+
+    ln -s functions/ecm.usb0 configs/c.1
+
+    # Write the device info in /sys/class/udc to UDC
+    echo 1e6a2000.usb > UDC
+
+fi
+exit 0
diff --git a/meta-ufispace/meta-common/recipes-phosphor/packagegroups/packagegroup-ufispace-apps.bb b/meta-ufispace/meta-common/recipes-phosphor/packagegroups/packagegroup-ufispace-apps.bb
new file mode 100644
index 0000000..52902d5
--- /dev/null
+++ b/meta-ufispace/meta-common/recipes-phosphor/packagegroups/packagegroup-ufispace-apps.bb
@@ -0,0 +1,47 @@
+SUMMARY = "OpenBMC for Ufispace - Applications"
+PR = "r1"
+
+inherit packagegroup
+
+PROVIDES = "${PACKAGES}"
+PACKAGES = " \
+    ${PN}-chassis \
+    ${PN}-fans \
+    ${PN}-flash \
+    ${PN}-system \
+    "
+
+PROVIDES += "virtual/obmc-chassis-mgmt"
+PROVIDES += "virtual/obmc-fan-mgmt"
+PROVIDES += "virtual/obmc-flash-mgmt"
+PROVIDES += "virtual/obmc-system-mgmt"
+
+RPROVIDES:${PN}-chassis += "virtual-obmc-chassis-mgmt"
+RPROVIDES:${PN}-fans += "virtual-obmc-fan-mgmt"
+RPROVIDES:${PN}-flash += "virtual-obmc-flash-mgmt"
+RPROVIDES:${PN}-system += "virtual-obmc-system-mgmt"
+
+SUMMARY:${PN}-chassis = "Ufispace Chassis"
+RDEPENDS:${PN}-chassis = " \
+    phosphor-skeleton-control-power \
+    "
+
+SUMMARY:${PN}-fans = "Ufispace Fans"
+RDEPENDS:${PN}-fans = " \
+    phosphor-pid-control \
+    "
+
+SUMMARY:${PN}-flash = "Ufispace Flash"
+RDEPENDS:${PN}-flash = " \
+    phosphor-software-manager \
+    phosphor-ipmi-blobs \
+    "
+
+SUMMARY:${PN}-system = "Ufispace System"
+RDEPENDS:${PN}-system = " \
+    webui-vue \
+    phosphor-sel-logger \
+    phosphor-state-manager \
+    usb-network \
+    smbios-mdr \
+    "