Skip to contentSkip to conversation

Add support for NAND flash to A7K/A8K SoC family

PATCH New kostap at marvell.com 2 participants 17 messages Mar 28, 2017 – May 9, 2017

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

cover Add support for NAND flash to A7K/A8K SoC family

From: Konstantin Porotchkin <[email protected]>

This patch series adds NAND flash support to Marvell A7K/A8K SoC families. Additionally it fixes the pxa3xx driver by enforcing usage of DTS-supplied NAND parameters instead of using the hardcoded ones.
The Marvell "bubt" command code related to NAND flash is updated according to new DM driver APIs.
Added a default configuration file for Armada-7040 DB with NAND flash selected as a boot device instead of default SPI flash.
Added a DTS file for this setup that includes proper MPPs configuration.

These patches should be applied on top of the following patch that was sent to the u-boot list earlier:
"fix: nand: Fix nand RW access wrappers"

Konstantin Porotchkin (5):
fix: nand: pxa3xx: Remove hardcode values from the driver
arm64: mvebu: a8k: Add support for NAND clock get
arm64: mvebu: Fix the bubt comamnd NAND device support
arm64: a8k: dts: Add support for NAND devices on A8K platform
arm64: mvebu: a8k: Add NAND configuration parameters

 arch/arm/dts/Makefile                   |   1 +
 arch/arm/dts/armada-7040-db-nand.dts    | 222 ++++++++++++++++++++++++++++++++
 arch/arm/dts/armada-7040-db.dts         |   1 +
 arch/arm/dts/armada-cp110-master.dtsi   |  13 ++
 arch/arm/mach-mvebu/armada8k/cpu.c      |  16 +++
 cmd/mvebu/bubt.c                        |  13 +-
 configs/mvebu_db-88f7040-nand_defconfig |  72 +++++++++++
 drivers/mtd/nand/pxa3xx_nand.c          |  62 +++++++--
 include/configs/mvebu_armada-8k.h       |  11 ++
 9 files changed, 397 insertions(+), 14 deletions(-)
 create mode 100644 arch/arm/dts/armada-7040-db-nand.dts
 create mode 100644 configs/mvebu_db-88f7040-nand_defconfig
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/5 fix: nand: pxa3xx: Remove hardcode values from the driver

From: Konstantin Porotchkin <[email protected]>

Obtain NAND controller setup parameters from the device tree instead of using hardcoded values.

Cc Scott Wood <[email protected]>
Cc Stefan Roese <[email protected]>
Cc Igal Liberman <[email protected]>
Cc Nadav Haklai <[email protected]>
---
 drivers/mtd/nand/pxa3xx_nand.c | 62 ++++++++++++++++++++++++++++++++++++------
 1 file changed, 54 insertions(+), 8 deletions(-)
drivers/mtd/nand/pxa3xx_nand.c +54 -8
index dfe8966..0042a7b 100644
@@ -9,6 +9,7 @@
 
 #include <common.h>
 #include <malloc.h>
+#include <fdtdec.h>
 #include <nand.h>
 #include <linux/errno.h>
 #include <asm/io.h>
@@ -19,6 +20,8 @@
 
 #include "pxa3xx_nand.h"
 
+DECLARE_GLOBAL_DATA_PTR;
+
 #define TIMEOUT_DRAIN_FIFO	5	/* in ms */
 #define	CHIP_DELAY_TIMEOUT	200
 #define NAND_STOP_DELAY		40
@@ -1510,8 +1513,6 @@ static int alloc_nand_resource(struct pxa3xx_nand_info *info)
 		chip->cmdfunc		= nand_cmdfunc;
 	}
 
-	info->mmio_base = (void __iomem *)MVEBU_NAND_BASE;
-
 	/* Allocate a buffer to allow flash detection */
 	info->buf_size = INIT_BUFFER_SIZE;
 	info->data_buff = kmalloc(info->buf_size, GFP_KERNEL);
@@ -1533,17 +1534,62 @@ fail_disable_clk:
 static int pxa3xx_nand_probe_dt(struct pxa3xx_nand_info *info)
 {
 	struct pxa3xx_nand_platform_data *pdata;
+	const void *blob = gd->fdt_blob;
+	int node = -1;
 
 	pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
 	if (!pdata)
 		return -ENOMEM;
 
-	pdata->enable_arbiter = 1;
-	pdata->num_cs = 1;
+	/* Get address decoding nodes from the FDT blob */
+	do {
+		node = fdt_node_offset_by_compatible(blob, node,
+						     "marvell,mvebu-pxa3xx-nand");
+		if (node < 0)
+			break;
+
+		/* Bypass disabeld nodes */
+		if (!fdtdec_get_is_enabled(blob, node))
+			continue;
 
-	info->pdata = pdata;
+		/* Get the first enabled NAND controler base address */
+		info->mmio_base =
+			(void __iomem *)fdtdec_get_addr_size_auto_noparent(
+					blob, node, "reg", 0, NULL, true);
 
-	return 0;
+		pdata->num_cs = fdtdec_get_int(blob, node, "num-cs", 1);
+		if (pdata->num_cs != 1) {
+			error("pxa3xx driver supports single CS only\n");
+			break;
+		}
+
+		if (fdtdec_get_bool(blob, node, "nand-enable-arbiter"))
+			pdata->enable_arbiter = 1;
+
+		if (fdtdec_get_bool(blob, node, "nand-keep-config"))
+			pdata->keep_config = 1;
+
+		/*
+		 * ECC parameters.
+		 * If these are not set, they will be selected according
+		 * to the detected flash type.
+		 */
+		/* ECC strength */
+		pdata->ecc_strength = fdtdec_get_int(blob, node,
+						     "nand-ecc-strength", 0);
+
+		/* ECC step size */
+		pdata->ecc_step_size = fdtdec_get_int(blob, node,
+						      "nand-ecc-step-size", 0);
+
+		info->pdata = pdata;
+
+		/* Currently support only a single NAND controller */
+		return 0;
+
+	} while (node >= 0);
+
+	return -EINVAL;
 }
 
 static int pxa3xx_nand_probe(struct pxa3xx_nand_info *info)
@@ -1603,8 +1649,8 @@ void board_nand_init(void)
 	int ret;
 
 	info = kzalloc(sizeof(*info) +
-				sizeof(*host) * CONFIG_SYS_MAX_NAND_DEVICE,
-			GFP_KERNEL);
+		       sizeof(*host) * CONFIG_SYS_MAX_NAND_DEVICE,
+		       GFP_KERNEL);
 	if (!info)
 		return;
 
Signature · 1 line
2.7.4
#2 lore raw

PATCH 1/5 fix: nand: pxa3xx: Remove hardcode values from the driver

Quoted 10 lines · kostap at marvell.com

From: Konstantin Porotchkin <[email protected]>

Obtain NAND controller setup parameters from the device tree instead of using hardcoded values.

Cc Scott Wood <[email protected]>
Cc Stefan Roese <[email protected]>
Cc Igal Liberman <[email protected]>
Cc Nadav Haklai <[email protected]>

Thanks,
Stefan

#3 lore raw

PATCH 1/5 fix: nand: pxa3xx: Remove hardcode values from the driver

In reply to kostap at marvell.com
Quoted 10 lines · kostap at marvell.com

From: Konstantin Porotchkin <[email protected]>

Obtain NAND controller setup parameters from the device tree instead of using hardcoded values.

Cc Scott Wood <[email protected]>
Cc Stefan Roese <[email protected]>
Cc Igal Liberman <[email protected]>
Cc Nadav Haklai <[email protected]>

Applied to u-boot-marvell/master.

Thanks,
Stefan

#4 lore raw

PATCH 2/5 arm64: mvebu: a8k: Add support for NAND clock get

In reply to kostap at marvell.com

From: Konstantin Porotchkin <[email protected]>

Implement mvebu_get_nand_clock call for A8K family. This function is used by PXA3XX NAND driver.

Cc Stefan Roese <[email protected]>
Cc Igal Liberman <[email protected]>
Cc Nadav Haklai <[email protected]>
---
 arch/arm/mach-mvebu/armada8k/cpu.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
arch/arm/mach-mvebu/armada8k/cpu.c +16 -0
index 2325e9a..e18ca6b 100644
@@ -110,3 +110,19 @@ void reset_cpu(ulong ignored)
 	reg &= ~(1 << RFU_SW_RESET_OFFSET);
 	writel(reg, RFU_GLOBAL_SW_RST);
 }
+
+#ifdef CONFIG_NAND_PXA3XX
+/* Return NAND clock in Hz */
+u32 mvebu_get_nand_clock(void)
+{
+	unsigned long NAND_FLASH_CLK_CTRL = 0xF2440700UL;
+	unsigned long NF_CLOCK_SEL_MASK = 0x1;
+	u32 reg;
+
+	reg = readl(NAND_FLASH_CLK_CTRL);
+	if (reg & NF_CLOCK_SEL_MASK)
+		return 400 * 1000000;
+	else
+		return 250 * 1000000;
+}
+#endif
Signature · 1 line
2.7.4
#5 lore raw

PATCH 2/5 arm64: mvebu: a8k: Add support for NAND clock get

Quoted 18 lines · kostap at marvell.com

From: Konstantin Porotchkin <[email protected]>

Implement mvebu_get_nand_clock call for A8K family. This function is used by PXA3XX NAND driver.

Cc Stefan Roese <[email protected]>
Cc Igal Liberman <[email protected]>
Cc Nadav Haklai <[email protected]>
---
 arch/arm/mach-mvebu/armada8k/cpu.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
arch/arm/mach-mvebu/armada8k/cpu.c +0 -0
index 2325e9a..e18ca6b 100644

arch/arm/mach-mvebu/armada8k/cpu.c void reset_cpu(ulong ignored) · line 114

Quoted 5 lines
arch/arm/mach-mvebu/armada8k/cpu.c +2 -0
@@ -110,3 +110,19 @@ void reset_cpu(ulong ignored)
 	reg &= ~(1 << RFU_SW_RESET_OFFSET);
 	writel(reg, RFU_GLOBAL_SW_RST);
 }
+
+#ifdef CONFIG_NAND_PXA3XX

Do we really need to have this code conditionally compiled here?

arch/arm/mach-mvebu/armada8k/cpu.c void reset_cpu(ulong ignored) · line 118

Quoted 4 lines
arch/arm/mach-mvebu/armada8k/cpu.c +4 -0
+/* Return NAND clock in Hz */
+u32 mvebu_get_nand_clock(void)
+{
+	unsigned long NAND_FLASH_CLK_CTRL = 0xF2440700UL;

I know that some of this code is historically done this way. But with DT available now, isn't it possible to at least get the base address of such registers from the DT instead of hardcoding it?

Thanks,
Stefan

#6 lore raw

PATCH 2/5 arm64: mvebu: a8k: Add support for NAND clock get

Hi, Stefan,

Quoted 14 lines · Stefan Roese
Quoted 13 lines · kostap at marvell.com

From: Konstantin Porotchkin <[email protected]>

Implement mvebu_get_nand_clock call for A8K family. This function is used by PXA3XX NAND driver.

Cc Stefan Roese <[email protected]>
Cc Igal Liberman <[email protected]>
Cc Nadav Haklai <[email protected]>
---
 arch/arm/mach-mvebu/armada8k/cpu.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
Quoted 13 lines

arch/arm/mach-mvebu/armada8k/cpu.c void reset_cpu(ulong ignored) · line 114

Quoted 11 lines
arch/arm/mach-mvebu/armada8k/cpu.c +2 -0
index 2325e9a..e18ca6b 100644
@@ -110,3 +110,19 @@ void reset_cpu(ulong ignored)
     reg &= ~(1 << RFU_SW_RESET_OFFSET);
     writel(reg, RFU_GLOBAL_SW_RST);
 }
+
+#ifdef CONFIG_NAND_PXA3XX

Do we really need to have this code conditionally compiled here?

I can remove it, just wanted not to increase the code size if not needed. Do you think it is excessive?

Quoted 9 lines

arch/arm/mach-mvebu/armada8k/cpu.c void reset_cpu(ulong ignored) · line 118

Quoted 5 lines
arch/arm/mach-mvebu/armada8k/cpu.c +4 -0
+/* Return NAND clock in Hz */
+u32 mvebu_get_nand_clock(void)
+{
+    unsigned long NAND_FLASH_CLK_CTRL = 0xF2440700UL;

I know that some of this code is historically done this way. But with DT available now, isn't it possible to at least get the base address of such registers from the DT instead of hardcoding it?

I see what you saying and I agree it is not as elegant as it could be. The only problem is that the NAND clock register is not part of the SoC NAND unit, so the IO base taken from DTS entry for NAND device is not really useful here. NAND unit and its clock configuration register are only sharing the CP0 base - 0xF2000000.

Quoted 3 lines

Thanks,
Stefan

#7 lore raw

PATCH 2/5 arm64: mvebu: a8k: Add support for NAND clock get

Hi Kosta,

Quoted 28 lines · Konstantin Porotchkin
Quoted 14 lines · Stefan Roese
Quoted 13 lines · kostap at marvell.com

From: Konstantin Porotchkin <[email protected]>

Implement mvebu_get_nand_clock call for A8K family. This function is used by PXA3XX NAND driver.

Cc Stefan Roese <[email protected]>
Cc Igal Liberman <[email protected]>
Cc Nadav Haklai <[email protected]>
---
 arch/arm/mach-mvebu/armada8k/cpu.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
Quoted 13 lines

arch/arm/mach-mvebu/armada8k/cpu.c void reset_cpu(ulong ignored) · line 114

Quoted 11 lines
arch/arm/mach-mvebu/armada8k/cpu.c +2 -0
index 2325e9a..e18ca6b 100644
@@ -110,3 +110,19 @@ void reset_cpu(ulong ignored)
     reg &= ~(1 << RFU_SW_RESET_OFFSET);
     writel(reg, RFU_GLOBAL_SW_RST);
 }
+
+#ifdef CONFIG_NAND_PXA3XX

Do we really need to have this code conditionally compiled here?

Quoted 2 lines

I can remove it, just wanted not to increase the code size if not needed. Do you think it is excessive?

Yes, please remove it. These platforms are not that size constraint as some SPL ones are. The pros for not adding more #ifdef's overweight the small code size increase - at least for my taste.

Quoted 8 lines
Quoted 8 lines

arch/arm/mach-mvebu/armada8k/cpu.c void reset_cpu(ulong ignored) · line 118

Quoted 4 lines
arch/arm/mach-mvebu/armada8k/cpu.c +4 -0
+/* Return NAND clock in Hz */
+u32 mvebu_get_nand_clock(void)
+{
+    unsigned long NAND_FLASH_CLK_CTRL = 0xF2440700UL;

I know that some of this code is historically done this way. But with DT available now, isn't it possible to at least get the base address of such registers from the DT instead of hardcoding it?

Quoted 5 lines

I see what you saying and I agree it is not as elegant as it could be. The only problem is that the NAND clock register is not part of the SoC NAND unit, so the IO base taken from DTS entry for NAND device is not really useful here. NAND unit and its clock configuration register are only sharing the CP0 base - 0xF2000000.

Right. I wouldn't have expected that this register is located in the NAND controller space - more likely some clocking controller / infrastructure. I'm okay with this patch for now, but perhaps you could add a small "ToDo" comment here, that this should be converted at some time, once a mvebu / a7k/8K DM clock driver is available in U-Boot (see drivers/clk)?

Thanks,
Stefan

#8 lore raw

PATCH 3/5 arm64: mvebu: Fix the bubt comamnd NAND device support

In reply to kostap at marvell.com

From: Konstantin Porotchkin <[email protected]>

Fix the NAND structures in bubt command according to latest changes in MTD API.

Cc Stefan Roese <[email protected]>
Cc Igal Liberman <[email protected]>
Cc Nadav Haklai <[email protected]>
---
 cmd/mvebu/bubt.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
cmd/mvebu/bubt.c +7 -6
index b752927..1e1f0af 100644
@@ -309,16 +309,17 @@ static int is_spi_active(void)
 #ifdef CONFIG_CMD_NAND
 static int nand_burn_image(size_t image_size)
 {
-	int ret, block_size;
-	nand_info_t *nand;
+	int ret;
+	uint32_t block_size;
+	struct mtd_info *nand;
 	int dev = nand_curr_device;
 
 	if ((dev < 0) || (dev >= CONFIG_SYS_MAX_NAND_DEVICE) ||
-	    (!nand_info[dev].name)) {
+	    (!nand_info[dev]->name)) {
 		puts("\nno devices available\n");
 		return -ENOMEDIUM;
 	}
-	nand = &nand_info[dev];
+	nand = nand_info[dev];
 	block_size = nand->erasesize;
 
 	/* Align U-Boot size to currently used blocksize */
@@ -334,8 +335,8 @@ static int nand_burn_image(size_t image_size)
 	printf("Done!\n");
 
 	/* Write the image to flash */
-	printf("Writing image:...");
-	printf("&image_size = 0x%p\n", (void *)&image_size);
+	printf("Writing %d bytes from 0x%lx to offset 0 ... ",
+	       (int)image_size, get_load_addr());
 	ret = nand_write(nand, 0, &image_size, (void *)get_load_addr());
 	if (ret)
 		printf("Error!\n");
Signature · 1 line
2.7.4
#9 lore raw

PATCH 3/5 arm64: mvebu: Fix the bubt comamnd NAND device support

Quoted 9 lines · kostap at marvell.com

From: Konstantin Porotchkin <[email protected]>

Fix the NAND structures in bubt command according to latest changes in MTD API.

Cc Stefan Roese <[email protected]>
Cc Igal Liberman <[email protected]>
Cc Nadav Haklai <[email protected]>

Thanks,
Stefan

#10 lore raw

PATCH 3/5 arm64: mvebu: Fix the bubt comamnd NAND device support

In reply to kostap at marvell.com
Quoted 9 lines · kostap at marvell.com

From: Konstantin Porotchkin <[email protected]>

Fix the NAND structures in bubt command according to latest changes in MTD API.

Cc Stefan Roese <[email protected]>
Cc Igal Liberman <[email protected]>
Cc Nadav Haklai <[email protected]>

Applied to u-boot-marvell/master.

Thanks,
Stefan

#11 lore raw

PATCH 4/5 arm64: a8k: dts: Add support for NAND devices on A8K platform

In reply to kostap at marvell.com

From: Konstantin Porotchkin <[email protected]>

Add NAND to CP master device tree. Add armada-7040-db-nand device tree for the board configured with NAND boot device. Add comment about boot device ID to armada-7040-db DTS.

Cc Stefan Roese <[email protected]>
Cc Igal Liberman <[email protected]>
Cc Nadav Haklai <[email protected]>
---
 arch/arm/dts/Makefile                 |   1 +
 arch/arm/dts/armada-7040-db-nand.dts  | 222 ++++++++++++++++++++++++++++++++++
 arch/arm/dts/armada-7040-db.dts       |   1 +
 arch/arm/dts/armada-cp110-master.dtsi |  13 ++
 4 files changed, 237 insertions(+)
 create mode 100644 arch/arm/dts/armada-7040-db-nand.dts
arch/arm/dts/Makefile +1 -0
index 0fbbb9b..d09d8f2 100644
@@ -77,6 +77,7 @@ dtb-$(CONFIG_ARCH_MVEBU) +=			\
 	armada-388-gp.dtb			\
 	armada-385-amc.dtb			\
 	armada-7040-db.dtb			\
+	armada-7040-db-nand.dtb			\
 	armada-8040-db.dtb			\
 	armada-8040-mcbin.dtb			\
 	armada-xp-gp.dtb			\
arch/arm/dts/armada-7040-db-nand.dts new file +222 -0

222 lines not on this page · raw message

arch/arm/dts/armada-7040-db.dts +1 -0
index 63442df..3bd699d 100644
@@ -42,6 +42,7 @@
 
 /*
  * Device Tree file for Marvell Armada 7040 Development board platform
+ * Boot device: SPI NOR, 0x32 (SW3)
  */
 
 #include "armada-7040.dtsi"
arch/arm/dts/armada-cp110-master.dtsi +13 -0
index 1f0edde..d4c6cc6 100644
@@ -236,6 +236,19 @@
 				dma-coherent;
 				status = "disabled";
 			};
+			cpm_nand: nand at 720000 {
+				compatible = "marvell,mvebu-pxa3xx-nand";
+				reg = <0x720000 0x100>;
+				#address-cells = <1>;
+
+				clocks = <&cpm_syscon0 1 2>;
+				nand-enable-arbiter;
+				num-cs = <1>;
+				nand-ecc-strength = <4>;
+				nand-ecc-step-size = <512>;
+				status = "disabled";
+			};
+
 		};
 
 		cpm_pcie0: pcie at f2600000 {
Signature · 1 line
2.7.4
#12 lore raw

PATCH 4/5 arm64: a8k: dts: Add support for NAND devices on A8K platform

Quoted 77 lines · kostap at marvell.com

From: Konstantin Porotchkin <[email protected]>

Add NAND to CP master device tree. Add armada-7040-db-nand device tree for the board configured with NAND boot device. Add comment about boot device ID to armada-7040-db DTS.

Cc Stefan Roese <[email protected]>
Cc Igal Liberman <[email protected]>
Cc Nadav Haklai <[email protected]>
---
 arch/arm/dts/Makefile                 |   1 +
 arch/arm/dts/armada-7040-db-nand.dts  | 222 ++++++++++++++++++++++++++++++++++
 arch/arm/dts/armada-7040-db.dts       |   1 +
 arch/arm/dts/armada-cp110-master.dtsi |  13 ++
 4 files changed, 237 insertions(+)
 create mode 100644 arch/arm/dts/armada-7040-db-nand.dts
arch/arm/dts/Makefile +1 -0
index 0fbbb9b..d09d8f2 100644
@@ -77,6 +77,7 @@ dtb-$(CONFIG_ARCH_MVEBU) +=			\
 	armada-388-gp.dtb			\
 	armada-385-amc.dtb			\
 	armada-7040-db.dtb			\
+	armada-7040-db-nand.dtb			\
 	armada-8040-db.dtb			\
 	armada-8040-mcbin.dtb			\
 	armada-xp-gp.dtb			\
arch/arm/dts/armada-7040-db-nand.dts new file +41 -0
new file mode 100644
index 0000000..da213ea
@@ -0,0 +1,222 @@
+/*
+ * Copyright (C) 2017 Marvell Technology Group Ltd.
+ *
+ * This file is dual-licensed: you can use it either under the terms
+ * of the GPLv2 or the X11 license, at your option. Note that this dual
+ * licensing only applies to this file, and not this project as a
+ * whole.
+ *
+ *  a) This library 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.
+ *
+ *     This library is distributed in the hope that it will be useful,
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *     GNU General Public License for more details.
+ *
+ * Or, alternatively,
+ *
+ *  b) Permission is hereby granted, free of charge, to any person
+ *     obtaining a copy of this software and associated documentation
+ *     files (the "Software"), to deal in the Software without
+ *     restriction, including without limitation the rights to use,
+ *     copy, modify, merge, publish, distribute, sublicense, and/or
+ *     sell copies of the Software, and to permit persons to whom the
+ *     Software is furnished to do so, subject to the following
+ *     conditions:
+ *
+ *     The above copyright notice and this permission notice shall be
+ *     included in all copies or substantial portions of the Software.
+ *
+ *     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ *     OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ *     HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ *     WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ *     FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ *     OTHER DEALINGS IN THE SOFTWARE.
+ */

arch/arm/dts/armada-7040-db-nand.dts line 51

Quoted 10 lines
arch/arm/dts/armada-7040-db-nand.dts new file +10 -0
+
+/*
+ * Device Tree file for Marvell Armada 7040 Development board platform
+ * Boot device: NAND, 0xE (SW3)
+ */
+
+#include "armada-7040.dtsi"
+
+/ {
+	model = "Marvell Armada 7040 DB board";

Perhaps a comment here mentioning NAND as well?

arch/arm/dts/armada-7040-db-nand.dts line 53

Quoted 2 lines
arch/arm/dts/armada-7040-db-nand.dts new file +2 -0
+	compatible = "marvell,armada7040-db", "marvell,armada7040",
+		     "marvell,armada-ap806-quad", "marvell,armada-ap806";

So this is identical to the original 7040-db board? Perhaps its better (or even necessary) to add a new "NAND" specific compatible string here?

Quoted 50 lines
arch/arm/dts/armada-7040-db-nand.dts new file +50 -0
+
+	chosen {
+		stdout-path = "serial0:115200n8";
+	};
+
+	aliases {
+		i2c0 = &cpm_i2c0;
+		spi0 = &cpm_spi1;
+	};
+
+	memory at 00000000 {
+		device_type = "memory";
+		reg = <0x0 0x0 0x0 0x80000000>;
+	};
+};
+
+&ap_pinctl {
+	   /* MPP Bus:
+	    * SDIO  [0-5]
+	    * UART0 [11,19]
+	    */
+		  /* 0   1   2   3   4   5   6   7   8   9 */
+	pin-func = < 0x1 0x1 0x1 0x1 0x1 0x1 0x0 0x0 0x0 0x0
+		     0x0 0x3 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x3 >;
+};
+
+&uart0 {
+	status = "okay";
+};
+
+
+&cpm_pcie2 {
+	status = "okay";
+};
+
+&cpm_i2c0 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&cpm_i2c0_pins>;
+	status = "okay";
+	clock-frequency = <100000>;
+};
+
+&cpm_pinctl {
+		/* MPP Bus:
+		 * AUDIO   [0-5]
+                 * GBE     [6-11]
+		 * SS_PWDN [12]
+		 * NF_RBn  [13]
+                 * GPIO    [14]
+		 * DEV_BUS [15-27]

arch/arm/dts/armada-7040-db-nand.dts line 113

Quoted 10 lines
arch/arm/dts/armada-7040-db-nand.dts new file +10 -0
+		 * SATA1   [28]
+		 * UART0   [29-30]
+		 * MSS_VTT_EN [31]
+		 * SMI	   [32,34]
+		 * XSMI    [35-36]
+		 * I2C	   [37-38]
+		 * RGMII1  [44-55]
+		 * SD	   [56-61]
+		 * GPIO    [62]
+		 */

The indentation looks "fishy" above.

Quoted 132 lines
arch/arm/dts/armada-7040-db-nand.dts new file +109 -0
+		 /*   0   1   2   3   4   5   6   7   8   9 */
+	 pin-func = < 0x2 0x2 0x2 0x2 0x2 0x2 0x3 0x3 0x3 0x3
+		      0x3 0x3 0x0 0x2 0x0 0x1 0x1 0x1 0x1 0x1
+		      0x1 0x1 0x1 0x1 0x1 0x1 0x1 0x1 0x9 0xa
+		      0xa 0x0 0x7 0x0 0x7 0x7 0x7 0x2 0x2 0x0
+		      0x0 0x0 0x0 0x0 0x1 0x1 0x1 0x1 0x1 0x1
+		      0x1 0x1 0x1 0x1 0x1 0x1 0xe 0xe 0xe 0xe
+		      0xe 0xe 0x0>;
+};
+
+&cpm_spi1 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&cpm_spi0_pins>;
+	status = "disabled";
+
+	spi-flash at 0 {
+		#address-cells = <0x1>;
+		#size-cells = <0x1>;
+		compatible = "jedec,spi-nor";
+		reg = <0x0>;
+		spi-max-frequency = <20000000>;
+
+		partitions {
+			compatible = "fixed-partitions";
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			partition at 0 {
+				label = "U-Boot";
+				reg = <0x0 0x200000>;
+			};
+
+			partition at 400000 {
+				label = "Filesystem";
+				reg = <0x200000 0xe00000>;
+			};
+		};
+	};
+};
+
+&cpm_sata0 {
+	status = "okay";
+};
+
+&cpm_usb3_0 {
+	status = "okay";
+};
+
+&cpm_usb3_1 {
+	status = "okay";
+};
+
+&cpm_comphy {
+	phy0 {
+		phy-type = <PHY_TYPE_SGMII2>;
+		phy-speed = <PHY_SPEED_3_125G>;
+	};
+
+	phy1 {
+		phy-type = <PHY_TYPE_USB3_HOST0>;
+		phy-speed = <PHY_SPEED_5G>;
+	};
+
+	phy2 {
+		phy-type = <PHY_TYPE_SGMII0>;
+		phy-speed = <PHY_SPEED_1_25G>;
+	};
+
+	phy3 {
+		phy-type = <PHY_TYPE_SATA1>;
+		phy-speed = <PHY_SPEED_5G>;
+	};
+
+	phy4 {
+		phy-type = <PHY_TYPE_USB3_HOST1>;
+		phy-speed = <PHY_SPEED_5G>;
+	};
+
+	phy5 {
+		phy-type = <PHY_TYPE_PEX2>;
+		phy-speed = <PHY_SPEED_5G>;
+	};
+};
+
+&cpm_nand {
+	status = "okay";
+};
+
+&cpm_utmi0 {
+	status = "okay";
+};
+
+&cpm_utmi1 {
+	status = "okay";
+};
+
+&ap_sdhci0 {
+	status = "okay";
+	bus-width = <4>;
+	no-1-8-v;
+	non-removable;
+};
+
+&cpm_sdhci0 {
+	status = "okay";
+	bus-width = <4>;
+	no-1-8-v;
+	non-removable;
+};
arch/arm/dts/armada-7040-db.dts +1 -0
index 63442df..3bd699d 100644
@@ -42,6 +42,7 @@
 
 /*
  * Device Tree file for Marvell Armada 7040 Development board platform
+ * Boot device: SPI NOR, 0x32 (SW3)
  */
 
 #include "armada-7040.dtsi"
arch/arm/dts/armada-cp110-master.dtsi +3 -0
index 1f0edde..d4c6cc6 100644
@@ -236,6 +236,19 @@
 				dma-coherent;
 				status = "disabled";
 			};
+			cpm_nand: nand at 720000 {
+				compatible = "marvell,mvebu-pxa3xx-nand";
+				reg = <0x720000 0x100>;

arch/arm/dts/armada-cp110-master.dtsi line 251

Quoted 10 lines
arch/arm/dts/armada-cp110-master.dtsi +10 -0
+				#address-cells = <1>;
+
+				clocks = <&cpm_syscon0 1 2>;
+				nand-enable-arbiter;
+				num-cs = <1>;
+				nand-ecc-strength = <4>;
+				nand-ecc-step-size = <512>;
+				status = "disabled";
+			};
+

This empty line should probably be added before the "cpm_nand" node.

Thanks,
Stefan

#13 lore raw

PATCH 5/5 arm64: mvebu: a8k: Add NAND configuration parameters

In reply to kostap at marvell.com

From: Konstantin Porotchkin <[email protected]>

Add NAND configuration parameters to A8K shared config file. Add defconfig for db-88f7040 board with boot from NAND setup.

Cc Stefan Roese <[email protected]>
Cc Igal Liberman <[email protected]>
Cc Nadav Haklai <[email protected]>
---
 configs/mvebu_db-88f7040-nand_defconfig | 72 +++++++++++++++++++++++++++++++++
 include/configs/mvebu_armada-8k.h       | 11 +++++
 2 files changed, 83 insertions(+)
 create mode 100644 configs/mvebu_db-88f7040-nand_defconfig
configs/mvebu_db-88f7040-nand_defconfig new file +72 -0
new file mode 100644
index 0000000..d86c18e
@@ -0,0 +1,72 @@
+CONFIG_ARM=y
+CONFIG_ARCH_MVEBU=y
+CONFIG_SYS_MALLOC_F_LEN=0x2000
+CONFIG_TARGET_MVEBU_ARMADA_8K=y
+CONFIG_DEFAULT_DEVICE_TREE="armada-7040-db-nand"
+CONFIG_SMBIOS_PRODUCT_NAME=""
+CONFIG_AHCI=y
+# CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
+CONFIG_SYS_CONSOLE_INFO_QUIET=y
+CONFIG_BOARD_LATE_INIT=y
+# CONFIG_DISPLAY_CPUINFO is not set
+# CONFIG_DISPLAY_BOARDINFO is not set
+CONFIG_ARCH_EARLY_INIT_R=y
+CONFIG_BOARD_EARLY_INIT_F=y
+CONFIG_HUSH_PARSER=y
+# CONFIG_CMD_IMLS is not set
+# CONFIG_CMD_FLASH is not set
+CONFIG_CMD_MMC=y
+CONFIG_CMD_PART=y
+CONFIG_CMD_SF=y
+CONFIG_CMD_SPI=y
+CONFIG_CMD_I2C=y
+CONFIG_CMD_USB=y
+CONFIG_CMD_NAND=y
+# CONFIG_CMD_FPGA is not set
+# CONFIG_CMD_SETEXPR is not set
+CONFIG_CMD_TFTPPUT=y
+CONFIG_CMD_DHCP=y
+CONFIG_CMD_MII=y
+CONFIG_CMD_PING=y
+CONFIG_CMD_CACHE=y
+CONFIG_CMD_TIME=y
+CONFIG_CMD_MVEBU_BUBT=y
+CONFIG_CMD_EXT4=y
+CONFIG_CMD_EXT4_WRITE=y
+CONFIG_CMD_FAT=y
+CONFIG_CMD_FS_GENERIC=y
+CONFIG_MAC_PARTITION=y
+CONFIG_ISO_PARTITION=y
+CONFIG_EFI_PARTITION=y
+CONFIG_BLOCK_CACHE=y
+CONFIG_DM_I2C=y
+CONFIG_SYS_I2C_MVTWSI=y
+CONFIG_MISC=y
+CONFIG_DM_MMC=y
+CONFIG_MMC_SDHCI=y
+CONFIG_MMC_SDHCI_XENON=y
+CONFIG_SPI_FLASH=y
+CONFIG_SPI_FLASH_MACRONIX=y
+CONFIG_SPI_FLASH_SPANSION=y
+CONFIG_SPI_FLASH_STMICRO=y
+CONFIG_MVEBU_NAND_BOOT=y
+CONFIG_NAND_PXA3XX=y
+CONFIG_PHYLIB=y
+CONFIG_PCI=y
+CONFIG_DM_PCI=y
+CONFIG_PCIE_DW_MVEBU=y
+CONFIG_MVEBU_COMPHY_SUPPORT=y
+CONFIG_PINCTRL=y
+# CONFIG_SPL_SERIAL_PRESENT is not set
+CONFIG_DEBUG_UART=y
+CONFIG_DEBUG_UART_BASE=0xf0512000
+CONFIG_DEBUG_UART_CLOCK=200000000
+CONFIG_DEBUG_UART_SHIFT=2
+CONFIG_DEBUG_UART_ANNOUNCE=y
+CONFIG_SYS_NS16550=y
+CONFIG_USB=y
+CONFIG_DM_USB=y
+CONFIG_USB_XHCI_HCD=y
+CONFIG_USB_EHCI_HCD=y
+CONFIG_USB_STORAGE=y
+CONFIG_SMBIOS_MANUFACTURER=""
include/configs/mvebu_armada-8k.h +11 -0
index a8a9d15..839abd9 100644
@@ -76,11 +76,22 @@
 #define CONFIG_ENV_SPI_MODE		CONFIG_SF_DEFAULT_MODE
 
 /* Environment in SPI NOR flash */
+#ifdef CONFIG_MVEBU_SPI_BOOT
 #define CONFIG_ENV_IS_IN_SPI_FLASH
+/* Environment in NAND flash */
+#elif defined(CONFIG_MVEBU_NAND_BOOT)
+#define CONFIG_ENV_IS_IN_NAND
+#endif
+
 #define CONFIG_ENV_OFFSET		0x180000 /* as Marvell U-Boot version */
 #define CONFIG_ENV_SIZE			(64 << 10) /* 64KiB */
 #define CONFIG_ENV_SECT_SIZE		(64 << 10) /* 64KiB sectors */
 
+#define CONFIG_SYS_MAX_NAND_DEVICE	1
+#define CONFIG_SYS_NAND_MAX_CHIPS	1
+#define CONFIG_SYS_NAND_ONFI_DETECTION
+#define CONFIG_SYS_NAND_USE_FLASH_BBT
+
 /* USB 2.0 */
 #define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS 3
 
Signature · 1 line
2.7.4
#14 lore raw

PATCH 5/5 arm64: mvebu: a8k: Add NAND configuration parameters

Hi Kosta,

Quoted 9 lines · kostap at marvell.com

From: Konstantin Porotchkin <[email protected]>

Add NAND configuration parameters to A8K shared config file. Add defconfig for db-88f7040 board with boot from NAND setup.

Cc Stefan Roese <[email protected]>
Cc Igal Liberman <[email protected]>
Cc Nadav Haklai <[email protected]>
Quoted 5 lines
---
 configs/mvebu_db-88f7040-nand_defconfig | 72 +++++++++++++++++++++++++++++++++
 include/configs/mvebu_armada-8k.h       | 11 +++++
 2 files changed, 83 insertions(+)
 create mode 100644 configs/mvebu_db-88f7040-nand_defconfig

I'm currently testing this patchset and get this compilation error via Travis:

aarch64: + mvebu_db-88f7040-nand
+drivers/mtd/nand/pxa3xx_nand.c: In function alloc_nand_resource:
+drivers/mtd/nand/pxa3xx_nand.c:1513:36: error: MVEBU_NAND_BASE undeclared (first use in this function)
+ info->mmio_base = (void __iomem *)MVEBU_NAND_BASE;

Did I miss a patch that adds this macro for A7/8k?

Thanks,
Stefan

#15 lore raw

[U-Boot] [EXT] Re: [PATCH 5/5] arm64: mvebu: a8k: Add NAND configuration parameters

Hi, Stefan,

Quoted 39 lines

-----Original Message-----
From: Stefan Roese [mailto:sr at denx.de]
Sent: Wednesday, April 19, 2017 11:45
To: Kostya Porotchkin; u-boot at lists.denx.de
Cc: Igal Liberman; Nadav Haklai
Subject: [EXT] Re: [PATCH 5/5] arm64: mvebu: a8k: Add NAND configuration parameters

External Email

----------------------------------------------------------------------
Hi Kosta,

Quoted 11 lines · kostap at marvell.com

From: Konstantin Porotchkin <[email protected]>

Add NAND configuration parameters to A8K shared config file. Add defconfig for db-88f7040 board with boot from NAND setup.

Cc Stefan Roese <[email protected]>
Cc Igal Liberman <[email protected]>
Cc Nadav Haklai <[email protected]>
---
 configs/mvebu_db-88f7040-nand_defconfig | 72

+++++++++++++++++++++++++++++++++

Quoted 3 lines
 include/configs/mvebu_armada-8k.h       | 11 +++++
 2 files changed, 83 insertions(+)
 create mode 100644 configs/mvebu_db-88f7040-nand_defconfig

I'm currently testing this patchset and get this compilation error via Travis:

   aarch64:  +   mvebu_db-88f7040-nand
(quoted diff) +4 -0
+drivers/mtd/nand/pxa3xx_nand.c: In function alloc_nand_resource:
+drivers/mtd/nand/pxa3xx_nand.c:1513:36: error: MVEBU_NAND_BASE
+undeclared (first use in this function)
+  info->mmio_base = (void __iomem *)MVEBU_NAND_BASE;
Quoted 1 line

Did I miss a patch that adds this macro for A7/8k?

[Konstantin Porotchkin]
The hardcoded values should be changed in the following patch:
[PATCH 1/5] fix: nand: pxa3xx: Remove hardcode values from the driver However I do not see it on patchworks site.
Should I re-send it?

Thanks
Kosta

Quoted 3 lines

Thanks,
Stefan

#16 lore raw

[U-Boot] [EXT] Re: [PATCH 5/5] arm64: mvebu: a8k: Add NAND configuration parameters

Hi Kosta,

Quoted 41 lines · Kostya Porotchkin

Hi, Stefan,

Quoted 39 lines

-----Original Message-----
From: Stefan Roese [mailto:sr at denx.de]
Sent: Wednesday, April 19, 2017 11:45
To: Kostya Porotchkin; u-boot at lists.denx.de
Cc: Igal Liberman; Nadav Haklai
Subject: [EXT] Re: [PATCH 5/5] arm64: mvebu: a8k: Add NAND configuration parameters

External Email

----------------------------------------------------------------------
Hi Kosta,

Quoted 11 lines · kostap at marvell.com

From: Konstantin Porotchkin <[email protected]>

Add NAND configuration parameters to A8K shared config file. Add defconfig for db-88f7040 board with boot from NAND setup.

Cc Stefan Roese <[email protected]>
Cc Igal Liberman <[email protected]>
Cc Nadav Haklai <[email protected]>
---
 configs/mvebu_db-88f7040-nand_defconfig | 72

+++++++++++++++++++++++++++++++++

Quoted 3 lines
 include/configs/mvebu_armada-8k.h       | 11 +++++
 2 files changed, 83 insertions(+)
 create mode 100644 configs/mvebu_db-88f7040-nand_defconfig

I'm currently testing this patchset and get this compilation error via Travis:

   aarch64:  +   mvebu_db-88f7040-nand
(quoted diff) +4 -0
+drivers/mtd/nand/pxa3xx_nand.c: In function alloc_nand_resource:
+drivers/mtd/nand/pxa3xx_nand.c:1513:36: error: MVEBU_NAND_BASE
+undeclared (first use in this function)
+  info->mmio_base = (void __iomem *)MVEBU_NAND_BASE;
Quoted 6 lines
Quoted 1 line

Did I miss a patch that adds this macro for A7/8k?

[Konstantin Porotchkin]
The hardcoded values should be changed in the following patch:
[PATCH 1/5] fix: nand: pxa3xx: Remove hardcode values from the driver However I do not see it on patchworks site.
Should I re-send it?

No need. I've found it in my inbox. Travis build is already restarted...

Thanks,
Stefan