Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 30 Nov 2011 20:43:59 +0100
From:      Stefan Bethke <stb@lassitu.de>
To:        freebsd-embedded@freebsd.org
Subject:   Re: TL-WR1043: switch
Message-ID:  <3C0E9CA3-E130-4E9A-ABCC-1782E28999D1@lassitu.de>
In-Reply-To: <203BF1C8-D528-40C9-8611-9C7AC7E43BAB@lassitu.de>
References:  <68ABED76-CB1F-405A-8036-EC254F7511FA@lassitu.de> <3B3DB17D-BF87-40EE-B1C1-445F178E8844@lassitu.de> <86030CEE-6839-4B96-ACDC-2BA9AC1E4AE4@lassitu.de> <2D625CC9-A0E3-47AA-A504-CE8FB2F90245@lassitu.de> <203BF1C8-D528-40C9-8611-9C7AC7E43BAB@lassitu.de>

next in thread | previous in thread | raw e-mail | index | archive | help
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.

This patch removes the faulty check:
Index: sys/dev/iicbus/iiconf.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- sys/dev/iicbus/iiconf.c	(revision 228073)
+++ sys/dev/iicbus/iiconf.c	(working copy)
@@ -244,7 +244,7 @@
 	struct iicbus_softc *sc =3D (struct iicbus_softc =
*)device_get_softc(bus);
 =09
 	/* a slave must have been started with the appropriate address =
*/
-	if (!sc->started || (sc->started & LSB))
+	if (!sc->started)
 		return (EINVAL);
=20
 	return (IICBUS_WRITE(device_get_parent(bus), buf, len, sent, =
timeout));
@@ -262,7 +262,7 @@
 	struct iicbus_softc *sc =3D (struct iicbus_softc =
*)device_get_softc(bus);
 =09
 	/* a slave must have been started with the appropriate address =
*/
-	if (!sc->started || !(sc->started & LSB))
+	if (!sc->started)
 		return (EINVAL);
=20
 	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

--=20
Stefan Bethke <stb@lassitu.de>   Fon +49 151 14070811






Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3C0E9CA3-E130-4E9A-ABCC-1782E28999D1>