From owner-freebsd-embedded@FreeBSD.ORG Wed Nov 30 20:01:21 2011 Return-Path: Delivered-To: freebsd-embedded@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id ACE5E106566C for ; Wed, 30 Nov 2011 20:01:21 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (bsdimp.com [199.45.160.85]) by mx1.freebsd.org (Postfix) with ESMTP id 4EE5B8FC08 for ; Wed, 30 Nov 2011 20:01:21 +0000 (UTC) Received: from [10.30.101.60] ([209.117.142.2]) (authenticated bits=0) by harmony.bsdimp.com (8.14.4/8.14.3) with ESMTP id pAUJwJcf076055 (version=TLSv1/SSLv3 cipher=DHE-DSS-AES128-SHA bits=128 verify=NO); Wed, 30 Nov 2011 12:58:21 -0700 (MST) (envelope-from imp@bsdimp.com) Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii From: Warner Losh In-Reply-To: <3C0E9CA3-E130-4E9A-ABCC-1782E28999D1@lassitu.de> Date: Wed, 30 Nov 2011 12:58:14 -0700 Content-Transfer-Encoding: quoted-printable Message-Id: <2B8826C7-00C7-4117-B424-4A86F1346DFF@bsdimp.com> 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> <3C0E9CA3-E130-4E9A-ABCC-1782E28999D1@lassitu.de> To: Stefan Bethke X-Mailer: Apple Mail (2.1084) X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0.1 (harmony.bsdimp.com [10.0.0.6]); Wed, 30 Nov 2011 12:58:22 -0700 (MST) Cc: freebsd-embedded@freebsd.org Subject: Re: TL-WR1043: switch X-BeenThere: freebsd-embedded@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Dedicated and Embedded Systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Nov 2011 20:01:21 -0000 On Nov 30, 2011, at 12:43 PM, Stefan Bethke wrote: > One step closer: >=20 > http://www.lassitu.de/freebsd/rtl8366ctl.tbz >=20 > The starting point for a configuration utility. I've implemented two = "drivers": direct bitbanging access via gpio(4), or I2C access via = iic(4). >=20 > 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 > =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)); >=20 > 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. >=20 >=20 > Stefan >=20 > --=20 > Stefan Bethke Fon +49 151 14070811 >=20 >=20 >=20 > _______________________________________________ > freebsd-embedded@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-embedded > To unsubscribe, send any mail to = "freebsd-embedded-unsubscribe@freebsd.org" >=20 >=20