linux/include/linux/olpc-ec.h

/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _LINUX_OLPC_EC_H
#define _LINUX_OLPC_EC_H

#include <linux/bits.h>

/* XO-1 EC commands */
#define EC_FIRMWARE_REV
#define EC_WRITE_SCI_MASK
#define EC_WAKE_UP_WLAN
#define EC_WLAN_LEAVE_RESET
#define EC_DCON_POWER_MODE
#define EC_READ_EB_MODE
#define EC_SET_SCI_INHIBIT
#define EC_SET_SCI_INHIBIT_RELEASE
#define EC_WLAN_ENTER_RESET
#define EC_WRITE_EXT_SCI_MASK
#define EC_SCI_QUERY
#define EC_EXT_SCI_QUERY

/* SCI source values */
#define EC_SCI_SRC_GAME
#define EC_SCI_SRC_BATTERY
#define EC_SCI_SRC_BATSOC
#define EC_SCI_SRC_BATERR
#define EC_SCI_SRC_EBOOK
#define EC_SCI_SRC_WLAN
#define EC_SCI_SRC_ACPWR
#define EC_SCI_SRC_BATCRIT
#define EC_SCI_SRC_GPWAKE
#define EC_SCI_SRC_ALL

struct platform_device;

struct olpc_ec_driver {};

#ifdef CONFIG_OLPC_EC

extern void olpc_ec_driver_register(struct olpc_ec_driver *drv, void *arg);

extern int olpc_ec_cmd(u8 cmd, u8 *inbuf, size_t inlen, u8 *outbuf,
		size_t outlen);

extern void olpc_ec_wakeup_set(u16 value);
extern void olpc_ec_wakeup_clear(u16 value);

extern int olpc_ec_mask_write(u16 bits);
extern int olpc_ec_sci_query(u16 *sci_value);

extern bool olpc_ec_wakeup_available(void);

asmlinkage int xo1_do_sleep(u8 sleep_state);

#else

static inline int olpc_ec_cmd(u8 cmd, u8 *inbuf, size_t inlen, u8 *outbuf,
		size_t outlen) { return -ENODEV; }

static inline void olpc_ec_wakeup_set(u16 value) { }
static inline void olpc_ec_wakeup_clear(u16 value) { }

static inline bool olpc_ec_wakeup_available(void)
{
	return false;
}

#endif /* CONFIG_OLPC_EC */

#endif /* _LINUX_OLPC_EC_H */