From owner-freebsd-mips@FreeBSD.ORG Wed Feb 20 14:32:27 2013 Return-Path: Delivered-To: freebsd-mips@FreeBSD.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 3C74ADA9; Wed, 20 Feb 2013 14:32:27 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from duck.symmetricom.us (duck.symmetricom.us [206.168.13.214]) by mx1.freebsd.org (Postfix) with ESMTP id C23C87EF; Wed, 20 Feb 2013 14:32:26 +0000 (UTC) Received: from damnhippie.dyndns.org (daffy.symmetricom.us [206.168.13.218]) by duck.symmetricom.us (8.14.6/8.14.6) with ESMTP id r1KEWDUH022958; Wed, 20 Feb 2013 07:32:19 -0700 (MST) (envelope-from ian@FreeBSD.org) Received: from [172.22.42.240] (revolution.hippie.lan [172.22.42.240]) by damnhippie.dyndns.org (8.14.3/8.14.3) with ESMTP id r1KEWAKT051400; Wed, 20 Feb 2013 07:32:10 -0700 (MST) (envelope-from ian@FreeBSD.org) Subject: Re: SPI, _sz fields in struct spi_command From: Ian Lepore To: Warner Losh In-Reply-To: <54C08D8E-4C5F-49AF-BEE6-D78EC05D2A24@bsdimp.com> References: <20130220142140.f8e5a616c75d72e2519dbc69@freebsd.org> <54C08D8E-4C5F-49AF-BEE6-D78EC05D2A24@bsdimp.com> Content-Type: text/plain; charset="us-ascii" Date: Wed, 20 Feb 2013 07:32:10 -0700 Message-ID: <1361370730.1185.10.camel@revolution.hippie.lan> Mime-Version: 1.0 X-Mailer: Evolution 2.32.1 FreeBSD GNOME Team Port Content-Transfer-Encoding: 7bit Cc: Aleksandr Rybalko , freebsd-arm@FreeBSD.org, freebsd-mips@FreeBSD.org X-BeenThere: freebsd-mips@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Porting FreeBSD to MIPS List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Feb 2013 14:32:27 -0000 On Wed, 2013-02-20 at 07:15 -0700, Warner Losh wrote: > On Feb 20, 2013, at 5:21 AM, Aleksandr Rybalko wrote: > > > Hello ARM and MIPS hackers! > > > > Sorry for cross-post, but we have supported SPI devices on both > > platforms (and seems no others). > > > > Anyone know any reasons to keep both TX and RX _sz fields with same > > values? > > I wrote them to be separate for a reason.... I think I'd thought there'd be cases when you'd want to throw away the results or transmit garbage... I can't think of why right now... > > > sys/dev/flash/at45d.c > > static int > > at45d_get_mfg_info(device_t dev, uint8_t *resp) > > { > > ... > > cmd.tx_cmd_sz = cmd.rx_cmd_sz = 5; > > ... > > } > > > > or sys/dev/flash/mx25l.c > > static int > > mx25l_read(device_t dev, off_t offset, caddr_t data, off_t count) > > { > > ... > > cmd.tx_cmd_sz = 5; > > cmd.rx_cmd_sz = 5; > > ... > > } > > > > That always require second but unused buffer or writable tx buffer. And > > not all controllers able to TX with RX same time. (at least rt305x > > can't). So if nobody have any objections, I will update drivers (SPI > > controllers and SPI attached devices) to set unused _sz field to zero. > > IIRC, I will require help with AT91 controller update, at least with > > testing. > > The AT91, I think, required a minimum size, which is why the at45d driver set it I think.. > > I can't imagine an SPI controller that can't do both, because when you write something with SPI, you usually have to read back the status at the same time... > > Warner I think with at91 you really must do same-sized xfers in both directions or you'll get underflow/overflow errors from the hardware. It might be possible to just ignore the error, but even then the only useful way the xfer sizes could be different is one of them would be zero. Different non-zero sizes just don't make sense. -- Ian