devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Cédric Le Goater" <clg@kaod.org>
To: linux-mtd@lists.infradead.org
Cc: "Mark Rutland" <mark.rutland@arm.com>,
	"Boris Brezillon" <boris.brezillon@free-electrons.com>,
	devicetree@vger.kernel.org, "Richard Weinberger" <richard@nod.at>,
	"Marek Vasut" <marek.vasut@gmail.com>,
	"Rob Herring" <robh+dt@kernel.org>,
	"Joel Stanley" <joel@jms.id.au>,
	"Cyrille Pitchen" <cyrille.pitchen@atmel.com>,
	"Brian Norris" <computersforpeace@gmail.com>,
	"David Woodhouse" <dwmw2@infradead.org>,
	"Cédric Le Goater" <clg@kaod.org>
Subject: [PATCH v4 2/4] mtd: aspeed: add memory controllers for the Aspeed AST2400 SoC
Date: Mon, 12 Dec 2016 16:40:50 +0100	[thread overview]
Message-ID: <1481557252-13656-3-git-send-email-clg@kaod.org> (raw)
In-Reply-To: <1481557252-13656-1-git-send-email-clg@kaod.org>

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.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
Reviewed-by: Joel Stanley <joel@jms.id.au>
---
 drivers/mtd/spi-nor/Kconfig      |  2 +-
 drivers/mtd/spi-nor/aspeed-smc.c | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/spi-nor/Kconfig b/drivers/mtd/spi-nor/Kconfig
index 42168e9d6097..7b00a0cb9ed8 100644
--- a/drivers/mtd/spi-nor/Kconfig
+++ b/drivers/mtd/spi-nor/Kconfig
@@ -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.
 
diff --git a/drivers/mtd/spi-nor/aspeed-smc.c b/drivers/mtd/spi-nor/aspeed-smc.c
index 2667ab7aeb9b..ce2ab13d114d 100644
--- a/drivers/mtd/spi-nor/aspeed-smc.c
+++ b/drivers/mtd/spi-nor/aspeed-smc.c
@@ -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, \
@@ -388,6 +408,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 },
 	{ }
@@ -461,6 +483,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)
 {
-- 
2.7.4


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

  parent reply	other threads:[~2016-12-12 15:40 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-12 15:40 [PATCH v4 0/4] Static memory controllers for the Aspeed SoC Cédric Le Goater
2016-12-12 15:40 ` [PATCH v4 1/4] mtd: spi-nor: add memory controllers for the Aspeed AST2500 SoC Cédric Le Goater
     [not found]   ` <1481557252-13656-2-git-send-email-clg-Bxea+6Xhats@public.gmane.org>
2016-12-13  7:50     ` Marek Vasut
2016-12-13 12:22       ` Cédric Le Goater
2016-12-15 23:15   ` Cyrille Pitchen
     [not found]     ` <5566c62d-cc72-f207-e1dd-5a59e6947c24-yU5RGvR974pGWvitb5QawA@public.gmane.org>
2016-12-16 14:56       ` Cédric Le Goater
     [not found]         ` <a7cb781c-a4a8-f0f7-e7db-5cd9f19da0aa-Bxea+6Xhats@public.gmane.org>
2016-12-20 15:17           ` Cyrille Pitchen
2016-12-21 16:47             ` Cédric Le Goater
     [not found]               ` <645db8c4-7f3c-f8bf-ddd9-3f513ce2ed14-Bxea+6Xhats@public.gmane.org>
2017-01-04 14:52                 ` Cyrille Pitchen
     [not found]                   ` <4c5cf674-06f9-ad6b-05bf-a1d39aaa7ed5-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
2017-01-04 17:50                     ` Boris Brezillon
2017-01-05 13:39                       ` Cédric Le Goater
     [not found]                         ` <4c0b4498-12c7-303d-c8f8-4f27a02d6c12-Bxea+6Xhats@public.gmane.org>
2017-01-06  8:49                           ` Boris Brezillon
2017-01-06 10:04                             ` Cédric Le Goater
2017-01-06 10:23                               ` Boris Brezillon
2016-12-12 15:40 ` Cédric Le Goater [this message]
     [not found] ` <1481557252-13656-1-git-send-email-clg-Bxea+6Xhats@public.gmane.org>
2016-12-12 15:40   ` [PATCH v4 3/4] mtd: spi-nor: bindings for the Aspeed memory controllers Cédric Le Goater
     [not found]     ` <1481557252-13656-4-git-send-email-clg-Bxea+6Xhats@public.gmane.org>
2016-12-12 23:43       ` Joel Stanley
2016-12-13 19:45       ` Rob Herring
2016-12-12 15:40   ` [PATCH v4 4/4] mtd: spi-nor: add a label property to jedec,spi-nor Cédric Le Goater
     [not found]     ` <1481557252-13656-5-git-send-email-clg-Bxea+6Xhats@public.gmane.org>
2016-12-13 19:46       ` Rob Herring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1481557252-13656-3-git-send-email-clg@kaod.org \
    --to=clg@kaod.org \
    --cc=boris.brezillon@free-electrons.com \
    --cc=computersforpeace@gmail.com \
    --cc=cyrille.pitchen@atmel.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dwmw2@infradead.org \
    --cc=joel@jms.id.au \
    --cc=linux-mtd@lists.infradead.org \
    --cc=marek.vasut@gmail.com \
    --cc=mark.rutland@arm.com \
    --cc=richard@nod.at \
    --cc=robh+dt@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).