Skip to contentSkip to conversation

add driver for Atmel QSPI controller

PATCH Superseded Cyrille Pitchen 4 participants 15 messages Jul 16, 2015 – Jul 20, 2015

Subsystems (5)

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

cover add driver for Atmel QSPI controller

Hi all,

in order to be able to use Micron Quad SPI memories with the new Atmel QSPI controller I added a new set_protocol() callback into struct spi_nor. Indeed, once the quad I/O mode has been enabled on a Micron QSPI flash by clearing bit 7 in its Enhanced Volatile Configuration Register, this memory expects all the following commands to use the QSPI 4-4-4 protocol. So the QSPI controller needs to be notified about this protocol change before reading the Status register, 0x05 command sent by the spi_nor_wail_till_ready() function, in micron_quad_enable().

Reading spi-nor.h, I saw an interesting struct spi_nor_xfer_cfg and its associated callbacks write_xfer() and read_xfer(). However these callbacks don't seem to be used at all for now. They look to have been designed to add QSPI support to the generic spi-nor framework. So before extending the framework with my own callback, I'd like to know whether I should have tried to used the read_xfer()/write_xfer() callbacks to join an already existing effort to add QSPI support.
If so, I think either the read/write_reg() prototypes should be updated or new callbacks should be added for register reads/writes. As explained above, even for reading the Status register the QSPI 4-4-4 protocol must be used with Micron memories in quad I/O mode. So the framework has to find a way to tell the QSPI controller which protocol it should use.

So I'm interested in your comments! :)

Best Regards,

Cyrille

ChangeLog

v1:

This series of patches add support for the new Atmel QSPI controller embedded inside sama5d2x SoCs.

These patches were first developped for linux-3.18-at91 and tested on a sama5d27 Xplained ultra board, which embeds a Micron n25q128a13 QSPI NOR flash memory. Then the series was adapted for mainline.

Cyrille Pitchen (7):
Documentation: mtd: add a DT property to set the number of dummy
cycles
mtd: spi-nor: notify (Q)SPI controller about protocol change
mtd: spi-nor: allow to tune the number of dummy cycles
Documentation: mtd: add a DT property to set the latency code of
Spansion memory
mtd: spi-nor: allow the set the latency code on Spansion memories
Documentation: atmel-quadspi: add binding file for Atmel QSPI driver
mtd: atmel-quadspi: add driver for Atmel QSPI controller

 .../devicetree/bindings/mtd/atmel-quadspi.txt      |  29 +
 .../devicetree/bindings/mtd/jedec,spi-nor.txt      |   6 +
 .../devicetree/bindings/mtd/spansion-nor.txt       |  22 +
 drivers/mtd/spi-nor/Kconfig                        |   7 +
 drivers/mtd/spi-nor/Makefile                       |   1 +
 drivers/mtd/spi-nor/atmel-quadspi.c                | 901 +++++++++++++++++++++
 drivers/mtd/spi-nor/spi-nor.c                      | 160 +++-
 include/linux/mtd/spi-nor.h                        |  15 +
 8 files changed, 1122 insertions(+), 19 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mtd/atmel-quadspi.txt
 create mode 100644 Documentation/devicetree/bindings/mtd/spansion-nor.txt
 create mode 100644 drivers/mtd/spi-nor/atmel-quadspi.c
Signature · 1 line
1.8.2.2
#1 lore raw

PATCH 1/7 Documentation: mtd: add a DT property to set the number of dummy cycles

Depending on the SPI clock frequency, the Fast Read op code and the Single/Dual Data Rate mode, the number of dummy cycles can be tuned to improve transfer speed.
The actual number of dummy cycles is specific for each memory model and is provided by the manufacturer thanks to the memory datasheet.

---
 Documentation/devicetree/bindings/mtd/jedec,spi-nor.txt | 6 ++++++
 1 file changed, 6 insertions(+)
Documentation/devicetree/bindings/mtd/jedec,spi-nor.txt +6 -0
index 2bee68103b01..4387567d8024 100644
@@ -19,6 +19,11 @@ Optional properties:
                    all chips and support for it can not be detected at runtime.
                    Refer to your chips' datasheet to check if this is supported
                    by your chip.
+- m25p,num-dummy-cycles : Set the number of dummy cycles for Fast Read commands.
+                          Depending on the manufacturer additional dedicated
+                          commands are sent to the flash memory so the
+                          controller and the memory can agree on the number of
+                          dummy cycles to use.
 
 Example:
 
@@ -29,4 +34,5 @@ Example:
 		reg = <0>;
 		spi-max-frequency = <40000000>;
 		m25p,fast-read;
+		m25p,num-dummy-cycles = <8>;
 	};
Signature · 1 line
1.8.2.2
#2 lore raw

PATCH 2/7 mtd: spi-nor: notify (Q)SPI controller about protocol change

In reply to Cyrille Pitchen

Once the Quad SPI mode has been enabled on a Micron flash memory, this device expects ALL the following commands to use the SPI 4-4-4 protocol. The (Q)SPI controller needs to be notified about the protocol change so it can adapt and keep on dialoging with the Micron memory.

---
 drivers/mtd/spi-nor/spi-nor.c | 17 +++++++++++++++++
 include/linux/mtd/spi-nor.h   | 13 +++++++++++++
 2 files changed, 30 insertions(+)
drivers/mtd/spi-nor/spi-nor.c +17 -0
index d78831b4422b..93627d4e6be8 100644
@@ -163,6 +163,18 @@ static inline int write_disable(struct spi_nor *nor)
 	return nor->write_reg(nor, SPINOR_OP_WRDI, NULL, 0, 0);
 }
 
+/*
+ * Notify the (Q)SPI controller about the new protocol to be used.
+ */
+static inline int spi_nor_set_protocol(struct spi_nor *nor,
+				       enum spi_protocol proto)
+{
+	if (nor->set_protocol)
+		return nor->set_protocol(nor, proto);
+
+	return 0;
+}
+
 static inline struct spi_nor *mtd_to_spi_nor(struct mtd_info *mtd)
 {
 	return mtd->priv;
@@ -943,6 +955,11 @@ static int micron_quad_enable(struct spi_nor *nor)
 		return ret;
 	}
 
+	/* switch protocol to Quad CMD 4-4-4 */
+	ret = spi_nor_set_protocol(nor, SPI_PROTO_4_4_4);
+	if (ret)
+		return ret;
+
 	ret = spi_nor_wait_till_ready(nor);
 	if (ret)
 		return ret;
include/linux/mtd/spi-nor.h +13 -0
index e5409524bb0a..1bf6f11310ef 100644
@@ -87,6 +87,16 @@ enum read_mode {
 	SPI_NOR_QUAD,
 };
 
+enum spi_protocol {
+	SPI_PROTO_1_1_1,	/* SPI */
+	SPI_PROTO_1_1_2,	/* Dual Output */
+	SPI_PROTO_1_1_4,	/* Quad Output */
+	SPI_PROTO_1_2_2,	/* Dual IO */
+	SPI_PROTO_1_4_4,	/* Quad IO */
+	SPI_PROTO_2_2_2,	/* Dual Command */
+	SPI_PROTO_4_4_4,	/* Quad Command */
+};
+
 /**
  * struct spi_nor_xfer_cfg - Structure for defining a Serial Flash transfer
  * @wren:		command for "Write Enable", or 0x00 for not required
@@ -149,6 +159,7 @@ enum spi_nor_option_flags {
  *			read/write/erase/lock/unlock operations
  * @read_xfer:		[OPTIONAL] the read fundamental primitive
  * @write_xfer:		[OPTIONAL] the writefundamental primitive
+ * @set_protocol:	[OPTIONAL] notify about protocol change
  * @read_reg:		[DRIVER-SPECIFIC] read out the register
  * @write_reg:		[DRIVER-SPECIFIC] write data to the register
  * @read:		[DRIVER-SPECIFIC] read data from the SPI NOR
@@ -185,6 +196,8 @@ struct spi_nor {
 	int (*write_reg)(struct spi_nor *nor, u8 opcode, u8 *buf, int len,
 			int write_enable);
 
+	int (*set_protocol)(struct spi_nor *nor, enum spi_protocol proto);
+
 	int (*read)(struct spi_nor *nor, loff_t from,
 			size_t len, size_t *retlen, u_char *read_buf);
 	void (*write)(struct spi_nor *nor, loff_t to,
Signature · 1 line
1.8.2.2
#3 lore raw

PATCH 3/7 mtd: spi-nor: allow to tune the number of dummy cycles

In reply to Cyrille Pitchen

The number of dummy cycles used during Fast Read commands can be reduced to improve transfer performances. Each manufacturer has a dedicated set of registers to provide the memory with the exact number of dummy cycles it should expect. Both the memory and the (Q)SPI controller must agree on this number of dummy cycles.

The number of dummy cycles can be found into the memory datasheet and mostly depends on the SPI clock frequency, the Fast Read op code and the Single/Dual Data Rate mode.

Probing JEDEC Serial Flash Discoverable Parameters (SFDP) tables would only provide the driver with a high enough number of dummy cycles for each Fast Read command to be used for all clock frequencies: this solution would not be optimized.

---
 drivers/mtd/spi-nor/spi-nor.c | 97 ++++++++++++++++++++++++++++++++++---------
 include/linux/mtd/spi-nor.h   |  2 +
 2 files changed, 80 insertions(+), 19 deletions(-)
drivers/mtd/spi-nor/spi-nor.c +78 -19
index 93627d4e6be8..5df6e4712a9e 100644
@@ -119,24 +119,6 @@ static int read_cr(struct spi_nor *nor)
 }
 
 /*
- * Dummy Cycle calculation for different type of read.
- * It can be used to support more commands with
- * different dummy cycle requirements.
- */
-static inline int spi_nor_read_dummy_cycles(struct spi_nor *nor)
-{
-	switch (nor->flash_read) {
-	case SPI_NOR_FAST:
-	case SPI_NOR_DUAL:
-	case SPI_NOR_QUAD:
-		return 8;
-	case SPI_NOR_NORMAL:
-		return 0;
-	}
-	return 0;
-}
-
-/*
  * Write status register 1 byte
  * Returns negative if error occurred.
  */
@@ -1007,6 +989,81 @@ static int set_quad_mode(struct spi_nor *nor, struct flash_info *info)
 	}
 }
 
+static int micron_set_dummy_cycles(struct spi_nor *nor)
+{
+	int ret;
+	u8 val, mask;
+
+	/* read the Volatile Configuration Register (VCR) */
+	ret = nor->read_reg(nor, SPINOR_OP_RD_VCR, &val, 1);
+	if (ret < 0) {
+		dev_err(nor->dev, "error %d reading VCR\n", ret);
+		return ret;
+	}
+
+	write_enable(nor);
+
+	/* update the number of dummy into the VCR */
+	mask = GENMASK(7, 4);
+	val &= ~mask;
+	val |= (nor->read_dummy << 4) & mask;
+	ret = nor->write_reg(nor, SPINOR_OP_WR_VCR, &val, 1, 0);
+	if (ret < 0) {
+		dev_err(nor->dev, "error while writing VCR register\n");
+		return ret;
+	}
+
+	ret = spi_nor_wait_till_ready(nor);
+	if (ret)
+		return ret;
+
+	return 0;
+}
+
+/*
+ * Dummy Cycle calculation for different type of read.
+ * It can be used to support more commands with
+ * different dummy cycle requirements.
+ */
+static int spi_nor_read_dummy_cycles(struct spi_nor *nor,
+				     const struct flash_info *info)
+{
+	struct device_node *np = nor->dev->of_node;
+	u32 num_dummy_cycles;
+
+	if (np && !of_property_read_u32(np, "m25p,num-dummy-cycles",
+					&num_dummy_cycles)) {
+		nor->read_dummy = num_dummy_cycles;
+
+		/*
+		 * This switch block might be moved after the if...then...else
+		 * statement but it was not tested with all Spansion or Micron
+		 * memories.
+		 * Now the "m25p,num-dummy-cycles" property needs to be
+		 * explicitly set in the device tree so the switch statement is
+		 * executed. This should avoid unwanted side effects and keep
+		 * backward compatibility.
+		 */
+		switch (JEDEC_MFR(info)) {
+		case CFI_MFR_ST:
+			return micron_set_dummy_cycles(nor);
+		default:
+			break;
+		}
+	} else {
+		switch (nor->flash_read) {
+		case SPI_NOR_FAST:
+		case SPI_NOR_DUAL:
+		case SPI_NOR_QUAD:
+			nor->read_dummy = 8;
+		case SPI_NOR_NORMAL:
+			nor->read_dummy = 0;
+		}
+	}
+
+	return 0;
+}
+
 static int spi_nor_check(struct spi_nor *nor)
 {
 	if (!nor->dev || !nor->read || !nor->write ||
@@ -1211,7 +1268,9 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, enum read_mode mode)
 		nor->addr_width = 3;
 	}
 
-	nor->read_dummy = spi_nor_read_dummy_cycles(nor);
+	ret = spi_nor_read_dummy_cycles(nor, info);
+	if (ret)
+		return ret;
 
 	dev_info(dev, "%s (%lld Kbytes)\n", id->name,
 			(long long)mtd->size >> 10);
include/linux/mtd/spi-nor.h +2 -0
index 1bf6f11310ef..e03a4c4053d3 100644
@@ -59,6 +59,8 @@
 /* Used for Micron flashes only. */
 #define SPINOR_OP_RD_EVCR      0x65    /* Read EVCR register */
 #define SPINOR_OP_WD_EVCR      0x61    /* Write EVCR register */
+#define SPINOR_OP_RD_VCR	0x85	/* Read VCR register */
+#define SPINOR_OP_WR_VCR	0x81	/* Write VCR register */
 
 /* Status Register bits. */
 #define SR_WIP			1	/* Write in progress */
Signature · 1 line
1.8.2.2
#4 lore raw

PATCH 4/7 Documentation: mtd: add a DT property to set the latency code of Spansion memory

In reply to Cyrille Pitchen

Both the SPI controller and the NOR flash memory need to agree on the number of dummy cycles to use for Fast Read commands. For Spansion memories, this number of dummy cycles is not given directly but through a so called "latency code".
The latency code can be found into the memory datasheet and depends on the SPI clock frequency, the Fast Read op code and the Single/Dual Data Rate mode.

---
 .../devicetree/bindings/mtd/spansion-nor.txt       | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mtd/spansion-nor.txt
Documentation/devicetree/bindings/mtd/spansion-nor.txt new file +22 -0
new file mode 100644
index 000000000000..a55c62db0e6f
@@ -0,0 +1,22 @@
+* Spansion NOR flash
+
+Optional properties:
+- spansion,latency-code : Only used when the "m25p,num-dummy-cycles" property is
+                          set. The Spansion latency code tells the NOR flash
+                          memory the number of dummy cycles to expect for each
+                          Fast Read command. The value to be used is provided by
+                          tables in the memory datasheet and depends on the SPI
+                          clock frequency and on the Single/Dual Data Rate mode.
+                          Then the value of "m25p,num-dummy-cycles" property
+                          should match the (Fast) Read command to be used for
+                          the chosen latency code.
+
+Example:
+
+	m25p80 at 0 {
+		compatible = "spansion,s25fl512s";
+		reg = <0>;
+		spi-max-frequency = <104000000>;
+		m25p,num-dummy-cycles = <8>;
+		spansion,latency-code = <2>;
+	};
Signature · 1 line
1.8.2.2
#5 lore raw

Re: [PATCH 4/7] Documentation: mtd: add a DT property to set the latency code of Spansion memory

On Thursday, July 16, 2015 at 05:27:51 PM, Cyrille Pitchen wrote:

Hi!

Quoted 7 lines

Both the SPI controller and the NOR flash memory need to agree on the number of dummy cycles to use for Fast Read commands. For Spansion memories, this number of dummy cycles is not given directly but through a so called "latency code".
The latency code can be found into the memory datasheet and depends on the SPI clock frequency, the Fast Read op code and the Single/Dual Data Rate mode.

Shouldn't you be able to derive the latency code from the above information, which you already know then ?

Best regards,
Marek Vasut

#6 lore raw

Re: [PATCH 4/7] Documentation: mtd: add a DT property to set the latency code of Spansion memory

Hi Marek,

Le 16/07/2015 19:44, Marek Vasut a ?crit :

Quoted 12 lines · Cyrille Pitchen

Hi!

Quoted 7 lines

Both the SPI controller and the NOR flash memory need to agree on the number of dummy cycles to use for Fast Read commands. For Spansion memories, this number of dummy cycles is not given directly but through a so called "latency code".
The latency code can be found into the memory datasheet and depends on the SPI clock frequency, the Fast Read op code and the Single/Dual Data Rate mode.

Quoted 2 lines

Shouldn't you be able to derive the latency code from the above information, which you already know then ?

Yes I agree with you; this could have been done adding static tables inside the driver instead of creating a new DT property dedicated to Spansion memories.

When I wrote this patch, I had a close look at the s25fl512s datasheet but only overviewed few datasheets for other Spansion QSPI flash memories. So I don't know whether a single latency code table could be shared among all Spansion memories or many tables should be added to support different memory models.

That's why I've chosen to add a dedicated DT property to support Spansion memories as it avoids to add tables to guess the proper latency code to be used. I thought it would be more flexible.

Maybe I will remove the support of Spansion QSPI memories from this series for now. Their support can still be implemented later.

Anyway, thanks for your review :)

Quoted 4 lines

Best regards,
Marek Vasut

Best Regards,

Cyrille

#7 lore raw

Re: [PATCH 4/7] Documentation: mtd: add a DT property to set the latency code of Spansion memory

Quoted 1 line · Cyrille Pitchen

Hi Marek,

Hi!

Quoted 13 lines

Le 16/07/2015 19:44, Marek Vasut a ?crit :

Quoted 12 lines · Cyrille Pitchen

Hi!

Quoted 7 lines

Both the SPI controller and the NOR flash memory need to agree on the number of dummy cycles to use for Fast Read commands. For Spansion memories, this number of dummy cycles is not given directly but through a so called "latency code".
The latency code can be found into the memory datasheet and depends on the SPI clock frequency, the Fast Read op code and the Single/Dual Data Rate mode.

Quoted 6 lines
Quoted 2 lines

Shouldn't you be able to derive the latency code from the above information, which you already know then ?

Yes I agree with you; this could have been done adding static tables inside the driver instead of creating a new DT property dedicated to Spansion memories.

OK, I see now. The latency code can not be calculed from "SPI clock frequency, the Fast Read op code and the Single/Dual Data Rate mode" easily, you need to index into some table to obtain some ad-hoc value. Got it. Sorry for the noise!

Quoted 6 lines

When I wrote this patch, I had a close look at the s25fl512s datasheet but only overviewed few datasheets for other Spansion QSPI flash memories. So I don't know whether a single latency code table could be shared among all Spansion memories or many tables should be added to support different memory models.

Quoted 8 lines

That's why I've chosen to add a dedicated DT property to support Spansion memories as it avoids to add tables to guess the proper latency code to be used. I thought it would be more flexible.

Maybe I will remove the support of Spansion QSPI memories from this series for now. Their support can still be implemented later.

Anyway, thanks for your review :)

Let's wait for more comments :)

Best regards,
Marek Vasut

#8 lore raw

PATCH 5/7 mtd: spi-nor: allow the set the latency code on Spansion memories

In reply to Cyrille Pitchen

Both the SPI controller and the flash memory must agree on the number of dummy cycles to use for Fast Read commands. For Spansion memories, this number of dummy cycles is configured through a so called latency code in their Control Register.
The right latency code can be found in the memory datasheet and depends on the SPI clock frequency, the op code of the Fast Read command and the Single/Dual Data Rate mode.

---
 drivers/mtd/spi-nor/spi-nor.c | 46 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)
drivers/mtd/spi-nor/spi-nor.c +46 -0
index 5df6e4712a9e..32fddf06da3f 100644
@@ -989,6 +989,50 @@ static int set_quad_mode(struct spi_nor *nor, struct flash_info *info)
 	}
 }
 
+static int spansion_set_latency_code(struct spi_nor *nor)
+{
+	struct device_node *np = nor->dev->of_node;
+	u8 cr, mask = GENMASK(7, 6);
+	u32 lc;
+	int ret;
+
+	if (!np || of_property_read_u32(np, "spansion,latency-code", &lc))
+		return 0;
+
+	if (lc & ~(mask >> 6)) {
+		dev_err(nor->dev, "invalid latency code: %u\n", lc);
+		return -EINVAL;
+	}
+
+	ret = read_cr(nor);
+	if (ret < 0) {
+		dev_err(nor->dev,
+			"error while reading configuration register\n");
+		return ret;
+	}
+
+	write_enable(nor);
+
+	cr = ret;
+	cr &= ~mask;
+	cr |= (lc << 6);
+	ret = write_sr_cr(nor, cr << 8);
+	if (ret < 0) {
+		dev_err(nor->dev,
+			"error while updating configuration register\n");
+		return -EINVAL;
+	}
+
+	/* read back and check it */
+	ret = read_cr(nor);
+	if (!(ret >= 0 && (ret & mask) == (lc << 6))) {
+		dev_err(nor->dev, "Spansion latency code not set\n");
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
 static int micron_set_dummy_cycles(struct spi_nor *nor)
 {
 	int ret;
@@ -1045,6 +1089,8 @@ static int spi_nor_read_dummy_cycles(struct spi_nor *nor,
 		 * backward compatibility.
 		 */
 		switch (JEDEC_MFR(info)) {
+		case CFI_MFR_AMD:
+			return spansion_set_latency_code(nor);
 		case CFI_MFR_ST:
 			return micron_set_dummy_cycles(nor);
 		default:
Signature · 1 line
1.8.2.2
#9 lore raw

PATCH 6/7 Documentation: atmel-quadspi: add binding file for Atmel QSPI driver

In reply to Cyrille Pitchen

This patch documents the DT bindings for the driver of the Atmel QSPI controller embedded inside sama5d2x SoCs.

---
 .../devicetree/bindings/mtd/atmel-quadspi.txt      | 29 ++++++++++++++++++++++
 1 file changed, 29 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mtd/atmel-quadspi.txt
Documentation/devicetree/bindings/mtd/atmel-quadspi.txt new file +29 -0
new file mode 100644
index 000000000000..a0d60ac7ae10
@@ -0,0 +1,29 @@
+* Atmel Quad Serial Peripheral Interface (QSPI)
+
+Required properties:
+  - compatible : Should be "atmel,sama5d2-qspi"
+  - reg : the first contains the register location and length,
+          the second contains the memory mapping address and length
+  - interrupts : Should contain the interrupt for the device
+  - clocks : The clock needed by the QSPI controller
+  - #address-cells : should be 1
+  - #size-cells : should be 0
+
+Example:
+
+qspi0: qspi at f0020000 {
+	compatible = "atmel,sama5d2-qspi";
+	reg = <0xf0020000 0x100>,
+	      <0xd0000000 0x08000000>;
+	interrupts = <52 IRQ_TYPE_LEVEL_HIGH 7>;
+	clocks = <&qspi0_clk>;
+	#address-cells = <1>;
+	#size-cells = <0>;
+	pinctrl-names = "default";
+	pinctrl-0 = <&pinctrl_qspi0_default>;
+	status = "okay";
+
+	m25p80 at 0 {
+		...
+	};
+};
Signature · 1 line
1.8.2.2
#10 lore raw

Re: [PATCH 6/7] Documentation: atmel-quadspi: add binding file for Atmel QSPI driver

Hello.

Quoted 19 lines · Cyrille Pitchen

This patch documents the DT bindings for the driver of the Atmel QSPI controller embedded inside sama5d2x SoCs.

---
  .../devicetree/bindings/mtd/atmel-quadspi.txt      | 29 ++++++++++++++++++++++
  1 file changed, 29 insertions(+)

create mode 100644 Documentation/devicetree/bindings/mtd/atmel-quadspi.txt

Documentation/devicetree/bindings/mtd/atmel-quadspi.txt new file +4 -0
new file mode 100644
index 000000000000..a0d60ac7ae10
@@ -0,0 +1,29 @@
+* Atmel Quad Serial Peripheral Interface (QSPI)
+
+Required properties:
+  - compatible : Should be "atmel,sama5d2-qspi"

Documentation/devicetree/bindings/mtd/atmel-quadspi.txt line 14

Quoted 10 lines
Documentation/devicetree/bindings/mtd/atmel-quadspi.txt new file +10 -0
+  - reg : the first contains the register location and length,
+          the second contains the memory mapping address and length
+  - interrupts : Should contain the interrupt for the device
+  - clocks : The clock needed by the QSPI controller
+  - #address-cells : should be 1
+  - #size-cells : should be 0
+
+Example:
+
+qspi0: qspi at f0020000 {

Once again, the ePAPR standard tells up to call the node just "spi", not
"qspi".

Documentation/devicetree/bindings/mtd/atmel-quadspi.txt line 17

Quoted 3 lines
Documentation/devicetree/bindings/mtd/atmel-quadspi.txt new file +3 -0
+	compatible = "atmel,sama5d2-qspi";
+	reg = <0xf0020000 0x100>,
+	      <0xd0000000 0x08000000>;

Either you use the leading zeroes or you don't. :-)

[...]

MBR, Sergei

#11 lore raw

Re: [PATCH 6/7] Documentation: atmel-quadspi: add binding file for Atmel QSPI driver

Hi Sergei,

thanks for the review. For the next series I've removed all references to "qspi" in the node example but the one from the compatible string. I've also removed the leading 0 in the size of the second memory region.

Best Regards,

Cyrille

Le 17/07/2015 13:44, Sergei Shtylyov a ?crit :

Quoted 46 lines

Hello.

Quoted 19 lines · Cyrille Pitchen

This patch documents the DT bindings for the driver of the Atmel QSPI controller embedded inside sama5d2x SoCs.

---
  .../devicetree/bindings/mtd/atmel-quadspi.txt      | 29 ++++++++++++++++++++++
  1 file changed, 29 insertions(+)

create mode 100644 Documentation/devicetree/bindings/mtd/atmel-quadspi.txt

Documentation/devicetree/bindings/mtd/atmel-quadspi.txt new file +4 -0
new file mode 100644
index 000000000000..a0d60ac7ae10
@@ -0,0 +1,29 @@
+* Atmel Quad Serial Peripheral Interface (QSPI)
+
+Required properties:
+  - compatible : Should be "atmel,sama5d2-qspi"

Documentation/devicetree/bindings/mtd/atmel-quadspi.txt line 14

Quoted 10 lines
Documentation/devicetree/bindings/mtd/atmel-quadspi.txt new file +10 -0
+  - reg : the first contains the register location and length,
+          the second contains the memory mapping address and length
+  - interrupts : Should contain the interrupt for the device
+  - clocks : The clock needed by the QSPI controller
+  - #address-cells : should be 1
+  - #size-cells : should be 0
+
+Example:
+
+qspi0: qspi at f0020000 {

Once again, the ePAPR standard tells up to call the node just "spi", not "qspi".

Documentation/devicetree/bindings/mtd/atmel-quadspi.txt line 17

Quoted 3 lines
Documentation/devicetree/bindings/mtd/atmel-quadspi.txt new file +3 -0
+    compatible = "atmel,sama5d2-qspi";
+    reg = <0xf0020000 0x100>,
+          <0xd0000000 0x08000000>;

Either you use the leading zeroes or you don't. :-)

[...]

MBR, Sergei

#12 lore raw

PATCH 7/7 mtd: atmel-quadspi: add driver for Atmel QSPI controller

In reply to Cyrille Pitchen

This driver add support to the new Atmel QSPI controller embedded into sama5d2x SoCs. It expects a NOR memory to be connected to the QSPI controller.

---
 drivers/mtd/spi-nor/Kconfig         |   7 +
 drivers/mtd/spi-nor/Makefile        |   1 +
 drivers/mtd/spi-nor/atmel-quadspi.c | 901 ++++++++++++++++++++++++++++++++++++
 3 files changed, 909 insertions(+)
 create mode 100644 drivers/mtd/spi-nor/atmel-quadspi.c
drivers/mtd/spi-nor/Kconfig +7 -0
index 64a4f0edabc7..bcdda302f5ab 100644
@@ -28,4 +28,11 @@ 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_ATMEL_QUADSPI
+	tristate "Atmel Quad SPI Controller"
+	depends on (ARCH_AT91 || COMPILE_TEST)
+	help
+	  This enables support for the Quad SPI controller in master mode.
+	  We only connect the NOR to this controller now.
+
 endif # MTD_SPI_NOR
drivers/mtd/spi-nor/Makefile +1 -0
index 6a7ce1462247..243ea8a479ef 100644
@@ -1,2 +1,3 @@
 obj-$(CONFIG_MTD_SPI_NOR)	+= spi-nor.o
 obj-$(CONFIG_SPI_FSL_QUADSPI)	+= fsl-quadspi.o
+obj-$(CONFIG_SPI_ATMEL_QUADSPI)	+= atmel-quadspi.o
drivers/mtd/spi-nor/atmel-quadspi.c new file +901 -0

901 lines not on this page · raw message

Signature · 1 line
1.8.2.2
#13 lore raw

Re: [PATCH 7/7] mtd: atmel-quadspi: add driver for Atmel QSPI controller

drivers/mtd/spi-nor/atmel-quadspi.c line 897

Quoted 10 lines · Cyrille Pitchen
drivers/mtd/spi-nor/atmel-quadspi.c new file +7 -0
 
+static struct platform_driver atmel_qspi_driver = {
+	.driver		= {
+		[...]
+		.bus	= &platform_bus_type,
+		[...]
+};
+module_platform_driver(atmel_qspi_driver);

Nit: on module init this will basically do

    __platform_driver_register(&atmel_qspi_driver, THIS_MODULE);

which will again set bus to &platform_bus_type. So you might as well drop that line.

Paul Bolle

#14 lore raw

Re: [PATCH 7/7] mtd: atmel-quadspi: add driver for Atmel QSPI controller

Hi Paul,

I've removed the ".bus = &plaform_bus_type" for the next series. Thank you for the explanation and the review :)

Best Regards,

Cyrille

Le 17/07/2015 11:04, Paul Bolle a ?crit :

Quoted 21 lines · Cyrille Pitchen

drivers/mtd/spi-nor/atmel-quadspi.c line 897

Quoted 10 lines
drivers/mtd/spi-nor/atmel-quadspi.c new file +7 -0
 
+static struct platform_driver atmel_qspi_driver = {
+	.driver		= {
+		[...]
+		.bus	= &platform_bus_type,
+		[...]
+};
+module_platform_driver(atmel_qspi_driver);

Nit: on module init this will basically do

    __platform_driver_register(&atmel_qspi_driver, THIS_MODULE);

which will again set bus to &platform_bus_type. So you might as well drop that line.

Paul Bolle