Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
392a325c AS |
2 | #ifndef _LINUX_OLPC_EC_H |
3 | #define _LINUX_OLPC_EC_H | |
4 | ||
8097548f LR |
5 | #include <linux/bits.h> |
6 | ||
392a325c AS |
7 | /* 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 | |
98d4f93c | 12 | #define EC_DCON_POWER_MODE 0x26 |
392a325c AS |
13 | #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 | ||
ec9964b4 | 21 | /* SCI source values */ |
8097548f LR |
22 | #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) | |
ec9964b4 | 32 | |
ac250415 AS |
33 | struct platform_device; |
34 | ||
3d26c20b | 35 | struct olpc_ec_driver { |
ac250415 AS |
36 | int (*suspend)(struct platform_device *); |
37 | int (*resume)(struct platform_device *); | |
38 | ||
3d26c20b | 39 | int (*ec_cmd)(u8, u8 *, size_t, u8 *, size_t, void *); |
ec9964b4 LR |
40 | |
41 | bool wakeup_available; | |
3d26c20b AS |
42 | }; |
43 | ||
392a325c AS |
44 | #ifdef CONFIG_OLPC |
45 | ||
3d26c20b AS |
46 | extern void olpc_ec_driver_register(struct olpc_ec_driver *drv, void *arg); |
47 | ||
392a325c AS |
48 | extern int olpc_ec_cmd(u8 cmd, u8 *inbuf, size_t inlen, u8 *outbuf, |
49 | size_t outlen); | |
50 | ||
ec9964b4 LR |
51 | extern void olpc_ec_wakeup_set(u16 value); |
52 | extern void olpc_ec_wakeup_clear(u16 value); | |
53 | ||
54 | extern int olpc_ec_mask_write(u16 bits); | |
55 | extern int olpc_ec_sci_query(u16 *sci_value); | |
56 | ||
57 | extern bool olpc_ec_wakeup_available(void); | |
58 | ||
392a325c AS |
59 | #else |
60 | ||
61 | static inline int olpc_ec_cmd(u8 cmd, u8 *inbuf, size_t inlen, u8 *outbuf, | |
62 | size_t outlen) { return -ENODEV; } | |
63 | ||
ec9964b4 LR |
64 | static inline void olpc_ec_wakeup_set(u16 value) { } |
65 | static inline void olpc_ec_wakeup_clear(u16 value) { } | |
66 | ||
67 | static inline bool olpc_ec_wakeup_available(void) | |
68 | { | |
69 | return false; | |
70 | } | |
71 | ||
392a325c AS |
72 | #endif /* CONFIG_OLPC */ |
73 | ||
74 | #endif /* _LINUX_OLPC_EC_H */ |