summaryrefslogtreecommitdiffstats
path: root/src/drivers/bitbash/i2c_bit.c
diff options
context:
space:
mode:
authorMichael Brown2006-06-14 02:20:35 +0200
committerMichael Brown2006-06-14 02:20:35 +0200
commitab4f96e525fe082b0750867cc50d03becf018048 (patch)
tree8475725200b15eb3f72f17579ba64a5952e04295 /src/drivers/bitbash/i2c_bit.c
parentTranslate between "0 = success" and "0 = failure" call standards. (diff)
downloadipxe-ab4f96e525fe082b0750867cc50d03becf018048.tar.gz
ipxe-ab4f96e525fe082b0750867cc50d03becf018048.tar.xz
ipxe-ab4f96e525fe082b0750867cc50d03becf018048.zip
Move per-transition delays from generic bit-bashing layer to i2c layer
(since SPI bit-bashing will require different delay semantics).
Diffstat (limited to 'src/drivers/bitbash/i2c_bit.c')
-rw-r--r--src/drivers/bitbash/i2c_bit.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/drivers/bitbash/i2c_bit.c b/src/drivers/bitbash/i2c_bit.c
index cc73968b..2551bb4f 100644
--- a/src/drivers/bitbash/i2c_bit.c
+++ b/src/drivers/bitbash/i2c_bit.c
@@ -32,14 +32,24 @@
*/
/**
+ * 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
*
* @v basher Bit-bashing interface
* @v state New state of SCL
*/
-static inline __attribute__ (( always_inline )) void
-setscl ( struct bit_basher *basher, int state ) {
+static void setscl ( struct bit_basher *basher, int 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 state New state of SDA
*/
-static inline __attribute__ (( always_inline )) void
-setsda ( struct bit_basher *basher, int state ) {
+static void setsda ( struct bit_basher *basher, int 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
* @ret state State of SDA
*/
-static inline __attribute__ (( always_inline )) int
-getsda ( struct bit_basher *basher ) {
+static int getsda ( struct bit_basher *basher ) {
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 );
i2cbit->i2c.read = i2c_bit_read;
i2cbit->i2c.write = i2c_bit_write;
- basher->udelay = I2C_UDELAY;
i2c_stop ( basher );
}