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: 9440565 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 771A7600BA for ; Tue, 22 Nov 2016 07:12:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 697B828462 for ; Tue, 22 Nov 2016 07:12:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5B42D2844B; Tue, 22 Nov 2016 07:12:45 +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=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1D5312844B for ; Tue, 22 Nov 2016 07:12:45 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1c95Eb-0005Sp-7l; Tue, 22 Nov 2016 07:11:17 +0000 Received: from mail-pg0-x243.google.com ([2607:f8b0:400e:c05::243]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1c95EH-0005ES-BB for linux-arm-kernel@lists.infradead.org; Tue, 22 Nov 2016 07:10:59 +0000 Received: by mail-pg0-x243.google.com with SMTP id p66so1245905pga.2 for ; 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=jWeJxJ5P/aapGARYi4bGFYhA56qVXCVuhhCYzD9jtO5lZ8oGG0wvFV+e3N1LXC9PRL gFb6O7ZCAgv25ThK/QEE9hNni/IxO4p2gBgK/X5RFNNjckxPbLP2+g5CHjnd+cEMeVG7 fRplrrv7KQcBZqrjv2TQxfXJLOKSqeAiL/pMVMU4qvIUiEaYwkw9YjrzEA5t/xgy9htq Uo2ybOM/xaEdzAB4hedW89k1IABFxXdiRI7gVlF16N1CVqvV25Fi81atLrexkDxxHWiX GhyxtvDZGqZ79TlbyZ6urefeXFpyfYNRJCZz1TtBj4Ig0pvSqZ1MOnVMhYl0VXZ5MoKY RKLA== X-Gm-Message-State: AKaTC005aCmMYHZEIl44xKHGSlY7e8zpe4VlgVp/LNhX1yIr9vhpuEf0T4/+I7Oanid0OA== 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 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: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161121_231057_678414_50BB32B7 X-CRM114-Status: GOOD ( 13.65 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sanchayan Maity , linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, stefan@agner.ch, linux-kernel@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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; } }