Skip to contentSkip to conversation

onenand_spl_simple: Call onenand_spl_get_geometry() only once

PATCH New Ladislav Michl 2 participants 4 messages Jun 20, 2017 – Jun 24, 2017 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 onenand_spl_simple: Call onenand_spl_get_geometry() only once

Do not call onenand_spl_get_geometry() for each block read.

---
 drivers/mtd/onenand/onenand_spl.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/mtd/onenand/onenand_spl.c +5 -2
index 1925f41d8a..6fad34aa1d 100644
@@ -110,9 +110,12 @@ static u8 scratch_buf[PAGE_4K];
  */
 int onenand_spl_read_block(int block, int offset, int len, void *dst)
 {
-	int page, read, psize;
+	int page, read;
+	static int psize;
+
+	if (!psize)
+		psize = onenand_spl_get_geometry();
 
-	psize = onenand_spl_get_geometry();
 	/* Calculate the page number */
 	page = offset / psize;
 	/* Offset to the start of a flash page */
Signature · 1 line
2.11.0
#1 lore raw

PATCH 2/2 onenand_spl_simple: Add DDP OneNAND support

Current implementation is unable to access second half of DDP OneNAND flash (reads first half mirrored). Use block and bufferram address calculations from onenand_base to fix this.

---
 drivers/mtd/onenand/onenand_spl.c | 29 +++++++++++++++++++++++++----
 1 file changed, 25 insertions(+), 4 deletions(-)
drivers/mtd/onenand/onenand_spl.c +25 -4
index 6fad34aa1d..0b78067a23 100644
@@ -23,11 +23,29 @@ enum onenand_spl_pagesize {
 	PAGE_4K = 4096,
 };
 
+static unsigned int density_mask;
+
 #define ONENAND_PAGES_PER_BLOCK			64
-#define onenand_block_address(block)		(block)
 #define onenand_sector_address(page)		(page << 2)
 #define onenand_buffer_address()		((1 << 3) << 8)
-#define onenand_bufferram_address(block)	(0)
+
+static inline int onenand_block_address(int block)
+{
+	/* Device Flash Core select, NAND Flash Block Address */
+	if (block & density_mask)
+		return ONENAND_DDP_CHIP1 | (block ^ density_mask);
+
+	return block;
+}
+
+static inline int onenand_bufferram_address(int block)
+{
+	/* Device BufferRAM Select */
+	if (block & density_mask)
+		return ONENAND_DDP_CHIP1;
+
+	return ONENAND_DDP_CHIP0;
+}
 
 static inline uint16_t onenand_readw(uint32_t addr)
 {
@@ -41,7 +59,7 @@ static inline void onenand_writew(uint16_t value, uint32_t addr)
 
 static enum onenand_spl_pagesize onenand_spl_get_geometry(void)
 {
-	uint32_t dev_id, density;
+	unsigned int dev_id, density, size;
 
 	if (!onenand_readw(ONENAND_REG_TECHNOLOGY)) {
 		dev_id = onenand_readw(ONENAND_REG_DEVICE_ID);
@@ -51,8 +69,11 @@ static enum onenand_spl_pagesize onenand_spl_get_geometry(void)
 		if (density < ONENAND_DEVICE_DENSITY_4Gb)
 			return PAGE_2K;
 
-		if (dev_id & ONENAND_DEVICE_IS_DDP)
+		if (dev_id & ONENAND_DEVICE_IS_DDP) {
+			size = onenand_readw(ONENAND_REG_DATA_BUFFER_SIZE);
+			density_mask = 1 << (18 + density - ffs(size));
 			return PAGE_2K;
+		}
 	}
 
 	return PAGE_4K;
Signature · 1 line
2.11.0
#2 lore raw

PATCH 2/2 onenand_spl_simple: Add DDP OneNAND support

Quoted 6 lines · Ladislav Michl

Current implementation is unable to access second half of DDP OneNAND flash (reads first half mirrored). Use block and bufferram address calculations from onenand_base to fix this.

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/20170624/1d271875/attachment.sig>
#3 lore raw

PATCH 1/2 onenand_spl_simple: Call onenand_spl_get_geometry() only once

In reply to Ladislav Michl
Quoted 3 lines · Ladislav Michl

Do not call onenand_spl_get_geometry() for each block read.

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/20170624/c99f2bc4/attachment.sig>