From patchwork Tue May 23 18:22:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 9743169 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6EEB3601C2 for ; Tue, 23 May 2017 18:22:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 62C6228420 for ; Tue, 23 May 2017 18:22:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 575642868D; Tue, 23 May 2017 18:22:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9D38628420 for ; Tue, 23 May 2017 18:22:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967150AbdEWSWy (ORCPT ); Tue, 23 May 2017 14:22:54 -0400 Received: from mezzanine.sirena.org.uk ([106.187.55.193]:45312 "EHLO mezzanine.sirena.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967131AbdEWSWx (ORCPT ); Tue, 23 May 2017 14:22:53 -0400 Received: from [2001:470:1f1d:6b5::3] (helo=debutante) by mezzanine.sirena.org.uk with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dDESC-0004hW-9v; Tue, 23 May 2017 18:22:46 +0000 Received: from broonie by debutante with local (Exim 4.89) (envelope-from ) id 1dDES9-00034A-G8; Tue, 23 May 2017 19:22:41 +0100 From: Mark Brown To: Sascha Hauer Cc: Mark Brown , linux-spi@vger.kernel.org, Jiada Wang , kernel@pengutronix.de, Mark Brown , Fabio Estevam , linux-spi@vger.kernel.org In-Reply-To: <20170523123827.22408-1-s.hauer@pengutronix.de> Message-Id: Date: Tue, 23 May 2017 19:22:41 +0100 X-SA-Exim-Connect-IP: 2001:470:1f1d:6b5::3 X-SA-Exim-Mail-From: broonie@sirena.org.uk Subject: Applied "spi: imx: Revert "spi: imx: dynamic burst length adjust for PIO mode"" to the spi tree X-SA-Exim-Version: 4.2.1 (built Mon, 26 Dec 2011 16:24:06 +0000) X-SA-Exim-Scanned: No (on mezzanine.sirena.org.uk); Unknown failure Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The patch spi: imx: Revert "spi: imx: dynamic burst length adjust for PIO mode" has been applied to the spi tree at git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark From 09b3ed2d5916f270ffbc5d002a2196ededf5ec7e Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Tue, 23 May 2017 14:38:27 +0200 Subject: [PATCH] spi: imx: Revert "spi: imx: dynamic burst length adjust for PIO mode" This reverts commits 8d4a6cad7adb3ddac32cd52635f20e11de11a658 and 179547e143e773f9f866ad3536275ab627711f3a. Besides the problems already found with this patch it also modifies the spi transfer tx_buf in spi_imx_u32_swap_u8() and spi_imx_u32_swap_u16(). This is hidden from the compiler with an explicit cast from const void* to u32*, so no warning is issued. Signed-off-by: Sascha Hauer Signed-off-by: Mark Brown --- drivers/spi/spi-imx.c | 163 +++----------------------------------------------- 1 file changed, 8 insertions(+), 155 deletions(-) diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c index 19b30cf7d2b7..b402530a7a9a 100644 --- a/drivers/spi/spi-imx.c +++ b/drivers/spi/spi-imx.c @@ -56,11 +56,9 @@ /* The maximum bytes that a sdma BD can transfer.*/ #define MAX_SDMA_BD_BYTES (1 << 15) -#define MX51_ECSPI_CTRL_MAX_BURST 512 struct spi_imx_config { unsigned int speed_hz; unsigned int bpw; - unsigned int len; }; enum spi_imx_devtype { @@ -99,14 +97,12 @@ struct spi_imx_data { unsigned int bytes_per_word; unsigned int spi_drctl; - unsigned int count, count_index; + unsigned int count; void (*tx)(struct spi_imx_data *); void (*rx)(struct spi_imx_data *); void *rx_buf; const void *tx_buf; unsigned int txfifo; /* number of words pushed in tx FIFO */ - unsigned int dynamic_burst, bpw_rx; - unsigned int bpw_w; /* DMA */ bool usedma; @@ -256,7 +252,6 @@ static bool spi_imx_can_dma(struct spi_master *master, struct spi_device *spi, #define MX51_ECSPI_CTRL_PREDIV_OFFSET 12 #define MX51_ECSPI_CTRL_CS(cs) ((cs) << 18) #define MX51_ECSPI_CTRL_BL_OFFSET 20 -#define MX51_ECSPI_CTRL_BL_MASK (0xfff << 20) #define MX51_ECSPI_CONFIG 0x0c #define MX51_ECSPI_CONFIG_SCLKPHA(cs) (1 << ((cs) + 0)) @@ -284,77 +279,6 @@ static bool spi_imx_can_dma(struct spi_master *master, struct spi_device *spi, #define MX51_ECSPI_TESTREG 0x20 #define MX51_ECSPI_TESTREG_LBC BIT(31) -static void spi_imx_u32_swap_u8(struct spi_transfer *transfer, u32 *buf) -{ - int i; - - if (!buf) - return; - - for (i = 0; i < transfer->len / 4; i++) - *(buf + i) = cpu_to_be32(*(buf + i)); -} - -static void spi_imx_u32_swap_u16(struct spi_transfer *transfer, u32 *buf) -{ - int i; - - if (!buf) - return; - - for (i = 0; i < transfer->len / 4; i++) { - u16 *temp = (u16 *)buf; - - *(temp + i * 2) = cpu_to_be16(*(temp + i * 2)); - *(temp + i * 2 + 1) = cpu_to_be16(*(temp + i * 2 + 1)); - - *(buf + i) = cpu_to_be32(*(buf + i)); - } -} - -static void spi_imx_buf_rx_swap(struct spi_imx_data *spi_imx) -{ - if (!spi_imx->bpw_rx) { - spi_imx_buf_rx_u32(spi_imx); - return; - } - - if (spi_imx->bpw_w == 1) - spi_imx_buf_rx_u8(spi_imx); - else if (spi_imx->bpw_w == 2) - spi_imx_buf_rx_u16(spi_imx); -} - -static void spi_imx_buf_tx_swap(struct spi_imx_data *spi_imx) -{ - u32 ctrl, val; - - if (spi_imx->count == spi_imx->count_index) { - spi_imx->count_index = spi_imx->count > sizeof(u32) ? - spi_imx->count % sizeof(u32) : 0; - ctrl = readl(spi_imx->base + MX51_ECSPI_CTRL); - ctrl &= ~MX51_ECSPI_CTRL_BL_MASK; - if (spi_imx->count >= sizeof(u32)) { - val = spi_imx->count - spi_imx->count_index; - } else { - val = spi_imx->bpw_w; - spi_imx->bpw_rx = 1; - } - ctrl |= ((val * 8 - 1) << MX51_ECSPI_CTRL_BL_OFFSET); - writel(ctrl, spi_imx->base + MX51_ECSPI_CTRL); - } - - if (spi_imx->count >= sizeof(u32)) { - spi_imx_buf_tx_u32(spi_imx); - return; - } - - if (spi_imx->bpw_w == 1) - spi_imx_buf_tx_u8(spi_imx); - else if (spi_imx->bpw_w == 2) - spi_imx_buf_tx_u16(spi_imx); -} - /* MX51 eCSPI */ static unsigned int mx51_ecspi_clkdiv(struct spi_imx_data *spi_imx, unsigned int fspi, unsigned int *fres) @@ -446,15 +370,7 @@ static int mx51_ecspi_config(struct spi_device *spi, /* set chip select to use */ ctrl |= MX51_ECSPI_CTRL_CS(spi->chip_select); - if (spi_imx->dynamic_burst) { - if (config->len > MX51_ECSPI_CTRL_MAX_BURST) - ctrl |= MX51_ECSPI_CTRL_BL_MASK; - else - ctrl |= (((config->len - config->len % 4) * 8 - 1) << - MX51_ECSPI_CTRL_BL_OFFSET); - } else { - ctrl |= (config->bpw - 1) << MX51_ECSPI_CTRL_BL_OFFSET; - } + ctrl |= (config->bpw - 1) << MX51_ECSPI_CTRL_BL_OFFSET; cfg |= MX51_ECSPI_CONFIG_SBBCTRL(spi->chip_select); @@ -889,8 +805,6 @@ static void spi_imx_push(struct spi_imx_data *spi_imx) while (spi_imx->txfifo < spi_imx_get_fifosize(spi_imx)) { if (!spi_imx->count) break; - if (spi_imx->txfifo && (spi_imx->count == spi_imx->count_index)) - break; spi_imx->tx(spi_imx); spi_imx->txfifo++; } @@ -981,12 +895,8 @@ static int spi_imx_setupxfer(struct spi_device *spi, struct spi_imx_config config; int ret; - spi_imx->dynamic_burst = 0; - spi_imx->bpw_rx = 0; - config.bpw = t ? t->bits_per_word : spi->bits_per_word; config.speed_hz = t ? t->speed_hz : spi->max_speed_hz; - config.len = t->len; if (!config.speed_hz) config.speed_hz = spi->max_speed_hz; @@ -995,32 +905,14 @@ static int spi_imx_setupxfer(struct spi_device *spi, /* Initialize the functions for transfer */ if (config.bpw <= 8) { - if (t->len >= sizeof(u32) && is_imx51_ecspi(spi_imx)) { - spi_imx->dynamic_burst = 1; - spi_imx->rx = spi_imx_buf_rx_swap; - spi_imx->tx = spi_imx_buf_tx_swap; - } else { - spi_imx->rx = spi_imx_buf_rx_u8; - spi_imx->tx = spi_imx_buf_tx_u8; - } + spi_imx->rx = spi_imx_buf_rx_u8; + spi_imx->tx = spi_imx_buf_tx_u8; } else if (config.bpw <= 16) { - if (t->len >= sizeof(u32) && is_imx51_ecspi(spi_imx)) { - spi_imx->dynamic_burst = 1; - spi_imx->rx = spi_imx_buf_rx_swap; - spi_imx->tx = spi_imx_buf_tx_swap; - } else { - spi_imx->rx = spi_imx_buf_rx_u16; - spi_imx->tx = spi_imx_buf_tx_u16; - } + spi_imx->rx = spi_imx_buf_rx_u16; + spi_imx->tx = spi_imx_buf_tx_u16; } else { - if (is_imx51_ecspi(spi_imx)) { - spi_imx->dynamic_burst = 1; - spi_imx->rx = spi_imx_buf_rx_swap; - spi_imx->tx = spi_imx_buf_tx_swap; - } else { - spi_imx->rx = spi_imx_buf_rx_u32; - spi_imx->tx = spi_imx_buf_tx_u32; - } + spi_imx->rx = spi_imx_buf_rx_u32; + spi_imx->tx = spi_imx_buf_tx_u32; } if (spi_imx_can_dma(spi_imx->bitbang.master, spi, t)) @@ -1028,8 +920,6 @@ static int spi_imx_setupxfer(struct spi_device *spi, else spi_imx->usedma = 0; - spi_imx->bpw_w = DIV_ROUND_UP(config.bpw, 8); - if (spi_imx->usedma) { ret = spi_imx_dma_configure(spi->master, spi_imx_bytes_per_word(config.bpw)); @@ -1204,27 +1094,6 @@ static int spi_imx_pio_transfer(struct spi_device *spi, spi_imx->count = transfer->len; spi_imx->txfifo = 0; - if (spi_imx->dynamic_burst) { - if (spi_imx->count > MX51_ECSPI_CTRL_MAX_BURST) - spi_imx->count_index = spi_imx->count % - MX51_ECSPI_CTRL_MAX_BURST; - else - spi_imx->count_index = spi_imx->count % sizeof(u32); - - switch (spi_imx->bpw_w) { - case 1: - spi_imx_u32_swap_u8(transfer, - (u32 *)transfer->tx_buf); - break; - case 2: - spi_imx_u32_swap_u16(transfer, - (u32 *)transfer->tx_buf); - break; - default: - break; - } - } - reinit_completion(&spi_imx->xfer_done); spi_imx_push(spi_imx); @@ -1241,22 +1110,6 @@ static int spi_imx_pio_transfer(struct spi_device *spi, return -ETIMEDOUT; } - if (spi_imx->dynamic_burst) { - switch (spi_imx->bpw_w) { - case 1: - spi_imx_u32_swap_u8(transfer, - (u32 *)transfer->rx_buf); - break; - case 2: - spi_imx_u32_swap_u16(transfer, - (u32 *)transfer->rx_buf); - break; - default: - break; - } - spi_imx->dynamic_burst = 0; - } - return transfer->len; }