Skip to contentSkip to conversation

Add Freescale DSPI driver for Vybrid VF610 platform

PATCH Superseded Chao Fu 2 participants 7 messages Aug 16, 2013 – Aug 22, 2013

Subsystems (3)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Chao Fu

author
#0 lore raw

v3 cover Add Freescale DSPI driver for Vybrid VF610 platform

This driver is the SPI master mode driver and has been tested on Vybrid VF610TWR board. Changes in v2:
- Add a document for DSPI driver under Documentation/devicetree/bindings/spi/.
- Move spi-num-chipselects info dtsi nodes.
Changes in v3:
- Remove two dts properties(dbr,pbr) from documentation bindings, they will be calculated in code.
- Update driver code in bitbang framework.
- Brief some functions in driver code.

author
#1 lore raw

PATCH v3 1/4 ARM:dts: vf610: Add DSPI nodes

From: Chao Fu <[email protected]>

Add Freescale DSPI node into vf610 dts.

---
 arch/arm/boot/dts/vf610.dtsi | 12 ++++++++++++
 1 file changed, 12 insertions(+)
arch/arm/boot/dts/vf610.dtsi +12 -0
index 67d929c..af687a4 100644
@@ -87,6 +87,18 @@
 				arm,tag-latency = <2 2 2>;
 			};
 
+			dspi0: dspi0 at 4002c000 {
+				#address-cells = <1>;
+				#size-cells = <0>;
+				compatible = "fsl,vf610-dspi";
+				reg = <0x4002c000 0x1000>;
+				interrupts = <0 67 0x04>;
+				clocks = <&clks VF610_CLK_DSPI0>;
+				clock-names = "dspi";
+				spi-num-chipselects = <5>;
+				status = "disabled";
+			};
+
 			uart0: serial at 40027000 {
 				compatible = "fsl,vf610-lpuart";
 				reg = <0x40027000 0x1000>;
Signature · 1 line
1.8.0
author
#2 lore raw

PATCH v3 2/4 ARM:dts:vf610-twr:Enable DSPI0 devices and Flash at26df081a

In reply to Chao Fu

From: Chao Fu <[email protected]>

This patch enables DSPI0 and at26df081a flash device for Vybrid VF610 TOWER board.

---
 arch/arm/boot/dts/vf610-twr.dts | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
arch/arm/boot/dts/vf610-twr.dts +19 -0
index b3905f5..d29226c 100644
@@ -36,6 +36,25 @@
 
 };
 
+&dspi0 {
+	bus-num = <0>;
+	pinctrl-names = "default";
+	pinctrl-0 = <&pinctrl_dspi0_1>;
+	status = "okay";
+
+	sflash: at26df081a at 0 {
+		#address-cells = <1>;
+		#size-cells = <1>;
+		compatible = "atmel,at26df081a";
+		spi-max-frequency = <16000000>;
+		spi-cpol;
+		spi-cpha;
+		reg = <0>;
+		linux,modalias = "m25p80";
+		modal = "at26df081a";
+	};
+};
+
 &fec0 {
 	phy-mode = "rmii";
 	pinctrl-names = "default";
Signature · 1 line
1.8.0
author
#3 lore raw

PATCH v3 3/4 Documentation: DT: Add Freescale DSPI driver

In reply to Chao Fu

From: Chao Fu <[email protected]>

This patch adds the document for DSPI driver under Documentation/devicetree/bindings/spi/.

---
 .../devicetree/bindings/spi/spi-fsl-dspi.txt       | 42 ++++++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/spi/spi-fsl-dspi.txt
Documentation/devicetree/bindings/spi/spi-fsl-dspi.txt new file +42 -0
new file mode 100644
index 0000000..a1fb303
@@ -0,0 +1,42 @@
+ARM Freescale DSPI controller
+
+Required properties:
+- compatible : "fsl,vf610-dspi"
+- reg : Offset and length of the register set for the device
+- interrupts : Should contain SPI controller interrupt
+- clocks: from common clock binding: handle to dspi clock.
+- clock-names: from common clock binding: Shall be "dspi".
+- pinctrl-0: pin control group to be used for this controller.
+- pinctrl-names: must contain a "default" entry.
+- spi-num-chipselects : the number of the chipselect signals.
+- bus-num : the slave chip chipselect signal number.
+Example:
+
+dspi0 at 4002c000 {
+	#address-cells = <1>;
+	#size-cells = <0>;
+	compatible = "fsl,vf610-dspi";
+	reg = <0x4002c000 0x1000>;
+	interrupts = <0 67 0x04>;
+	clocks = <&clks VF610_CLK_DSPI0>;
+	clock-names = "dspi";
+	spi-num-chipselects = <5>;
+	bus-num = <0>;
+	pinctrl-names = "default";
+	pinctrl-0 = <&pinctrl_dspi0_1>;
+	status = "okay";
+
+	sflash: at26df081a at 0 {
+		#address-cells = <1>;
+		#size-cells = <1>;
+		compatible = "atmel,at26df081a";
+		spi-max-frequency = <16000000>;
+		spi-cpol;
+		spi-cpha;
+		reg = <0>;
+		linux,modalias = "m25p80";
+		modal = "at26df081a";
+	};
+};
+
+
Signature · 1 line
1.8.0
maintainer
#4 lore raw

PATCH v3 3/4 Documentation: DT: Add Freescale DSPI driver

Quoted 4 lines · Chao Fu

From: Chao Fu <[email protected]>

This patch adds the document for DSPI driver under Documentation/devicetree/bindings/spi/.

Applied, thanks.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20130822/d1296a7a/attachment-0001.sig>

author
#5 lore raw

PATCH v3 4/4 spi:Add Freescale DSPI driver for Vybrid VF610 platform

In reply to Chao Fu

From: Chao Fu <[email protected]>

The serial peripheral interface (SPI) module implemented on Freescale Vybrid platform provides a synchronous serial bus for communication between Vybrid and the external peripheral device.
The SPI supports full-duplex, three-wire synchronous transfer, has TX/RX FIFO with depth of four entries.

This driver is the SPI master mode driver and has been tested on Vybrid VF610TWR board.

---
 drivers/spi/Kconfig        |   7 +
 drivers/spi/Makefile       |   1 +
 drivers/spi/spi-fsl-dspi.c | 557 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 565 insertions(+)
 create mode 100644 drivers/spi/spi-fsl-dspi.c
drivers/spi/Kconfig +7 -0
index 9e61107..ba5ae05 100644
@@ -255,6 +255,13 @@ config SPI_FSL_SPI
 	  This also enables using the Aeroflex Gaisler GRLIB SPI controller in
 	  master mode.
 
+config SPI_FSL_DSPI
+	tristate "Freescale DSPI controller"
+	select SPI_BITBANG
+	help
+	  This enables support for the Freescale DSPI controller in master
+	  mode. VF610 platform uses the controller.
+
 config SPI_FSL_ESPI
 	bool "Freescale eSPI controller"
 	depends on FSL_SOC
drivers/spi/Makefile +1 -0
index 7c41702..aaacc93 100644
@@ -31,6 +31,7 @@ spi-dw-midpci-objs			:= spi-dw-pci.o spi-dw-mid.o
 obj-$(CONFIG_SPI_EP93XX)		+= spi-ep93xx.o
 obj-$(CONFIG_SPI_FALCON)		+= spi-falcon.o
 obj-$(CONFIG_SPI_FSL_CPM)		+= spi-fsl-cpm.o
+obj-$(CONFIG_SPI_FSL_DSPI)		+= spi-fsl-dspi.o
 obj-$(CONFIG_SPI_FSL_LIB)		+= spi-fsl-lib.o
 obj-$(CONFIG_SPI_FSL_ESPI)		+= spi-fsl-espi.o
 obj-$(CONFIG_SPI_FSL_SPI)		+= spi-fsl-spi.o
drivers/spi/spi-fsl-dspi.c new file +557 -0

557 lines not on this page · raw message

Signature · 1 line
1.8.0
maintainer Applied
#6 lore raw

PATCH v3 4/4 spi:Add Freescale DSPI driver for Vybrid VF610 platform

Quoted 7 lines · Chao Fu

From: Chao Fu <[email protected]>

The serial peripheral interface (SPI) module implemented on Freescale Vybrid platform provides a synchronous serial bus for communication between Vybrid and the external peripheral device.
The SPI supports full-duplex, three-wire synchronous transfer, has TX/RX FIFO with depth of four entries.

Applied, thanks. Couple of things though:

drivers/spi/spi-fsl-dspi.c line 394

Quoted 6 lines
drivers/spi/spi-fsl-dspi.c new file +6 -0
+
+	if (!dspi->len) {
+		if (dspi->dataflags & TRAN_STATE_WORD_ODD_NUM)
+			set_bit_mode(dspi, 16);
+		dspi->waitflags = 1;
+		wake_up_interruptible(&dspi->waitq);

There's no reason for this to be interruptible.

drivers/spi/spi-fsl-dspi.c line 417

Quoted 7 lines
drivers/spi/spi-fsl-dspi.c new file +7 -0
+static int dspi_suspend(struct device *dev)
+{
+	struct spi_master *master = dev_get_drvdata(dev);
+	struct fsl_dspi *dspi = spi_master_get_devdata(master);
+
+	spi_master_suspend(master);
+	clk_disable_unprepare(dspi->clk);

You could get a small power optimisation by enabling and disabling the
clock using runtime PM instead so it's only active while the controller
is actually being used rather than whenever the CPU is active.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20130822/601758fc/attachment.sig>