Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef _LINUX_OLPC_EC_H
0003 #define _LINUX_OLPC_EC_H
0004 
0005 #include <linux/bits.h>
0006 
0007 /* XO-1 EC commands */
0008 #define EC_FIRMWARE_REV         0x08
0009 #define EC_WRITE_SCI_MASK       0x1b
0010 #define EC_WAKE_UP_WLAN         0x24
0011 #define EC_WLAN_LEAVE_RESET     0x25
0012 #define EC_DCON_POWER_MODE      0x26
0013 #define EC_READ_EB_MODE         0x2a
0014 #define EC_SET_SCI_INHIBIT      0x32
0015 #define EC_SET_SCI_INHIBIT_RELEASE  0x34
0016 #define EC_WLAN_ENTER_RESET     0x35
0017 #define EC_WRITE_EXT_SCI_MASK       0x38
0018 #define EC_SCI_QUERY            0x84
0019 #define EC_EXT_SCI_QUERY        0x85
0020 
0021 /* SCI source values */
0022 #define EC_SCI_SRC_GAME         BIT(0)
0023 #define EC_SCI_SRC_BATTERY      BIT(1)
0024 #define EC_SCI_SRC_BATSOC       BIT(2)
0025 #define EC_SCI_SRC_BATERR       BIT(3)
0026 #define EC_SCI_SRC_EBOOK        BIT(4)    /* XO-1 only */
0027 #define EC_SCI_SRC_WLAN         BIT(5)    /* XO-1 only */
0028 #define EC_SCI_SRC_ACPWR        BIT(6)
0029 #define EC_SCI_SRC_BATCRIT      BIT(7)
0030 #define EC_SCI_SRC_GPWAKE       BIT(8)   /* XO-1.5 only */
0031 #define EC_SCI_SRC_ALL          GENMASK(8, 0)
0032 
0033 struct platform_device;
0034 
0035 struct olpc_ec_driver {
0036     int (*suspend)(struct platform_device *);
0037     int (*resume)(struct platform_device *);
0038 
0039     int (*ec_cmd)(u8, u8 *, size_t, u8 *, size_t, void *);
0040 
0041     bool wakeup_available;
0042 };
0043 
0044 #ifdef CONFIG_OLPC_EC
0045 
0046 extern void olpc_ec_driver_register(struct olpc_ec_driver *drv, void *arg);
0047 
0048 extern int olpc_ec_cmd(u8 cmd, u8 *inbuf, size_t inlen, u8 *outbuf,
0049         size_t outlen);
0050 
0051 extern void olpc_ec_wakeup_set(u16 value);
0052 extern void olpc_ec_wakeup_clear(u16 value);
0053 
0054 extern int olpc_ec_mask_write(u16 bits);
0055 extern int olpc_ec_sci_query(u16 *sci_value);
0056 
0057 extern bool olpc_ec_wakeup_available(void);
0058 
0059 #else
0060 
0061 static inline int olpc_ec_cmd(u8 cmd, u8 *inbuf, size_t inlen, u8 *outbuf,
0062         size_t outlen) { return -ENODEV; }
0063 
0064 static inline void olpc_ec_wakeup_set(u16 value) { }
0065 static inline void olpc_ec_wakeup_clear(u16 value) { }
0066 
0067 static inline bool olpc_ec_wakeup_available(void)
0068 {
0069     return false;
0070 }
0071 
0072 #endif /* CONFIG_OLPC_EC */
0073 
0074 #endif /* _LINUX_OLPC_EC_H */