aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/u-boot/u-boot-2009.11/at91/vG20/0003-u-boot-Add-dataflash-page-size-power-2-support.patch
blob: 6d3a8ca1dad70be0b0b61f06e61215b1719451a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
From d2562a1fa3b745e1e088ae908f4493f8f9304bad Mon Sep 17 00:00:00 2001
From: mlafauci <mlafauci@metodo2.it>
Date: Mon, 3 Oct 2011 22:49:31 +0200
Subject: [PATCH 3/3] u-boot: Add dataflash page size power 2 support

---
 drivers/mtd/dataflash.c |   15 +++++++++++++--
 include/dataflash.h     |    1 +
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/dataflash.c b/drivers/mtd/dataflash.c
index 96cd395..ab35e97 100644
--- a/drivers/mtd/dataflash.c
+++ b/drivers/mtd/dataflash.c
@@ -42,6 +42,7 @@ int AT91F_DataflashInit (void)
	int last_part;
	int found[CONFIG_SYS_MAX_DATAFLASH_BANKS];
	unsigned char protected;
+	unsigned char powerOf2 = 0;

	AT91F_SpiInit ();

@@ -52,6 +53,7 @@ int AT91F_DataflashInit (void)
		dataflash_info[i].Device.pages_number = 0;
		dfcode = AT91F_DataflashProbe (cs[i].cs,
				&dataflash_info[i].Desc);
+		powerOf2 =  dataflash_info[i].Desc.command[1] & PAGE_SIZE_POWER2;

		switch (dfcode) {
		case AT45DB021:
@@ -104,8 +106,17 @@ int AT91F_DataflashInit (void)

		case AT45DB642:
			dataflash_info[i].Device.pages_number = 8192;
-			dataflash_info[i].Device.pages_size = 1056;
-			dataflash_info[i].Device.page_offset = 11;
+			if (powerOf2)
+			{
+				//Binary page address
+				dataflash_info[i].Device.pages_size = 1024;
+				dataflash_info[i].Device.page_offset = 10;
+			}
+			else
+			{
+				dataflash_info[i].Device.pages_size = 1056;
+				dataflash_info[i].Device.page_offset = 11;
+			}
			dataflash_info[i].Device.byte_mask = 0x700;
			dataflash_info[i].Device.cs = cs[i].cs;
			dataflash_info[i].Desc.DataFlash_state = IDLE;
diff --git a/include/dataflash.h b/include/dataflash.h
index 63b3bf9..2295d15 100644
--- a/include/dataflash.h
+++ b/include/dataflash.h
@@ -142,6 +142,7 @@ struct dataflash_addr {
 #define AT45DB642	0x3c
 #define AT45DB128	0x10
 #define	PAGES_PER_BLOCK	8
+#define PAGE_SIZE_POWER2	0x01

 #define AT91C_DATAFLASH_TIMEOUT		10000	/* For AT91F_DataFlashWaitReady */

--
1.7.0.4