From: hramrach@gmail.com (Michal Suchanek)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3 08/13] spi: sunxi: synchronize whitespace, comments, struct
Date: 13 Jun 2016 17:46:51 -0000 [thread overview]
Message-ID: <96b6a34fb7bb60376928e1c92de56c19277abd51.1465490774.git.hramrach@gmail.com> (raw)
In-Reply-To: <cover.1465490774.git.hramrach@gmail.com>
Minimize differences between sun4i and sun6i driver without code
changes.
Signed-off-by: Michal Suchanek <hramrach@gmail.com>
---
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 <linux/module.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
+#include <linux/reset.h>
#include <linux/spi/spi.h>
@@ -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
--
2.8.1
next prev parent reply other threads:[~2016-06-13 17:46 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-13 17:46 [PATCH v3 00/13] sunxi spi fixes Michal Suchanek
2016-06-13 17:46 ` [PATCH v3 01/13] spi: sunxi: set maximum and minimum speed of SPI master Michal Suchanek
2016-06-13 19:55 ` Maxime Ripard
2016-06-13 17:46 ` [PATCH v3 03/13] spi: sun4i: fix FIFO limit Michal Suchanek
2016-06-13 19:56 ` Maxime Ripard
2016-06-13 17:46 ` [PATCH v3 02/13] spi: sunxi: fix transfer timeout Michal Suchanek
2016-06-13 19:55 ` Maxime Ripard
2016-06-13 17:46 ` [PATCH v3 06/13] spi: sunxi: rename sun4i,sun6i -> sunxi Michal Suchanek
2016-06-13 17:46 ` [PATCH v3 05/13] spi: sun6i: update CS handling from spi-sun4i Michal Suchanek
2016-06-13 17:46 ` [PATCH v3 04/13] spi: sunxi: expose maximum transfer size limit Michal Suchanek
2016-06-13 19:56 ` Maxime Ripard
2016-06-13 17:46 ` [PATCH v3 09/13] spi: sunxi: use register map Michal Suchanek
2016-06-13 17:46 ` Michal Suchanek [this message]
2016-06-13 17:46 ` [PATCH v3 07/13] spi: sunxi: rename constants to match between sun4i and sun6i Michal Suchanek
2016-06-13 23:31 ` [linux-sunxi] " Julian Calaby
2016-06-14 4:43 ` Michal Suchanek
2016-06-13 17:46 ` [PATCH v3 11/13] dt: spi: sun4i: merge sun4i and sun6i binding doc Michal Suchanek
2016-06-13 23:45 ` [linux-sunxi] " Julian Calaby
2016-06-14 4:40 ` Michal Suchanek
2016-06-14 4:48 ` Julian Calaby
2016-06-13 17:46 ` [PATCH v3 10/13] spi: sunxi: merge sun4i and sun6i SPI driver Michal Suchanek
2016-06-13 23:43 ` [linux-sunxi] " Julian Calaby
2016-06-14 4:34 ` Michal Suchanek
2016-06-14 4:47 ` Julian Calaby
2016-06-14 5:28 ` Michal Suchanek
2016-06-14 5:45 ` Julian Calaby
2016-06-14 6:35 ` Michal Suchanek
2016-06-14 11:20 ` Julian Calaby
2016-06-13 17:46 ` [PATCH v3 12/13] spi: sunxi: remove CONFIG_SPI_SUN6I Michal Suchanek
2016-06-13 17:46 ` [PATCH v3 13/13] spi: sun4i: add DMA support Michal
2016-06-13 19:57 ` [PATCH v3 00/13] sunxi spi fixes Maxime Ripard
2016-06-14 4:50 ` Michal Suchanek
2016-06-17 10:34 ` Michal Suchanek
2016-07-25 7:32 ` Maxime Ripard
2016-07-25 8:03 ` Michal Suchanek
2016-07-29 20:22 ` Maxime Ripard
2016-07-30 17:32 ` Michal Suchanek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=96b6a34fb7bb60376928e1c92de56c19277abd51.1465490774.git.hramrach@gmail.com \
--to=hramrach@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).