1 /****************************************************************************
2 * Driver for Solarflare Solarstorm network controllers and boards
3 * Copyright 2005 Fen Systems Ltd.
4 * Copyright 2006 Solarflare Communications Inc.
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation, incorporated herein by reference.
11 #ifndef EFX_I2C_DIRECT_H
12 #define EFX_I2C_DIRECT_H
14 #include "net_driver.h"
17 * Direct control of an I2C bus
20 struct efx_i2c_interface
;
23 * struct efx_i2c_bit_operations - I2C bus direct control methods
25 * I2C bus direct control methods.
27 * @setsda: Set state of SDA line
28 * @setscl: Set state of SCL line
29 * @getsda: Get state of SDA line
30 * @getscl: Get state of SCL line
31 * @udelay: Delay between each bit operation
32 * @mdelay: Delay between each byte write
34 struct efx_i2c_bit_operations
{
35 void (*setsda
) (struct efx_i2c_interface
*i2c
);
36 void (*setscl
) (struct efx_i2c_interface
*i2c
);
37 int (*getsda
) (struct efx_i2c_interface
*i2c
);
38 int (*getscl
) (struct efx_i2c_interface
*i2c
);
44 * struct efx_i2c_interface - an I2C interface
48 * @efx: Attached Efx NIC
49 * @op: I2C bus control methods
50 * @sda: Current output state of SDA line
51 * @scl: Current output state of SCL line
53 struct efx_i2c_interface
{
55 struct efx_i2c_bit_operations
*op
;
60 extern int efx_i2c_check_presence(struct efx_i2c_interface
*i2c
, u8 device_id
);
61 extern int efx_i2c_fast_read(struct efx_i2c_interface
*i2c
,
62 u8 device_id
, u8 offset
,
63 u8
*data
, unsigned int len
);
64 extern int efx_i2c_fast_write(struct efx_i2c_interface
*i2c
,
65 u8 device_id
, u8 offset
,
66 const u8
*data
, unsigned int len
);
67 extern int efx_i2c_read(struct efx_i2c_interface
*i2c
,
68 u8 device_id
, u8 offset
, u8
*data
, unsigned int len
);
69 extern int efx_i2c_write(struct efx_i2c_interface
*i2c
,
70 u8 device_id
, u8 offset
,
71 const u8
*data
, unsigned int len
);
73 extern int efx_i2c_send_bytes(struct efx_i2c_interface
*i2c
, u8 device_id
,
74 const u8
*bytes
, unsigned int len
);
76 extern int efx_i2c_recv_bytes(struct efx_i2c_interface
*i2c
, u8 device_id
,
77 u8
*bytes
, unsigned int len
);
80 /* Versions of the API that retry on failure. */
81 extern int efx_i2c_check_presence_retry(struct efx_i2c_interface
*i2c
,
84 extern int efx_i2c_read_retry(struct efx_i2c_interface
*i2c
,
85 u8 device_id
, u8 offset
, u8
*data
, unsigned int len
);
87 extern int efx_i2c_write_retry(struct efx_i2c_interface
*i2c
,
88 u8 device_id
, u8 offset
,
89 const u8
*data
, unsigned int len
);
91 #endif /* EFX_I2C_DIRECT_H */