Skip to contentSkip to conversation

xtensa xtfpga SPI controller driver

PATCH Superseded Max Filippov 3 participants 8 messages Mar 12, 2014

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Max Filippov

author maintainer
#0 lore raw

v2 cover xtensa xtfpga SPI controller driver

Hello,

this series adds driver for SPI controller used on xtfpga xtensa platform, device tree binding documentation and an entry to MAINTAINERS.

Changes v1 -> v2:
- support 8 bit transfers;
- busy-wait for maximum 100 usec (instead of 100 msec) polling BUSY register;
- use chipselect callback to check transfer size.

Max Filippov (3):
spi: add xtfpga SPI controller driver
spi/xtensa-xtfpga: add DT binding documentation
MAINTAINERS: add xtfpga platform section

 .../devicetree/bindings/spi/spi-xtensa-xtfpga.txt  |   9 +
 MAINTAINERS                                        |   6 +
 drivers/spi/Kconfig                                |  13 ++
 drivers/spi/Makefile                               |   1 +
 drivers/spi/spi-xtensa-xtfpga.c                    | 187 +++++++++++++++++++++
 5 files changed, 216 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/spi/spi-xtensa-xtfpga.txt
 create mode 100644 drivers/spi/spi-xtensa-xtfpga.c
Signature · 6 lines
1.8.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
author maintainer
#1 lore raw

PATCH v2 1/3 spi: add xtfpga SPI controller driver

This simple SPI master controller is built into xtfpga bitstreams. It always transfers 16 bit words in SPI mode 0, automatically asserting CS on transfer start and deasserting on end.

---
Changes v1 -> v2:
- support 8 bit transfers;
- busy-wait for maximum 100 usec (instead of 100 msec) polling BUSY register;
- use chipselect callback to check transfer size.

 drivers/spi/Kconfig             |  13 +++
 drivers/spi/Makefile            |   1 +
 drivers/spi/spi-xtensa-xtfpga.c | 187 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 201 insertions(+)
 create mode 100644 drivers/spi/spi-xtensa-xtfpga.c
drivers/spi/Kconfig +13 -0
index 581ee2a..e3f5335 100644
@@ -520,6 +520,19 @@ config SPI_XILINX
 
 	  Or for the DS570, see "XPS Serial Peripheral Interface (SPI) (v2.00b)"
 
+config SPI_XTENSA_XTFPGA
+	tristate "Xtensa SPI controller for xtfpga"
+	depends on XTENSA && XTENSA_PLATFORM_XTFPGA
+	select SPI_BITBANG
+	help
+	  SPI driver for xtfpga SPI master controller.
+
+	  This simple SPI master controller is built into xtfpga bitstreams
+	  and is used to control daughterboard audio codec. It always transfers
+	  16 bit words in SPI mode 0, automatically asserting CS on transfer
+	  start and deasserting on end.
+
+
 config SPI_NUC900
 	tristate "Nuvoton NUC900 series SPI"
 	depends on ARCH_W90X900
drivers/spi/Makefile +1 -0
index 95af48d..5379ade 100644
@@ -79,3 +79,4 @@ obj-$(CONFIG_SPI_TOPCLIFF_PCH)		+= spi-topcliff-pch.o
 obj-$(CONFIG_SPI_TXX9)			+= spi-txx9.o
 obj-$(CONFIG_SPI_XCOMM)		+= spi-xcomm.o
 obj-$(CONFIG_SPI_XILINX)		+= spi-xilinx.o
+obj-$(CONFIG_SPI_XTENSA_XTFPGA)		+= spi-xtensa-xtfpga.o
drivers/spi/spi-xtensa-xtfpga.c new file +187 -0

187 lines not on this page · raw message

Signature · 1 line
1.8.1.4
maintainer
#2 lore raw

Re: [PATCH v2 1/3] spi: add xtfpga SPI controller driver

drivers/spi/spi-xtensa-xtfpga.c line 73

Quoted 8 lines · Max Filippov
drivers/spi/spi-xtensa-xtfpga.c new file +8 -0
+	case 16:
+		/* Bytes that should go out earlier have lower addresses,
+		 * but the hardware operates with 16 bit words and transmits
+		 * higher bits first. Thus data in memory is in BE order.
+		 */
+		xspi->data = (xspi->data << 16) | be16_to_cpu(v);
+		xspi->data_sz += 2;
+		break;

Are you sure you need to do this byte swap? SPI words are big endian so if you are running on a little endian processor if you are transmitting 16 bit words you should see the data getting swapped on the bus (this is why I say you should never have more than 8 bits per word for regmap).

author maintainer
#3 lore raw

Re: [PATCH v2 1/3] spi: add xtfpga SPI controller driver

Quoted 11 lines · Mark Brown

drivers/spi/spi-xtensa-xtfpga.c line 73

Quoted 8 lines · Max Filippov
drivers/spi/spi-xtensa-xtfpga.c new file +8 -0
+     case 16:
+             /* Bytes that should go out earlier have lower addresses,
+              * but the hardware operates with 16 bit words and transmits
+              * higher bits first. Thus data in memory is in BE order.
+              */
+             xspi->data = (xspi->data << 16) | be16_to_cpu(v);
+             xspi->data_sz += 2;
+             break;
Quoted 4 lines

Are you sure you need to do this byte swap? SPI words are big endian so if you are running on a little endian processor if you are transmitting 16 bit words you should see the data getting swapped on the bus (this is why I say you should never have more than 8 bits per word for regmap).

Looks like this swap is not needed: I've looked at drivers that set bits_per_word = 16, they submit data in cpu endianness. Will fix in v3.

Signature · 6 lines
Thanks.
-- Max
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
author maintainer
#4 lore raw

PATCH v2 2/3 spi/xtensa-xtfpga: add DT binding documentation

In reply to Max Filippov
---
 Documentation/devicetree/bindings/spi/spi-xtensa-xtfpga.txt | 9 +++++++++
 1 file changed, 9 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/spi/spi-xtensa-xtfpga.txt
Documentation/devicetree/bindings/spi/spi-xtensa-xtfpga.txt new file +9 -0
new file mode 100644
index 0000000..b6ebe2b
@@ -0,0 +1,9 @@
+Cadence Xtensa XTFPGA platform SPI controller.
+
+This simple SPI master controller is built into xtfpga bitstreams and is used
+to control daughterboard audio codec.
+
+Required properties:
+- compatible: should be "cdns,xtfpga-spi".
+- reg: physical base address of the controller and length of memory mapped
+  region.
Signature · 6 lines
1.8.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#5 lore raw

Re: [PATCH v2 2/3] spi/xtensa-xtfpga: add DT binding documentation

Quoted 12 lines · Max Filippov
---
 Documentation/devicetree/bindings/spi/spi-xtensa-xtfpga.txt | 9 +++++++++
 1 file changed, 9 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/spi/spi-xtensa-xtfpga.txt
Documentation/devicetree/bindings/spi/spi-xtensa-xtfpga.txt new file +0 -0
new file mode 100644
index 0000000..b6ebe2b

Documentation/devicetree/bindings/spi/spi-xtensa-xtfpga.txt line 7

Quoted 7 lines
Documentation/devicetree/bindings/spi/spi-xtensa-xtfpga.txt new file +7 -0
@@ -0,0 +1,9 @@
+Cadence Xtensa XTFPGA platform SPI controller.
+
+This simple SPI master controller is built into xtfpga bitstreams and is used
+to control daughterboard audio codec.
+
+Required properties:
+- compatible: should be "cdns,xtfpga-spi".

Is that the official name of the block? Nothing more specific?

Documentation/devicetree/bindings/spi/spi-xtensa-xtfpga.txt line 9

Quoted 2 lines
Documentation/devicetree/bindings/spi/spi-xtensa-xtfpga.txt new file +2 -0
+- reg: physical base address of the controller and length of memory mapped
+  region.

No interrupts?

Otherwise, this looks fine to me.

Cheers,
Mark.
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

author maintainer
#6 lore raw

Re: [PATCH v2 2/3] spi/xtensa-xtfpga: add DT binding documentation

Quoted 7 lines · Mark Rutland
Quoted 6 lines · Max Filippov
---
 Documentation/devicetree/bindings/spi/spi-xtensa-xtfpga.txt | 9 +++++++++
 1 file changed, 9 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/spi/spi-xtensa-xtfpga.txt
Quoted 15 lines

Documentation/devicetree/bindings/spi/spi-xtensa-xtfpga.txt line 7

Quoted 13 lines
Documentation/devicetree/bindings/spi/spi-xtensa-xtfpga.txt new file +7 -0
new file mode 100644
index 0000000..b6ebe2b
@@ -0,0 +1,9 @@
+Cadence Xtensa XTFPGA platform SPI controller.
+
+This simple SPI master controller is built into xtfpga bitstreams and is used
+to control daughterboard audio codec.
+
+Required properties:
+- compatible: should be "cdns,xtfpga-spi".

Is that the official name of the block? Nothing more specific?

There's no official name, so I composed this from the official name of the platform + the block function. AFAIK there's single version of this IP block. Marc G., please correct me if I'm wrong.

Quoted 4 lines

Documentation/devicetree/bindings/spi/spi-xtensa-xtfpga.txt line 9

Quoted 2 lines
Documentation/devicetree/bindings/spi/spi-xtensa-xtfpga.txt new file +2 -0
+- reg: physical base address of the controller and length of memory mapped
+  region.

No interrupts?

Correct.

Quoted 1 line

Otherwise, this looks fine to me.

Signature · 2 lines
Thanks.
-- Max
author maintainer
#7 lore raw

PATCH v2 3/3 MAINTAINERS: add xtfpga platform section

In reply to Max Filippov

This section will list xtfpga platform-specific drivers.

---
 MAINTAINERS | 6 ++++++
 1 file changed, 6 insertions(+)
MAINTAINERS +6 -0
index c6d0e93..9f75849 100644
@@ -9768,6 +9768,12 @@ L:	[email protected]
 S:	Maintained
 F:	drivers/tty/serial/uartlite.c
 
+XTENSA XTFPGA PLATFORM SUPPORT
+M:	Max Filippov <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	drivers/spi/spi-xtensa-xtfpga.c
+
 YAM DRIVER FOR AX.25
 M:	Jean-Paul Roubelat <[email protected]>
 L:	[email protected]
Signature · 1 line
1.8.1.4