TL-WR1043: switch

Warner Losh imp at bsdimp.com
Wed Nov 30 20:01:21 UTC 2011


On Nov 30, 2011, at 12:43 PM, Stefan Bethke wrote:

> One step closer:
> 
> http://www.lassitu.de/freebsd/rtl8366ctl.tbz
> 
> The starting point for a configuration utility.  I've implemented two "drivers": direct bitbanging access via gpio(4), or I2C access via iic(4).
> 
> The I2C framework makes a faulty assumption that the read/not-write bit of the first byte (the address) indicates whether reads or writes are to follow.  While many simple I2C devices usually will follow this rule, it's not prescribed by the protocol (AFAICT), and is incompatible with the way the RTL8366 familiy uses the bus: after sending the address+read/not-write byte, two register address bytes are sent, then the 16-bit register value is sent or received.  While the register write access can be performed as a 4-byte write, the read access requires the read bit to be set, but the first two bytes for the register address then need to be transmitted.

I thought that was spelled out in the i2c spec fairly clearly...  Do you have the data sheet showing this timing?

Warner

> This patch removes the faulty check:
> Index: sys/dev/iicbus/iiconf.c
> ===================================================================
> --- sys/dev/iicbus/iiconf.c	(revision 228073)
> +++ sys/dev/iicbus/iiconf.c	(working copy)
> @@ -244,7 +244,7 @@
> 	struct iicbus_softc *sc = (struct iicbus_softc *)device_get_softc(bus);
> 	
> 	/* a slave must have been started with the appropriate address */
> -	if (!sc->started || (sc->started & LSB))
> +	if (!sc->started)
> 		return (EINVAL);
> 
> 	return (IICBUS_WRITE(device_get_parent(bus), buf, len, sent, timeout));
> @@ -262,7 +262,7 @@
> 	struct iicbus_softc *sc = (struct iicbus_softc *)device_get_softc(bus);
> 	
> 	/* a slave must have been started with the appropriate address */
> -	if (!sc->started || !(sc->started & LSB))
> +	if (!sc->started)
> 		return (EINVAL);
> 
> 	return (IICBUS_READ(device_get_parent(bus), buf, len, read, last, delay));
> 
> While trying to figure this out, I also came across the panic in sys/dev/gpio/gpiobus.c:panic("rb_cpldbus: cannot serialize the access to device.").  I'm not sure how I triggered it (the backtrace wasn't immediately revealing to me), but I'm speculating that the I2C fails to relinquish the GPIO when a bus transaction is aborted.
> 
> 
> Stefan
> 
> -- 
> Stefan Bethke <stb at lassitu.de>   Fon +49 151 14070811
> 
> 
> 
> _______________________________________________
> freebsd-embedded at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-embedded
> To unsubscribe, send any mail to "freebsd-embedded-unsubscribe at freebsd.org"
> 
> 



More information about the freebsd-embedded mailing list