Skip to contentSkip to conversation

Static memory controllers for the Aspeed SoC

PATCH Superseded Cédric Le Goater 4 participants 23 messages Dec 9, 2016 – Dec 12, 2016 13 messages not in the archive

Subsystems (4)

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v3 cover Static memory controllers for the Aspeed SoC

Hello,

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

The driver only support SPI type flash.

Tested on:

* OpenPOWER Palmetto (AST2400) with
FMC controller : n25q256a

	SPI controller : mx25l25635e and n25q512ax3

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

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

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

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

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

Thanks,

C.

Cédric Le Goater (5):
mtd: spi-nor: add memory controllers for the Aspeed AST2500 SoC
mtd: aspeed: add memory controllers for the Aspeed AST2400 SoC
mtd: aspeed: used a label property
mtd: spi-nor: bindings for the Aspeed memory controllers
mtd: spi-nor: add a label property to jedec,spi-nor

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


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

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

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

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

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

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

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

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

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

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

735 lines not on this page · raw message

Signature · 6 lines
2.7.4


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

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

#3 lore raw

Re: [PATCH v3 1/5] mtd: spi-nor: add memory controllers for the Aspeed AST2500 SoC

On 12/09/2016 05:49 PM, Cédric Le Goater wrote:

[...]

drivers/mtd/spi-nor/aspeed-smc.c line 58

Quoted 6 lines
drivers/mtd/spi-nor/aspeed-smc.c new file +6 -0
+static int aspeed_smc_read_from_ahb(void *buf, const void __iomem *src,
+				    size_t len)
+{
+	if (IS_ALIGNED((u32)src, sizeof(u32)) &&
+	    IS_ALIGNED((u32)buf, sizeof(u32)) &&
+	    IS_ALIGNED(len, sizeof(u32))) {

Did you try compiling this on any 64bit system ?

drivers/mtd/spi-nor/aspeed-smc.c line 60

Quoted 2 lines
drivers/mtd/spi-nor/aspeed-smc.c new file +2 -0
+		while (len > 3) {
+			*(u32 *)buf = readl(src);

ioread32_rep() to avoid open-coding the loop .

Quoted 14 lines
drivers/mtd/spi-nor/aspeed-smc.c new file +14 -0
+			buf += 4;
+			src += 4;
+			len -= 4;
+		}
+	}
+
+	while (len--) {
+		*(u8 *)buf = readb(src);
+		buf += 1;
+		src += 1;
+	}
+	return 0;
+}
+

drivers/mtd/spi-nor/aspeed-smc.c line 84

Quoted 10 lines
drivers/mtd/spi-nor/aspeed-smc.c new file +10 -0
+static int aspeed_smc_write_to_ahb(void __iomem *dst, const void *buf,
+				   size_t len)
+{
+	if (IS_ALIGNED((u32)dst, sizeof(u32)) &&
+	    IS_ALIGNED((u32)buf, sizeof(u32)) &&
+	    IS_ALIGNED(len, sizeof(u32))) {
+		while (len > 3) {
+			u32 val = *(u32 *)buf;
+
+			writel(val, dst);

iowrite32_rep()

Quoted 26 lines
drivers/mtd/spi-nor/aspeed-smc.c new file +26 -0
+			buf += 4;
+			dst += 4;
+			len -= 4;
+		}
+	}
+
+	while (len--) {
+		u8 val = *(u8 *)buf;
+
+		writeb(val, dst);
+		buf += 1;
+		dst += 1;
+	}
+	return 0;
+}
+
+/*
+ * The driver only support SPI flash
+ */
+enum aspeed_smc_flash_type {
+	smc_type_nor  = 0,
+	smc_type_nand = 1,
+	smc_type_spi  = 2,
+};
+
+struct aspeed_smc_chip;

drivers/mtd/spi-nor/aspeed-smc.c line 120

Quoted 10 lines
drivers/mtd/spi-nor/aspeed-smc.c new file +10 -0
+
+struct aspeed_smc_info {
+	u32 maxsize;		/* maximum size of chip window */
+	u8 nce;			/* number of chip enables */
+	bool hastype;		/* flash type field exists in config reg */
+	u8 we0;			/* shift for write enable bit for CE0 */
+	u8 ctl0;		/* offset in regs of ctl for CE0 */
+
+	void (*set_4b)(struct aspeed_smc_chip *chip);
+};

Move all the structs to the beginning of the driver please.

Quoted 26 lines
drivers/mtd/spi-nor/aspeed-smc.c new file +26 -0
+static void aspeed_smc_chip_set_4b(struct aspeed_smc_chip *chip);
+
+static const struct aspeed_smc_info fmc_2500_info = {
+	.maxsize = 256 * 1024 * 1024,
+	.nce = 3,
+	.hastype = true,
+	.we0 = 16,
+	.ctl0 = 0x10,
+	.set_4b = aspeed_smc_chip_set_4b,
+};
+
+static const struct aspeed_smc_info spi_2500_info = {
+	.maxsize = 128 * 1024 * 1024,
+	.nce = 2,
+	.hastype = false,
+	.we0 = 16,
+	.ctl0 = 0x10,
+	.set_4b = aspeed_smc_chip_set_4b,
+};
+
+enum aspeed_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 */
+	smc_max,
+};

[...]

drivers/mtd/spi-nor/aspeed-smc.c line 234

Quoted 6 lines
drivers/mtd/spi-nor/aspeed-smc.c new file +6 -0
+#define CONTROL_CE_STOP_ACTIVE_CONTROL	BIT(2)
+#define CONTROL_COMMAND_MODE_MASK	GENMASK(1, 0)
+#define CONTROL_COMMAND_MODE_NORMAL	(0)
+#define CONTROL_COMMAND_MODE_FREAD	(1)
+#define CONTROL_COMMAND_MODE_WRITE	(2)
+#define CONTROL_COMMAND_MODE_USER	(3)

Drop the parenthesis around constants :)

drivers/mtd/spi-nor/aspeed-smc.c line 246

Quoted 11 lines
drivers/mtd/spi-nor/aspeed-smc.c new file +11 -0
+#define CONTROL_KEEP_MASK						\
+	(CONTROL_AAF_MODE | CONTROL_CE_INACTIVE_MASK | CONTROL_CLK_DIV4 | \
+	 CONTROL_IO_DUMMY_MASK | CONTROL_CLOCK_FREQ_SEL_MASK |		\
+	 CONTROL_LSB_FIRST | CONTROL_CLOCK_MODE_3)
+
+/*
+ * Segment Address Registers. Start and end addresses are encoded
+ * using 8MB units
+ */
+#define SEGMENT_ADDR_REG0		0x30
+#define SEGMENT_ADDR_START(_r)		((((_r) >> 16) & 0xFF) << 23)

is that ((r) & 0xff0000) << 7 ?

Quoted 1 line

+#define SEGMENT_ADDR_END(_r) ((((_r) >> 24) & 0xFF) << 23)

((r) & 0xff000000) >> 1 ?

Quoted 4 lines
drivers/mtd/spi-nor/aspeed-smc.c new file +4 -0
+static inline u32 aspeed_smc_chip_write_bit(struct aspeed_smc_chip *chip)
+{
+	return BIT(chip->controller->info->we0 + chip->cs);
+}

[...]

Quoted 14 lines
drivers/mtd/spi-nor/aspeed-smc.c new file +14 -0
+static int aspeed_smc_chip_setup_init(struct aspeed_smc_chip *chip,
+				      struct resource *res)
+{
+	struct aspeed_smc_controller *controller = chip->controller;
+	const struct aspeed_smc_info *info = controller->info;
+	u32 reg, base_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 */

drivers/mtd/spi-nor/aspeed-smc.c line 505

Quoted 10 lines
drivers/mtd/spi-nor/aspeed-smc.c new file +10 -0
+	if (info->hastype)
+		aspeed_smc_chip_set_type(chip, smc_type_spi);
+
+	/*
+	 * Configure chip base address in memory
+	 */
+	chip->ahb_base = aspeed_smc_chip_base(chip, res);
+	if (!chip->ahb_base) {
+		dev_warn(chip->nor.dev, "CE segment window closed.\n");
+		return -1;

return -EINVAL ? Check whether you always use errno.h macros in returns.

Quoted 8 lines
drivers/mtd/spi-nor/aspeed-smc.c new file +8 -0
+	}
+
+	/*
+	 * Get value of the inherited control register. U-Boot usually
+	 * does some timing calibration on the FMC chip, so it's good
+	 * to keep them. In the future, we should handle calibration
+	 * from Linux.
+	 */

drivers/mtd/spi-nor/aspeed-smc.c line 523

Quoted 10 lines
drivers/mtd/spi-nor/aspeed-smc.c new file +10 -0
+	reg = readl(chip->ctl);
+	dev_dbg(controller->dev, "control register: %08x\n", reg);
+
+	base_reg = reg & CONTROL_KEEP_MASK;
+	if (base_reg != reg) {
+		dev_info(controller->dev,
+			 "control register changed to: %08x\n",
+			 base_reg);
+	}
+	chip->ctl_val[smc_base] = base_reg;

[...]

Mostly minor nits, looks nice otherwise, thanks :)

Signature · 6 lines
Best regards,
Marek Vasut
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 68aa03be-8195-1824-a9e1-609a5ad74381-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#5 lore raw

Re: [PATCH v3 1/5] mtd: spi-nor: add memory controllers for the Aspeed AST2500 SoC

Hello,

Quoted 5 lines · Marek Vasut

On 12/09/2016 05:49 PM, Cédric Le Goater wrote:

[...]

Quoted 8 lines

drivers/mtd/spi-nor/aspeed-smc.c line 58

Quoted 6 lines
drivers/mtd/spi-nor/aspeed-smc.c new file +6 -0
+static int aspeed_smc_read_from_ahb(void *buf, const void __iomem *src,
+				    size_t len)
+{
+	if (IS_ALIGNED((u32)src, sizeof(u32)) &&
+	    IS_ALIGNED((u32)buf, sizeof(u32)) &&
+	    IS_ALIGNED(len, sizeof(u32))) {

Did you try compiling this on any 64bit system ?

I cross compile the kernel on a 64bit host and then upload on the target. What kind of problem are you forseeing ?

Quoted 5 lines

drivers/mtd/spi-nor/aspeed-smc.c line 60

Quoted 3 lines
drivers/mtd/spi-nor/aspeed-smc.c new file +2 -0
+		while (len > 3) {
+			*(u32 *)buf = readl(src);

ioread32_rep() to avoid open-coding the loop .

ok.

Quoted 57 lines
Quoted 14 lines
drivers/mtd/spi-nor/aspeed-smc.c new file +14 -0
+			buf += 4;
+			src += 4;
+			len -= 4;
+		}
+	}
+
+	while (len--) {
+		*(u8 *)buf = readb(src);
+		buf += 1;
+		src += 1;
+	}
+	return 0;
+}
+

drivers/mtd/spi-nor/aspeed-smc.c line 84

Quoted 10 lines
drivers/mtd/spi-nor/aspeed-smc.c new file +10 -0
+static int aspeed_smc_write_to_ahb(void __iomem *dst, const void *buf,
+				   size_t len)
+{
+	if (IS_ALIGNED((u32)dst, sizeof(u32)) &&
+	    IS_ALIGNED((u32)buf, sizeof(u32)) &&
+	    IS_ALIGNED(len, sizeof(u32))) {
+		while (len > 3) {
+			u32 val = *(u32 *)buf;
+
+			writel(val, dst);

iowrite32_rep()

Quoted 30 lines
drivers/mtd/spi-nor/aspeed-smc.c new file +30 -0
+			buf += 4;
+			dst += 4;
+			len -= 4;
+		}
+	}
+
+	while (len--) {
+		u8 val = *(u8 *)buf;
+
+		writeb(val, dst);
+		buf += 1;
+		dst += 1;
+	}
+	return 0;
+}
+
+/*
+ * The driver only support SPI flash
+ */
+enum aspeed_smc_flash_type {
+	smc_type_nor  = 0,
+	smc_type_nand = 1,
+	smc_type_spi  = 2,
+};
+
+struct aspeed_smc_chip;
+
+struct aspeed_smc_info {
+	u32 maxsize;		/* maximum size of chip window */
+	u8 nce;			/* number of chip enables */
Quoted 8 lines

drivers/mtd/spi-nor/aspeed-smc.c line 120

Quoted 6 lines
drivers/mtd/spi-nor/aspeed-smc.c new file +6 -0
+	bool hastype;		/* flash type field exists in config reg */
+	u8 we0;			/* shift for write enable bit for CE0 */
+	u8 ctl0;		/* offset in regs of ctl for CE0 */
+
+	void (*set_4b)(struct aspeed_smc_chip *chip);
+};

Move all the structs to the beginning of the driver please.

ok.

Quoted 30 lines
Quoted 27 lines
drivers/mtd/spi-nor/aspeed-smc.c new file +26 -0
+static void aspeed_smc_chip_set_4b(struct aspeed_smc_chip *chip);
+
+static const struct aspeed_smc_info fmc_2500_info = {
+	.maxsize = 256 * 1024 * 1024,
+	.nce = 3,
+	.hastype = true,
+	.we0 = 16,
+	.ctl0 = 0x10,
+	.set_4b = aspeed_smc_chip_set_4b,
+};
+
+static const struct aspeed_smc_info spi_2500_info = {
+	.maxsize = 128 * 1024 * 1024,
+	.nce = 2,
+	.hastype = false,
+	.we0 = 16,
+	.ctl0 = 0x10,
+	.set_4b = aspeed_smc_chip_set_4b,
+};
+
+enum aspeed_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 */
+	smc_max,
+};

[...]

Quoted 8 lines

drivers/mtd/spi-nor/aspeed-smc.c line 234

Quoted 6 lines
drivers/mtd/spi-nor/aspeed-smc.c new file +6 -0
+#define CONTROL_CE_STOP_ACTIVE_CONTROL	BIT(2)
+#define CONTROL_COMMAND_MODE_MASK	GENMASK(1, 0)
+#define CONTROL_COMMAND_MODE_NORMAL	(0)
+#define CONTROL_COMMAND_MODE_FREAD	(1)
+#define CONTROL_COMMAND_MODE_WRITE	(2)
+#define CONTROL_COMMAND_MODE_USER	(3)

Drop the parenthesis around constants :)

yeah

Quoted 14 lines

drivers/mtd/spi-nor/aspeed-smc.c line 246

Quoted 11 lines
drivers/mtd/spi-nor/aspeed-smc.c new file +11 -0
+#define CONTROL_KEEP_MASK						\
+	(CONTROL_AAF_MODE | CONTROL_CE_INACTIVE_MASK | CONTROL_CLK_DIV4 | \
+	 CONTROL_IO_DUMMY_MASK | CONTROL_CLOCK_FREQ_SEL_MASK |		\
+	 CONTROL_LSB_FIRST | CONTROL_CLOCK_MODE_3)
+
+/*
+ * Segment Address Registers. Start and end addresses are encoded
+ * using 8MB units
+ */
+#define SEGMENT_ADDR_REG0		0x30
+#define SEGMENT_ADDR_START(_r)		((((_r) >> 16) & 0xFF) << 23)

is that ((r) & 0xff0000) << 7 ?

Quoted 3 lines
Quoted 1 line

+#define SEGMENT_ADDR_END(_r) ((((_r) >> 24) & 0xFF) << 23)

((r) & 0xff000000) >> 1 ?

yes.

I rather keep the initial macros though, which I found easier to understand.

The Segment Register uses a 8MB unit to encode the start address and the end address of the mapping window of a flash SPI slave :

        | byte 1 | byte 2 | byte 3 | byte 4 |
        +--------+--------+--------+--------+
        |  end   |  start |   0    |   0    |
Quoted 25 lines
Quoted 4 lines
drivers/mtd/spi-nor/aspeed-smc.c new file +4 -0
+static inline u32 aspeed_smc_chip_write_bit(struct aspeed_smc_chip *chip)
+{
+	return BIT(chip->controller->info->we0 + chip->cs);
+}

[...]

Quoted 18 lines
drivers/mtd/spi-nor/aspeed-smc.c new file +18 -0
+static int aspeed_smc_chip_setup_init(struct aspeed_smc_chip *chip,
+				      struct resource *res)
+{
+	struct aspeed_smc_controller *controller = chip->controller;
+	const struct aspeed_smc_info *info = controller->info;
+	u32 reg, base_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 */
+	if (info->hastype)
+		aspeed_smc_chip_set_type(chip, smc_type_spi);
+
+	/*
Quoted 8 lines

drivers/mtd/spi-nor/aspeed-smc.c line 505

Quoted 6 lines
drivers/mtd/spi-nor/aspeed-smc.c new file +6 -0
+	 * Configure chip base address in memory
+	 */
+	chip->ahb_base = aspeed_smc_chip_base(chip, res);
+	if (!chip->ahb_base) {
+		dev_warn(chip->nor.dev, "CE segment window closed.\n");
+		return -1;

return -EINVAL ? Check whether you always use errno.h macros in returns.

ah yes. I missed that one.

Quoted 22 lines
Quoted 19 lines
drivers/mtd/spi-nor/aspeed-smc.c new file +18 -0
+	}
+
+	/*
+	 * Get value of the inherited control register. U-Boot usually
+	 * does some timing calibration on the FMC chip, so it's good
+	 * to keep them. In the future, we should handle calibration
+	 * from Linux.
+	 */
+	reg = readl(chip->ctl);
+	dev_dbg(controller->dev, "control register: %08x\n", reg);
+
+	base_reg = reg & CONTROL_KEEP_MASK;
+	if (base_reg != reg) {
+		dev_info(controller->dev,
+			 "control register changed to: %08x\n",
+			 base_reg);
+	}
+	chip->ctl_val[smc_base] = base_reg;

[...]

Quoted 1 line

Mostly minor nits, looks nice otherwise, thanks :)

Thanks for the review,

C.

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

A message that is not in the archive (sent off-list or not yet received): f0ad683a-0989-e1ae-b33b-9746260ffa0e-Bxea+6Xhats@public.gmane.org

#7 lore raw

Re: [PATCH v3 1/5] mtd: spi-nor: add memory controllers for the Aspeed AST2500 SoC

Quoted 1 line · Cédric Le Goater

Hello,

Hi!

Quoted 15 lines · Marek Vasut
Quoted 5 lines · Cédric Le Goater

[...]

Quoted 8 lines

drivers/mtd/spi-nor/aspeed-smc.c line 58

Quoted 6 lines
drivers/mtd/spi-nor/aspeed-smc.c new file +6 -0
+static int aspeed_smc_read_from_ahb(void *buf, const void __iomem *src,
+				    size_t len)
+{
+	if (IS_ALIGNED((u32)src, sizeof(u32)) &&
+	    IS_ALIGNED((u32)buf, sizeof(u32)) &&
+	    IS_ALIGNED(len, sizeof(u32))) {

Did you try compiling this on any 64bit system ?

Quoted 2 lines

I cross compile the kernel on a 64bit host and then upload on the target. What kind of problem are you forseeing ?

Something about the pointer being clipped to 4 bytes, I'd rather use uintptr_t cast instead of u32 . I don't think it matters for this check, but just to be extra precise ...

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/mtd/spi-nor/aspeed-smc.c new file +2 -0
+		while (len > 3) {
+			*(u32 *)buf = readl(src);

[...]

Quoted 18 lines
Quoted 9 lines

drivers/mtd/spi-nor/aspeed-smc.c line 246

Quoted 6 lines
drivers/mtd/spi-nor/aspeed-smc.c new file +6 -0
+/*
+ * Segment Address Registers. Start and end addresses are encoded
+ * using 8MB units
+ */
+#define SEGMENT_ADDR_REG0		0x30
+#define SEGMENT_ADDR_START(_r)		((((_r) >> 16) & 0xFF) << 23)

is that ((r) & 0xff0000) << 7 ?

Quoted 3 lines
Quoted 1 line

+#define SEGMENT_ADDR_END(_r) ((((_r) >> 24) & 0xFF) << 23)

((r) & 0xff000000) >> 1 ?

yes.

I rather keep the initial macros though, which I found easier to understand.

Quoted 6 lines

The Segment Register uses a 8MB unit to encode the start address and the end address of the mapping window of a flash SPI slave :

        | byte 1 | byte 2 | byte 3 | byte 4 |
        +--------+--------+--------+--------+
        |  end   |  start |   0    |   0    |

Then the above should be in the comment , it's a good explanation :)

Thanks!

Signature · 6 lines
Best regards,
Marek Vasut
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reviewed-by
#8 lore raw

Re: [PATCH v3 1/5] mtd: spi-nor: add memory controllers for the Aspeed AST2500 SoC

In reply to a message not in the archive
Quoted 7 lines · Cédric Le Goater

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

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

I had a read and it looks good. Once you have addressed Marek's review, please add:

drivers/mtd/spi-nor/aspeed-smc.c line 734

Quoted 11 lines
---
 drivers/mtd/spi-nor/Kconfig      |  10 +
 drivers/mtd/spi-nor/Makefile     |   1 +
 drivers/mtd/spi-nor/aspeed-smc.c | 735 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 746 insertions(+)
 create mode 100644 drivers/mtd/spi-nor/aspeed-smc.c
drivers/mtd/spi-nor/aspeed-smc.c new file +3 -0
+
+MODULE_DESCRIPTION("ASPEED Static Memory Controller Driver");
+MODULE_AUTHOR("Milton Miller");

You can stick your name here instead, or drop the define.

Quoted 4 lines

+MODULE_LICENSE("GPL v2");
--
2.7.4

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

#9 lore raw

Re: [PATCH v3 1/5] mtd: spi-nor: add memory controllers for the Aspeed AST2500 SoC

In reply to a message not in the archive
Quoted 26 lines · Cédric Le Goater
drivers/mtd/spi-nor/Kconfig +10 -0
index 4a682ee0f632..5c0efbd9dd89 100644
@@ -29,6 +29,16 @@ config MTD_SPI_NOR_USE_4K_SECTORS
          Please note that some tools/drivers/filesystems may not work with
          4096 B erase size (e.g. UBIFS requires 15 KiB as a minimum).
 
+config SPI_ASPEED
+       tristate "Aspeed flash controllers in SPI mode"
+       depends on ARCH_ASPEED || COMPILE_TEST
+       depends on HAS_IOMEM && OF
+       help
+         This enables support for the Firmware Memory controller (FMC)
+         in the Aspeed AST2500 SoC when attached to SPI NOR chips,
+         and support for the SPI flash memory controller (SPI) for
+         the host firmware. The implementation only supports SPI NOR.
+
 config SPI_ATMEL_QUADSPI
        tristate "Atmel Quad SPI Controller"
        depends on ARCH_AT91 || (ARM && COMPILE_TEST)
drivers/mtd/spi-nor/Makefile +0 -0
index 121695e83542..d73d772c689c 100644

drivers/mtd/spi-nor/Makefile line 2

Quoted 2 lines
drivers/mtd/spi-nor/Makefile +1 -0
@@ -1,4 +1,5 @@
 obj-$(CONFIG_MTD_SPI_NOR)      += spi-nor.o
+obj-$(CONFIG_SPI_ASPEED)       += aspeed-smc.o

Can we make the symbol CONFIG_SPI_ASPEED_SMC?

Brendan has proposed a generic SPI master driver for the Aspeed SoC that would allow the controller to be used for non-flash devices. The obvious symbol for that driver is CONFIG_SPI_ASPEED.

Cheers,

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

A message that is not in the archive (sent off-list or not yet received): CACPK8XeTw4uNCjzp7qmbwkojrSAJw_U=7vXD-wTjDL2gb220qQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#11 lore raw

Re: [PATCH v3 1/5] mtd: spi-nor: add memory controllers for the Aspeed AST2500 SoC

Quoted 24 lines · Joel Stanley
Quoted 22 lines · Cédric Le Goater
drivers/mtd/spi-nor/Kconfig +10 -0
index 4a682ee0f632..5c0efbd9dd89 100644
@@ -29,6 +29,16 @@ config MTD_SPI_NOR_USE_4K_SECTORS
          Please note that some tools/drivers/filesystems may not work with
          4096 B erase size (e.g. UBIFS requires 15 KiB as a minimum).
 
+config SPI_ASPEED
+       tristate "Aspeed flash controllers in SPI mode"
+       depends on ARCH_ASPEED || COMPILE_TEST
+       depends on HAS_IOMEM && OF
+       help
+         This enables support for the Firmware Memory controller (FMC)
+         in the Aspeed AST2500 SoC when attached to SPI NOR chips,
+         and support for the SPI flash memory controller (SPI) for
+         the host firmware. The implementation only supports SPI NOR.
+
 config SPI_ATMEL_QUADSPI
        tristate "Atmel Quad SPI Controller"
        depends on ARCH_AT91 || (ARM && COMPILE_TEST)
drivers/mtd/spi-nor/Makefile +0 -0
Quoted 8 lines

drivers/mtd/spi-nor/Makefile line 2

Quoted 6 lines

index 121695e83542..d73d772c689c 100644

drivers/mtd/spi-nor/Makefile +1 -0
@@ -1,4 +1,5 @@
 obj-$(CONFIG_MTD_SPI_NOR)      += spi-nor.o
+obj-$(CONFIG_SPI_ASPEED)       += aspeed-smc.o

Can we make the symbol CONFIG_SPI_ASPEED_SMC?

sure. I will change the config option name and leave room for a potential generic SPI driver.

Thanks,

C.

Quoted 8 lines

Brendan has proposed a generic SPI master driver for the Aspeed SoC that would allow the controller to be used for non-flash devices. The obvious symbol for that driver is CONFIG_SPI_ASPEED.

Cheers,

Joel

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

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

#13 lore raw

PATCH v3 2/5 mtd: aspeed: add memory controllers for the Aspeed AST2400 SoC

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

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

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

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

---
 drivers/mtd/spi-nor/Kconfig      |  2 +-
 drivers/mtd/spi-nor/aspeed-smc.c | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+), 1 deletion(-)
drivers/mtd/spi-nor/Kconfig +1 -1
index 5c0efbd9dd89..22bea563f9bc 100644
@@ -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.
 
drivers/mtd/spi-nor/aspeed-smc.c +33 -0
index 6f9244f07aef..99302b0d7786 100644
@@ -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)
 {
Signature · 6 lines
2.7.4

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

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

#15 lore raw

Re: [PATCH v3 2/5] mtd: aspeed: add memory controllers for the Aspeed AST2400 SoC

Quoted 16 lines · Cédric Le Goater

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

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

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

Quoted 4 lines

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

Well this is a nice split :-)

Quoted 70 lines
---
 drivers/mtd/spi-nor/Kconfig      |  2 +-
 drivers/mtd/spi-nor/aspeed-smc.c | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+), 1 deletion(-)
drivers/mtd/spi-nor/Kconfig +1 -1
index 5c0efbd9dd89..22bea563f9bc 100644
@@ -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.
 
drivers/mtd/spi-nor/aspeed-smc.c +22 -0
index 6f9244f07aef..99302b0d7786 100644
@@ -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)
 	}
 }

drivers/mtd/spi-nor/aspeed-smc.c static void aspeed_smc_chip_set_4b(struct aspeed_smc_chip *chip) · line 512

Quoted 10 lines
drivers/mtd/spi-nor/aspeed-smc.c +9 -0
 
+/*
+ * 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;

How do you know the SPI NOR is in 4B mode ?

Quoted 6 lines
drivers/mtd/spi-nor/aspeed-smc.c +2 -0
+}
+
 static int aspeed_smc_chip_setup_init(struct aspeed_smc_chip *chip,
 				      struct resource *res)
 {
Signature · 6 lines
Best regards,
Marek Vasut
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 076683ea-fa94-2284-f269-2fcebd793940-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#17 lore raw

Re: [PATCH v3 2/5] mtd: aspeed: add memory controllers for the Aspeed AST2400 SoC

Quoted 10 lines · Marek Vasut

drivers/mtd/spi-nor/aspeed-smc.c static void aspeed_smc_chip_set_4b(struct aspeed_smc_chip *chip) · line 512

Quoted 9 lines
drivers/mtd/spi-nor/aspeed-smc.c +9 -0
+/*
+ * 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;

How do you know the SPI NOR is in 4B mode ?

in aspeed_smc_chip_setup_finish() :

	if (chip->nor.addr_width == 4 && info->set_4b)
		info->set_4b(chip);

C.

Quoted 6 lines

drivers/mtd/spi-nor/aspeed-smc.c static void aspeed_smc_chip_set_4b(struct aspeed_smc_chip *chip) · line 517

Quoted 6 lines
drivers/mtd/spi-nor/aspeed-smc.c +2 -0
+}
+
 static int aspeed_smc_chip_setup_init(struct aspeed_smc_chip *chip,
 				      struct resource *res)
 {

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

A message that is not in the archive (sent off-list or not yet received): 30a50d6d-07c5-0ca6-2d1b-3ba46c10da49-Bxea+6Xhats@public.gmane.org

#19 lore raw

Re: [PATCH v3 2/5] mtd: aspeed: add memory controllers for the Aspeed AST2400 SoC

Quoted 12 lines · Cédric Le Goater
Quoted 10 lines · Marek Vasut

drivers/mtd/spi-nor/aspeed-smc.c static void aspeed_smc_chip_set_4b(struct aspeed_smc_chip *chip) · line 512

Quoted 9 lines
drivers/mtd/spi-nor/aspeed-smc.c +9 -0
+/*
+ * 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;

How do you know the SPI NOR is in 4B mode ?

Quoted 5 lines

in aspeed_smc_chip_setup_finish() :

	if (chip->nor.addr_width == 4 && info->set_4b)
		info->set_4b(chip);

Ahhh, great :)

Signature · 6 lines
Best regards,
Marek Vasut
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reviewed-by
#20 lore raw

Re: [PATCH v3 2/5] mtd: aspeed: add memory controllers for the Aspeed AST2400 SoC

In reply to a message not in the archive
Quoted 4 lines · Cédric Le Goater

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

Good work. It was worth spending the time splitting out the different controllers I think.

Quoted 4 lines
---
 drivers/mtd/spi-nor/Kconfig      |  2 +-
 drivers/mtd/spi-nor/aspeed-smc.c | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+), 1 deletion(-)

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

#21 lore raw

PATCH v3 3/5 mtd: aspeed: used a label property

In reply to a message not in the archive

This can be used to easily identify a chip on a system with multiple chips.

---
 drivers/mtd/spi-nor/aspeed-smc.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/mtd/spi-nor/aspeed-smc.c +2 -0
index 99302b0d7786..9119c0ca86b6 100644
@@ -676,6 +676,8 @@ static int aspeed_smc_setup_flash(struct aspeed_smc_controller *controller,
 		nor->prepare = aspeed_smc_prep;
 		nor->unprepare = aspeed_smc_unprep;
 
+		mtd->name = of_get_property(child, "label", NULL);
+
 		ret = aspeed_smc_chip_setup_init(chip, r);
 		if (ret)
 			break;
Signature · 6 lines
2.7.4

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

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

#23 lore raw

Re: [PATCH v3 3/5] mtd: aspeed: used a label property

Quoted 2 lines · Cédric Le Goater

This can be used to easily identify a chip on a system with multiple chips.

I don't think I understand what this patch does. It seems to me like this one should be wrapped into 1/5.

Quoted 19 lines
---
 drivers/mtd/spi-nor/aspeed-smc.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/mtd/spi-nor/aspeed-smc.c +2 -0
index 99302b0d7786..9119c0ca86b6 100644
@@ -676,6 +676,8 @@ static int aspeed_smc_setup_flash(struct aspeed_smc_controller *controller,
 		nor->prepare = aspeed_smc_prep;
 		nor->unprepare = aspeed_smc_unprep;
 
+		mtd->name = of_get_property(child, "label", NULL);
+
 		ret = aspeed_smc_chip_setup_init(chip, r);
 		if (ret)
 			break;
Signature · 6 lines
Best regards,
Marek Vasut
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#24 lore raw

Re: [PATCH v3 3/5] mtd: aspeed: used a label property

Quoted 6 lines · Marek Vasut
Quoted 2 lines · Cédric Le Goater

This can be used to easily identify a chip on a system with multiple chips.

I don't think I understand what this patch does. It seems to me like this one should be wrapped into 1/5.

Yes, but this is to open the discussion on the change required in the jedec,spi-nor binding.

C.

Quoted 13 lines
Quoted 13 lines
---
 drivers/mtd/spi-nor/aspeed-smc.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/mtd/spi-nor/aspeed-smc.c +0 -0
index 99302b0d7786..9119c0ca86b6 100644
@@ -676,6 +676,8 @@ static int aspeed_smc_setup_flash(struct aspeed_smc_controller *controller,
 		nor->prepare = aspeed_smc_prep;
 		nor->unprepare = aspeed_smc_unprep;
 
Quoted 8 lines

drivers/mtd/spi-nor/aspeed-smc.c static int aspeed_smc_setup_flash(struct aspeed_smc_controller *controller, · line 683

Quoted 6 lines
drivers/mtd/spi-nor/aspeed-smc.c +2 -0
+		mtd->name = of_get_property(child, "label", NULL);
+
 		ret = aspeed_smc_chip_setup_init(chip, r);
 		if (ret)
 			break;

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

Acked-by
#25 lore raw

Re: [PATCH v3 3/5] mtd: aspeed: used a label property

In reply to a message not in the archive
Quoted 4 lines · Cédric Le Goater

This can be used to easily identify a chip on a system with multiple chips.

Our userspace benefits from having this.

Quoted 18 lines
---
 drivers/mtd/spi-nor/aspeed-smc.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/mtd/spi-nor/aspeed-smc.c +2 -1
index 99302b0d7786..9119c0ca86b6 100644
@@ -676,6 +676,8 @@ static int aspeed_smc_setup_flash(struct aspeed_smc_controller *controller,
                nor->prepare = aspeed_smc_prep;
                nor->unprepare = aspeed_smc_unprep;
 
+               mtd->name = of_get_property(child, "label", NULL);
+
                ret = aspeed_smc_chip_setup_init(chip, r);
                if (ret)
                        break;
--
Quoted 2 lines

2.7.4

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

A message that is not in the archive (sent off-list or not yet received): CACPK8Xcj4P34-4krGbnimVG89wMcHoRX4XJ66-_7KtAt6-vTkA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#27 lore raw

Re: [PATCH v3 3/5] mtd: aspeed: used a label property

Quoted 9 lines · Joel Stanley
Quoted 4 lines · Cédric Le Goater

This can be used to easily identify a chip on a system with multiple chips.

Our userspace benefits from having this.

Shouldn't such thing be part of core code then ?

Quoted 20 lines
Quoted 20 lines
---
 drivers/mtd/spi-nor/aspeed-smc.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/mtd/spi-nor/aspeed-smc.c +2 -1
index 99302b0d7786..9119c0ca86b6 100644
@@ -676,6 +676,8 @@ static int aspeed_smc_setup_flash(struct aspeed_smc_controller *controller,
                nor->prepare = aspeed_smc_prep;
                nor->unprepare = aspeed_smc_unprep;
 
+               mtd->name = of_get_property(child, "label", NULL);
+
                ret = aspeed_smc_chip_setup_init(chip, r);
                if (ret)
                        break;
--

2.7.4

Signature · 6 lines
Best regards,
Marek Vasut
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): d8a6f699-3ee2-07b1-f0f5-478b0d8dd259-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#29 lore raw

Re: [PATCH v3 3/5] mtd: aspeed: used a label property

Quoted 5 lines · Marek Vasut
Quoted 4 lines · Joel Stanley
Quoted 3 lines · Cédric Le Goater

This can be used to easily identify a chip on a system with multiple chips.

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

Our userspace benefits from having this.

Shouldn't such thing be part of core code then ?

yes. I will merge it in the next version.

we already have the jedec,spi-nor label patch to discuss about the binding change.

Thanks,

C.

Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
---
 drivers/mtd/spi-nor/aspeed-smc.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/mtd/spi-nor/aspeed-smc.c +0 -0
index 99302b0d7786..9119c0ca86b6 100644
@@ -676,6 +676,8 @@ static int aspeed_smc_setup_flash(struct aspeed_smc_controller *controller,
                nor->prepare = aspeed_smc_prep;
                nor->unprepare = aspeed_smc_unprep;
 
Quoted 10 lines
Quoted 8 lines
Quoted 8 lines
drivers/mtd/spi-nor/aspeed-smc.c +2 -1
+               mtd->name = of_get_property(child, "label", NULL);
+
                ret = aspeed_smc_chip_setup_init(chip, r);
                if (ret)
                        break;
--

2.7.4

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

#30 lore raw

PATCH v3 4/5 mtd: spi-nor: bindings for the Aspeed memory controllers

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


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

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

#32 lore raw

Re: [PATCH v3 4/5] mtd: spi-nor: bindings for the Aspeed memory controllers

Quoted 12 lines · Cédric Le Goater
---
 .../devicetree/bindings/mtd/aspeed-smc.txt         | 51 ++++++++++++++++++++++
 1 file changed, 51 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mtd/aspeed-smc.txt
Documentation/devicetree/bindings/mtd/aspeed-smc.txt new file +0 -0
new file mode 100644
index 000000000000..e2c88cea38f6

Documentation/devicetree/bindings/mtd/aspeed-smc.txt line 6

Quoted 6 lines
Documentation/devicetree/bindings/mtd/aspeed-smc.txt new file +6 -0
@@ -0,0 +1,51 @@
+* Aspeed Firmware Memory controller
+* Aspeed SPI Flash Memory Controller
+
+The Firmware Memory Controller in the Aspeed AST2500 SoC supports
+three chip selects, two of which are always of SPI type and the third
+can be SPI or NOR type flash, but the driver only supports SPI.

As the bindings are a description of the hardware and not the driver, we might want to reword this. Perhaps "these bindings only describe SPI"?

Cheers,

Joel

Quoted 46 lines
Documentation/devicetree/bindings/mtd/aspeed-smc.txt new file +45 -1
+
+The two SPI flash memory controllers in the AST2500 each support two
+chip selects.
+
+Required properties:
+  - compatible : Should be one of
+       "aspeed,ast2400-fmc" for the AST2400 Firmware Memory Controller
+       "aspeed,ast2400-spi" for the AST2400 SPI Flash memory Controller
+       "aspeed,ast2500-fmc" for the AST2500 Firmware Memory Controller
+       "aspeed,ast2500-spi" for the AST2500 SPI flash memory controllers
+
+  - reg : the first contains the control register location and length,
+          the second contains the memory window mapping address and length
+  - #address-cells : must be 1 corresponding to chip select child binding
+  - #size-cells : must be 0 corresponding to chip select child binding
+
+Optional properties:
+  - interrupts : Should contain the interrupt for the dma device if an
+    FMC
+
+The child nodes are the SPI flash modules which must have a compatible
+property as specified in bindings/mtd/jedec,spi-nor.txt
+
+Optionally, the child node can contain properties for SPI mode (may be
+ignored):
+  - spi-max-frequency - max frequency of spi bus
+
+
+Example:
+fmc: fmc@1e620000 {
+       compatible = "aspeed,ast2500-fmc";
+       reg = < 0x1e620000 0x94
+               0x20000000 0x02000000 >;
+       #address-cells = <1>;
+       #size-cells = <0>;
+       interrupts = <19>;
+       flash@0 {
+               reg = < 0 >;
+               compatible = "jedec,spi-nor";
+               /* spi-max-frequency = <>; */
+               /* m25p,fast-read; */
+               #address-cells = <1>;
+               #size-cells = <1>;
+       };
+};
--
Quoted 2 lines

2.7.4

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

#33 lore raw

PATCH v3 5/5 mtd: spi-nor: add a label property to jedec,spi-nor

In reply to Cédric Le Goater

This can be used to easily identify a chip on a system with multiple chips.

---
 Documentation/devicetree/bindings/mtd/jedec,spi-nor.txt | 2 ++
 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/mtd/jedec,spi-nor.txt +2 -0
index 2c91c03e7eb0..b7cd02a3ebe8 100644
@@ -65,6 +65,7 @@ Optional properties:
                    all chips and support for it can not be detected at runtime.
                    Refer to your chips' datasheet to check if this is supported
                    by your chip.
+- label : name to assign to mtd. If omitted, the label is the MTD device name.
 
 Example:
 
@@ -75,4 +76,5 @@ Example:
 		reg = <0>;
 		spi-max-frequency = <40000000>;
 		m25p,fast-read;
+		label = "System-firmware";
 	};
Signature · 6 lines
2.7.4


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

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

Acked-by
#35 lore raw

Re: [PATCH v3 5/5] mtd: spi-nor: add a label property to jedec,spi-nor

Quoted 4 lines · Cédric Le Goater

This can be used to easily identify a chip on a system with multiple chips.

This is very useful when writing userspace that wants to select the mtd device that represents a specific flash chip.

Quoted 23 lines
---
 Documentation/devicetree/bindings/mtd/jedec,spi-nor.txt | 2 ++
 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/mtd/jedec,spi-nor.txt +2 -1
index 2c91c03e7eb0..b7cd02a3ebe8 100644
@@ -65,6 +65,7 @@ Optional properties:
                    all chips and support for it can not be detected at runtime.
                    Refer to your chips' datasheet to check if this is supported
                    by your chip.
+- label : name to assign to mtd. If omitted, the label is the MTD device name.
 
 Example:
 
@@ -75,4 +76,5 @@ Example:
                reg = <0>;
                spi-max-frequency = <40000000>;
                m25p,fast-read;
+               label = "System-firmware";
        };
--
Quoted 2 lines

2.7.4

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