Skip to contentSkip to conversation

nand: Add zynq nand controller driver support

PATCH New Siva Durga Prasad Paladugu 5 participants 12 messages Feb 17, 2014 – Feb 28, 2014 1 message not in the archive

Subsystems (4)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH v3 1/7 nand: Add zynq nand controller driver support

From: Jagannadha Sutradharudu Teki <[email protected]>

Added support for Zynq Nand controller driver.

---
Changes for v3:
-Fixed all review comments on v1 as
some comments are not fixed on v2.
-Separeted out the nand patch series
as per Michal comment.
Changes for v2:
-Fixed issues pointed by Scott

---
 README                                    |    3 +
 arch/arm/include/asm/arch-zynq/hardware.h |    2 +
 drivers/mtd/nand/Makefile                 |    1 +
 drivers/mtd/nand/zynq_nand.c              | 1188 +++++++++++++++++++++++++++++
 4 files changed, 1194 insertions(+), 0 deletions(-)
 create mode 100755 drivers/mtd/nand/zynq_nand.c
README +3 -0
index fe48ccd..b1974b9 100644
@@ -3950,6 +3950,9 @@ but it can not erase, write this NOR flash by SRIO or PCIE interface.
 	environment. If redundant environment is used, it will be copied to
 	CONFIG_NAND_ENV_DST + CONFIG_ENV_SIZE.
 
+- CONFIG_NAND_ZYNQ
+	Define this for enabling zynq nand controller with onfi detection support.
+
 - CONFIG_ENV_IS_IN_UBI:
 
 	Define this if you have an UBI volume that you want to use for the
arch/arm/include/asm/arch-zynq/hardware.h +2 -0
index cd69677..2e504cf 100644
@@ -19,6 +19,8 @@
 #define ZYNQ_I2C_BASEADDR1		0xE0005000
 #define ZYNQ_SPI_BASEADDR0		0xE0006000
 #define ZYNQ_SPI_BASEADDR1		0xE0007000
+#define ZYNQ_SMC_BASEADDR		0xE000E000
+#define ZYNQ_NAND_BASEADDR		0xE1000000
 #define ZYNQ_DDRC_BASEADDR		0xF8006000
 
 /* Reflect slcr offsets */
drivers/mtd/nand/Makefile +1 -0
index 02b149c..abe9330 100644
@@ -59,6 +59,7 @@ obj-$(CONFIG_NAND_OMAP_GPMC) += omap_gpmc.o
 obj-$(CONFIG_NAND_OMAP_ELM) += omap_elm.o
 obj-$(CONFIG_NAND_PLAT) += nand_plat.o
 obj-$(CONFIG_NAND_DOCG4) += docg4.o
+obj-$(CONFIG_NAND_ZYNQ) += zynq_nand.o
 
 else  # minimal SPL drivers
 
drivers/mtd/nand/zynq_nand.c new file +1188 -0

1,188 lines not on this page · raw message

Signature · 1 line
1.7.4
#2 lore raw

PATCH v3 1/7 nand: Add zynq nand controller driver support

Hi Scott,

Quoted 14 lines · Siva Durga Prasad Paladugu

From: Jagannadha Sutradharudu Teki <[email protected]>

Added support for Zynq Nand controller driver.

---
Changes for v3:
-Fixed all review comments on v1 as
some comments are not fixed on v2.
-Separeted out the nand patch series
as per Michal comment.
Changes for v2:
-Fixed issues pointed by Scott

Quoted 7 lines
---
 README                                    |    3 +
 arch/arm/include/asm/arch-zynq/hardware.h |    2 +
 drivers/mtd/nand/Makefile                 |    1 +
 drivers/mtd/nand/zynq_nand.c              | 1188 +++++++++++++++++++++++++++++
 4 files changed, 1194 insertions(+), 0 deletions(-)
 create mode 100755 drivers/mtd/nand/zynq_nand.c

One note: Here is incorrect file permission.

Can you please review this driver?
Patches 2-7 should go through ARM tree but this first one should go through your tree.

Thanks,
Michal

Signature · 14 lines
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Microblaze cpu - http://www.monstr.eu/fdt/
Maintainer of Linux kernel - Xilinx Zynq ARM architecture
Microblaze U-BOOT custodian and responsible for u-boot arm zynq platform


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 263 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140225/f9560203/attachment.pgp>
#3 lore raw

PATCH v3 1/7 nand: Add zynq nand controller driver support

In reply to Siva Durga Prasad Paladugu
Quoted 13 lines · Siva Durga Prasad Paladugu
drivers/mtd/nand/zynq_nand.c new file +13 -0
+/* Generic flash bbt decriptors */
+static u8 bbt_pattern[] = {'B', 'b', 't', '0' };
+static u8 mirror_pattern[] = {'1', 't', 'b', 'B' };
+
+static struct nand_bbt_descr bbt_main_descr = {
+	.options = NAND_BBT_LASTBLOCK | NAND_BBT_CREATE | NAND_BBT_WRITE |
+		NAND_BBT_2BIT | NAND_BBT_VERSION | NAND_BBT_PERCHIP,
+	.offs = 4,
+	.len = 4,
+	.veroffs = 20,
+	.maxblocks = 4,
+	.pattern = bbt_pattern
+};

drivers/mtd/nand/zynq_nand.c line 206

Quoted 10 lines
drivers/mtd/nand/zynq_nand.c new file +10 -0
+
+static struct nand_bbt_descr bbt_mirror_descr = {
+	.options = NAND_BBT_LASTBLOCK | NAND_BBT_CREATE | NAND_BBT_WRITE |
+		NAND_BBT_2BIT | NAND_BBT_VERSION | NAND_BBT_PERCHIP,
+	.offs = 4,
+	.len = 4,
+	.veroffs = 20,
+	.maxblocks = 4,
+	.pattern = mirror_pattern
+};

If this BBT description is only for chips with on-die ECC, chips with 64-byte OOB, etc., say so in a comment -- and don't label them "Generic flash bbt descriptors". :-)

Quoted 52 lines
drivers/mtd/nand/zynq_nand.c new file +52 -0
+/*
+ * onehot - onehot function
+ * @value:	value to check for onehot
+ *
+ * This function checks whether a value is onehot or not.
+ * onehot is if and only if one bit is set.
+ *
+ * FIXME: Try to move this in common.h
+ */
+static bool onehot(unsigned short value)
+{
+	bool onehot;
+
+	onehot = value && !(value & (value - 1));
+	return onehot;
+}
+
+/*
+ * zynq_nand_correct_data - ECC correction function
+ * @mtd:	Pointer to the mtd_info structure
+ * @buf:	Pointer to the page data
+ * @read_ecc:	Pointer to the ECC value read from spare data area
+ * @calc_ecc:	Pointer to the calculated ECC value
+ *
+ * This function corrects the ECC single bit errors & detects 2-bit errors.
+ *
+ * returns:	0 if no ECC errors found
+ *		1 if single bit error found and corrected.
+ *		-1 if multiple ECC errors found.
+ */
+static int zynq_nand_correct_data(struct mtd_info *mtd, unsigned char *buf,
+			unsigned char *read_ecc, unsigned char *calc_ecc)
+{
+	unsigned char bit_addr;
+	unsigned int byte_addr;
+	unsigned short ecc_odd, ecc_even;
+	unsigned short read_ecc_lower, read_ecc_upper;
+	unsigned short calc_ecc_lower, calc_ecc_upper;
+
+	read_ecc_lower = (read_ecc[0] | (read_ecc[1] << 8)) & 0xfff;
+	read_ecc_upper = ((read_ecc[1] >> 4) | (read_ecc[2] << 4)) & 0xfff;
+
+	calc_ecc_lower = (calc_ecc[0] | (calc_ecc[1] << 8)) & 0xfff;
+	calc_ecc_upper = ((calc_ecc[1] >> 4) | (calc_ecc[2] << 4)) & 0xfff;
+
+	ecc_odd = read_ecc_lower ^ calc_ecc_lower;
+	ecc_even = read_ecc_upper ^ calc_ecc_upper;
+
+	if ((ecc_odd == 0) && (ecc_even == 0))
+		return 0;       /* no error */
+
+	if (ecc_odd == (~ecc_even & 0xfff)) {

drivers/mtd/nand/zynq_nand.c line 378

Quoted 10 lines
drivers/mtd/nand/zynq_nand.c new file +10 -0
+		/* bits [11:3] of error code is byte offset */
+		byte_addr = (ecc_odd >> 3) & 0x1ff;
+		/* bits [2:0] of error code is bit offset */
+		bit_addr = ecc_odd & 0x7;
+		/* Toggling error bit */
+		buf[byte_addr] ^= (1 << bit_addr);
+		return 1;
+	}
+
+	if (onehot(ecc_odd | ecc_even) == 1)

Why are you comparing a bool to an integer?

drivers/mtd/nand/zynq_nand.c line 844

Quoted 4 lines
drivers/mtd/nand/zynq_nand.c new file +4 -0
+	} else if (page_addr != -1) /* Erase */
+		cmd_data = page_addr;
+	else if (column != -1) { /* Change read/write column, read id etc */
+		/* Adjust columns for 16 bit bus width */

Please use braces here.

Quoted 16 lines
drivers/mtd/nand/zynq_nand.c new file +16 -0
+		if ((chip->options & NAND_BUSWIDTH_16) &&
+		    ((command == NAND_CMD_READ0) ||
+		     (command == NAND_CMD_SEQIN) ||
+		     (command == NAND_CMD_RNDOUT) ||
+		     (command == NAND_CMD_RNDIN)))
+			column >>= 1;
+		cmd_data = column;
+	}
+
+	writel(cmd_data, cmd_addr);
+
+	if (curr_cmd->end_cmd_valid) {
+		xnand->end_cmd = curr_cmd->end_cmd;
+		xnand->end_cmd_pending = 1;
+	}
+

drivers/mtd/nand/zynq_nand.c line 870

Quoted 10 lines
drivers/mtd/nand/zynq_nand.c new file +10 -0
+	ndelay(100);
+
+	if ((command == NAND_CMD_READ0) ||
+	    (command == NAND_CMD_RESET) ||
+	    (command == NAND_CMD_PARAM) ||
+	    (command == NAND_CMD_GET_FEATURES))
+		/* wait until command is processed */
+		nand_wait_ready(mtd);
+
+}

Don't put newlines before an ending brace.

Quoted 19 lines
drivers/mtd/nand/zynq_nand.c new file +19 -0
+
+/*
+ * zynq_nand_read_buf - read chip data into buffer
+ * @mtd:        MTD device structure
+ * @buf:        buffer to store date
+ * @len:        number of bytes to read
+ */
+static void zynq_nand_read_buf(struct mtd_info *mtd, u8 *buf, int len)
+{
+	struct nand_chip *chip = mtd->priv;
+
+	/* Make sure that buf is 32 bit aligned */
+	if (((int)buf & 0x3) != 0) {
+		if (((int)buf & 0x1) != 0) {
+			if (len) {
+				*buf = readb(chip->IO_ADDR_R);
+				buf += 1;
+				len--;
+			}

drivers/mtd/nand/zynq_nand.c line 899

Quoted 10 lines
drivers/mtd/nand/zynq_nand.c new file +10 -0
+		}
+
+		if (((int)buf & 0x3) != 0) {
+			if (len >= 2) {
+				*(u16 *)buf = readw(chip->IO_ADDR_R);
+				buf += 2;
+				len -= 2;
+			}
+		}
+	}

Cast pointers to "unsigned long" or "uintptr_t", not "int".

Doesn't the casting of buf violate C99 aliasing rules? You can access arbitrary pointers as char pointers, but not the other way around.

drivers/mtd/nand/zynq_nand.c line 1009

Quoted 7 lines
drivers/mtd/nand/zynq_nand.c new file +7 -0
+	xnand = calloc(1, sizeof(struct zynq_nand_info));
+	if (!xnand) {
+		printf("%s: failed to allocate\n", __func__);
+		goto free;
+	}
+
+	xnand->nand_base = (void *)ZYNQ_NAND_BASEADDR;

This is a bit confusing -- ZYNQ_NAND_BASEADDR looks like an I/O address, but you don't have __iomem and aren't using I/O accessors, and the contents appear to be normal software data.

drivers/mtd/nand/zynq_nand.c line 1063

Quoted 12 lines
drivers/mtd/nand/zynq_nand.c new file +12 -0
+	if ((maf_id == 0x2c) && ((dev_id == 0xf1) ||
+				 (dev_id == 0xa1) || (dev_id == 0xb1) ||
+				 (dev_id == 0xaa) || (dev_id == 0xba) ||
+				 (dev_id == 0xda) || (dev_id == 0xca) ||
+				 (dev_id == 0xac) || (dev_id == 0xbc) ||
+				 (dev_id == 0xdc) || (dev_id == 0xcc) ||
+				 (dev_id == 0xa3) || (dev_id == 0xb3) ||
+				 (dev_id == 0xd3) || (dev_id == 0xc3))) {
+		nand_chip->cmdfunc(mtd, NAND_CMD_SET_FEATURES,
+						ONDIE_ECC_FEATURE_ADDR, -1);
+		for (i = 0; i < 4; i++)
+			writeb(set_feature[i], nand_chip->IO_ADDR_W);

I wonder how much of this on-die ECC stuff belongs in the common code rathen than a controller driver.

drivers/mtd/nand/zynq_nand.c line 1076

Quoted 12 lines
drivers/mtd/nand/zynq_nand.c new file +12 -0
+		/* Wait for 1us after writing data with SET_FEATURES command */
+		ndelay(1000);
+
+		nand_chip->cmdfunc(mtd, NAND_CMD_GET_FEATURES,
+						ONDIE_ECC_FEATURE_ADDR, -1);
+		nand_chip->read_buf(mtd, get_feature, 4);
+
+		if (get_feature[0] & ONDIE_ECC_FEATURE_ENABLE) {
+			debug("%s: OnDie ECC flash\n", __func__);
+			ondie_ecc_enabled = 1;
+		} else {
+			printf("%s: Unable to detect OnDie ECC\n", __func__);

Why does the lack of on-die ECC warrant a message?

drivers/mtd/nand/zynq_nand.c line 1084

Quoted 5 lines
drivers/mtd/nand/zynq_nand.c new file +5 -0
+	if (ondie_ecc_enabled) {
+		/* Bypass the controller ECC block */
+		ecc_cfg = readl(&zynq_nand_smc_base->emcr);
+		ecc_cfg &= ~0xc;
+		writel(ecc_cfg, &zynq_nand_smc_base->emcr);

What is 0xc? Don't use magic numbers.

Quoted 15 lines
drivers/mtd/nand/zynq_nand.c new file +15 -0
+		/* The software ECC routines won't work
+		 * with the SMC controller
+		 */
+		nand_chip->ecc.mode = NAND_ECC_HW;
+		nand_chip->ecc.strength = 1;
+		nand_chip->ecc.read_page = zynq_nand_read_page_raw_nooob;
+		nand_chip->ecc.read_subpage = zynq_nand_read_subpage_raw;
+		nand_chip->ecc.write_page = zynq_nand_write_page_raw;
+		nand_chip->ecc.read_page_raw = zynq_nand_read_page_raw;
+		nand_chip->ecc.write_page_raw = zynq_nand_write_page_raw;
+		nand_chip->ecc.read_oob = zynq_nand_read_oob;
+		nand_chip->ecc.write_oob = zynq_nand_write_oob;
+		nand_chip->ecc.size = mtd->writesize;
+		nand_chip->ecc.bytes = 0;
+

drivers/mtd/nand/zynq_nand.c line 1110

Quoted 10 lines
drivers/mtd/nand/zynq_nand.c new file +10 -0
+		/* NAND with on-die ECC supports subpage reads */
+		nand_chip->options |= NAND_SUBPAGE_READ;
+
+		/* On-Die ECC spare bytes offset 8 is used for ECC codes */
+		if (ondie_ecc_enabled) {
+			nand_chip->ecc.layout = &ondie_nand_oob_64;
+			/* Use the BBT pattern descriptors */
+			nand_chip->bbt_td = &bbt_main_descr;
+			nand_chip->bbt_md = &bbt_mirror_descr;
+		}

On-die ECC implies 64 bytes of OOB?

Quoted 35 lines
drivers/mtd/nand/zynq_nand.c new file +35 -0
+	} else {
+		/* Hardware ECC generates 3 bytes ECC code for each 512 bytes */
+		nand_chip->ecc.mode = NAND_ECC_HW;
+		nand_chip->ecc.strength = 1;
+		nand_chip->ecc.size = ZYNQ_NAND_ECC_SIZE;
+		nand_chip->ecc.bytes = 3;
+		nand_chip->ecc.calculate = zynq_nand_calculate_hwecc;
+		nand_chip->ecc.correct = zynq_nand_correct_data;
+		nand_chip->ecc.hwctl = NULL;
+		nand_chip->ecc.read_page = zynq_nand_read_page_hwecc;
+		nand_chip->ecc.write_page = zynq_nand_write_page_hwecc;
+		nand_chip->ecc.read_page_raw = zynq_nand_read_page_raw;
+		nand_chip->ecc.write_page_raw = zynq_nand_write_page_raw;
+		nand_chip->ecc.read_oob = zynq_nand_read_oob;
+		nand_chip->ecc.write_oob = zynq_nand_write_oob;
+
+		switch (mtd->writesize) {
+		case 512:
+			ecc_page_size = 0x1;
+			/* Set the ECC memory config register */
+			writel((ZYNQ_NAND_ECC_CONFIG | ecc_page_size),
+			       &zynq_nand_smc_base->emcr);
+			break;
+		case 1024:
+			ecc_page_size = 0x2;
+			/* Set the ECC memory config register */
+			writel((ZYNQ_NAND_ECC_CONFIG | ecc_page_size),
+			       &zynq_nand_smc_base->emcr);
+			break;
+		case 2048:
+			ecc_page_size = 0x3;
+			/* Set the ECC memory config register */
+			writel((ZYNQ_NAND_ECC_CONFIG | ecc_page_size),
+			       &zynq_nand_smc_base->emcr);
+			break;

drivers/mtd/nand/zynq_nand.c line 1155

Quoted 10 lines
drivers/mtd/nand/zynq_nand.c new file +10 -0
+		default:
+			/* The software ECC routines won't work with
+			 * the SMC controller
+			 */
+			nand_chip->ecc.mode = NAND_ECC_SOFT;
+			nand_chip->ecc.calculate = nand_calculate_ecc;
+			nand_chip->ecc.correct = nand_correct_data;
+			nand_chip->ecc.read_page = zynq_nand_read_page_swecc;
+			nand_chip->ecc.write_page = zynq_nand_write_page_swecc;
+			nand_chip->ecc.size = 256;

What's going on here? Are you using soft ECC or not?

drivers/mtd/nand/zynq_nand.c line 1163

Quoted 8 lines
drivers/mtd/nand/zynq_nand.c new file +8 -0
+			break;
+		}
+
+		if (mtd->oobsize == 16)
+			nand_chip->ecc.layout = &nand_oob_16;
+		else if (mtd->oobsize == 64)
+			nand_chip->ecc.layout = &nand_oob_64;
+	}

What if oobsize > 64?

drivers/mtd/nand/zynq_nand.c line 1167

Quoted 4 lines
drivers/mtd/nand/zynq_nand.c new file +4 -0
+
+	/* Second phase scan */
+	if (nand_scan_tail(mtd)) {
+		printf("%s: nand_scan_tailfailed\n", __func__);

s/tailfailed/tail failed/

-Scott

#4 lore raw

PATCH v3 2/7 zynq-common: Define CONFIG_NAND_ZYNQ

In reply to a message not in the archive

From: Jagannadha Sutradharudu Teki <[email protected]>

Defined CONFIG_NAND_ZYNQ for enabling zynq nand controller with onfi detection support.

---
Changes for v3:
-Separated out the nand patch series
as per Michal comment.
Changes for v2:
-None

---
 include/configs/zynq-common.h |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
include/configs/zynq-common.h +10 -0
index e7a8e9f..08adaa2 100644
@@ -91,6 +91,16 @@
 # define CONFIG_SYS_FLASH_USE_BUFFER_WRITE
 #endif
 
+/* NAND */
+#ifdef CONFIG_NAND_ZYNQ
+# define CONFIG_CMD_NAND
+# define CONFIG_CMD_NAND_LOCK_UNLOCK
+# define CONFIG_SYS_MAX_NAND_DEVICE	1
+# define CONFIG_SYS_NAND_SELF_INIT
+# define CONFIG_SYS_NAND_ONFI_DETECTION
+# define CONFIG_MTD_DEVICE
+#endif
+
 /* MMC */
 #if defined(CONFIG_ZYNQ_SDHCI0) || defined(CONFIG_ZYNQ_SDHCI1)
 # define CONFIG_MMC
Signature · 1 line
1.7.4
#5 lore raw

PATCH v3 3/7 zynq: Add zynq_zc770 xm011 board support

In reply to a message not in the archive

From: Jagannadha Sutradharudu Teki <[email protected]>

ZC770 is a complete development board based on the Xilinx Zynq-7000 All Programmable SoC, similar to ZC70x board but which has four different daughter cards, like XM010, XM011, XM012 and XM013

ZC770 XM011:
- 1GB DDR3
- 8 and 16-bit Micron NAND devices
- USB-UART

---
Changes for v3:
-Separated out the nand patch series
as per Michal comment.
Changes for v2:
-None

---
 boards.cfg                   |    1 +
 include/configs/zynq_zc770.h |    4 ++++
 2 files changed, 5 insertions(+), 0 deletions(-)
boards.cfg +1 -0
index c97c4bd..5743565 100644
@@ -360,6 +360,7 @@ Active  arm         armv7          vf610       freescale       vf610twr
 Active  arm         armv7          zynq        xilinx          zynq                zynq_microzed                        -                                                                                                                                 Michal Simek <[email protected]>:Jagannadha Sutradharudu Teki <[email protected]>
 Active  arm         armv7          zynq        xilinx          zynq                zynq_zc70x                           -                                                                                                                                 Michal Simek <[email protected]>:Jagannadha Sutradharudu Teki <[email protected]>
 Active  arm         armv7          zynq        xilinx          zynq                zynq_zc770_xm010                     zynq_zc770:ZC770_XM010                                                                                                            Michal Simek <[email protected]>:Jagannadha Sutradharudu Teki <[email protected]>
+Active  arm         armv7          zynq        xilinx          zynq                zynq_zc770_xm011                     zynq_zc770:ZC770_XM011                                                                                                            Michal Simek <[email protected]>:Jagannadha Sutradharudu Teki <[email protected]>
 Active  arm         armv7          zynq        xilinx          zynq                zynq_zc770_xm012                     zynq_zc770:ZC770_XM012                                                                                                            Michal Simek <[email protected]>:Jagannadha Sutradharudu Teki <[email protected]>
 Active  arm         armv7          zynq        xilinx          zynq                zynq_zc770_xm013                     zynq_zc770:ZC770_XM013                                                                                                            Michal Simek <[email protected]>:Jagannadha Sutradharudu Teki <[email protected]>
 Active  arm         armv7          zynq        xilinx          zynq                zynq_zed                             -                                                                                                                                 Michal Simek <[email protected]>:Jagannadha Sutradharudu Teki <[email protected]>
include/configs/zynq_zc770.h +4 -0
index 8aa96e7..b7765db 100644
@@ -22,6 +22,10 @@
 # define CONFIG_ZYNQ_SPI
 # define CONFIG_DEFAULT_DEVICE_TREE	zynq-zc770-xm010
 
+#elif defined(CONFIG_ZC770_XM011)
+# define CONFIG_ZYNQ_SERIAL_UART1
+# define CONFIG_NAND_ZYNQ
+
 #elif defined(CONFIG_ZC770_XM012)
 # define CONFIG_ZYNQ_SERIAL_UART1
 # undef CONFIG_SYS_NO_FLASH
Signature · 1 line
1.7.4
#6 lore raw

PATCH v3 4/7 zynq: zc770: Add base dts for zc770_xm011

In reply to a message not in the archive

From: Jagannadha Sutradharudu Teki <[email protected]>

Added base dts support for zc770_xm011 (nand) board.

---
Changes for v3:
-Separated out the nand patch series
as per Michal comment.
Changes for v2:
-None

---
 board/xilinx/dts/zynq-zc770-xm011.dts |   14 ++++++++++++++
 include/configs/zynq_zc770.h          |    1 +
 2 files changed, 15 insertions(+), 0 deletions(-)
 create mode 100644 board/xilinx/dts/zynq-zc770-xm011.dts
board/xilinx/dts/zynq-zc770-xm011.dts new file +14 -0
new file mode 100644
index 0000000..c61a4b3
@@ -0,0 +1,14 @@
+/*
+ * Xilinx ZC770 XM011 board DTS
+ *
+ * Copyright (C) 2014 Xilinx, Inc.
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+/dts-v1/;
+#include "zynq-7000.dtsi"
+
+/ {
+	model = "Zynq ZC770 XM011 Board";
+	compatible = "xlnx,zynq-zc770-xm011", "xlnx,zynq-7000";
+};
include/configs/zynq_zc770.h +1 -0
index b7765db..d16ce0b 100644
@@ -25,6 +25,7 @@
 #elif defined(CONFIG_ZC770_XM011)
 # define CONFIG_ZYNQ_SERIAL_UART1
 # define CONFIG_NAND_ZYNQ
+# define CONFIG_DEFAULT_DEVICE_TREE	zynq-zc770-xm011
 
 #elif defined(CONFIG_ZC770_XM012)
 # define CONFIG_ZYNQ_SERIAL_UART1
Signature · 1 line
1.7.4
#7 lore raw

PATCH v3 5/7 zynq: Add support for auto nandboot

In reply to a message not in the archive

From: Jagannadha Sutradharudu Teki <[email protected]>

Added support to find the nand bootmode and also
updated the default env. with nandboot.

---
Changes for v3:
-Separated out the nand patch series
as per Michal comment.
Changes for v2:
-None

---
 board/xilinx/zynq/board.c     |    4 ++++
 doc/README.zynq               |    3 ++-
 include/configs/zynq-common.h |    3 +++
 3 files changed, 9 insertions(+), 1 deletions(-)
board/xilinx/zynq/board.c +4 -0
index 5a47149..9dd158c 100644
@@ -15,6 +15,7 @@ DECLARE_GLOBAL_DATA_PTR;
 /* Bootmode setting values */
 #define ZYNQ_BM_MASK		0x0F
 #define ZYNQ_BM_NOR		0x02
+#define ZYNQ_BM_NAND		0x04
 #define ZYNQ_BM_SD		0x05
 #define ZYNQ_BM_JTAG		0x0
 
@@ -75,6 +76,9 @@ int board_late_init(void)
 	case ZYNQ_BM_NOR:
 		setenv("modeboot", "norboot");
 		break;
+	case ZYNQ_BM_NAND:
+		setenv("modeboot", "nandboot");
+		break;
 	case ZYNQ_BM_SD:
 		setenv("modeboot", "sdboot");
 		break;
doc/README.zynq +2 -1
index 043c970..e0b38cf 100644
@@ -54,10 +54,11 @@ is intern used in autoboot.
 
 SLCR bootmode register Bit[3:0] values
 #define ZYNQ_BM_NOR		0x02
+#define ZYNQ_BM_NOR		0x04
 #define ZYNQ_BM_SD		0x05
 #define ZYNQ_BM_JTAG		0x0
 
-"modeboot" variable can assign any of "norboot", "sdboot" or "jtagboot"
+"modeboot" variable can assign any of "norboot", "nandboot", "sdboot" or "jtagboot"
 bootmode strings at runtime.
 
 5. Mainline status
include/configs/zynq-common.h +3 -0
index 08adaa2..068e59a 100644
@@ -170,6 +170,9 @@
 	"norboot=echo Copying FIT from NOR flash to RAM... && " \
 		"cp.b ${nor_flash_off} ${load_addr} ${fit_size} && " \
 		"bootm ${load_addr}\0" \
+	"nandboot=echo Copying FIT from NAND flash to RAM... && " \
+		"nand read ${load_addr} ${flash_off} ${fit_size} && " \
+		"bootm ${load_addr}\0" \
 	"sdboot=echo Copying FIT from SD to RAM... && " \
 		"fatload mmc 0 ${load_addr} ${fit_image} && " \
 		"bootm ${load_addr}\0" \
Signature · 1 line
1.7.4
#8 lore raw

PATCH v3 5/7 zynq: Add support for auto nandboot

Quoted 63 lines · Siva Durga Prasad Paladugu

From: Jagannadha Sutradharudu Teki <[email protected]>

Added support to find the nand bootmode and also
updated the default env. with nandboot.

---
Changes for v3:
-Separated out the nand patch series
as per Michal comment.
Changes for v2:

(quoted diff) +0 -2
-None
---
 board/xilinx/zynq/board.c     |    4 ++++
 doc/README.zynq               |    3 ++-
 include/configs/zynq-common.h |    3 +++
 3 files changed, 9 insertions(+), 1 deletions(-)
board/xilinx/zynq/board.c +4 -0
index 5a47149..9dd158c 100644
@@ -15,6 +15,7 @@ DECLARE_GLOBAL_DATA_PTR;
 /* Bootmode setting values */
 #define ZYNQ_BM_MASK           0x0F
 #define ZYNQ_BM_NOR            0x02
+#define ZYNQ_BM_NAND           0x04
 #define ZYNQ_BM_SD             0x05
 #define ZYNQ_BM_JTAG           0x0
 
@@ -75,6 +76,9 @@ int board_late_init(void)
        case ZYNQ_BM_NOR:
                setenv("modeboot", "norboot");
                break;
+       case ZYNQ_BM_NAND:
+               setenv("modeboot", "nandboot");
+               break;
        case ZYNQ_BM_SD:
                setenv("modeboot", "sdboot");
                break;
doc/README.zynq +2 -1
index 043c970..e0b38cf 100644
@@ -54,10 +54,11 @@ is intern used in autoboot.
 
 SLCR bootmode register Bit[3:0] values
 #define ZYNQ_BM_NOR            0x02
+#define ZYNQ_BM_NOR            0x04
 #define ZYNQ_BM_SD             0x05
 #define ZYNQ_BM_JTAG           0x0
 
-"modeboot" variable can assign any of "norboot", "sdboot" or "jtagboot"
+"modeboot" variable can assign any of "norboot", "nandboot", "sdboot" or "jtagboot"
 bootmode strings at runtime.
 
 5. Mainline status
include/configs/zynq-common.h +0 -0
index 08adaa2..068e59a 100644

include/configs/zynq-common.h line 175

Quoted 6 lines
include/configs/zynq-common.h +3 -0
@@ -170,6 +170,9 @@
        "norboot=echo Copying FIT from NOR flash to RAM... && " \
                "cp.b ${nor_flash_off} ${load_addr} ${fit_size} && " \
                "bootm ${load_addr}\0" \
+       "nandboot=echo Copying FIT from NAND flash to RAM... && " \
+               "nand read ${load_addr} ${flash_off} ${fit_size} && " \
+               "bootm ${load_addr}\0" \

Is there an opportunity to use 'nboot' here? i.e. nboot ${load_addr} 0 ${flash_off} (instead of nand read and bootm)

This would mean you don't waste time reading NAND you don't use and you don't have to worry about maintaining ${fit_size} whenever the kernel changes size.

Andrew Murray

Quoted 11 lines
include/configs/zynq-common.h +0 -1
        "sdboot=echo Copying FIT from SD to RAM... && " \
                "fatload mmc 0 ${load_addr} ${fit_image} && " \
                "bootm ${load_addr}\0" \
--

1.7.4

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

#9 lore raw

PATCH v3 5/7 zynq: Add support for auto nandboot

Quoted 75 lines · Andrew Murray
Quoted 63 lines · Siva Durga Prasad Paladugu

From: Jagannadha Sutradharudu Teki <[email protected]>

Added support to find the nand bootmode and also
updated the default env. with nandboot.

---
Changes for v3:
-Separated out the nand patch series
as per Michal comment.
Changes for v2:

(quoted diff) +0 -2
-None
---
 board/xilinx/zynq/board.c     |    4 ++++
 doc/README.zynq               |    3 ++-
 include/configs/zynq-common.h |    3 +++
 3 files changed, 9 insertions(+), 1 deletions(-)
board/xilinx/zynq/board.c +4 -0
index 5a47149..9dd158c 100644
@@ -15,6 +15,7 @@ DECLARE_GLOBAL_DATA_PTR;
 /* Bootmode setting values */
 #define ZYNQ_BM_MASK           0x0F
 #define ZYNQ_BM_NOR            0x02
+#define ZYNQ_BM_NAND           0x04
 #define ZYNQ_BM_SD             0x05
 #define ZYNQ_BM_JTAG           0x0
 
@@ -75,6 +76,9 @@ int board_late_init(void)
        case ZYNQ_BM_NOR:
                setenv("modeboot", "norboot");
                break;
+       case ZYNQ_BM_NAND:
+               setenv("modeboot", "nandboot");
+               break;
        case ZYNQ_BM_SD:
                setenv("modeboot", "sdboot");
                break;
doc/README.zynq +2 -1
index 043c970..e0b38cf 100644
@@ -54,10 +54,11 @@ is intern used in autoboot.
 
 SLCR bootmode register Bit[3:0] values
 #define ZYNQ_BM_NOR            0x02
+#define ZYNQ_BM_NOR            0x04
 #define ZYNQ_BM_SD             0x05
 #define ZYNQ_BM_JTAG           0x0
 
-"modeboot" variable can assign any of "norboot", "sdboot" or "jtagboot"
+"modeboot" variable can assign any of "norboot", "nandboot", "sdboot" or "jtagboot"
 bootmode strings at runtime.
 
 5. Mainline status
include/configs/zynq-common.h +0 -0
index 08adaa2..068e59a 100644

include/configs/zynq-common.h line 175

Quoted 6 lines
include/configs/zynq-common.h +3 -0
@@ -170,6 +170,9 @@
        "norboot=echo Copying FIT from NOR flash to RAM... && " \
                "cp.b ${nor_flash_off} ${load_addr} ${fit_size} && " \
                "bootm ${load_addr}\0" \
+       "nandboot=echo Copying FIT from NAND flash to RAM... && " \
+               "nand read ${load_addr} ${flash_off} ${fit_size} && " \
+               "bootm ${load_addr}\0" \

Is there an opportunity to use 'nboot' here? i.e. nboot ${load_addr} 0 ${flash_off} (instead of nand read and bootm)

Quoted 3 lines

This would mean you don't waste time reading NAND you don't use and you don't have to worry about maintaining ${fit_size} whenever the kernel changes size.

Yes - we can use, thanks for pointing.

Quoted 8 lines

Andrew Murray

Quoted 5 lines
include/configs/zynq-common.h +0 -1
        "sdboot=echo Copying FIT from SD to RAM... && " \
                "fatload mmc 0 ${load_addr} ${fit_image} && " \
                "bootm ${load_addr}\0" \
--

1.7.4

thanks!

Signature · 1 line
Jagan.
#10 lore raw

PATCH v3 5/7 zynq: Add support for auto nandboot

In reply to Siva Durga Prasad Paladugu

Hi Siva,

Quoted 46 lines · Siva Durga Prasad Paladugu

From: Jagannadha Sutradharudu Teki <[email protected]>

Added support to find the nand bootmode and also
updated the default env. with nandboot.

---
Changes for v3:
-Separated out the nand patch series
as per Michal comment.
Changes for v2:

(quoted diff) +0 -2
-None
---
 board/xilinx/zynq/board.c     |    4 ++++
 doc/README.zynq               |    3 ++-
 include/configs/zynq-common.h |    3 +++
 3 files changed, 9 insertions(+), 1 deletions(-)
board/xilinx/zynq/board.c +4 -0
index 5a47149..9dd158c 100644
@@ -15,6 +15,7 @@ DECLARE_GLOBAL_DATA_PTR;
 /* Bootmode setting values */
 #define ZYNQ_BM_MASK           0x0F
 #define ZYNQ_BM_NOR            0x02
+#define ZYNQ_BM_NAND           0x04
 #define ZYNQ_BM_SD             0x05
 #define ZYNQ_BM_JTAG           0x0
 
@@ -75,6 +76,9 @@ int board_late_init(void)
        case ZYNQ_BM_NOR:
                setenv("modeboot", "norboot");
                break;
+       case ZYNQ_BM_NAND:
+               setenv("modeboot", "nandboot");
+               break;
        case ZYNQ_BM_SD:
                setenv("modeboot", "sdboot");
                break;
doc/README.zynq +0 -0
index 043c970..e0b38cf 100644

doc/README.zynq is intern used in autoboot. · line 57

Quoted 4 lines
doc/README.zynq +1 -0
@@ -54,10 +54,11 @@ is intern used in autoboot.
 
 SLCR bootmode register Bit[3:0] values
 #define ZYNQ_BM_NOR            0x02
+#define ZYNQ_BM_NOR            0x04

Can you please correct this typo - I think it's ZYNQ_BM_NAND

Quoted 26 lines
doc/README.zynq +1 -1
 #define ZYNQ_BM_SD             0x05
 #define ZYNQ_BM_JTAG           0x0
 
-"modeboot" variable can assign any of "norboot", "sdboot" or "jtagboot"
+"modeboot" variable can assign any of "norboot", "nandboot", "sdboot" or "jtagboot"
 bootmode strings at runtime.
 
 5. Mainline status
include/configs/zynq-common.h +3 -1
index 08adaa2..068e59a 100644
@@ -170,6 +170,9 @@
        "norboot=echo Copying FIT from NOR flash to RAM... && " \
                "cp.b ${nor_flash_off} ${load_addr} ${fit_size} && " \
                "bootm ${load_addr}\0" \
+       "nandboot=echo Copying FIT from NAND flash to RAM... && " \
+               "nand read ${load_addr} ${flash_off} ${fit_size} && " \
+               "bootm ${load_addr}\0" \
        "sdboot=echo Copying FIT from SD to RAM... && " \
                "fatload mmc 0 ${load_addr} ${fit_image} && " \
                "bootm ${load_addr}\0" \
--

1.7.4

Quoted 4 lines

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

thanks!

Signature · 1 line
Jagan.
#11 lore raw

PATCH v3 6/7 doc: README.zynq: Updated with nand support addition

In reply to a message not in the archive

From: Jagannadha Sutradharudu Teki <[email protected]>

Updated README.zynq with nand support additions, nand driver and nand board.

---
Changes for v3:
-Separated out the nand patch series
as per Michal comment.
Changes for v2:
-None

---
 doc/README.zynq |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)
doc/README.zynq +2 -3
index e0b38cf..98073f0 100644
@@ -65,7 +65,7 @@ bootmode strings at runtime.
 
 - Added basic board configurations support.
 - Added zynq u-boot bsp code - arch/arm/cpu/armv7/zynq
-- Added zynq boards named - zc70x, zed, microzed, zc770_xm010, zc770_xm012, zc770_xm013
+- Added zynq boards named - zc70x, zed, microzed, zc770_xm010, zc770-xm011, zc770_xm012, zc770_xm013
 - Added zynq drivers:
   serial - drivers/serial/serial_zynq.c
   net - drivers/net/zynq_gem.c
@@ -73,15 +73,14 @@ bootmode strings at runtime.
   mmc - drivers/mmc/zynq_sdhci.c
   spi-  drivers/spi/zynq_spi.c
   i2c - drivers/i2c/zynq_i2c.c
+  nand - drivers/mtd/nand/zynq_nand.c
 - Done proper cleanups on board configurations
 - Added basic FDT support for zynq boards
 - d-cache support for zynq_gem.c
 
 6. TODO
 
-- Add zynq boards support - zc770_xm011
 - Add zynq qspi controller driver
-- Add zynq nand controller driver
 - Add FDT support on individual drivers
 
 [1] http://www.xilinx.com/products/boards-and-kits/EK-Z7-ZC702-G.htm
Signature · 1 line
1.7.4
#12 lore raw

PATCH v3 7/7 zynq: Enable nand env. support

In reply to a message not in the archive

From: Jagannadha Sutradharudu Teki <[email protected]>

Added nand environment support - last 128Kb sector of 1st 1MB of nand can be used for u-boot environment.

---
Changes for v3:
-Separated out the nand patch series
as per Michal comment.
Changes for v2:
-None

---
 include/configs/zynq-common.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
include/configs/zynq-common.h +2 -0
index 068e59a..971a088 100644
@@ -149,6 +149,8 @@
 #ifndef CONFIG_ENV_IS_NOWHERE
 # ifndef CONFIG_SYS_NO_FLASH
 #  define CONFIG_ENV_IS_IN_FLASH
+# elif defined(CONFIG_NAND_ZYNQ)
+#  define CONFIG_ENV_IS_IN_NAND
 # elif defined(CONFIG_SYS_NO_FLASH)
 #  define CONFIG_ENV_IS_NOWHERE
 # endif
Signature · 1 line
1.7.4