NFSv4.1/flexfiles: Fix a protocol error in layoutreturn
[linux/fpc-iii.git] / arch / blackfin / include / asm / bfin_twi.h
blobaaa0834d34aa7ed768fb66d5d779c672225932a8
1 /*
2 * bfin_twi.h - interface to Blackfin TWIs
4 * Copyright 2005-2010 Analog Devices Inc.
6 * Licensed under the GPL-2 or later.
7 */
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)
32 #if !ANOMALY_16000030
33 DEFINE_TWI_REG(RCV_DATA8, rcv_data8)
34 DEFINE_TWI_REG(RCV_DATA16, rcv_data16)
35 #else
36 static inline u16 read_RCV_DATA8(struct bfin_twi_iface *iface)
38 u16 ret;
39 unsigned long flags;
41 flags = hard_local_irq_save();
42 ret = bfin_read16(&iface->regs_base->rcv_data8);
43 hard_local_irq_restore(flags);
45 return ret;
48 static inline u16 read_RCV_DATA16(struct bfin_twi_iface *iface)
50 u16 ret;
51 unsigned long flags;
53 flags = hard_local_irq_save();
54 ret = bfin_read16(&iface->regs_base->rcv_data16);
55 hard_local_irq_restore(flags);
57 return ret;
59 #endif
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);
69 SSYNC();
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)
79 SSYNC();
80 bfin_write16(&iface->regs_base->control, v);
82 #endif