From patchwork Wed Oct 10 09:00:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Renner Berthing X-Patchwork-Id: 10634209 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 780F2679F for ; Wed, 10 Oct 2018 09:01:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6BAE1299B4 for ; Wed, 10 Oct 2018 09:01:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6923629AF3; Wed, 10 Oct 2018 09:01:52 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,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 155F5299B4 for ; Wed, 10 Oct 2018 09:01:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727562AbeJJQXC (ORCPT ); Wed, 10 Oct 2018 12:23:02 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:42788 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726741AbeJJQXC (ORCPT ); Wed, 10 Oct 2018 12:23:02 -0400 Received: by mail-lj1-f196.google.com with SMTP id y71-v6so4151006lje.9; Wed, 10 Oct 2018 02:01:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=joyn6OLBg1f4D+Fifxa/SS4Ke79l5wLNhvUf6HfLSis=; b=UwzqO7dLXaqGsobplb0rRenHcymcWD4t0o/wLYke1IE5ecHCzgaE4iY+GsfUTF+n7L BudA0/q5lMD8Y9t1A1Iy2/yzawrWgZmw6CU8gNVGVmFifPZ39+2Rg1aQFkKu7yfccP2l EMhCNFegmYEuTK3e/Eox9SiCKC+Kjd2b8nODMY284WUNvN7gGmA5PiHnpYcsPNpZta0M ynwl+LMhMYW7uIjei+JdBM7p+CuZ37+LJRIZv0JtsO+oKYgF2htYdtXGHBBn2Cr5UHw9 2pp7uKSNegWGr5y0E1w+qgd1I2UTH+D818xRFQUclIWuuHhlR4rJ9rlsfg2QnqICPM4m yazA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=joyn6OLBg1f4D+Fifxa/SS4Ke79l5wLNhvUf6HfLSis=; b=spqODZSIwRxTLuF03BBngadbSydEyjTsVf7LLXcscIKyA5qg/Z4aNTvyOvb3VgPfLO suSKo4gkNiDA0UnTmXEfna8UD8dwf+nRbPYiPJ/XHMXJSG9XWsJvRBiu1g/o8rWlOgRd JP61fVnYdsQ9VH/QpfVg3FPtX6s8uGv6LsnENITISLFov8vUgJ1CX4NbUSG/D0OrdUTc sm2lz604p5ENCPqfs0WcoA4K0+Pj++7Bo5mopq+1z+tCgUDxBuRXmS/hzPfRQQVI4p4v rW+nGn00ga7O3Q9gBru1yTw10DQjT7bpUOyRoKA3TAIkjbXtzWC/RekiCb9IVWhVMnrv to6w== X-Gm-Message-State: ABuFfohVWgAG7/A0aZFPNTLSwTHBqkMt61dz/joOl/9LdKWqpraBRwkC Sr0NaRkB9r4feYUXfFdGE5/8WVDB10o= X-Google-Smtp-Source: ACcGV60CUCC4NeYdYDziVaGp4qNnsIFv551K06yJPnVj2rcCu4FGrg18xdg4WZDUVlp6O8cwMey8tQ== X-Received: by 2002:a2e:4751:: with SMTP id u78-v6mr9503679lja.72.1539162106471; Wed, 10 Oct 2018 02:01:46 -0700 (PDT) Received: from localhost.localdomain ([5.57.50.195]) by smtp.gmail.com with ESMTPSA id q2-v6sm2150078lfc.67.2018.10.10.02.01.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Oct 2018 02:01:45 -0700 (PDT) From: Emil Renner Berthing To: linux-rockchip@lists.infradead.org Cc: Emil Renner Berthing , Rob Herring , Mark Rutland , Heiko Stuebner , Mark Brown , Enric Balletbo i Serra , Brian Norris , Douglas Anderson , Shunqian Zheng , Nickey Yang , Klaus Goger , Randy Li , Chris Zhong , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org, Huibin Hong Subject: [PATCH 1/7] spi: rockchip: initialize dma_slave_config properly Date: Wed, 10 Oct 2018 11:00:32 +0200 Message-Id: <20181010090038.20834-2-kernel@esmil.dk> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181010090038.20834-1-kernel@esmil.dk> References: <20181010090038.20834-1-kernel@esmil.dk> MIME-Version: 1.0 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 From: Huibin Hong The rxconf and txconf structs are allocated on the stack, so make sure we zero them before filling out the relevant fields. Signed-off-by: Huibin Hong Signed-off-by: Emil Renner Berthing --- drivers/spi/spi-rockchip.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/spi/spi-rockchip.c b/drivers/spi/spi-rockchip.c index fdcf3076681b..185bbdce62b1 100644 --- a/drivers/spi/spi-rockchip.c +++ b/drivers/spi/spi-rockchip.c @@ -445,6 +445,9 @@ static int rockchip_spi_prepare_dma(struct rockchip_spi *rs) struct dma_slave_config rxconf, txconf; struct dma_async_tx_descriptor *rxdesc, *txdesc; + memset(&rxconf, 0, sizeof(rxconf)); + memset(&txconf, 0, sizeof(txconf)); + spin_lock_irqsave(&rs->lock, flags); rs->state &= ~RXBUSY; rs->state &= ~TXBUSY; From patchwork Wed Oct 10 09:00:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Renner Berthing X-Patchwork-Id: 10634227 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 55B2169B1 for ; Wed, 10 Oct 2018 09:02:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4FDA02974B for ; Wed, 10 Oct 2018 09:02:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 44356298B0; Wed, 10 Oct 2018 09:02:24 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,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 DD4C329808 for ; Wed, 10 Oct 2018 09:02:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727563AbeJJQXD (ORCPT ); Wed, 10 Oct 2018 12:23:03 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:46517 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727285AbeJJQXC (ORCPT ); Wed, 10 Oct 2018 12:23:02 -0400 Received: by mail-lj1-f195.google.com with SMTP id x3-v6so4142101lji.13; Wed, 10 Oct 2018 02:01:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WLfksrGx9Fi3iwQ2Hcus/p3nhLsfw8qp1vLf53uAlEc=; b=RSejjSeZ6UhaZsuSXgI45iX6TxJslop2N/nCVC7r68sgO1ItowxP8go10qsOGLPH2k eGjBrF23DYoa/pAorVvh8BJfb3Tp5YbSYmI1IeRCUVP/s1PA8DacTRK75UiGUlVE67xr SukxDBWAQ0AhhSRfmBQtyn9aE00Dm6771pCaB15GT5tAg8b+Fk2R+aU0Nyi72CEufsyK CF8QVG8oCTTDQ+j/EkC92rmDN4m4ZfwQ717ZKhzTPUFZnat4x7bzvMokQ/KQhkDVFHQ7 lFu7X6bAI45pylKqJpBRYBEjjU6C8pbVhVc/xTGPAdEU0FEZSuutx04Mv2o3yBET/Pom QBlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=WLfksrGx9Fi3iwQ2Hcus/p3nhLsfw8qp1vLf53uAlEc=; b=k85Apm2dTmD/+ROeHLpyH+RTzyKDJEvILkST1GzZVrKuPMEaRbbCT4WJIj1HsIAxkV NItybGfL4QnHPbeqlAoAnypdoeQFnXqRHxR3jgNk576Yuv+GhbruIEhMKZIbBrzAsHTC eNSTiL8q2DQ+aa9gykr3DJrhvdvJ4PhRWcgWfCIw+mUxWSbv+wOjoHCxlbH+DRWlJNy/ 6st44QahszrdECAojgp6xbIX63Ctl66CagjKj4WBhZZiUVLnZUanZ3VEuAkCkqJNXmcF dhIcAou8PWm5E1bHxxyW3kh/vKeEAdrtwTva06lS5kMV7szshqaqUyKTnKcdbGoM/ZZJ xX1w== X-Gm-Message-State: ABuFfoijNVudwPFUlNBZ6SpvDdFJYfC3DTKlU0WwveMpFJ55k4n6H1Iz 5RHIZeqdNUi97wod5CzlmJQ= X-Google-Smtp-Source: ACcGV62ST321hoWnmn1sD9Ow7VAjsVxgvBxPdyTAUZv0RRCfGXsbbXLP0VSGim+kpzKLjBePZ/2W0w== X-Received: by 2002:a2e:87da:: with SMTP id v26-v6mr21776381ljj.13.1539162108528; Wed, 10 Oct 2018 02:01:48 -0700 (PDT) Received: from localhost.localdomain ([5.57.50.195]) by smtp.gmail.com with ESMTPSA id q2-v6sm2150078lfc.67.2018.10.10.02.01.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Oct 2018 02:01:47 -0700 (PDT) From: Emil Renner Berthing To: linux-rockchip@lists.infradead.org Cc: Emil Renner Berthing , Rob Herring , Mark Rutland , Heiko Stuebner , Mark Brown , Enric Balletbo i Serra , Brian Norris , Douglas Anderson , Shunqian Zheng , Nickey Yang , Klaus Goger , Randy Li , Chris Zhong , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org, Huibin Hong Subject: [PATCH 2/7] spi: rockchip: adjust dma watermark and burstlen Date: Wed, 10 Oct 2018 11:00:33 +0200 Message-Id: <20181010090038.20834-3-kernel@esmil.dk> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181010090038.20834-1-kernel@esmil.dk> References: <20181010090038.20834-1-kernel@esmil.dk> MIME-Version: 1.0 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 From: Huibin Hong Signal tx dma when spi fifo is less than half full, and limit tx bursts to half the fifo length. Clamp rx burst length to 1 to avoid alignment issues. Signed-off-by: Huibin Hong Signed-off-by: Emil Renner Berthing --- drivers/spi/spi-rockchip.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/spi/spi-rockchip.c b/drivers/spi/spi-rockchip.c index 185bbdce62b1..ede3002215cd 100644 --- a/drivers/spi/spi-rockchip.c +++ b/drivers/spi/spi-rockchip.c @@ -458,10 +458,7 @@ static int rockchip_spi_prepare_dma(struct rockchip_spi *rs) rxconf.direction = rs->dma_rx.direction; rxconf.src_addr = rs->dma_rx.addr; rxconf.src_addr_width = rs->n_bytes; - if (rs->dma_caps.max_burst > 4) - rxconf.src_maxburst = 4; - else - rxconf.src_maxburst = 1; + rxconf.src_maxburst = 1; dmaengine_slave_config(rs->dma_rx.ch, &rxconf); rxdesc = dmaengine_prep_slave_sg( @@ -480,10 +477,7 @@ static int rockchip_spi_prepare_dma(struct rockchip_spi *rs) txconf.direction = rs->dma_tx.direction; txconf.dst_addr = rs->dma_tx.addr; txconf.dst_addr_width = rs->n_bytes; - if (rs->dma_caps.max_burst > 4) - txconf.dst_maxburst = 4; - else - txconf.dst_maxburst = 1; + txconf.dst_maxburst = rs->fifo_len / 2; dmaengine_slave_config(rs->dma_tx.ch, &txconf); txdesc = dmaengine_prep_slave_sg( @@ -581,7 +575,7 @@ static void rockchip_spi_config(struct rockchip_spi *rs) writel_relaxed(rs->fifo_len / 2 - 1, rs->regs + ROCKCHIP_SPI_TXFTLR); writel_relaxed(rs->fifo_len / 2 - 1, rs->regs + ROCKCHIP_SPI_RXFTLR); - writel_relaxed(0, rs->regs + ROCKCHIP_SPI_DMATDLR); + writel_relaxed(rs->fifo_len / 2 - 1, rs->regs + ROCKCHIP_SPI_DMATDLR); writel_relaxed(0, rs->regs + ROCKCHIP_SPI_DMARDLR); writel_relaxed(dmacr, rs->regs + ROCKCHIP_SPI_DMACR); From patchwork Wed Oct 10 09:00:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Renner Berthing X-Patchwork-Id: 10634221 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E013A13AD for ; Wed, 10 Oct 2018 09:02:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2740729808 for ; Wed, 10 Oct 2018 09:02:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1B62A298D7; Wed, 10 Oct 2018 09:02:20 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,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 AC69229808 for ; Wed, 10 Oct 2018 09:02:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727610AbeJJQXE (ORCPT ); Wed, 10 Oct 2018 12:23:04 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:43819 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727554AbeJJQXE (ORCPT ); Wed, 10 Oct 2018 12:23:04 -0400 Received: by mail-lj1-f196.google.com with SMTP id r8-v6so4161115ljc.10; Wed, 10 Oct 2018 02:01:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=J2OCDbqMb6nYqZMgYt5ZgfyBJjth2xz5R26iqEUWcAQ=; b=hAbxJ1ufKoTUfC9+bybFXqMl6xW9gPx+FObVDUNTyVkBcCW9ztLNHOjb5WAK1mDd8l zm3E4wnDrAjX8ToF6eRABtTHdUWplLFNXscwkbjfH4QH/GizXljSYTlfMwMtdhluEyyJ FOsChJObB6cZu8imfx9BkC4NZ/SSJpAJAGtabZqlEI9TxiMdf8LHGzvBt4kMO89tdHL7 NkWfhJFpfbamQxjph9JI3J5hbtFclGIUKdppPhsnIs0WL+jF/7GT+h8sp8is0fXnYOtX OL3Z+gQiWYFbmLxmVuLuUJEG4yL2CPX8KGmk5vPEkozPLz7sU7LmYvlzfTI35VfO4lhO OiMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=J2OCDbqMb6nYqZMgYt5ZgfyBJjth2xz5R26iqEUWcAQ=; b=Y9gbO2fyMRFXyS2UyqLLN/u/oWb+JdpzDXYgKCO3f5JuE9/lVO+F74p1jIVrR6JG2j EktW0purR6KqxdE1vPI8r3gF6xqnezb5OFqiaI/CI8dl6Eo6iI0L6Ru1yh2ktUFIngi/ 3WMe43bzFid+wVO01OIXb/JtNoCVD8Z/84ukis/lOplwN/tr5unAWeqdgbmKtDGz3j4k 3gLcHBUYPBa6RoQra87ks7552SrUyDpYnkZ9bbBh6Xb5Jeic4E34T7FOaerV6dKHeH4h UIkrzYid2aP4FIpLen6Pkyt9P1w+eG60geVfxAHdXYsiS3Ev5FTqNtF4JvNzoQFRKjkP IEsw== X-Gm-Message-State: ABuFfohZvOrMYeWrkZ/D2MUQhItParQG01ARS2ZexzvzOimux8HU/yjU eXUYr0VfnRPNwbOf/Ejs+1g= X-Google-Smtp-Source: ACcGV63uwLPLZdfv3hnbQRd0TrjuL4yIGVC5cnIviIAM0Gehi8XYdbWm1+MDo/RYkKayofZmOx7GbA== X-Received: by 2002:a2e:6e08:: with SMTP id j8-v6mr16663276ljc.61.1539162110537; Wed, 10 Oct 2018 02:01:50 -0700 (PDT) Received: from localhost.localdomain ([5.57.50.195]) by smtp.gmail.com with ESMTPSA id q2-v6sm2150078lfc.67.2018.10.10.02.01.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Oct 2018 02:01:49 -0700 (PDT) From: Emil Renner Berthing To: linux-rockchip@lists.infradead.org Cc: Emil Renner Berthing , Rob Herring , Mark Rutland , Heiko Stuebner , Mark Brown , Enric Balletbo i Serra , Brian Norris , Douglas Anderson , Shunqian Zheng , Nickey Yang , Klaus Goger , Randy Li , Chris Zhong , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org Subject: [PATCH 3/7] arm64: dts: rockchip: add rk3399 SPI DMAs Date: Wed, 10 Oct 2018 11:00:34 +0200 Message-Id: <20181010090038.20834-4-kernel@esmil.dk> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181010090038.20834-1-kernel@esmil.dk> References: <20181010090038.20834-1-kernel@esmil.dk> MIME-Version: 1.0 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 Add spi dma channels as specified by the rk3399 TRM. Signed-off-by: Emil Renner Berthing --- arch/arm64/boot/dts/rockchip/rk3399.dtsi | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/arm64/boot/dts/rockchip/rk3399.dtsi b/arch/arm64/boot/dts/rockchip/rk3399.dtsi index c88e603396f6..c11b5ae6f1ad 100644 --- a/arch/arm64/boot/dts/rockchip/rk3399.dtsi +++ b/arch/arm64/boot/dts/rockchip/rk3399.dtsi @@ -653,6 +653,8 @@ clocks = <&cru SCLK_SPI0>, <&cru PCLK_SPI0>; clock-names = "spiclk", "apb_pclk"; interrupts = ; + dmas = <&dmac_peri 10>, <&dmac_peri 11>; + dma-names = "tx", "rx"; pinctrl-names = "default"; pinctrl-0 = <&spi0_clk &spi0_tx &spi0_rx &spi0_cs0>; #address-cells = <1>; @@ -666,6 +668,8 @@ clocks = <&cru SCLK_SPI1>, <&cru PCLK_SPI1>; clock-names = "spiclk", "apb_pclk"; interrupts = ; + dmas = <&dmac_peri 12>, <&dmac_peri 13>; + dma-names = "tx", "rx"; pinctrl-names = "default"; pinctrl-0 = <&spi1_clk &spi1_tx &spi1_rx &spi1_cs0>; #address-cells = <1>; @@ -679,6 +683,8 @@ clocks = <&cru SCLK_SPI2>, <&cru PCLK_SPI2>; clock-names = "spiclk", "apb_pclk"; interrupts = ; + dmas = <&dmac_peri 14>, <&dmac_peri 15>; + dma-names = "tx", "rx"; pinctrl-names = "default"; pinctrl-0 = <&spi2_clk &spi2_tx &spi2_rx &spi2_cs0>; #address-cells = <1>; @@ -692,6 +698,8 @@ clocks = <&cru SCLK_SPI4>, <&cru PCLK_SPI4>; clock-names = "spiclk", "apb_pclk"; interrupts = ; + dmas = <&dmac_peri 18>, <&dmac_peri 19>; + dma-names = "tx", "rx"; pinctrl-names = "default"; pinctrl-0 = <&spi4_clk &spi4_tx &spi4_rx &spi4_cs0>; #address-cells = <1>; @@ -705,6 +713,8 @@ clocks = <&cru SCLK_SPI5>, <&cru PCLK_SPI5>; clock-names = "spiclk", "apb_pclk"; interrupts = ; + dmas = <&dmac_bus 8>, <&dmac_bus 9>; + dma-names = "tx", "rx"; pinctrl-names = "default"; pinctrl-0 = <&spi5_clk &spi5_tx &spi5_rx &spi5_cs0>; power-domains = <&power RK3399_PD_SDIOAUDIO>; From patchwork Wed Oct 10 09:00:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Renner Berthing X-Patchwork-Id: 10634219 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F1B9F17E1 for ; Wed, 10 Oct 2018 09:02:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4D2C32974B for ; Wed, 10 Oct 2018 09:02:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 40B05298B0; Wed, 10 Oct 2018 09:02: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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,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 BC6552974B for ; Wed, 10 Oct 2018 09:02:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727640AbeJJQXH (ORCPT ); Wed, 10 Oct 2018 12:23:07 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:43822 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727615AbeJJQXG (ORCPT ); Wed, 10 Oct 2018 12:23:06 -0400 Received: by mail-lj1-f195.google.com with SMTP id r8-v6so4161222ljc.10; Wed, 10 Oct 2018 02:01:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KG0sdeNKejQuoulTZccIXDqy9239NiodF80G4qiM8YQ=; b=dwX9tbl84V4YOiGml1DAurWDeR8exFtugbPJNbxcT3UPtyFENSkRyU7ZEQo4JxO3zW LL3mP7Pwto6nYU5Rnv1WinEOVonO69hBozgBT71UJrGcC8lEGSjSIo+IjfAko3INSbWk t79mekUZ75iYa+X6RUO4Iyh0xOxpAu+yAjTWl4ztfjMBkfvbq01jf0ETYt0KWnXJ1Gir UZqORd56eG+GrRYSVcuXJ3uzesS8A4+ya28Fywns7SwZ39Tci6LS2mGP7OoXfm2q2ELm IMalUTbuGHegep8O24FSD48kBick+APcQfwuut7nbTTtFnqRPywJL1LbQ5030Wg3kFp3 i0Bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=KG0sdeNKejQuoulTZccIXDqy9239NiodF80G4qiM8YQ=; b=Le2sPOE5FAX/Xzn0R1TVnFYstE0FA7VLEiLRQ5wZB1e+nw5HjX6pDVnZTv4lqXRJ/v uFAP5qHlEp2/6Fuf2tTGRlduxXcuUk/uOOMpLNZtlrO7Xi+dm1brr222svCWknuDR6Fs Cyn1qIgzoEuCBhtznEAuyeV7alJMacxc/Bz2aMd82Nm6SFHnYOzG9JaEnkZTIJRZ7pq+ odof2b4QRnwARf93DRy0W/vksyFc8G9l2yAZb1Fk72ES9kULcn6iCgPlt14/eADoBgks SlZ85Wf9EGNPBngy5Cm4kPWmSdyflv9DM19kh4s5DxVAzrBgG0vtVeeImbaW/JsvZV51 sucA== X-Gm-Message-State: ABuFfoixmrSZ1+b06XtOVDiSqSwJ8OcU2UjkHWdAwzFb5ijM+xPSAq0V xkrX1ACM56t87ltrn5PE6j4= X-Google-Smtp-Source: ACcGV63TMn627laop0LM3zRqknrAUhl3yFoTD9zz7aGaR1gtxHWXJT/rawTYEFsTs7pc0qLsOeK/Bw== X-Received: by 2002:a2e:8684:: with SMTP id l4-v6mr3079435lji.52.1539162112525; Wed, 10 Oct 2018 02:01:52 -0700 (PDT) Received: from localhost.localdomain ([5.57.50.195]) by smtp.gmail.com with ESMTPSA id q2-v6sm2150078lfc.67.2018.10.10.02.01.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Oct 2018 02:01:51 -0700 (PDT) From: Emil Renner Berthing To: linux-rockchip@lists.infradead.org Cc: Emil Renner Berthing , Rob Herring , Mark Rutland , Heiko Stuebner , Mark Brown , Enric Balletbo i Serra , Brian Norris , Douglas Anderson , Shunqian Zheng , Nickey Yang , Klaus Goger , Randy Li , Chris Zhong , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org Subject: [PATCH 4/7] spi: rockchip: remove unneeded dma_caps Date: Wed, 10 Oct 2018 11:00:35 +0200 Message-Id: <20181010090038.20834-5-kernel@esmil.dk> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181010090038.20834-1-kernel@esmil.dk> References: <20181010090038.20834-1-kernel@esmil.dk> MIME-Version: 1.0 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 We no longer need the dma_caps since the dma driver already clamps the burst length to the hardware limit, so don't request and store dma_caps in device data. Signed-off-by: Emil Renner Berthing --- drivers/spi/spi-rockchip.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/spi/spi-rockchip.c b/drivers/spi/spi-rockchip.c index ede3002215cd..85358f96f78f 100644 --- a/drivers/spi/spi-rockchip.c +++ b/drivers/spi/spi-rockchip.c @@ -207,7 +207,6 @@ struct rockchip_spi { struct sg_table rx_sg; struct rockchip_spi_dma_data dma_rx; struct rockchip_spi_dma_data dma_tx; - struct dma_slave_caps dma_caps; }; static inline void spi_enable_chip(struct rockchip_spi *rs, int enable) @@ -777,7 +776,6 @@ static int rockchip_spi_probe(struct platform_device *pdev) } if (rs->dma_tx.ch && rs->dma_rx.ch) { - dma_get_slave_caps(rs->dma_rx.ch, &(rs->dma_caps)); rs->dma_tx.addr = (dma_addr_t)(mem->start + ROCKCHIP_SPI_TXDR); rs->dma_rx.addr = (dma_addr_t)(mem->start + ROCKCHIP_SPI_RXDR); rs->dma_tx.direction = DMA_MEM_TO_DEV; From patchwork Wed Oct 10 09:00:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Renner Berthing X-Patchwork-Id: 10634223 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EE8ED679F for ; Wed, 10 Oct 2018 09:02:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DDEE62974B for ; Wed, 10 Oct 2018 09:02:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D17DE298B0; Wed, 10 Oct 2018 09:02:16 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,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 9DD7029808 for ; Wed, 10 Oct 2018 09:02:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727615AbeJJQXK (ORCPT ); Wed, 10 Oct 2018 12:23:10 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:41659 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727554AbeJJQXI (ORCPT ); Wed, 10 Oct 2018 12:23:08 -0400 Received: by mail-lf1-f66.google.com with SMTP id q39-v6so3360620lfi.8; Wed, 10 Oct 2018 02:01:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TA2hMcCsbnh1Gd9P/xX1f3LeZx7iF3o9MbmxqKWAyAk=; b=GAUp9Mt9TeIwF5R3rhnYGJUHDiV1Qz/t25mpiYrjA7PbOKKMSHW7EKhtkKOpWCUhAf PgXHrmRcHzz/LkNWkS0Zkh7Ip7iuvohCFqt6tYxsCXYLJWI2G+hSjPwuaoYZAAuLc8d8 2bzul8GgZQpSk99e0+gRxhVqAs7Gkm8N3ogKc7HjOhktzC37/It4mMM109Vkeo4f5rG3 cTrhEBW6eEf+rPrhaJRpd+YyvvKyVkCpvBipg5TlFCICCqGH1ZoAUqnfQeEOAzEUtXqv 6tSMzRpzKvIuxBH2LPEAhxPEHQQitXWv6dMYnlC3031bXaoRn35v6V3TwLKH1W9zJ9dh wyrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=TA2hMcCsbnh1Gd9P/xX1f3LeZx7iF3o9MbmxqKWAyAk=; b=HMTBQ7GJvEGFFttIA9x9tHDOUc3o6A6MJvkKE7KJL/V744LmDwYrFKxzkUMUmXR9be /VIvdiGUPWyiqS/I40yD8QYSv0bmSSVoSNZUTUhsdI5+Hj//L9U9DvQUQ62AEtINhjNd RYqczrFq5kliUtgf657JAKcbPRtmsF1h53xrYmnDTlHR7onP/N/U531oBl+oWe/8avvt LwYmS82u6iwyJwTedRV0GMia2l16DpLpkvajbHqh76IJz7YXze74KLqlFY98zp5utyny YJEhhQ6RURQ2WdLbJkKIi2K1CdSzZku0ju/L11Wik+oLfLqxNEcdYM2HQPaCNZ0FSh0s EVAw== X-Gm-Message-State: ABuFfojaEoSCvvw3a3pgCzURWdPvnqAkPnonC49ZCWMsbPR9csgyt+lg lxsvPCSqNDZdzFgWgka2Fn4= X-Google-Smtp-Source: ACcGV60ge1yDJBedeGV3xpRir0WlnArmlOXWPzpPwkVMFxN7nAgLmV0NdMd+s4oszuybspptIpmt7A== X-Received: by 2002:a19:5205:: with SMTP id m5-v6mr17373907lfb.68.1539162114515; Wed, 10 Oct 2018 02:01:54 -0700 (PDT) Received: from localhost.localdomain ([5.57.50.195]) by smtp.gmail.com with ESMTPSA id q2-v6sm2150078lfc.67.2018.10.10.02.01.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Oct 2018 02:01:53 -0700 (PDT) From: Emil Renner Berthing To: linux-rockchip@lists.infradead.org Cc: Emil Renner Berthing , Rob Herring , Mark Rutland , Heiko Stuebner , Mark Brown , Enric Balletbo i Serra , Brian Norris , Douglas Anderson , Shunqian Zheng , Nickey Yang , Klaus Goger , Randy Li , Chris Zhong , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org Subject: [PATCH 5/7] spi: rockchip: mark use_dma as bool Date: Wed, 10 Oct 2018 11:00:36 +0200 Message-Id: <20181010090038.20834-6-kernel@esmil.dk> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181010090038.20834-1-kernel@esmil.dk> References: <20181010090038.20834-1-kernel@esmil.dk> MIME-Version: 1.0 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 driver data has a u32 field use_dma which is only ever used as a boolean, so change its type to reflect that. Signed-off-by: Emil Renner Berthing --- drivers/spi/spi-rockchip.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/spi/spi-rockchip.c b/drivers/spi/spi-rockchip.c index 85358f96f78f..1d8bf45304a5 100644 --- a/drivers/spi/spi-rockchip.c +++ b/drivers/spi/spi-rockchip.c @@ -202,7 +202,7 @@ struct rockchip_spi { bool cs_asserted[ROCKCHIP_SPI_MAX_CS_NUM]; - u32 use_dma; + bool use_dma; struct sg_table tx_sg; struct sg_table rx_sg; struct rockchip_spi_dma_data dma_rx; @@ -631,9 +631,9 @@ static int rockchip_spi_transfer_one( /* we need prepare dma before spi was enabled */ if (master->can_dma && master->can_dma(master, spi, xfer)) - rs->use_dma = 1; + rs->use_dma = true; else - rs->use_dma = 0; + rs->use_dma = false; rockchip_spi_config(rs); From patchwork Wed Oct 10 09:00:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Renner Berthing X-Patchwork-Id: 10634215 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E2A2869B1 for ; Wed, 10 Oct 2018 09:02:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A5128298B0 for ; Wed, 10 Oct 2018 09:02:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9889F298E9; Wed, 10 Oct 2018 09:02:11 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,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 1D1B4298B0 for ; Wed, 10 Oct 2018 09:02:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727722AbeJJQXK (ORCPT ); Wed, 10 Oct 2018 12:23:10 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:46412 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727493AbeJJQXK (ORCPT ); Wed, 10 Oct 2018 12:23:10 -0400 Received: by mail-lf1-f66.google.com with SMTP id z144-v6so3360073lff.13; Wed, 10 Oct 2018 02:01:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=H1wYnlUgcfpcHgJvA96w+RLcQIxhKmNVE/gaATftEyo=; b=YX8ftzhcGVUtGMcOs/GPlyGJsTa82qCFw1D3W72YFq761h+2Hsr0RJjEH4sTqiK1l5 v66ua5nUCMbl9V65AVPwJnGWwNaMzV55W52ry4HBkPOTOmx/OFwfC2ZPDPifnmhLtNbK +ix1bDrDrt6hqrrXKV/KXjNrKDfZl/dYalW01ivXIjxvGfVSEm5QXWjv14Qe2zvZDb+W xBy260e4sAtaXzV+WZB9lH0llVpqM7uKHQXaSRSwCLNZbZ6tbQXrBwLY+09RWml29U9s wSak9hExeKWvRovax5RBq/C7PiEbI+dAltZFngsZER4OlJ0rcIa8+Hd410GO6zICp1z8 GnSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=H1wYnlUgcfpcHgJvA96w+RLcQIxhKmNVE/gaATftEyo=; b=BCYW8JGzxSu8KuhLs9PuQmepBBvjZ2b6J7Daz5XaZ0HBkaq8mbnIQLUOhb0g6+LNZI LOcWMDHVOhCZCHBQHYbmMw5Z9R1zPyF0wdwhgKFwDIX1IWoyxbvEWn5zk5M2ou9cwqpa mbksPzcmWed9iQ21o4f8nz+Sfdsd6qOTCwFZy2tk1Czm6JSU4s5Ub1K/2ZMqo+NCcDjE LyFgH1tig0ryi5BEM5wEEMGU7QX9uPihbTcv3Wpr6EESqPRb+R9unOQAfOucxCz7p3bJ bL8TCP1lP3i8ivs+TcVpJ3zZnNXcbb1nF7h8tjF3gcfJP1NNV67Ocu9quTCSB12J6N6Z CHgw== X-Gm-Message-State: ABuFfohJaXI4WMTdPE6l0QG+q/cAffbNb0S2GMRd0XdX1aEYA7kz9MEB Ss7BPpQjmQ9KS/xi3Nqomn8= X-Google-Smtp-Source: ACcGV61n5/KgpPFjcr0D0nPzvbXlF4T9M+zjt0qq3dmcy0RcqcjAxHXWT86QY0K2fc8AGUc8OYuTqw== X-Received: by 2002:a19:5e5d:: with SMTP id z29-v6mr17336105lfi.110.1539162116518; Wed, 10 Oct 2018 02:01:56 -0700 (PDT) Received: from localhost.localdomain ([5.57.50.195]) by smtp.gmail.com with ESMTPSA id q2-v6sm2150078lfc.67.2018.10.10.02.01.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Oct 2018 02:01:55 -0700 (PDT) From: Emil Renner Berthing To: linux-rockchip@lists.infradead.org Cc: Emil Renner Berthing , Rob Herring , Mark Rutland , Heiko Stuebner , Mark Brown , Enric Balletbo i Serra , Brian Norris , Douglas Anderson , Shunqian Zheng , Nickey Yang , Klaus Goger , Randy Li , Chris Zhong , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org Subject: [PATCH 6/7] spi: rockchip: directly use direction constants Date: Wed, 10 Oct 2018 11:00:37 +0200 Message-Id: <20181010090038.20834-7-kernel@esmil.dk> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181010090038.20834-1-kernel@esmil.dk> References: <20181010090038.20834-1-kernel@esmil.dk> MIME-Version: 1.0 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 dma direction for the tx and rx dma channels never change, so just use the constants directly rather than storing them in device data. Signed-off-by: Emil Renner Berthing --- drivers/spi/spi-rockchip.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/spi/spi-rockchip.c b/drivers/spi/spi-rockchip.c index 1d8bf45304a5..1044849a352d 100644 --- a/drivers/spi/spi-rockchip.c +++ b/drivers/spi/spi-rockchip.c @@ -164,7 +164,6 @@ enum rockchip_ssi_type { struct rockchip_spi_dma_data { struct dma_chan *ch; - enum dma_transfer_direction direction; dma_addr_t addr; }; @@ -454,7 +453,7 @@ static int rockchip_spi_prepare_dma(struct rockchip_spi *rs) rxdesc = NULL; if (rs->rx) { - rxconf.direction = rs->dma_rx.direction; + rxconf.direction = DMA_DEV_TO_MEM; rxconf.src_addr = rs->dma_rx.addr; rxconf.src_addr_width = rs->n_bytes; rxconf.src_maxburst = 1; @@ -463,7 +462,7 @@ static int rockchip_spi_prepare_dma(struct rockchip_spi *rs) rxdesc = dmaengine_prep_slave_sg( rs->dma_rx.ch, rs->rx_sg.sgl, rs->rx_sg.nents, - rs->dma_rx.direction, DMA_PREP_INTERRUPT); + DMA_DEV_TO_MEM, DMA_PREP_INTERRUPT); if (!rxdesc) return -EINVAL; @@ -473,7 +472,7 @@ static int rockchip_spi_prepare_dma(struct rockchip_spi *rs) txdesc = NULL; if (rs->tx) { - txconf.direction = rs->dma_tx.direction; + txconf.direction = DMA_MEM_TO_DEV; txconf.dst_addr = rs->dma_tx.addr; txconf.dst_addr_width = rs->n_bytes; txconf.dst_maxburst = rs->fifo_len / 2; @@ -482,7 +481,7 @@ static int rockchip_spi_prepare_dma(struct rockchip_spi *rs) txdesc = dmaengine_prep_slave_sg( rs->dma_tx.ch, rs->tx_sg.sgl, rs->tx_sg.nents, - rs->dma_tx.direction, DMA_PREP_INTERRUPT); + DMA_MEM_TO_DEV, DMA_PREP_INTERRUPT); if (!txdesc) { if (rxdesc) dmaengine_terminate_sync(rs->dma_rx.ch); @@ -778,8 +777,6 @@ static int rockchip_spi_probe(struct platform_device *pdev) if (rs->dma_tx.ch && rs->dma_rx.ch) { rs->dma_tx.addr = (dma_addr_t)(mem->start + ROCKCHIP_SPI_TXDR); rs->dma_rx.addr = (dma_addr_t)(mem->start + ROCKCHIP_SPI_RXDR); - rs->dma_tx.direction = DMA_MEM_TO_DEV; - rs->dma_rx.direction = DMA_DEV_TO_MEM; master->can_dma = rockchip_spi_can_dma; master->dma_tx = rs->dma_tx.ch; From patchwork Wed Oct 10 09:00:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Renner Berthing X-Patchwork-Id: 10634211 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4C100679F for ; Wed, 10 Oct 2018 09:02:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 49FAC29808 for ; Wed, 10 Oct 2018 09:02:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3DDFA298DB; Wed, 10 Oct 2018 09:02: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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,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 D1444298E9 for ; Wed, 10 Oct 2018 09:02:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727748AbeJJQXO (ORCPT ); Wed, 10 Oct 2018 12:23:14 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:33473 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727195AbeJJQXN (ORCPT ); Wed, 10 Oct 2018 12:23:13 -0400 Received: by mail-lj1-f194.google.com with SMTP id z21-v6so4184682ljz.0; Wed, 10 Oct 2018 02:02:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ePO3J3Hd1Gc2W0qvUwMkU3g/clFK2S8VRj/cGZ2vxiw=; b=Wxz8jkliERYElnGwco0K1Yl3iGzfsXj1A1nhCiMSDG2jJDcmROdr+v1l466HUGXA2b T2J5pIYfiR6DmIWam1BCK0O86kUSeG6RvwAS125CFjUdu1cmvowqxjjLgsQvnTqgOLUN CDQpo3IETcxu1pHstWUkJEGtKHpppn9OZDhDbqKMpFdAMKv8EYE/4wM5AquM7eUed/bX VzEJZvQMAkzwRFTo3RQtSw9AtYpqyIj0Q0LTXl7DU93f2R6pTmFCNQJ0GsTh2IyJOKXY lQI7wEMi0PEhqvp7Ma/tutMg7mm9lGEijM6KhuhTW4HFGo4bOc6yDKxrYyRHZj6fQLok lSBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=ePO3J3Hd1Gc2W0qvUwMkU3g/clFK2S8VRj/cGZ2vxiw=; b=IveI5eHtDhFc9I9GDG6VLGDSp0UfsYRLxw76Toi/WUevFvzIbsJCCZ9sPqA2vS6ya/ uAojcdnWtAwlXStNUMudxJm+wxZIHC42b720gqnSRzOfhywwGeKY5N8sCN9ccwZIZHDa 6LWh8Pb1SKIqKnhUT93j7pwpDmERJSa32pvQvulg+9FGQtEOZX9Ru0BRU1nZpRysIVYi lD5SSwU+T5Kqz2C8p3PuoTDQKhyBMfRxRFUGa+wMxjGQcZnh6LCx1NXoyFASKLXMebWW QFjxJgp40o5b+UEwRyFKHQiOIW2KBD2IwKoUpOP7Iw92H6jv9K8ik4vASO0CtEu8p1Fs BtxQ== X-Gm-Message-State: ABuFfoigoW7xUCsq7BVpSlEtYmVb/BWC3iRmr0lWGKGaZf6sG55qXuTB bbj7gt95yDBpzj/RliDnYcc= X-Google-Smtp-Source: ACcGV61nKTMOfdCLyjWnbZfNQtan8+VXTMd/XDXAk6gvoVrlKz8lXWMJaK4qzuOaDYpiy96WzPnBCg== X-Received: by 2002:a2e:5c89:: with SMTP id q131-v6mr21223531ljb.119.1539162118533; Wed, 10 Oct 2018 02:01:58 -0700 (PDT) Received: from localhost.localdomain ([5.57.50.195]) by smtp.gmail.com with ESMTPSA id q2-v6sm2150078lfc.67.2018.10.10.02.01.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Oct 2018 02:01:57 -0700 (PDT) From: Emil Renner Berthing To: linux-rockchip@lists.infradead.org Cc: Emil Renner Berthing , Rob Herring , Mark Rutland , Heiko Stuebner , Mark Brown , Enric Balletbo i Serra , Brian Norris , Douglas Anderson , Shunqian Zheng , Nickey Yang , Klaus Goger , Randy Li , Chris Zhong , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org Subject: [PATCH 7/7] spi: rockchip: simplify spi enable logic Date: Wed, 10 Oct 2018 11:00:38 +0200 Message-Id: <20181010090038.20834-8-kernel@esmil.dk> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181010090038.20834-1-kernel@esmil.dk> References: <20181010090038.20834-1-kernel@esmil.dk> MIME-Version: 1.0 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 Let the dma/non-dma code paths handle the spi enable flag themselves. This removes some logic to determine if the flag should be turned on before or after dma and also don't leave the spi enabled if the dma path fails. Signed-off-by: Emil Renner Berthing --- drivers/spi/spi-rockchip.c | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/drivers/spi/spi-rockchip.c b/drivers/spi/spi-rockchip.c index 1044849a352d..51ef632bca52 100644 --- a/drivers/spi/spi-rockchip.c +++ b/drivers/spi/spi-rockchip.c @@ -379,6 +379,8 @@ static int rockchip_spi_pio_transfer(struct rockchip_spi *rs) { int remain = 0; + spi_enable_chip(rs, 1); + do { if (rs->tx) { remain = rs->tx_end - rs->tx; @@ -501,6 +503,8 @@ static int rockchip_spi_prepare_dma(struct rockchip_spi *rs) dma_async_issue_pending(rs->dma_rx.ch); } + spi_enable_chip(rs, 1); + if (txdesc) { spin_lock_irqsave(&rs->lock, flags); rs->state |= TXBUSY; @@ -509,7 +513,8 @@ static int rockchip_spi_prepare_dma(struct rockchip_spi *rs) dma_async_issue_pending(rs->dma_tx.ch); } - return 0; + /* 1 means the transfer is in progress */ + return 1; } static void rockchip_spi_config(struct rockchip_spi *rs) @@ -592,7 +597,6 @@ static int rockchip_spi_transfer_one( struct spi_device *spi, struct spi_transfer *xfer) { - int ret = 0; struct rockchip_spi *rs = spi_master_get_devdata(master); WARN_ON(readl_relaxed(rs->regs + ROCKCHIP_SPI_SSIENR) && @@ -636,24 +640,10 @@ static int rockchip_spi_transfer_one( rockchip_spi_config(rs); - if (rs->use_dma) { - if (rs->tmode == CR0_XFM_RO) { - /* rx: dma must be prepared first */ - ret = rockchip_spi_prepare_dma(rs); - spi_enable_chip(rs, 1); - } else { - /* tx or tr: spi must be enabled first */ - spi_enable_chip(rs, 1); - ret = rockchip_spi_prepare_dma(rs); - } - /* successful DMA prepare means the transfer is in progress */ - ret = ret ? ret : 1; - } else { - spi_enable_chip(rs, 1); - ret = rockchip_spi_pio_transfer(rs); - } + if (rs->use_dma) + return rockchip_spi_prepare_dma(rs); - return ret; + return rockchip_spi_pio_transfer(rs); } static bool rockchip_spi_can_dma(struct spi_master *master,