From patchwork Mon Jun 13 17:46:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Suchanek X-Patchwork-Id: 9173697 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 C6D1260573 for ; Mon, 13 Jun 2016 17:49:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BD5DF20855 for ; Mon, 13 Jun 2016 17:49:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B1E1D262AE; Mon, 13 Jun 2016 17:49:56 +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.2 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,RCVD_IN_DNSWL_MED autolearn=ham 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 3F81520855 for ; Mon, 13 Jun 2016 17:49:56 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1bCVyL-0004g0-6i; Mon, 13 Jun 2016 17:48:25 +0000 Received: from dec59.ruk.cuni.cz ([2001:718:1e03:4::11]) by bombadil.infradead.org with smtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1bCVxK-0003uu-U0 for linux-arm-kernel@lists.infradead.org; Mon, 13 Jun 2016 17:47:24 +0000 Received: (qmail 53124 invoked by uid 2313); 13 Jun 2016 17:46:51 -0000 Date: 13 Jun 2016 17:46:51 -0000 MBOX-Line: From 96b6a34fb7bb60376928e1c92de56c19277abd51 Mon Sep 17 00:00:00 2001 Message-Id: <96b6a34fb7bb60376928e1c92de56c19277abd51.1465490774.git.hramrach@gmail.com> In-Reply-To: References: From: Michal Suchanek Subject: [PATCH v3 08/13] spi: sunxi: synchronize whitespace, comments, struct To: linux-sunxi@googlegroups.com, Rob Herring , Pawel Moll , Mark Rutland , Ian Campbell , Kumar Gala , Maxime Ripard , Chen-Yu Tsai , Russell King , Mark Brown , Michal Suchanek , Arnd Bergmann , Olof Johansson , Krzysztof Kozlowski , Javier Martinez Canillas , Simon Horman , Sjoerd Simons , Thierry Reding , Alison Wang , Timo Sigurdsson , Jonathan Liu , Gerhard Bertelsmann , Priit Laes , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org, X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160613_104723_408080_02512DA2 X-CRM114-Status: GOOD ( 13.61 ) 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: , 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 Minimize differences between sun4i and sun6i driver without code changes. Signed-off-by: Michal Suchanek --- drivers/spi/spi-sun4i.c | 11 ++++++----- drivers/spi/spi-sun6i.c | 8 +++----- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/spi/spi-sun4i.c b/drivers/spi/spi-sun4i.c index b7f8de1..bbb0996 100644 --- a/drivers/spi/spi-sun4i.c +++ b/drivers/spi/spi-sun4i.c @@ -19,6 +19,7 @@ #include #include #include +#include #include @@ -56,7 +57,7 @@ #define SUNXI_CLK_CTL_REG 0x1c #define SUNXI_CLK_CTL_CDR2_MASK 0xff -#define SUNXI_CLK_CTL_CDR2(div) ((div) & SUNXI_CLK_CTL_CDR2_MASK) +#define SUNXI_CLK_CTL_CDR2(div) (((div) & SUNXI_CLK_CTL_CDR2_MASK) << 0) #define SUNXI_CLK_CTL_CDR1_MASK 0xf #define SUNXI_CLK_CTL_CDR1(div) (((div) & SUNXI_CLK_CTL_CDR1_MASK) << 8) #define SUNXI_CLK_CTL_DRS BIT(12) @@ -78,6 +79,7 @@ struct sunxi_spi { void __iomem *base_addr; struct clk *hclk; struct clk *mclk; + struct reset_control *rstc; struct completion done; @@ -136,7 +138,6 @@ static void sunxi_spi_set_cs(struct spi_device *spi, bool enable) u32 reg; reg = sunxi_spi_read(sspi, SUNXI_TFR_CTL_REG); - reg &= ~SUNXI_TFR_CTL_CS_MASK; reg |= SUNXI_TFR_CTL_CS(spi->chip_select); @@ -198,7 +199,6 @@ static int sunxi_spi_transfer_one(struct spi_master *master, /* Clear pending interrupts */ sunxi_spi_write(sspi, SUNXI_INT_STA_REG, ~0); - reg = sunxi_spi_read(sspi, SUNXI_TFR_CTL_REG); /* Reset FIFOs */ @@ -224,7 +224,6 @@ static int sunxi_spi_transfer_one(struct spi_master *master, else reg &= ~SUNXI_TFR_CTL_FBS; - /* * If it's a TX only transfer, we don't want to fill the RX * FIFO with bogus data @@ -248,7 +247,7 @@ static int sunxi_spi_transfer_one(struct spi_master *master, * * We have two choices there. Either we can use the clock * divide rate 1, which is calculated thanks to this formula: - * SPI_CLK = MOD_CLK / (2 ^ (cdr + 1)) + * SPI_CLK = MOD_CLK / (2 ^ cdr) * Or we can use CDR2, which is calculated with the formula: * SPI_CLK = MOD_CLK / (2 * (cdr + 1)) * Wether we use the former or the latter is set through the @@ -352,6 +351,8 @@ static int sunxi_spi_runtime_resume(struct device *dev) return 0; +err2: + clk_disable_unprepare(sspi->mclk); err: clk_disable_unprepare(sspi->hclk); out: diff --git a/drivers/spi/spi-sun6i.c b/drivers/spi/spi-sun6i.c index f26b52a..d14a953 100644 --- a/drivers/spi/spi-sun6i.c +++ b/drivers/spi/spi-sun6i.c @@ -29,7 +29,6 @@ #define SUNXI_CTL_ENABLE BIT(0) #define SUNXI_CTL_MASTER BIT(1) #define SUNXI_CTL_TP BIT(7) -#define SUNXI_GBL_CTL_RST BIT(31) #define SUNXI_TFR_CTL_REG 0x08 #define SUNXI_TFR_CTL_CPHA BIT(0) @@ -44,7 +43,6 @@ #define SUNXI_TFR_CTL_XCH BIT(31) #define SUNXI_INT_CTL_REG 0x10 -#define SUNXI_INT_CTL_RF_OVF BIT(8) #define SUNXI_INT_CTL_TC BIT(12) #define SUNXI_INT_STA_REG 0x14 @@ -200,7 +198,9 @@ static int sunxi_spi_transfer_one(struct spi_master *master, /* Clear pending interrupts */ sunxi_spi_write(sspi, SUNXI_INT_STA_REG, ~0); - /* Reset FIFO */ + reg = sunxi_spi_read(sspi, SUNXI_TFR_CTL_REG); + + /* Reset FIFOs */ sunxi_spi_write(sspi, SUNXI_FIFO_CTL_REG, SUNXI_CTL_RF_RST | SUNXI_CTL_TF_RST); @@ -208,8 +208,6 @@ static int sunxi_spi_transfer_one(struct spi_master *master, * Setup the transfer control register: Chip Select, * polarities, etc. */ - reg = sunxi_spi_read(sspi, SUNXI_TFR_CTL_REG); - if (spi->mode & SPI_CPOL) reg |= SUNXI_TFR_CTL_CPOL; else