From patchwork Thu Sep 1 20:39:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Kaiser X-Patchwork-Id: 9309759 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 B78B560865 for ; Thu, 1 Sep 2016 21:31:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7F97B29406 for ; Thu, 1 Sep 2016 21:31:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 744422954D; Thu, 1 Sep 2016 21:31:18 +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 6F0602954E for ; Thu, 1 Sep 2016 21:31:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756843AbcIAVbJ (ORCPT ); Thu, 1 Sep 2016 17:31:09 -0400 Received: from botnar.kaiser.cx ([176.28.20.183]:49129 "EHLO botnar.kaiser.cx" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756021AbcIAVbG (ORCPT ); Thu, 1 Sep 2016 17:31:06 -0400 X-Greylist: delayed 1799 seconds by postgrey-1.27 at vger.kernel.org; Thu, 01 Sep 2016 17:31:06 EDT Received: from p4fd7885c.dip0.t-ipconnect.de ([79.215.136.92] helo=reykholt.kaiser.cx) by botnar.kaiser.cx with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.72) (envelope-from ) id 1bfYmG-00073Z-Hk; Thu, 01 Sep 2016 22:40:00 +0200 Received: from martin by reykholt.kaiser.cx with local (Exim 4.80) (envelope-from ) id 1bfYmE-000259-1A; Thu, 01 Sep 2016 22:39:58 +0200 Date: Thu, 1 Sep 2016 22:39:58 +0200 From: Martin Kaiser To: Mark Brown Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] spi: imx: support loopback mode on imx35 Message-ID: <20160901203957.GA7994@reykholt.kaiser.cx> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) 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 imx35 and compatible chipsets support loopback mode by setting a loopback control bit in the test register. Make this setting available for data transfers, similar to what we do for imx51. Signed-off-by: Martin Kaiser --- drivers/spi/spi-imx.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c index 5cc72be..53e7a32 100644 --- a/drivers/spi/spi-imx.c +++ b/drivers/spi/spi-imx.c @@ -455,6 +455,9 @@ static void mx51_ecspi_reset(struct spi_imx_data *spi_imx) #define MX31_CSPISTATUS 0x14 #define MX31_STATUS_RR (1 << 3) +#define MX31_CSPI_TESTREG 0x1C +#define MX31_TEST_LBC (1 << 14) + /* These functions also work for the i.MX35, but be aware that * the i.MX35 has a slightly different register layout for bits * we do not use here. @@ -510,6 +513,13 @@ static int mx31_config(struct spi_device *spi, struct spi_imx_config *config) writel(reg, spi_imx->base + MXC_CSPICTRL); + reg = readl(spi_imx->base + MX31_CSPI_TESTREG); + if (spi->mode & SPI_LOOP) + reg |= MX31_TEST_LBC; + else + reg &= ~MX31_TEST_LBC; + writel(reg, spi_imx->base + MX31_CSPI_TESTREG); + return 0; } @@ -1186,7 +1196,7 @@ 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 (is_imx51_ecspi(spi_imx)) + if (is_imx35_cspi(spi_imx) || is_imx51_ecspi(spi_imx)) spi_imx->bitbang.master->mode_bits |= SPI_LOOP; init_completion(&spi_imx->xfer_done);