Author: wulf
Date: Sun Nov  3 21:12:59 2019
New Revision: 354317
URL: https://svnweb.freebsd.org/changeset/base/354317

Log:
  [ig4] wait for bus stop condition after stop command issued
  
  It gives better error detection and ig4 driver's lock coverage
  in a pipelined write case

Modified:
  head/sys/dev/ichiic/ig4_iic.c

Modified: head/sys/dev/ichiic/ig4_iic.c
==============================================================================
--- head/sys/dev/ichiic/ig4_iic.c       Sun Nov  3 21:10:47 2019        
(r354316)
+++ head/sys/dev/ichiic/ig4_iic.c       Sun Nov  3 21:12:59 2019        
(r354317)
@@ -362,7 +362,8 @@ ig4iic_xfer_start(ig4iic_softc_t *sc, uint16_t slave, 
 
        if (!repeated_start) {
                /*
-                * Clear any previous TX/RX FIFOs overflow/underflow bits.
+                * Clear any previous TX/RX FIFOs overflow/underflow bits
+                * and I2C bus STOP condition.
                 */
                reg_read(sc, IG4_REG_CLR_INTR);
        }
@@ -613,6 +614,13 @@ ig4iic_transfer(device_t dev, struct iic_msg *msgs, ui
                else
                        error = ig4iic_write(sc, msgs[i].buf, msgs[i].len,
                            rpstart, stop);
+
+               /* Wait for error or stop condition occurred on the I2C bus */
+               if (stop && error == 0) {
+                       error = wait_intr(sc, IG4_INTR_STOP_DET);
+                       if (error == 0)
+                               reg_read(sc, IG4_REG_CLR_INTR);
+               }
 
                if (error != 0) {
                        /*
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to