From patchwork Thu Feb 12 12:07:27 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien BOUIN X-Patchwork-Id: 5818901 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 7AA64BF440 for ; Thu, 12 Feb 2015 12:08:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9C70F201C0 for ; Thu, 12 Feb 2015 12:08:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C0D9020148 for ; Thu, 12 Feb 2015 12:08:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932193AbbBLMIY (ORCPT ); Thu, 12 Feb 2015 07:08:24 -0500 Received: from mail-we0-f173.google.com ([74.125.82.173]:55466 "EHLO mail-we0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755412AbbBLMH5 (ORCPT ); Thu, 12 Feb 2015 07:07:57 -0500 Received: by mail-we0-f173.google.com with SMTP id w55so9601603wes.4; Thu, 12 Feb 2015 04:07:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=jDJBBE2N+Y3XIyb6oEfrjUnqFpqVV33SnmKV0kG2+lU=; b=sxZh9Xj+L55IXXL2UoB0WUJZTjbaPCkG5Hf3Jm9aEqF8ViukBtwAZsGofjy6f0K7Un JTSCTHB52UbjHNj0JHeU9gup/VfE3601GjRYLbYRGEmW+O91GofdEFvylSvCYXg/zeA1 Dafk7pBI6jDidvU6eZisloSIrftb3Z0Pz7kLaUYfqPhERS5pu4JODw0IA9y1RszdWKky mnIRA84UK09fsgInW4/CoLfWp9CqTw1sTakAF5c115Jyw3NwZLA6Mo6btNXytU7FGptN A+NDTRK/7ET12optj9Vw3uzzBqlWKILxZGw47tWx+9LQtCuzIb/w3OlL1IImxdmIA98x IBJg== X-Received: by 10.180.82.129 with SMTP id i1mr1266019wiy.1.1423742876200; Thu, 12 Feb 2015 04:07:56 -0800 (PST) Received: from bouin-3screens.castel.fr (srvmail.castel.fr. [80.74.74.33]) by mx.google.com with ESMTPSA id ub1sm5398430wjc.43.2015.02.12.04.07.55 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Feb 2015 04:07:55 -0800 (PST) From: Aurelien BOUIN To: broonie@kernel.org Cc: festevam@gmail.com, linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, Aurelien BOUIN Subject: [PATCH 3/4] spi: imx: Chose DMA bits per word transfered Date: Thu, 12 Feb 2015 13:07:27 +0100 Message-Id: <1423742848-15369-3-git-send-email-a.bouin@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1423742848-15369-1-git-send-email-a.bouin@gmail.com> References: <1423742848-15369-1-git-send-email-a.bouin@gmail.com> Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_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 enable to give a parameter to device tree to set the number of bits per word the DMA uses in transfer In device tree you can specify fsl,spi-dma-bits-per-word = <16>; in the ecspi section Signed-off-by: Aurelien BOUIN diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c index f8400b2..9690d57 100644 --- a/drivers/spi/spi-imx.c +++ b/drivers/spi/spi-imx.c @@ -110,6 +110,7 @@ struct spi_imx_data { u32 rxt_wml; struct completion dma_rx_completion; struct completion dma_tx_completion; + unsigned int dma_bits_per_word; const struct spi_imx_devtype_data *devtype_data; int chipselect[0]; @@ -825,6 +826,7 @@ static int spi_imx_sdma_init(struct device *dev, struct spi_imx_data *spi_imx, { struct dma_slave_config slave_config = {}; int ret; + enum dma_slave_buswidth dsb_default = DMA_SLAVE_BUSWIDTH_1_BYTE; /* use pio mode for i.mx6dl chip TKT238285 */ if (of_machine_is_compatible("fsl,imx6dl")) @@ -837,10 +839,20 @@ static int spi_imx_sdma_init(struct device *dev, struct spi_imx_data *spi_imx, ret = -EINVAL; goto err; } - + switch (spi_imx->dma_bits_per_word) { + case 32: + dsb_default = DMA_SLAVE_BUSWIDTH_4_BYTES; + break; + case 16: + dsb_default = DMA_SLAVE_BUSWIDTH_2_BYTES; + break; + default: + dsb_default = DMA_SLAVE_BUSWIDTH_1_BYTE; + break; + } slave_config.direction = DMA_MEM_TO_DEV; slave_config.dst_addr = res->start + MXC_CSPITXDATA; - slave_config.dst_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE; + slave_config.dst_addr_width = dsb_default; slave_config.dst_maxburst = spi_imx_get_fifosize(spi_imx) / 2; ret = dmaengine_slave_config(master->dma_tx, &slave_config); if (ret) { @@ -858,7 +870,7 @@ static int spi_imx_sdma_init(struct device *dev, struct spi_imx_data *spi_imx, slave_config.direction = DMA_DEV_TO_MEM; slave_config.src_addr = res->start + MXC_CSPIRXDATA; - slave_config.src_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE; + slave_config.src_addr_width = dsb_default; slave_config.src_maxburst = spi_imx_get_fifosize(spi_imx) / 2; ret = dmaengine_slave_config(master->dma_rx, &slave_config); if (ret) { @@ -1083,7 +1095,7 @@ static int spi_imx_probe(struct platform_device *pdev) struct spi_master *master; struct spi_imx_data *spi_imx; struct resource *res; - int i, ret, num_cs; + int i, ret, num_cs, dma_bits_per_word = 8; if (!np && !mxc_platform_info) { dev_err(&pdev->dev, "can't get the platform data\n"); @@ -1138,6 +1150,11 @@ static int spi_imx_probe(struct platform_device *pdev) spi_imx->bitbang.master->prepare_message = spi_imx_prepare_message; spi_imx->bitbang.master->unprepare_message = spi_imx_unprepare_message; spi_imx->bitbang.master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH; + if (of_property_read_u32(np, "fsl,spi-dma-bits-per-word", + &dma_bits_per_word)) + spi_imx->dma_bits_per_word = dma_bits_per_word; + else + spi_imx->dma_bits_per_word = 8; init_completion(&spi_imx->xfer_done);