mirror of
https://github.com/ipxe/ipxe
synced 2025-12-17 18:11:49 +03:00
Move per-transition delays from generic bit-bashing layer to i2c layer
(since SPI bit-bashing will require different delay semantics).
This commit is contained in:
@@ -38,7 +38,6 @@
|
|||||||
void write_bit ( struct bit_basher *basher, unsigned int bit_id,
|
void write_bit ( struct bit_basher *basher, unsigned int bit_id,
|
||||||
unsigned long data ) {
|
unsigned long data ) {
|
||||||
basher->write ( basher, bit_id, ( data ? -1UL : 0 ) );
|
basher->write ( basher, bit_id, ( data ? -1UL : 0 ) );
|
||||||
udelay ( basher->udelay );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -31,15 +31,25 @@
|
|||||||
* that provides two lines: SCL (clock) and SDA (data).
|
* that provides two lines: SCL (clock) and SDA (data).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delay between output state changes
|
||||||
|
*
|
||||||
|
* Max rated i2c speed (for the basic i2c protocol) is 100kbps,
|
||||||
|
* i.e. 200k clock transitions per second.
|
||||||
|
*/
|
||||||
|
static void i2c_delay ( void ) {
|
||||||
|
udelay ( I2C_UDELAY );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set state of I2C SCL line
|
* Set state of I2C SCL line
|
||||||
*
|
*
|
||||||
* @v basher Bit-bashing interface
|
* @v basher Bit-bashing interface
|
||||||
* @v state New state of SCL
|
* @v state New state of SCL
|
||||||
*/
|
*/
|
||||||
static inline __attribute__ (( always_inline )) void
|
static void setscl ( struct bit_basher *basher, int state ) {
|
||||||
setscl ( struct bit_basher *basher, int state ) {
|
|
||||||
write_bit ( basher, I2C_BIT_SCL, state );
|
write_bit ( basher, I2C_BIT_SCL, state );
|
||||||
|
i2c_delay();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -48,9 +58,9 @@ setscl ( struct bit_basher *basher, int state ) {
|
|||||||
* @v basher Bit-bashing interface
|
* @v basher Bit-bashing interface
|
||||||
* @v state New state of SDA
|
* @v state New state of SDA
|
||||||
*/
|
*/
|
||||||
static inline __attribute__ (( always_inline )) void
|
static void setsda ( struct bit_basher *basher, int state ) {
|
||||||
setsda ( struct bit_basher *basher, int state ) {
|
|
||||||
write_bit ( basher, I2C_BIT_SDA, state );
|
write_bit ( basher, I2C_BIT_SDA, state );
|
||||||
|
i2c_delay();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -59,8 +69,7 @@ setsda ( struct bit_basher *basher, int state ) {
|
|||||||
* @v basher Bit-bashing interface
|
* @v basher Bit-bashing interface
|
||||||
* @ret state State of SDA
|
* @ret state State of SDA
|
||||||
*/
|
*/
|
||||||
static inline __attribute__ (( always_inline )) int
|
static int getsda ( struct bit_basher *basher ) {
|
||||||
getsda ( struct bit_basher *basher ) {
|
|
||||||
return read_bit ( basher, I2C_BIT_SDA );
|
return read_bit ( basher, I2C_BIT_SDA );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -308,6 +317,5 @@ void init_i2c_bit_basher ( struct i2c_bit_basher *i2cbit ) {
|
|||||||
assert ( basher->write != NULL );
|
assert ( basher->write != NULL );
|
||||||
i2cbit->i2c.read = i2c_bit_read;
|
i2cbit->i2c.read = i2c_bit_read;
|
||||||
i2cbit->i2c.write = i2c_bit_write;
|
i2cbit->i2c.write = i2c_bit_write;
|
||||||
basher->udelay = I2C_UDELAY;
|
|
||||||
i2c_stop ( basher );
|
i2c_stop ( basher );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,8 +33,6 @@ struct bit_basher {
|
|||||||
* @ret non-zero Input is a logic 1
|
* @ret non-zero Input is a logic 1
|
||||||
*/
|
*/
|
||||||
int ( * read ) ( struct bit_basher *basher, unsigned int bit_id );
|
int ( * read ) ( struct bit_basher *basher, unsigned int bit_id );
|
||||||
/** Delay between subsequent calls to write(), in microseconds */
|
|
||||||
unsigned int udelay;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern void write_bit ( struct bit_basher *basher, unsigned int bit_id,
|
extern void write_bit ( struct bit_basher *basher, unsigned int bit_id,
|
||||||
|
|||||||
Reference in New Issue
Block a user