mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCHv3] spi: orion: Add multiple chip select support to spi-orion
@ 2015-01-16  3:10 Ken Wilson
  2015-01-16 12:39 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Ken Wilson @ 2015-01-16  3:10 UTC (permalink / raw)
  To: broonie; +Cc: linux-spi, linux-kernel, Ken Wilson

This commit adds support for multiple hardware chip selects to spi-orion.
Different SoCs support different number of chip selects (up to
8 on some platforms). The driver allows up to this number, and it is up
to the implementer to only use the chip selects that are available.

Signed-off-by: Ken Wilson <ken.wilson@opengear.com>
---
 drivers/spi/spi-orion.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi-orion.c b/drivers/spi/spi-orion.c
index e6ac9d5..db50f0e 100644
--- a/drivers/spi/spi-orion.c
+++ b/drivers/spi/spi-orion.c
@@ -28,7 +28,12 @@
 /* Runtime PM autosuspend timeout: PM is fairly light on this driver */
 #define SPI_AUTOSUSPEND_TIMEOUT		200
 
-#define ORION_NUM_CHIPSELECTS		1 /* only one slave is supported*/
+/* Some SoCs using this driver support up to 8 chip selects.
+ * It is up to the implementer to only use the chip selects
+ * that are available.
+ */
+#define ORION_NUM_CHIPSELECTS		8
+
 #define ORION_SPI_WAIT_RDY_MAX_LOOP	2000 /* in usec */
 
 #define ORION_SPI_IF_CTRL_REG		0x00
@@ -44,6 +49,10 @@
 #define ARMADA_SPI_CLK_PRESCALE_MASK	0xDF
 #define ORION_SPI_MODE_MASK		(ORION_SPI_MODE_CPOL | \
 					 ORION_SPI_MODE_CPHA)
+#define ORION_SPI_CS_MASK	0x1C
+#define ORION_SPI_CS_SHIFT	2
+#define ORION_SPI_CS(cs)	((cs << ORION_SPI_CS_SHIFT) & \
+					ORION_SPI_CS_MASK)
 
 enum orion_spi_type {
 	ORION_SPI,
@@ -221,6 +230,10 @@ static void orion_spi_set_cs(struct spi_device *spi, bool enable)
 
 	orion_spi = spi_master_get_devdata(spi->master);
 
+	orion_spi_clrbits(orion_spi, ORION_SPI_IF_CTRL_REG, ORION_SPI_CS_MASK);
+	orion_spi_setbits(orion_spi, ORION_SPI_IF_CTRL_REG,
+				ORION_SPI_CS(spi->chip_select));
+
 	/* Chip select logic is inverted from spi_set_cs */
 	if (!enable)
 		orion_spi_setbits(orion_spi, ORION_SPI_IF_CTRL_REG, 0x1);
-- 
2.0.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCHv3] spi: orion: Add multiple chip select support to spi-orion
  2015-01-16  3:10 [PATCHv3] spi: orion: Add multiple chip select support to spi-orion Ken Wilson
@ 2015-01-16 12:39 ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2015-01-16 12:39 UTC (permalink / raw)
  To: Ken Wilson; +Cc: linux-spi, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 363 bytes --]

On Fri, Jan 16, 2015 at 01:10:47PM +1000, Ken Wilson wrote:
> This commit adds support for multiple hardware chip selects to spi-orion.
> Different SoCs support different number of chip selects (up to
> 8 on some platforms). The driver allows up to this number, and it is up
> to the implementer to only use the chip selects that are available.

Applied, thanks.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-01-16 12:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-16  3:10 [PATCHv3] spi: orion: Add multiple chip select support to spi-orion Ken Wilson
2015-01-16 12:39 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®