public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot-Users] [PATCH] Where does U-Boot's CFI driver check for top/bottom boot?
@ 2006-11-06 23:46 timur at freescale.com
  2006-11-07  0:51 ` Tolunay Orkun
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: timur at freescale.com @ 2006-11-06 23:46 UTC (permalink / raw)
  To: u-boot

From: Timur Tabi <timur@freescale.com>

This patch adds support for the reversed geometry data in some AMD flash
chips.

I'm not proud of this patch, so I'm posting it for review only.  I know it
works on the my board that was the problem, but I have no idea if it will
break any other board.  I'm sure this code could be improved a lot.

Signed-off-by: Timur Tabi <timur@freescale.com>
---
 drivers/cfi_flash.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/drivers/cfi_flash.c b/drivers/cfi_flash.c
index fd0a186..8cc8d60 100644
--- a/drivers/cfi_flash.c
+++ b/drivers/cfi_flash.c
@@ -1120,6 +1120,7 @@ ulong flash_get_size (ulong base, int ba
 	uchar num_erase_regions;
 	int erase_region_size;
 	int erase_region_count;
+	int geometry_reversed = 0;
 #ifdef CFG_FLASH_PROTECTION
 	int ext_addr;
 	info->legacy_unlock = 0;
@@ -1148,6 +1149,8 @@ #endif
 		case CFI_CMDSET_AMD_STANDARD:
 		case CFI_CMDSET_AMD_EXTENDED:
 			info->cmd_reset = AMD_CMD_RESET;
+			if (flash_read_uchar(info, FLASH_OFFSET_CFI_RESP + (0x7E / info->portwidth)) == 3)
+				geometry_reversed = 1;
 			break;
 		}

@@ -1171,8 +1174,13 @@ #endif
 					num_erase_regions, NUM_ERASE_REGIONS);
 				break;
 			}
-			tmp = flash_read_long (info, 0,
+			if (geometry_reversed)
+				tmp = flash_read_long (info, 0,
 					       FLASH_OFFSET_ERASE_REGIONS +
+					       (num_erase_regions - 1 - i) * 4);
+			else
+				tmp = flash_read_long (info, 0,
+				       FLASH_OFFSET_ERASE_REGIONS +
 					       i * 4);
 			erase_region_size =
 				(tmp & 0xffff) ? ((tmp & 0xffff) * 256) : 128;
--
1.4.2.1

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2006-11-07 23:19 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-06 23:46 [U-Boot-Users] [PATCH] Where does U-Boot's CFI driver check for top/bottom boot? timur at freescale.com
2006-11-07  0:51 ` Tolunay Orkun
2006-11-07  1:09 ` [U-Boot-Users] [PATCH] Where does U-Boot's CFI driver check fortop/bottom boot? Spence Nick-rxtd10
2006-11-07 10:57 ` [U-Boot-Users] [PATCH] Where does U-Boot's CFI driver check for top/bottom boot? Tolunay Orkun
2006-11-07 17:24   ` Timur Tabi
2006-11-07 18:01     ` Tolunay Orkun
2006-11-07 18:16       ` Stefan Roese
2006-11-07 23:05         ` Tolunay Orkun
2006-11-07 23:19         ` Tolunay Orkun
2006-11-07 17:50   ` Spence Nick-rxtd10
2006-11-07 18:14     ` Tolunay Orkun
2006-11-07 18:38       ` Timur Tabi
2006-11-07 18:46         ` Stefan Roese

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox