From patchwork Tue Nov 22 07:01:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sanchayan X-Patchwork-Id: 9440555 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 C797A600BA for ; Tue, 22 Nov 2016 07:11:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BB07A2844B for ; Tue, 22 Nov 2016 07:11:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AFDD42846D; Tue, 22 Nov 2016 07:11:09 +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.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 5DEDF2844B for ; Tue, 22 Nov 2016 07:11:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754915AbcKVHKn (ORCPT ); Tue, 22 Nov 2016 02:10:43 -0500 Received: from mail-pg0-f67.google.com ([74.125.83.67]:36336 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754413AbcKVHKk (ORCPT ); Tue, 22 Nov 2016 02:10:40 -0500 Received: by mail-pg0-f67.google.com with SMTP id x23so1244129pgx.3; Mon, 21 Nov 2016 23:10:40 -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 :in-reply-to:references; bh=lXZlhGVKBwifj1OplE41KrL5Z+EU3XBRXKVc4uMNBtE=; b=L6aLB4MjEQw5acD0zRgp99ZpuzaK3M/99XBrTtQuwlgLB09yC6OXwjj+ZQJHvPzKxL aODmD+KasqbDt+17NcPHWfPLL5c9d7sANTpPJeJHwZ3j2awc46rMpRmV4KlJvKt1s0vc onciaL+nvzqqATsL5tSux3B4jJr9pAKDKU2PjOBN9yco8e7SnY24K2lNkjRexCGsqPAY 1oOsUJVJHZtSyJO7d6M4frIlTpYSUILM9kkfDHaHvc2u3GTFj7lBuMVyLFv5uhqUAeoo SRRkW4PGaTPJOK7pgJtiJxgOLPb5Nje78bHtgDN5575kLJoYigjniTU4tMafj0Jb6SiM KX3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=lXZlhGVKBwifj1OplE41KrL5Z+EU3XBRXKVc4uMNBtE=; b=Fm87fiwI9k8n5iqfjh1aTp964yto12clMs3xwxx5o6R3VP0l01cYkcDwdBMhFeHEIM EeVIKfJj2ZvrgkgTaKTDBehObzJkd4R5qDq0xCurBJHZxt8obsB5HWbNj22igBwxWRbo bxQkWc9YJLTl6Me/gnl5WG262I9EAA6u6ek26vAriPyKfija29KVB+lWJb7tOU9djCFy KUECUDNpLuzyF+Bq+BgapOEcfHNtTNkVZVvhouFubC5mum5PY+niepGFKLZMuZhtVI7r YBboK/KWVOA4MHszEVAUkgmReHG47CN2IlvCR+KAiWZ8U7p0AB4HWArUwtaun9S7pQVl CV8A== X-Gm-Message-State: AKaTC00HFNP5nLtV00Iv+0bOEAstbPNDuoXtHL7fS4smFYumZ7RLCQU+3WZ1UihkNQPbsg== X-Received: by 10.98.74.142 with SMTP id c14mr23644755pfj.139.1479798640072; Mon, 21 Nov 2016 23:10:40 -0800 (PST) Received: from localhost ([115.115.243.34]) by smtp.gmail.com with ESMTPSA id t21sm42320757pfa.1.2016.11.21.23.10.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 21 Nov 2016 23:10:39 -0800 (PST) From: Sanchayan Maity To: broonie@kernel.org Cc: stefan@agner.ch, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org, Sanchayan Maity Subject: [PATCH v3 2/3] spi: spi-fsl-dspi: Fix continuous selection format Date: Tue, 22 Nov 2016 12:31:31 +0530 Message-Id: X-Mailer: git-send-email 2.10.2 In-Reply-To: References: In-Reply-To: References: 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 Current DMA implementation was not handling the continuous selection format viz. SPI chip select would be deasserted even between sequential serial transfers. Use existing dspi_data_to_pushr function to restructure the transmit code path and set or reset the CONT bit on same lines as code path in EOQ mode does. This correctly implements continuous selection format while also correcting and cleaning up the transmit code path. Signed-off-by: Sanchayan Maity --- drivers/spi/spi-fsl-dspi.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/drivers/spi/spi-fsl-dspi.c b/drivers/spi/spi-fsl-dspi.c index 911aadb..8af3151 100644 --- a/drivers/spi/spi-fsl-dspi.c +++ b/drivers/spi/spi-fsl-dspi.c @@ -196,6 +196,8 @@ struct fsl_dspi { struct fsl_dspi_dma *dma; }; +static u32 dspi_data_to_pushr(struct fsl_dspi *dspi, int tx_word); + static inline int is_double_byte_mode(struct fsl_dspi *dspi) { unsigned int val; @@ -242,24 +244,15 @@ static int dspi_next_xfer_dma_submit(struct fsl_dspi *dspi) int time_left; int tx_word; int i; - u16 val; tx_word = is_double_byte_mode(dspi); - for (i = 0; i < dma->curr_xfer_len - 1; i++) { - val = tx_word ? *(u16 *) dspi->tx : *(u8 *) dspi->tx; - dspi->dma->tx_dma_buf[i] = - SPI_PUSHR_TXDATA(val) | SPI_PUSHR_PCS(dspi->cs) | - SPI_PUSHR_CTAS(0) | SPI_PUSHR_CONT; - dspi->tx += tx_word + 1; + for (i = 0; i < dma->curr_xfer_len; i++) { + dspi->dma->tx_dma_buf[i] = dspi_data_to_pushr(dspi, tx_word); + if ((dspi->cs_change) && (!dspi->len)) + dspi->dma->tx_dma_buf[i] &= ~SPI_PUSHR_CONT; } - val = tx_word ? *(u16 *) dspi->tx : *(u8 *) dspi->tx; - dspi->dma->tx_dma_buf[i] = SPI_PUSHR_TXDATA(val) | - SPI_PUSHR_PCS(dspi->cs) | - SPI_PUSHR_CTAS(0); - dspi->tx += tx_word + 1; - dma->tx_desc = dmaengine_prep_slave_single(dma->chan_tx, dma->tx_dma_phys, dma->curr_xfer_len * @@ -351,7 +344,6 @@ static int dspi_dma_xfer(struct fsl_dspi *dspi) curr_remaining_bytes -= dma->curr_xfer_len * word; if (curr_remaining_bytes < 0) curr_remaining_bytes = 0; - dspi->len = curr_remaining_bytes; } }