2 * bfin_twi.h - interface to Blackfin TWIs
4 * Copyright 2005-2010 Analog Devices Inc.
6 * Licensed under the GPL-2 or later.
9 #ifndef __ASM_BFIN_TWI_H__
10 #define __ASM_BFIN_TWI_H__
12 #include <asm/blackfin.h>
14 #define DEFINE_TWI_REG(reg_name, reg) \
15 static inline u16 read_##reg_name(struct bfin_twi_iface *iface) \
16 { return bfin_read16(&iface->regs_base->reg); } \
17 static inline void write_##reg_name(struct bfin_twi_iface *iface, u16 v) \
18 { bfin_write16(&iface->regs_base->reg, v); }
20 DEFINE_TWI_REG(CLKDIV
, clkdiv
)
21 DEFINE_TWI_REG(SLAVE_CTL
, slave_ctl
)
22 DEFINE_TWI_REG(SLAVE_STAT
, slave_stat
)
23 DEFINE_TWI_REG(SLAVE_ADDR
, slave_addr
)
24 DEFINE_TWI_REG(MASTER_CTL
, master_ctl
)
25 DEFINE_TWI_REG(MASTER_STAT
, master_stat
)
26 DEFINE_TWI_REG(MASTER_ADDR
, master_addr
)
27 DEFINE_TWI_REG(INT_STAT
, int_stat
)
28 DEFINE_TWI_REG(INT_MASK
, int_mask
)
29 DEFINE_TWI_REG(FIFO_STAT
, fifo_stat
)
30 DEFINE_TWI_REG(XMT_DATA8
, xmt_data8
)
31 DEFINE_TWI_REG(XMT_DATA16
, xmt_data16
)
33 DEFINE_TWI_REG(RCV_DATA8
, rcv_data8
)
34 DEFINE_TWI_REG(RCV_DATA16
, rcv_data16
)
36 static inline u16
read_RCV_DATA8(struct bfin_twi_iface
*iface
)
41 flags
= hard_local_irq_save();
42 ret
= bfin_read16(&iface
->regs_base
->rcv_data8
);
43 hard_local_irq_restore(flags
);
48 static inline u16
read_RCV_DATA16(struct bfin_twi_iface
*iface
)
53 flags
= hard_local_irq_save();
54 ret
= bfin_read16(&iface
->regs_base
->rcv_data16
);
55 hard_local_irq_restore(flags
);
61 static inline u16
read_FIFO_CTL(struct bfin_twi_iface
*iface
)
63 return bfin_read16(&iface
->regs_base
->fifo_ctl
);
66 static inline void write_FIFO_CTL(struct bfin_twi_iface
*iface
, u16 v
)
68 bfin_write16(&iface
->regs_base
->fifo_ctl
, v
);
72 static inline u16
read_CONTROL(struct bfin_twi_iface
*iface
)
74 return bfin_read16(&iface
->regs_base
->control
);
77 static inline void write_CONTROL(struct bfin_twi_iface
*iface
, u16 v
)
80 bfin_write16(&iface
->regs_base
->control
, v
);