blob: c4602364e909dd059d71fb24268f7754a0a9a688 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Andres Salomon392a3252012-07-10 19:31:51 -07002#ifndef _LINUX_OLPC_EC_H
3#define _LINUX_OLPC_EC_H
4
Lubomir Rintel80975482019-05-13 09:56:36 +02005#include <linux/bits.h>
6
Andres Salomon392a3252012-07-10 19:31:51 -07007/* XO-1 EC commands */
8#define EC_FIRMWARE_REV 0x08
9#define EC_WRITE_SCI_MASK 0x1b
10#define EC_WAKE_UP_WLAN 0x24
11#define EC_WLAN_LEAVE_RESET 0x25
Jens Frederich98d4f932013-08-15 21:34:55 +020012#define EC_DCON_POWER_MODE 0x26
Andres Salomon392a3252012-07-10 19:31:51 -070013#define EC_READ_EB_MODE 0x2a
14#define EC_SET_SCI_INHIBIT 0x32
15#define EC_SET_SCI_INHIBIT_RELEASE 0x34
16#define EC_WLAN_ENTER_RESET 0x35
17#define EC_WRITE_EXT_SCI_MASK 0x38
18#define EC_SCI_QUERY 0x84
19#define EC_EXT_SCI_QUERY 0x85
20
Lubomir Rintelec9964b2019-05-13 09:56:34 +020021/* SCI source values */
Lubomir Rintel80975482019-05-13 09:56:36 +020022#define EC_SCI_SRC_GAME BIT(0)
23#define EC_SCI_SRC_BATTERY BIT(1)
24#define EC_SCI_SRC_BATSOC BIT(2)
25#define EC_SCI_SRC_BATERR BIT(3)
26#define EC_SCI_SRC_EBOOK BIT(4) /* XO-1 only */
27#define EC_SCI_SRC_WLAN BIT(5) /* XO-1 only */
28#define EC_SCI_SRC_ACPWR BIT(6)
29#define EC_SCI_SRC_BATCRIT BIT(7)
30#define EC_SCI_SRC_GPWAKE BIT(8) /* XO-1.5 only */
31#define EC_SCI_SRC_ALL GENMASK(8, 0)
Lubomir Rintelec9964b2019-05-13 09:56:34 +020032
Andres Salomonac250412012-07-13 05:57:17 -070033struct platform_device;
34
Andres Salomon3d26c202012-07-11 17:40:25 -070035struct olpc_ec_driver {
Andres Salomonac250412012-07-13 05:57:17 -070036 int (*suspend)(struct platform_device *);
37 int (*resume)(struct platform_device *);
38
Andres Salomon3d26c202012-07-11 17:40:25 -070039 int (*ec_cmd)(u8, u8 *, size_t, u8 *, size_t, void *);
Lubomir Rintelec9964b2019-05-13 09:56:34 +020040
41 bool wakeup_available;
Andres Salomon3d26c202012-07-11 17:40:25 -070042};
43
Lubomir Rintel0c3d9312019-05-13 09:56:37 +020044#ifdef CONFIG_OLPC_EC
Andres Salomon392a3252012-07-10 19:31:51 -070045
Andres Salomon3d26c202012-07-11 17:40:25 -070046extern void olpc_ec_driver_register(struct olpc_ec_driver *drv, void *arg);
47
Andres Salomon392a3252012-07-10 19:31:51 -070048extern int olpc_ec_cmd(u8 cmd, u8 *inbuf, size_t inlen, u8 *outbuf,
49 size_t outlen);
50
Lubomir Rintelec9964b2019-05-13 09:56:34 +020051extern void olpc_ec_wakeup_set(u16 value);
52extern void olpc_ec_wakeup_clear(u16 value);
53
54extern int olpc_ec_mask_write(u16 bits);
55extern int olpc_ec_sci_query(u16 *sci_value);
56
57extern bool olpc_ec_wakeup_available(void);
58
Andres Salomon392a3252012-07-10 19:31:51 -070059#else
60
61static inline int olpc_ec_cmd(u8 cmd, u8 *inbuf, size_t inlen, u8 *outbuf,
62 size_t outlen) { return -ENODEV; }
63
Lubomir Rintelec9964b2019-05-13 09:56:34 +020064static inline void olpc_ec_wakeup_set(u16 value) { }
65static inline void olpc_ec_wakeup_clear(u16 value) { }
66
67static inline bool olpc_ec_wakeup_available(void)
68{
69 return false;
70}
71
Lubomir Rintel0c3d9312019-05-13 09:56:37 +020072#endif /* CONFIG_OLPC_EC */
Andres Salomon392a3252012-07-10 19:31:51 -070073
74#endif /* _LINUX_OLPC_EC_H */