From owner-freebsd-embedded@FreeBSD.ORG Wed Nov 30 21:13:18 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 B0D1D1065677 for ; Wed, 30 Nov 2011 21:13:18 +0000 (UTC) (envelope-from ray@ddteam.net) Received: from mail-fx0-f54.google.com (mail-fx0-f54.google.com [209.85.161.54]) by mx1.freebsd.org (Postfix) with ESMTP id 407BB8FC12 for ; Wed, 30 Nov 2011 21:13:18 +0000 (UTC) Received: by faak28 with SMTP id k28so1367486faa.13 for ; Wed, 30 Nov 2011 13:13:17 -0800 (PST) Received: by 10.204.157.151 with SMTP id b23mr4228333bkx.30.1322687597010; Wed, 30 Nov 2011 13:13:17 -0800 (PST) Received: from rnote.ddteam.net (241-186-133-95.pool.ukrtel.net. [95.133.186.241]) by mx.google.com with ESMTPS id z7sm6653275bka.1.2011.11.30.13.13.14 (version=SSLv3 cipher=OTHER); Wed, 30 Nov 2011 13:13:15 -0800 (PST) Date: Wed, 30 Nov 2011 23:13:11 +0200 From: Aleksandr Rybalko To: Warner Losh Message-Id: <20111130231311.4a154bc5.ray@ddteam.net> In-Reply-To: <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> <2B8826C7-00C7-4117-B424-4A86F1346DFF@bsdimp.com> X-Mailer: Sylpheed 3.1.0 (GTK+ 2.24.5; amd64-portbld-freebsd9.0) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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 21:13:18 -0000 Hi, On Wed, 30 Nov 2011 12:58:14 -0700 Warner Losh wrote: > > 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. Now I recall my problems with iic :) > > I thought that was spelled out in the i2c spec fairly clearly... Do > you have the data sheet showing this timing? > I found the same in other Realtek switches, that rules applied also to RTL8367, 8370. IIRC Realtek even don't name this bus as I2C :) This usage maybe related with use of this bus to access i2c EEPROM for initialization. > 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 Fon +49 151 14070811 > > > > > > > > _______________________________________________ > > 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" > > > > > > _______________________________________________ > 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" -- Aleksandr Rybalko