From patchwork Sun May 30 00:12:23 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cory Maccarrone X-Patchwork-Id: 103100 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o4U0Cxq2018251 for ; Sun, 30 May 2010 00:13:00 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756887Ab0E3AM4 (ORCPT ); Sat, 29 May 2010 20:12:56 -0400 Received: from mail-gw0-f46.google.com ([74.125.83.46]:61812 "EHLO mail-gw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756835Ab0E3AM4 (ORCPT ); Sat, 29 May 2010 20:12:56 -0400 Received: by gwaa12 with SMTP id a12so1904528gwa.19 for ; Sat, 29 May 2010 17:12:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer; bh=NuBnc/ajFYF6nu1eBZKJPb4oLgrGrmx+y6hotdrCyjU=; b=NuSdYG59MLn3v/eW24DhIhLY52LespUwEI2p8QtulKCYzJ6J2SCgZ7+RUJ8op7/F70 UDCAyEGPJ5wj+GtkzE1nqjgVYXcbJnU9uOtrdyICYeaPl01SDkXYXomIZgDcpLDcRFns PwhQPD/NqgeQL7vQmRCpzpnsPuRJ8E7Uum7gQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=wmP4SB5LupPAY/ay76SRRkgYsVxi+gNH42Pu831PozsEN1f51Si/89JQSWkCEaD8J6 F7NR8OY43oDpPomDnyyPP1XdW2wd8avIR2kvJ15xafrnYe3C+SnuEjYqxE/bBvLeTSZq yI7AFfblmLsqGY+DCmQFd03vFk+PrndgI6x+U= Received: by 10.231.176.16 with SMTP id bc16mr3138462ibb.4.1275178375030; Sat, 29 May 2010 17:12:55 -0700 (PDT) Received: from localhost (97-126-104-191.tukw.qwest.net [97.126.104.191]) by mx.google.com with ESMTPS id a8sm18344697ibi.17.2010.05.29.17.12.53 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 29 May 2010 17:12:54 -0700 (PDT) From: Cory Maccarrone To: spi-devel-general@lists.sourceforge.net Cc: linux-omap@vger.kernel.org, Cory Maccarrone Subject: [PATCH] [SPI] SPI100k: Fix 8-bit and RX-only transfers Date: Sat, 29 May 2010 17:12:23 -0700 Message-Id: <1275178343-28193-1-git-send-email-darkstar6262@gmail.com> X-Mailer: git-send-email 1.7.0.4 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Sun, 30 May 2010 00:13:00 +0000 (UTC) diff --git a/drivers/spi/omap_spi_100k.c b/drivers/spi/omap_spi_100k.c index 24668b3..9bd1c92 100644 --- a/drivers/spi/omap_spi_100k.c +++ b/drivers/spi/omap_spi_100k.c @@ -141,7 +141,12 @@ static void spi100k_write_data(struct spi_master *master, int len, int data) { struct omap1_spi100k *spi100k = spi_master_get_devdata(master); - /* write 16-bit word */ + /* write 16-bit word, shifting 8-bit data if necessary */ + if (len <= 8) { + data <<= 8; + len = 16; + } + spi100k_enable_clock(master); writew( data , spi100k->base + SPI_TX_MSB); @@ -162,6 +167,10 @@ static int spi100k_read_data(struct spi_master *master, int len) int dataH,dataL; struct omap1_spi100k *spi100k = spi_master_get_devdata(master); + /* Always do at least 16 bits */ + if (len <= 8) + len = 16; + spi100k_enable_clock(master); writew(SPI_CTRL_SEN(0) | SPI_CTRL_WORD_SIZE(len) | @@ -214,10 +223,6 @@ omap1_spi100k_txrx_pio(struct spi_device *spi, struct spi_transfer *xfer) c = count; word_len = cs->word_len; - /* RX_ONLY mode needs dummy data in TX reg */ - if (xfer->tx_buf == NULL) - spi100k_write_data(spi->master,word_len, 0); - if (word_len <= 8) { u8 *rx; const u8 *tx; @@ -227,9 +232,9 @@ omap1_spi100k_txrx_pio(struct spi_device *spi, struct spi_transfer *xfer) do { c-=1; if (xfer->tx_buf != NULL) - spi100k_write_data(spi->master,word_len, *tx); + spi100k_write_data(spi->master, word_len, *tx++); if (xfer->rx_buf != NULL) - *rx = spi100k_read_data(spi->master,word_len); + *rx++ = spi100k_read_data(spi->master, word_len); } while(c); } else if (word_len <= 16) { u16 *rx; @@ -380,10 +385,6 @@ static void omap1_spi100k_work(struct work_struct *work) if (t->len) { unsigned count; - /* RX_ONLY mode needs dummy data in TX reg */ - if (t->tx_buf == NULL) - spi100k_write_data(spi->master, 8, 0); - count = omap1_spi100k_txrx_pio(spi, t); m->actual_length += count;