meta-ampere: mtjade: support PSU present detection via GPIO
It checks GPIO key for powersupply presence, and creates
the inventory object.
Tested:
1. Plug the PSU, check busctl command for Present attribute
2. Plug out the PSU, check busctl command for Present attribute
$ busctl --no-pager introspect xyz.openbmc_project.Inventory.Manager
/xyz/openbmc_project/inventory/system/chassis/motherboard/powersupply0
Signed-off-by: Chanh Nguyen <chanh@os.amperecomputing.com>
Change-Id: I4520d537d425249debe5c0d8c6bf8b0f6e3c5b34
diff --git a/meta-ampere/meta-jade/conf/machine/mtjade.conf b/meta-ampere/meta-jade/conf/machine/mtjade.conf
index 1e41792..171a023 100644
--- a/meta-ampere/meta-jade/conf/machine/mtjade.conf
+++ b/meta-ampere/meta-jade/conf/machine/mtjade.conf
@@ -13,6 +13,8 @@
FLASH_ROFS_OFFSET = "10240"
FLASH_RWFS_OFFSET = "43008"
+OBMC_POWER_SUPPLY_INSTANCES = "0 1"
+
OBMC_MACHINE_FEATURES += "\
obmc-phosphor-chassis-mgmt \
obmc-phosphor-flash-mgmt \
diff --git a/meta-ampere/meta-jade/recipes-phosphor/gpio/phosphor-gpio-monitor/obmc/gpio/phosphor-power-supply-0.conf b/meta-ampere/meta-jade/recipes-phosphor/gpio/phosphor-gpio-monitor/obmc/gpio/phosphor-power-supply-0.conf
new file mode 100644
index 0000000..c5fc23a
--- /dev/null
+++ b/meta-ampere/meta-jade/recipes-phosphor/gpio/phosphor-gpio-monitor/obmc/gpio/phosphor-power-supply-0.conf
@@ -0,0 +1,6 @@
+INVENTORY=/system/chassis/motherboard/powersupply0
+DEVPATH=/dev/input/by-path/platform-gpio-keys-event
+KEY=64
+NAME=powersupply0
+DRIVERS=/sys/bus/i2c/drivers/pmbus,6-0058
+EXTRA_IFACES=xyz.openbmc_project.Inventory.Item.PowerSupply
diff --git a/meta-ampere/meta-jade/recipes-phosphor/gpio/phosphor-gpio-monitor/obmc/gpio/phosphor-power-supply-1.conf b/meta-ampere/meta-jade/recipes-phosphor/gpio/phosphor-gpio-monitor/obmc/gpio/phosphor-power-supply-1.conf
new file mode 100644
index 0000000..e591227
--- /dev/null
+++ b/meta-ampere/meta-jade/recipes-phosphor/gpio/phosphor-gpio-monitor/obmc/gpio/phosphor-power-supply-1.conf
@@ -0,0 +1,6 @@
+INVENTORY=/system/chassis/motherboard/powersupply1
+DEVPATH=/dev/input/by-path/platform-gpio-keys-event
+KEY=65
+NAME=powersupply1
+DRIVERS=/sys/bus/i2c/drivers/pmbus,6-0059
+EXTRA_IFACES=xyz.openbmc_project.Inventory.Item.PowerSupply
diff --git a/meta-ampere/meta-jade/recipes-phosphor/gpio/phosphor-gpio-monitor_%.bbappend b/meta-ampere/meta-jade/recipes-phosphor/gpio/phosphor-gpio-monitor_%.bbappend
new file mode 100644
index 0000000..0bff1c7
--- /dev/null
+++ b/meta-ampere/meta-jade/recipes-phosphor/gpio/phosphor-gpio-monitor_%.bbappend
@@ -0,0 +1,12 @@
+FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
+
+TMPL_POWERSUPPLY = "phosphor-gpio-presence@.service"
+INSTFMT_POWERSUPPLY = "phosphor-gpio-presence@{0}.service"
+POWERSUPPLY_TGT = "multi-user.target"
+FMT_POWERSUPPLY = "../${TMPL_POWERSUPPLY}:${POWERSUPPLY_TGT}.requires/${INSTFMT_POWERSUPPLY}"
+
+SYSTEMD_LINK_${PN}-presence_append_mtjade = " ${@compose_list(d, 'FMT_POWERSUPPLY', 'OBMC_POWER_SUPPLY_INSTANCES')}"
+
+POWERSUPPLY_ENV_FMT = "obmc/gpio/phosphor-power-supply-{0}.conf"
+
+SYSTEMD_ENVIRONMENT_FILE_${PN}-presence_append_mtjade = " ${@compose_list(d, 'POWERSUPPLY_ENV_FMT', 'OBMC_POWER_SUPPLY_INSTANCES')}"