From patchwork Tue Sep 24 14:00:35 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajeshwari Shinde X-Patchwork-Id: 2933931 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 584DEBFF05 for ; Tue, 24 Sep 2013 14:00:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AE0FD2044A for ; Tue, 24 Sep 2013 14:00:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2C6F920421 for ; Tue, 24 Sep 2013 14:00:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752854Ab3IXOAd (ORCPT ); Tue, 24 Sep 2013 10:00:33 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:57163 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751340Ab3IXOAc (ORCPT ); Tue, 24 Sep 2013 10:00:32 -0400 Received: from epcpsbgr2.samsung.com (u142.gpu120.samsung.co.kr [203.254.230.142]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MTM005VYUU606Y0@mailout3.samsung.com>; Tue, 24 Sep 2013 22:58:57 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.125]) by epcpsbgr2.samsung.com (EPCPMTA) with SMTP id C4.60.17682.1AA91425; Tue, 24 Sep 2013 22:58:57 +0900 (KST) X-AuditID: cbfee68e-b7f756d000004512-e9-52419aa1d8ac Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 26.AE.09055.1AA91425; Tue, 24 Sep 2013 22:58:57 +0900 (KST) Received: from localhost.localdomain.com ([107.108.73.95]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MTM00IA9UU06J40@mmp2.samsung.com>; Tue, 24 Sep 2013 22:58:57 +0900 (KST) From: Rajeshwari S Shinde To: linux-samsung-soc@vger.kernel.org Cc: linux-spi@vger.kernel.org, sjg@chromium.org, alim.akhtar@samsung.com, dianders@google.com Subject: [RFC/PATCH] spi: s3c64xx: Enable Word transfer Date: Tue, 24 Sep 2013 19:30:35 +0530 Message-id: <1380031235-4065-1-git-send-email-rajeshwari.s@samsung.com> X-Mailer: git-send-email 1.7.11.7 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrDLMWRmVeSWpSXmKPExsWyRsSkVnfhLMcgg2c3NS0ezNvGZrFg+0om ixnn9zFZNH68yW7xbcs2RgdWj9kNF1k8Fmwq9ejbsorR4/MmuQCWKC6blNSczLLUIn27BK6M j22XWAta+Cse9pxiamD8z93FyMkhIWAiseDOUSYIW0ziwr31bF2MXBxCAksZJWY2b2eCKbo+ 5xQrRGI6o8Tq5mPMEE4Xk8S8ae1AGQ4ONqCqjScSQBpEBFQlPrctYAexmQXiJR5NusYCYgsL mEtcmX2YGaScBajm0jNZkDCvgLvE4j9rWCB2KUrMWPKMEcJ+zSbRODkDxGYREJD4NvkQC0ir hICsxKYDzBAlkhIHV9xgmcAouICRYRWjaGpBckFxUnqRkV5xYm5xaV66XnJ+7iZGYEie/ves bwfjzQPWhxiTgcZNZJYSTc4HhnReSbyhsZmRhamJqbGRuaUZacJK4rxqLdaBQgLpiSWp2amp BalF8UWlOanFhxiZODilGhglfq5uT//MUbdOK/tkBUPEwj9qc+dUMNnKcvXYaao7qYVtvrIm xlti38OTCU1FUQHXFilkys3zzpj55PKtqOhPK8/cCtHcumnrx4O2bBNMNNT/bzFZ/OvnXsbb 2abKzxp1b6XNDew6srj1kLDq9Zevj2x54Dpr9xbFPSuPXTrhnqjc8lxYs3GjEktxRqKhFnNR cSIAEg648l8CAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrFIsWRmVeSWpSXmKPExsVy+t9jQd2FsxyDDPr/K1g8mLeNzWLB9pVM FjPO72OyaPx4k93i25ZtjA6sHrMbLrJ4LNhU6tG3ZRWjx+dNcgEsUQ2MNhmpiSmpRQqpecn5 KZl56bZK3sHxzvGmZgaGuoaWFuZKCnmJuam2Si4+AbpumTlAe5UUyhJzSoFCAYnFxUr6dpgm hIa46VrANEbo+oYEwfUYGaCBhDWMGR/bLrEWtPBXPOw5xdTA+J+7i5GTQ0LAROL6nFOsELaY xIV769m6GLk4hASmM0qsbj7GDOF0MUnMm9YOVMXBwQbUsfFEAkiDiICqxOe2BewgNrNAvMSj SddYQGxhAXOJK7MPM4OUswDVXHomCxLmFXCXWPxnDQvELkWJGUueMU5g5F7AyLCKUTS1ILmg OCk911CvODG3uDQvXS85P3cTIzjkn0ntYFzZYHGIUYCDUYmHd4e3Q5AQa2JZcWXuIUYJDmYl EV7NWscgId6UxMqq1KL8+KLSnNTiQ4zJQMsnMkuJJucD4zGvJN7Q2MTc1NjU0sTCxMySNGEl cd4DrdaBQgLpiSWp2ampBalFMFuYODilGhhnWAucM/Xfn3R9qe3JJ9M7o7Seq6pySin/Z9Sx VZ73/2z0aX8z66Vn/x6rkP/1aPXTK0tMEna3qcyefDTzq3xHzTdXtsW1f+femj17cuj/ti0F C9K1bk1Pz10Z/CLV+4f54igrTZ+FfCcnbK8KdnTlPsHDwWv757t+/7dXMScW9V+6qzYvq3GL EktxRqKhFnNRcSIARBGdir0CAAA= DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-9.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch enables word transfer for s3c64xx spi driver. User can set bits_per_word to 32 before calling spi_setup, which would enable the word transfer mode. Signed-off-by: Rajeshwari S Shinde --- drivers/spi/spi-s3c64xx.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c index 512b889..893361b 100644 --- a/drivers/spi/spi-s3c64xx.c +++ b/drivers/spi/spi-s3c64xx.c @@ -498,6 +498,17 @@ static void enable_datapath(struct s3c64xx_spi_driver_data *sdd, chcfg = readl(regs + S3C64XX_SPI_CH_CFG); chcfg &= ~S3C64XX_SPI_CH_TXCH_ON; + if(sdd->cur_bpw == 32) { + /* For word transfer we need to swap bytes */ + u32 swapcfg = (S3C64XX_SPI_SWAP_TX_EN | S3C64XX_SPI_SWAP_TX_BYTE | + S3C64XX_SPI_SWAP_TX_HALF_WORD | + S3C64XX_SPI_SWAP_RX_EN | + S3C64XX_SPI_SWAP_RX_BYTE | + S3C64XX_SPI_SWAP_RX_HALF_WORD); + writel(swapcfg, regs + S3C64XX_SPI_SWAP_CFG); + } else + writel(0, regs + S3C64XX_SPI_SWAP_CFG); + if (dma_mode) { chcfg &= ~S3C64XX_SPI_CH_RXCH_ON; } else { @@ -905,19 +916,16 @@ static int s3c64xx_spi_transfer_one_message(struct spi_master *master, bpw = xfer->bits_per_word; speed = xfer->speed_hz ? : spi->max_speed_hz; - if (xfer->len % (bpw / 8)) { - dev_err(&spi->dev, - "Xfer length(%u) not a multiple of word size(%u)\n", - xfer->len, bpw / 8); - status = -EIO; - goto out; + if (speed != sdd->cur_speed) { + sdd->cur_speed = speed; } - if (bpw != sdd->cur_bpw || speed != sdd->cur_speed) { + if (xfer->len % (bpw / 8)) + sdd->cur_bpw = 8; + else sdd->cur_bpw = bpw; - sdd->cur_speed = speed; - s3c64xx_spi_config(sdd); - } + + s3c64xx_spi_config(sdd); /* Polling method for xfers not bigger than FIFO capacity */ use_dma = 0;