On 30-Apr-2015, at 11:37, Vipin K Parashar vi...@linux.vnet.ibm.com wrote:
This patch adds support for FSP EPOW (Early Power Off Warning) and
DPO (Delayed Power Off) events support for PowerNV platform. EPOW events
are generated by SPCN/FSP due to various critical system conditions that
need system shutdown. Few examples of these conditions are high ambient
temperature or system running on UPS power with low UPS battery. DPO event
is generated in response to admin initiated system shutdown request.
This patch enables host kernel on PowerNV platform to handle OPAL
notifications for these events and initiate system poweroff. Since EPOW
notifications are sent in advance of impending shutdown event and thus this
patch also adds functionality to wait for EPOW condition to return to
normal. If EPOW condition doesn't return to normal in estimated time it
proceeds with graceful system shutdown. System admin can also add host
userspace scripts to perform any specific actions like graceful guest
shutdown upon system poweroff.
Signed-off-by: Vipin K Parashar vi...@linux.vnet.ibm.com
---
arch/powerpc/include/asm/opal-api.h| 30 ++
arch/powerpc/include/asm/opal.h| 3 +-
arch/powerpc/platforms/powernv/Makefile| 1 +
.../platforms/powernv/opal-poweroff-events.c | 358 +
arch/powerpc/platforms/powernv/opal-wrappers.S | 1 +
5 files changed, 392 insertions(+), 1 deletion(-)
create mode 100644 arch/powerpc/platforms/powernv/opal-poweroff-events.c
diff --git a/arch/powerpc/include/asm/opal-api.h
b/arch/powerpc/include/asm/opal-api.h
index 0321a90..03b3cef 100644
--- a/arch/powerpc/include/asm/opal-api.h
+++ b/arch/powerpc/include/asm/opal-api.h
@@ -730,6 +730,36 @@ struct opal_i2c_request {
__be64 buffer_ra;/* Buffer real address */
};
+/*
+ * EPOW status sharing (OPAL and the host)
+ *
+ * The host will pass on OPAL, a buffer of length OPAL_EPOW_MAX_CLASSES
+ * to fetch system wide EPOW status. Each element in the returned buffer
+ * will contain bitwise EPOW status for each EPOW sub class.
+ */
+
+/* EPOW types */
+enum OpalEpow {
+OPAL_EPOW_POWER = 0,/* Power EPOW */
+OPAL_EPOW_TEMP = 1,/* Temperature EPOW */
+OPAL_EPOW_COOLING = 2,/* Cooling EPOW */
+OPAL_MAX_EPOW_CLASSES = 3,/* Max EPOW categories */
+};
+
+/* Power EPOW events */
+enum OpalEpowPower {
+OPAL_EPOW_POWER_UPS = 0x1, /* System on UPS power */
+OPAL_EPOW_POWER_UPS_LOW = 0x2, /* System on UPS power with low battery*/
+};
+
+/* Temperature EPOW events */
+enum OpalEpowTemp {
+OPAL_EPOW_TEMP_HIGH_AMB = 0x1, /* High ambient temperature */
+OPAL_EPOW_TEMP_CRIT_AMB = 0x2, /* Critical ambient temperature */
+OPAL_EPOW_TEMP_HIGH_INT = 0x4, /* High internal temperature */
+OPAL_EPOW_TEMP_CRIT_INT = 0x8, /* Critical internal temperature */
+};
+
#endif /* __ASSEMBLY__ */
#endif /* __OPAL_API_H */
diff --git a/arch/powerpc/include/asm/opal.h b/arch/powerpc/include/asm/opal.h
index 042af1a..0777864 100644
--- a/arch/powerpc/include/asm/opal.h
+++ b/arch/powerpc/include/asm/opal.h
@@ -141,7 +141,6 @@ int64_t opal_pci_fence_phb(uint64_t phb_id);
int64_t opal_pci_reinit(uint64_t phb_id, uint64_t reinit_scope, uint64_t
data);
int64_t opal_pci_mask_pe_error(uint64_t phb_id, uint16_t pe_number, uint8_t
error_type, uint8_t mask_action);
int64_t opal_set_slot_led_status(uint64_t phb_id, uint64_t slot_id, uint8_t
led_type, uint8_t led_action);
-int64_t opal_get_epow_status(__be64 *status);
int64_t opal_set_system_attention_led(uint8_t led_action);
int64_t opal_pci_next_error(uint64_t phb_id, __be64 *first_frozen_pe,
__be16 *pci_error_type, __be16 *severity);
@@ -200,6 +199,8 @@ int64_t opal_flash_write(uint64_t id, uint64_t offset,
uint64_t buf,
uint64_t size, uint64_t token);
int64_t opal_flash_erase(uint64_t id, uint64_t offset, uint64_t size,
uint64_t token);
+int32_t opal_get_epow_status(__be32 *status, __be32 *num_classes);
+int32_t opal_get_dpo_status(__be32 *timeout);
/* Internal functions */
extern int early_init_dt_scan_opal(unsigned long node, const char *uname,
diff --git a/arch/powerpc/platforms/powernv/Makefile
b/arch/powerpc/platforms/powernv/Makefile
index 33e44f3..b817bdb 100644
--- a/arch/powerpc/platforms/powernv/Makefile
+++ b/arch/powerpc/platforms/powernv/Makefile
@@ -2,6 +2,7 @@ obj-y+= setup.o opal-wrappers.o opal.o
opal-async.o
obj-y+= opal-rtc.o opal-nvram.o opal-lpc.o opal-flash.o
obj-y+= rng.o opal-elog.o opal-dump.o opal-sysparam.o
opal-sensor.o
obj-y+= opal-msglog.o opal-hmi.o opal-power.o
+obj-y+= opal-poweroff-events.o
obj-$(CONFIG_SMP)+= smp.o subcore.o subcore-asm.o
obj-$(CONFIG_PCI)+= pci.o pci-p5ioc2.o pci-ioda.o
diff --git