Skip to contentSkip to conversation

mtd: Add SPI-NOR core support

PATCH New Jagan Teki 1 participant 1 message Oct 30, 2016

Subsystems (3)
lore
Share & tools
lore

Jagan Teki

author
#0 lore raw

PATCH v9 2/21 mtd: Add SPI-NOR core support

Some of the SPI device drivers at drivers/spi not a real spi controllers, Unlike normal/generic SPI controllers they operates only with SPI-NOR flash devices. these were technically termed as SPI-NOR controllers, Ex: drivers/spi/fsl_qspi.c

The problem with these were resides at drivers/spi is entire SPI layer becomes SPI-NOR flash oriented which is absolutely a wrong indication where SPI layer getting effected more with flash operations - So this SPI-NOR core will resolve this issue by separating all SPI-NOR flash operations from spi layer and creats a generic layer called SPI-NOR core which can be used to interact SPI-NOR to SPI driver interface layer and the SPI-NOR controller driver. The idea is taken from Linux spi-nor framework.

------------------------------
mtd.c
------------------------------
mtd-uclass
-------------------------------
SPI-NOR Core
-------------------------------
m25p80.c zynq_qspi
-------------------------------
spi-uclass SPI NOR chip
-------------------------------
spi drivers
-------------------------------
SPI NOR chip
-------------------------------

---
 Makefile                          |   1 +
 drivers/mtd/spi-nor/Makefile      |   9 +
 drivers/mtd/spi-nor/spi-nor-ids.c | 176 +++++++++++
 drivers/mtd/spi-nor/spi-nor.c     | 648 ++++++++++++++++++++++++++++++++++++++
 include/linux/err.h               |   5 +
 include/linux/mtd/spi-nor.h       | 207 ++++++++++++
 6 files changed, 1046 insertions(+)
 create mode 100644 drivers/mtd/spi-nor/Makefile
 create mode 100644 drivers/mtd/spi-nor/spi-nor-ids.c
 create mode 100644 drivers/mtd/spi-nor/spi-nor.c
 create mode 100644 include/linux/mtd/spi-nor.h
Makefile +1 -0
index c67cc99..6404b12 100644
@@ -642,6 +642,7 @@ libs-$(CONFIG_CMD_NAND) += drivers/mtd/nand/
 libs-y += drivers/mtd/onenand/
 libs-$(CONFIG_CMD_UBI) += drivers/mtd/ubi/
 libs-y += drivers/mtd/spi/
+libs-y += drivers/mtd/spi-nor/
 libs-y += drivers/net/
 libs-y += drivers/net/phy/
 libs-y += drivers/pci/
drivers/mtd/spi-nor/Makefile new file +9 -0
new file mode 100644
index 0000000..15e43ea
@@ -0,0 +1,9 @@
+#
+# Copyright (C) 2016 Jagan Teki <[email protected]>
+#
+# SPDX-License-Identifier:	GPL-2.0+
+
+## spi-nor core
+ifdef CONFIG_MTD_SPI_NOR
+obj-y	+= spi-nor.o spi-nor-ids.o
+endif
drivers/mtd/spi-nor/spi-nor-ids.c new file +176 -0

176 lines not on this page · raw message

drivers/mtd/spi-nor/spi-nor.c new file +648 -0

648 lines not on this page · raw message

include/linux/err.h +5 -0
index e4d22d5..22e5756 100644
@@ -36,6 +36,11 @@ static inline long IS_ERR(const void *ptr)
 	return IS_ERR_VALUE((unsigned long)ptr);
 }
 
+static inline bool IS_ERR_OR_NULL(const void *ptr)
+{
+	return !ptr || IS_ERR_VALUE((unsigned long)ptr);
+}
+
 /**
  * ERR_CAST - Explicitly cast an error-valued pointer to another pointer type
  * @ptr: The pointer to cast.
include/linux/mtd/spi-nor.h new file +207 -0

207 lines not on this page · raw message

Signature · 1 line
2.7.4