]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - common/soft_i2c.c
* Patch by Stephan Linz, 09 Mar 2004
[karo-tx-uboot.git] / common / soft_i2c.c
index 77774801e87018f1e4ae962efc9b004583f3e56f..9a10b3126c1d5e2e91d3388eda1375728a2fefdb 100644 (file)
@@ -83,8 +83,12 @@ static void send_reset(void)
 #endif
        int j;
 
-       I2C_ACTIVE;
+       I2C_SCL(1);
        I2C_SDA(1);
+#ifdef I2C_INIT
+       I2C_INIT;
+#endif
+       I2C_TRISTATE;
        for(j = 0; j < 9; j++) {
                I2C_SCL(0);
                I2C_DELAY;
@@ -262,18 +266,11 @@ static uchar read_byte(int ack)
  */
 void i2c_init (int speed, int slaveaddr)
 {
-#ifdef CONFIG_8xx
-       volatile immap_t *immr = (immap_t *)CFG_IMMR;
-#endif
-
-#ifdef I2C_INIT
-       I2C_INIT;
-#endif
        /*
-         * WARNING: Do NOT save speed in a static variable: if the
-         * I2C routines are called before RAM is initialized (to read
-         * the DIMM SPD, for instance), RAM won't be usable and your
-         * system will crash.
+        * WARNING: Do NOT save speed in a static variable: if the
+        * I2C routines are called before RAM is initialized (to read
+        * the DIMM SPD, for instance), RAM won't be usable and your
+        * system will crash.
         */
        send_reset ();
 }
@@ -287,8 +284,9 @@ int i2c_probe(uchar addr)
 {
        int rc;
 
+       /* perform 1 byte read transaction */
        send_start();
-       rc = write_byte ((addr << 1) | 1);
+       rc = write_byte ((addr << 1) | 0);
        send_stop();
 
        return (rc ? 1 : 0);