#include <stdint.h>
#include <gpxe/bitbash.h>
Go to the source code of this file.
Data Structures | |
| struct | i2c_device |
| An I2C device. More... | |
| struct | i2c_interface |
| An I2C interface. More... | |
| struct | i2c_bit_basher |
| A bit-bashing I2C interface. More... | |
Defines | |
| #define | I2C_TENBIT_ADDRESS 0x7800 |
| Ten-bit address marker. | |
| #define | I2C_WRITE 0 |
| An I2C write command. | |
| #define | I2C_READ 1 |
| An I2C read command. | |
| #define | I2C_UDELAY 5 |
| Delay required for bit-bashing operation. | |
| #define | I2C_RESET_MAX_CYCLES 32 |
| Maximum number of cycles to use when attempting a bus reset. | |
Enumerations | |
| enum | { I2C_BIT_SCL = 0, I2C_BIT_SDA } |
| Bit indices used for I2C bit-bashing interface. More... | |
Functions | |
| FILE_LICENCE (GPL2_OR_LATER) | |
| static int | i2c_check_presence (struct i2c_interface *i2c, struct i2c_device *i2cdev) |
| Check presence of I2C device. | |
| int | init_i2c_bit_basher (struct i2c_bit_basher *i2cbit, struct bit_basher_operations *bash_op) |
| Initialise I2C bit-bashing interface. | |
| static __always_inline void | init_i2c_eeprom (struct i2c_device *i2cdev, unsigned int dev_addr) |
| Initialise generic I2C EEPROM device. | |
| static __always_inline void | init_at24c11 (struct i2c_device *i2cdev) |
| Initialise Atmel AT24C11. | |
Definition in file i2c.h.
| #define I2C_TENBIT_ADDRESS 0x7800 |
| #define I2C_WRITE 0 |
An I2C write command.
Definition at line 106 of file i2c.h.
Referenced by i2c_bit_read(), and i2c_bit_write().
| #define I2C_READ 1 |
| #define I2C_UDELAY 5 |
Delay required for bit-bashing operation.
Definition at line 120 of file i2c.h.
Referenced by i2c_delay().
| #define I2C_RESET_MAX_CYCLES 32 |
Maximum number of cycles to use when attempting a bus reset.
Definition at line 123 of file i2c.h.
Referenced by i2c_reset().
| anonymous enum |
Bit indices used for I2C bit-bashing interface.
Definition at line 112 of file i2c.h.
00112 { 00113 /** Serial clock */ 00114 I2C_BIT_SCL = 0, 00115 /** Serial data */ 00116 I2C_BIT_SDA, 00117 };
| FILE_LICENCE | ( | GPL2_OR_LATER | ) |
| static int i2c_check_presence | ( | struct i2c_interface * | i2c, | |
| struct i2c_device * | i2cdev | |||
| ) | [inline, static] |
Check presence of I2C device.
| rc | Return status code |
Definition at line 135 of file i2c.h.
References NULL, and i2c_interface::write.
Referenced by linda_init_i2c().
| int init_i2c_bit_basher | ( | struct i2c_bit_basher * | i2cbit, | |
| struct bit_basher_operations * | bash_op | |||
| ) |
Initialise I2C bit-bashing interface.
| i2cbit | I2C bit-bashing interface | |
| bash_op | Bit-basher operations |
Definition at line 373 of file i2c_bit.c.
References assert, i2c_bit_basher::basher, DBGC, i2c_bit_basher::i2c, i2c_bit_read(), i2c_bit_write(), i2c_reset(), NULL, bit_basher::op, i2c_interface::read, bit_basher_operations::read, strerror(), i2c_interface::write, and bit_basher_operations::write.
Referenced by falcon_probe_spi(), and linda_init_i2c().
00374 { 00375 struct bit_basher *basher = &i2cbit->basher; 00376 int rc; 00377 00378 /* Initialise data structures */ 00379 basher->op = bash_op; 00380 assert ( basher->op->read != NULL ); 00381 assert ( basher->op->write != NULL ); 00382 i2cbit->i2c.read = i2c_bit_read; 00383 i2cbit->i2c.write = i2c_bit_write; 00384 00385 /* Reset I2C bus */ 00386 if ( ( rc = i2c_reset ( basher ) ) != 0 ) { 00387 DBGC ( basher, "I2CBIT %p could not reset I2C bus: %s\n", 00388 basher, strerror ( rc ) ); 00389 return rc; 00390 } 00391 00392 return 0; 00393 }
| static __always_inline void init_i2c_eeprom | ( | struct i2c_device * | i2cdev, | |
| unsigned int | dev_addr | |||
| ) | [inline, static] |
Initialise generic I2C EEPROM device.
| i2cdev | I2C device |
Definition at line 149 of file i2c.h.
References i2c_device::dev_addr, i2c_device::dev_addr_len, and i2c_device::word_addr_len.
Referenced by linda_init_i2c().
00149 { 00150 i2cdev->dev_addr = dev_addr; 00151 i2cdev->dev_addr_len = 1; 00152 i2cdev->word_addr_len = 1; 00153 }
| static __always_inline void init_at24c11 | ( | struct i2c_device * | i2cdev | ) | [inline, static] |
Initialise Atmel AT24C11.
| i2cdev | I2C device |
Definition at line 161 of file i2c.h.
References i2c_device::dev_addr, i2c_device::dev_addr_len, and i2c_device::word_addr_len.
00161 { 00162 /* This chip has no device address; it must be the only chip 00163 * on the bus. The word address is contained entirely within 00164 * the device address field. 00165 */ 00166 i2cdev->dev_addr = 0; 00167 i2cdev->dev_addr_len = 1; 00168 i2cdev->word_addr_len = 0; 00169 }
1.5.7.1