1 #ifndef __I2C_KEYWEST_H__
2 #define __I2C_KEYWEST_H__
4 /* The Tumbler audio equalizer can be really slow sometimes */
5 #define POLL_TIMEOUT (2*HZ)
21 #define KW_I2C_MODE_100KHZ 0x00
22 #define KW_I2C_MODE_50KHZ 0x01
23 #define KW_I2C_MODE_25KHZ 0x02
24 #define KW_I2C_MODE_DUMB 0x00
25 #define KW_I2C_MODE_STANDARD 0x04
26 #define KW_I2C_MODE_STANDARDSUB 0x08
27 #define KW_I2C_MODE_COMBINED 0x0C
28 #define KW_I2C_MODE_MODE_MASK 0x0C
29 #define KW_I2C_MODE_CHAN_MASK 0xF0
31 /* Control register */
32 #define KW_I2C_CTL_AAK 0x01
33 #define KW_I2C_CTL_XADDR 0x02
34 #define KW_I2C_CTL_STOP 0x04
35 #define KW_I2C_CTL_START 0x08
38 #define KW_I2C_STAT_BUSY 0x01
39 #define KW_I2C_STAT_LAST_AAK 0x02
40 #define KW_I2C_STAT_LAST_RW 0x04
41 #define KW_I2C_STAT_SDA 0x08
42 #define KW_I2C_STAT_SCL 0x10
44 /* IER & ISR registers */
45 #define KW_I2C_IRQ_DATA 0x01
46 #define KW_I2C_IRQ_ADDR 0x02
47 #define KW_I2C_IRQ_STOP 0x04
48 #define KW_I2C_IRQ_START 0x08
49 #define KW_I2C_IRQ_MASK 0x0F
51 /* Physical interface */
54 struct device_node *node;
59 struct keywest_chan *channels;
67 struct timer_list timeout_timer;
68 struct completion complete;
80 /* Channel on an interface */
83 struct i2c_adapter adapter;
84 struct keywest_iface* iface;
90 static inline u8 __read_reg(struct keywest_iface *iface, reg_t reg)
92 return in_8(iface->base
93 + (((unsigned)reg) << iface->bsteps));
96 static inline void __write_reg(struct keywest_iface *iface, reg_t reg, u8 val)
99 + (((unsigned)reg) << iface->bsteps), val);
100 (void)__read_reg(iface, reg_subaddr);
103 #define write_reg(reg, val) __write_reg(iface, reg, val)
104 #define read_reg(reg) __read_reg(iface, reg)
108 #endif /* __I2C_KEYWEST_H__ */