All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v3] spi: kirkwood_spi: Add support for multiple chip-selects on MVEBU
@ 2016-04-06 11:54 Stefan Roese
  2016-04-06 12:25 ` Jagan Teki
  0 siblings, 1 reply; 5+ messages in thread
From: Stefan Roese @ 2016-04-06 11:54 UTC (permalink / raw)
  To: u-boot

Currently only chip-select 0 is supported by the kirkwood SPI driver.
The Armada XP / 38x SoCs also use this driver and support multiple chip
selects. This patch adds support for multiple CS on MVEBU.

The register definitions are restructured a bit with this patch. Grouping
them to the corresponding registers.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Luka Perkov <luka.perkov@sartura.hr>
Cc: Jagan Teki <jteki@openedev.com>
---
v3:
- Remove unnecessary #ifdef

v2:
- Introduce clain_bus() function and move the CS configuration
  into it. As it only needs to be done once for the active bus.

  arch/arm/include/asm/arch-mvebu/spi.h | 17 ++++++++++++-----
 drivers/spi/kirkwood_spi.c            | 14 ++++++++++++++
 2 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/arch/arm/include/asm/arch-mvebu/spi.h b/arch/arm/include/asm/arch-mvebu/spi.h
index 526fea6..78869a2 100644
--- a/arch/arm/include/asm/arch-mvebu/spi.h
+++ b/arch/arm/include/asm/arch-mvebu/spi.h
@@ -35,13 +35,15 @@ struct kwspi_registers {
 #define SCK_MPP10	(1 << 1)
 #define MISO_MPP11	(1 << 2)
 
+/* Control Register */
+#define KWSPI_CSN_ACT		(1 << 0) /* Activates serial memory interface */
+#define KWSPI_SMEMRDY		(1 << 1) /* SerMem Data xfer ready */
+#define KWSPI_CS_SHIFT		2	/* chip select shift */
+#define KWSPI_CS_MASK		0x7	/* chip select mask */
+
+/* Configuration Register */
 #define KWSPI_CLKPRESCL_MASK	0x1f
 #define KWSPI_CLKPRESCL_MIN	0x12
-#define KWSPI_CSN_ACT		1 /* Activates serial memory interface */
-#define KWSPI_SMEMRDY		(1 << 1) /* SerMem Data xfer ready */
-#define KWSPI_IRQUNMASK		1 /* unmask SPI interrupt */
-#define KWSPI_IRQMASK		0 /* mask SPI interrupt */
-#define KWSPI_SMEMRDIRQ		1 /* SerMem data xfer ready irq */
 #define KWSPI_XFERLEN_1BYTE	0
 #define KWSPI_XFERLEN_2BYTE	(1 << 5)
 #define KWSPI_XFERLEN_MASK	(1 << 5)
@@ -50,6 +52,11 @@ struct kwspi_registers {
 #define KWSPI_ADRLEN_3BYTE	(2 << 8)
 #define KWSPI_ADRLEN_4BYTE	(3 << 8)
 #define KWSPI_ADRLEN_MASK	(3 << 8)
+
+#define KWSPI_IRQUNMASK		1 /* unmask SPI interrupt */
+#define KWSPI_IRQMASK		0 /* mask SPI interrupt */
+#define KWSPI_SMEMRDIRQ		1 /* SerMem data xfer ready irq */
+
 #define KWSPI_TIMEOUT		10000
 
 #endif /* __KW_SPI_H__ */
diff --git a/drivers/spi/kirkwood_spi.c b/drivers/spi/kirkwood_spi.c
index 80cdbd0..6851ba9 100644
--- a/drivers/spi/kirkwood_spi.c
+++ b/drivers/spi/kirkwood_spi.c
@@ -283,6 +283,19 @@ static int mvebu_spi_xfer(struct udevice *dev, unsigned int bitlen,
 	return _spi_xfer(plat->spireg, bitlen, dout, din, flags);
 }
 
+static int mvebu_spi_claim_bus(struct udevice *dev)
+{
+	struct udevice *bus = dev->parent;
+	struct mvebu_spi_platdata *plat = dev_get_platdata(bus);
+
+	/* Configure the chip-select in the CTRL register */
+	clrsetbits_le32(&plat->spireg->ctrl,
+			KWSPI_CS_MASK << KWSPI_CS_SHIFT,
+			spi_chip_select(dev) << KWSPI_CS_SHIFT);
+
+	return 0;
+}
+
 static int mvebu_spi_probe(struct udevice *bus)
 {
 	struct mvebu_spi_platdata *plat = dev_get_platdata(bus);
@@ -305,6 +318,7 @@ static int mvebu_spi_ofdata_to_platdata(struct udevice *bus)
 }
 
 static const struct dm_spi_ops mvebu_spi_ops = {
+	.claim_bus	= mvebu_spi_claim_bus,
 	.xfer		= mvebu_spi_xfer,
 	.set_speed	= mvebu_spi_set_speed,
 	.set_mode	= mvebu_spi_set_mode,
-- 
2.8.1

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

* [U-Boot] [PATCH v3] spi: kirkwood_spi: Add support for multiple chip-selects on MVEBU
  2016-04-06 11:54 [U-Boot] [PATCH v3] spi: kirkwood_spi: Add support for multiple chip-selects on MVEBU Stefan Roese
@ 2016-04-06 12:25 ` Jagan Teki
  2016-04-06 12:31   ` Stefan Roese
  0 siblings, 1 reply; 5+ messages in thread
From: Jagan Teki @ 2016-04-06 12:25 UTC (permalink / raw)
  To: u-boot

On 6 April 2016 at 17:24, Stefan Roese <sr@denx.de> wrote:
> Currently only chip-select 0 is supported by the kirkwood SPI driver.
> The Armada XP / 38x SoCs also use this driver and support multiple chip
> selects. This patch adds support for multiple CS on MVEBU.
>
> The register definitions are restructured a bit with this patch. Grouping
> them to the corresponding registers.
>
> Signed-off-by: Stefan Roese <sr@denx.de>
> Cc: Luka Perkov <luka.perkov@sartura.hr>
> Cc: Jagan Teki <jteki@openedev.com>
> ---
> v3:
> - Remove unnecessary #ifdef

Does this mean dm for this driver will operate only for MVEBU now?

-- 
Jagan.

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

* [U-Boot] [PATCH v3] spi: kirkwood_spi: Add support for multiple chip-selects on MVEBU
  2016-04-06 12:25 ` Jagan Teki
@ 2016-04-06 12:31   ` Stefan Roese
  2016-04-06 13:31     ` Jagan Teki
  0 siblings, 1 reply; 5+ messages in thread
From: Stefan Roese @ 2016-04-06 12:31 UTC (permalink / raw)
  To: u-boot

On 06.04.2016 14:25, Jagan Teki wrote:
> On 6 April 2016 at 17:24, Stefan Roese <sr@denx.de> wrote:
>> Currently only chip-select 0 is supported by the kirkwood SPI driver.
>> The Armada XP / 38x SoCs also use this driver and support multiple chip
>> selects. This patch adds support for multiple CS on MVEBU.
>>
>> The register definitions are restructured a bit with this patch. Grouping
>> them to the corresponding registers.
>>
>> Signed-off-by: Stefan Roese <sr@denx.de>
>> Cc: Luka Perkov <luka.perkov@sartura.hr>
>> Cc: Jagan Teki <jteki@openedev.com>
>> ---
>> v3:
>> - Remove unnecessary #ifdef
>
> Does this mean dm for this driver will operate only for MVEBU now?

Not sure. The Kirkwood platform has not been ported to DM yet. But
I can't see anything right now that should prevent Kirkwood to
using this driver also once its ported to DM. Not sure why I had
this #ifdef in this patch - its been a while since I first started
this patch.

Are you okay with this patch now? If yes, should I push it via the
Marvell repository?

Thanks,
Stefan

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

* [U-Boot] [PATCH v3] spi: kirkwood_spi: Add support for multiple chip-selects on MVEBU
  2016-04-06 12:31   ` Stefan Roese
@ 2016-04-06 13:31     ` Jagan Teki
  2016-04-06 13:43       ` Stefan Roese
  0 siblings, 1 reply; 5+ messages in thread
From: Jagan Teki @ 2016-04-06 13:31 UTC (permalink / raw)
  To: u-boot

On Apr 6, 2016 6:01 PM, "Stefan Roese" <sr@denx.de> wrote:
>
> On 06.04.2016 14:25, Jagan Teki wrote:
>>
>> On 6 April 2016 at 17:24, Stefan Roese <sr@denx.de> wrote:
>>>
>>> Currently only chip-select 0 is supported by the kirkwood SPI driver.
>>> The Armada XP / 38x SoCs also use this driver and support multiple chip
>>> selects. This patch adds support for multiple CS on MVEBU.
>>>
>>> The register definitions are restructured a bit with this patch.
Grouping
>>> them to the corresponding registers.
>>>
>>> Signed-off-by: Stefan Roese <sr@denx.de>
>>> Cc: Luka Perkov <luka.perkov@sartura.hr>
>>> Cc: Jagan Teki <jteki@openedev.com>
>>> ---
>>> v3:
>>> - Remove unnecessary #ifdef
>>
>>
>> Does this mean dm for this driver will operate only for MVEBU now?
>
>
> Not sure. The Kirkwood platform has not been ported to DM yet. But
> I can't see anything right now that should prevent Kirkwood to
> using this driver also once its ported to DM. Not sure why I had
> this #ifdef in this patch - its been a while since I first started
> this patch.
>

Reviewed-by: Jagan Teki <jteki@openedev.com>

> Are you okay with this patch now? If yes, should I push it via the
> Marvell repository?

Ok.

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

* [U-Boot] [PATCH v3] spi: kirkwood_spi: Add support for multiple chip-selects on MVEBU
  2016-04-06 13:31     ` Jagan Teki
@ 2016-04-06 13:43       ` Stefan Roese
  0 siblings, 0 replies; 5+ messages in thread
From: Stefan Roese @ 2016-04-06 13:43 UTC (permalink / raw)
  To: u-boot

On 06.04.2016 15:31, Jagan Teki wrote:
>
> On Apr 6, 2016 6:01 PM, "Stefan Roese" <sr at denx.de <mailto:sr@denx.de>>
> wrote:
>  >
>  > On 06.04.2016 14:25, Jagan Teki wrote:
>  >>
>  >> On 6 April 2016 at 17:24, Stefan Roese <sr@denx.de
> <mailto:sr@denx.de>> wrote:
>  >>>
>  >>> Currently only chip-select 0 is supported by the kirkwood SPI driver.
>  >>> The Armada XP / 38x SoCs also use this driver and support multiple chip
>  >>> selects. This patch adds support for multiple CS on MVEBU.
>  >>>
>  >>> The register definitions are restructured a bit with this patch.
> Grouping
>  >>> them to the corresponding registers.
>  >>>
>  >>> Signed-off-by: Stefan Roese <sr at denx.de <mailto:sr@denx.de>>
>  >>> Cc: Luka Perkov <luka.perkov@sartura.hr
> <mailto:luka.perkov@sartura.hr>>
>  >>> Cc: Jagan Teki <jteki at openedev.com <mailto:jteki@openedev.com>>
>  >>> ---
>  >>> v3:
>  >>> - Remove unnecessary #ifdef
>  >>
>  >>
>  >> Does this mean dm for this driver will operate only for MVEBU now?
>  >
>  >
>  > Not sure. The Kirkwood platform has not been ported to DM yet. But
>  > I can't see anything right now that should prevent Kirkwood to
>  > using this driver also once its ported to DM. Not sure why I had
>  > this #ifdef in this patch - its been a while since I first started
>  > this patch.
>  >
>
> Reviewed-by: Jagan Teki <jteki at openedev.com <mailto:jteki@openedev.com>>
>
>  > Are you okay with this patch now? If yes, should I push it via the
>  > Marvell repository?
>
> Ok.

Applied to u-boot-marvell/master.

Thanks,
Stefan

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

end of thread, other threads:[~2016-04-06 13:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-06 11:54 [U-Boot] [PATCH v3] spi: kirkwood_spi: Add support for multiple chip-selects on MVEBU Stefan Roese
2016-04-06 12:25 ` Jagan Teki
2016-04-06 12:31   ` Stefan Roese
2016-04-06 13:31     ` Jagan Teki
2016-04-06 13:43       ` Stefan Roese

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.