156 DBG2 (
"[send %02x]",
byte );
157 for ( i = 8 ; i ; i-- ) {
164 DBG2 (
"%s", ( ack ?
"[acked]" :
"[not acked]" ) );
166 return ( ack ? 0 : -
EIO );
182 for ( i = 8 ; i ; i-- ) {
190 DBG2 (
"[rcvd %02x]",
byte );
219 shift >= 0 ; shift -= 8 ) {
220 byte = ( (
address >> shift ) & 0xff );
257 DBGC ( basher,
"I2CBIT %p reset after %d attempts\n",
265 DBGC ( basher,
"I2CBIT %p could not reset after %d attempts\n",
292 DBGC ( basher,
"I2CBIT %p reading from device %x: ",
322 DBGC ( basher,
"%s\n", (
rc ?
"failed" :
"" ) );
349 DBGC ( basher,
"I2CBIT %p writing to device %x: ",
375 DBGC ( basher,
"%s\n", (
rc ?
"failed" :
"" ) );
393 basher->
op = bash_op;
401 DBGC ( basher,
"I2CBIT %p could not reset I2C bus: %s\n",
struct arbelprm_rc_send_wqe rc
static void i2c_delay(void)
Delay between output state changes.
static unsigned int unsigned int bit
static void open_bit(struct bit_basher *basher)
Open bit-bashing interface.
int(* write)(struct i2c_interface *i2c, struct i2c_device *i2cdev, unsigned int offset, const uint8_t *data, unsigned int len)
Write data to I2C device.
static int i2c_reset(struct bit_basher *basher)
Reset I2C bus.
static int i2c_select(struct bit_basher *basher, struct i2c_device *i2cdev, unsigned int offset, unsigned int direction)
Select I2C device for reading or writing.
uint64_t address
Base address.
static void i2c_send_bit(struct bit_basher *basher, int bit)
Send an I2C data bit.
A bit-bashing I2C interface.
uint8_t direction
Direction.
unsigned int dev_addr
Address of this device.
static int i2c_recv_bit(struct bit_basher *basher)
Receive an I2C data bit.
struct bit_basher_operations * op
Bit-bashing operations.
#define I2C_RESET_MAX_CYCLES
Maximum number of cycles to use when attempting a bus reset.
static int i2c_send_byte(struct bit_basher *basher, uint8_t byte)
Send byte via I2C bus and check for acknowledgement.
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
#define container_of(ptr, type, field)
Get containing structure.
struct i2c_interface i2c
I2C interface.
static int i2c_bit_write(struct i2c_interface *i2c, struct i2c_device *i2cdev, unsigned int offset, const uint8_t *data, unsigned int len)
Write data to I2C device via bit-bashing interface.
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
static void setscl(struct bit_basher *basher, int state)
Set state of I2C SCL line.
struct bit_basher basher
Bit-bashing interface.
int(* read)(struct bit_basher *basher, unsigned int bit_id)
Read input bit.
char * strerror(int errno)
Retrieve string representation of error number.
static void i2c_stop(struct bit_basher *basher)
Send an I2C stop condition.
int(* read)(struct i2c_interface *i2c, struct i2c_device *i2cdev, unsigned int offset, uint8_t *data, unsigned int len)
Read data from I2C device.
unsigned int word_addr_len
Word adddress length, in bytes.
int read_bit(struct bit_basher *basher, unsigned int bit_id)
Read input bit.
#define I2C_WRITE
An I2C write command.
static uint8_t i2c_recv_byte(struct bit_basher *basher)
Receive byte via I2C bus.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
void(* write)(struct bit_basher *basher, unsigned int bit_id, unsigned long data)
Set/clear output bit.
#define I2C_READ
An I2C read command.
#define EIO
Input/output error.
uint8_t data[48]
Additional event data.
#define I2C_UDELAY
Delay required for bit-bashing operation.
static void i2c_start(struct bit_basher *basher)
Send an I2C start condition.
static void close_bit(struct bit_basher *basher)
Close bit-bashing interface.
static int getsda(struct bit_basher *basher)
Get state of I2C SDA line.
uint16_t offset
Offset to command line.
unsigned int dev_addr_len
Device address length, in bytes.
int init_i2c_bit_basher(struct i2c_bit_basher *i2cbit, struct bit_basher_operations *bash_op)
Initialise I2C bit-bashing interface.
#define NULL
NULL pointer (VOID *)
#define ETIMEDOUT
Connection timed out.
static int i2c_bit_read(struct i2c_interface *i2c, struct i2c_device *i2cdev, unsigned int offset, uint8_t *data, unsigned int len)
Read data from I2C device via bit-bashing interface.
static void setsda(struct bit_basher *basher, int state)
Set state of I2C SDA line.
void write_bit(struct bit_basher *basher, unsigned int bit_id, unsigned long data)
Set/clear output bit.