Skip to contentSkip to conversation

Static memory controllers for the Aspeed SoC

PATCH Applied Cédric Le Goater 3 participants 5 messages Dec 21, 2016 – Dec 23, 2016 1 message not in the archive

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v5 cover Static memory controllers for the Aspeed SoC

Hello,

Here is a series introducing a new driver for the different memory controllers of the Aspeed AST2500 and AST2400 SoCs. Each SoC has at least a memory controller for the BMC firmware and another one for the host firmware. The register set are mostly compatible but there are some slight differences on the AST2400.

The driver only supports SPI type flash.

Tested on:

* OpenPOWER Palmetto (AST2400) with
FMC controller : n25q256a

	SPI controller : mx25l25635e and n25q512ax3

* Evaluation board (AST2500) with
FMC controller : w25q256
SPI controller : w25q256

* OpenPOWER Witherspoon (AST2500) with
FMC controller : mx25l25635e * 2
SPI controller : mx66l1g45g

Changes since v4:
- improved IO routines with Cyrille's suggestions
- added dummy bytes hanling for fast read commands
- removed the 'label' property from jedec,spi-nor. Needs more discussion.

Changes since v3:
- reworked IO routines to use io{read,write}32_rep
- changed config option to SPI_ASPEED_SMC
- fixed aspeed_smc_chip_setup_init() returned value

Changes since v2:
- splitted patch to distinguish AST2400 and AST2500 controllers
- fixed controller names
- introduced prepare/unprepare ops
- introduced a aspeed_smc_setup_flash() routine
- various cleanups

Changes since v1:
- added a set4b ops to handle difference in the controllers
- simplified the IO routines
- prepared for fast read using dummy cycles

Work in progress:
- read optimization using higher SPI clock frequencies
- command mode to direct reads from AHB
- DMA support

Thanks,

C.

Cédric Le Goater (3):
mtd: spi-nor: add memory controllers for the Aspeed AST2500 SoC
mtd: aspeed: add memory controllers for the Aspeed AST2400 SoC
mtd: spi-nor: bindings for the Aspeed memory controllers

 .../devicetree/bindings/mtd/aspeed-smc.txt         |  51 ++
 drivers/mtd/spi-nor/Kconfig                        |  10 +
 drivers/mtd/spi-nor/Makefile                       |   1 +
 drivers/mtd/spi-nor/aspeed-smc.c                   | 759 +++++++++++++++++++++
 4 files changed, 821 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mtd/aspeed-smc.txt
 create mode 100644 drivers/mtd/spi-nor/aspeed-smc.c
Signature · 6 lines
2.7.4


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

A message that is not in the archive (sent off-list or not yet received): 1482339439-26402-1-git-send-email-clg-Bxea+6Xhats@public.gmane.org

#2 lore raw

PATCH v5 1/3 mtd: spi-nor: add memory controllers for the Aspeed AST2500 SoC

This driver adds mtd support for the Aspeed AST2500 SoC static memory controllers :

* Firmware SPI Memory Controller (FMC)
. BMC firmware
. 3 chip select pins (CE0 ~ CE2)
. supports SPI type flash memory (CE0-CE1)
. CE2 can be of NOR type flash but this is not supported by the
driver

* SPI Flash Controller (SPI1 and SPI2)
. host firmware
. 2 chip select pins (CE0 ~ CE1)
. supports SPI type flash memory

Each controller has a memory range on which it maps its flash module slaves. Each slave is assigned a memory window for its mapping that can be changed at bootime with the Segment Address Register.

Each SPI flash slave can then be accessed in two modes: Command and User. When in User mode, accesses to the memory segment of the slaves are translated in SPI transfers. When in Command mode, the HW generates the SPI commands automatically and the memory segment is accessed as if doing a MMIO.

Currently, only the User mode is supported. Command mode needs a little more work to check that the memory window on the AHB bus fits the module size.

Based on previous work from Milton D. Miller II <miltonm-r/[email protected]>

---

Changes since v4:
- improved IO routines with Cyrille's suggestions
- added dummy bytes hanling for fast read commands
- removed the 'label' property from jedec,spi-nor. Needs more discussion.

Changes since v3:
- reworked IO routines to use io{read,write}32_rep
- changed config option to SPI_ASPEED_SMC
- fixed aspeed_smc_chip_setup_init() returned value
- merged the use of the "label" property"

 drivers/mtd/spi-nor/Kconfig      |  10 +
 drivers/mtd/spi-nor/Makefile     |   1 +
 drivers/mtd/spi-nor/aspeed-smc.c | 726 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 737 insertions(+)
 create mode 100644 drivers/mtd/spi-nor/aspeed-smc.c
drivers/mtd/spi-nor/Kconfig +10 -0
index 4a682ee0f632..42168e9d6097 100644
@@ -29,6 +29,16 @@ config MTD_SPI_NOR_USE_4K_SECTORS
 	  Please note that some tools/drivers/filesystems may not work with
 	  4096 B erase size (e.g. UBIFS requires 15 KiB as a minimum).
 
+config SPI_ASPEED_SMC
+	tristate "Aspeed flash controllers in SPI mode"
+	depends on ARCH_ASPEED || COMPILE_TEST
+	depends on HAS_IOMEM && OF
+	help
+	  This enables support for the Firmware Memory controller (FMC)
+	  in the Aspeed AST2500 SoC when attached to SPI NOR chips,
+	  and support for the SPI flash memory controller (SPI) for
+	  the host firmware. The implementation only supports SPI NOR.
+
 config SPI_ATMEL_QUADSPI
 	tristate "Atmel Quad SPI Controller"
 	depends on ARCH_AT91 || (ARM && COMPILE_TEST)
drivers/mtd/spi-nor/Makefile +1 -0
index 121695e83542..6ff64bc7fa0e 100644
@@ -1,4 +1,5 @@
 obj-$(CONFIG_MTD_SPI_NOR)	+= spi-nor.o
+obj-$(CONFIG_SPI_ASPEED_SMC)	+= aspeed-smc.o
 obj-$(CONFIG_SPI_ATMEL_QUADSPI)	+= atmel-quadspi.o
 obj-$(CONFIG_SPI_CADENCE_QUADSPI)	+= cadence-quadspi.o
 obj-$(CONFIG_SPI_FSL_QUADSPI)	+= fsl-quadspi.o
drivers/mtd/spi-nor/aspeed-smc.c new file +726 -0

726 lines not on this page · raw message

Signature · 6 lines
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#3 lore raw
In reply to a message not in the archive
Quoted 61 lines · Cédric Le Goater

Hello,

Here is a series introducing a new driver for the different memory controllers of the Aspeed AST2500 and AST2400 SoCs. Each SoC has at least a memory controller for the BMC firmware and another one for the host firmware. The register set are mostly compatible but there are some slight differences on the AST2400.

The driver only supports SPI type flash.

Tested on:

* OpenPOWER Palmetto (AST2400) with
FMC controller : n25q256a

	SPI controller : mx25l25635e and n25q512ax3

* Evaluation board (AST2500) with
FMC controller : w25q256
SPI controller : w25q256

* OpenPOWER Witherspoon (AST2500) with
FMC controller : mx25l25635e * 2
SPI controller : mx66l1g45g

Changes since v4:
- improved IO routines with Cyrille's suggestions
- added dummy bytes hanling for fast read commands
- removed the 'label' property from jedec,spi-nor. Needs more discussion.

Changes since v3:
- reworked IO routines to use io{read,write}32_rep
- changed config option to SPI_ASPEED_SMC
- fixed aspeed_smc_chip_setup_init() returned value

Changes since v2:
- splitted patch to distinguish AST2400 and AST2500 controllers
- fixed controller names
- introduced prepare/unprepare ops
- introduced a aspeed_smc_setup_flash() routine
- various cleanups

Changes since v1:
- added a set4b ops to handle difference in the controllers
- simplified the IO routines
- prepared for fast read using dummy cycles

Work in progress:
- read optimization using higher SPI clock frequencies
- command mode to direct reads from AHB
- DMA support

Thanks,

C.

Cédric Le Goater (3):
mtd: spi-nor: add memory controllers for the Aspeed AST2500 SoC
mtd: aspeed: add memory controllers for the Aspeed AST2400 SoC
mtd: spi-nor: bindings for the Aspeed memory controllers

Quoted 8 lines
 .../devicetree/bindings/mtd/aspeed-smc.txt         |  51 ++
 drivers/mtd/spi-nor/Kconfig                        |  10 +
 drivers/mtd/spi-nor/Makefile                       |   1 +
 drivers/mtd/spi-nor/aspeed-smc.c                   | 759 +++++++++++++++++++++
 4 files changed, 821 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mtd/aspeed-smc.txt
 create mode 100644 drivers/mtd/spi-nor/aspeed-smc.c

Applied to git://github.com/spi-nor/linux.git

Thanks!

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw

PATCH v5 2/3 mtd: aspeed: add memory controllers for the Aspeed AST2400 SoC

In reply to Cédric Le Goater

This driver adds mtd support for the Aspeed AST2400 SoC static memory controllers:

* New Static Memory Controller (referred as FMC) . BMC firmware
. AST2500 compatible register set
. 5 chip select pins (CE0 ∼ CE4)
. supports NOR flash, NAND flash and SPI flash memory.

* SPI Flash Controller (SPI)
. host Firmware
. slightly different register set, between AST2500 and the legacy
controller
. supports SPI flash memory
. 1 chip select pin (CE0)

The legacy static memory controller (referred as SMC) is not supported, as well as types other than SPI.

---
 drivers/mtd/spi-nor/Kconfig      |  2 +-
 drivers/mtd/spi-nor/aspeed-smc.c | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+), 1 deletion(-)
drivers/mtd/spi-nor/Kconfig +1 -1
index 42168e9d6097..7b00a0cb9ed8 100644
@@ -35,7 +35,7 @@ config SPI_ASPEED_SMC
 	depends on HAS_IOMEM && OF
 	help
 	  This enables support for the Firmware Memory controller (FMC)
-	  in the Aspeed AST2500 SoC when attached to SPI NOR chips,
+	  in the Aspeed AST2500/AST2400 SoCs when attached to SPI NOR chips,
 	  and support for the SPI flash memory controller (SPI) for
 	  the host firmware. The implementation only supports SPI NOR.
 
drivers/mtd/spi-nor/aspeed-smc.c +33 -0
index f1e18bea9888..6bb4c7d1788c 100644
@@ -44,8 +44,27 @@ struct aspeed_smc_info {
 	void (*set_4b)(struct aspeed_smc_chip *chip);
 };
 
+static void aspeed_smc_chip_set_4b_spi_2400(struct aspeed_smc_chip *chip);
 static void aspeed_smc_chip_set_4b(struct aspeed_smc_chip *chip);
 
+static const struct aspeed_smc_info fmc_2400_info = {
+	.maxsize = 64 * 1024 * 1024,
+	.nce = 5,
+	.hastype = true,
+	.we0 = 16,
+	.ctl0 = 0x10,
+	.set_4b = aspeed_smc_chip_set_4b,
+};
+
+static const struct aspeed_smc_info spi_2400_info = {
+	.maxsize = 64 * 1024 * 1024,
+	.nce = 1,
+	.hastype = false,
+	.we0 = 0,
+	.ctl0 = 0x04,
+	.set_4b = aspeed_smc_chip_set_4b_spi_2400,
+};
+
 static const struct aspeed_smc_info fmc_2500_info = {
 	.maxsize = 256 * 1024 * 1024,
 	.nce = 3,
@@ -135,6 +154,7 @@ struct aspeed_smc_controller {
 #define CONTROL_IO_DUMMY_HI		BIT(14)
 #define CONTROL_IO_DUMMY_HI_SHIFT	14
 #define CONTROL_CLK_DIV4		BIT(13) /* others */
+#define CONTROL_IO_ADDRESS_4B		BIT(13) /* AST2400 SPI */
 #define CONTROL_RW_MERGE		BIT(12)
 #define CONTROL_IO_DUMMY_LO_SHIFT	6
 #define CONTROL_IO_DUMMY_LO		GENMASK(7, \
@@ -397,6 +417,8 @@ static int aspeed_smc_remove(struct platform_device *dev)
 }
 
 static const struct of_device_id aspeed_smc_matches[] = {
+	{ .compatible = "aspeed,ast2400-fmc", .data = &fmc_2400_info },
+	{ .compatible = "aspeed,ast2400-spi", .data = &spi_2400_info },
 	{ .compatible = "aspeed,ast2500-fmc", .data = &fmc_2500_info },
 	{ .compatible = "aspeed,ast2500-spi", .data = &spi_2500_info },
 	{ }
@@ -470,6 +492,17 @@ static void aspeed_smc_chip_set_4b(struct aspeed_smc_chip *chip)
 	}
 }
 
+/*
+ * The AST2400 SPI flash controller does not have a CE Control
+ * register. It uses the CE0 control register to set 4Byte mode at the
+ * controller level.
+ */
+static void aspeed_smc_chip_set_4b_spi_2400(struct aspeed_smc_chip *chip)
+{
+	chip->ctl_val[smc_base] |= CONTROL_IO_ADDRESS_4B;
+	chip->ctl_val[smc_read] |= CONTROL_IO_ADDRESS_4B;
+}
+
 static int aspeed_smc_chip_setup_init(struct aspeed_smc_chip *chip,
 				      struct resource *res)
 {
Signature · 6 lines
2.7.4


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
#5 lore raw

PATCH v5 3/3 mtd: spi-nor: bindings for the Aspeed memory controllers

In reply to Cédric Le Goater
---
 .../devicetree/bindings/mtd/aspeed-smc.txt         | 51 ++++++++++++++++++++++
 1 file changed, 51 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mtd/aspeed-smc.txt
Documentation/devicetree/bindings/mtd/aspeed-smc.txt new file +51 -0
new file mode 100644
index 000000000000..49f6528ef547
@@ -0,0 +1,51 @@
+* Aspeed Firmware Memory controller
+* Aspeed SPI Flash Memory Controller
+
+The Firmware Memory Controller in the Aspeed AST2500 SoC supports
+three chip selects, two of which are always of SPI type and the third
+can be SPI or NOR type flash. These bindings only describe SPI.
+
+The two SPI flash memory controllers in the AST2500 each support two
+chip selects.
+
+Required properties:
+  - compatible : Should be one of
+	"aspeed,ast2400-fmc" for the AST2400 Firmware Memory Controller
+	"aspeed,ast2400-spi" for the AST2400 SPI Flash memory Controller
+	"aspeed,ast2500-fmc" for the AST2500 Firmware Memory Controller
+	"aspeed,ast2500-spi" for the AST2500 SPI flash memory controllers
+
+  - reg : the first contains the control register location and length,
+          the second contains the memory window mapping address and length
+  - #address-cells : must be 1 corresponding to chip select child binding
+  - #size-cells : must be 0 corresponding to chip select child binding
+
+Optional properties:
+  - interrupts : Should contain the interrupt for the dma device if an
+    FMC
+
+The child nodes are the SPI flash modules which must have a compatible
+property as specified in bindings/mtd/jedec,spi-nor.txt
+
+Optionally, the child node can contain properties for SPI mode (may be
+ignored):
+  - spi-max-frequency - max frequency of spi bus
+
+
+Example:
+fmc: fmc@1e620000 {
+	compatible = "aspeed,ast2500-fmc";
+	reg = < 0x1e620000 0x94
+		0x20000000 0x02000000 >;
+	#address-cells = <1>;
+	#size-cells = <0>;
+	interrupts = <19>;
+	flash@0 {
+		reg = < 0 >;
+		compatible = "jedec,spi-nor";
+		/* spi-max-frequency = <>; */
+		/* m25p,fast-read; */
+		#address-cells = <1>;
+		#size-cells = <1>;
+	};
+};
Signature · 6 lines
2.7.4


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/