systemd: Handle PSU delay globally

Instead of requiring each reset service to handle reset delays, handle
them here.

Change-Id: Ibe452bf37fd81e386cbaacd789f957d519dfedfe
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/gbmc-psu-hardreset-pre.target b/gbmc-psu-hardreset-pre.target
new file mode 100644
index 0000000..6eb0a26
--- /dev/null
+++ b/gbmc-psu-hardreset-pre.target
@@ -0,0 +1,4 @@
+[Unit]
+Description=Sys PSU Hard Reset
+Wants=gbmc-psu-hardreset-time.service
+After=gbmc-psu-hardreset-time.service
diff --git a/gbmc-psu-hardreset-time.service b/gbmc-psu-hardreset-time.service
new file mode 100644
index 0000000..9c98eec
--- /dev/null
+++ b/gbmc-psu-hardreset-time.service
@@ -0,0 +1,9 @@
+
+[Unit]
+Description=Power Cycle Delay
+
+[Service]
+Type=oneshot
+Environment=PSU_HARDRESET_DELAY=0
+EnvironmentFile=-/run/psu_timedelay
+ExecStart=/bin/sleep $PSU_HARDRESET_DELAY
diff --git a/gbmc-psu-hardreset.target b/gbmc-psu-hardreset.target
index 60f70a5..6501a3c 100644
--- a/gbmc-psu-hardreset.target
+++ b/gbmc-psu-hardreset.target
@@ -1,2 +1,4 @@
 [Unit]
 Description=Sys PSU Hard Reset
+Wants=gbmc-psu-hardreset-pre.target
+After=gbmc-psu-hardreset-pre.target
diff --git a/meson.build b/meson.build
index ee34798..d561fdc 100644
--- a/meson.build
+++ b/meson.build
@@ -70,5 +70,7 @@
   install_data(
     'gbmc-host-poweroff.target',
     'gbmc-psu-hardreset.target',
+    'gbmc-psu-hardreset-pre.target',
+    'gbmc-psu-hardreset-time.service',
     install_dir: systemd_dep.get_variable(pkgconfig: 'systemdsystemunitdir'))
 endif