Skip to contentSkip to conversation

spl: Lightweight UBI and UBI fastmap support

PATCH New Ladislav Michl 2 participants 54 messages Jul 12, 2016 – Jul 23, 2016

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

v5 cover spl: Lightweight UBI and UBI fastmap support

Core of this patch serie is based on Thomas's patchset:
https://patchwork.ozlabs.org/patch/367305/
https://patchwork.ozlabs.org/patch/367306/

This serie contains also changes needed to let single binary running on IGEPv2 board equipped either with NAND or OneNAND flash memory:
igep0020_nand_defconfig is dropped and igep0020_defconfig modified to support both flash memories. As many flash manipulatioin routines do not expect flash reading failure (as chip is not present), fix them too.

Now, first four flash sectors contains SPL as this is what Boot ROM code expects and loads. The rest of flash is UBI managed: U-Boot, its environment, kernel and rootfs are stored in UBI volumes. As enviroment is stored in UBI volume, we need to know how is flash partitioned very early. Also various board modifications come with different geometry flash memories. To let this work two changes are
introduced: mtdpart code uses default partitions unless it is explicitely told to do otherwise and support for runtime generated default partitions has been added.

Changes in v5:
- dual license GPL/BSD

Changes in v4:
- drop unused name field from ubispl_load structure
- ipl_load returns lenght read

Changes in v3:
- move vol_id check to ubi_scan_vid_hdr to verify it has meaningfull value before testing ubi->toload
- fixed checkpatch errors except those present also in linux code

Changes in v2:
- rename nand_spl_read_flash to nand_spl_read_block and optimize it.
- fixes ubi_calc_fm_size to include also sizeof(struct ubi_fm_sb)
- dropped private copy of ubi-media.h
- ubi-wrapper.h now contains only needed definitions from ubi.h and ubi-user.h
- used return values from errno.h

Ladislav Michl (24):
mtd: Sort subsystem directories aplhabeticaly in Makefile
onenand_spl_simple: Add a simple OneNAND read function
spl: support loading from UBI volumes
spl: zImage support in Falcon mode
armv7: add reset timeout to identify_nand_chip
armv7: make gpmc_cfg const
armv7: armv7: introduce set_gpmc_cs0
armv7: simplify identify_nand_chip
mtd: OneNAND: add timeout to wait ready loops
mtd: OneNAND: allow board init function fail
mtd: OneNAND: initialize mtd->writebufsize to let UBI work
cmd: mtdparts: fix mtdparts variable presence confusion in
mtdparts_init
cmd: mtdparts: fix null pointer dereference in parse_mtdparts
cmd: mtdparts: consolidate mtdparts reading from env
cmd: mtdparts: use defaults by default
cmd: mtdparts: support runtime generated mtdparts
igep00x0: move sysinfo into C file
igep00x0: reorder lan9221 code to remove ifdefs
igep00x0: remove useless setup_net_chip declaration
igep00x0: remove unused empty function omap_rev_string()
igep00x0: runtime flash detection
igep00x0: UBIize
igep00x0: generate default mtdparts according NAND chip used
igep00x0: Falcon mode

Thomas Gleixner (2):
nand_spl_simple: Add a simple NAND read function
spl: Lightweight UBI and UBI fastmap support

 README                                      |   4 +
 arch/arm/cpu/armv7/omap-common/mem-common.c | 156 +++--
 arch/arm/cpu/armv7/omap3/spl_id_nand.c      |  57 +-
 arch/arm/include/asm/arch-omap3/sys_proto.h |   7 +-
 arch/arm/lib/Makefile                       |   2 +
 arch/arm/lib/bootm.c                        |  32 -
 arch/arm/lib/zimage.c                       |  40 ++
 board/isee/igep00x0/igep00x0.c              | 164 +++--
 board/isee/igep00x0/igep00x0.h              |  20 -
 board/micronas/vct/ebi_onenand.c            |   4 +-
 board/samsung/goni/onenand.c                |   4 +-
 board/samsung/smdkc100/onenand.c            |   4 +-
 board/samsung/universal_c210/onenand.c      |   4 +-
 cmd/mtdparts.c                              |  92 +--
 common/spl/Makefile                         |   3 +
 common/spl/spl.c                            |  29 +
 common/spl/spl_ubi.c                        |  78 +++
 configs/igep0020_defconfig                  |   4 +-
 configs/igep0020_nand_defconfig             |  27 -
 doc/README.ubispl                           | 141 +++++
 drivers/Makefile                            |   5 +-
 drivers/mtd/nand/nand_spl_simple.c          |  62 ++
 drivers/mtd/nand/omap_gpmc.c                |   3 +-
 drivers/mtd/onenand/onenand_base.c          |  31 +-
 drivers/mtd/onenand/onenand_spl.c           |  48 ++
 drivers/mtd/onenand/onenand_uboot.c         |  30 +-
 drivers/mtd/ubispl/Makefile                 |   1 +
 drivers/mtd/ubispl/ubi-wrapper.h            | 106 ++++
 drivers/mtd/ubispl/ubispl.c                 | 926 ++++++++++++++++++++++++++++
 drivers/mtd/ubispl/ubispl.h                 | 136 ++++
 include/configs/omap3_igep00x0.h            |  86 ++-
 include/linux/mtd/omap_gpmc.h               |   3 +-
 include/nand.h                              |   1 +
 include/onenand_uboot.h                     |   3 +-
 include/spl.h                               |   4 +
 include/ubispl.h                            |  90 +++
 36 files changed, 2056 insertions(+), 351 deletions(-)
 create mode 100644 arch/arm/lib/zimage.c
 create mode 100644 common/spl/spl_ubi.c
 delete mode 100644 configs/igep0020_nand_defconfig
 create mode 100644 doc/README.ubispl
 create mode 100644 drivers/mtd/ubispl/Makefile
 create mode 100644 drivers/mtd/ubispl/ubi-wrapper.h
 create mode 100644 drivers/mtd/ubispl/ubispl.c
 create mode 100644 drivers/mtd/ubispl/ubispl.h
 create mode 100644 include/ubispl.h
Signature · 1 line
2.1.4
#1 lore raw

PATCH v5 1/26 mtd: Sort subsystem directories aplhabeticaly in Makefile

---

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 drivers/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/Makefile +2 -2
index 1723958..b3ac8a6 100644
@@ -19,14 +19,14 @@ obj-$(CONFIG_ARMADA_38X) += ddr/marvell/a38x/
 obj-$(CONFIG_ARMADA_XP) += ddr/marvell/axp/
 obj-$(CONFIG_ALTERA_SDRAM) += ddr/altera/
 obj-$(CONFIG_SPL_SERIAL_SUPPORT) += serial/
-obj-$(CONFIG_SPL_SPI_FLASH_SUPPORT) += mtd/spi/
 obj-$(CONFIG_SPL_SPI_SUPPORT) += spi/
 obj-$(CONFIG_SPL_POWER_SUPPORT) += power/ power/pmic/
 obj-$(CONFIG_SPL_POWER_SUPPORT) += power/regulator/
+obj-$(CONFIG_SPL_DRIVERS_MISC_SUPPORT) += misc/
 obj-$(CONFIG_SPL_MTD_SUPPORT) += mtd/
 obj-$(CONFIG_SPL_NAND_SUPPORT) += mtd/nand/
-obj-$(CONFIG_SPL_DRIVERS_MISC_SUPPORT) += misc/
 obj-$(CONFIG_SPL_ONENAND_SUPPORT) += mtd/onenand/
+obj-$(CONFIG_SPL_SPI_FLASH_SUPPORT) += mtd/spi/
 obj-$(CONFIG_SPL_DMA_SUPPORT) += dma/
 obj-$(CONFIG_SPL_ETH_SUPPORT) += net/
 obj-$(CONFIG_SPL_ETH_SUPPORT) += net/phy/
Signature · 1 line
2.1.4
#2 lore raw

PATCH v5 1/26 mtd: Sort subsystem directories aplhabeticaly in Makefile

Quoted 3 lines · Ladislav Michl

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160722/1706c94a/attachment.sig>
#3 lore raw

PATCH v5 2/26 nand_spl_simple: Add a simple NAND read function

In reply to Ladislav Michl

From: Thomas Gleixner <[email protected]>

To support UBI in SPL we need a simple NAND read function. Add one to nand_spl_simple and keep it as simple as it goes.

---

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2:
- Rename nand_spl_read_flash to nand_spl_read_block and optimize it.

 drivers/mtd/nand/nand_spl_simple.c | 62 ++++++++++++++++++++++++++++++++++++++
 include/nand.h                     |  1 +
 2 files changed, 63 insertions(+)
drivers/mtd/nand/nand_spl_simple.c +62 -0
index 60a7607..55f48d3 100644
@@ -209,6 +209,68 @@ static int nand_read_page(int block, int page, void *dst)
 }
 #endif
 
+#ifdef CONFIG_SPL_UBI
+/*
+ * Temporary storage for non NAND page aligned and non NAND page sized
+ * reads. Note: This does not support runtime detected FLASH yet, but
+ * that should be reasonably easy to fix by making the buffer large
+ * enough :)
+ */
+static u8 scratch_buf[CONFIG_SYS_NAND_PAGE_SIZE];
+
+/**
+ * nand_spl_read_block - Read data from physical eraseblock into a buffer
+ * @block:	Number of the physical eraseblock
+ * @offset:	Data offset from the start of @peb
+ * @len:	Data size to read
+ * @dst:	Address of the destination buffer
+ *
+ * This could be further optimized if we'd have a subpage read
+ * function in the simple code. On NAND which allows subpage reads
+ * this would spare quite some time to readout e.g. the VID header of
+ * UBI.
+ *
+ * Notes:
+ *	@offset + @len are not allowed to be larger than a physical
+ *	erase block. No sanity check done for simplicity reasons.
+ *
+ * To support runtime detected flash this needs to be extended by
+ * information about the actual flash geometry, but thats beyond the
+ * scope of this effort and for most applications where fast boot is
+ * required it is not an issue anyway.
+ */
+int nand_spl_read_block(int block, int offset, int len, void *dst)
+{
+	int page, read;
+
+	/* Calculate the page number */
+	page = offset / CONFIG_SYS_NAND_PAGE_SIZE;
+
+	/* Offset to the start of a flash page */
+	offset = offset % CONFIG_SYS_NAND_PAGE_SIZE;
+
+	while (len) {
+		/*
+		 * Non page aligned reads go to the scratch buffer.
+		 * Page aligned reads go directly to the destination.
+		 */
+		if (offset || len < CONFIG_SYS_NAND_PAGE_SIZE) {
+			nand_read_page(block, page, scratch_buf);
+			read = min(len, CONFIG_SYS_NAND_PAGE_SIZE - offset);
+			memcpy(dst, scratch_buf + offset, read);
+			offset = 0;
+		} else {
+			nand_read_page(block, page, dst);
+			read = CONFIG_SYS_NAND_PAGE_SIZE;
+		}
+		page++;
+		len -= read;
+		dst += read;
+	}
+	return 0;
+}
+#endif
+
 int nand_spl_load_image(uint32_t offs, unsigned int size, void *dst)
 {
 	unsigned int block, lastblock;
include/nand.h +1 -0
index a4f0f92..627b217 100644
@@ -122,6 +122,7 @@ int nand_unlock(struct mtd_info *mtd, loff_t start, size_t length,
 int nand_get_lock_status(struct mtd_info *mtd, loff_t offset);
 
 int nand_spl_load_image(uint32_t offs, unsigned int size, void *dst);
+int nand_spl_read_block(int block, int offset, int len, void *dst);
 void nand_deselect(void);
 
 #ifdef CONFIG_SYS_NAND_SELECT_DEVICE
Signature · 1 line
2.1.4
#4 lore raw

PATCH v5 2/26 nand_spl_simple: Add a simple NAND read function

Quoted 10 lines · Ladislav Michl

From: Thomas Gleixner <[email protected]>

To support UBI in SPL we need a simple NAND read function. Add one to nand_spl_simple and keep it as simple as it goes.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160722/13e5dac0/attachment.sig>
#5 lore raw

PATCH v5 3/26 onenand_spl_simple: Add a simple OneNAND read function

In reply to Ladislav Michl

---

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 drivers/mtd/onenand/onenand_spl.c | 48 +++++++++++++++++++++++++++++++++++++++
 include/onenand_uboot.h           |  1 +
 2 files changed, 49 insertions(+)
drivers/mtd/onenand/onenand_spl.c +48 -0
index fe6b7d9..1925f41 100644
@@ -93,6 +93,54 @@ static int onenand_spl_read_page(uint32_t block, uint32_t page, uint32_t *buf,
 	return 0;
 }
 
+#ifdef CONFIG_SPL_UBI
+/* Temporary storage for non page aligned and non page sized reads. */
+static u8 scratch_buf[PAGE_4K];
+
+/**
+ * onenand_spl_read_block - Read data from physical eraseblock into a buffer
+ * @block:	Number of the physical eraseblock
+ * @offset:	Data offset from the start of @peb
+ * @len:	Data size to read
+ * @dst:	Address of the destination buffer
+ *
+ * Notes:
+ *	@offset + @len are not allowed to be larger than a physical
+ *	erase block. No sanity check done for simplicity reasons.
+ */
+int onenand_spl_read_block(int block, int offset, int len, void *dst)
+{
+	int page, read, psize;
+
+	psize = onenand_spl_get_geometry();
+	/* Calculate the page number */
+	page = offset / psize;
+	/* Offset to the start of a flash page */
+	offset = offset % psize;
+
+	while (len) {
+		/*
+		 * Non page aligned reads go to the scratch buffer.
+		 * Page aligned reads go directly to the destination.
+		 */
+		if (offset || len < psize) {
+			onenand_spl_read_page(block, page,
+			                      (uint32_t *)scratch_buf, psize);
+			read = min(len, psize - offset);
+			memcpy(dst, scratch_buf + offset, read);
+			offset = 0;
+		} else {
+			onenand_spl_read_page(block, page, dst, psize);
+			read = psize;
+		}
+		page++;
+		len -= read;
+		dst += read;
+	}
+	return 0;
+}
+#endif
+
 void onenand_spl_load_image(uint32_t offs, uint32_t size, void *dst)
 {
 	uint32_t *addr = (uint32_t *)dst;
include/onenand_uboot.h +1 -0
index fd01040..d69e0d2 100644
@@ -49,6 +49,7 @@ extern int flexonenand_set_boundary(struct mtd_info *mtd, int die,
 					int boundary, int lock);
 
 /* SPL */
+int onenand_spl_read_block(int block, int offset, int len, void *dst);
 void onenand_spl_load_image(uint32_t offs, uint32_t size, void *dst);
 
 #endif /* __UBOOT_ONENAND_H */
Signature · 1 line
2.1.4
#6 lore raw

PATCH v5 3/26 onenand_spl_simple: Add a simple OneNAND read function

Quoted 1 line · Ladislav Michl

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160722/b68709fd/attachment.sig>
#7 lore raw

PATCH v5 4/26 spl: Lightweight UBI and UBI fastmap support

In reply to Ladislav Michl

From: Thomas Gleixner <[email protected]>

Booting a payload out of NAND FLASH from the SPL is a crux today, as it requires hard partioned FLASH. Not a brilliant idea with the reliability of todays NAND FLASH chips.

The upstream UBI + UBI fastmap implementation which is about to brought to u-boot is too heavy weight for SPLs as it provides way more functionality than needed for a SPL and does not even fit into the restricted SPL areas which are loaded from the SoC boot ROM.

So this provides a fast and lightweight implementation of UBI scanning and UBI fastmap attach. The scan and logical to physical block mapping code is developed from scratch, while the fastmap implementation is lifted from the linux kernel source and stripped down to fit the SPL needs.

The text foot print on the board which I used for development is:

6854 0 0 6854 1abd
drivers/mtd/ubispl/built-in.o

Attaching a NAND chip with 4096 physical eraseblocks (4 blocks are reserved for the SPL) takes:

In full scan mode:      1172ms
In fastmap mode:          95ms

The code requires quite some storage. The largest and unknown part of it is the number of fastmap blocks to read. Therefor the data structure is not put into the BSS. The code requires a pointer to free memory handed in which is initialized by the UBI attach code itself.

See doc/README.ubispl for further information on how to use it.

This shares the ubi-media.h and crc32 implementation of drivers/mtd/ubi There is no way to share the fastmap code, as UBISPL only utilizes the slightly modified functions ubi_attach_fastmap() and ubi_scan_fastmap() from the original kernel ubi fastmap implementation.

---

Changes in v5:
- dual license GPL/BSD

Changes in v4:
- drop unused name field from ubispl_load structure
- ipl_load returns lenght read

Changes in v3:
- move vol_id check to ubi_scan_vid_hdr to verify it has meaningfull value before testing ubi->toload
- fixed checkpatch errors except those present also in linux code

Changes in v2:
- fixes ubi_calc_fm_size to include also sizeof(struct ubi_fm_sb)
- dropped private copy of ubi-media.h
- ubi-wrapper.h now contains only needed definitions from ubi.h and ubi-user.h
- used return values from errno.h

 README                           |   4 +
 doc/README.ubispl                | 141 ++++++
 drivers/Makefile                 |   1 +
 drivers/mtd/ubispl/Makefile      |   1 +
 drivers/mtd/ubispl/ubi-wrapper.h | 106 +++++
 drivers/mtd/ubispl/ubispl.c      | 926 +++++++++++++++++++++++++++++++++++++++
 drivers/mtd/ubispl/ubispl.h      | 136 ++++++
 include/ubispl.h                 |  90 ++++
 8 files changed, 1405 insertions(+)
 create mode 100644 doc/README.ubispl
 create mode 100644 drivers/mtd/ubispl/Makefile
 create mode 100644 drivers/mtd/ubispl/ubi-wrapper.h
 create mode 100644 drivers/mtd/ubispl/ubispl.c
 create mode 100644 drivers/mtd/ubispl/ubispl.h
 create mode 100644 include/ubispl.h
README +4 -0
index 26d5ad2..00f818a 100644
@@ -3583,6 +3583,10 @@ FIT uImage format:
 		Support for NAND boot using simple NAND drivers that
 		expose the cmd_ctrl() interface.
 
+		CONFIG_SPL_UBI
+		Support for a lightweight UBI (fastmap) scanner and
+		loader
+
 		CONFIG_SPL_MTD_SUPPORT
 		Support for the MTD subsystem within SPL.  Useful for
 		environment on NAND support within SPL.
doc/README.ubispl new file +141 -0

141 lines not on this page · raw message

drivers/Makefile +1 -0
index b3ac8a6..ad5cbae 100644
@@ -27,6 +27,7 @@ obj-$(CONFIG_SPL_MTD_SUPPORT) += mtd/
 obj-$(CONFIG_SPL_NAND_SUPPORT) += mtd/nand/
 obj-$(CONFIG_SPL_ONENAND_SUPPORT) += mtd/onenand/
 obj-$(CONFIG_SPL_SPI_FLASH_SUPPORT) += mtd/spi/
+obj-$(CONFIG_SPL_UBI) += mtd/ubispl/
 obj-$(CONFIG_SPL_DMA_SUPPORT) += dma/
 obj-$(CONFIG_SPL_ETH_SUPPORT) += net/
 obj-$(CONFIG_SPL_ETH_SUPPORT) += net/phy/
drivers/mtd/ubispl/Makefile new file +1 -0
new file mode 100644
index 0000000..740dbed
@@ -0,0 +1 @@
+obj-y += ubispl.o ../ubi/crc32.o
drivers/mtd/ubispl/ubi-wrapper.h new file +106 -0

106 lines not on this page · raw message

drivers/mtd/ubispl/ubispl.c new file +926 -0

926 lines not on this page · raw message

drivers/mtd/ubispl/ubispl.h new file +136 -0

136 lines not on this page · raw message

include/ubispl.h new file +90 -0

90 lines not on this page · raw message

Signature · 1 line
2.1.4
#8 lore raw

PATCH v5 4/26 spl: Lightweight UBI and UBI fastmap support

Quoted 40 lines · Ladislav Michl

From: Thomas Gleixner <[email protected]>

Booting a payload out of NAND FLASH from the SPL is a crux today, as it requires hard partioned FLASH. Not a brilliant idea with the reliability of todays NAND FLASH chips.

The upstream UBI + UBI fastmap implementation which is about to brought to u-boot is too heavy weight for SPLs as it provides way more functionality than needed for a SPL and does not even fit into the restricted SPL areas which are loaded from the SoC boot ROM.

So this provides a fast and lightweight implementation of UBI scanning and UBI fastmap attach. The scan and logical to physical block mapping code is developed from scratch, while the fastmap implementation is lifted from the linux kernel source and stripped down to fit the SPL needs.

The text foot print on the board which I used for development is:

6854 0 0 6854 1abd
drivers/mtd/ubispl/built-in.o

Attaching a NAND chip with 4096 physical eraseblocks (4 blocks are reserved for the SPL) takes:

In full scan mode:      1172ms
In fastmap mode:          95ms

The code requires quite some storage. The largest and unknown part of it is the number of fastmap blocks to read. Therefor the data structure is not put into the BSS. The code requires a pointer to free memory handed in which is initialized by the UBI attach code itself.

See doc/README.ubispl for further information on how to use it.

This shares the ubi-media.h and crc32 implementation of drivers/mtd/ubi There is no way to share the fastmap code, as UBISPL only utilizes the slightly modified functions ubi_attach_fastmap() and ubi_scan_fastmap() from the original kernel ubi fastmap implementation.

Quoted 4 lines

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160722/064e7bbb/attachment.sig>
#9 lore raw

PATCH v5 5/26 spl: support loading from UBI volumes

In reply to Ladislav Michl

Add support for loading from UBI volumes on the top of NAND and OneNAND.

---

Changes in v5:
- dual license GPL/BSD

Changes in v4: None
Changes in v3: None
Changes in v2: None

 common/spl/Makefile  |  3 ++
 common/spl/spl.c     |  6 ++++
 common/spl/spl_ubi.c | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 include/spl.h        |  4 +++
 4 files changed, 91 insertions(+)
 create mode 100644 common/spl/spl_ubi.c
common/spl/Makefile +3 -0
index 2e0f695..b15f0f6 100644
@@ -13,8 +13,11 @@ obj-$(CONFIG_SPL_FRAMEWORK) += spl.o
 obj-$(CONFIG_SPL_LOAD_FIT) += spl_fit.o
 obj-$(CONFIG_SPL_NOR_SUPPORT) += spl_nor.o
 obj-$(CONFIG_SPL_YMODEM_SUPPORT) += spl_ymodem.o
+ifndef CONFIG_SPL_UBI
 obj-$(CONFIG_SPL_NAND_SUPPORT) += spl_nand.o
 obj-$(CONFIG_SPL_ONENAND_SUPPORT) += spl_onenand.o
+endif
+obj-$(CONFIG_SPL_UBI) += spl_ubi.o
 obj-$(CONFIG_SPL_NET_SUPPORT) += spl_net.o
 obj-$(CONFIG_SPL_MMC_SUPPORT) += spl_mmc.o
 obj-$(CONFIG_SPL_USB_SUPPORT) += spl_usb.o
common/spl/spl.c +6 -0
index 840910a..ef113f6 100644
@@ -330,6 +330,11 @@ static int spl_load_image(u32 boot_device)
 	case BOOT_DEVICE_MMC2_2:
 		return spl_mmc_load_image(boot_device);
 #endif
+#ifdef CONFIG_SPL_UBI
+	case BOOT_DEVICE_NAND:
+	case BOOT_DEVICE_ONENAND:
+		return spl_ubi_load_image(boot_device);
+#else
 #ifdef CONFIG_SPL_NAND_SUPPORT
 	case BOOT_DEVICE_NAND:
 		return spl_nand_load_image();
@@ -338,6 +343,7 @@ static int spl_load_image(u32 boot_device)
 	case BOOT_DEVICE_ONENAND:
 		return spl_onenand_load_image();
 #endif
+#endif
 #ifdef CONFIG_SPL_NOR_SUPPORT
 	case BOOT_DEVICE_NOR:
 		return spl_nor_load_image();
common/spl/spl_ubi.c new file +78 -0

78 lines not on this page · raw message

include/spl.h +4 -0
index 2360466..8afa085 100644
@@ -71,6 +71,7 @@ void spl_set_header_raw_uboot(void);
 int spl_parse_image_header(const struct image_header *header);
 void spl_board_prepare_for_linux(void);
 void spl_board_prepare_for_boot(void);
+int spl_board_ubi_load_image(u32 boot_device);
 void __noreturn jump_to_image_linux(void *arg);
 int spl_start_uboot(void);
 void spl_display_print(void);
@@ -84,6 +85,9 @@ int spl_onenand_load_image(void);
 /* NOR SPL functions */
 int spl_nor_load_image(void);
 
+/* UBI SPL functions */
+int spl_ubi_load_image(u32 boot_device);
+
 /* MMC SPL functions */
 int spl_mmc_load_image(u32 boot_device);
 
Signature · 1 line
2.1.4
#10 lore raw

PATCH v5 5/26 spl: support loading from UBI volumes

Quoted 5 lines · Ladislav Michl

Add support for loading from UBI volumes on the top of NAND and OneNAND.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160722/9c59639d/attachment.sig>
#11 lore raw

PATCH v5 6/26 spl: zImage support in Falcon mode

In reply to Ladislav Michl

Other payload than uImage is currently considered to be raw U-Boot image. Check also for zImage in Falcon mode.

---

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 arch/arm/lib/Makefile |  2 ++
 arch/arm/lib/bootm.c  | 32 --------------------------------
 arch/arm/lib/zimage.c | 40 ++++++++++++++++++++++++++++++++++++++++
 common/spl/spl.c      | 23 +++++++++++++++++++++++
 4 files changed, 65 insertions(+), 32 deletions(-)
 create mode 100644 arch/arm/lib/zimage.c
arch/arm/lib/Makefile +2 -0
index 0e05e87..8d89c94 100644
@@ -27,11 +27,13 @@ endif
 obj-$(CONFIG_CPU_V7M) += cmd_boot.o
 obj-$(CONFIG_OF_LIBFDT) += bootm-fdt.o
 obj-$(CONFIG_CMD_BOOTM) += bootm.o
+obj-$(CONFIG_CMD_BOOTM) += zimage.o
 obj-$(CONFIG_SYS_L2_PL310) += cache-pl310.o
 obj-$(CONFIG_USE_ARCH_MEMSET) += memset.o
 obj-$(CONFIG_USE_ARCH_MEMCPY) += memcpy.o
 else
 obj-$(CONFIG_SPL_FRAMEWORK) += spl.o
+obj-$(CONFIG_SPL_FRAMEWORK) += zimage.o
 endif
 obj-$(CONFIG_SEMIHOSTING) += semihosting.o
 
arch/arm/lib/bootm.c +0 -32
index 0838d89..c20ef22 100644
@@ -358,38 +358,6 @@ int do_bootm_linux(int flag, int argc, char * const argv[],
 	return 0;
 }
 
-#ifdef CONFIG_CMD_BOOTZ
-
-struct zimage_header {
-	uint32_t	code[9];
-	uint32_t	zi_magic;
-	uint32_t	zi_start;
-	uint32_t	zi_end;
-};
-
-#define	LINUX_ARM_ZIMAGE_MAGIC	0x016f2818
-
-int bootz_setup(ulong image, ulong *start, ulong *end)
-{
-	struct zimage_header *zi;
-
-	zi = (struct zimage_header *)map_sysmem(image, 0);
-	if (zi->zi_magic != LINUX_ARM_ZIMAGE_MAGIC) {
-		puts("Bad Linux ARM zImage magic!\n");
-		return 1;
-	}
-
-	*start = zi->zi_start;
-	*end = zi->zi_end;
-
-	printf("Kernel image @ %#08lx [ %#08lx - %#08lx ]\n", image, *start,
-	      *end);
-
-	return 0;
-}
-
-#endif	/* CONFIG_CMD_BOOTZ */
-
 #if defined(CONFIG_BOOTM_VXWORKS)
 void boot_prep_vxworks(bootm_headers_t *images)
 {
arch/arm/lib/zimage.c new file +40 -0
new file mode 100644
index 0000000..1e811a8
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2016
+ * Ladislav Michl <[email protected]>
+ *
+ * bootz code:
+ * Copyright (C) 2012 Marek Vasut <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+#include <common.h>
+
+#define	LINUX_ARM_ZIMAGE_MAGIC	0x016f2818
+
+struct arm_z_header {
+	uint32_t	code[9];
+	uint32_t	zi_magic;
+	uint32_t	zi_start;
+	uint32_t	zi_end;
+} __attribute__ ((__packed__));
+
+int bootz_setup(ulong image, ulong *start, ulong *end)
+{
+	struct arm_z_header *zi = (struct arm_z_header *)image;
+
+	if (zi->zi_magic != LINUX_ARM_ZIMAGE_MAGIC) {
+#ifndef CONFIG_SPL_FRAMEWORK
+		puts("Bad Linux ARM zImage magic!\n");
+#endif
+		return 1;
+	}
+
+	*start = zi->zi_start;
+	*end = zi->zi_end;
+#ifndef CONFIG_SPL_FRAMEWORK
+	printf("Kernel image @ %#08lx [ %#08lx - %#08lx ]\n",
+	       image, *start, *end);
+#endif
+
+	return 0;
+}
common/spl/spl.c +23 -0
index ef113f6..25d989b 100644
@@ -57,6 +57,15 @@ __weak int spl_start_uboot(void)
 	puts("SPL: Direct Linux boot not active!\n");
 	return 1;
 }
+
+/*
+ * Weak default function for arch specific zImage check. Return zero
+ * and fill start and end address if image is recognized.
+ */
+int __weak bootz_setup(ulong image, ulong *start, ulong *end)
+{
+	 return 1;
+}
 #endif
 
 /*
@@ -125,6 +134,20 @@ int spl_parse_image_header(const struct image_header *header)
 		/* Signature not found, proceed to other boot methods. */
 		return -EINVAL;
 #else
+#ifdef CONFIG_SPL_OS_BOOT
+		ulong start, end;
+
+		if (!bootz_setup((ulong)header, &start, &end)) {
+			spl_image.name = "Linux";
+			spl_image.os = IH_OS_LINUX;
+			spl_image.load_addr = CONFIG_SYS_LOAD_ADDR;
+			spl_image.entry_point = CONFIG_SYS_LOAD_ADDR;
+			spl_image.size = end - start;
+			debug("spl: payload zImage, load addr: 0x%x size: %d\n",
+			      spl_image.load_addr, spl_image.size);
+			return 0;
+		}
+#endif
 		/* Signature not found - assume u-boot.bin */
 		debug("mkimage signature not found - ih_magic = %x\n",
 			header->ih_magic);
Signature · 1 line
2.1.4
#12 lore raw

PATCH v5 6/26 spl: zImage support in Falcon mode

Quoted 5 lines · Ladislav Michl

Other payload than uImage is currently considered to be raw U-Boot image. Check also for zImage in Falcon mode.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160722/4bf7a5c0/attachment.sig>
#13 lore raw

PATCH v5 7/26 armv7: add reset timeout to identify_nand_chip

In reply to Ladislav Michl

identify_nand_chip hangs forever in loop when NAND is not present. As IGEPv2 comes either with NAND or OneNAND flash, add reset timeout to let function fail gracefully allowing caller to know NAND is not present. On NAND equipped board, reset succeeds on first read, so 1000 loops seems to be safe timeout.

---

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 arch/arm/cpu/armv7/omap3/spl_id_nand.c      | 32 +++++++++++++----------------
 arch/arm/include/asm/arch-omap3/sys_proto.h |  2 +-
 2 files changed, 15 insertions(+), 19 deletions(-)
arch/arm/cpu/armv7/omap3/spl_id_nand.c +14 -18
index db6de09..26d3aa4 100644
@@ -20,29 +20,16 @@
 
 static struct gpmc *gpmc_config = (struct gpmc *)GPMC_BASE;
 
-/* nand_command: Send a flash command to the flash chip */
-static void nand_command(u8 command)
-{
-	writeb(command, &gpmc_config->cs[0].nand_cmd);
-
-	if (command == NAND_CMD_RESET) {
-		unsigned char ret_val;
-		writeb(NAND_CMD_STATUS, &gpmc_config->cs[0].nand_cmd);
-		do {
-			/* Wait until ready */
-			ret_val = readl(&gpmc_config->cs[0].nand_dat);
-		} while ((ret_val & NAND_STATUS_READY) != NAND_STATUS_READY);
-	}
-}
-
 /*
  * Many boards will want to know the results of the NAND_CMD_READID command
  * in order to decide what to do about DDR initialization.  This function
  * allows us to do that very early and to pass those results back to the
  * board so it can make whatever decisions need to be made.
  */
-void identify_nand_chip(int *mfr, int *id)
+int identify_nand_chip(int *mfr, int *id)
 {
+	int loops = 1000;
+
 	/* Make sure that we have setup GPMC for NAND correctly. */
 	writel(M_NAND_GPMC_CONFIG1, &gpmc_config->cs[0].config1);
 	writel(M_NAND_GPMC_CONFIG2, &gpmc_config->cs[0].config2);
@@ -62,8 +49,15 @@ void identify_nand_chip(int *mfr, int *id)
 	sdelay(2000);
 
 	/* Issue a RESET and then READID */
-	nand_command(NAND_CMD_RESET);
-	nand_command(NAND_CMD_READID);
+	writeb(NAND_CMD_RESET, &gpmc_config->cs[0].nand_cmd);
+	writeb(NAND_CMD_STATUS, &gpmc_config->cs[0].nand_cmd);
+	while ((readl(&gpmc_config->cs[0].nand_dat) & NAND_STATUS_READY)
+	                                           != NAND_STATUS_READY) {
+		sdelay(100);
+		if (--loops == 0)
+			return 1;
+	}
+	writeb(NAND_CMD_READID, &gpmc_config->cs[0].nand_cmd);
 
 	/* Set the address to read to 0x0 */
 	writeb(0x0, &gpmc_config->cs[0].nand_adr);
@@ -71,4 +65,6 @@ void identify_nand_chip(int *mfr, int *id)
 	/* Read off the manufacturer and device id. */
 	*mfr = readb(&gpmc_config->cs[0].nand_dat);
 	*id = readb(&gpmc_config->cs[0].nand_dat);
+
+	return 0;
 }
arch/arm/include/asm/arch-omap3/sys_proto.h +1 -1
index 24563c0..1be2b15 100644
@@ -40,7 +40,7 @@ void sdrc_init(void);
 void do_sdrc_init(u32, u32);
 
 void get_board_mem_timings(struct board_sdrc_timings *timings);
-void identify_nand_chip(int *mfr, int *id);
+int identify_nand_chip(int *mfr, int *id);
 void emif4_init(void);
 void gpmc_init(void);
 void enable_gpmc_cs_config(const u32 *gpmc_config, struct gpmc_cs *cs, u32 base,
Signature · 1 line
2.1.4
#14 lore raw

PATCH v5 7/26 armv7: add reset timeout to identify_nand_chip

Quoted 7 lines · Ladislav Michl

identify_nand_chip hangs forever in loop when NAND is not present. As IGEPv2 comes either with NAND or OneNAND flash, add reset timeout to let function fail gracefully allowing caller to know NAND is not present. On NAND equipped board, reset succeeds on first read, so 1000 loops seems to be safe timeout.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160722/db158c30/attachment.sig>
#15 lore raw

PATCH v5 8/26 armv7: make gpmc_cfg const

In reply to Ladislav Michl

---

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 arch/arm/cpu/armv7/omap-common/mem-common.c | 8 +++-----
 arch/arm/include/asm/arch-omap3/sys_proto.h | 4 ++--
 drivers/mtd/nand/omap_gpmc.c                | 3 ++-
 include/linux/mtd/omap_gpmc.h               | 2 +-
 4 files changed, 8 insertions(+), 9 deletions(-)
arch/arm/cpu/armv7/omap-common/mem-common.c +3 -5
index fc4290c..136a032 100644
@@ -21,7 +21,7 @@
 #include <command.h>
 #include <linux/mtd/omap_gpmc.h>
 
-struct gpmc *gpmc_cfg;
+const struct gpmc *gpmc_cfg = (struct gpmc *)GPMC_BASE;
 
 #if defined(CONFIG_OMAP34XX)
 /********************************************************
@@ -50,8 +50,8 @@ u32 mem_ok(u32 cs)
 }
 #endif
 
-void enable_gpmc_cs_config(const u32 *gpmc_config, struct gpmc_cs *cs, u32 base,
-			u32 size)
+void enable_gpmc_cs_config(const u32 *gpmc_config, const struct gpmc_cs *cs,
+				u32 base, u32 size)
 {
 	writel(0, &cs->config7);
 	sdelay(1000);
@@ -75,8 +75,6 @@ void enable_gpmc_cs_config(const u32 *gpmc_config, struct gpmc_cs *cs, u32 base,
  *****************************************************/
 void gpmc_init(void)
 {
-	/* putting a blanket check on GPMC based on ZeBu for now */
-	gpmc_cfg = (struct gpmc *)GPMC_BASE;
 #if defined(CONFIG_NOR)
 /* configure GPMC for NOR */
 	const u32 gpmc_regs[GPMC_MAX_REG] = {	STNOR_GPMC_CONFIG1,
arch/arm/include/asm/arch-omap3/sys_proto.h +2 -2
index 1be2b15..4c5aa99 100644
@@ -43,8 +43,8 @@ void get_board_mem_timings(struct board_sdrc_timings *timings);
 int identify_nand_chip(int *mfr, int *id);
 void emif4_init(void);
 void gpmc_init(void);
-void enable_gpmc_cs_config(const u32 *gpmc_config, struct gpmc_cs *cs, u32 base,
-			u32 size);
+void enable_gpmc_cs_config(const u32 *gpmc_config, const struct gpmc_cs *cs,
+				u32 base, u32 size);
 
 void watchdog_init(void);
 void set_muxconf_regs(void);
drivers/mtd/nand/omap_gpmc.c +2 -1
index 67f293d..6e201d6 100644
@@ -264,7 +264,8 @@ static int omap_calculate_ecc(struct mtd_info *mtd, const uint8_t *dat,
 {
 	struct nand_chip *chip = mtd_to_nand(mtd);
 	struct omap_nand_info *info = nand_get_controller_data(chip);
-	uint32_t *ptr, val = 0;
+	const uint32_t *ptr;
+	uint32_t val = 0;
 	int8_t i = 0, j;
 
 	switch (info->ecc_scheme) {
include/linux/mtd/omap_gpmc.h +1 -1
index 3a75674..f49ea3d 100644
@@ -92,6 +92,6 @@ struct gpmc {
 };
 
 /* Used for board specific gpmc initialization */
-extern struct gpmc *gpmc_cfg;
+extern const struct gpmc *gpmc_cfg;
 
 #endif /* __ASM_OMAP_GPMC_H */
Signature · 1 line
2.1.4
#16 lore raw

PATCH v5 8/26 armv7: make gpmc_cfg const

Quoted 1 line · Ladislav Michl

Fixed am33xx, duovero and omap_zoom1 and then, applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160722/c59d49bd/attachment.sig>
#17 lore raw

PATCH v5 9/26 armv7: armv7: introduce set_gpmc_cs0

In reply to Ladislav Michl

Allow boards to runtime detect flash type.

---

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 arch/arm/cpu/armv7/omap-common/mem-common.c | 148 +++++++++++++++++-----------
 arch/arm/include/asm/arch-omap3/sys_proto.h |   1 +
 include/linux/mtd/omap_gpmc.h               |   1 +
 3 files changed, 92 insertions(+), 58 deletions(-)
arch/arm/cpu/armv7/omap-common/mem-common.c +90 -58
index 136a032..d72e82e 100644
@@ -20,9 +20,20 @@
 #include <asm/arch/sys_proto.h>
 #include <command.h>
 #include <linux/mtd/omap_gpmc.h>
+#include <jffs2/load_kernel.h>
 
 const struct gpmc *gpmc_cfg = (struct gpmc *)GPMC_BASE;
 
+#if defined(CONFIG_NOR)
+char gpmc_cs0_flash = MTD_DEV_TYPE_NOR;
+#elif defined(CONFIG_NAND) || defined(CONFIG_CMD_NAND)
+char gpmc_cs0_flash = MTD_DEV_TYPE_NAND;
+#elif defined(CONFIG_CMD_ONENAND)
+char gpmc_cs0_flash = MTD_DEV_TYPE_ONENAND;
+#else
+char gpmc_cs0_flash = -1;
+#endif
+
 #if defined(CONFIG_OMAP34XX)
 /********************************************************
  *  mem_ok() - test used to see if timings are correct
@@ -68,6 +79,81 @@ void enable_gpmc_cs_config(const u32 *gpmc_config, const struct gpmc_cs *cs,
 	sdelay(2000);
 }
 
+void set_gpmc_cs0(int flash_type)
+{
+	const u32 *gpmc_regs;
+	u32 base, size;
+#if defined(CONFIG_NOR)
+	const u32 gpmc_regs_nor[GPMC_MAX_REG] = {
+		STNOR_GPMC_CONFIG1,
+		STNOR_GPMC_CONFIG2,
+		STNOR_GPMC_CONFIG3,
+		STNOR_GPMC_CONFIG4,
+		STNOR_GPMC_CONFIG5,
+		STNOR_GPMC_CONFIG6,
+		STNOR_GPMC_CONFIG7
+	};
+#endif
+#if defined(CONFIG_NAND) || defined(CONFIG_CMD_NAND)
+	const u32 gpmc_regs_nand[GPMC_MAX_REG] = {
+		M_NAND_GPMC_CONFIG1,
+		M_NAND_GPMC_CONFIG2,
+		M_NAND_GPMC_CONFIG3,
+		M_NAND_GPMC_CONFIG4,
+		M_NAND_GPMC_CONFIG5,
+		M_NAND_GPMC_CONFIG6,
+		0
+	};
+#endif
+#if defined(CONFIG_CMD_ONENAND)
+	const u32 gpmc_regs_onenand[GPMC_MAX_REG] = {
+		ONENAND_GPMC_CONFIG1,
+		ONENAND_GPMC_CONFIG2,
+		ONENAND_GPMC_CONFIG3,
+		ONENAND_GPMC_CONFIG4,
+		ONENAND_GPMC_CONFIG5,
+		ONENAND_GPMC_CONFIG6,
+		0
+	};
+#endif
+
+	switch (flash_type) {
+#if defined(CONFIG_NOR)
+	case MTD_DEV_TYPE_NOR:
+		gpmc_regs = gpmc_regs_nor;
+		base = CONFIG_SYS_FLASH_BASE;
+		size = (CONFIG_SYS_FLASH_SIZE > 0x08000000) ? GPMC_SIZE_256M :
+		      ((CONFIG_SYS_FLASH_SIZE > 0x04000000) ? GPMC_SIZE_128M :
+		      ((CONFIG_SYS_FLASH_SIZE > 0x02000000) ? GPMC_SIZE_64M  :
+		      ((CONFIG_SYS_FLASH_SIZE > 0x01000000) ? GPMC_SIZE_32M  :
+		                                              GPMC_SIZE_16M)));
+		break;
+#endif
+#if defined(CONFIG_NAND) || defined(CONFIG_CMD_NAND)
+	case MTD_DEV_TYPE_NAND:
+		gpmc_regs = gpmc_regs_nand;
+		base = CONFIG_SYS_NAND_BASE;
+		size = GPMC_SIZE_16M;
+		break;
+#endif
+#if defined(CONFIG_CMD_ONENAND)
+	case MTD_DEV_TYPE_ONENAND:
+		gpmc_regs = gpmc_regs_onenand;
+		base = CONFIG_SYS_ONENAND_BASE;
+		size = GPMC_SIZE_128M;
+		break;
+#endif
+	default:
+		/* disable the GPMC0 config set by ROM code */
+		writel(0, &gpmc_cfg->cs[0].config7);
+		sdelay(1000);
+		return;
+	}
+
+	/* enable chip-select specific configurations */
+	enable_gpmc_cs_config(gpmc_regs, &gpmc_cfg->cs[0], base, size);
+}
+
 /*****************************************************
  * gpmc_init(): init gpmc bus
  * Init GPMC for x16, MuxMode (SDRAM in x32).
@@ -75,68 +161,14 @@ void enable_gpmc_cs_config(const u32 *gpmc_config, const struct gpmc_cs *cs,
  *****************************************************/
 void gpmc_init(void)
 {
-#if defined(CONFIG_NOR)
-/* configure GPMC for NOR */
-	const u32 gpmc_regs[GPMC_MAX_REG] = {	STNOR_GPMC_CONFIG1,
-						STNOR_GPMC_CONFIG2,
-						STNOR_GPMC_CONFIG3,
-						STNOR_GPMC_CONFIG4,
-						STNOR_GPMC_CONFIG5,
-						STNOR_GPMC_CONFIG6,
-						STNOR_GPMC_CONFIG7
-						};
-	u32 base = CONFIG_SYS_FLASH_BASE;
-	u32 size =	(CONFIG_SYS_FLASH_SIZE  > 0x08000000) ? GPMC_SIZE_256M :
-	/* > 64MB */	((CONFIG_SYS_FLASH_SIZE > 0x04000000) ? GPMC_SIZE_128M :
-	/* > 32MB */	((CONFIG_SYS_FLASH_SIZE > 0x02000000) ? GPMC_SIZE_64M  :
-	/* > 16MB */	((CONFIG_SYS_FLASH_SIZE > 0x01000000) ? GPMC_SIZE_32M  :
-	/* min 16MB */	GPMC_SIZE_16M)));
-#elif defined(CONFIG_NAND) || defined(CONFIG_CMD_NAND)
-/* configure GPMC for NAND */
-	const u32  gpmc_regs[GPMC_MAX_REG] = {	M_NAND_GPMC_CONFIG1,
-						M_NAND_GPMC_CONFIG2,
-						M_NAND_GPMC_CONFIG3,
-						M_NAND_GPMC_CONFIG4,
-						M_NAND_GPMC_CONFIG5,
-						M_NAND_GPMC_CONFIG6,
-						0
-						};
-	u32 base = CONFIG_SYS_NAND_BASE;
-	u32 size = GPMC_SIZE_16M;
-
-#elif defined(CONFIG_CMD_ONENAND)
-	const u32 gpmc_regs[GPMC_MAX_REG] = {	ONENAND_GPMC_CONFIG1,
-						ONENAND_GPMC_CONFIG2,
-						ONENAND_GPMC_CONFIG3,
-						ONENAND_GPMC_CONFIG4,
-						ONENAND_GPMC_CONFIG5,
-						ONENAND_GPMC_CONFIG6,
-						0
-						};
-	u32 size = GPMC_SIZE_128M;
-	u32 base = CONFIG_SYS_ONENAND_BASE;
-#else
-	const u32 gpmc_regs[GPMC_MAX_REG] = { 0, 0, 0, 0, 0, 0, 0 };
-	u32 size = 0;
-	u32 base = 0;
-#endif
 	/* global settings */
 	writel(0x00000008, &gpmc_cfg->sysconfig);
 	writel(0x00000000, &gpmc_cfg->irqstatus);
 	writel(0x00000000, &gpmc_cfg->irqenable);
 	/* disable timeout, set a safe reset value */
 	writel(0x00001ff0, &gpmc_cfg->timeout_control);
-#ifdef CONFIG_NOR
-	writel(0x00000200, &gpmc_cfg->config);
-#else
-	writel(0x00000012, &gpmc_cfg->config);
-#endif
-	/*
-	 * Disable the GPMC0 config set by ROM code
-	 */
-	writel(0, &gpmc_cfg->cs[0].config7);
-	sdelay(1000);
-	/* enable chip-select specific configurations */
-	if (base != 0)
-		enable_gpmc_cs_config(gpmc_regs, &gpmc_cfg->cs[0], base, size);
+	writel(gpmc_cs0_flash == MTD_DEV_TYPE_NOR ?
+		0x00000200 : 0x00000012, &gpmc_cfg->config);
+
+	set_gpmc_cs0(gpmc_cs0_flash);
 }
arch/arm/include/asm/arch-omap3/sys_proto.h +1 -0
index 4c5aa99..5979340 100644
@@ -45,6 +45,7 @@ void emif4_init(void);
 void gpmc_init(void);
 void enable_gpmc_cs_config(const u32 *gpmc_config, const struct gpmc_cs *cs,
 				u32 base, u32 size);
+void set_gpmc_cs0(int flash_type);
 
 void watchdog_init(void);
 void set_muxconf_regs(void);
include/linux/mtd/omap_gpmc.h +1 -0
index f49ea3d..be3ce9d 100644
@@ -93,5 +93,6 @@ struct gpmc {
 
 /* Used for board specific gpmc initialization */
 extern const struct gpmc *gpmc_cfg;
+extern char gpmc_cs0_flash;
 
 #endif /* __ASM_OMAP_GPMC_H */
Signature · 1 line
2.1.4
#18 lore raw

PATCH v5 9/26 armv7: armv7: introduce set_gpmc_cs0

Quoted 3 lines · Ladislav Michl

Allow boards to runtime detect flash type.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160722/dae46170/attachment.sig>
#19 lore raw

PATCH v5 10/26 armv7: simplify identify_nand_chip

In reply to Ladislav Michl

Use newly introduced function

---

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 arch/arm/cpu/armv7/omap3/spl_id_nand.c | 35 +++++++++++-----------------------
 1 file changed, 11 insertions(+), 24 deletions(-)
arch/arm/cpu/armv7/omap3/spl_id_nand.c +11 -24
index 26d3aa4..0e2f0a2 100644
@@ -13,13 +13,13 @@
  */
 
 #include <common.h>
+#include <jffs2/load_kernel.h>
 #include <linux/mtd/nand.h>
+#include <linux/mtd/omap_gpmc.h>
 #include <asm/io.h>
 #include <asm/arch/sys_proto.h>
 #include <asm/arch/mem.h>
 
-static struct gpmc *gpmc_config = (struct gpmc *)GPMC_BASE;
-
 /*
  * Many boards will want to know the results of the NAND_CMD_READID command
  * in order to decide what to do about DDR initialization.  This function
@@ -31,40 +31,27 @@ int identify_nand_chip(int *mfr, int *id)
 	int loops = 1000;
 
 	/* Make sure that we have setup GPMC for NAND correctly. */
-	writel(M_NAND_GPMC_CONFIG1, &gpmc_config->cs[0].config1);
-	writel(M_NAND_GPMC_CONFIG2, &gpmc_config->cs[0].config2);
-	writel(M_NAND_GPMC_CONFIG3, &gpmc_config->cs[0].config3);
-	writel(M_NAND_GPMC_CONFIG4, &gpmc_config->cs[0].config4);
-	writel(M_NAND_GPMC_CONFIG5, &gpmc_config->cs[0].config5);
-	writel(M_NAND_GPMC_CONFIG6, &gpmc_config->cs[0].config6);
-
-	/*
-	 * Enable the config.  The CS size goes in bits 11:8.  We set
-	 * bit 6 to enable the CS and the base address goes into bits 5:0.
-	 */
-	writel((GPMC_SIZE_128M << 8) | (GPMC_CS_ENABLE << 6) |
-				((NAND_BASE >> 24) & GPMC_BASEADDR_MASK),
-			&gpmc_config->cs[0].config7);
+	set_gpmc_cs0(MTD_DEV_TYPE_NAND);
 
 	sdelay(2000);
 
 	/* Issue a RESET and then READID */
-	writeb(NAND_CMD_RESET, &gpmc_config->cs[0].nand_cmd);
-	writeb(NAND_CMD_STATUS, &gpmc_config->cs[0].nand_cmd);
-	while ((readl(&gpmc_config->cs[0].nand_dat) & NAND_STATUS_READY)
-	                                           != NAND_STATUS_READY) {
+	writeb(NAND_CMD_RESET, &gpmc_cfg->cs[0].nand_cmd);
+	writeb(NAND_CMD_STATUS, &gpmc_cfg->cs[0].nand_cmd);
+	while ((readl(&gpmc_cfg->cs[0].nand_dat) & NAND_STATUS_READY)
+	                                        != NAND_STATUS_READY) {
 		sdelay(100);
 		if (--loops == 0)
 			return 1;
 	}
-	writeb(NAND_CMD_READID, &gpmc_config->cs[0].nand_cmd);
+	writeb(NAND_CMD_READID, &gpmc_cfg->cs[0].nand_cmd);
 
 	/* Set the address to read to 0x0 */
-	writeb(0x0, &gpmc_config->cs[0].nand_adr);
+	writeb(0x0, &gpmc_cfg->cs[0].nand_adr);
 
 	/* Read off the manufacturer and device id. */
-	*mfr = readb(&gpmc_config->cs[0].nand_dat);
-	*id = readb(&gpmc_config->cs[0].nand_dat);
+	*mfr = readb(&gpmc_cfg->cs[0].nand_dat);
+	*id = readb(&gpmc_cfg->cs[0].nand_dat);
 
 	return 0;
 }
Signature · 1 line
2.1.4
#20 lore raw

PATCH v5 10/26 armv7: simplify identify_nand_chip

Quoted 3 lines · Ladislav Michl

Use newly introduced function

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160722/69840574/attachment.sig>
#21 lore raw

PATCH v5 11/26 mtd: OneNAND: add timeout to wait ready loops

In reply to Ladislav Michl

Add timeout to onenand_wait ready loop as it hangs here indefinitely when chip not present. Once there, do the same for onenand_bbt_wait as well (note: recent Linux driver code does the same)

---

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 drivers/mtd/onenand/onenand_base.c | 30 +++++++++++++++++++-----------
 1 file changed, 19 insertions(+), 11 deletions(-)
drivers/mtd/onenand/onenand_base.c +19 -11
index 03deabc..d194d97 100644
@@ -20,6 +20,7 @@
  */
 
 #include <common.h>
+#include <watchdog.h>
 #include <linux/compat.h>
 #include <linux/mtd/mtd.h>
 #include "linux/mtd/flashchip.h"
@@ -467,15 +468,18 @@ static int onenand_read_ecc(struct onenand_chip *this)
 static int onenand_wait(struct mtd_info *mtd, int state)
 {
 	struct onenand_chip *this = mtd->priv;
-	unsigned int flags = ONENAND_INT_MASTER;
 	unsigned int interrupt = 0;
 	unsigned int ctrl;
 
-	while (1) {
+	/* Wait at most 20ms ... */
+	u32 timeo = (CONFIG_SYS_HZ * 20) / 1000;
+	u32 time_start = get_timer(0);
+	do {
+		WATCHDOG_RESET();
+		if (get_timer(time_start) > timeo)
+			return -EIO;
 		interrupt = this->read_word(this->base + ONENAND_REG_INTERRUPT);
-		if (interrupt & flags)
-			break;
-	}
+	} while ((interrupt & ONENAND_INT_MASTER) == 0);
 
 	ctrl = this->read_word(this->base + ONENAND_REG_CTRL_STATUS);
 
@@ -1154,15 +1158,18 @@ int onenand_read_oob(struct mtd_info *mtd, loff_t from,
 static int onenand_bbt_wait(struct mtd_info *mtd, int state)
 {
 	struct onenand_chip *this = mtd->priv;
-	unsigned int flags = ONENAND_INT_MASTER;
 	unsigned int interrupt;
 	unsigned int ctrl;
 
-	while (1) {
+	/* Wait at most 20ms ... */
+	u32 timeo = (CONFIG_SYS_HZ * 20) / 1000;
+	u32 time_start = get_timer(0);
+	do {
+		WATCHDOG_RESET();
+		if (get_timer(time_start) > timeo)
+			return ONENAND_BBT_READ_FATAL_ERROR;
 		interrupt = this->read_word(this->base + ONENAND_REG_INTERRUPT);
-		if (interrupt & flags)
-			break;
-	}
+	} while ((interrupt & ONENAND_INT_MASTER) == 0);
 
 	/* To get correct interrupt status in timeout case */
 	interrupt = this->read_word(this->base + ONENAND_REG_INTERRUPT);
@@ -2536,7 +2543,8 @@ static int onenand_chip_probe(struct mtd_info *mtd)
 	this->write_word(ONENAND_CMD_RESET, this->base + ONENAND_BOOTRAM);
 
 	/* Wait reset */
-	this->wait(mtd, FL_RESETING);
+	if (this->wait(mtd, FL_RESETING))
+		return -ENXIO;
 
 	/* Restore system configuration 1 */
 	this->write_word(syscfg, this->base + ONENAND_REG_SYS_CFG1);
Signature · 1 line
2.1.4
#22 lore raw

PATCH v5 11/26 mtd: OneNAND: add timeout to wait ready loops

Quoted 5 lines · Ladislav Michl

Add timeout to onenand_wait ready loop as it hangs here indefinitely when chip not present. Once there, do the same for onenand_bbt_wait as well (note: recent Linux driver code does the same)

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160722/f7123537/attachment.sig>
#23 lore raw

PATCH v5 12/26 mtd: OneNAND: allow board init function fail

In reply to Ladislav Michl

---

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 board/micronas/vct/ebi_onenand.c       |  4 +++-
 board/samsung/goni/onenand.c           |  4 +++-
 board/samsung/smdkc100/onenand.c       |  4 +++-
 board/samsung/universal_c210/onenand.c |  4 +++-
 drivers/mtd/onenand/onenand_uboot.c    | 30 +++++++++++++++---------------
 include/onenand_uboot.h                |  2 +-
 6 files changed, 28 insertions(+), 20 deletions(-)
board/micronas/vct/ebi_onenand.c +3 -1
index 62eb648..ef892ca 100644
@@ -169,7 +169,7 @@ static int ebi_write_bufferram(struct mtd_info *mtd, loff_t addr, int area,
 	return 0;
 }
 
-void onenand_board_init(struct mtd_info *mtd)
+int onenand_board_init(struct mtd_info *mtd)
 {
 	struct onenand_chip *chip = mtd->priv;
 
@@ -181,4 +181,6 @@ void onenand_board_init(struct mtd_info *mtd)
 
 	chip->read_bufferram = ebi_read_bufferram;
 	chip->write_bufferram = ebi_write_bufferram;
+
+	return 0;
 }
board/samsung/goni/onenand.c +3 -1
index b74d8e8..cbe1d12f 100644
@@ -11,11 +11,13 @@
 #include <linux/mtd/samsung_onenand.h>
 #include <onenand_uboot.h>
 
-void onenand_board_init(struct mtd_info *mtd)
+int onenand_board_init(struct mtd_info *mtd)
 {
 	struct onenand_chip *this = mtd->priv;
 
 	this->base = (void *)CONFIG_SYS_ONENAND_BASE;
 	this->options |= ONENAND_RUNTIME_BADBLOCK_CHECK;
 	this->chip_probe = s5pc110_chip_probe;
+
+	return 0;
 }
board/samsung/smdkc100/onenand.c +3 -1
index 577c1a5..994d91d 100644
@@ -16,7 +16,7 @@
 #include <asm/io.h>
 #include <asm/arch/clock.h>
 
-void onenand_board_init(struct mtd_info *mtd)
+int onenand_board_init(struct mtd_info *mtd)
 {
 	struct onenand_chip *this = mtd->priv;
 	struct s5pc100_clock *clk =
@@ -65,4 +65,6 @@ void onenand_board_init(struct mtd_info *mtd)
 	writel(value, &onenand->int_err_mask);
 
 	s3c_onenand_init(mtd);
+
+	return 0;
 }
board/samsung/universal_c210/onenand.c +3 -1
index 28bc811..147a95e 100644
@@ -10,11 +10,13 @@
 #include <linux/mtd/onenand.h>
 #include <linux/mtd/samsung_onenand.h>
 
-void onenand_board_init(struct mtd_info *mtd)
+int onenand_board_init(struct mtd_info *mtd)
 {
 	struct onenand_chip *this = mtd->priv;
 
 	this->base = (void *)CONFIG_SYS_ONENAND_BASE;
 	this->options |= ONENAND_RUNTIME_BADBLOCK_CHECK;
 	this->chip_probe = s5pc210_chip_probe;
+
+	return 0;
 }
drivers/mtd/onenand/onenand_uboot.c +15 -15
index ae60c3b..c15ec9d 100644
@@ -24,33 +24,33 @@ static __attribute__((unused)) char dev_name[] = "onenand0";
 
 void onenand_init(void)
 {
+	int err = 0;
 	memset(&onenand_mtd, 0, sizeof(struct mtd_info));
 	memset(&onenand_chip, 0, sizeof(struct onenand_chip));
 
 	onenand_mtd.priv = &onenand_chip;
 
 #ifdef CONFIG_USE_ONENAND_BOARD_INIT
-	/*
-	 * It's used for some board init required
-	 */
-	onenand_board_init(&onenand_mtd);
+	/* It's used for some board init required */
+	err = onenand_board_init(&onenand_mtd);
 #else
 	onenand_chip.base = (void *) CONFIG_SYS_ONENAND_BASE;
 #endif
 
-	onenand_scan(&onenand_mtd, 1);
+	if (!err && !(onenand_scan(&onenand_mtd, 1))) {
 
-	if (onenand_chip.device_id & DEVICE_IS_FLEXONENAND)
-		puts("Flex-");
-	puts("OneNAND: ");
-	print_size(onenand_chip.chipsize, "\n");
+		if (onenand_chip.device_id & DEVICE_IS_FLEXONENAND)
+			puts("Flex-");
+		puts("OneNAND: ");
 
 #ifdef CONFIG_MTD_DEVICE
-	/*
-	 * Add MTD device so that we can reference it later
-	 * via the mtdcore infrastructure (e.g. ubi).
-	 */
-	onenand_mtd.name = dev_name;
-	add_mtd_device(&onenand_mtd);
+		/*
+		 * Add MTD device so that we can reference it later
+		 * via the mtdcore infrastructure (e.g. ubi).
+		 */
+		onenand_mtd.name = dev_name;
+		add_mtd_device(&onenand_mtd);
 #endif
+	}
+	print_size(onenand_chip.chipsize, "\n");
 }
include/onenand_uboot.h +1 -1
index d69e0d2..995f0aa 100644
@@ -26,7 +26,7 @@ extern struct mtd_info onenand_mtd;
 extern struct onenand_chip onenand_chip;
 
 /* board */
-extern void onenand_board_init(struct mtd_info *);
+extern int onenand_board_init(struct mtd_info *);
 
 /* Functions */
 extern void onenand_init(void);
Signature · 1 line
2.1.4
#24 lore raw

PATCH v5 12/26 mtd: OneNAND: allow board init function fail

Quoted 1 line · Ladislav Michl

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160722/92683a13/attachment.sig>
#25 lore raw

PATCH v5 13/26 mtd: OneNAND: initialize mtd->writebufsize to let UBI work

In reply to Ladislav Michl

io_init checks this value and fails with "bad write buffer size 0 for 2048 min. I/O unit"

---

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 drivers/mtd/onenand/onenand_base.c | 1 +
 1 file changed, 1 insertion(+)
drivers/mtd/onenand/onenand_base.c +1 -0
index d194d97..0e35dc5 100644
@@ -2657,6 +2657,7 @@ int onenand_probe(struct mtd_info *mtd)
 	mtd->_sync = onenand_sync;
 	mtd->_block_isbad = onenand_block_isbad;
 	mtd->_block_markbad = onenand_block_markbad;
+	mtd->writebufsize = mtd->writesize;
 
 	return 0;
 }
Signature · 1 line
2.1.4
#26 lore raw

PATCH v5 13/26 mtd: OneNAND: initialize mtd->writebufsize to let UBI work

Quoted 4 lines · Ladislav Michl

io_init checks this value and fails with "bad write buffer size 0 for 2048 min. I/O unit"

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160722/6191ba7e/attachment.sig>
#27 lore raw

PATCH v5 14/26 cmd: mtdparts: fix mtdparts variable presence confusion in mtdparts_init

In reply to Ladislav Michl

A private buffer is used to read mtdparts variable from non-relocated environment. A pointer to that buffer is returned unconditionally, confusing later test for variable presence in the environment. Fix it by returning NULL when getenv_f fails.

---

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 cmd/mtdparts.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
cmd/mtdparts.c +6 -4
index 44b2c3a..3a88a10 100644
@@ -1720,11 +1720,13 @@ int mtdparts_init(void)
 	 * before the env is relocated, then we need to use our own stack
 	 * buffer.  gd->env_buf will be too small.
 	 */
-	if (gd->flags & GD_FLG_ENV_READY) {
+	if (gd->flags & GD_FLG_ENV_READY)
 		parts = getenv("mtdparts");
-	} else {
-		parts = tmp_parts;
-		getenv_f("mtdparts", tmp_parts, MTDPARTS_MAXLEN);
+	else {
+		if (getenv_f("mtdparts", tmp_parts, MTDPARTS_MAXLEN) != -1)
+			parts = tmp_parts;
+		else
+			parts = NULL;
 	}
 	current_partition = getenv("partition");
 
Signature · 1 line
2.1.4
#28 lore raw

PATCH v5 14/26 cmd: mtdparts: fix mtdparts variable presence confusion in mtdparts_init

Quoted 6 lines · Ladislav Michl

A private buffer is used to read mtdparts variable from non-relocated environment. A pointer to that buffer is returned unconditionally, confusing later test for variable presence in the environment. Fix it by returning NULL when getenv_f fails.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160722/9867b118/attachment.sig>
#29 lore raw

PATCH v5 15/26 cmd: mtdparts: fix null pointer dereference in parse_mtdparts

In reply to Ladislav Michl

In case there is no mtdparts variable in relocated environment, NULL is assigned to p, which is later fed to strncpy. Also function parameter mtdparts is completely ignored, so use it in case mtdparts variable is not found in environment. This parameter is checked not to be NULL in caller.

---

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 cmd/mtdparts.c | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)
cmd/mtdparts.c +13 -10
index 3a88a10..995cb87 100644
@@ -1524,7 +1524,7 @@ static int spread_partitions(void)
  */
 static int parse_mtdparts(const char *const mtdparts)
 {
-	const char *p = mtdparts;
+	const char *p;
 	struct mtd_device *dev;
 	int err = 1;
 	char tmp_parts[MTDPARTS_MAXLEN];
@@ -1538,20 +1538,25 @@ static int parse_mtdparts(const char *const mtdparts)
 	}
 
 	/* re-read 'mtdparts' variable, mtd_devices_init may be updating env */
-	if (gd->flags & GD_FLG_ENV_READY) {
+	if (gd->flags & GD_FLG_ENV_READY)
 		p = getenv("mtdparts");
-	} else {
-		p = tmp_parts;
-		getenv_f("mtdparts", tmp_parts, MTDPARTS_MAXLEN);
+	else {
+		if (getenv_f("mtdparts", tmp_parts, MTDPARTS_MAXLEN) != -1)
+			p = tmp_parts;
+		else
+			p = NULL;
 	}
 
+	if (!p)
+		p = mtdparts;
+
 	if (strncmp(p, "mtdparts=", 9) != 0) {
 		printf("mtdparts variable doesn't start with 'mtdparts='\n");
 		return err;
 	}
 	p += 9;
 
-	while (p && (*p != '\0')) {
+	while (*p != '\0') {
 		err = 1;
 		if ((device_parse(p, &p, &dev) != 0) || (!dev))
 			break;
@@ -1569,12 +1574,10 @@ static int parse_mtdparts(const char *const mtdparts)
 		list_add_tail(&dev->link, &devices);
 		err = 0;
 	}
-	if (err == 1) {
+	if (err == 1)
 		device_delall(&devices);
-		return 1;
-	}
 
-	return 0;
+	return err;
 }
 
 /**
Signature · 1 line
2.1.4
#30 lore raw

PATCH v5 15/26 cmd: mtdparts: fix null pointer dereference in parse_mtdparts

Quoted 7 lines · Ladislav Michl

In case there is no mtdparts variable in relocated environment, NULL is assigned to p, which is later fed to strncpy. Also function parameter mtdparts is completely ignored, so use it in case mtdparts variable is not found in environment. This parameter is checked not to be NULL in caller.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160722/97f8bf83/attachment.sig>
#31 lore raw

PATCH v5 16/26 cmd: mtdparts: consolidate mtdparts reading from env

In reply to Ladislav Michl

---

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 cmd/mtdparts.c | 42 ++++++++++++++++++++----------------------
 1 file changed, 20 insertions(+), 22 deletions(-)
cmd/mtdparts.c +20 -22
index 995cb87..7860ed9 100644
@@ -1516,6 +1516,23 @@ static int spread_partitions(void)
 #endif /* CONFIG_CMD_MTDPARTS_SPREAD */
 
 /**
+ * The mtdparts variable tends to be long. If we need to access it
+ * before the env is relocated, then we need to use our own stack
+ * buffer.  gd->env_buf will be too small.
+ *
+ * @param buf temporary buffer pointer MTDPARTS_MAXLEN long
+ * @return mtdparts variable string, NULL if not found
+ */
+static const char *getenv_mtdparts(char *buf)
+{
+	if (gd->flags & GD_FLG_ENV_READY)
+		return getenv("mtdparts");
+	if (getenv_f("mtdparts", buf, MTDPARTS_MAXLEN) != -1)
+		return buf;
+	return NULL;
+}
+
+/**
  * Accept character string describing mtd partitions and call device_parse()
  * for each entry. Add created devices to the global devices list.
  *
@@ -1538,15 +1555,7 @@ static int parse_mtdparts(const char *const mtdparts)
 	}
 
 	/* re-read 'mtdparts' variable, mtd_devices_init may be updating env */
-	if (gd->flags & GD_FLG_ENV_READY)
-		p = getenv("mtdparts");
-	else {
-		if (getenv_f("mtdparts", tmp_parts, MTDPARTS_MAXLEN) != -1)
-			p = tmp_parts;
-		else
-			p = NULL;
-	}
-
+	p = getenv_mtdparts(tmp_parts);
 	if (!p)
 		p = mtdparts;
 
@@ -1691,6 +1700,7 @@ static int parse_mtdids(const char *const ids)
 	return 0;
 }
 
+
 /**
  * Parse and initialize global mtdids mapping and create global
  * device/partition list.
@@ -1718,19 +1728,7 @@ int mtdparts_init(void)
 
 	/* get variables */
 	ids = getenv("mtdids");
-	/*
-	 * The mtdparts variable tends to be long. If we need to access it
-	 * before the env is relocated, then we need to use our own stack
-	 * buffer.  gd->env_buf will be too small.
-	 */
-	if (gd->flags & GD_FLG_ENV_READY)
-		parts = getenv("mtdparts");
-	else {
-		if (getenv_f("mtdparts", tmp_parts, MTDPARTS_MAXLEN) != -1)
-			parts = tmp_parts;
-		else
-			parts = NULL;
-	}
+	parts = getenv_mtdparts(tmp_parts);
 	current_partition = getenv("partition");
 
 	/* save it for later parsing, cannot rely on current partition pointer
Signature · 1 line
2.1.4
#32 lore raw

PATCH v5 16/26 cmd: mtdparts: consolidate mtdparts reading from env

Quoted 1 line · Ladislav Michl

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160722/464090d2/attachment.sig>
#33 lore raw

PATCH v5 17/26 cmd: mtdparts: use defaults by default

In reply to Ladislav Michl

Boards which are defining default mtdparts often need them early in boot process (to load environment from UBI volume, for example). This is currently solved by adding mtdparts and mtdids variable definitions also to default environment. With this change, default partitions are used by default unless explicitely deleted or redefined.

---

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 cmd/mtdparts.c | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)
cmd/mtdparts.c +16 -6
index 7860ed9..53074a1 100644
@@ -142,6 +142,8 @@ static struct list_head devices;
 struct mtd_device *current_mtd_dev = NULL;
 u8 current_mtd_partnum = 0;
 
+u8 use_defaults;
+
 static struct part_info* mtd_part_info(struct mtd_device *dev, unsigned int part_num);
 
 /* command line only routines */
@@ -1723,6 +1725,7 @@ int mtdparts_init(void)
 		memset(last_ids, 0, MTDIDS_MAXLEN);
 		memset(last_parts, 0, MTDPARTS_MAXLEN);
 		memset(last_partition, 0, PARTITION_MAXLEN);
+		use_defaults = 1;
 		initialized = 1;
 	}
 
@@ -1761,10 +1764,16 @@ int mtdparts_init(void)
 		return 1;
 	}
 
-	/* do no try to use defaults when mtdparts variable is not defined,
-	 * just check the length */
-	if (!parts)
-		printf("mtdparts variable not set, see 'help mtdparts'\n");
+	/* use defaults when mtdparts variable is not defined
+	 * once mtdparts is saved environment, drop use_defaults flag */
+	if (!parts) {
+		if (mtdparts_default && use_defaults) {
+			parts = mtdparts_default;
+			if (setenv("mtdparts", (char *)parts) == 0)
+				use_defaults = 0;
+		} else
+			printf("mtdparts variable not set, see 'help mtdparts'\n");
+	}
 
 	if (parts && (strlen(parts) > MTDPARTS_MAXLEN - 1)) {
 		printf("mtdparts too long (> %d)\n", MTDPARTS_MAXLEN);
@@ -1936,9 +1945,10 @@ static int do_mtdparts(cmd_tbl_t *cmdtp, int flag, int argc,
 {
 	if (argc == 2) {
 		if (strcmp(argv[1], "default") == 0) {
-			setenv("mtdids", (char *)mtdids_default);
-			setenv("mtdparts", (char *)mtdparts_default);
+			setenv("mtdids", NULL);
+			setenv("mtdparts", NULL);
 			setenv("partition", NULL);
+			use_defaults = 1;
 
 			mtdparts_init();
 			return 0;
Signature · 1 line
2.1.4
#34 lore raw

PATCH v5 17/26 cmd: mtdparts: use defaults by default

Quoted 8 lines · Ladislav Michl

Boards which are defining default mtdparts often need them early in boot process (to load environment from UBI volume, for example). This is currently solved by adding mtdparts and mtdids variable definitions also to default environment. With this change, default partitions are used by default unless explicitely deleted or redefined.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160722/dddf2b91/attachment.sig>
#35 lore raw

PATCH v5 18/26 cmd: mtdparts: support runtime generated mtdparts

In reply to Ladislav Michl

Some CPUs contains boot ROM code capable reading first few blocks (where SPL resides) of NAND flash and executing it. It is wise to create separate partition here for SPL. As block size depends on NAND chip used, we could either use worst case (biggest) partition size or base its size on actual block size. This patch adds support for the latter option.

---

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 cmd/mtdparts.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)
cmd/mtdparts.c +12 -9
index 53074a1..3f4f334 100644
@@ -109,17 +109,17 @@ DECLARE_GLOBAL_DATA_PTR;
 #define MTD_WRITEABLE_CMD		1
 
 /* default values for mtdids and mtdparts variables */
-#if defined(MTDIDS_DEFAULT)
-static const char *const mtdids_default = MTDIDS_DEFAULT;
-#else
-static const char *const mtdids_default = NULL;
+#if !defined(MTDIDS_DEFAULT)
+#define MTDIDS_DEFAULT NULL
 #endif
-
-#if defined(MTDPARTS_DEFAULT)
-static const char *const mtdparts_default = MTDPARTS_DEFAULT;
-#else
-static const char *const mtdparts_default = NULL;
+#if !defined(MTDPARTS_DEFAULT)
+#define MTDPARTS_DEFAULT NULL
 #endif
+#if defined(CONFIG_SYS_MTDPARTS_RUNTIME)
+extern void board_mtdparts_default(const char **mtdids, const char **mtdparts);
+#endif
+static const char *mtdids_default = MTDIDS_DEFAULT;
+static const char *mtdparts_default = MTDPARTS_DEFAULT;
 
 /* copies of last seen 'mtdids', 'mtdparts' and 'partition' env variables */
 #define MTDIDS_MAXLEN		128
@@ -1725,6 +1725,9 @@ int mtdparts_init(void)
 		memset(last_ids, 0, MTDIDS_MAXLEN);
 		memset(last_parts, 0, MTDPARTS_MAXLEN);
 		memset(last_partition, 0, PARTITION_MAXLEN);
+#if defined(CONFIG_SYS_MTDPARTS_RUNTIME)
+		board_mtdparts_default(&mtdids_default, &mtdparts_default);
+#endif
 		use_defaults = 1;
 		initialized = 1;
 	}
Signature · 1 line
2.1.4
#36 lore raw

PATCH v5 18/26 cmd: mtdparts: support runtime generated mtdparts

Quoted 8 lines · Ladislav Michl

Some CPUs contains boot ROM code capable reading first few blocks (where SPL resides) of NAND flash and executing it. It is wise to create separate partition here for SPL. As block size depends on NAND chip used, we could either use worst case (biggest) partition size or base its size on actual block size. This patch adds support for the latter option.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160722/a95286df/attachment.sig>
#37 lore raw

PATCH v5 19/26 igep00x0: move sysinfo into C file

In reply to Ladislav Michl

---

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 board/isee/igep00x0/igep00x0.c | 18 ++++++++++++++++++
 board/isee/igep00x0/igep00x0.h | 18 ------------------
 2 files changed, 18 insertions(+), 18 deletions(-)
board/isee/igep00x0/igep00x0.c +18 -0
index d1a6a6f..0ad5123 100644
@@ -21,6 +21,24 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
+const omap3_sysinfo sysinfo = {
+	DDR_STACKED,
+#if (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0020)
+	"IGEPv2",
+#endif
+#if (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0030)
+	"IGEP COM MODULE/ELECTRON",
+#endif
+#if (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0032)
+	"IGEP COM PROTON",
+#endif
+#if defined(CONFIG_ENV_IS_IN_ONENAND)
+	"ONENAND",
+#else
+	"NAND",
+#endif
+};
+
 #if defined(CONFIG_CMD_NET)
 /* GPMC definitions for LAN9221 chips */
 static const u32 gpmc_lan_config[] = {
board/isee/igep00x0/igep00x0.h +0 -18
index 3c7ff9b..e47ee66 100644
@@ -7,24 +7,6 @@
 #ifndef _IGEP00X0_H_
 #define _IGEP00X0_H_
 
-const omap3_sysinfo sysinfo = {
-	DDR_STACKED,
-#if (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0020)
-	"IGEPv2",
-#endif
-#if (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0030)
-	"IGEP COM MODULE/ELECTRON",
-#endif
-#if (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0032)
-	"IGEP COM PROTON",
-#endif
-#if defined(CONFIG_ENV_IS_IN_ONENAND)
-	"ONENAND",
-#else
-	"NAND",
-#endif
-};
-
 static void setup_net_chip(void);
 
 /*
Signature · 1 line
2.1.4
#38 lore raw

PATCH v5 19/26 igep00x0: move sysinfo into C file

Quoted 1 line · Ladislav Michl

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160722/196eb35f/attachment.sig>
#39 lore raw

PATCH v5 20/26 igep00x0: reorder lan9221 code to remove ifdefs

In reply to Ladislav Michl

---

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 board/isee/igep00x0/igep00x0.c | 41 +++++++++++++++++------------------------
 1 file changed, 17 insertions(+), 24 deletions(-)
board/isee/igep00x0/igep00x0.c +17 -24
index 0ad5123..4baaee5 100644
@@ -39,18 +39,6 @@ const omap3_sysinfo sysinfo = {
 #endif
 };
 
-#if defined(CONFIG_CMD_NET)
-/* GPMC definitions for LAN9221 chips */
-static const u32 gpmc_lan_config[] = {
-	NET_LAN9221_GPMC_CONFIG1,
-	NET_LAN9221_GPMC_CONFIG2,
-	NET_LAN9221_GPMC_CONFIG3,
-	NET_LAN9221_GPMC_CONFIG4,
-	NET_LAN9221_GPMC_CONFIG5,
-	NET_LAN9221_GPMC_CONFIG6,
-};
-#endif
-
 static const struct ns16550_platdata igep_serial = {
 	.base = OMAP34XX_UART3,
 	.reg_shift = 2,
@@ -119,7 +107,6 @@ void get_board_mem_timings(struct board_sdrc_timings *timings)
 #endif
 
 #if defined(CONFIG_CMD_NET)
-
 static void reset_net_chip(int gpio)
 {
 	if (!gpio_request(gpio, "eth nrst")) {
@@ -140,6 +127,14 @@ static void reset_net_chip(int gpio)
 static void setup_net_chip(void)
 {
 	struct ctrl *ctrl_base = (struct ctrl *)OMAP34XX_CTRL_BASE;
+	static const u32 gpmc_lan_config[] = {
+		NET_LAN9221_GPMC_CONFIG1,
+		NET_LAN9221_GPMC_CONFIG2,
+		NET_LAN9221_GPMC_CONFIG3,
+		NET_LAN9221_GPMC_CONFIG4,
+		NET_LAN9221_GPMC_CONFIG5,
+		NET_LAN9221_GPMC_CONFIG6,
+	};
 
 	enable_gpmc_cs_config(gpmc_lan_config, &gpmc_cfg->cs[5],
 			CONFIG_SMC911X_BASE, GPMC_SIZE_16M);
@@ -154,6 +149,15 @@ static void setup_net_chip(void)
 
 	reset_net_chip(64);
 }
+
+int board_eth_init(bd_t *bis)
+{
+#ifdef CONFIG_SMC911X
+	return smc911x_initialize(0, CONFIG_SMC911X_BASE);
+#else
+	return 0;
+#endif
+}
 #else
 static inline void setup_net_chip(void) {}
 #endif
@@ -219,14 +223,3 @@ void set_muxconf_regs(void)
 	MUX_IGEP0030();
 #endif
 }
-
-#if defined(CONFIG_CMD_NET)
-int board_eth_init(bd_t *bis)
-{
-#ifdef CONFIG_SMC911X
-	return smc911x_initialize(0, CONFIG_SMC911X_BASE);
-#else
-	return 0;
-#endif
-}
-#endif
Signature · 1 line
2.1.4
#40 lore raw

PATCH v5 20/26 igep00x0: reorder lan9221 code to remove ifdefs

Quoted 1 line · Ladislav Michl

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160722/458f9157/attachment.sig>
#41 lore raw

PATCH v5 21/26 igep00x0: remove useless setup_net_chip declaration

In reply to Ladislav Michl

---

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 board/isee/igep00x0/igep00x0.h | 2 --
 1 file changed, 2 deletions(-)
board/isee/igep00x0/igep00x0.h +0 -2
index e47ee66..5698efa 100644
@@ -7,8 +7,6 @@
 #ifndef _IGEP00X0_H_
 #define _IGEP00X0_H_
 
-static void setup_net_chip(void);
-
 /*
  * IEN  - Input Enable
  * IDIS - Input Disable
Signature · 1 line
2.1.4
#42 lore raw

PATCH v5 21/26 igep00x0: remove useless setup_net_chip declaration

Quoted 1 line · Ladislav Michl

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160722/45584f3a/attachment.sig>
#43 lore raw

PATCH v5 22/26 igep00x0: remove unused empty function omap_rev_string()

In reply to Ladislav Michl

---

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 board/isee/igep00x0/igep00x0.c | 8 --------
 1 file changed, 8 deletions(-)
board/isee/igep00x0/igep00x0.c +0 -8
index 4baaee5..5dfb7d2 100644
@@ -69,14 +69,6 @@ int board_init(void)
 
 #ifdef CONFIG_SPL_BUILD
 /*
- * Routine: omap_rev_string
- * Description: For SPL builds output board rev
- */
-void omap_rev_string(void)
-{
-}
-
-/*
  * Routine: get_board_mem_timings
  * Description: If we use SPL then there is no x-loader nor config header
  * so we have to setup the DDR timings ourself on both banks.
Signature · 1 line
2.1.4
#44 lore raw

PATCH v5 22/26 igep00x0: remove unused empty function omap_rev_string()

Quoted 1 line · Ladislav Michl

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160722/72d1d2e4/attachment.sig>
#45 lore raw

PATCH v5 23/26 igep00x0: runtime flash detection

In reply to Ladislav Michl

---

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 board/isee/igep00x0/igep00x0.c | 71 +++++++++++++++++++++++++++++++-----------
 1 file changed, 53 insertions(+), 18 deletions(-)
board/isee/igep00x0/igep00x0.c +53 -18
index 5dfb7d2..b36709c 100644
@@ -17,6 +17,10 @@
 #include <asm/arch/mux.h>
 #include <asm/arch/sys_proto.h>
 #include <asm/mach-types.h>
+#include <linux/mtd/nand.h>
+#include <linux/mtd/nand.h>
+#include <linux/mtd/onenand.h>
+#include <jffs2/load_kernel.h>
 #include "igep00x0.h"
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -56,7 +60,25 @@ U_BOOT_DEVICE(igep_uart) = {
  */
 int board_init(void)
 {
-	gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
+	int loops = 100;
+
+	/* find out flash memory type, assume NAND first */
+	gpmc_cs0_flash = MTD_DEV_TYPE_NAND;
+	gpmc_init();
+
+	/* Issue a RESET and then READID */
+	writeb(NAND_CMD_RESET, &gpmc_cfg->cs[0].nand_cmd);
+	writeb(NAND_CMD_STATUS, &gpmc_cfg->cs[0].nand_cmd);
+	while ((readl(&gpmc_cfg->cs[0].nand_dat) & NAND_STATUS_READY)
+	                                        != NAND_STATUS_READY) {
+		udelay(1);
+		if (--loops == 0) {
+			gpmc_cs0_flash = MTD_DEV_TYPE_ONENAND;
+			gpmc_init();	/* reinitialize for OneNAND */
+			break;
+		}
+	}
+
 	/* boot param addr */
 	gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
 
@@ -75,29 +97,42 @@ int board_init(void)
  */
 void get_board_mem_timings(struct board_sdrc_timings *timings)
 {
-	timings->mr = MICRON_V_MR_165;
-#ifdef CONFIG_BOOT_NAND
-	timings->mcfg = MICRON_V_MCFG_200(256 << 20);
-	timings->ctrla = MICRON_V_ACTIMA_200;
-	timings->ctrlb = MICRON_V_ACTIMB_200;
-	timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_200MHz;
-#else
-	if (get_cpu_family() == CPU_OMAP34XX) {
-		timings->mcfg = NUMONYX_V_MCFG_165(256 << 20);
-		timings->ctrla = NUMONYX_V_ACTIMA_165;
-		timings->ctrlb = NUMONYX_V_ACTIMB_165;
-		timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz;
+	int mfr, id, err = identify_nand_chip(&mfr, &id);
 
-	} else {
-		timings->mcfg = NUMONYX_V_MCFG_200(256 << 20);
-		timings->ctrla = NUMONYX_V_ACTIMA_200;
-		timings->ctrlb = NUMONYX_V_ACTIMB_200;
+	timings->mr = MICRON_V_MR_165;
+	if (!err && mfr == NAND_MFR_MICRON) {
+		timings->mcfg = MICRON_V_MCFG_200(256 << 20);
+		timings->ctrla = MICRON_V_ACTIMA_200;
+		timings->ctrlb = MICRON_V_ACTIMB_200;
 		timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_200MHz;
+		gpmc_cs0_flash = MTD_DEV_TYPE_NAND;
+	} else {
+		if (get_cpu_family() == CPU_OMAP34XX) {
+			timings->mcfg = NUMONYX_V_MCFG_165(256 << 20);
+			timings->ctrla = NUMONYX_V_ACTIMA_165;
+			timings->ctrlb = NUMONYX_V_ACTIMB_165;
+			timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz;
+		} else {
+			timings->mcfg = NUMONYX_V_MCFG_200(256 << 20);
+			timings->ctrla = NUMONYX_V_ACTIMA_200;
+			timings->ctrlb = NUMONYX_V_ACTIMB_200;
+			timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_200MHz;
+		}
+		gpmc_cs0_flash = MTD_DEV_TYPE_ONENAND;
 	}
-#endif
 }
 #endif
 
+int onenand_board_init(struct mtd_info *mtd)
+{
+	if (gpmc_cs0_flash == MTD_DEV_TYPE_ONENAND) {
+		struct onenand_chip *this = mtd->priv;
+		this->base = (void *)CONFIG_SYS_ONENAND_BASE;
+		return 0;
+	}
+	return 1;
+}
+
 #if defined(CONFIG_CMD_NET)
 static void reset_net_chip(int gpio)
 {
Signature · 1 line
2.1.4
#46 lore raw

PATCH v5 23/26 igep00x0: runtime flash detection

Quoted 1 line · Ladislav Michl

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160722/ce63d9aa/attachment.sig>
#47 lore raw

PATCH v5 24/26 igep00x0: UBIize

In reply to Ladislav Michl

Convert IGEP board to use UBI volumes for U-Boot, its environment and kernel. With exception of first four sectors read by SoC boot ROM whole (One)NAND is UBI managed.
Also merge NAND and OneNAND defconfigs as now one binary can serve both flashes.
As code is too big now, drop CONFIG_SPL_EXT_SUPPORT to make it fit.

---

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 configs/igep0020_defconfig       |  4 +-
 configs/igep0020_nand_defconfig  | 27 -------------
 include/configs/omap3_igep00x0.h | 85 ++++++++++++++++++----------------------
 3 files changed, 41 insertions(+), 75 deletions(-)
 delete mode 100644 configs/igep0020_nand_defconfig
configs/igep0020_defconfig +3 -1
index 66dd93f..649dd47 100644
@@ -2,7 +2,8 @@ CONFIG_ARM=y
 CONFIG_OMAP34XX=y
 CONFIG_TARGET_OMAP3_IGEP00X0=y
 CONFIG_SPL=y
-CONFIG_SYS_EXTRA_OPTIONS="MACH_TYPE=MACH_TYPE_IGEP0020,BOOT_ONENAND"
+CONFIG_SYS_EXTRA_OPTIONS="MACH_TYPE=MACH_TYPE_IGEP0020"
+CONFIG_BOOTDELAY=3
 CONFIG_HUSH_PARSER=y
 CONFIG_CMD_BOOTZ=y
 # CONFIG_CMD_IMLS is not set
@@ -24,4 +25,5 @@ CONFIG_CMD_FAT=y
 CONFIG_CMD_FS_GENERIC=y
 CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_SYS_NS16550=y
+CONFIG_USE_TINY_PRINTF=y
 CONFIG_OF_LIBFDT=y
configs/igep0020_nand_defconfig deleted +0 -27
deleted file mode 100644
index 7535d10..0000000
@@ -1,27 +0,0 @@
-CONFIG_ARM=y
-CONFIG_OMAP34XX=y
-CONFIG_TARGET_OMAP3_IGEP00X0=y
-CONFIG_SPL=y
-CONFIG_SYS_EXTRA_OPTIONS="MACH_TYPE=MACH_TYPE_IGEP0020,BOOT_NAND"
-CONFIG_HUSH_PARSER=y
-CONFIG_CMD_BOOTZ=y
-# CONFIG_CMD_IMLS is not set
-CONFIG_CMD_ASKENV=y
-# CONFIG_CMD_FLASH is not set
-CONFIG_CMD_MMC=y
-CONFIG_CMD_SPI=y
-CONFIG_CMD_I2C=y
-CONFIG_CMD_GPIO=y
-# CONFIG_CMD_SETEXPR is not set
-CONFIG_CMD_DHCP=y
-CONFIG_CMD_MII=y
-CONFIG_CMD_PING=y
-CONFIG_CMD_CACHE=y
-CONFIG_CMD_EXT2=y
-CONFIG_CMD_EXT4=y
-CONFIG_CMD_EXT4_WRITE=y
-CONFIG_CMD_FAT=y
-CONFIG_CMD_FS_GENERIC=y
-CONFIG_NET_RANDOM_ETHADDR=y
-CONFIG_SYS_NS16550=y
-CONFIG_OF_LIBFDT=y
include/configs/omap3_igep00x0.h +38 -47

117 lines not on this page · raw message

Signature · 1 line
2.1.4
#48 lore raw

PATCH v5 24/26 igep00x0: UBIize

Quoted 9 lines · Ladislav Michl

Convert IGEP board to use UBI volumes for U-Boot, its environment and kernel. With exception of first four sectors read by SoC boot ROM whole (One)NAND is UBI managed.
Also merge NAND and OneNAND defconfigs as now one binary can serve both flashes.
As code is too big now, drop CONFIG_SPL_EXT_SUPPORT to make it fit.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160722/0bd3b186/attachment.sig>
#49 lore raw

PATCH v5 24/26 igep00x0: UBIize

In reply to Ladislav Michl
Quoted 9 lines · Ladislav Michl

Convert IGEP board to use UBI volumes for U-Boot, its environment and kernel. With exception of first four sectors read by SoC boot ROM whole (One)NAND is UBI managed.
Also merge NAND and OneNAND defconfigs as now one binary can serve both flashes.
As code is too big now, drop CONFIG_SPL_EXT_SUPPORT to make it fit.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160722/6325fd45/attachment.sig>
#50 lore raw

PATCH v5 25/26 igep00x0: generate default mtdparts according NAND chip used

In reply to Ladislav Michl

---

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 board/isee/igep00x0/igep00x0.c   | 18 ++++++++++++++++++
 include/configs/omap3_igep00x0.h |  1 +
 2 files changed, 19 insertions(+)
board/isee/igep00x0/igep00x0.c +18 -0
index b36709c..4c52b36 100644
@@ -17,6 +17,7 @@
 #include <asm/arch/mux.h>
 #include <asm/arch/sys_proto.h>
 #include <asm/mach-types.h>
+#include <linux/mtd/mtd.h>
 #include <linux/mtd/nand.h>
 #include <linux/mtd/nand.h>
 #include <linux/mtd/onenand.h>
@@ -232,6 +233,23 @@ int misc_init_r(void)
 	return 0;
 }
 
+void board_mtdparts_default(const char **mtdids, const char **mtdparts)
+{
+	struct mtd_info *mtd = get_mtd_device(NULL, 0);
+	if (mtd) {
+		static char ids[24];
+		static char parts[48];
+		const char *linux_name = "omap2-nand";
+		if (strncmp(mtd->name, "onenand0", 8) == 0)
+			linux_name = "omap2-onenand";
+		snprintf(ids, sizeof(ids), "%s=%s", mtd->name, linux_name);
+		snprintf(parts, sizeof(parts), "mtdparts=%s:%dk(SPL),-(UBI)",
+		         linux_name, 4 * mtd->erasesize >> 10);
+		*mtdids = ids;
+		*mtdparts = parts;
+	}
+}
+
 /*
  * Routine: set_muxconf_regs
  * Description: Setting up the configuration Mux registers specific to the
include/configs/omap3_igep00x0.h +1 -0
index 03ffda9..e0d2593 100644
@@ -113,6 +113,7 @@
 
 #define CONFIG_RBTREE
 #define CONFIG_MTD_PARTITIONS
+#define CONFIG_SYS_MTDPARTS_RUNTIME
 
 /* OneNAND config */
 #define CONFIG_SPL_ONENAND_SUPPORT
Signature · 1 line
2.1.4
#51 lore raw

PATCH v5 25/26 igep00x0: generate default mtdparts according NAND chip used

Quoted 1 line · Ladislav Michl

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160722/64220b36/attachment.sig>
#52 lore raw

PATCH v5 26/26 igep00x0: Falcon mode

In reply to Ladislav Michl

Implement spl_start_uboot to let Falcon mode work.

---

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 board/isee/igep00x0/igep00x0.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
board/isee/igep00x0/igep00x0.c +12 -0
index 4c52b36..808955e 100644
@@ -10,6 +10,7 @@
 #include <ns16550.h>
 #include <twl4030.h>
 #include <netdev.h>
+#include <spl.h>
 #include <asm/gpio.h>
 #include <asm/io.h>
 #include <asm/arch/mem.h>
@@ -122,6 +123,17 @@ void get_board_mem_timings(struct board_sdrc_timings *timings)
 		gpmc_cs0_flash = MTD_DEV_TYPE_ONENAND;
 	}
 }
+
+#ifdef CONFIG_SPL_OS_BOOT
+int spl_start_uboot(void)
+{
+	/* break into full u-boot on 'c' */
+	if (serial_tstc() && serial_getc() == 'c')
+		return 1;
+
+	return 0;
+}
+#endif
 #endif
 
 int onenand_board_init(struct mtd_info *mtd)
Signature · 1 line
2.1.4
#53 lore raw

PATCH v5 26/26 igep00x0: Falcon mode

Quoted 5 lines · Ladislav Michl

Implement spl_start_uboot to let Falcon mode work.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160722/5dae1ebb/attachment.sig>