From patchwork Sun Mar 13 14:34:22 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Williamson X-Patchwork-Id: 631691 Received: from devils.ext.ti.com (devils.ext.ti.com [198.47.26.153]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p2DEV0oH012926 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 13 Mar 2011 14:31:21 GMT Received: from dlep33.itg.ti.com ([157.170.170.112]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id p2DEUvqt031213 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sun, 13 Mar 2011 09:30:58 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by dlep33.itg.ti.com (8.13.7/8.13.7) with ESMTP id p2DEUv6q012469 for ; Sun, 13 Mar 2011 09:30:57 -0500 (CDT) Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id A3E0380665 for ; Sun, 13 Mar 2011 08:30:55 -0600 (CST) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dflp53.itg.ti.com (dflp53.itg.ti.com [128.247.5.6]) by linux.omap.com (Postfix) with ESMTP id 25F7280626 for ; Sun, 13 Mar 2011 08:30:48 -0600 (CST) Received: from red.ext.ti.com (localhost [127.0.0.1]) by dflp53.itg.ti.com (8.13.8/8.13.8) with ESMTP id p2DEUldQ010270 for ; Sun, 13 Mar 2011 09:30:47 -0500 (CDT) Received: from psmtp.com (na3sys009amx179.postini.com [74.125.149.160]) by red.ext.ti.com (8.13.7/8.13.7) with SMTP id p2DEUluK026525 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sun, 13 Mar 2011 09:30:47 -0500 Received: from source ([209.85.160.173]) (using TLSv1) by na3sys009amx179.postini.com ([74.125.148.10]) with SMTP; Sun, 13 Mar 2011 07:30:47 PDT Received: by gyf1 with SMTP id 1so756230gyf.4 for ; Sun, 13 Mar 2011 07:30:46 -0700 (PDT) Received: by 10.236.62.66 with SMTP id x42mr4992998yhc.10.1300026644562; Sun, 13 Mar 2011 07:30:44 -0700 (PDT) Received: from localhost.localdomain (rrcs-24-39-249-130.nys.biz.rr.com [24.39.249.130]) by mx.google.com with ESMTPS id k29sm4465538yhk.14.2011.03.13.07.30.43 (version=SSLv3 cipher=OTHER); Sun, 13 Mar 2011 07:30:44 -0700 (PDT) From: Michael Williamson To: spi-devel-general@lists.sourceforge.net Subject: [PATCH] spi: davinci: Support DMA transfers larger than 65535 words Date: Sun, 13 Mar 2011 10:34:22 -0400 Message-Id: <1300026862-1179-2-git-send-email-michael.williamson@criticallink.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1300026862-1179-1-git-send-email-michael.williamson@criticallink.com> References: <1300026862-1179-1-git-send-email-michael.williamson@criticallink.com> X-pstn-neptune: 0/0/0.00/0 X-pstn-levels: (S:49.26292/99.90000 CV:99.9000 FC:95.5390 LC:95.5390 R:95.9108 P:95.9108 M:97.0282 C:98.6951 ) X-pstn-settings: 2 (0.5000:0.0750) s cv GT3 gt2 gt1 r p m c X-pstn-addresses: from [db-null] Cc: grant.likely@secretlab.ca, davinci-linux-open-source@linux.davincidsp.com, dbrownell@users.sourceforge.net X-BeenThere: davinci-linux-open-source@linux.davincidsp.com X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: davinci-linux-open-source-bounces+patchwork-davinci=patchwork.kernel.org@linux.davincidsp.com Errors-To: davinci-linux-open-source-bounces+patchwork-davinci=patchwork.kernel.org@linux.davincidsp.com X-Greylist: Sender succeeded STARTTLS authentication, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Sun, 13 Mar 2011 14:31:21 +0000 (UTC) diff --git a/drivers/spi/davinci_spi.c b/drivers/spi/davinci_spi.c index 037ba82..411cc32 100644 --- a/drivers/spi/davinci_spi.c +++ b/drivers/spi/davinci_spi.c @@ -571,6 +571,7 @@ static int davinci_spi_bufs(struct spi_device *spi, struct spi_transfer *t) unsigned long tx_reg, rx_reg; struct edmacc_param param; void *rx_buf; + int b, c; dma = &dspi->dma; @@ -599,14 +600,30 @@ static int davinci_spi_bufs(struct spi_device *spi, struct spi_transfer *t) } } + /* + * If number of words is greater than 65535, then we need + * to configure a 3 dimension transfer. Use the BCNTRLD + * feature to allow for transfers that aren't even multiples + * of 65535 (or any other possible b size) by first transferring + * the remainder amount then grabbing the next N blocks of + * 65535 words. + */ + + c = dspi->wcount/(SZ_64K-1); /* N 65535 count Blocks */ + b = dspi->wcount-c*(SZ_64K-1); /* Remainder */ + if (b) + c++; + else + b = SZ_64K-1; + param.opt = TCINTEN | EDMA_TCC(dma->tx_channel); param.src = t->tx_buf ? t->tx_dma : tx_reg; - param.a_b_cnt = dspi->wcount << 16 | data_type; + param.a_b_cnt = b << 16 | data_type; param.dst = tx_reg; param.src_dst_bidx = t->tx_buf ? data_type : 0; - param.link_bcntrld = 0xffff; - param.src_dst_cidx = 0; - param.ccnt = 1; + param.link_bcntrld = 0xffffffff; + param.src_dst_cidx = t->tx_buf ? data_type : 0; + param.ccnt = c; edma_write_slot(dma->tx_channel, ¶m); edma_link(dma->tx_channel, dma->dummy_param_slot); @@ -643,12 +660,12 @@ static int davinci_spi_bufs(struct spi_device *spi, struct spi_transfer *t) param.opt = TCINTEN | EDMA_TCC(dma->rx_channel); param.src = rx_reg; - param.a_b_cnt = dspi->rcount << 16 | data_type; + param.a_b_cnt = b << 16 | data_type; param.dst = t->rx_dma; param.src_dst_bidx = (t->rx_buf ? data_type : 0) << 16; - param.link_bcntrld = 0xffff; - param.src_dst_cidx = 0; - param.ccnt = 1; + param.link_bcntrld = 0xffffffff; + param.src_dst_cidx = (t->rx_buf ? data_type : 0) << 16; + param.ccnt = c; edma_write_slot(dma->rx_channel, ¶m); if (pdata->cshold_bug)