|
@@ -31,15 +31,25 @@
|
31
|
31
|
* that provides two lines: SCL (clock) and SDA (data).
|
32
|
32
|
*/
|
33
|
33
|
|
|
34
|
+/**
|
|
35
|
+ * Delay between output state changes
|
|
36
|
+ *
|
|
37
|
+ * Max rated i2c speed (for the basic i2c protocol) is 100kbps,
|
|
38
|
+ * i.e. 200k clock transitions per second.
|
|
39
|
+ */
|
|
40
|
+static void i2c_delay ( void ) {
|
|
41
|
+ udelay ( I2C_UDELAY );
|
|
42
|
+}
|
|
43
|
+
|
34
|
44
|
/**
|
35
|
45
|
* Set state of I2C SCL line
|
36
|
46
|
*
|
37
|
47
|
* @v basher Bit-bashing interface
|
38
|
48
|
* @v state New state of SCL
|
39
|
49
|
*/
|
40
|
|
-static inline __attribute__ (( always_inline )) void
|
41
|
|
-setscl ( struct bit_basher *basher, int state ) {
|
|
50
|
+static void setscl ( struct bit_basher *basher, int state ) {
|
42
|
51
|
write_bit ( basher, I2C_BIT_SCL, state );
|
|
52
|
+ i2c_delay();
|
43
|
53
|
}
|
44
|
54
|
|
45
|
55
|
/**
|
|
@@ -48,9 +58,9 @@ setscl ( struct bit_basher *basher, int state ) {
|
48
|
58
|
* @v basher Bit-bashing interface
|
49
|
59
|
* @v state New state of SDA
|
50
|
60
|
*/
|
51
|
|
-static inline __attribute__ (( always_inline )) void
|
52
|
|
-setsda ( struct bit_basher *basher, int state ) {
|
|
61
|
+static void setsda ( struct bit_basher *basher, int state ) {
|
53
|
62
|
write_bit ( basher, I2C_BIT_SDA, state );
|
|
63
|
+ i2c_delay();
|
54
|
64
|
}
|
55
|
65
|
|
56
|
66
|
/**
|
|
@@ -59,8 +69,7 @@ setsda ( struct bit_basher *basher, int state ) {
|
59
|
69
|
* @v basher Bit-bashing interface
|
60
|
70
|
* @ret state State of SDA
|
61
|
71
|
*/
|
62
|
|
-static inline __attribute__ (( always_inline )) int
|
63
|
|
-getsda ( struct bit_basher *basher ) {
|
|
72
|
+static int getsda ( struct bit_basher *basher ) {
|
64
|
73
|
return read_bit ( basher, I2C_BIT_SDA );
|
65
|
74
|
}
|
66
|
75
|
|
|
@@ -308,6 +317,5 @@ void init_i2c_bit_basher ( struct i2c_bit_basher *i2cbit ) {
|
308
|
317
|
assert ( basher->write != NULL );
|
309
|
318
|
i2cbit->i2c.read = i2c_bit_read;
|
310
|
319
|
i2cbit->i2c.write = i2c_bit_write;
|
311
|
|
- basher->udelay = I2C_UDELAY;
|
312
|
320
|
i2c_stop ( basher );
|
313
|
321
|
}
|