meta-nicole: Initial version

NICOLE is a new storage controller for TATLIN server.
It based on IBM Romulus reference design (POWER9)
and uses an AST2500 BMC SoC.

(From meta-yadro rev: 13af90da095c5eb6874ce6f89a8b66a7932e6c50)

Change-Id: I4685be88448e1de8a1a716ad3f59ef09e168a1df
Signed-off-by: Alexander Soldatov <a.soldatov@yadro.com>
Signed-off-by: Alexander Filippov <a.filippov@yadro.com>
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/meta-yadro/meta-nicole/recipes-phosphor/chassis/avsbus-control.bb b/meta-yadro/meta-nicole/recipes-phosphor/chassis/avsbus-control.bb
new file mode 100644
index 0000000..854795b
--- /dev/null
+++ b/meta-yadro/meta-nicole/recipes-phosphor/chassis/avsbus-control.bb
@@ -0,0 +1,25 @@
+SUMMARY = "Nicole AVSBus control"
+PR = "r1"
+LICENSE = "Apache-2.0"
+LIC_FILES_CHKSUM = "file://${YADROBASE}/COPYING.apache-2.0;md5=34400b68072d710fecd0a2940a0d1658"
+
+inherit obmc-phosphor-systemd
+
+RDEPENDS_${PN} += "i2c-tools"
+
+S = "${WORKDIR}"
+SRC_URI += "file://avsbus-control.sh"
+
+do_install() {
+        install -d ${D}${bindir}
+        install -m 0755 ${WORKDIR}/avsbus-control.sh \
+            ${D}${bindir}/avsbus-control.sh
+}
+
+TMPL= "avsbus-control@.service"
+INSTFMT= "avsbus-control@{0}.service"
+TGTFMT = "obmc-chassis-poweron@{0}.target"
+FMT = "../${TMPL}:${TGTFMT}.requires/${INSTFMT}"
+
+SYSTEMD_SERVICE_${PN} += "${TMPL}"
+SYSTEMD_LINK_${PN} += "${@compose_list(d, 'FMT', 'OBMC_CHASSIS_INSTANCES')}"
diff --git a/meta-yadro/meta-nicole/recipes-phosphor/chassis/avsbus-control/avsbus-control.sh b/meta-yadro/meta-nicole/recipes-phosphor/chassis/avsbus-control/avsbus-control.sh
new file mode 100755
index 0000000..0330b22
--- /dev/null
+++ b/meta-yadro/meta-nicole/recipes-phosphor/chassis/avsbus-control/avsbus-control.sh
@@ -0,0 +1,31 @@
+#!/bin/sh -eu
+
+function override_avs_settings()
+{
+    BUS=$1
+
+    i2cset -y ${BUS} 0x44 0x00 0x00 b    # VCS
+    i2cset -y ${BUS} 0x44 0x24 0x044C w  # VOUT_MAX 1100mV
+    i2cset -y ${BUS} 0x44 0x40 0x0456 w  # VOUT_OV_FAULT_LIMIT 1110mV
+    i2cset -y ${BUS} 0x44 0x25 0x0438 w  # VOUT_MARGING_HIGH 1080mV
+    i2cset -y ${BUS} 0x44 0x26 0x03D4 w  # VOUT_MARGING_LOW 980mV
+    i2cset -y ${BUS} 0x44 0x44 0x024E w  # VOUT_UV_FAULT_LIMIT 590mV
+    i2cset -y ${BUS} 0x44 0x2B 0x0258 w  # VOUT_MIN 600mV
+
+    i2cset -y ${BUS} 0x44 0x00 0x01 b    # VDD
+    i2cset -y ${BUS} 0x44 0x24 0x044C w  # VOUT_MAX 1100mV
+    i2cset -y ${BUS} 0x44 0x40 0x0456 w  # VOUT_OV_FAULT_LIMIT 1110mV
+    i2cset -y ${BUS} 0x44 0x25 0x041A w  # VOUT_MARGING_HIGH 1050mV
+    i2cset -y ${BUS} 0x44 0x26 0x03B6 w  # VOUT_MARGING_LOW 950mV
+    i2cset -y ${BUS} 0x44 0x44 0x024E w  # VOUT_UV_FAULT_LIMIT 590mV
+    i2cset -y ${BUS} 0x44 0x2B 0x0258 w  # VOUT_MIN 600mV
+
+    i2cset -y ${BUS} 0x44 0x00 0xFF b   # All pages (VCS & VDD)
+    i2cset -y ${BUS} 0x44 0x01 0xB0 b   # Enable
+
+    i2cset -y ${BUS} 0x46 0x00 0x01 b    # VDN
+    i2cset -y ${BUS} 0x46 0x01 0xB0 b    # Enable
+}
+
+override_avs_settings 4
+override_avs_settings 5
diff --git a/meta-yadro/meta-nicole/recipes-phosphor/chassis/avsbus-control/avsbus-control@.service b/meta-yadro/meta-nicole/recipes-phosphor/chassis/avsbus-control/avsbus-control@.service
new file mode 100644
index 0000000..247c506
--- /dev/null
+++ b/meta-yadro/meta-nicole/recipes-phosphor/chassis/avsbus-control/avsbus-control@.service
@@ -0,0 +1,20 @@
+[Unit]
+Description=Enable the AVS bus on VRMs
+Wants=obmc-host-start-pre@%i.target
+Before=obmc-host-start-pre@%i.target
+Wants=obmc-power-on@%i.target
+After=obmc-power-on@%i.target
+Wants=fsi-scan@%i.service
+After=fsi-scan@%i.service
+Conflicts=obmc-chassis-poweroff@%i.target
+ConditionPathExists=!/run/openbmc/chassis@%i-on
+
+[Service]
+ExecStart=/usr/bin/avsbus-control.sh
+SyslogIdentifier=avsbus-control.sh
+Type=oneshot
+RemainAfterExit=yes
+
+[Install]
+WantedBy=obmc-chassis-poweron@%i.target
+
diff --git a/meta-yadro/meta-nicole/recipes-phosphor/console/obmc-console/obmc-console.conf b/meta-yadro/meta-nicole/recipes-phosphor/console/obmc-console/obmc-console.conf
new file mode 100644
index 0000000..a5ba3f3
--- /dev/null
+++ b/meta-yadro/meta-nicole/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-yadro/meta-nicole/recipes-phosphor/console/obmc-console_%.bbappend b/meta-yadro/meta-nicole/recipes-phosphor/console/obmc-console_%.bbappend
new file mode 100644
index 0000000..72d991c
--- /dev/null
+++ b/meta-yadro/meta-nicole/recipes-phosphor/console/obmc-console_%.bbappend
@@ -0,0 +1 @@
+FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
diff --git a/meta-yadro/meta-nicole/recipes-phosphor/host/p9-host-start.bbappend b/meta-yadro/meta-nicole/recipes-phosphor/host/p9-host-start.bbappend
new file mode 100644
index 0000000..83ef545
--- /dev/null
+++ b/meta-yadro/meta-nicole/recipes-phosphor/host/p9-host-start.bbappend
@@ -0,0 +1,2 @@
+RDEPENDS_${PN}_append = " avsbus-control"
+RDEPENDS_${PN}_remove = " p9-vcs-workaround"
diff --git a/meta-yadro/meta-nicole/recipes-phosphor/images/obmc-phosphor-image.bbappend b/meta-yadro/meta-nicole/recipes-phosphor/images/obmc-phosphor-image.bbappend
new file mode 100644
index 0000000..aa57bbf
--- /dev/null
+++ b/meta-yadro/meta-nicole/recipes-phosphor/images/obmc-phosphor-image.bbappend
@@ -0,0 +1 @@
+OBMC_IMAGE_EXTRA_INSTALL_append = " mboxd"
diff --git a/meta-yadro/meta-nicole/recipes-phosphor/mboxd/mboxd_%.bbappend b/meta-yadro/meta-nicole/recipes-phosphor/mboxd/mboxd_%.bbappend
new file mode 100644
index 0000000..8b6248a
--- /dev/null
+++ b/meta-yadro/meta-nicole/recipes-phosphor/mboxd/mboxd_%.bbappend
@@ -0,0 +1 @@
+MBOXD_FLASH_SIZE = "64M"
diff --git a/meta-yadro/meta-nicole/recipes-phosphor/skeleton/obmc-libobmc-intf/gpio_defs.json b/meta-yadro/meta-nicole/recipes-phosphor/skeleton/obmc-libobmc-intf/gpio_defs.json
new file mode 100644
index 0000000..146b9af
--- /dev/null
+++ b/meta-yadro/meta-nicole/recipes-phosphor/skeleton/obmc-libobmc-intf/gpio_defs.json
@@ -0,0 +1,72 @@
+{
+    "gpio_configs": {
+
+        "power_config": {
+            "power_good_in": "SYS_PWROK_BUFF",
+            "power_up_outs": [
+                { "name": "SOFTWARE_PGOOD", "polarity": true},
+                { "name": "BMC_POWER_UP", "polarity": true}
+            ],
+            "reset_outs": [
+            ]
+        }
+    },
+
+    "gpio_definitions": [
+        {
+            "name": "SOFTWARE_PGOOD",
+            "pin": "R1",
+            "direction": "out"
+        },
+        {
+            "name": "BMC_POWER_UP",
+            "pin": "D1",
+            "direction": "out"
+        },
+        {
+            "name": "SYS_PWROK_BUFF",
+            "pin": "D2",
+            "direction": "in"
+        },
+        {
+            "name": "BMC_WD_CLEAR_PULSE_N",
+            "pin": "N5",
+            "direction": "falling"
+        },
+        {
+            "name": "CHECKSTOP",
+            "pin": "J2",
+            "direction": "falling"
+        },
+        {
+            "name": "BMC_CP0_RESET_N",
+            "pin": "A1",
+            "direction": "out"
+        },
+        {
+            "name": "BMC_CP0_PERST_ENABLE_R",
+            "pin": "A3",
+            "direction": "out"
+        },
+        {
+            "name": "BMC_THROTTLE",
+            "pin": "J3",
+            "direction": "out"
+        },
+        {
+            "name": "IDBTN",
+            "pin": "Q7",
+            "direction": "out"
+        },
+        {
+            "name": "POWER_BUTTON",
+            "pin": "I3",
+            "direction": "both"
+        },
+        {
+            "name": "RESET_BUTTON",
+            "pin": "J1",
+            "direction": "both"
+        }
+    ]
+}
diff --git a/meta-yadro/meta-nicole/recipes-phosphor/skeleton/obmc-libobmc-intf_%.bbappend b/meta-yadro/meta-nicole/recipes-phosphor/skeleton/obmc-libobmc-intf_%.bbappend
new file mode 100644
index 0000000..72d991c
--- /dev/null
+++ b/meta-yadro/meta-nicole/recipes-phosphor/skeleton/obmc-libobmc-intf_%.bbappend
@@ -0,0 +1 @@
+FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"