[PATCH] powerpc, powernv: Add OPAL platform event driver

Neelesh Gupta neelegup at linux.vnet.ibm.com
Tue Sep 30 15:23:29 EST 2014


On 09/29/2014 03:53 PM, Anshuman Khandual wrote:
> This patch creates a new OPAL platform event character driver
> which will give userspace clients the access to these events
> and process them effectively. Following platforms events are
> currently supported with this platform driver.
>
> 	(1) Environmental and Power Warning (EPOW)
> 	(2) Delayed Power Off (DPO)
>
> The user interface for this driver is /dev/opal_event character
> device file where the user space clients can poll and read for
> new opal platform events. The expected sequence of events driven
> from user space should be like the following.
>
> 	(1) Open the character device file
> 	(2) Poll on the file for POLLIN event
> 	(3) When unblocked, must attempt to read PLAT_EVENT_MAX_SIZE size
> 	(4) Kernel driver will pass at most one opal_plat_event structure
> 	(5) Poll again for more new events
>
> The driver registers for OPAL messages notifications corresponding to
> individual OPAL events. When any of those event messages arrive in the
> kernel, the callbacks are called to process them which in turn unblocks
> the polling thread on the character device file. The driver also registers
> a timer function which will be called after a threshold amount of time to
> shutdown the system. The user space client receives the timeout value for
> all individual OPAL platform events and hence must prepare the system and
> eventually shutdown. In case the user client does not shutdown the system,
> the timer function will be called after the threshold and shutdown the
> system explicitly.
>
> Signed-off-by: Anshuman Khandual <khandual at linux.vnet.ibm.com>

Reviewed-by: Neelesh Gupta <neelegup at linux.vnet.ibm.com>

- Neelesh

> ---
>   arch/powerpc/include/asm/opal.h                    |  45 +-
>   .../include/uapi/asm/opal_platform_events.h        |  90 +++
>   arch/powerpc/platforms/powernv/Makefile            |   2 +-
>   .../platforms/powernv/opal-platform-events.c       | 737 +++++++++++++++++++++
>   arch/powerpc/platforms/powernv/opal-wrappers.S     |   1 +
>   arch/powerpc/platforms/powernv/opal.c              |   8 +-
>   6 files changed, 880 insertions(+), 3 deletions(-)
>   create mode 100644 arch/powerpc/include/uapi/asm/opal_platform_events.h
>   create mode 100644 arch/powerpc/platforms/powernv/opal-platform-events.c
>
> diff --git a/arch/powerpc/include/asm/opal.h b/arch/powerpc/include/asm/opal.h
> index 86055e5..c134137 100644
> --- a/arch/powerpc/include/asm/opal.h
> +++ b/arch/powerpc/include/asm/opal.h
> @@ -151,6 +151,7 @@ struct opal_sg_list {
>   #define OPAL_HANDLE_HMI				98
>   #define OPAL_REGISTER_DUMP_REGION		101
>   #define OPAL_UNREGISTER_DUMP_REGION		102
> +#define OPAL_GET_DPO_STATUS			105
>   
>   #ifndef __ASSEMBLY__
>   
> @@ -249,6 +250,7 @@ enum OpalMessageType {
>   	OPAL_MSG_EPOW,
>   	OPAL_MSG_SHUTDOWN,
>   	OPAL_MSG_HMI_EVT,
> +	OPAL_MSG_DPO,
>   	OPAL_MSG_TYPE_MAX,
>   };
>   
> @@ -417,6 +419,46 @@ struct opal_msg {
>   	__be64 params[8];
>   };
>   
> +/*
> + * EPOW status sharing (OPAL and the host)
> + *
> + * The host will pass on OPAL, a buffer of length OPAL_SYSEPOW_MAX
> + * with individual elements being 16 bits wide to fetch the system
> + * wide EPOW status. Each element in the buffer will contain the
> + * EPOW status in it's bit representation for a particular EPOW sub
> + * class as defiend here. So multiple detailed EPOW status bits
> + * specific for any sub class can be represented in a single buffer
> + * element as it's bit representation.
> + */
> +
> +/* System EPOW type */
> +enum OpalSysEpow {
> +	OPAL_SYSEPOW_POWER	= 0,	/* Power EPOW */
> +	OPAL_SYSEPOW_TEMP	= 1,	/* Temperature EPOW */
> +	OPAL_SYSEPOW_COOLING	= 2,	/* Cooling EPOW */
> +	OPAL_SYSEPOW_MAX	= 3,	/* Max EPOW categories */
> +};
> +
> +/* Power EPOW */
> +enum OpalSysPower {
> +	OPAL_SYSPOWER_UPS	= 0x0001, /* System on UPS power */
> +	OPAL_SYSPOWER_CHNG	= 0x0002, /* System power config change */
> +	OPAL_SYSPOWER_FAIL	= 0x0004, /* System impending power failure */
> +	OPAL_SYSPOWER_INCL	= 0x0008, /* System incomplete power */
> +};
> +



More information about the Linuxppc-dev mailing list