Kaynağa Gözat

Move per-transition delays from generic bit-bashing layer to i2c layer

(since SPI bit-bashing will require different delay semantics).
tags/v0.9.3
Michael Brown 18 yıl önce
ebeveyn
işleme
ab4f96e525

+ 0
- 1
src/drivers/bitbash/bitbash.c Dosyayı Görüntüle

@@ -38,7 +38,6 @@
38 38
 void write_bit ( struct bit_basher *basher, unsigned int bit_id,
39 39
 		 unsigned long data ) {
40 40
 	basher->write ( basher, bit_id, ( data ? -1UL : 0 ) );
41
-	udelay ( basher->udelay );
42 41
 }
43 42
 
44 43
 /**

+ 15
- 7
src/drivers/bitbash/i2c_bit.c Dosyayı Görüntüle

@@ -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
 }

+ 0
- 2
src/include/gpxe/bitbash.h Dosyayı Görüntüle

@@ -33,8 +33,6 @@ struct bit_basher {
33 33
 	 * @ret non-zero	Input is a logic 1
34 34
 	 */
35 35
 	int ( * read ) ( struct bit_basher *basher, unsigned int bit_id );
36
-	/** Delay between subsequent calls to write(), in microseconds */
37
-	unsigned int udelay;
38 36
 };
39 37
 
40 38
 extern void write_bit ( struct bit_basher *basher, unsigned int bit_id,

Loading…
İptal
Kaydet