Port-powerpc archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: mistake the i2c_bitbang direction



Hi! also port-powerpc guys,


First, please see this thread at current-users@.

  http://mail-index.netbsd.org/current-users/2008/07/07/msg003400.html


And, I will not understand the specification of i2c.


From: Izumi Tsutsui <tsutsui%ceres.dti.ne.jp@localhost>
Date: Tue, 8 Jul 2008 04:25:12 +0900

> > > I think mistake to set the direction.  We necessary DIR(INPUT) before 
> > > READ,
> > > and DIR(OUTPUT) before SETBITS().
> > 
> > No.
> > 
> > DIR() should be used only for SDA, not for SCL.
> > As I noted in the log message, using DIR(INPUT) to read SCL
> > in i2c_wait_for_scl() causes unexpected stop condition
> > in SCL=H, SDA=L and DIR(OUTPUT) case.
> 
> Furthermore, we have to do SETBITS() before DIR(OUTPUT) in some case
> otherwise the device might put unexpected glitch during delay between
> DIR(OUTPUT) and SETBITS().

I think that the following correction is necessary for gpiic of 405Gp
of imb4xx if his correction is correct.


Index: gpiic_opb.c
===================================================================
RCS file: /cvsroot/src/sys/arch/powerpc/ibm4xx/dev/gpiic_opb.c,v
retrieving revision 1.5
diff -u -r1.5 gpiic_opb.c
--- gpiic_opb.c 6 Dec 2007 17:00:33 -0000       1.5
+++ gpiic_opb.c 8 Jul 2008 14:53:05 -0000
@@ -213,11 +213,8 @@
 {
        struct gpiic_softc *sc = arg;
 
-       if (sc->sc_txen == 0 && (bits & IIC_DIRECTCNTL_SDAC) == 0) {
-               printf("gpiic_set_bits: SDA low with no output enable\n");
+       if (sc->sc_txen == 0 && (bits & IIC_DIRECTCNTL_SDAC) == 0)
                bits |= IIC_DIRECTCNTL_SDAC;
-       }
-
        bus_space_write_1(sc->sc_bust, sc->sc_bush, IIC_DIRECTCNTL, bits);
 }
 
@@ -227,9 +224,6 @@
        struct gpiic_softc *sc = arg;
        uint8_t rv;
 
-       if (sc->sc_txen != 0)
-               printf("gpiic_read_bits: Read in output mode\n");
-
        rv = bus_space_read_1(sc->sc_bust, sc->sc_bush, IIC_DIRECTCNTL) << 2;
        rv &= (IIC_DIRECTCNTL_SCC | IIC_DIRECTCNTL_SDAC);


Has you any other idea?  ;-)

Thanks,
--
kiyohara


Home | Main Index | Thread Index | Old Index