All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH linux dev4.7 v2 0/9] aspeed-smc: add support for AST2500 and DMA transfers
@ 2016-10-21  5:44 Cédric Le Goater
  2016-10-21  5:44 ` [PATCH linux dev4.7 v2 1/9] Revert "mtd/spi-nor: Add SPI memory controllers for Aspeed SoCs" Cédric Le Goater
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: Cédric Le Goater @ 2016-10-21  5:44 UTC (permalink / raw)
  To: openbmc

Hello,

This patchset adds to the current aspeed SMC driver the register
settings enabling support for the AST2500. Some initial work is done
on the segment registers to provide a better configuration of the
mapping windows on the flash modules but this area clearly needs more
work to be solid.

Also, a first version of DMA read/write is provided. But the speed
results are not very satisfying so they are disabled by default. You

Thanks,

C.

Changes since v1:

 - included a first revert of the current driver
 - merged all the difference in one patch to be sent to mainline
 - added a pinctrl fix for the witherspoon. 

Cédric Le Goater (6):
  Revert "mtd/spi-nor: Add SPI memory controllers for Aspeed SoCs"
  mtd/spi-nor: Add SPI memory controllers for Aspeed SoCs
  ARM: dts: aspeed-g5: update ast2500 evb with new spi-nor binding
  mtd: spi-nor: aspeed: add DMA support to smc controller
  ARM: dts: aspeed: update SMC controller nodes supporting DMAs
  ARM: dts: witherspoon: use spi1debug pinctrl group

Milton Miller (3):
  mtd: spi-nor: Add Micronix mx66l1g45g spi flash
  ARM: dts: aspeed-g5: update for new spi-nor binding
  ARM: dts: aspeed-g5: update witherspoon for new spi-nor binding

 .../devicetree/bindings/mtd/aspeed-smc.txt         |  37 +-
 arch/arm/boot/dts/aspeed-ast2500-evb.dts           |  28 +-
 arch/arm/boot/dts/aspeed-bmc-opp-palmetto.dts      |   2 +
 arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts   |  31 +-
 arch/arm/boot/dts/aspeed-g5.dtsi                   |  65 ++
 drivers/mtd/spi-nor/aspeed-smc.c                   | 655 +++++++++++++++++----
 drivers/mtd/spi-nor/spi-nor.c                      |   1 +
 7 files changed, 665 insertions(+), 154 deletions(-)

-- 
2.7.4

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH linux dev4.7 v2 1/9] Revert "mtd/spi-nor: Add SPI memory controllers for Aspeed SoCs"
  2016-10-21  5:44 [PATCH linux dev4.7 v2 0/9] aspeed-smc: add support for AST2500 and DMA transfers Cédric Le Goater
@ 2016-10-21  5:44 ` Cédric Le Goater
  2016-10-21  5:44 ` [PATCH linux dev4.7 v2 2/9] mtd/spi-nor: Add SPI memory controllers for Aspeed SoCs Cédric Le Goater
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Cédric Le Goater @ 2016-10-21  5:44 UTC (permalink / raw)
  To: openbmc

This reverts commit 94a6b4df012964167a502cf2ffb4adfff5d40b2e.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 .../devicetree/bindings/mtd/aspeed-smc.txt         |  75 ---
 drivers/mtd/spi-nor/Kconfig                        |  11 -
 drivers/mtd/spi-nor/Makefile                       |   1 -
 drivers/mtd/spi-nor/aspeed-smc.c                   | 567 ---------------------
 4 files changed, 654 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/mtd/aspeed-smc.txt
 delete mode 100644 drivers/mtd/spi-nor/aspeed-smc.c

diff --git a/Documentation/devicetree/bindings/mtd/aspeed-smc.txt b/Documentation/devicetree/bindings/mtd/aspeed-smc.txt
deleted file mode 100644
index a91496a6e46e..000000000000
--- a/Documentation/devicetree/bindings/mtd/aspeed-smc.txt
+++ /dev/null
@@ -1,75 +0,0 @@
-* Aspeed Static Memory controller in SPI mode
-* Aspeed SPI Flash Controller
-
-Required properties:
-  - compatible : Should be one of
-	"aspeed,ast2400-fmc" for the AST2400 Static Memory Controller
-	"aspeed,ast2500-fmc" for the AST2500 Static Memory Controller
-	"aspeed,ast2400-smc" for the AST2400 SPI flash controller
-  - reg : the first contains the register location and length,
-          the second through nth contains the memory mapping address and length
-	  for the access window for each chips select
-  - interrupts : Should contain the interrupt for the dma device if fmc
-  - clocks : The APB clock input to the controller
-  - #address-cells : must be 1 corresponding to chip select child binding
-  - #size-cells : must be 0 corresponding to chip select child binding
-
-
-Child node required properties:
-  - reg : must contain chip select number in first cell of address, must
-	  be 1 tuple long
-  - compatible : may contain "vendor,part", must include "jedec,spi-nor"
-		(see spi-nor.txt binding).
-
-Child node optional properties:
-  - label           - (optional) name to assign to mtd, default os assigned
-  - spi-max-frequency - (optional) max frequency of spi bus (XXX max if missing)
-  - spi-cpol        - (optional) Empty property indicating device requires
-    	 		inverse clock polarity (CPOL) mode (boolean)
-  - spi-cpha        - (optional) Empty property indicating device requires
-    			shifted clock phase (CPHA) mode (boolean)
-  - spi-tx-bus-width - (optional) The bus width(number of data wires) that
-                        used for MOSI. Defaults to 1 if not present.
-  - spi-rx-bus-width - (optional) The bus width(number of data wires) that
-                        used for MOSI. Defaults to 1 if not present.
-
-Child node optional properties:
- - see mtd/partiton.txt for partitioning bindings and mtd naming
-
-
-Example:
-
-fmc: fmc@1e620000 {
-	compatible = "aspeed,ast2400-fmc";
-	reg = < 0x1e620000 0x94
-		0x20000000 0x02000000
-		0x22000000 0x02000000 >;
-	#address-cells = <1>;
-	#size-cells = <0>;
-	flash@0 {
-		reg = < 0 >;
-		compatible = "jedec,spi-nor" ;
-		label = "bmc";
-		/* spi-max-frequency = <>; */
-		/* m25p,fast-read; */
-		#address-cells = <1>;
-		#size-cells = <1>;
-		boot@0 {
-			label = "boot-loader";
-			reg = < 0 0x8000 >
-		}
-		image@8000 {
-			label = "kernel-image";
-			reg = < 0x8000 0x1f8000 >
-		}
-	};
-	flash@1 {
-		reg = < 1 >;
-		compatible = "jedec,spi-nor" ;
-		label = "alt";
-		/* spi-max-frequency = <>; */
-		status = "fail";
-		/* m25p,fast-read; */
-	};
-};
-
diff --git a/drivers/mtd/spi-nor/Kconfig b/drivers/mtd/spi-nor/Kconfig
index fe336e25f8e2..d42c98e1f581 100644
--- a/drivers/mtd/spi-nor/Kconfig
+++ b/drivers/mtd/spi-nor/Kconfig
@@ -49,15 +49,4 @@ config SPI_NXP_SPIFI
 	  Flash. Enable this option if you have a device with a SPIFI
 	  controller and want to access the Flash as a mtd device.
 
-config ASPEED_FLASH_SPI
-	tristate "Aspeed flash controllers in SPI mode"
-	depends on HAS_IOMEM && OF
-	depends on ARCH_ASPEED || COMPILE_TEST
-	# IO_SPACE_LIMIT must be equivalent to (~0UL)
-	depends on !NEED_MACH_IO_H
-	help
-	  This enables support for the New Static Memory Controller (FMC)
-	  in the AST2400 when attached to SPI nor chips, and support for
-	  the SPI Memory controller (SPI) for the BIOS.
-
 endif # MTD_SPI_NOR
diff --git a/drivers/mtd/spi-nor/Makefile b/drivers/mtd/spi-nor/Makefile
index a20dd35877b0..0bf3a7f81675 100644
--- a/drivers/mtd/spi-nor/Makefile
+++ b/drivers/mtd/spi-nor/Makefile
@@ -1,5 +1,4 @@
 obj-$(CONFIG_MTD_SPI_NOR)	+= spi-nor.o
 obj-$(CONFIG_SPI_FSL_QUADSPI)	+= fsl-quadspi.o
 obj-$(CONFIG_MTD_MT81xx_NOR)    += mtk-quadspi.o
-obj-$(CONFIG_ASPEED_FLASH_SPI)	+= aspeed-smc.o
 obj-$(CONFIG_SPI_NXP_SPIFI)	+= nxp-spifi.o
diff --git a/drivers/mtd/spi-nor/aspeed-smc.c b/drivers/mtd/spi-nor/aspeed-smc.c
deleted file mode 100644
index e61a0d8aa5c0..000000000000
--- a/drivers/mtd/spi-nor/aspeed-smc.c
+++ /dev/null
@@ -1,567 +0,0 @@
-/*
- * ASPEED Static Memory Controller driver
- * Copyright 2016 IBM Corporation
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 2 as
- *  published by the Free Software Foundation.
- *
- */
-
-#include <linux/bug.h>
-#include <linux/device.h>
-#include <linux/io.h>
-#include <linux/module.h>
-#include <linux/mutex.h>
-#include <linux/mtd/mtd.h>
-#include <linux/mtd/partitions.h>
-#include <linux/mtd/spi-nor.h>
-#include <linux/of.h>
-#include <linux/of_platform.h>
-#include <linux/sysfs.h>
-
-/*
- * In user mode bytes all data bytes read or written to the chip decode 
- * address range are sent to the SPI bus.  The range is treated as a fifo
- * of arbitratry 1, 2, or 4 byte width but each write has to be aligned
- * to its size.  The address within the multiple 8kB range is ignored when
- * sending bytes to the SPI bus.
- *
- * On the arm architecture, as of Linux version 4.3, memcpy_fromio and
- * memcpy_toio on little endian targets use the optimized memcpy routines
- * that were designed for well behavied memory storage.  These routines
- * have a stutter if the source and destination are not both word aligned,
- * once with a duplicate access to the source after aligning the destination
- * to a word boundary, and once with a duplicate access to the destination
- * when the final byte count is not word aligned.
- *
- * When writing or reading the fifo this stutter discards data or sends
- * too much data to the fifo and can not be used by this driver.
- *
- * While the low level io string routines that implement the insl family do
- * the desired accesses and memory increments, the cross architecture io
- * macros make them essentially impossible to use on a memory mapped address
- * instead of a a token from the call to iomap of an io port.
- *
- * These fifo routines use readl and friends to a constant io port and update
- * the memory buffer pointer and count via explict code.  The final updates
- * to len are optimistically suppressed.
- */
-
-static void aspeed_smc_from_fifo(void *buf, const void __iomem *iop, size_t len)
-{
-	if (!len)
-		return;
-
-	/* Expect a 4 byte input port.  Otherwise just read bytes. */
-	if (unlikely((unsigned long)iop & 3)) {
-		while (len--) {
-			*(u8 *)buf = readb(iop);
-			buf++;
-		}
-	}
-
-	/* Align target to word: first byte then half word */
-	if ((unsigned long)buf & 1) {
-		*(u8 *)buf = readb(iop);
-		buf++;
-		len--;
-	}
-	if (((unsigned long)buf & 2) && (len >= 2)) {
-		*(u16 *)buf = readw(iop);
-		buf += 2;
-		len -= 2;
-	}
-
-	/* Transfer words, then remaining halfword and remaining byte */
-	while (len >= 4) {
-		*(u32 *)buf = readl(iop);
-		buf += 4;
-		len -= 4;
-	}
-	if (len & 2) {
-		*(u16 *)buf = readw(iop);
-		buf += 2;
-	}
-	if (len & 1) {
-		*(u8 *)buf = readb(iop);
-	}
-}
-
-static void aspeed_smc_to_fifo(void __iomem *iop, const void *buf, size_t len)
-{
-	if (!len)
-		return;
-
-	/* Expect a 4 byte output port.  Otherwise just write bytes. */
-	if ((unsigned long)iop & 3) {
-		while (len--) {
-			writeb(*(u8 *)buf, iop);
-			buf++;
-		}
-		return;
-	}
-
-	/* Align target to word: first byte then half word */
-	if ((unsigned long)buf & 1) {
-		writeb(*(u8 *)buf, iop);
-		buf++;
-		len--;
-	}
-	if (((unsigned long)buf & 2) && (len >= 2)) {
-		writew(*(u16 *)buf, iop);
-		buf += 2;
-		len -= 2;
-	}
-
-	/* Transfer words, then remaining halfword and remaining byte */
-	while (len >= 4) {
-		writel(*(u32 *)buf, iop);
-		buf += 4;
-		len -= 4;
-	}
-	if (len & 2) {
-		writew(*(u16 *)buf, iop);
-		buf += 2;
-	}
-	if (len & 1) {
-		writeb(*(u8 *)buf, iop);
-	}
-}
-
-enum smc_flash_type {
-	smc_type_nor = 0,	/* controller connected to nor flash */
-	smc_type_nand = 1,	/* controller connected to nand flash */
-	smc_type_spi = 2,	/* controller connected to spi flash */
-};
-
-struct aspeed_smc_info {
-	u8 nce;			/* number of chip enables */
-	u8 maxwidth;		/* max width of spi bus */
-	bool hasdma;		/* has dma engine */
-	bool hastype;		/* flash type field exists in cfg reg */
-	u8 we0;			/* we shift for ce 0 in cfg reg */
-	u8 ctl0;		/* offset in regs of ctl for ce 0 */
-	u8 cfg;			/* offset in regs of cfg */
-	u8 time;		/* offset in regs of timing */
-	u8 misc;		/* offset in regs of misc settings */
-};
-
-static struct aspeed_smc_info fmc_info = {
-	.nce = 5,
-	.maxwidth = 4,
-	.hasdma = true,
-	.hastype = true,
-	.we0 = 16,
-	.ctl0 = 0x10,
-	.cfg = 0x00,
-	.time = 0x54,
-	.misc = 0x50,
-};
-
-static struct aspeed_smc_info smc_info = {
-	.nce = 1,
-	.maxwidth = 2,
-	.hasdma = false,
-	.hastype = false,
-	.we0 = 0,
-	.ctl0 = 0x04,
-	.cfg = 0x00,
-	.time = 0x14,
-	.misc = 0x10,
-};
-
-enum smc_ctl_reg_value {
-	smc_base,		/* base value without mode for other commands */
-	smc_read,		/* command reg for (maybe fast) reads */
-	smc_write,		/* command reg for writes with timings */
-	smc_num_ctl_reg_values	/* last value to get count of commands */
-};
-
-struct aspeed_smc_controller;
-
-struct aspeed_smc_chip {
-	struct aspeed_smc_controller *controller;
-	__le32 __iomem *ctl;			/* control register */
-	void __iomem *base;			/* base of chip window */
-	__le32 ctl_val[smc_num_ctl_reg_values];	/* controls with timing */
-	enum smc_flash_type type;		/* what type of flash */
-	struct spi_nor nor;
-};
-
-struct aspeed_smc_controller {
-	struct mutex mutex;			/* controller access mutex */
-	const struct aspeed_smc_info *info;	/* type info of controller */
-	void __iomem *regs;			/* controller registers */
-	struct aspeed_smc_chip *chips[0];	/* pointers to attached chips */
-};
-
-#define CONTROL_SPI_AAF_MODE BIT(31)
-#define CONTROL_SPI_IO_MODE_MASK GENMASK(30, 28)
-#define CONTROL_SPI_IO_DUAL_DATA BIT(29)
-#define CONTROL_SPI_IO_DUAL_ADDR_DATA (BIT(29) | BIT(28))
-#define CONTROL_SPI_IO_QUAD_DATA BIT(30)
-#define CONTROL_SPI_IO_QUAD_ADDR_DATA (BIT(30) | BIT(28))
-#define CONTROL_SPI_CE_INACTIVE_SHIFT 24
-#define CONTROL_SPI_CE_INACTIVE_MASK GENMASK(27, CONTROL_SPI_CE_INACTIVE_SHIFT)
-/* 0 = 16T ... 15 = 1T   T=HCLK */
-#define CONTROL_SPI_COMMAND_SHIFT 16
-#define CONTROL_SPI_DUMMY_CYCLE_COMMAND_OUTPUT BIT(15)
-#define CONTROL_SPI_IO_DUMMY_CYCLES_HI BIT(14)
-#define CONTROL_SPI_IO_DUMMY_CYCLES_HI_SHIFT (14 - 2)
-#define CONTROL_SPI_IO_ADDRESS_4B BIT(13) /* FMC, LEGACY */
-#define CONTROL_SPI_CLK_DIV4 BIT(13) /* BIOS */
-#define CONTROL_SPI_RW_MERGE BIT(12)
-#define CONTROL_SPI_IO_DUMMY_CYCLES_LO_SHIFT 6
-#define CONTROL_SPI_IO_DUMMY_CYCLES_LO GENMASK(7, CONTROL_SPI_IO_DUMMY_CYCLES_LO_SHIFT)
-#define CONTROL_SPI_IO_DUMMY_CYCLES_MASK (CONTROL_SPI_IO_DUMMY_CYCLES_HI | \
-					  CONTROL_SPI_IO_DUMMY_CYCLES_LO)
-#define CONTROL_SPI_CLOCK_FREQ_SEL_SHIFT 8
-#define CONTROL_SPI_CLOCK_FREQ_SEL_MASK GENMASK(11, CONTROL_SPI_CLOCK_FREQ_SEL_SHIFT)
-#define CONTROL_SPI_LSB_FIRST BIT(5)
-#define CONTROL_SPI_CLOCK_MODE_3 BIT(4)
-#define CONTROL_SPI_IN_DUAL_DATA BIT(3)
-#define CONTROL_SPI_CE_STOP_ACTIVE_CONTROL BIT(2)
-#define CONTROL_SPI_COMMAND_MODE_MASK GENMASK(1, 0)
-#define CONTROL_SPI_COMMAND_MODE_NORMAL (0)
-#define CONTROL_SPI_COMMAND_MODE_FREAD (1)
-#define CONTROL_SPI_COMMAND_MODE_WRITE (2)
-#define CONTROL_SPI_COMMAND_MODE_USER (3)
-
-#define CONTROL_SPI_KEEP_MASK (CONTROL_SPI_AAF_MODE | \
-	CONTROL_SPI_CE_INACTIVE_MASK | CONTROL_SPI_IO_ADDRESS_4B | \
-	CONTROL_SPI_IO_DUMMY_CYCLES_MASK | CONTROL_SPI_CLOCK_FREQ_SEL_MASK | \
-	CONTROL_SPI_LSB_FIRST | CONTROL_SPI_CLOCK_MODE_3)
-
-
-static u32 spi_control_fill_opcode(u8 opcode)
-{
-	return ((u32)(opcode)) << CONTROL_SPI_COMMAND_SHIFT;
-}
-
-static void aspeed_smc_start_user(struct spi_nor *nor)
-{
-	struct aspeed_smc_chip *chip = nor->priv;
-	u32 ctl = chip->ctl_val[smc_base];
-
-	mutex_lock(&chip->controller->mutex);
-
-	ctl |= CONTROL_SPI_COMMAND_MODE_USER |
-		CONTROL_SPI_CE_STOP_ACTIVE_CONTROL;
-	writel(ctl, chip->ctl);
-
-	ctl &= ~CONTROL_SPI_CE_STOP_ACTIVE_CONTROL;
-	writel(ctl, chip->ctl);
-}
-
-static void aspeed_smc_stop_user(struct spi_nor *nor)
-{
-	struct aspeed_smc_chip *chip = nor->priv;
-
-	u32 ctl = chip->ctl_val[smc_read];
-	u32 ctl2 = ctl | CONTROL_SPI_COMMAND_MODE_USER |
-		CONTROL_SPI_CE_STOP_ACTIVE_CONTROL;
-
-	writel(ctl2, chip->ctl);	/* stop user CE control */
-	writel(ctl, chip->ctl);		/* default to fread or read */
-
-	mutex_unlock(&chip->controller->mutex);
-}
-
-static int aspeed_smc_read_reg(struct spi_nor *nor, u8 opcode, u8 *buf, int len)
-{
-	struct aspeed_smc_chip *chip = nor->priv;
-
-	aspeed_smc_start_user(nor);
-	aspeed_smc_to_fifo(chip->base, &opcode, 1);
-	aspeed_smc_from_fifo(buf, chip->base, len);
-	aspeed_smc_stop_user(nor);
-
-	return 0;
-}
-
-static int aspeed_smc_write_reg(struct spi_nor *nor, u8 opcode, u8 *buf,
-				int len)
-{
-	struct aspeed_smc_chip *chip = nor->priv;
-
-	aspeed_smc_start_user(nor);
-	aspeed_smc_to_fifo(chip->base, &opcode, 1);
-	aspeed_smc_to_fifo(chip->base, buf, len);
-	aspeed_smc_stop_user(nor);
-
-	return 0;
-}
-
-static void aspeed_smc_send_cmd_addr(struct spi_nor *nor, u8 cmd, u32 addr)
-{
-	struct aspeed_smc_chip *chip = nor->priv;
-	__be32 temp;
-	u32 cmdaddr;
-
-	switch (nor->addr_width) {
-	default:
-		WARN_ONCE(1, "Unexpected address width %u, defaulting to 3\n",
-			  nor->addr_width);
-		/* FALLTHROUGH */
-	case 3:
-		cmdaddr = addr & 0xFFFFFF;
-
-		cmdaddr |= (u32)cmd << 24;
-
-		temp = cpu_to_be32(cmdaddr);
-		aspeed_smc_to_fifo(chip->base, &temp, 4);
-		break;
-	case 4:
-		temp = cpu_to_be32(addr);
-		aspeed_smc_to_fifo(chip->base, &cmd, 1);
-		aspeed_smc_to_fifo(chip->base, &temp, 4);
-		break;
-	}
-}
-
-static int aspeed_smc_read_user(struct spi_nor *nor, loff_t from, size_t len,
-				size_t *retlen, u_char *read_buf)
-{
-	struct aspeed_smc_chip *chip = nor->priv;
-
-	aspeed_smc_start_user(nor);
-	aspeed_smc_send_cmd_addr(nor, nor->read_opcode, from);
-	aspeed_smc_from_fifo(read_buf, chip->base, len);
-	*retlen += len;
-	aspeed_smc_stop_user(nor);
-
-	return 0;
-}
-
-static void aspeed_smc_write_user(struct spi_nor *nor, loff_t to, size_t len,
-				  size_t *retlen, const u_char *write_buf)
-{
-	struct aspeed_smc_chip *chip = nor->priv;
-
-	aspeed_smc_start_user(nor);
-	aspeed_smc_send_cmd_addr(nor, nor->program_opcode, to);
-	aspeed_smc_to_fifo(chip->base, write_buf, len);
-	*retlen += len;
-	aspeed_smc_stop_user(nor);
-}
-
-static int aspeed_smc_remove(struct platform_device *dev)
-{
-	struct aspeed_smc_chip *chip;
-	struct aspeed_smc_controller *controller = platform_get_drvdata(dev);
-	int n;
-
-	for (n = 0; n < controller->info->nce; n++) {
-		chip = controller->chips[n];
-		if (chip)
-			mtd_device_unregister(&chip->nor.mtd);
-	}
-
-	return 0;
-}
-
-const struct of_device_id aspeed_smc_matches[] = {
-	{ .compatible = "aspeed,ast2500-fmc", .data = &fmc_info },
-	{ .compatible = "aspeed,ast2400-fmc", .data = &fmc_info },
-	{ .compatible = "aspeed,ast2400-smc", .data = &smc_info },
-	{ }
-};
-MODULE_DEVICE_TABLE(of, aspeed_smc_matches);
-
-static struct platform_device *
-of_platform_device_create_or_find(struct device_node *child,
-				  struct device *parent)
-{
-	struct platform_device *cdev;
-
-	cdev = of_platform_device_create(child, NULL, parent);
-	if (!cdev)
-		cdev = of_find_device_by_node(child);
-	return cdev;
-}
-
-static int aspeed_smc_probe(struct platform_device *dev)
-{
-	struct aspeed_smc_controller *controller;
-	const struct of_device_id *match;
-	const struct aspeed_smc_info *info;
-	struct resource *r;
-	void __iomem *regs;
-	struct device_node *child;
-	int err = 0;
-	unsigned int n;
-
-	match = of_match_device(aspeed_smc_matches, &dev->dev);
-	if (!match || !match->data)
-		return -ENODEV;
-	info = match->data;
-	r = platform_get_resource(dev, IORESOURCE_MEM, 0);
-	regs = devm_ioremap_resource(&dev->dev, r);
-	if (IS_ERR(regs))
-		return PTR_ERR(regs);
-
-	controller = devm_kzalloc(&dev->dev, sizeof(*controller) +
-		info->nce * sizeof(controller->chips[0]), GFP_KERNEL);
-	if (!controller)
-		return -ENOMEM;
-	platform_set_drvdata(dev, controller);
-	controller->regs = regs;
-	controller->info = info;
-	mutex_init(&controller->mutex);
-
-	/* The pinmux or bootloader will disable legacy mode. */
-
-	/*
-	 * XXX Need to add arbitration to the SMC (BIOS) controller if access
-	 * is shared by the host.
-	 */
-
-	for_each_available_child_of_node(dev->dev.of_node, child) {
-		struct platform_device *cdev;
-		struct aspeed_smc_chip *chip;
-		u32 reg;
-
-		/* This version does not support nand or nor flash devices. */
-		if (!of_device_is_compatible(child, "jedec,spi-nor"))
-			continue;
-
-
-		/*
-		 * create a platform device from the of node.  If the device
-		 * already was created (eg from a prior bind/unbind cycle)
-		 * reuse it.
-		 *
-		 * The creating the device node for the child here allows its
-		 * use for error reporting via dev_err below.
-		 */
-		cdev = of_platform_device_create_or_find(child, &dev->dev);
-		if (!cdev)
-			continue;
-
-		err = of_property_read_u32(child, "reg", &n);
-		if (err == -EINVAL && info->nce == 1)
-			n = 0;
-		else if (err || n >= info->nce)
-			continue;
-		if (controller->chips[n]) {
-			dev_err(&cdev->dev,
-				"chip-id %u already in use in use by %s\n",
-				n, dev_name(controller->chips[n]->nor.dev));
-			continue;
-		}
-		chip = devm_kzalloc(&dev->dev, sizeof(*chip), GFP_KERNEL);
-		if (!chip)
-			continue;
-
-		r = platform_get_resource(dev, IORESOURCE_MEM, n + 1);
-		chip->base = devm_ioremap_resource(&dev->dev, r);
-
-		if (!chip->base)
-			continue;
-		chip->controller = controller;
-		chip->ctl = controller->regs + info->ctl0 + n * 4;
-
-		/*
-		 * The device tree said the chip is spi.
-		 * XXX Need to set it in controller if has_type says the
-		 * type is programmable.
-		 */
-		chip->type = smc_type_spi;
-
-		/*
-		 * Always turn on the write enable bit in the config register
-		 * to allow opcodes to be sent in user mode.
-		 */
-		mutex_lock(&controller->mutex);
-		reg = readl(controller->regs + info->cfg);
-		dev_dbg(&dev->dev, "flash config was %08x\n", reg);
-		reg |= 1 << (info->we0 + n); /* WEn */
-		writel(reg, controller->regs + info->cfg);
-		mutex_unlock(&controller->mutex);
-
-		/*
-		 * Read the existing control register to get basic values.
-		 *
-		 * XXX This register probably needs more sanitation.
-		 * XXX Do we trust the bootloader or the device tree?
-		 * spi-nor.c trusts jtag id over passed ids.
-		 *
-		 * Do we need support for mode 3 vs mode 0 clock phasing?
-		 */
-		reg = readl(chip->ctl);
-		chip->ctl_val[smc_base] = reg & CONTROL_SPI_KEEP_MASK;
-
-		/*
-		 * Retain the prior value of the control register as the
-		 * default if it was normal access mode.  Otherwise start
-		 * with the sanitized base value set to read mode.
-		 */
-		if ((reg & CONTROL_SPI_COMMAND_MODE_MASK) ==
-		     CONTROL_SPI_COMMAND_MODE_NORMAL)
-			chip->ctl_val[smc_read] = reg;
-		else
-			chip->ctl_val[smc_read] = chip->ctl_val[smc_base] |
-				CONTROL_SPI_COMMAND_MODE_NORMAL;
-
-		chip->nor.dev = &cdev->dev;
-		chip->nor.priv = chip;
-		spi_nor_set_flash_node(&chip->nor, child);
-		chip->nor.mtd.name = of_get_property(child, "label", NULL);
-		chip->nor.read = aspeed_smc_read_user;
-		chip->nor.write = aspeed_smc_write_user;
-		chip->nor.read_reg = aspeed_smc_read_reg;
-		chip->nor.write_reg = aspeed_smc_write_reg;
-
-		/*
-		 * XXX Add support for SPI_NOR_QUAD and SPI_NOR_DUAL attach
-		 * when board support is present as determined by of property.
-		 */
-		err = spi_nor_scan(&chip->nor, NULL, SPI_NOR_NORMAL);
-		if (err)
-			continue;
-
-		chip->ctl_val[smc_write] = chip->ctl_val[smc_base] |
-			spi_control_fill_opcode(chip->nor.program_opcode) |
-			CONTROL_SPI_COMMAND_MODE_WRITE;
-
-		/*
-		 * XXX TODO
-		 * Enable fast read mode as required here.
-		 * Adjust clocks if fast read and write are supported.
-		 * Interpret spi-nor flags to adjust controller settings.
-		 * Check if resource size big enough for detected chip and
-		 * add support assisted (normal or fast-) read.
-		 */
-
-		err = mtd_device_register(&chip->nor.mtd, NULL, 0);
-		if (err)
-			continue;
-		controller->chips[n] = chip;
-	}
-
-	/* Were any children registered? */
-	for (n = 0; n < info->nce; n++)
-		if (controller->chips[n])
-			break;
-
-	if (n == info->nce)
-		return -ENODEV;
-
-	return 0;
-}
-
-static struct platform_driver aspeed_smc_driver = {
-	.probe = aspeed_smc_probe,
-	.remove = aspeed_smc_remove,
-	.driver = {
-		.name = KBUILD_MODNAME,
-		.of_match_table = aspeed_smc_matches,
-	}
-};
-
-module_platform_driver(aspeed_smc_driver);
-
-MODULE_DESCRIPTION("ASPEED Static Memory Controller Driver");
-MODULE_AUTHOR("Milton Miller");
-MODULE_LICENSE("GPL v2");
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH linux dev4.7 v2 2/9] mtd/spi-nor: Add SPI memory controllers for Aspeed SoCs
  2016-10-21  5:44 [PATCH linux dev4.7 v2 0/9] aspeed-smc: add support for AST2500 and DMA transfers Cédric Le Goater
  2016-10-21  5:44 ` [PATCH linux dev4.7 v2 1/9] Revert "mtd/spi-nor: Add SPI memory controllers for Aspeed SoCs" Cédric Le Goater
@ 2016-10-21  5:44 ` Cédric Le Goater
  2016-10-21  5:44 ` [PATCH linux dev4.7 v2 3/9] mtd: spi-nor: Add Micronix mx66l1g45g spi flash Cédric Le Goater
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Cédric Le Goater @ 2016-10-21  5:44 UTC (permalink / raw)
  To: openbmc

This driver adds mtd support for spi-nor attached to either or both of
the Firmware Memory Controller or the SPI Flash Controller (AST2400
only).

The SMC controllers on the Aspeed AST2500 SoC are very similar to the
ones found on the AST2400. The differences are on the number of
supported flash modules and their default mappings in the SoC address
space.

The Aspeed AST2500 has one SPI controller for the BMC firmware and two
for the host firmware. All controllers have now the same set of
registers compatible with the AST2400 FMC controller and the legacy
'SMC' controller is fully gone.

Based on previous work from Milton D. Miller II <miltonm@us.ibm.com>

Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 .../devicetree/bindings/mtd/aspeed-smc.txt         |  86 +++
 drivers/mtd/spi-nor/Kconfig                        |  11 +
 drivers/mtd/spi-nor/Makefile                       |   1 +
 drivers/mtd/spi-nor/aspeed-smc.c                   | 747 +++++++++++++++++++++
 4 files changed, 845 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mtd/aspeed-smc.txt
 create mode 100644 drivers/mtd/spi-nor/aspeed-smc.c

diff --git a/Documentation/devicetree/bindings/mtd/aspeed-smc.txt b/Documentation/devicetree/bindings/mtd/aspeed-smc.txt
new file mode 100644
index 000000000000..f6bfa7761205
--- /dev/null
+++ b/Documentation/devicetree/bindings/mtd/aspeed-smc.txt
@@ -0,0 +1,86 @@
+* Aspeed Static Memory controller
+* Aspeed SPI Flash Controller
+
+The Static memory controller in the ast2400 supports 5 chip selects each
+can be attached to NAND, parallel NOR, or SPI NOR attached flash.  The
+Firmware Memory Controller in the ast2500 supports 3 chip selects, two of
+which are always in SPI-NOR mode and the third can be SPI-NOR or parallel
+flash.  The SPI flash controller in the ast2400 supports one of 2 chip
+selects selected by pinmux.  The two SPI flash controllers in the ast2500
+each support two chip selects.
+
+Required properties:
+  - compatible : Should be one of
+	"aspeed,ast2400-fmc" for the AST2400 Static Memory Controller
+	"aspeed,ast2400-smc" for the AST2400 SPI Flash Controller
+	"aspeed,ast2500-fmc" for the AST2500 Firmware SPI Memory Controller
+	"aspeed,ast2500-smc" for the AST2500 SPI Flash Controllers
+  - reg : the first contains the control register location and length,
+          the second contains the memory window mapping address and length
+  - clocks : The APB clock input to the controller
+  - #address-cells : must be 1 corresponding to chip select child binding
+  - #size-cells : must be 0 corresponding to chip select child binding
+
+Optional properties:
+  - aspeed,fmc-has-dma : controller supports DMA transfers
+  - interrupts : Should contain the interrupt for the dma device if an fmc
+
+Child node required properties:
+  - reg : must contain chip select number in first cell of address, must
+	  be 1 tuple long
+  - compatible : may contain "vendor,part", must include "jedec,spi-nor"
+		when attached to SPI flash (see spi-nor.txt binding).
+
+Child node optional properties:
+  - label           - (optional) name to assign to mtd, default os assigned
+
+Child node optional properties for SPI mode (may be ignored):
+  - spi-max-frequency - (optional) max frequency of spi bus
+  - spi-cpol        - (optional) Empty property indicating device requires
+			inverse clock polarity (CPOL) mode (boolean)
+  - spi-cpha        - (optional) Empty property indicating device requires
+			shifted clock phase (CPHA) mode (boolean)
+  - spi-tx-bus-width - (optional) The bus width(number of data wires) that
+                        used for MOSI. Defaults to 1 if not present.
+  - spi-rx-bus-width - (optional) The bus width(number of data wires) that
+                        used for MOSI. Defaults to 1 if not present.
+
+Grandchild node optional properties:
+ - see mtd/partiton.txt for partitioning bindings and mtd naming
+
+
+Example:
+
+fmc: fmc@1e620000 {
+	compatible = "aspeed,ast2400-fmc";
+	reg = < 0x1e620000 0x94
+		0x20000000 0x02000000
+		0x22000000 0x02000000 >;
+	#address-cells = <1>;
+	#size-cells = <0>;
+	flash@0 {
+		reg = < 0 >;
+		compatible = "jedec,spi-nor" ;
+		label = "bmc";
+		/* spi-max-frequency = <>; */
+		/* m25p,fast-read; */
+		#address-cells = <1>;
+		#size-cells = <1>;
+		boot@0 {
+			label = "boot-loader";
+			reg = < 0 0x8000 >
+		}
+		image@8000 {
+			label = "kernel-image";
+			reg = < 0x8000 0x1f8000 >
+		}
+	};
+	flash@1 {
+		reg = < 1 >;
+		compatible = "jedec,spi-nor" ;
+		label = "alt";
+		/* spi-max-frequency = <>; */
+		status = "fail";
+		/* m25p,fast-read; */
+	};
+};
diff --git a/drivers/mtd/spi-nor/Kconfig b/drivers/mtd/spi-nor/Kconfig
index d42c98e1f581..fe336e25f8e2 100644
--- a/drivers/mtd/spi-nor/Kconfig
+++ b/drivers/mtd/spi-nor/Kconfig
@@ -49,4 +49,15 @@ config SPI_NXP_SPIFI
 	  Flash. Enable this option if you have a device with a SPIFI
 	  controller and want to access the Flash as a mtd device.
 
+config ASPEED_FLASH_SPI
+	tristate "Aspeed flash controllers in SPI mode"
+	depends on HAS_IOMEM && OF
+	depends on ARCH_ASPEED || COMPILE_TEST
+	# IO_SPACE_LIMIT must be equivalent to (~0UL)
+	depends on !NEED_MACH_IO_H
+	help
+	  This enables support for the New Static Memory Controller (FMC)
+	  in the AST2400 when attached to SPI nor chips, and support for
+	  the SPI Memory controller (SPI) for the BIOS.
+
 endif # MTD_SPI_NOR
diff --git a/drivers/mtd/spi-nor/Makefile b/drivers/mtd/spi-nor/Makefile
index 0bf3a7f81675..a20dd35877b0 100644
--- a/drivers/mtd/spi-nor/Makefile
+++ b/drivers/mtd/spi-nor/Makefile
@@ -1,4 +1,5 @@
 obj-$(CONFIG_MTD_SPI_NOR)	+= spi-nor.o
 obj-$(CONFIG_SPI_FSL_QUADSPI)	+= fsl-quadspi.o
 obj-$(CONFIG_MTD_MT81xx_NOR)    += mtk-quadspi.o
+obj-$(CONFIG_ASPEED_FLASH_SPI)	+= aspeed-smc.o
 obj-$(CONFIG_SPI_NXP_SPIFI)	+= nxp-spifi.o
diff --git a/drivers/mtd/spi-nor/aspeed-smc.c b/drivers/mtd/spi-nor/aspeed-smc.c
new file mode 100644
index 000000000000..aed610d8ab2f
--- /dev/null
+++ b/drivers/mtd/spi-nor/aspeed-smc.c
@@ -0,0 +1,747 @@
+/*
+ * ASPEED Static Memory Controller driver
+ *
+ * Copyright (c) 2015-2016, IBM Corporation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+#include <linux/bug.h>
+#include <linux/device.h>
+#include <linux/io.h>
+#include <linux/module.h>
+#include <linux/mutex.h>
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/partitions.h>
+#include <linux/mtd/spi-nor.h>
+#include <linux/of.h>
+#include <linux/of_platform.h>
+#include <linux/sysfs.h>
+
+#define DEVICE_NAME	"aspeed-smc"
+
+/*
+ * In user mode all data bytes read or written to the chip decode address
+ * range are transferred to or from the SPI bus. The range is treated as a
+ * fifo of arbitratry 1, 2, or 4 byte width but each write has to be aligned
+ * to its size.  The address within the multiple 8kB range is ignored when
+ * sending bytes to the SPI bus.
+ *
+ * On the arm architecture, as of Linux version 4.3, memcpy_fromio and
+ * memcpy_toio on little endian targets use the optimized memcpy routines
+ * that were designed for well behavied memory storage.  These routines
+ * have a stutter if the source and destination are not both word aligned,
+ * once with a duplicate access to the source after aligning to the
+ * destination to a word boundary, and again with a duplicate access to
+ * the source when the final byte count is not word aligned.
+ *
+ * When writing or reading the fifo this stutter discards data or sends
+ * too much data to the fifo and can not be used by this driver.
+ *
+ * While the low level io string routines that implement the insl family do
+ * the desired accesses and memory increments, the cross architecture io
+ * macros make them essentially impossible to use on a memory mapped address
+ * instead of a a token from the call to iomap of an io port.
+ *
+ * These fifo routines use readl and friends to a constant io port and update
+ * the memory buffer pointer and count via explicit code. The final updates
+ * to len are optimistically suppressed.
+ */
+
+static void aspeed_smc_from_fifo(void *buf, const void __iomem *iop, size_t len)
+{
+	if (!len)
+		return;
+
+	/* Expect a 4 byte input port.  Otherwise just read bytes. */
+	if (unlikely((unsigned long)iop & 3)) {
+		while (len--) {
+			*(u8 *)buf = readb(iop);
+			buf++;
+		}
+	}
+
+	/* Align target to word: first byte then half word */
+	if ((unsigned long)buf & 1) {
+		*(u8 *)buf = readb(iop);
+		buf++;
+		len--;
+	}
+	if (((unsigned long)buf & 2) && (len >= 2)) {
+		*(u16 *)buf = readw(iop);
+		buf += 2;
+		len -= 2;
+	}
+
+	/* Transfer words, then remaining halfword and remaining byte */
+	while (len >= 4) {
+		*(u32 *)buf = readl(iop);
+		buf += 4;
+		len -= 4;
+	}
+	if (len & 2) {
+		*(u16 *)buf = readw(iop);
+		buf += 2;
+	}
+	if (len & 1)
+		*(u8 *)buf = readb(iop);
+}
+
+static void aspeed_smc_to_fifo(void __iomem *iop, const void *buf, size_t len)
+{
+	if (!len)
+		return;
+
+	/* Expect a 4 byte output port.  Otherwise just write bytes. */
+	if ((unsigned long)iop & 3) {
+		while (len--) {
+			writeb(*(u8 *)buf, iop);
+			buf++;
+		}
+		return;
+	}
+
+	/* Align target to word: first byte then half word */
+	if ((unsigned long)buf & 1) {
+		writeb(*(u8 *)buf, iop);
+		buf++;
+		len--;
+	}
+	if (((unsigned long)buf & 2) && (len >= 2)) {
+		writew(*(u16 *)buf, iop);
+		buf += 2;
+		len -= 2;
+	}
+
+	/* Transfer words, then remaining halfword and remaining byte */
+	while (len >= 4) {
+		writel(*(u32 *)buf, iop);
+		buf += 4;
+		len -= 4;
+	}
+	if (len & 2) {
+		writew(*(u16 *)buf, iop);
+		buf += 2;
+	}
+	if (len & 1)
+		writeb(*(u8 *)buf, iop);
+}
+
+enum smc_flash_type {
+	smc_type_nor = 0,	/* controller connected to nor flash */
+	smc_type_nand = 1,	/* controller connected to nand flash */
+	smc_type_spi = 2,	/* controller connected to spi flash */
+};
+
+struct aspeed_smc_info {
+	u32 maxsize;		/* maximum size of 1 chip window */
+	u8 nce;			/* number of chip enables */
+	u8 maxwidth;		/* max width of spi bus */
+	bool hastype;		/* flash type field exists in cfg reg */
+	u8 we0;			/* shift for write enable bit for ce 0 */
+	u8 ctl0;		/* offset in regs of ctl for ce 0 */
+	u8 time;		/* offset in regs of timing */
+	u8 misc;		/* offset in regs of misc settings */
+};
+
+static struct aspeed_smc_info fmc_2400_info = {
+	.maxsize = 64 * 1024 * 1024,
+	.nce = 5,
+	.maxwidth = 4,
+	.hastype = true,
+	.we0 = 16,
+	.ctl0 = 0x10,
+	.time = 0x94,
+	.misc = 0x54,
+};
+
+static struct aspeed_smc_info smc_2400_info = {
+	.maxsize = 64 * 1024 * 1024,
+	.nce = 1,
+	.maxwidth = 2,
+	.hastype = false,
+	.we0 = 0,
+	.ctl0 = 0x04,
+	.time = 0x14,
+	.misc = 0x10,
+};
+
+static struct aspeed_smc_info fmc_2500_info = {
+	.maxsize = 256 * 1024 * 1024,
+	.nce = 3,
+	.maxwidth = 2,
+	.hastype = true,
+	.we0 = 16,
+	.ctl0 = 0x10,
+	.time = 0x94,
+	.misc = 0x54,
+};
+
+static struct aspeed_smc_info smc_2500_info = {
+	.maxsize = 128 * 1024 * 1024,
+	.nce = 2,
+	.maxwidth = 2,
+	.hastype = false,
+	.we0 = 16,
+	.ctl0 = 0x10,
+	.time = 0x94,
+	.misc = 0x54,
+};
+
+enum smc_ctl_reg_value {
+	smc_base,		/* base value without mode for other commands */
+	smc_read,		/* command reg for (maybe fast) reads */
+	smc_write,		/* command reg for writes with timings */
+	smc_num_ctl_reg_values	/* last value to get count of commands */
+};
+
+struct aspeed_smc_controller;
+
+struct aspeed_smc_chip {
+	int cs;
+	struct aspeed_smc_controller *controller;
+	__le32 __iomem *ctl;			/* control register */
+	void __iomem *base;			/* base of chip window */
+	__le32 ctl_val[smc_num_ctl_reg_values];	/* controls with timing */
+	enum smc_flash_type type;		/* what type of flash */
+	struct spi_nor nor;
+};
+
+struct aspeed_smc_controller {
+	struct device *dev;
+
+	struct mutex mutex;			/* controller access mutex */
+	const struct aspeed_smc_info *info;	/* type info of controller */
+	void __iomem *regs;			/* controller registers */
+	void __iomem *windows;			/* per-chip windows resource */
+
+	struct aspeed_smc_chip *chips[0];	/* pointers to attached chips */
+};
+
+/*
+ * FMC Type setting Register
+ *   or
+ * SPI Flash Configuration Register
+ */
+#define CONFIG_REG			0x0
+
+/*
+ * CE Control Register
+ */
+#define CE_CONTROL_REG			0x4
+#define    CE0_CONTROL_EXTENDED		    BIT(0)
+
+/* CE0 Control Register (depends on the controller type) */
+#define CONTROL_SPI_AAF_MODE BIT(31)
+#define CONTROL_SPI_IO_MODE_MASK GENMASK(30, 28)
+#define CONTROL_SPI_IO_DUAL_DATA BIT(29)
+#define CONTROL_SPI_IO_DUAL_ADDR_DATA (BIT(29) | BIT(28))
+#define CONTROL_SPI_IO_QUAD_DATA BIT(30)
+#define CONTROL_SPI_IO_QUAD_ADDR_DATA (BIT(30) | BIT(28))
+#define CONTROL_SPI_CE_INACTIVE_SHIFT 24
+#define CONTROL_SPI_CE_INACTIVE_MASK GENMASK(27, CONTROL_SPI_CE_INACTIVE_SHIFT)
+/* 0 = 16T ... 15 = 1T   T=HCLK */
+#define CONTROL_SPI_COMMAND_SHIFT 16
+#define CONTROL_SPI_DUMMY_CYCLE_COMMAND_OUTPUT BIT(15)
+#define CONTROL_SPI_IO_DUMMY_CYCLES_HI BIT(14)
+#define CONTROL_SPI_IO_DUMMY_CYCLES_HI_SHIFT (14 - 2)
+#define CONTROL_SPI_IO_ADDRESS_4B BIT(13) /* 2400-smc */
+#define CONTROL_SPI_CLK_DIV4 BIT(13) /* FMC, 2500 */
+#define CONTROL_SPI_RW_MERGE BIT(12)
+#define CONTROL_SPI_IO_DUMMY_CYCLES_LO_SHIFT 6
+#define CONTROL_SPI_IO_DUMMY_CYCLES_LO GENMASK(7, \
+				       CONTROL_SPI_IO_DUMMY_CYCLES_LO_SHIFT)
+#define CONTROL_SPI_IO_DUMMY_CYCLES_MASK (CONTROL_SPI_IO_DUMMY_CYCLES_HI | \
+					  CONTROL_SPI_IO_DUMMY_CYCLES_LO)
+#define CONTROL_SPI_CLOCK_FREQ_SEL_SHIFT 8
+#define CONTROL_SPI_CLOCK_FREQ_SEL_MASK GENMASK(11, \
+					CONTROL_SPI_CLOCK_FREQ_SEL_SHIFT)
+#define CONTROL_SPI_LSB_FIRST BIT(5)
+#define CONTROL_SPI_CLOCK_MODE_3 BIT(4)
+#define CONTROL_SPI_IN_DUAL_DATA BIT(3)
+#define CONTROL_SPI_CE_STOP_ACTIVE_CONTROL BIT(2)
+#define CONTROL_SPI_COMMAND_MODE_MASK GENMASK(1, 0)
+#define CONTROL_SPI_COMMAND_MODE_NORMAL (0)
+#define CONTROL_SPI_COMMAND_MODE_FREAD (1)
+#define CONTROL_SPI_COMMAND_MODE_WRITE (2)
+#define CONTROL_SPI_COMMAND_MODE_USER (3)
+
+#define CONTROL_SPI_KEEP_MASK (CONTROL_SPI_AAF_MODE | \
+	CONTROL_SPI_CE_INACTIVE_MASK | CONTROL_SPI_CLK_DIV4 | \
+	CONTROL_SPI_IO_DUMMY_CYCLES_MASK | CONTROL_SPI_CLOCK_FREQ_SEL_MASK | \
+	CONTROL_SPI_LSB_FIRST | CONTROL_SPI_CLOCK_MODE_3)
+
+/* Segment Address Registers */
+#define SEGMENT_ADDR_REG0		0x30
+#define     SEGMENT_ADDR_START(_r)	    ((((_r) >> 16) & 0xFF) << 23)
+#define     SEGMENT_ADDR_END(_r)	    ((((_r) >> 24) & 0xFF) << 23)
+
+static u32 spi_control_fill_opcode(u8 opcode)
+{
+	return ((u32)(opcode)) << CONTROL_SPI_COMMAND_SHIFT;
+}
+
+static inline u32 aspeed_smc_chip_write_bit(struct aspeed_smc_chip *chip)
+{
+	return ((u32)1 << (chip->controller->info->we0 + chip->cs));
+}
+
+static void aspeed_smc_chip_check_config(struct aspeed_smc_chip *chip)
+{
+	struct aspeed_smc_controller *controller = chip->controller;
+	u32 reg;
+
+	reg = readl(controller->regs + CONFIG_REG);
+
+	if (!(reg & aspeed_smc_chip_write_bit(chip))) {
+		dev_dbg(controller->dev,
+			"config write is not set ! @%p: 0x%08x\n",
+			controller->regs + CONFIG_REG, reg);
+		reg |= aspeed_smc_chip_write_bit(chip);
+		writel(reg, controller->regs + CONFIG_REG);
+	}
+}
+
+static void aspeed_smc_start_user(struct spi_nor *nor)
+{
+	struct aspeed_smc_chip *chip = nor->priv;
+	u32 ctl = chip->ctl_val[smc_base];
+
+	/*
+	 * When the chip is controlled in user mode, we need write
+	 * access to send the opcodes to it. So check the config.
+	 */
+	aspeed_smc_chip_check_config(chip);
+
+	ctl |= CONTROL_SPI_COMMAND_MODE_USER |
+		CONTROL_SPI_CE_STOP_ACTIVE_CONTROL;
+	writel(ctl, chip->ctl);
+
+	ctl &= ~CONTROL_SPI_CE_STOP_ACTIVE_CONTROL;
+	writel(ctl, chip->ctl);
+}
+
+static void aspeed_smc_stop_user(struct spi_nor *nor)
+{
+	struct aspeed_smc_chip *chip = nor->priv;
+
+	u32 ctl = chip->ctl_val[smc_read];
+	u32 ctl2 = ctl | CONTROL_SPI_COMMAND_MODE_USER |
+		CONTROL_SPI_CE_STOP_ACTIVE_CONTROL;
+
+	writel(ctl2, chip->ctl);	/* stop user CE control */
+	writel(ctl, chip->ctl);		/* default to fread or read */
+}
+
+static int aspeed_smc_read_reg(struct spi_nor *nor, u8 opcode, u8 *buf, int len)
+{
+	struct aspeed_smc_chip *chip = nor->priv;
+
+	mutex_lock(&chip->controller->mutex);
+
+	aspeed_smc_start_user(nor);
+	aspeed_smc_to_fifo(chip->base, &opcode, 1);
+	aspeed_smc_from_fifo(buf, chip->base, len);
+	aspeed_smc_stop_user(nor);
+
+	mutex_unlock(&chip->controller->mutex);
+
+	return 0;
+}
+
+static int aspeed_smc_write_reg(struct spi_nor *nor, u8 opcode, u8 *buf,
+				int len)
+{
+	struct aspeed_smc_chip *chip = nor->priv;
+
+	mutex_lock(&chip->controller->mutex);
+
+	aspeed_smc_start_user(nor);
+	aspeed_smc_to_fifo(chip->base, &opcode, 1);
+	aspeed_smc_to_fifo(chip->base, buf, len);
+	aspeed_smc_stop_user(nor);
+
+	mutex_unlock(&chip->controller->mutex);
+
+	return 0;
+}
+
+static void aspeed_smc_send_cmd_addr(struct spi_nor *nor, u8 cmd, u32 addr)
+{
+	struct aspeed_smc_chip *chip = nor->priv;
+	__be32 temp;
+	u32 cmdaddr;
+
+	switch (nor->addr_width) {
+	default:
+		WARN_ONCE(1, "Unexpected address width %u, defaulting to 3\n",
+			  nor->addr_width);
+		/* FALLTHROUGH */
+	case 3:
+		cmdaddr = addr & 0xFFFFFF;
+
+		cmdaddr |= (u32)cmd << 24;
+
+		temp = cpu_to_be32(cmdaddr);
+		aspeed_smc_to_fifo(chip->base, &temp, 4);
+		break;
+	case 4:
+		temp = cpu_to_be32(addr);
+		aspeed_smc_to_fifo(chip->base, &cmd, 1);
+		aspeed_smc_to_fifo(chip->base, &temp, 4);
+		break;
+	}
+}
+
+static int aspeed_smc_read_user(struct spi_nor *nor, loff_t from, size_t len,
+				size_t *retlen, u_char *read_buf)
+{
+	struct aspeed_smc_chip *chip = nor->priv;
+
+	mutex_lock(&chip->controller->mutex);
+
+	aspeed_smc_start_user(nor);
+	aspeed_smc_send_cmd_addr(nor, nor->read_opcode, from);
+	aspeed_smc_from_fifo(read_buf, chip->base, len);
+	aspeed_smc_stop_user(nor);
+
+	mutex_unlock(&chip->controller->mutex);
+
+	*retlen += len;
+	return 0;
+}
+
+static void aspeed_smc_write_user(struct spi_nor *nor, loff_t to, size_t len,
+				  size_t *retlen, const u_char *write_buf)
+{
+	struct aspeed_smc_chip *chip = nor->priv;
+
+	mutex_lock(&chip->controller->mutex);
+
+	aspeed_smc_start_user(nor);
+	aspeed_smc_send_cmd_addr(nor, nor->program_opcode, to);
+	aspeed_smc_to_fifo(chip->base, write_buf, len);
+	aspeed_smc_stop_user(nor);
+
+	mutex_unlock(&chip->controller->mutex);
+
+	*retlen += len;
+}
+
+static int aspeed_smc_remove(struct platform_device *dev)
+{
+	struct aspeed_smc_chip *chip;
+	struct aspeed_smc_controller *controller = platform_get_drvdata(dev);
+	int n;
+
+	for (n = 0; n < controller->info->nce; n++) {
+		chip = controller->chips[n];
+		if (chip)
+			mtd_device_unregister(&chip->nor.mtd);
+	}
+
+	return 0;
+}
+
+const struct of_device_id aspeed_smc_matches[] = {
+	{ .compatible = "aspeed,ast2400-fmc", .data = &fmc_2400_info },
+	{ .compatible = "aspeed,ast2400-smc", .data = &smc_2400_info },
+	{ .compatible = "aspeed,ast2500-fmc", .data = &fmc_2500_info },
+	{ .compatible = "aspeed,ast2500-smc", .data = &smc_2500_info },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, aspeed_smc_matches);
+
+static struct platform_device *
+of_platform_device_create_or_find(struct device_node *child,
+				  struct device *parent)
+{
+	struct platform_device *cdev;
+
+	cdev = of_platform_device_create(child, NULL, parent);
+	if (!cdev)
+		cdev = of_find_device_by_node(child);
+	return cdev;
+}
+
+static void __iomem *window_start(struct aspeed_smc_controller *controller,
+				  struct resource *r, unsigned int n)
+{
+	u32 offset = 0;
+	u32 reg;
+
+	if (controller->info->nce > 1) {
+		reg = readl(controller->regs + SEGMENT_ADDR_REG0 + n * 4);
+
+		if (SEGMENT_ADDR_START(reg) >= SEGMENT_ADDR_END(reg))
+			return NULL;
+
+		offset = SEGMENT_ADDR_START(reg) - r->start;
+	}
+
+	return controller->windows + offset;
+}
+
+static void aspeed_smc_chip_enable_write(struct aspeed_smc_chip *chip)
+{
+	struct aspeed_smc_controller *controller = chip->controller;
+	u32 reg;
+
+	reg = readl(controller->regs + CONFIG_REG);
+	dev_dbg(controller->dev, "config reg @%p: 0x%08x\n",
+		controller->regs + CONFIG_REG, reg);
+
+	reg |= aspeed_smc_chip_write_bit(chip);
+	writel(reg, controller->regs + CONFIG_REG);
+}
+
+static void aspeed_smc_chip_set_type(struct aspeed_smc_chip *chip, int type)
+{
+	struct aspeed_smc_controller *controller = chip->controller;
+	u32 reg;
+
+	reg = readl(controller->regs + CONFIG_REG);
+	dev_dbg(controller->dev, "config reg @%p: 0x%08x\n",
+		controller->regs + CONFIG_REG, reg);
+
+	chip->type = type;
+
+	reg &= ~(3 << (chip->cs * 2));
+	reg |= chip->type << (chip->cs * 2);
+	writel(reg, controller->regs + CONFIG_REG);
+}
+
+static int aspeed_smc_chip_setup_init(struct aspeed_smc_chip *chip,
+				      struct resource *r)
+{
+	struct aspeed_smc_controller *controller = chip->controller;
+	const struct aspeed_smc_info *info = controller->info;
+	u32 reg;
+
+	/*
+	 * Always turn on the write enable bit to allow opcodes to be
+	 * sent in user mode.
+	 */
+	aspeed_smc_chip_enable_write(chip);
+
+	/* The driver only supports SPI type flash for the moment */
+	if (info->hastype)
+		aspeed_smc_chip_set_type(chip, smc_type_spi);
+
+	/*
+	 * Configure chip base address in memory
+	 */
+	chip->base = window_start(controller, r, chip->cs);
+	if (!chip->base) {
+		dev_warn(chip->nor.dev, "CE segment window closed.\n");
+		return -1;
+	}
+
+	/*
+	 * Read the existing control register to get basic values.
+	 *
+	 * XXX This register probably needs more sanitation.
+	 *
+	 * Do we need support for mode 3 vs mode 0 clock phasing?
+	 */
+	reg = readl(chip->ctl);
+	dev_dbg(controller->dev, "control register: %08x\n", reg);
+
+	if ((reg & CONTROL_SPI_KEEP_MASK) != reg) {
+		chip->ctl_val[smc_base] = reg & CONTROL_SPI_KEEP_MASK;
+		dev_info(controller->dev,
+			 "control register changed to: %08x\n",
+			 chip->ctl_val[smc_base]);
+	}
+
+	/*
+	 * Retain the prior value of the control register as the
+	 * default if it was normal access mode. Otherwise start with
+	 * the sanitized base value set to read mode.
+	 */
+	if ((reg & CONTROL_SPI_COMMAND_MODE_MASK) ==
+	    CONTROL_SPI_COMMAND_MODE_NORMAL)
+		chip->ctl_val[smc_read] = reg;
+	else
+		chip->ctl_val[smc_read] = chip->ctl_val[smc_base] |
+			CONTROL_SPI_COMMAND_MODE_NORMAL;
+
+	return 0;
+}
+
+static void aspeed_smc_chip_setup_finish(struct aspeed_smc_chip *chip)
+{
+	struct aspeed_smc_controller *controller = chip->controller;
+	u32 reg;
+
+	/*
+	 * Set 4 byte mode in the chip controller register and also in
+	 * controller config register. The BMC flash controller is
+	 * strapped by hardware, or autodetected, but the SPI flash
+	 * controller of the AST2500 still needs to be set.
+	 */
+	if (chip->nor.mtd.size > SZ_16M) {
+		chip->ctl_val[smc_base] |= CONTROL_SPI_IO_ADDRESS_4B;
+
+		/*
+		 * The SPI flash controller of the AST2400 does not
+		 * have such a setting.
+		 */
+		if (chip->controller->info == &smc_2500_info) {
+			reg = readl(controller->regs + CE_CONTROL_REG);
+			reg |= 1 << chip->cs;
+			writel(reg, controller->regs + CE_CONTROL_REG);
+		}
+	}
+
+	chip->ctl_val[smc_write] = chip->ctl_val[smc_base] |
+		spi_control_fill_opcode(chip->nor.program_opcode) |
+		CONTROL_SPI_COMMAND_MODE_WRITE;
+
+	/*
+	 * XXX TODO
+	 * Enable fast read mode as required here.
+	 * Adjust clocks if fast read and write are supported.
+	 * Interpret spi-nor flags to adjust controller settings.
+	 * Check if resource size big enough for detected chip and
+	 * add support assisted (normal or fast-) read and dma.
+	 */
+}
+
+static int aspeed_smc_probe(struct platform_device *pdev)
+{
+	struct aspeed_smc_controller *controller;
+	const struct of_device_id *match;
+	const struct aspeed_smc_info *info;
+	struct resource *r;
+	struct device_node *child;
+	int err = 0;
+	unsigned int n;
+
+	match = of_match_device(aspeed_smc_matches, &pdev->dev);
+	if (!match || !match->data)
+		return -ENODEV;
+	info = match->data;
+
+	controller = devm_kzalloc(&pdev->dev, sizeof(*controller) +
+		info->nce * sizeof(controller->chips[0]), GFP_KERNEL);
+	if (!controller)
+		return -ENOMEM;
+	controller->info = info;
+
+	mutex_init(&controller->mutex);
+	platform_set_drvdata(pdev, controller);
+
+	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	controller->regs = devm_ioremap_resource(&pdev->dev, r);
+	if (IS_ERR(controller->regs))
+		return PTR_ERR(controller->regs);
+
+	r = platform_get_resource(pdev, IORESOURCE_MEM, 1);
+	controller->windows = devm_ioremap_resource(&pdev->dev, r);
+	if (IS_ERR(controller->windows))
+		return PTR_ERR(controller->windows);
+
+	controller->dev = &pdev->dev;
+
+	/* The pinmux or bootloader will disable the legacy mode controller */
+
+	/*
+	 * XXX Need to add arbitration to the SMC (BIOS) controller if access
+	 * is shared by the host.
+	 */
+	for_each_available_child_of_node(controller->dev->of_node, child) {
+		struct platform_device *cdev;
+		struct aspeed_smc_chip *chip;
+
+		/* This version does not support nand or nor flash devices. */
+		if (!of_device_is_compatible(child, "jedec,spi-nor"))
+			continue;
+
+		/*
+		 * create a platform device from the of node.  If the device
+		 * already was created (eg from a prior bind/unbind cycle)
+		 * reuse it.
+		 *
+		 * The creating the device node for the child here allows its
+		 * use for error reporting via dev_err below.
+		 */
+		cdev = of_platform_device_create_or_find(child,
+							 controller->dev);
+		if (!cdev)
+			continue;
+
+		err = of_property_read_u32(child, "reg", &n);
+		if (err == -EINVAL && info->nce == 1)
+			n = 0;
+		else if (err || n >= info->nce)
+			continue;
+		if (controller->chips[n]) {
+			dev_err(&cdev->dev,
+				"chip-id %u already in use in use by %s\n",
+				n, dev_name(controller->chips[n]->nor.dev));
+			continue;
+		}
+
+		chip = devm_kzalloc(controller->dev, sizeof(*chip), GFP_KERNEL);
+		if (!chip)
+			continue;
+		chip->controller = controller;
+		chip->ctl = controller->regs + info->ctl0 + n * 4;
+		chip->cs = n;
+
+		chip->nor.dev = &cdev->dev;
+		chip->nor.priv = chip;
+		spi_nor_set_flash_node(&chip->nor, child);
+		chip->nor.mtd.name = of_get_property(child, "label", NULL);
+		chip->nor.read = aspeed_smc_read_user;
+		chip->nor.write = aspeed_smc_write_user;
+		chip->nor.read_reg = aspeed_smc_read_reg;
+		chip->nor.write_reg = aspeed_smc_write_reg;
+
+		aspeed_smc_chip_setup_init(chip, r);
+
+		/*
+		 * XXX Add support for SPI_NOR_QUAD and SPI_NOR_DUAL attach
+		 * when board support is present as determined by of property.
+		 */
+		err = spi_nor_scan(&chip->nor, NULL, SPI_NOR_NORMAL);
+		if (err)
+			continue;
+
+		aspeed_smc_chip_setup_finish(chip);
+
+		err = mtd_device_register(&chip->nor.mtd, NULL, 0);
+		if (err)
+			continue;
+		controller->chips[n] = chip;
+	}
+
+	/* Were any children registered? */
+	for (n = 0; n < info->nce; n++)
+		if (controller->chips[n])
+			break;
+
+	if (n == info->nce)
+		return -ENODEV;
+
+	return 0;
+}
+
+static struct platform_driver aspeed_smc_driver = {
+	.probe = aspeed_smc_probe,
+	.remove = aspeed_smc_remove,
+	.driver = {
+		.name = DEVICE_NAME,
+		.of_match_table = aspeed_smc_matches,
+	}
+};
+
+module_platform_driver(aspeed_smc_driver);
+
+MODULE_DESCRIPTION("ASPEED Static Memory Controller Driver");
+MODULE_AUTHOR("Milton Miller");
+MODULE_LICENSE("GPL v2");
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH linux dev4.7 v2 3/9] mtd: spi-nor: Add Micronix mx66l1g45g spi flash
  2016-10-21  5:44 [PATCH linux dev4.7 v2 0/9] aspeed-smc: add support for AST2500 and DMA transfers Cédric Le Goater
  2016-10-21  5:44 ` [PATCH linux dev4.7 v2 1/9] Revert "mtd/spi-nor: Add SPI memory controllers for Aspeed SoCs" Cédric Le Goater
  2016-10-21  5:44 ` [PATCH linux dev4.7 v2 2/9] mtd/spi-nor: Add SPI memory controllers for Aspeed SoCs Cédric Le Goater
@ 2016-10-21  5:44 ` Cédric Le Goater
  2016-10-21  5:44 ` [PATCH linux dev4.7 v2 4/9] ARM: dts: aspeed-g5: update for new spi-nor binding Cédric Le Goater
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Cédric Le Goater @ 2016-10-21  5:44 UTC (permalink / raw)
  To: openbmc

From: Milton Miller <miltonm@us.ibm.com>

These modules are used on the OpenPOWER Witherspoon systems to hold
the POWER9 host firmware image.

Signed-off-by: Milton Miller <miltonm@us.ibm.com>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 drivers/mtd/spi-nor/spi-nor.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index a6adb2785b14..a68073afe8a8 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -858,6 +858,7 @@ static const struct flash_info spi_nor_ids[] = {
 	{ "mx25l25635e", INFO(0xc22019, 0, 64 * 1024, 512, 0) },
 	{ "mx25l25655e", INFO(0xc22619, 0, 64 * 1024, 512, 0) },
 	{ "mx66l51235l", INFO(0xc2201a, 0, 64 * 1024, 1024, SPI_NOR_QUAD_READ) },
+	{ "mx66l1g45g",  INFO(0xc2201b, 0, 64 * 1024, 2048, SECT_4K | SPI_NOR_QUAD_READ) },
 	{ "mx66l1g55g",  INFO(0xc2261b, 0, 64 * 1024, 2048, SPI_NOR_QUAD_READ) },
 
 	/* Micron */
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH linux dev4.7 v2 4/9] ARM: dts: aspeed-g5: update for new spi-nor binding
  2016-10-21  5:44 [PATCH linux dev4.7 v2 0/9] aspeed-smc: add support for AST2500 and DMA transfers Cédric Le Goater
                   ` (2 preceding siblings ...)
  2016-10-21  5:44 ` [PATCH linux dev4.7 v2 3/9] mtd: spi-nor: Add Micronix mx66l1g45g spi flash Cédric Le Goater
@ 2016-10-21  5:44 ` Cédric Le Goater
  2016-10-21  5:44 ` [PATCH linux dev4.7 v2 5/9] ARM: dts: aspeed-g5: update witherspoon " Cédric Le Goater
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Cédric Le Goater @ 2016-10-21  5:44 UTC (permalink / raw)
  To: openbmc

From: Milton Miller <miltonm@us.ibm.com>

Signed-off-by: Milton Miller <miltonm@us.ibm.com>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 arch/arm/boot/dts/aspeed-g5.dtsi | 63 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 63 insertions(+)

diff --git a/arch/arm/boot/dts/aspeed-g5.dtsi b/arch/arm/boot/dts/aspeed-g5.dtsi
index 7e18a8e2c083..d96f09a9eb1a 100644
--- a/arch/arm/boot/dts/aspeed-g5.dtsi
+++ b/arch/arm/boot/dts/aspeed-g5.dtsi
@@ -24,6 +24,69 @@
 		#size-cells = <1>;
 		ranges;
 
+		fmc: flash-controller@1e620000 {
+			reg = < 0x1e620000 0xc4
+				0x20000000 0x10000000 >;
+			#address-cells = <1>;
+			#size-cells = <0>;
+			compatible = "aspeed,ast2500-fmc";
+			status = "disabled";
+			flash@0 {
+				reg = < 0 >;
+				compatible = "jedec,spi-nor";
+				status = "disabled";
+			};
+			flash@1 {
+				reg = < 1 >;
+				compatible = "jedec,spi-nor";
+				status = "disabled";
+			};
+			flash@2 {
+				reg = < 2 >;
+				compatible = "jedec,spi-nor";
+				// compatible = "cfi,flash", "jedec,flash";
+				status = "disabled";
+			};
+		};
+
+		spi1: flash-controller@1e630000 {
+			reg = < 0x1e630000 0xc4
+				0x30000000 0x08000000 >;
+			#address-cells = <1>;
+			#size-cells = <0>;
+			compatible = "aspeed,ast2500-smc";
+			status = "disabled";
+			flash@0 {
+				reg = < 0 >;
+				compatible = "jedec,spi-nor";
+				status = "disabled";
+			};
+			flash@1 {
+				reg = < 1 >;
+				compatible = "jedec,spi-nor";
+				status = "disabled";
+			};
+		};
+
+		spi2: flash-controller@1e631000 {
+			reg = < 0x1e631000 0xc4
+				0x38000000 0x08000000 >;
+			#address-cells = <1>;
+			#size-cells = <0>;
+			compatible = "aspeed,ast2500-smc";
+			status = "disabled";
+			flash@0 {
+				reg = < 0 >;
+				compatible = "jedec,spi-nor";
+				status = "disabled";
+			};
+			flash@1 {
+				reg = < 1 >;
+				compatible = "jedec,spi-nor";
+				status = "disabled";
+			};
+		};
+
 		vic: interrupt-controller@1e6c0080 {
 			compatible = "aspeed,ast2400-vic";
 			interrupt-controller;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH linux dev4.7 v2 5/9] ARM: dts: aspeed-g5: update witherspoon for new spi-nor binding
  2016-10-21  5:44 [PATCH linux dev4.7 v2 0/9] aspeed-smc: add support for AST2500 and DMA transfers Cédric Le Goater
                   ` (3 preceding siblings ...)
  2016-10-21  5:44 ` [PATCH linux dev4.7 v2 4/9] ARM: dts: aspeed-g5: update for new spi-nor binding Cédric Le Goater
@ 2016-10-21  5:44 ` Cédric Le Goater
  2016-10-21  5:44 ` [PATCH linux dev4.7 v2 6/9] ARM: dts: aspeed-g5: update ast2500 evb with " Cédric Le Goater
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Cédric Le Goater @ 2016-10-21  5:44 UTC (permalink / raw)
  To: openbmc

From: Milton Miller <miltonm@us.ibm.com>

Witherspoon has two flash modules for the BMC firmware and one for the
host.

Signed-off-by: Milton Miller <miltonm@us.ibm.com>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts | 28 ++++++++++++++----------
 1 file changed, 16 insertions(+), 12 deletions(-)

diff --git a/arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts b/arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts
index fcc880a80ee0..53af584e8f63 100644
--- a/arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts
+++ b/arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts
@@ -19,20 +19,24 @@
 	memory {
 		reg = <0x80000000 0x40000000>;
 	};
+};
 
-	ahb {
-		bmc_pnor: fmc@1e620000 {
-			reg = < 0x1e620000 0x94
-				0x20000000 0x02000000 >;
-			#address-cells = <1>;
-			#size-cells = <0>;
-			compatible = "aspeed,ast2500-fmc";
-			flash@0 {
-				reg = < 0 >;
-				compatible = "jedec,spi-nor" ;
+&fmc {
+	status = "okay";
+	flash@0 {
+		status = "okay";
 #include "aspeed-bmc-opp-flash-layout.dtsi"
-			};
-		};
+	};
+	flash@1 {
+		status = "okay";
+		label = "alt";
+	};
+};
+
+&spi1 {
+	status = "okay";
+	flash@0 {
+		status = "okay";
 	};
 };
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH linux dev4.7 v2 6/9] ARM: dts: aspeed-g5: update ast2500 evb with new spi-nor binding
  2016-10-21  5:44 [PATCH linux dev4.7 v2 0/9] aspeed-smc: add support for AST2500 and DMA transfers Cédric Le Goater
                   ` (4 preceding siblings ...)
  2016-10-21  5:44 ` [PATCH linux dev4.7 v2 5/9] ARM: dts: aspeed-g5: update witherspoon " Cédric Le Goater
@ 2016-10-21  5:44 ` Cédric Le Goater
  2016-10-21  5:44 ` [PATCH linux dev4.7 v2 7/9] mtd: spi-nor: aspeed: add DMA support to smc controller Cédric Le Goater
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Cédric Le Goater @ 2016-10-21  5:44 UTC (permalink / raw)
  To: openbmc

The ast2500 evb has one flash module for the BMC firmware and one for
the host.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 arch/arm/boot/dts/aspeed-ast2500-evb.dts | 28 ++++++++++++++++------------
 1 file changed, 16 insertions(+), 12 deletions(-)

diff --git a/arch/arm/boot/dts/aspeed-ast2500-evb.dts b/arch/arm/boot/dts/aspeed-ast2500-evb.dts
index d34e6f15a0cb..33b3907c436b 100644
--- a/arch/arm/boot/dts/aspeed-ast2500-evb.dts
+++ b/arch/arm/boot/dts/aspeed-ast2500-evb.dts
@@ -18,23 +18,27 @@
 	memory {
 		reg = <0x80000000 0x20000000>;
 	};
+};
 
-	ahb {
-		bmc_pnor: fmc@1e620000 {
-			reg = < 0x1e620000 0x94
-				0x20000000 0x02000000 >;
-			#address-cells = <1>;
-			#size-cells = <0>;
-			compatible = "aspeed,ast2500-fmc";
-			flash@0 {
-				reg = < 0 >;
-				compatible = "jedec,spi-nor" ;
+&fmc {
+	status = "okay";
+	flash@0 {
+		status = "okay";
 #include "aspeed-bmc-opp-flash-layout.dtsi"
-			};
-		};
 	};
 };
 
+&spi1 {
+	status = "okay";
+	flash@0 {
+		status = "okay";
+	};
+};
+
+&spi2 {
+	status = "okay";
+};
+
 &uart5 {
 	status = "okay";
 };
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH linux dev4.7 v2 7/9] mtd: spi-nor: aspeed: add DMA support to smc controller
  2016-10-21  5:44 [PATCH linux dev4.7 v2 0/9] aspeed-smc: add support for AST2500 and DMA transfers Cédric Le Goater
                   ` (5 preceding siblings ...)
  2016-10-21  5:44 ` [PATCH linux dev4.7 v2 6/9] ARM: dts: aspeed-g5: update ast2500 evb with " Cédric Le Goater
@ 2016-10-21  5:44 ` Cédric Le Goater
  2016-10-21  5:44 ` [PATCH linux dev4.7 v2 8/9] ARM: dts: aspeed: update SMC controller nodes supporting DMAs Cédric Le Goater
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Cédric Le Goater @ 2016-10-21  5:44 UTC (permalink / raw)
  To: openbmc

The Aspeed FMC controller can handle transfers to the flash modules
using DMAs. A couple of registers first need to be programmed with the
DRAM and flash addresses and the length of the transfer. The transfer
is then initiated using a DMA control register and an interrupt
notifies the completion.

Such transfers can replace the current IO mode in the read/write ops
when some conditions are met on the size and the alignment. In case of
failure, a timeout for instance, the operation is restarted using the
IO mode.

DMA support does not seem to be that efficient. So we provide some
sysfs files for tuning and to switch it on and off (default is off)

Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 drivers/mtd/spi-nor/aspeed-smc.c | 241 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 241 insertions(+)

diff --git a/drivers/mtd/spi-nor/aspeed-smc.c b/drivers/mtd/spi-nor/aspeed-smc.c
index aed610d8ab2f..f220df775f2b 100644
--- a/drivers/mtd/spi-nor/aspeed-smc.c
+++ b/drivers/mtd/spi-nor/aspeed-smc.c
@@ -20,10 +20,25 @@
 #include <linux/of.h>
 #include <linux/of_platform.h>
 #include <linux/sysfs.h>
+#include <linux/dma-direction.h>
+#include <linux/dma-mapping.h>
 
 #define DEVICE_NAME	"aspeed-smc"
 
 /*
+ * DMAs do not seem to be that fast, so disable by default
+ */
+static bool use_dma;
+module_param(use_dma, bool, 0644);
+
+static unsigned int min_dma_size = 256;
+module_param(min_dma_size, uint, 0644);
+
+/* with 100ms we had a couple of timeouts */
+static unsigned int dma_timeout = 200;
+module_param(dma_timeout, uint, 0644);
+
+/*
  * In user mode all data bytes read or written to the chip decode address
  * range are transferred to or from the SPI bus. The range is treated as a
  * fifo of arbitratry 1, 2, or 4 byte width but each write has to be aligned
@@ -206,6 +221,7 @@ struct aspeed_smc_chip {
 	__le32 __iomem *ctl;			/* control register */
 	void __iomem *base;			/* base of chip window */
 	__le32 ctl_val[smc_num_ctl_reg_values];	/* controls with timing */
+	unsigned long phys_base;
 	enum smc_flash_type type;		/* what type of flash */
 	struct spi_nor nor;
 };
@@ -218,6 +234,18 @@ struct aspeed_smc_controller {
 	void __iomem *regs;			/* controller registers */
 	void __iomem *windows;			/* per-chip windows resource */
 
+	/* interrupt handling */
+	int irq;
+
+	/* dma */
+	bool has_dma;
+	struct completion dma_done;
+
+	/* dma logging */
+	size_t dma_length;
+	dma_addr_t dma_addr;			/* bus address of buffer */
+	dma_addr_t flash_addr;			/* flash address */
+
 	struct aspeed_smc_chip *chips[0];	/* pointers to attached chips */
 };
 
@@ -274,11 +302,123 @@ struct aspeed_smc_controller {
 	CONTROL_SPI_IO_DUMMY_CYCLES_MASK | CONTROL_SPI_CLOCK_FREQ_SEL_MASK | \
 	CONTROL_SPI_LSB_FIRST | CONTROL_SPI_CLOCK_MODE_3)
 
+/* Interrupt Control and Status Register */
+#define INTERRUPT_STATUS_REG		0x08
+#define     INTERRUPT_DMA_ENABLE	    BIT(3)
+#define     INTERRUPT_DMA_STATUS	    BIT(11)
+
 /* Segment Address Registers */
 #define SEGMENT_ADDR_REG0		0x30
 #define     SEGMENT_ADDR_START(_r)	    ((((_r) >> 16) & 0xFF) << 23)
 #define     SEGMENT_ADDR_END(_r)	    ((((_r) >> 24) & 0xFF) << 23)
 
+
+/* DMA Registers */
+#define DMA_CONTROL_REG			0x80
+#define     DMA_ENABLE			    BIT(0)
+#define     DMA_WRITE			    BIT(1)
+
+#define DMA_FLASH_BASE_REG		0x84
+#define DMA_DRAM_BASE_REG		0x88
+#define DMA_LENGTH_REG			0x8c
+
+static void aspeed_smc_dma_done(struct aspeed_smc_controller *controller)
+{
+	writel(0, controller->regs + INTERRUPT_STATUS_REG);
+	writel(0, controller->regs + DMA_CONTROL_REG);
+}
+
+static int aspeed_smc_dma_wait(struct aspeed_smc_chip *chip)
+{
+	struct aspeed_smc_controller *controller = chip->controller;
+
+	if (!wait_for_completion_timeout(&controller->dma_done,
+					 msecs_to_jiffies(dma_timeout))) {
+		dev_err(chip->nor.dev, "timeout waiting for DMA interrupt "
+			"addr@%.8x faddr@%.8x size=%x "
+			"dram@%.8x flash@%.8x done=%x\n",
+			controller->dma_addr,
+			controller->flash_addr,
+			controller->dma_length,
+			readl(controller->regs + DMA_DRAM_BASE_REG),
+			readl(controller->regs + DMA_FLASH_BASE_REG),
+			readl(controller->regs + DMA_LENGTH_REG));
+		return -ETIMEDOUT;
+	}
+
+	return 0;
+}
+
+#define DMA_LENGTH(x) (((x) - 4) & ~0xFE000003)
+#define DMA_ADDR(x) ((x) & ~0xE0000003)
+
+static inline void aspeed_smc_chip_configure(struct aspeed_smc_chip *chip,
+					     u32 ctl)
+{
+	ctl |= CONTROL_SPI_CE_STOP_ACTIVE_CONTROL;
+	writel(ctl, chip->ctl);
+
+	ctl &= ~CONTROL_SPI_CE_STOP_ACTIVE_CONTROL;
+	writel(ctl, chip->ctl);
+}
+
+/*
+ * TODO: configure FREAD mode
+ */
+static int aspeed_smc_dma_start(struct aspeed_smc_chip *chip,
+				u32 offset, void *buf, size_t length,
+				int is_write)
+{
+	struct aspeed_smc_controller *controller = chip->controller;
+	dma_addr_t dma_addr, flash_addr;
+	int ret;
+
+	aspeed_smc_chip_configure(chip, is_write ? chip->ctl_val[smc_write] :
+		chip->ctl_val[smc_base]);
+
+	dev_dbg(chip->nor.dev, "DMA %s to=0x%08x len=0x%08x\n",
+		is_write ? "write" : "read", offset, length);
+
+	dma_addr = dma_map_single(chip->nor.dev, buf, length,
+				  (is_write ? DMA_TO_DEVICE : DMA_FROM_DEVICE));
+
+	if (unlikely(dma_mapping_error(chip->nor.dev, dma_addr))) {
+		dev_err(chip->nor.dev, "Failed to dma_map_single()\n");
+		ret = -ENOMEM;
+		goto out;
+	}
+	flash_addr = chip->phys_base + offset;
+
+	controller->dma_length = length;
+	controller->dma_addr = dma_addr;
+	controller->flash_addr = flash_addr;
+
+	reinit_completion(&controller->dma_done);
+
+	writel(0, controller->regs + DMA_CONTROL_REG);
+	writel(DMA_ADDR(flash_addr), controller->regs +
+	       DMA_FLASH_BASE_REG);
+	writel(DMA_ADDR(dma_addr), controller->regs + DMA_DRAM_BASE_REG);
+	writel(DMA_LENGTH(length), controller->regs + DMA_LENGTH_REG);
+
+	writel(INTERRUPT_DMA_ENABLE,
+	       controller->regs + INTERRUPT_STATUS_REG);
+
+	writel(DMA_ENABLE | (is_write << 1),
+	       controller->regs + DMA_CONTROL_REG);
+
+	ret = aspeed_smc_dma_wait(chip);
+	if (ret)
+		aspeed_smc_dma_done(controller);
+
+	dma_unmap_single(chip->nor.dev,
+			 controller->dma_addr, controller->dma_length,
+			 (is_write ? DMA_TO_DEVICE : DMA_FROM_DEVICE));
+out:
+	aspeed_smc_chip_configure(chip, chip->ctl_val[smc_base]);
+	return ret;
+}
+
 static u32 spi_control_fill_opcode(u8 opcode)
 {
 	return ((u32)(opcode)) << CONTROL_SPI_COMMAND_SHIFT;
@@ -400,14 +540,28 @@ static int aspeed_smc_read_user(struct spi_nor *nor, loff_t from, size_t len,
 				size_t *retlen, u_char *read_buf)
 {
 	struct aspeed_smc_chip *chip = nor->priv;
+	int ret;
 
 	mutex_lock(&chip->controller->mutex);
 
+	/*
+	 * Try DMA transfer when size and alignment are correct. In case
+	 * of failure, just restart using the IO mode.
+	 */
+	if (!(from & 0x3) && !(len & 0x3) && (len >= min_dma_size) &&
+	    chip->controller->has_dma && use_dma) {
+		ret = aspeed_smc_dma_start(chip, from, read_buf, len, 0);
+		if (!ret)
+			goto out;
+		dev_err(chip->nor.dev, "DMA read failed: %d", ret);
+	}
+
 	aspeed_smc_start_user(nor);
 	aspeed_smc_send_cmd_addr(nor, nor->read_opcode, from);
 	aspeed_smc_from_fifo(read_buf, chip->base, len);
 	aspeed_smc_stop_user(nor);
 
+out:
 	mutex_unlock(&chip->controller->mutex);
 
 	*retlen += len;
@@ -418,19 +572,102 @@ static void aspeed_smc_write_user(struct spi_nor *nor, loff_t to, size_t len,
 				  size_t *retlen, const u_char *write_buf)
 {
 	struct aspeed_smc_chip *chip = nor->priv;
+	int ret;
 
 	mutex_lock(&chip->controller->mutex);
 
+	/*
+	 * Try DMA transfer when size and alignment are correct. In case
+	 * of failure, just restart using the IO mode.
+	 */
+	if (!(to & 0x3) && !(len & 0x3) && (len >= min_dma_size) &&
+	    chip->controller->has_dma && use_dma) {
+		ret = aspeed_smc_dma_start(chip, to, (void *)write_buf,
+					   len, 1);
+		if (!ret)
+			goto out;
+		dev_err(chip->nor.dev, "DMA write failed: %d", ret);
+	}
+
 	aspeed_smc_start_user(nor);
 	aspeed_smc_send_cmd_addr(nor, nor->program_opcode, to);
 	aspeed_smc_to_fifo(chip->base, write_buf, len);
 	aspeed_smc_stop_user(nor);
 
+out:
 	mutex_unlock(&chip->controller->mutex);
 
 	*retlen += len;
 }
 
+static irqreturn_t aspeed_smc_irq(int irq, void *arg)
+{
+	struct aspeed_smc_controller *controller = arg;
+	struct device *dev = controller->dev;
+	irqreturn_t ret = IRQ_NONE;
+	u32 dma_ctl = readl(controller->regs + DMA_CONTROL_REG);
+	u32 status = readl(controller->regs + INTERRUPT_STATUS_REG);
+
+	dev_dbg(dev, "received IRQ. status: %x", status);
+
+	if (!(status & INTERRUPT_DMA_ENABLE) || !(dma_ctl & DMA_ENABLE)) {
+		dev_err(dev, "No DMA. bad IRQ status: %x", status);
+		goto out;
+	}
+
+	if (!(status & INTERRUPT_DMA_STATUS)) {
+		dev_err(dev, "DMA still in progress. length %d\n",
+			readl(controller->regs + DMA_LENGTH_REG));
+		goto out;
+	}
+
+	ret = IRQ_HANDLED;
+	aspeed_smc_dma_done(controller);
+	complete(&controller->dma_done);
+
+out:
+	return ret;
+}
+
+static int aspeed_smc_config_irq(struct aspeed_smc_controller *controller,
+				 struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	int rc;
+
+	controller->irq = platform_get_irq(pdev, 0);
+	if (!controller->irq)
+		return -ENODEV;
+
+	rc = devm_request_irq(dev, controller->irq, aspeed_smc_irq, IRQF_SHARED,
+			      DEVICE_NAME, controller);
+	if (rc < 0) {
+		dev_warn(dev, "Unable to request IRQ %d\n", controller->irq);
+		controller->irq = 0;
+		return rc;
+	}
+
+	dev_info(dev, "Using IRQ %d\n", controller->irq);
+	return 0;
+}
+
+static void aspeed_smc_dma_setup(struct aspeed_smc_controller *controller,
+				 struct platform_device *pdev)
+{
+	init_completion(&controller->dma_done);
+
+	controller->has_dma = false;
+	if (of_get_property(controller->dev->of_node, "aspeed,fmc-has-dma",
+			    NULL))
+		controller->has_dma = !aspeed_smc_config_irq(controller, pdev);
+
+	if (controller->has_dma)
+		dev_info(controller->dev, "DMA support %sactivated.\n",
+			 use_dma ? "" : "de");
+	else
+		dev_info(controller->dev, "no DMA support.\n");
+}
+
 static int aspeed_smc_remove(struct platform_device *dev)
 {
 	struct aspeed_smc_chip *chip;
@@ -540,6 +777,8 @@ static int aspeed_smc_chip_setup_init(struct aspeed_smc_chip *chip,
 		return -1;
 	}
 
+	chip->phys_base = r->start;
+
 	/*
 	 * Read the existing control register to get basic values.
 	 *
@@ -647,6 +886,8 @@ static int aspeed_smc_probe(struct platform_device *pdev)
 
 	controller->dev = &pdev->dev;
 
+	aspeed_smc_dma_setup(controller, pdev);
+
 	/* The pinmux or bootloader will disable the legacy mode controller */
 
 	/*
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH linux dev4.7 v2 8/9] ARM: dts: aspeed: update SMC controller nodes supporting DMAs
  2016-10-21  5:44 [PATCH linux dev4.7 v2 0/9] aspeed-smc: add support for AST2500 and DMA transfers Cédric Le Goater
                   ` (6 preceding siblings ...)
  2016-10-21  5:44 ` [PATCH linux dev4.7 v2 7/9] mtd: spi-nor: aspeed: add DMA support to smc controller Cédric Le Goater
@ 2016-10-21  5:44 ` Cédric Le Goater
  2016-10-21  5:44 ` [PATCH linux dev4.7 v2 9/9] ARM: dts: witherspoon: use spi1debug pinctrl group Cédric Le Goater
  2016-10-21  6:35 ` [PATCH linux dev4.7 v2 0/9] aspeed-smc: add support for AST2500 and DMA transfers Joel Stanley
  9 siblings, 0 replies; 11+ messages in thread
From: Cédric Le Goater @ 2016-10-21  5:44 UTC (permalink / raw)
  To: openbmc

Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 arch/arm/boot/dts/aspeed-bmc-opp-palmetto.dts | 2 ++
 arch/arm/boot/dts/aspeed-g5.dtsi              | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/arch/arm/boot/dts/aspeed-bmc-opp-palmetto.dts b/arch/arm/boot/dts/aspeed-bmc-opp-palmetto.dts
index 5c689613e5bd..a6ebab1bfe2b 100644
--- a/arch/arm/boot/dts/aspeed-bmc-opp-palmetto.dts
+++ b/arch/arm/boot/dts/aspeed-bmc-opp-palmetto.dts
@@ -43,6 +43,8 @@
 			#address-cells = <1>;
 			#size-cells = <0>;
 			compatible = "aspeed,ast2400-fmc";
+			aspeed,fmc-has-dma;
+			interrupts = <19>;
 			flash@0 {
 				reg = < 0 >;
 				compatible = "jedec,spi-nor" ;
diff --git a/arch/arm/boot/dts/aspeed-g5.dtsi b/arch/arm/boot/dts/aspeed-g5.dtsi
index d96f09a9eb1a..d72aea7ab8f2 100644
--- a/arch/arm/boot/dts/aspeed-g5.dtsi
+++ b/arch/arm/boot/dts/aspeed-g5.dtsi
@@ -31,6 +31,8 @@
 			#size-cells = <0>;
 			compatible = "aspeed,ast2500-fmc";
 			status = "disabled";
+			aspeed,fmc-has-dma;
+			interrupts = <19>;
 			flash@0 {
 				reg = < 0 >;
 				compatible = "jedec,spi-nor";
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH linux dev4.7 v2 9/9] ARM: dts: witherspoon: use spi1debug pinctrl group
  2016-10-21  5:44 [PATCH linux dev4.7 v2 0/9] aspeed-smc: add support for AST2500 and DMA transfers Cédric Le Goater
                   ` (7 preceding siblings ...)
  2016-10-21  5:44 ` [PATCH linux dev4.7 v2 8/9] ARM: dts: aspeed: update SMC controller nodes supporting DMAs Cédric Le Goater
@ 2016-10-21  5:44 ` Cédric Le Goater
  2016-10-21  6:35 ` [PATCH linux dev4.7 v2 0/9] aspeed-smc: add support for AST2500 and DMA transfers Joel Stanley
  9 siblings, 0 replies; 11+ messages in thread
From: Cédric Le Goater @ 2016-10-21  5:44 UTC (permalink / raw)
  To: openbmc

pinctrl is very strict and the device tree should match exactly how
the HW is strapped.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts b/arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts
index 53af584e8f63..db3afafbfe9e 100644
--- a/arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts
+++ b/arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts
@@ -35,6 +35,9 @@
 
 &spi1 {
 	status = "okay";
+	pinctrl-names = "default";
+	pinctrl-0 = <&pinctrl_spi1debug_default>;
+
 	flash@0 {
 		status = "okay";
 	};
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH linux dev4.7 v2 0/9] aspeed-smc: add support for AST2500 and DMA transfers
  2016-10-21  5:44 [PATCH linux dev4.7 v2 0/9] aspeed-smc: add support for AST2500 and DMA transfers Cédric Le Goater
                   ` (8 preceding siblings ...)
  2016-10-21  5:44 ` [PATCH linux dev4.7 v2 9/9] ARM: dts: witherspoon: use spi1debug pinctrl group Cédric Le Goater
@ 2016-10-21  6:35 ` Joel Stanley
  9 siblings, 0 replies; 11+ messages in thread
From: Joel Stanley @ 2016-10-21  6:35 UTC (permalink / raw)
  To: Cédric Le Goater; +Cc: OpenBMC Maillist

On Fri, Oct 21, 2016 at 4:14 PM, Cédric Le Goater <clg@kaod.org> wrote:
> Hello,
>
> This patchset adds to the current aspeed SMC driver the register
> settings enabling support for the AST2500. Some initial work is done
> on the segment registers to provide a better configuration of the
> mapping windows on the flash modules but this area clearly needs more
> work to be solid.
>
> Also, a first version of DMA read/write is provided. But the speed
> results are not very satisfying so they are disabled by default. You
>
> Thanks,
>
> C.
>
> Changes since v1:
>
>  - included a first revert of the current driver
>  - merged all the difference in one patch to be sent to mainline
>  - added a pinctrl fix for the witherspoon.

Series applied to dev-4.7 as of d676d5ee0e1b3b5e774c2d61d2c9a760f5df78b0.

Cheers,

Joel

>
> Cédric Le Goater (6):
>   Revert "mtd/spi-nor: Add SPI memory controllers for Aspeed SoCs"
>   mtd/spi-nor: Add SPI memory controllers for Aspeed SoCs
>   ARM: dts: aspeed-g5: update ast2500 evb with new spi-nor binding
>   mtd: spi-nor: aspeed: add DMA support to smc controller
>   ARM: dts: aspeed: update SMC controller nodes supporting DMAs
>   ARM: dts: witherspoon: use spi1debug pinctrl group
>
> Milton Miller (3):
>   mtd: spi-nor: Add Micronix mx66l1g45g spi flash
>   ARM: dts: aspeed-g5: update for new spi-nor binding
>   ARM: dts: aspeed-g5: update witherspoon for new spi-nor binding
>
>  .../devicetree/bindings/mtd/aspeed-smc.txt         |  37 +-
>  arch/arm/boot/dts/aspeed-ast2500-evb.dts           |  28 +-
>  arch/arm/boot/dts/aspeed-bmc-opp-palmetto.dts      |   2 +
>  arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts   |  31 +-
>  arch/arm/boot/dts/aspeed-g5.dtsi                   |  65 ++
>  drivers/mtd/spi-nor/aspeed-smc.c                   | 655 +++++++++++++++++----
>  drivers/mtd/spi-nor/spi-nor.c                      |   1 +
>  7 files changed, 665 insertions(+), 154 deletions(-)
>
> --
> 2.7.4
>

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2016-10-21  6:35 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-21  5:44 [PATCH linux dev4.7 v2 0/9] aspeed-smc: add support for AST2500 and DMA transfers Cédric Le Goater
2016-10-21  5:44 ` [PATCH linux dev4.7 v2 1/9] Revert "mtd/spi-nor: Add SPI memory controllers for Aspeed SoCs" Cédric Le Goater
2016-10-21  5:44 ` [PATCH linux dev4.7 v2 2/9] mtd/spi-nor: Add SPI memory controllers for Aspeed SoCs Cédric Le Goater
2016-10-21  5:44 ` [PATCH linux dev4.7 v2 3/9] mtd: spi-nor: Add Micronix mx66l1g45g spi flash Cédric Le Goater
2016-10-21  5:44 ` [PATCH linux dev4.7 v2 4/9] ARM: dts: aspeed-g5: update for new spi-nor binding Cédric Le Goater
2016-10-21  5:44 ` [PATCH linux dev4.7 v2 5/9] ARM: dts: aspeed-g5: update witherspoon " Cédric Le Goater
2016-10-21  5:44 ` [PATCH linux dev4.7 v2 6/9] ARM: dts: aspeed-g5: update ast2500 evb with " Cédric Le Goater
2016-10-21  5:44 ` [PATCH linux dev4.7 v2 7/9] mtd: spi-nor: aspeed: add DMA support to smc controller Cédric Le Goater
2016-10-21  5:44 ` [PATCH linux dev4.7 v2 8/9] ARM: dts: aspeed: update SMC controller nodes supporting DMAs Cédric Le Goater
2016-10-21  5:44 ` [PATCH linux dev4.7 v2 9/9] ARM: dts: witherspoon: use spi1debug pinctrl group Cédric Le Goater
2016-10-21  6:35 ` [PATCH linux dev4.7 v2 0/9] aspeed-smc: add support for AST2500 and DMA transfers Joel Stanley

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.