Skip to contentSkip to conversation

cfi_flash: add shift option for some cfi memory chips

PATCH Superseded Oleksij Rempel 3 participants 3 messages Apr 22, 2013

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 cfi_flash: add shift option for some cfi memory chips

From: Oleksij Rempel <[email protected]>

Many cfi chips support 16 and 8 bit modes. Most important difference is use of so called "Q15/A-1" pin. In 16bit mode this pin is used for data IO. In 8bit mode, it is an address input which add one more least significant bit (LSB). In this case we should shift all adresses by one:
For example 0xaa << 1 = 0x154

---
 drivers/nor/Kconfig     |    8 ++++++++
 drivers/nor/cfi_flash.h |    4 ++++
 2 files changed, 12 insertions(+)
drivers/nor/Kconfig +8 -0
index c8ce24f..b556b0c 100644
@@ -50,6 +50,14 @@ config DRIVER_CFI_BANK_WIDTH_8
 	  If you wish to support CFI devices on a physical bus which is
 	  64 bits wide, say 'Y'.
 
+config DRIVER_CFI_BANK_SHIFT_1
+	bool "Shift addressspace of flash at one bit"
+	depends on DRIVER_CFI
+	default n
+	help
+	  If you have flash with enabled LSB bit, then you
+	  wont to enable this function.
+
 config CFI_BUFFER_WRITE
 	bool "use cfi driver with buffer write"
 	depends on DRIVER_CFI || DRIVER_CFI
drivers/nor/cfi_flash.h +4 -0
index 8f818ba..6c7cac4 100644
@@ -295,7 +295,11 @@ static inline u64 flash_read64(void *addr)
  */
 static inline uchar *flash_make_addr (struct flash_info *info, flash_sect_t sect, uint offset)
 {
+#ifdef CONFIG_DRIVER_CFI_BANK_SHIFT_1
+	return ((uchar *) (info->start[sect] + (offset * info->portwidth << 1)));
+#else
 	return ((uchar *) (info->start[sect] + (offset * info->portwidth)));
+#endif
 }
 
 uchar flash_read_uchar (struct flash_info *info, uint offset);
Signature · 7 lines
1.7.10.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw
Quoted 7 lines · Oleksij Rempel

From: Oleksij Rempel <[email protected]>

drivers/nor/cfi_flash.h +0 -0
index 8f818ba..6c7cac4 100644

drivers/nor/cfi_flash.h static inline u64 flash_read64(void *addr) · line 303

Quoted 9 lines
drivers/nor/cfi_flash.h +4 -0
@@ -295,7 +295,11 @@ static inline u64 flash_read64(void *addr)
  */
 static inline uchar *flash_make_addr (struct flash_info *info, flash_sect_t sect, uint offset)
 {
+#ifdef CONFIG_DRIVER_CFI_BANK_SHIFT_1
+	return ((uchar *) (info->start[sect] + (offset * info->portwidth << 1)));
+#else
 	return ((uchar *) (info->start[sect] + (offset * info->portwidth)));
+#endif
 }

Please make this a runtime option configurable via platform data. Making this a compile time option is not so nice.
Or could this be automatically detected?

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw
Quoted 12 lines

From: Oleksij Rempel <[email protected]>

Quoted 11 lines
drivers/nor/cfi_flash.h +2 -0
index 8f818ba..6c7cac4 100644
@@ -295,7 +295,11 @@ static inline u64 flash_read64(void *addr)
  */
 static inline uchar *flash_make_addr (struct flash_info *info, flash_sect_t sect, uint offset)
 {
+#ifdef CONFIG_DRIVER_CFI_BANK_SHIFT_1
+	return ((uchar *) (info->start[sect] + (offset * info->portwidth << 1)));
Quoted 8 lines

drivers/nor/cfi_flash.h static inline u64 flash_read64(void *addr) · line 303

Quoted 4 lines
drivers/nor/cfi_flash.h +2 -0
+#else
 	return ((uchar *) (info->start[sect] + (offset * info->portwidth)));
+#endif
 }

Please make this a runtime option configurable via platform data. Making this a compile time option is not so nice.
Or could this be automatically detected?

Do not treat my opinion as solution but I think better if we make this option as integer as make it available always. In this case we can avoid using #ifdef.

---
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox