Skip to contentSkip to conversation

mtd: spi-nor: Add driver for Cadence Quad SPI Flash Controller

PATCH Superseded Graham Moore 2 participants 5 messages Dec 5, 2014 – Dec 8, 2014

Subsystems (3)

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

cover mtd: spi-nor: Add driver for Cadence Quad SPI Flash Controller

This patchset provides a driver for the Cadence Quad SPI Flash Controller. This controller is used on SOCFPGA systems.

The driver was tested on Altera's Cyclone5 and Arria5 dev kits, with Micron n25q00 and n25q512 flash parts.

Comments from Ezequiel Garcia were incorporated.

Graham Moore (2):
mtd: spi-nor: Bindings for Cadence Quad SPI Flash Controller driver.
mtd: spi-nor: Add driver for Cadence Quad SPI Flash Controller.

 .../devicetree/bindings/mtd/cadence_quadspi.txt    |   50 +
 drivers/mtd/spi-nor/Kconfig                        |    6 +
 drivers/mtd/spi-nor/Makefile                       |    1 +
 drivers/mtd/spi-nor/cadence-quadspi.c              | 1281 ++++++++++++++++++++
 4 files changed, 1338 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mtd/cadence_quadspi.txt
 create mode 100644 drivers/mtd/spi-nor/cadence-quadspi.c
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/2 mtd: spi-nor: Bindings for Cadence Quad SPI Flash Controller driver.

---
 .../devicetree/bindings/mtd/cadence_quadspi.txt    |   50 ++++++++++++++++++++
 1 file changed, 50 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mtd/cadence_quadspi.txt
Documentation/devicetree/bindings/mtd/cadence_quadspi.txt new file +50 -0
new file mode 100644
index 0000000..3a8ea1c
@@ -0,0 +1,50 @@
+* Cadence Quad SPI controller
+
+Required properties:
+- compatible : Should be "cdns,qspi-nor".
+- reg : Contains two entries, each of which is a tuple consisting of a
+	physical address and length.  The first entry is the address and
+	length of the controller register set.  The second entry is the
+	address and length of the QSPI Controller data area.
+- interrupts : Unit interrupt specifier for the controller interrupt.
+- clocks : phandle to the Quad SPI clock.
+- ext-decoder : Value of 0 means no external chipselect decoder is
+	connected, 1 means there is an external chipselect decoder connected.
+- fifo-depth : Size of the data FIFO in words.
+- bus-num : Number of the SPI bus to which the controller is connected.
+
+Optional subnodes:
+Subnodes of the Cadence Quad SPI controller are spi slave nodes with additional
+custom properties:
+- cdns,page-size : Size, in bytes, of the device's write page
+- cdns,block-size : Size of the device's erase block
+- cdns,read-delay : Selay for read capture logic, in clock cycles
+- cdns,tshsl-ns : Delay in master reference clocks for the length that the master mode chip select outputs are de-asserted between transactions.
+- cdns,tsd2d-ns : Delay in master reference clocks between one chip select being de-activated and the activation of another.
+- cdns,tchsh-ns : Delay in master reference clocks between last bit of current transaction and deasserting the device chip select (qspi_n_ss_out).
+- cdns,tslch-ns : Delay in master reference clocks between setting qspi_n_ss_out low and first bit transfer.
+
+Example:
+
+	qspi: spi@ff705000 {
+		compatible = "cdns,qspi-nor";
+		#address-cells = <1>;
+		#size-cells = <0>;
+		reg = <0xff705000 0x1000>,
+			<0xffa00000 0x1000>;
+		interrupts = <0 151 4>;
+		clocks = <&qspi_clk>;
+		ext-decoder = <0>;
+		fifo-depth = <128>;
+
+		flash0: n25q00@0 {
+			...
+			cdns,page-size = <256>;
+			cdns,block-size = <16>;
+			cdns,read-delay = <4>;
+			cdns,tshsl-ns = <50>;
+			cdns,tsd2d-ns = <50>;
+			cdns,tchsh-ns = <4>;
+			cdns,tslch-ns = <4>;
+		}
+	}
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH 2/2 mtd: spi-nor: Add driver for Cadence Quad SPI Flash Controller.

In reply to Graham Moore
---
 drivers/mtd/spi-nor/Kconfig           |    6 +
 drivers/mtd/spi-nor/Makefile          |    1 +
 drivers/mtd/spi-nor/cadence-quadspi.c | 1281 +++++++++++++++++++++++++++++++++
 3 files changed, 1288 insertions(+)
 create mode 100644 drivers/mtd/spi-nor/cadence-quadspi.c
drivers/mtd/spi-nor/Kconfig +6 -0
index 64a4f0e..9485481 100644
@@ -28,4 +28,10 @@ config SPI_FSL_QUADSPI
 	  This enables support for the Quad SPI controller in master mode.
 	  We only connect the NOR to this controller now.
 
+config SPI_CADENCE_QUADSPI
+	tristate "Cadence Quad SPI controller"
+	depends on ARCH_SOCFPGA
+	help
+	  This enables support for the Cadence Quad SPI controller and NOR flash.
+
 endif # MTD_SPI_NOR
drivers/mtd/spi-nor/Makefile +1 -0
index 6a7ce14..372628c 100644
@@ -1,2 +1,3 @@
 obj-$(CONFIG_MTD_SPI_NOR)	+= spi-nor.o
+obj-$(CONFIG_SPI_CADENCE_QUADSPI)	+= cadence-quadspi.o
 obj-$(CONFIG_SPI_FSL_QUADSPI)	+= fsl-quadspi.o
drivers/mtd/spi-nor/cadence-quadspi.c new file +1281 -0

1,281 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#3 lore raw

Re: [PATCH 2/2] mtd: spi-nor: Add driver for Cadence Quad SPI Flash Controller.

drivers/mtd/spi-nor/cadence-quadspi.c line 1261

Quoted 12 lines · Graham Moore
drivers/mtd/spi-nor/cadence-quadspi.c new file +11 -0
+               if (of_modalias_node(np, modalias, sizeof(modalias)) < 0)
+                       goto probe_failed;
+
+               ret = spi_nor_scan(nor, modalias, SPI_NOR_QUAD);
+               if (ret)
+                       goto probe_failed;
(...)
+
+static struct of_device_id cqspi_dt_ids[] = {
+       {.compatible = "cdns,qspi-nor",},
+       { /* end of table */ }
+};

AFAIU of_modalias_node will give you "qspi-nor" string. Second argument passed to the spi_nor_scan is a chip name you expect on the device. Of course passing "qspi-nor" (if I'm right about of_modalias_node) doesn't make any sense.

Since my commit
mtd: spi-nor: allow NULL as chip name and try to auto detect it second argument is optional.

Can you simply pass NULL instead of modalias?

Signature · 1 line
Rafał
#4 lore raw

Re: [PATCH 2/2] mtd: spi-nor: Add driver for Cadence Quad SPI Flash Controller.

Quoted 6 lines · Rafał Miłecki

Since my commit
mtd: spi-nor: allow NULL as chip name and try to auto detect it second argument is optional.

Can you simply pass NULL instead of modalias?

OK, passing NULL. Works fine for me, thanks.

-Graham