LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 0/3] xilinx-spi: Support more spi modes and multiple device tree
@ 2015-01-21 15:53 Ricardo Ribalda Delgado
  2015-01-21 15:53 ` [PATCH 1/3] spi/xilinx: Use automatic bus number on " Ricardo Ribalda Delgado
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Ricardo Ribalda Delgado @ 2015-01-21 15:53 UTC (permalink / raw)
  To: Mark Brown, Michal Simek, Sören Brinkmann, linux-spi,
	linux-arm-kernel, linux-kernel
  Cc: Ricardo Ribalda Delgado

This series of patches add drier support for hardware implemented modes:
spi_lsb_fist and spi_loop

Also fix an issue when multiple spi devices are defined on a device tree.

Ricardo Ribalda Delgado (3):
  spi/xilinx: Use automatic bus number on device tree
  spi/xilinx: Support for spi mode LSB_FIRST
  spi/xilinx: Support for spi mode LOOP

 drivers/spi/spi-xilinx.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

-- 
2.1.4


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

* [PATCH 1/3] spi/xilinx: Use automatic bus number on device tree
  2015-01-21 15:53 [PATCH 0/3] xilinx-spi: Support more spi modes and multiple device tree Ricardo Ribalda Delgado
@ 2015-01-21 15:53 ` Ricardo Ribalda Delgado
  2015-01-21 16:02   ` Lars-Peter Clausen
  2015-01-21 15:53 ` [PATCH 2/3] spi/xilinx: Support for spi mode LSB_FIRST Ricardo Ribalda Delgado
  2015-01-21 15:53 ` [PATCH 3/3] spi/xilinx: Support for spi mode LOOP Ricardo Ribalda Delgado
  2 siblings, 1 reply; 6+ messages in thread
From: Ricardo Ribalda Delgado @ 2015-01-21 15:53 UTC (permalink / raw)
  To: Mark Brown, Michal Simek, Sören Brinkmann, linux-spi,
	linux-arm-kernel, linux-kernel
  Cc: Ricardo Ribalda Delgado

If there is more than one spi device on a device tree, the second one
will fail to probe due to a duplicated bus_num.

This patch uses automatic bus number if the device is deined on a device
tree.

Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
---
 drivers/spi/spi-xilinx.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi-xilinx.c b/drivers/spi/spi-xilinx.c
index 79bd84f..2ea4ca5 100644
--- a/drivers/spi/spi-xilinx.c
+++ b/drivers/spi/spi-xilinx.c
@@ -332,14 +332,17 @@ static int xilinx_spi_probe(struct platform_device *pdev)
 	struct spi_master *master;
 	u32 tmp;
 	u8 i;
+	s16 bus_num;
 
 	pdata = dev_get_platdata(&pdev->dev);
 	if (pdata) {
 		num_cs = pdata->num_chipselect;
 		bits_per_word = pdata->bits_per_word;
+		bus_num = pdev->id;
 	} else {
 		of_property_read_u32(pdev->dev.of_node, "xlnx,num-ss-bits",
 					  &num_cs);
+		bus_num = -1;
 	}
 
 	if (!num_cs) {
@@ -369,7 +372,7 @@ static int xilinx_spi_probe(struct platform_device *pdev)
 		goto put_master;
 	}
 
-	master->bus_num = pdev->id;
+	master->bus_num = bus_num;
 	master->num_chipselect = num_cs;
 	master->dev.of_node = pdev->dev.of_node;
 
-- 
2.1.4


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

* [PATCH 2/3] spi/xilinx: Support for spi mode LSB_FIRST
  2015-01-21 15:53 [PATCH 0/3] xilinx-spi: Support more spi modes and multiple device tree Ricardo Ribalda Delgado
  2015-01-21 15:53 ` [PATCH 1/3] spi/xilinx: Use automatic bus number on " Ricardo Ribalda Delgado
@ 2015-01-21 15:53 ` Ricardo Ribalda Delgado
  2015-01-21 15:53 ` [PATCH 3/3] spi/xilinx: Support for spi mode LOOP Ricardo Ribalda Delgado
  2 siblings, 0 replies; 6+ messages in thread
From: Ricardo Ribalda Delgado @ 2015-01-21 15:53 UTC (permalink / raw)
  To: Mark Brown, Michal Simek, Sören Brinkmann, linux-spi,
	linux-arm-kernel, linux-kernel
  Cc: Ricardo Ribalda Delgado

Hardware supports LSB_FIRST mode. Support it also in the driver.

Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
---
 drivers/spi/spi-xilinx.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi-xilinx.c b/drivers/spi/spi-xilinx.c
index 2ea4ca5..b8ce58d 100644
--- a/drivers/spi/spi-xilinx.c
+++ b/drivers/spi/spi-xilinx.c
@@ -34,7 +34,8 @@
 #define XSPI_CR_MASTER_MODE	0x04
 #define XSPI_CR_CPOL		0x08
 #define XSPI_CR_CPHA		0x10
-#define XSPI_CR_MODE_MASK	(XSPI_CR_CPHA | XSPI_CR_CPOL)
+#define XSPI_CR_MODE_MASK	(XSPI_CR_CPHA | XSPI_CR_CPOL | \
+				 XSPI_CR_LSB_FIRST)
 #define XSPI_CR_TXFIFO_RESET	0x20
 #define XSPI_CR_RXFIFO_RESET	0x40
 #define XSPI_CR_MANUAL_SSELECT	0x80
@@ -194,6 +195,8 @@ static void xilinx_spi_chipselect(struct spi_device *spi, int is_on)
 			cr |= XSPI_CR_CPHA;
 		if (spi->mode & SPI_CPOL)
 			cr |= XSPI_CR_CPOL;
+		if (spi->mode & SPI_LSB_FIRST)
+			cr |= XSPI_CR_LSB_FIRST;
 		xspi->write_fn(cr, xspi->regs + XSPI_CR_OFFSET);
 
 		/* We do not check spi->max_speed_hz here as the SPI clock
-- 
2.1.4


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

* [PATCH 3/3] spi/xilinx: Support for spi mode LOOP
  2015-01-21 15:53 [PATCH 0/3] xilinx-spi: Support more spi modes and multiple device tree Ricardo Ribalda Delgado
  2015-01-21 15:53 ` [PATCH 1/3] spi/xilinx: Use automatic bus number on " Ricardo Ribalda Delgado
  2015-01-21 15:53 ` [PATCH 2/3] spi/xilinx: Support for spi mode LSB_FIRST Ricardo Ribalda Delgado
@ 2015-01-21 15:53 ` Ricardo Ribalda Delgado
  2 siblings, 0 replies; 6+ messages in thread
From: Ricardo Ribalda Delgado @ 2015-01-21 15:53 UTC (permalink / raw)
  To: Mark Brown, Michal Simek, Sören Brinkmann, linux-spi,
	linux-arm-kernel, linux-kernel
  Cc: Ricardo Ribalda Delgado

Hardware supports LOOP mode. Support it also in the driver.

Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
---
 drivers/spi/spi-xilinx.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi-xilinx.c b/drivers/spi/spi-xilinx.c
index b8ce58d..f6ceb60 100644
--- a/drivers/spi/spi-xilinx.c
+++ b/drivers/spi/spi-xilinx.c
@@ -35,7 +35,7 @@
 #define XSPI_CR_CPOL		0x08
 #define XSPI_CR_CPHA		0x10
 #define XSPI_CR_MODE_MASK	(XSPI_CR_CPHA | XSPI_CR_CPOL | \
-				 XSPI_CR_LSB_FIRST)
+				 XSPI_CR_LSB_FIRST | XSPI_CR_LOOP)
 #define XSPI_CR_TXFIFO_RESET	0x20
 #define XSPI_CR_RXFIFO_RESET	0x40
 #define XSPI_CR_MANUAL_SSELECT	0x80
@@ -197,6 +197,8 @@ static void xilinx_spi_chipselect(struct spi_device *spi, int is_on)
 			cr |= XSPI_CR_CPOL;
 		if (spi->mode & SPI_LSB_FIRST)
 			cr |= XSPI_CR_LSB_FIRST;
+		if (spi->mode & SPI_LOOP)
+			cr |= XSPI_CR_LOOP;
 		xspi->write_fn(cr, xspi->regs + XSPI_CR_OFFSET);
 
 		/* We do not check spi->max_speed_hz here as the SPI clock
-- 
2.1.4


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

* Re: [PATCH 1/3] spi/xilinx: Use automatic bus number on device tree
  2015-01-21 15:53 ` [PATCH 1/3] spi/xilinx: Use automatic bus number on " Ricardo Ribalda Delgado
@ 2015-01-21 16:02   ` Lars-Peter Clausen
  2015-01-21 16:51     ` Ricardo Ribalda Delgado
  0 siblings, 1 reply; 6+ messages in thread
From: Lars-Peter Clausen @ 2015-01-21 16:02 UTC (permalink / raw)
  To: Ricardo Ribalda Delgado, Mark Brown, Michal Simek,
	Sören Brinkmann, linux-spi, linux-arm-kernel, linux-kernel

On 01/21/2015 04:53 PM, Ricardo Ribalda Delgado wrote:
> If there is more than one spi device on a device tree, the second one
> will fail to probe due to a duplicated bus_num.
 > [...]

This should already be fixed. See commit 4b153a2137c5 ("spi: xilinx: Use 
pdev->id instead of pdev->dev.id for the SPI bus number")[1]. If the device 
was registered using devicetree pdev->id is -1, so dynamic numbers will be used.

- Lars

[1] 
http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/drivers/spi/spi-xilinx.c?id=4b153a2137c5d2914794c8944d78c731c1b0ae9d


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

* Re: [PATCH 1/3] spi/xilinx: Use automatic bus number on device tree
  2015-01-21 16:02   ` Lars-Peter Clausen
@ 2015-01-21 16:51     ` Ricardo Ribalda Delgado
  0 siblings, 0 replies; 6+ messages in thread
From: Ricardo Ribalda Delgado @ 2015-01-21 16:51 UTC (permalink / raw)
  To: Lars-Peter Clausen
  Cc: Mark Brown, Michal Simek, Sören Brinkmann, linux-spi,
	moderated list:ARM/S5P EXYNOS AR...,
	LKML

Hi Lars

I think you are right. The other patches on the set are still valid though


Thanks!

On Wed, Jan 21, 2015 at 5:02 PM, Lars-Peter Clausen <lars@metafoo.de> wrote:
> On 01/21/2015 04:53 PM, Ricardo Ribalda Delgado wrote:
>>
>> If there is more than one spi device on a device tree, the second one
>> will fail to probe due to a duplicated bus_num.
>
>> [...]
>
> This should already be fixed. See commit 4b153a2137c5 ("spi: xilinx: Use
> pdev->id instead of pdev->dev.id for the SPI bus number")[1]. If the device
> was registered using devicetree pdev->id is -1, so dynamic numbers will be
> used.
>
> - Lars
>
> [1]
> http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/drivers/spi/spi-xilinx.c?id=4b153a2137c5d2914794c8944d78c731c1b0ae9d
>



-- 
Ricardo Ribalda

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

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

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-21 15:53 [PATCH 0/3] xilinx-spi: Support more spi modes and multiple device tree Ricardo Ribalda Delgado
2015-01-21 15:53 ` [PATCH 1/3] spi/xilinx: Use automatic bus number on " Ricardo Ribalda Delgado
2015-01-21 16:02   ` Lars-Peter Clausen
2015-01-21 16:51     ` Ricardo Ribalda Delgado
2015-01-21 15:53 ` [PATCH 2/3] spi/xilinx: Support for spi mode LSB_FIRST Ricardo Ribalda Delgado
2015-01-21 15:53 ` [PATCH 3/3] spi/xilinx: Support for spi mode LOOP Ricardo Ribalda Delgado

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).