nicole: Add VPD support

VPD contains general description of the BMC card and MAC address for
the Ethernet controller.
Physically, VPD is stored in the EEPROM AT24C256C, which is connected
to the Aspeed SoC via I2C and can be read or written through
the special device file /sys/bus/i2c/devices/0-0050/eeprom.

Signed-off-by: Artem Senichev <a.senichev@yadro.com>
Change-Id: Id3d10968c9658141e7deec8b4b505bab8018892a
diff --git a/meta-nicole/conf/machine/nicole.conf b/meta-nicole/conf/machine/nicole.conf
index 488e6af..35d94e4 100644
--- a/meta-nicole/conf/machine/nicole.conf
+++ b/meta-nicole/conf/machine/nicole.conf
@@ -11,3 +11,7 @@
 require conf/machine/include/p9.inc
 
 IMAGE_FEATURES_remove = " obmc-fan-control obmc-fan-mgmt obmc-leds"
+
+PREFERRED_PROVIDER_virtual/openpower-fru-vpd-layout = "nicole-openpower-fru-vpd-layout-native"
+PREFERRED_PROVIDER_virtual/openpower-fru-inventory = "nicole-openpower-fru-inventory-native"
+PREFERRED_PROVIDER_virtual/openpower-fru-properties = "nicole-openpower-fru-properties-native"
diff --git a/meta-nicole/recipes-kernel/linux/linux-aspeed/arch/arm/boot/dts/aspeed-bmc-opp-nicole.dts b/meta-nicole/recipes-kernel/linux/linux-aspeed/arch/arm/boot/dts/aspeed-bmc-opp-nicole.dts
index 07f7d29..0b146e3 100644
--- a/meta-nicole/recipes-kernel/linux/linux-aspeed/arch/arm/boot/dts/aspeed-bmc-opp-nicole.dts
+++ b/meta-nicole/recipes-kernel/linux/linux-aspeed/arch/arm/boot/dts/aspeed-bmc-opp-nicole.dts
@@ -145,6 +145,16 @@
 	clock-names = "MACCLK", "RCLK";
 };
 
+&i2c0 {
+	status = "okay";
+
+	eeprom@50 {
+		compatible = "atmel,24c256";
+		reg = <0x50>;
+		pagesize = <64>;
+	};
+};
+
 &i2c1 {
 	status = "okay";
 };
diff --git a/meta-nicole/recipes-phosphor/images/obmc-phosphor-image.bbappend b/meta-nicole/recipes-phosphor/images/obmc-phosphor-image.bbappend
index aa57bbf..b2b27da 100644
--- a/meta-nicole/recipes-phosphor/images/obmc-phosphor-image.bbappend
+++ b/meta-nicole/recipes-phosphor/images/obmc-phosphor-image.bbappend
@@ -1 +1,4 @@
-OBMC_IMAGE_EXTRA_INSTALL_append = " mboxd"
+OBMC_IMAGE_EXTRA_INSTALL_append = " mboxd \
+                                    openpower-fru-vpd \
+                                    first-boot-set-mac \
+                                    first-boot-set-hostname"
diff --git a/meta-nicole/recipes-phosphor/network/first-boot-set-mac_%.bbappend b/meta-nicole/recipes-phosphor/network/first-boot-set-mac_%.bbappend
new file mode 100644
index 0000000..29d23c8
--- /dev/null
+++ b/meta-nicole/recipes-phosphor/network/first-boot-set-mac_%.bbappend
@@ -0,0 +1 @@
+SYSTEMD_SERVICE_${PN} += "first-boot-set-mac@eth0.service"
diff --git a/meta-nicole/recipes-phosphor/vpd/nicole-openpower-fru-inventory-native.bb b/meta-nicole/recipes-phosphor/vpd/nicole-openpower-fru-inventory-native.bb
new file mode 100644
index 0000000..0a5d73c
--- /dev/null
+++ b/meta-nicole/recipes-phosphor/vpd/nicole-openpower-fru-inventory-native.bb
@@ -0,0 +1,19 @@
+SUMMARY = "Nicole Inventory config for openpower-vpd-parser"
+PR = "r1"
+LICENSE = "Apache-2.0"
+LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
+
+inherit native
+inherit openpower-fru-vpd
+
+SRC_URI += "file://inventory"
+
+PROVIDES += "virtual/openpower-fru-inventory"
+
+S = "${WORKDIR}"
+
+do_install() {
+        DEST=${D}${inventory_datadir_native}
+        install -d ${DEST}
+        install inventory ${DEST}
+}
diff --git a/meta-nicole/recipes-phosphor/vpd/nicole-openpower-fru-inventory/inventory b/meta-nicole/recipes-phosphor/vpd/nicole-openpower-fru-inventory/inventory
new file mode 100644
index 0000000..62ab2da
--- /dev/null
+++ b/meta-nicole/recipes-phosphor/vpd/nicole-openpower-fru-inventory/inventory
@@ -0,0 +1,3 @@
+FRUS=BMC,ETHERNET
+PATHS=/system/chassis/bmc,/system/chassis/ethernet
+EEPROM=/sys/bus/i2c/devices/0-0050/eeprom
diff --git a/meta-nicole/recipes-phosphor/vpd/nicole-openpower-fru-properties-native.bb b/meta-nicole/recipes-phosphor/vpd/nicole-openpower-fru-properties-native.bb
new file mode 100644
index 0000000..05be1df
--- /dev/null
+++ b/meta-nicole/recipes-phosphor/vpd/nicole-openpower-fru-properties-native.bb
@@ -0,0 +1,19 @@
+SUMMARY = "FRU properties config for openpower-vpd-parser"
+PR = "r1"
+LICENSE = "Apache-2.0"
+LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
+
+inherit native
+inherit openpower-fru-vpd
+
+SRC_URI += "file://properties.yaml"
+
+PROVIDES += "virtual/openpower-fru-properties"
+
+S = "${WORKDIR}"
+
+do_install() {
+        DEST=${D}${properties_datadir}
+        install -d ${DEST}
+        install properties.yaml ${DEST}/out.yaml
+}
diff --git a/meta-nicole/recipes-phosphor/vpd/nicole-openpower-fru-properties/properties.yaml b/meta-nicole/recipes-phosphor/vpd/nicole-openpower-fru-properties/properties.yaml
new file mode 100644
index 0000000..96e567c
--- /dev/null
+++ b/meta-nicole/recipes-phosphor/vpd/nicole-openpower-fru-properties/properties.yaml
@@ -0,0 +1,7 @@
+/system/chassis/bmc:
+    xyz.openbmc_project.Inventory.Item:
+        Present: 'true'
+
+/system/chassis/ethernet:
+    xyz.openbmc_project.Inventory.Item:
+        Present: 'true'
diff --git a/meta-nicole/recipes-phosphor/vpd/nicole-openpower-fru-vpd-layout-native.bb b/meta-nicole/recipes-phosphor/vpd/nicole-openpower-fru-vpd-layout-native.bb
new file mode 100644
index 0000000..35c4de4
--- /dev/null
+++ b/meta-nicole/recipes-phosphor/vpd/nicole-openpower-fru-vpd-layout-native.bb
@@ -0,0 +1,19 @@
+SUMMARY = "Nicole VPD layout for openpower-fru-vpd"
+PR = "r1"
+LICENSE = "Apache-2.0"
+LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
+
+inherit native
+inherit openpower-fru-vpd
+
+SRC_URI += "file://layout.yaml"
+
+PROVIDES += "virtual/openpower-fru-vpd-layout"
+
+S = "${WORKDIR}"
+
+do_install() {
+        DEST=${D}${vpdlayout_datadir}
+        install -d ${DEST}
+        install layout.yaml ${DEST}
+}
diff --git a/meta-nicole/recipes-phosphor/vpd/nicole-openpower-fru-vpd-layout/layout.yaml b/meta-nicole/recipes-phosphor/vpd/nicole-openpower-fru-vpd-layout/layout.yaml
new file mode 100644
index 0000000..e71776b
--- /dev/null
+++ b/meta-nicole/recipes-phosphor/vpd/nicole-openpower-fru-vpd-layout/layout.yaml
@@ -0,0 +1,14 @@
+BMC:
+    xyz.openbmc_project.Inventory.Decorator.Asset:
+        OPFR,VP: PartNumber
+        OPFR,VS: SerialNumber
+        OPFR,VN: Manufacturer
+        OPFR,MB: BuildDate
+        OPFR,DR: Model
+    xyz.openbmc_project.Inventory.Item:
+        VINI,DR: PrettyName
+    xyz.openbmc_project.Inventory.Item.Bmc:
+ETHERNET:
+    xyz.openbmc_project.Inventory.Item.NetworkInterface:
+        OPFR,B1: MACAddress
+    xyz.openbmc_project.Inventory.Item.Ethernet: