linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] spi: pl022: Add support for chip select extension
@ 2014-09-15 11:38 Anders Berg
  2014-09-16 18:34 ` Mark Brown
  0 siblings, 1 reply; 8+ messages in thread
From: Anders Berg @ 2014-09-15 11:38 UTC (permalink / raw)
  To: Mark Brown, Linus Walleij
  Cc: linux-arm-kernel, linux-spi, linux-kernel, Anders Berg

Add support for a extended PL022 which has an extra register for controlling up
to five chip select signals. This controller is found on the AXM5516 SoC.
Unfortunately the PrimeCell identification registers are identical to a
standard ARM PL022. To work around this, the peripheral ID must be overridden
in the device tree using the "arm,primecell-periphid" property with the value
0x000b6022.

Signed-off-by: Anders Berg <anders.berg@avagotech.com>
---
Changelog:

v2:
    - added constant to <linux/amba/bus.h>

 drivers/spi/spi-pl022.c  | 59 +++++++++++++++++++++++++++++++++++++++++++++++-
 include/linux/amba/bus.h |  5 ++++
 2 files changed, 63 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c
index 1189cfd..b395489 100644
--- a/drivers/spi/spi-pl022.c
+++ b/drivers/spi/spi-pl022.c
@@ -82,6 +82,7 @@
 #define SSP_MIS(r)	(r + 0x01C)
 #define SSP_ICR(r)	(r + 0x020)
 #define SSP_DMACR(r)	(r + 0x024)
+#define SSP_CSR(r)	(r + 0x030) /* vendor extension */
 #define SSP_ITCR(r)	(r + 0x080)
 #define SSP_ITIP(r)	(r + 0x084)
 #define SSP_ITOP(r)	(r + 0x088)
@@ -198,6 +199,12 @@
 #define SSP_DMACR_MASK_TXDMAE		(0x1UL << 1)
 
 /*
+ * SSP Chip Select Control Register - SSP_CSR
+ * (vendor extension)
+ */
+#define SSP_CSR_CSVALUE_MASK		(0x1FUL << 0)
+
+/*
  * SSP Integration Test control Register - SSP_ITCR
  */
 #define SSP_ITCR_MASK_ITEN		(0x1UL << 0)
@@ -313,6 +320,7 @@ enum ssp_writing {
  * @extended_cr: 32 bit wide control register 0 with extra
  * features and extra features in CR1 as found in the ST variants
  * @pl023: supports a subset of the ST extensions called "PL023"
+ * @internal_cs_ctrl: supports chip select control register
  */
 struct vendor_data {
 	int fifodepth;
@@ -321,6 +329,7 @@ struct vendor_data {
 	bool extended_cr;
 	bool pl023;
 	bool loopback;
+	bool internal_cs_ctrl;
 };
 
 /**
@@ -440,9 +449,32 @@ static void null_cs_control(u32 command)
 	pr_debug("pl022: dummy chip select control, CS=0x%x\n", command);
 }
 
+/**
+ * internal_cs_control - Control chip select signals via SSP_CSR.
+ * @pl022: SSP driver private data structure
+ * @command: select/delect the chip
+ *
+ * Used on controller with internal chip select control via SSP_CSR register
+ * (vendor extension). Each of the 5 LSB in the register controls one chip
+ * select signal.
+ */
+static void internal_cs_control(struct pl022 *pl022, u32 command)
+{
+	u32 tmp;
+
+	tmp = readw(SSP_CSR(pl022->virtbase));
+	if (command == SSP_CHIP_SELECT)
+		tmp &= ~BIT(pl022->cur_cs);
+	else
+		tmp |= BIT(pl022->cur_cs);
+	writew(tmp, SSP_CSR(pl022->virtbase));
+}
+
 static void pl022_cs_control(struct pl022 *pl022, u32 command)
 {
-	if (gpio_is_valid(pl022->cur_cs))
+	if (pl022->vendor->internal_cs_ctrl)
+		internal_cs_control(pl022, command);
+	else if (gpio_is_valid(pl022->cur_cs))
 		gpio_set_value(pl022->cur_cs, command);
 	else
 		pl022->cur_chip->cs_control(command);
@@ -2118,6 +2150,9 @@ static int pl022_probe(struct amba_device *adev, const struct amba_id *id)
 	if (platform_info->num_chipselect && platform_info->chipselects) {
 		for (i = 0; i < num_cs; i++)
 			pl022->chipselects[i] = platform_info->chipselects[i];
+	} else if (pl022->vendor->internal_cs_ctrl) {
+		for (i = 0; i < num_cs; i++)
+			pl022->chipselects[i] = i;
 	} else if (IS_ENABLED(CONFIG_OF)) {
 		for (i = 0; i < num_cs; i++) {
 			int cs_gpio = of_get_named_gpio(np, "cs-gpios", i);
@@ -2347,6 +2382,7 @@ static struct vendor_data vendor_arm = {
 	.extended_cr = false,
 	.pl023 = false,
 	.loopback = true,
+	.internal_cs_ctrl = false,
 };
 
 static struct vendor_data vendor_st = {
@@ -2356,6 +2392,7 @@ static struct vendor_data vendor_st = {
 	.extended_cr = true,
 	.pl023 = false,
 	.loopback = true,
+	.internal_cs_ctrl = false,
 };
 
 static struct vendor_data vendor_st_pl023 = {
@@ -2365,6 +2402,17 @@ static struct vendor_data vendor_st_pl023 = {
 	.extended_cr = true,
 	.pl023 = true,
 	.loopback = false,
+	.internal_cs_ctrl = false,
+};
+
+static struct vendor_data vendor_lsi = {
+	.fifodepth = 8,
+	.max_bpw = 16,
+	.unidir = false,
+	.extended_cr = false,
+	.pl023 = false,
+	.loopback = true,
+	.internal_cs_ctrl = true,
 };
 
 static struct amba_id pl022_ids[] = {
@@ -2398,6 +2446,15 @@ static struct amba_id pl022_ids[] = {
 		.mask	= 0xffffffff,
 		.data	= &vendor_st_pl023,
 	},
+	{
+		/*
+		 * PL022 variant that has a chip select control register whih
+		 * allows control of 5 output signals nCS[0:4].
+		 */
+		.id	= 0x000b6022,
+		.mask	= 0x000fffff,
+		.data	= &vendor_lsi,
+	},
 	{ 0, 0 },
 };
 
diff --git a/include/linux/amba/bus.h b/include/linux/amba/bus.h
index fdd7e1b..c324f57 100644
--- a/include/linux/amba/bus.h
+++ b/include/linux/amba/bus.h
@@ -44,10 +44,15 @@ struct amba_driver {
 	const struct amba_id	*id_table;
 };
 
+/*
+ * Constants for the designer field of the Peripheral ID register. When bit 7
+ * is set to '1', bits [6:0] should be the JEP106 manufacturer identity code.
+ */
 enum amba_vendor {
 	AMBA_VENDOR_ARM = 0x41,
 	AMBA_VENDOR_ST = 0x80,
 	AMBA_VENDOR_QCOM = 0x51,
+	AMBA_VENDOR_LSI = 0xb6,
 };
 
 extern struct bus_type amba_bustype;
-- 
1.9.1


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

* Re: [PATCH v2] spi: pl022: Add support for chip select extension
  2014-09-15 11:38 [PATCH v2] spi: pl022: Add support for chip select extension Anders Berg
@ 2014-09-16 18:34 ` Mark Brown
  2014-09-17  6:46   ` Anders Berg
  0 siblings, 1 reply; 8+ messages in thread
From: Mark Brown @ 2014-09-16 18:34 UTC (permalink / raw)
  To: Anders Berg; +Cc: Linus Walleij, linux-arm-kernel, linux-spi, linux-kernel

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

On Mon, Sep 15, 2014 at 01:38:52PM +0200, Anders Berg wrote:

> v2:
>     - added constant to <linux/amba/bus.h>

Since you're editing the AMBA code you should also CC Russell so he can
review the AMBA part of the change.

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

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

* [PATCH v2] spi: pl022: Add support for chip select extension
  2014-09-16 18:34 ` Mark Brown
@ 2014-09-17  6:46   ` Anders Berg
  2014-09-23 15:30     ` Linus Walleij
  2014-09-24  8:32     ` Mark Brown
  0 siblings, 2 replies; 8+ messages in thread
From: Anders Berg @ 2014-09-17  6:46 UTC (permalink / raw)
  To: Mark Brown, Linus Walleij
  Cc: Russell King, linux-arm-kernel, linux-spi, linux-kernel, Anders Berg

Add support for a extended PL022 which has an extra register for controlling up
to five chip select signals. This controller is found on the AXM5516 SoC.
Unfortunately the PrimeCell identification registers are identical to a
standard ARM PL022. To work around this, the peripheral ID must be overridden
in the device tree using the "arm,primecell-periphid" property with the value
0x000b6022.

Signed-off-by: Anders Berg <anders.berg@avagotech.com>
---

Adding Russell to Cc.

Changelog:

v2:
    - added constant to <linux/amba/bus.h>

 drivers/spi/spi-pl022.c  | 59 +++++++++++++++++++++++++++++++++++++++++++++++-
 include/linux/amba/bus.h |  5 ++++
 2 files changed, 63 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c
index 1189cfd..b395489 100644
--- a/drivers/spi/spi-pl022.c
+++ b/drivers/spi/spi-pl022.c
@@ -82,6 +82,7 @@
 #define SSP_MIS(r)	(r + 0x01C)
 #define SSP_ICR(r)	(r + 0x020)
 #define SSP_DMACR(r)	(r + 0x024)
+#define SSP_CSR(r)	(r + 0x030) /* vendor extension */
 #define SSP_ITCR(r)	(r + 0x080)
 #define SSP_ITIP(r)	(r + 0x084)
 #define SSP_ITOP(r)	(r + 0x088)
@@ -198,6 +199,12 @@
 #define SSP_DMACR_MASK_TXDMAE		(0x1UL << 1)
 
 /*
+ * SSP Chip Select Control Register - SSP_CSR
+ * (vendor extension)
+ */
+#define SSP_CSR_CSVALUE_MASK		(0x1FUL << 0)
+
+/*
  * SSP Integration Test control Register - SSP_ITCR
  */
 #define SSP_ITCR_MASK_ITEN		(0x1UL << 0)
@@ -313,6 +320,7 @@ enum ssp_writing {
  * @extended_cr: 32 bit wide control register 0 with extra
  * features and extra features in CR1 as found in the ST variants
  * @pl023: supports a subset of the ST extensions called "PL023"
+ * @internal_cs_ctrl: supports chip select control register
  */
 struct vendor_data {
 	int fifodepth;
@@ -321,6 +329,7 @@ struct vendor_data {
 	bool extended_cr;
 	bool pl023;
 	bool loopback;
+	bool internal_cs_ctrl;
 };
 
 /**
@@ -440,9 +449,32 @@ static void null_cs_control(u32 command)
 	pr_debug("pl022: dummy chip select control, CS=0x%x\n", command);
 }
 
+/**
+ * internal_cs_control - Control chip select signals via SSP_CSR.
+ * @pl022: SSP driver private data structure
+ * @command: select/delect the chip
+ *
+ * Used on controller with internal chip select control via SSP_CSR register
+ * (vendor extension). Each of the 5 LSB in the register controls one chip
+ * select signal.
+ */
+static void internal_cs_control(struct pl022 *pl022, u32 command)
+{
+	u32 tmp;
+
+	tmp = readw(SSP_CSR(pl022->virtbase));
+	if (command == SSP_CHIP_SELECT)
+		tmp &= ~BIT(pl022->cur_cs);
+	else
+		tmp |= BIT(pl022->cur_cs);
+	writew(tmp, SSP_CSR(pl022->virtbase));
+}
+
 static void pl022_cs_control(struct pl022 *pl022, u32 command)
 {
-	if (gpio_is_valid(pl022->cur_cs))
+	if (pl022->vendor->internal_cs_ctrl)
+		internal_cs_control(pl022, command);
+	else if (gpio_is_valid(pl022->cur_cs))
 		gpio_set_value(pl022->cur_cs, command);
 	else
 		pl022->cur_chip->cs_control(command);
@@ -2118,6 +2150,9 @@ static int pl022_probe(struct amba_device *adev, const struct amba_id *id)
 	if (platform_info->num_chipselect && platform_info->chipselects) {
 		for (i = 0; i < num_cs; i++)
 			pl022->chipselects[i] = platform_info->chipselects[i];
+	} else if (pl022->vendor->internal_cs_ctrl) {
+		for (i = 0; i < num_cs; i++)
+			pl022->chipselects[i] = i;
 	} else if (IS_ENABLED(CONFIG_OF)) {
 		for (i = 0; i < num_cs; i++) {
 			int cs_gpio = of_get_named_gpio(np, "cs-gpios", i);
@@ -2347,6 +2382,7 @@ static struct vendor_data vendor_arm = {
 	.extended_cr = false,
 	.pl023 = false,
 	.loopback = true,
+	.internal_cs_ctrl = false,
 };
 
 static struct vendor_data vendor_st = {
@@ -2356,6 +2392,7 @@ static struct vendor_data vendor_st = {
 	.extended_cr = true,
 	.pl023 = false,
 	.loopback = true,
+	.internal_cs_ctrl = false,
 };
 
 static struct vendor_data vendor_st_pl023 = {
@@ -2365,6 +2402,17 @@ static struct vendor_data vendor_st_pl023 = {
 	.extended_cr = true,
 	.pl023 = true,
 	.loopback = false,
+	.internal_cs_ctrl = false,
+};
+
+static struct vendor_data vendor_lsi = {
+	.fifodepth = 8,
+	.max_bpw = 16,
+	.unidir = false,
+	.extended_cr = false,
+	.pl023 = false,
+	.loopback = true,
+	.internal_cs_ctrl = true,
 };
 
 static struct amba_id pl022_ids[] = {
@@ -2398,6 +2446,15 @@ static struct amba_id pl022_ids[] = {
 		.mask	= 0xffffffff,
 		.data	= &vendor_st_pl023,
 	},
+	{
+		/*
+		 * PL022 variant that has a chip select control register whih
+		 * allows control of 5 output signals nCS[0:4].
+		 */
+		.id	= 0x000b6022,
+		.mask	= 0x000fffff,
+		.data	= &vendor_lsi,
+	},
 	{ 0, 0 },
 };
 
diff --git a/include/linux/amba/bus.h b/include/linux/amba/bus.h
index fdd7e1b..c324f57 100644
--- a/include/linux/amba/bus.h
+++ b/include/linux/amba/bus.h
@@ -44,10 +44,15 @@ struct amba_driver {
 	const struct amba_id	*id_table;
 };
 
+/*
+ * Constants for the designer field of the Peripheral ID register. When bit 7
+ * is set to '1', bits [6:0] should be the JEP106 manufacturer identity code.
+ */
 enum amba_vendor {
 	AMBA_VENDOR_ARM = 0x41,
 	AMBA_VENDOR_ST = 0x80,
 	AMBA_VENDOR_QCOM = 0x51,
+	AMBA_VENDOR_LSI = 0xb6,
 };
 
 extern struct bus_type amba_bustype;
-- 
1.9.1


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

* Re: [PATCH v2] spi: pl022: Add support for chip select extension
  2014-09-17  6:46   ` Anders Berg
@ 2014-09-23 15:30     ` Linus Walleij
  2014-09-24  8:32     ` Mark Brown
  1 sibling, 0 replies; 8+ messages in thread
From: Linus Walleij @ 2014-09-23 15:30 UTC (permalink / raw)
  To: Anders Berg
  Cc: Mark Brown, Russell King, linux-arm-kernel, linux-spi, linux-kernel

On Wed, Sep 17, 2014 at 8:46 AM, Anders Berg <anders.berg@avagotech.com> wrote:

> Add support for a extended PL022 which has an extra register for controlling up
> to five chip select signals. This controller is found on the AXM5516 SoC.
> Unfortunately the PrimeCell identification registers are identical to a
> standard ARM PL022. To work around this, the peripheral ID must be overridden
> in the device tree using the "arm,primecell-periphid" property with the value
> 0x000b6022.
>
> Signed-off-by: Anders Berg <anders.berg@avagotech.com>
> ---
>
> Adding Russell to Cc.
>
> Changelog:
>
> v2:
>     - added constant to <linux/amba/bus.h>

Acked-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

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

* Re: [PATCH v2] spi: pl022: Add support for chip select extension
  2014-09-17  6:46   ` Anders Berg
  2014-09-23 15:30     ` Linus Walleij
@ 2014-09-24  8:32     ` Mark Brown
  2014-09-24  8:33       ` Mark Brown
  1 sibling, 1 reply; 8+ messages in thread
From: Mark Brown @ 2014-09-24  8:32 UTC (permalink / raw)
  To: Anders Berg
  Cc: Linus Walleij, Russell King, linux-arm-kernel, linux-spi, linux-kernel

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

On Wed, Sep 17, 2014 at 08:46:58AM +0200, Anders Berg wrote:
> Add support for a extended PL022 which has an extra register for controlling up
> to five chip select signals. This controller is found on the AXM5516 SoC.
> Unfortunately the PrimeCell identification registers are identical to a
> standard ARM PL022. To work around this, the peripheral ID must be overridden
> in the device tree using the "arm,primecell-periphid" property with the value
> 0x000b6022.

Applied, thanks.

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

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

* Re: [PATCH v2] spi: pl022: Add support for chip select extension
  2014-09-24  8:32     ` Mark Brown
@ 2014-09-24  8:33       ` Mark Brown
  2014-09-24  9:23         ` Russell King - ARM Linux
  0 siblings, 1 reply; 8+ messages in thread
From: Mark Brown @ 2014-09-24  8:33 UTC (permalink / raw)
  To: Anders Berg
  Cc: Linus Walleij, Russell King, linux-arm-kernel, linux-spi, linux-kernel

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

On Wed, Sep 24, 2014 at 09:32:05AM +0100, Mark Brown wrote:
> On Wed, Sep 17, 2014 at 08:46:58AM +0200, Anders Berg wrote:
> > Add support for a extended PL022 which has an extra register for controlling up
> > to five chip select signals. This controller is found on the AXM5516 SoC.
> > Unfortunately the PrimeCell identification registers are identical to a
> > standard ARM PL022. To work around this, the peripheral ID must be overridden
> > in the device tree using the "arm,primecell-periphid" property with the value
> > 0x000b6022.
> 
> Applied, thanks.

Actually there's still the amba/bus.h update in here - I'll hold off for
a while yet so Russell has a chance to review.

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

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

* Re: [PATCH v2] spi: pl022: Add support for chip select extension
  2014-09-24  8:33       ` Mark Brown
@ 2014-09-24  9:23         ` Russell King - ARM Linux
  2014-09-24  9:26           ` Mark Brown
  0 siblings, 1 reply; 8+ messages in thread
From: Russell King - ARM Linux @ 2014-09-24  9:23 UTC (permalink / raw)
  To: Mark Brown
  Cc: Anders Berg, Linus Walleij, linux-kernel, linux-arm-kernel, linux-spi

On Wed, Sep 24, 2014 at 09:33:31AM +0100, Mark Brown wrote:
> On Wed, Sep 24, 2014 at 09:32:05AM +0100, Mark Brown wrote:
> > On Wed, Sep 17, 2014 at 08:46:58AM +0200, Anders Berg wrote:
> > > Add support for a extended PL022 which has an extra register for controlling up
> > > to five chip select signals. This controller is found on the AXM5516 SoC.
> > > Unfortunately the PrimeCell identification registers are identical to a
> > > standard ARM PL022. To work around this, the peripheral ID must be overridden
> > > in the device tree using the "arm,primecell-periphid" property with the value
> > > 0x000b6022.
> > 
> > Applied, thanks.
> 
> Actually there's still the amba/bus.h update in here - I'll hold off for
> a while yet so Russell has a chance to review.

It's fine.  I'd prefer to have seen the vendor list ordered in some way
(since it's neither alphabetical nor numerical with its existing three
entries) but that would be the subject of a separate patch.

Acked-by: Russell King <rmk+kernel@arm.linux.org.uk>

-- 
FTTC broadband for 0.8mile line: currently at 9.5Mbps down 400kbps up
according to speedtest.net.

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

* Re: [PATCH v2] spi: pl022: Add support for chip select extension
  2014-09-24  9:23         ` Russell King - ARM Linux
@ 2014-09-24  9:26           ` Mark Brown
  0 siblings, 0 replies; 8+ messages in thread
From: Mark Brown @ 2014-09-24  9:26 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: Anders Berg, Linus Walleij, linux-kernel, linux-arm-kernel, linux-spi

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

On Wed, Sep 24, 2014 at 10:23:12AM +0100, Russell King - ARM Linux wrote:

> It's fine.  I'd prefer to have seen the vendor list ordered in some way
> (since it's neither alphabetical nor numerical with its existing three
> entries) but that would be the subject of a separate patch.

> Acked-by: Russell King <rmk+kernel@arm.linux.org.uk>

Thanks, applied now.

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

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

end of thread, other threads:[~2014-09-24  9:27 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-15 11:38 [PATCH v2] spi: pl022: Add support for chip select extension Anders Berg
2014-09-16 18:34 ` Mark Brown
2014-09-17  6:46   ` Anders Berg
2014-09-23 15:30     ` Linus Walleij
2014-09-24  8:32     ` Mark Brown
2014-09-24  8:33       ` Mark Brown
2014-09-24  9:23         ` Russell King - ARM Linux
2014-09-24  9:26           ` Mark Brown

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