devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Cédric Le Goater" <clg-Bxea+6Xhats@public.gmane.org>
To: linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Cc: "David Woodhouse" <dwmw2-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>,
	"Brian Norris"
	<computersforpeace-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	"Boris Brezillon"
	<boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>,
	"Marek Vasut"
	<marek.vasut-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	"Richard Weinberger" <richard-/L3Ra7n9ekc@public.gmane.org>,
	"Cyrille Pitchen"
	<cyrille.pitchen-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	"Rob Herring" <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	"Mark Rutland" <mark.rutland-5wv7dgnIgG8@public.gmane.org>,
	"Joel Stanley" <joel-U3u1mxZcP9KHXe+LvDLADg@public.gmane.org>,
	"Cédric Le Goater" <clg-Bxea+6Xhats@public.gmane.org>
Subject: [PATCH v3 2/5] mtd: aspeed: add memory controllers for the Aspeed AST2400 SoC
Date: Fri,  9 Dec 2016 17:49:24 +0100	[thread overview]
Message-ID: <1481302167-28044-3-git-send-email-clg@kaod.org> (raw)
In-Reply-To: <1481302167-28044-1-git-send-email-clg-Bxea+6Xhats@public.gmane.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-Bxea+6Xhats@public.gmane.org>
---
 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 5c0efbd9dd89..22bea563f9bc 100644
--- a/drivers/mtd/spi-nor/Kconfig
+++ b/drivers/mtd/spi-nor/Kconfig
@@ -35,7 +35,7 @@ config SPI_ASPEED
 	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 6f9244f07aef..99302b0d7786 100644
--- a/drivers/mtd/spi-nor/aspeed-smc.c
+++ b/drivers/mtd/spi-nor/aspeed-smc.c
@@ -119,8 +119,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,
@@ -210,6 +229,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, \
@@ -406,6 +426,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 },
 	{ }
@@ -479,6 +501,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

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2016-12-09 16:49 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-09 16:49 [PATCH v3 0/5] Static memory controllers for the Aspeed SoC Cédric Le Goater
2016-12-09 16:49 ` [PATCH v3 1/5] mtd: spi-nor: add memory controllers for the Aspeed AST2500 SoC Cédric Le Goater
     [not found]   ` <1481302167-28044-2-git-send-email-clg-Bxea+6Xhats@public.gmane.org>
2016-12-10  4:01     ` Marek Vasut
     [not found]       ` <68aa03be-8195-1824-a9e1-609a5ad74381-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-12-10 17:34         ` Cédric Le Goater
     [not found]           ` <f0ad683a-0989-e1ae-b33b-9746260ffa0e-Bxea+6Xhats@public.gmane.org>
2016-12-10 19:08             ` Marek Vasut
2016-12-12  0:05     ` Joel Stanley
2016-12-12  5:02     ` Joel Stanley
     [not found]       ` <CACPK8XeTw4uNCjzp7qmbwkojrSAJw_U=7vXD-wTjDL2gb220qQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-12-12  9:57         ` Cédric Le Goater
     [not found] ` <1481302167-28044-1-git-send-email-clg-Bxea+6Xhats@public.gmane.org>
2016-12-09 16:49   ` Cédric Le Goater [this message]
     [not found]     ` <1481302167-28044-3-git-send-email-clg-Bxea+6Xhats@public.gmane.org>
2016-12-10  4:03       ` [PATCH v3 2/5] mtd: aspeed: add memory controllers for the Aspeed AST2400 SoC Marek Vasut
     [not found]         ` <076683ea-fa94-2284-f269-2fcebd793940-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-12-10 17:18           ` Cédric Le Goater
     [not found]             ` <30a50d6d-07c5-0ca6-2d1b-3ba46c10da49-Bxea+6Xhats@public.gmane.org>
2016-12-10 17:30               ` Marek Vasut
2016-12-12  0:10       ` Joel Stanley
2016-12-09 16:49   ` [PATCH v3 3/5] mtd: aspeed: used a label property Cédric Le Goater
     [not found]     ` <1481302167-28044-4-git-send-email-clg-Bxea+6Xhats@public.gmane.org>
2016-12-10  4:03       ` Marek Vasut
2016-12-10 17:16         ` Cédric Le Goater
2016-12-11 23:46       ` Joel Stanley
     [not found]         ` <CACPK8Xcj4P34-4krGbnimVG89wMcHoRX4XJ66-_7KtAt6-vTkA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-12-12  2:27           ` Marek Vasut
     [not found]             ` <d8a6f699-3ee2-07b1-f0f5-478b0d8dd259-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-12-12  9:18               ` Cédric Le Goater
2016-12-09 16:49 ` [PATCH v3 4/5] mtd: spi-nor: bindings for the Aspeed memory controllers Cédric Le Goater
     [not found]   ` <1481302167-28044-5-git-send-email-clg-Bxea+6Xhats@public.gmane.org>
2016-12-12  0:13     ` Joel Stanley
2016-12-09 16:49 ` [PATCH v3 5/5] mtd: spi-nor: add a label property to jedec,spi-nor Cédric Le Goater
     [not found]   ` <1481302167-28044-6-git-send-email-clg-Bxea+6Xhats@public.gmane.org>
2016-12-11 23:47     ` Joel Stanley

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=1481302167-28044-3-git-send-email-clg@kaod.org \
    --to=clg-bxea+6xhats@public.gmane.org \
    --cc=boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org \
    --cc=computersforpeace-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=cyrille.pitchen-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=dwmw2-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org \
    --cc=joel-U3u1mxZcP9KHXe+LvDLADg@public.gmane.org \
    --cc=linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=marek.vasut-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
    --cc=richard-/L3Ra7n9ekc@public.gmane.org \
    --cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.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).