linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Talel Shenhar <talel@amazon.com>
To: <broonie@kernel.org>, <linux-spi@vger.kernel.org>,
	<robh+dt@kernel.org>, <mark.rutland@arm.com>,
	<devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Cc: <talel@amazon.com>, <jonnyc@amazon.com>, <ronenk@amazon.com>,
	<barakw@amazon.com>, David Woodhouse <dwmw@amazon.co.uk>
Subject: [PATCH 2/2] dw: spi: add support for Alpine spi controller
Date: Wed, 10 Oct 2018 18:15:16 +0300	[thread overview]
Message-ID: <1539184516-8200-2-git-send-email-talel@amazon.com> (raw)
In-Reply-To: <1539184516-8200-1-git-send-email-talel@amazon.com>

Add support for a new devicetree compatible string called
'al,alpine-apb-ssi', which is necessary for the Amazon Alpine spi
controller. 'al,alpine-dw-apb-ssi' is used in the dw spi driver if
specified in the devicetree.  Otherwise, fall back to driver default
behavior, i.e. original dw IP hw driver behavior.

Signed-off-by: Talel Shenhar <talel@amazon.com>
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
---
 drivers/spi/spi-dw-mmio.c | 9 +++++++++
 drivers/spi/spi-dw.c      | 6 ++++++
 drivers/spi/spi-dw.h      | 2 ++
 3 files changed, 17 insertions(+)

diff --git a/drivers/spi/spi-dw-mmio.c b/drivers/spi/spi-dw-mmio.c
index a768461..88b04d2 100644
--- a/drivers/spi/spi-dw-mmio.c
+++ b/drivers/spi/spi-dw-mmio.c
@@ -126,6 +126,14 @@ static int dw_spi_mscc_jaguar2_init(struct platform_device *pdev,
 				JAGUAR2_IF_SI_OWNER_OFFSET);
 }
 
+static int dw_spi_alpine_init(struct platform_device *pdev,
+			      struct dw_spi_mmio *dwsmmio)
+{
+	dwsmmio->dws.cs_override = 1;
+
+	return 0;
+}
+
 static int dw_spi_mmio_probe(struct platform_device *pdev)
 {
 	int (*init_func)(struct platform_device *pdev,
@@ -230,6 +238,7 @@ static const struct of_device_id dw_spi_mmio_of_match[] = {
 	{ .compatible = "snps,dw-apb-ssi", },
 	{ .compatible = "mscc,ocelot-spi", .data = dw_spi_mscc_ocelot_init},
 	{ .compatible = "mscc,jaguar2-spi", .data = dw_spi_mscc_jaguar2_init},
+	{ .compatible = "al,alpine-dw-apb-ssi", .data = dw_spi_alpine_init},
 	{ /* end of table */}
 };
 MODULE_DEVICE_TABLE(of, dw_spi_mmio_of_match);
diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c
index 3e205ab..b705f2b 100644
--- a/drivers/spi/spi-dw.c
+++ b/drivers/spi/spi-dw.c
@@ -144,6 +144,8 @@ void dw_spi_set_cs(struct spi_device *spi, bool enable)
 
 	if (!enable)
 		dw_writel(dws, DW_SPI_SER, BIT(spi->chip_select));
+	else if (dws->cs_override)
+		dw_writel(dws, DW_SPI_SER, 0);
 }
 EXPORT_SYMBOL_GPL(dw_spi_set_cs);
 
@@ -463,6 +465,10 @@ static void spi_hw_init(struct device *dev, struct dw_spi *dws)
 		dws->fifo_len = (fifo == 1) ? 0 : fifo;
 		dev_dbg(dev, "Detected FIFO size: %u bytes\n", dws->fifo_len);
 	}
+
+	/* enable HW fixup for explicit CS deselect for Amazon's alpine chip */
+	if (dws->cs_override)
+		dw_writel(dws, DW_SPI_CS_OVERRIDE, 0xF);
 }
 
 int dw_spi_add_host(struct device *dev, struct dw_spi *dws)
diff --git a/drivers/spi/spi-dw.h b/drivers/spi/spi-dw.h
index 0168b08..c9c1588 100644
--- a/drivers/spi/spi-dw.h
+++ b/drivers/spi/spi-dw.h
@@ -32,6 +32,7 @@
 #define DW_SPI_IDR			0x58
 #define DW_SPI_VERSION			0x5c
 #define DW_SPI_DR			0x60
+#define DW_SPI_CS_OVERRIDE		0xf4
 
 /* Bit fields in CTRLR0 */
 #define SPI_DFS_OFFSET			0
@@ -109,6 +110,7 @@ struct dw_spi {
 	u32			fifo_len;	/* depth of the FIFO buffer */
 	u32			max_freq;	/* max bus freq supported */
 
+	int			cs_override;
 	u32			reg_io_width;	/* DR I/O width in bytes */
 	u16			bus_num;
 	u16			num_cs;		/* supported slave numbers */
-- 
2.7.4

  reply	other threads:[~2018-10-10 15:15 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-10  7:08 [PATCH 1/2] dt-bindings: spi: dw: add cs-override property Talel Shenhar
2018-10-10  7:08 ` [PATCH 2/2] dw: spi: add 'cs-override' DT property support Talel Shenhar
2018-10-10 10:18 ` [PATCH 1/2] dt-bindings: spi: dw: add cs-override property Mark Brown
2018-10-10 11:23   ` Talel Shenhar
2018-10-10 11:27     ` Mark Brown
     [not found]       ` <ba83a08073614d9244c01218da28fe3e23f3bbc2.camel@amazon.co.uk>
2018-10-10 12:27         ` Mark Brown
2018-10-10 22:52           ` Trent Piepho
2018-10-10 15:15 ` [PATCH 1/2] dt-bindings: spi: dw: add compatible for Alpine spi controller Talel Shenhar
2018-10-10 15:15   ` Talel Shenhar [this message]
2018-10-10 22:08     ` [PATCH 2/2] dw: spi: add support " Trent Piepho
2018-10-11 11:20       ` [PATCH 1/2] dt-bindings: spi: dw: add compatible for Amazon's " Talel Shenhar
2018-10-11 11:20         ` [PATCH 2/2] dw: spi: add support " Talel Shenhar
2018-10-11 14:58           ` Applied "dw: spi: add support for Amazon's Alpine spi controller" to the spi tree Mark Brown
2018-10-11 13:44         ` [PATCH 1/2] dt-bindings: spi: dw: add compatible for Amazon's Alpine spi controller Mark Brown
2018-10-11 14:58         ` Applied "spi: dw: add compatible for Amazon's Alpine spi controller" to the spi tree Mark Brown
2018-10-11 11:22       ` [PATCH 2/2] dw: spi: add support for Alpine spi controller Talel Shenhar
2018-10-10 22:21 ` [PATCH 1/2] dt-bindings: spi: dw: add cs-override property Trent Piepho
2018-10-11  7:39   ` Talel Shenhar
2018-10-11 13:46   ` Mark Brown

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=1539184516-8200-2-git-send-email-talel@amazon.com \
    --to=talel@amazon.com \
    --cc=barakw@amazon.com \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dwmw@amazon.co.uk \
    --cc=jonnyc@amazon.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=robh+dt@kernel.org \
    --cc=ronenk@amazon.com \
    /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).