]> Pileus Git - ~andy/linux/blob - drivers/staging/nvec/nvec.h
Merge git://git.infradead.org/battery-2.6
[~andy/linux] / drivers / staging / nvec / nvec.h
1 #ifndef __LINUX_MFD_NVEC
2 #define __LINUX_MFD_NVEC
3
4 #include <linux/semaphore.h>
5
6 typedef enum {
7         NVEC_2BYTES,
8         NVEC_3BYTES,
9         NVEC_VAR_SIZE
10 } nvec_size;
11
12 typedef enum {
13         NOT_REALLY,
14         YES,
15         NOT_AT_ALL,
16 } how_care;
17
18 typedef enum {
19         NVEC_SYS=1,
20         NVEC_BAT,
21         NVEC_KBD = 5,
22         NVEC_PS2,
23         NVEC_CNTL,
24         NVEC_KB_EVT = 0x80,
25         NVEC_PS2_EVT
26 } nvec_event;
27
28 typedef enum {
29        NVEC_WAIT,
30        NVEC_READ,
31        NVEC_WRITE
32 } nvec_state;
33
34 struct nvec_msg {
35         unsigned char *data;
36         unsigned short size;
37         unsigned short pos;
38         struct list_head node;
39 };
40
41 struct nvec_subdev {
42         const char *name;
43         void *platform_data;
44         int id;
45 };
46
47 struct nvec_platform_data {
48         int num_subdevs;
49         int i2c_addr;
50         int gpio;
51         int irq;
52         int base;
53         int size;
54         char clock[16];
55         struct nvec_subdev *subdevs;
56 };
57
58 struct nvec_chip {
59         struct device *dev;
60         int gpio;
61         int irq;
62         unsigned char *i2c_regs;
63         nvec_state state;
64         struct atomic_notifier_head notifier_list;
65         struct list_head rx_data, tx_data;
66         struct notifier_block nvec_status_notifier;
67         struct work_struct rx_work, tx_work;
68         struct nvec_msg *rx, *tx;
69
70 /* sync write stuff */
71         struct semaphore sync_write_mutex;
72         struct completion sync_write;
73         u16 sync_write_pending;
74         struct nvec_msg *last_sync_msg;
75 };
76
77 extern void nvec_write_async(struct nvec_chip *nvec, unsigned char *data, short size);
78
79 extern int nvec_register_notifier(struct nvec_chip *nvec,
80                  struct notifier_block *nb, unsigned int events);
81
82 extern int nvec_unregister_notifier(struct device *dev,
83                 struct notifier_block *nb, unsigned int events);
84
85 const char *nvec_send_msg(unsigned char *src, unsigned char *dst_size, how_care care_resp, void (*rt_handler)(unsigned char *data));
86
87 extern int nvec_ps2(struct nvec_chip *nvec);
88 extern int nvec_kbd_init(struct nvec_chip *nvec);
89
90 #define I2C_CNFG                        0x00
91 #define I2C_CNFG_PACKET_MODE_EN         (1<<10)
92 #define I2C_CNFG_NEW_MASTER_SFM         (1<<11)
93 #define I2C_CNFG_DEBOUNCE_CNT_SHIFT     12
94
95 #define I2C_SL_CNFG             0x20
96 #define I2C_SL_NEWL             (1<<2)
97 #define I2C_SL_NACK             (1<<1)
98 #define I2C_SL_RESP             (1<<0)
99 #define I2C_SL_IRQ              (1<<3)
100 #define END_TRANS               (1<<4)
101 #define RCVD                    (1<<2)
102 #define RNW                     (1<<1)
103
104 #define I2C_SL_RCVD             0x24
105 #define I2C_SL_STATUS           0x28
106 #define I2C_SL_ADDR1            0x2c
107 #define I2C_SL_ADDR2            0x30
108 #define I2C_SL_DELAY_COUNT      0x3c
109
110 #endif