Skip to contentSkip to conversation

spi: Add Atmel QuadSPI driver

PATCH Superseded Tudor.Ambarus at microchip.com 1 participant 6 messages May 7, 2019

Subsystems (3)

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

cover spi: Add Atmel QuadSPI driver

From: Tudor Ambarus <[email protected]>

Backport the driver from linux v5.1-rc5 and adapt it for u-boot. Tested on sama5d2_xplained Rev B with mx25l25635e spi-nor flash.

=> sf probe 1:0
SF: Detected mx25l25635e with page size 256 Bytes, erase size 64 KiB, total 32 MiB => sf erase 0 100000
SF: 1048576 bytes @ 0x0 Erased: OK
=> mw.b 0x21000000 bc 100000
=> sf write 0x21000000 0 100000
device 0 offset 0x0, size 0x100000
SF: 1048576 bytes @ 0x0 Written: OK
=> sf read 0x21100000 0 100000
device 0 offset 0x0, size 0x100000
SF: 1048576 bytes @ 0x0 Read: OK
=> cmp.b 0x21000000 0x21100000 100000
Total of 1048576 byte(s) were the same

Tudor Ambarus (5):
dt-bindings: spi: add bindings for Atmel QSPI driver
spi: Add Atmel QuadSPI driver
configs: sama5d2_xplained: enable SST and MACRONIX flashes
ARM: dts: at91: sama5d2_xplained: use jedec,spi-nor compatible
ARM: dts: at91: sama5d2_xplained: describe flash bus width

 arch/arm/dts/at91-sama5d2_xplained.dts         |   4 +-
 configs/sama5d2_xplained_mmc_defconfig         |   2 +
 doc/device-tree-bindings/spi/atmel-quadspi.txt |  37 ++
 drivers/spi/Kconfig                            |   7 +
 drivers/spi/Makefile                           |   1 +
 drivers/spi/atmel-quadspi.c                    | 535 +++++++++++++++++++++++++
 6 files changed, 585 insertions(+), 1 deletion(-)
 create mode 100644 doc/device-tree-bindings/spi/atmel-quadspi.txt
 create mode 100644 drivers/spi/atmel-quadspi.c
Signature · 1 line
2.9.5
#1 lore raw

PATCH 1/5 dt-bindings: spi: add bindings for Atmel QSPI driver

From: Tudor Ambarus <[email protected]>

Describe the DT bindings for the driver of the Atmel QSPI controller. Taken form linux v5.1-rc5.

---
 doc/device-tree-bindings/spi/atmel-quadspi.txt | 37 ++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100644 doc/device-tree-bindings/spi/atmel-quadspi.txt
doc/device-tree-bindings/spi/atmel-quadspi.txt new file +37 -0
new file mode 100644
index 000000000000..7c40ea694352
@@ -0,0 +1,37 @@
+* Atmel Quad Serial Peripheral Interface (QSPI)
+
+Required properties:
+- compatible:     Should be one of the following:
+		  - "atmel,sama5d2-qspi"
+		  - "microchip,sam9x60-qspi"
+- reg:            Should contain the locations and lengths of the base registers
+                  and the mapped memory.
+- reg-names:      Should contain the resource reg names:
+                  - qspi_base: configuration register address space
+                  - qspi_mmap: memory mapped address space
+- interrupts:     Should contain the interrupt for the device.
+- clocks:         Should reference the peripheral clock and the QSPI system
+                  clock if available.
+- clock-names:    Should contain "pclk" for the peripheral clock and "qspick"
+                  for the system clock when available.
+- #address-cells: Should be <1>.
+- #size-cells:    Should be <0>.
+
+Example:
+
+spi at f0020000 {
+	compatible = "atmel,sama5d2-qspi";
+	reg = <0xf0020000 0x100>, <0xd0000000 0x8000000>;
+	reg-names = "qspi_base", "qspi_mmap";
+	interrupts = <52 IRQ_TYPE_LEVEL_HIGH 7>;
+	clocks = <&pmc PMC_TYPE_PERIPHERAL 52>;
+	clock-names = "pclk";
+	#address-cells = <1>;
+	#size-cells = <0>;
+	pinctrl-names = "default";
+	pinctrl-0 = <&pinctrl_spi0_default>;
+
+	m25p80 at 0 {
+		...
+	};
+};
Signature · 1 line
2.9.5
#2 lore raw

PATCH 2/5 spi: Add Atmel QuadSPI driver

In reply to Tudor.Ambarus at microchip.com

From: Tudor Ambarus <[email protected]>

Backport the driver from linux v5.1-rc5 and adapt it for u-boot. Tested on sama5d2_xplained Rev B with mx25l25635e spi-nor flash.

---
 drivers/spi/Kconfig         |   7 +
 drivers/spi/Makefile        |   1 +
 drivers/spi/atmel-quadspi.c | 535 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 543 insertions(+)
 create mode 100644 drivers/spi/atmel-quadspi.c
drivers/spi/Kconfig +7 -0
index 2830f765877b..deb48e41568f 100644
@@ -49,6 +49,13 @@ config ATH79_SPI
 	  uses driver model and requires a device tree binding to operate.
 	  please refer to doc/device-tree-bindings/spi/spi-ath79.txt.
 
+config ATMEL_QSPI
+	bool "Atmel QSPI driver"
+	depends on ARCH_AT91
+	help
+	  Enable the Ateml Quad-SPI (QSPI) driver. This driver can only be
+	  used to access SPI NOR flashes.
+
 config ATMEL_SPI
 	bool "Atmel SPI driver"
 	default y if ARCH_AT91
drivers/spi/Makefile +1 -0
index 8be9a4baa244..32b42d18b1af 100644
@@ -18,6 +18,7 @@ endif
 
 obj-$(CONFIG_ALTERA_SPI) += altera_spi.o
 obj-$(CONFIG_ATH79_SPI) += ath79_spi.o
+obj-$(CONFIG_ATMEL_QSPI) += atmel-quadspi.o
 obj-$(CONFIG_ATMEL_SPI) += atmel_spi.o
 obj-$(CONFIG_BCM63XX_HSSPI) += bcm63xx_hsspi.o
 obj-$(CONFIG_BCM63XX_SPI) += bcm63xx_spi.o
drivers/spi/atmel-quadspi.c new file +535 -0

535 lines not on this page · raw message

Signature · 1 line
2.9.5
#3 lore raw

PATCH 3/5 configs: sama5d2_xplained: enable SST and MACRONIX flashes

In reply to Tudor.Ambarus at microchip.com

From: Tudor Ambarus <[email protected]>

We have a macronix spi-nor flash on sama5d2_xplained RevB and a sst spi-nor flash on RevC.

---
 configs/sama5d2_xplained_mmc_defconfig | 2 ++
 1 file changed, 2 insertions(+)
configs/sama5d2_xplained_mmc_defconfig +2 -0
index c25d67bfebb1..a2b1674b1313 100644
@@ -67,6 +67,8 @@ CONFIG_DM_SPI_FLASH=y
 CONFIG_SPI_FLASH=y
 CONFIG_SF_DEFAULT_SPEED=30000000
 CONFIG_SPI_FLASH_ATMEL=y
+CONFIG_SPI_FLASH_MACRONIX=y
+CONFIG_SPI_FLASH_SST=y
 CONFIG_DM_ETH=y
 CONFIG_MACB=y
 CONFIG_PINCTRL=y
Signature · 1 line
2.9.5
#4 lore raw

PATCH 4/5 ARM: dts: at91: sama5d2_xplained: use jedec, spi-nor compatible

In reply to Tudor.Ambarus at microchip.com

From: Tudor Ambarus <[email protected]>

The flashes present on sama5d2_xplained, mx25l25635e and sst26vf064b, are jedec compatible. Use "jedec,spi-nor" binding.

---
 arch/arm/dts/at91-sama5d2_xplained.dts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/dts/at91-sama5d2_xplained.dts +1 -1
index c0708feeb7b2..08f000b77436 100644
@@ -82,7 +82,7 @@
 				status = "okay";
 
 				flash at 0 {
-					compatible = "atmel,sama5d2-qspi-flash";
+					compatible = "jedec,spi-nor";
 					reg = <0>;
 					#address-cells = <1>;
 					#size-cells = <1>;
Signature · 1 line
2.9.5
#5 lore raw

PATCH 5/5 ARM: dts: at91: sama5d2_xplained: describe flash bus width

In reply to Tudor.Ambarus at microchip.com

From: Tudor Ambarus <[email protected]>

sama5d2_xplained advertises quad capable flashes.
Set bus with to 4.

---
 arch/arm/dts/at91-sama5d2_xplained.dts | 2 ++
 1 file changed, 2 insertions(+)
arch/arm/dts/at91-sama5d2_xplained.dts +2 -0
index 08f000b77436..aa69ee7af405 100644
@@ -89,6 +89,8 @@
 					pinctrl-names = "default";
 					pinctrl-0 = <&pinctrl_qspi0_default>;
 					spi-max-frequency = <83000000>;
+					spi-rx-bus-width = <4>;
+					spi-tx-bus-width = <4>;
 
 					partition at 00000000 {
 						label = "boot";
Signature · 1 line
2.9.5