mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/3] cfi_flash: add shift option for some cfi memory chips
@ 2013-04-22  8:53 Oleksij Rempel
  2013-04-22 16:10 ` Sascha Hauer
  0 siblings, 1 reply; 3+ messages in thread
From: Oleksij Rempel @ 2013-04-22  8:53 UTC (permalink / raw)
  To: barebox; +Cc: Oleksij Rempel

From: Oleksij Rempel <bug-track@fisher-privat.net>

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(+)

diff --git a/drivers/nor/Kconfig b/drivers/nor/Kconfig
index c8ce24f..b556b0c 100644
--- a/drivers/nor/Kconfig
+++ b/drivers/nor/Kconfig
@@ -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
diff --git a/drivers/nor/cfi_flash.h b/drivers/nor/cfi_flash.h
index 8f818ba..6c7cac4 100644
--- a/drivers/nor/cfi_flash.h
+++ b/drivers/nor/cfi_flash.h
@@ -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);
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH 1/3] cfi_flash: add shift option for some cfi memory chips
  2013-04-22  8:53 [PATCH 1/3] cfi_flash: add shift option for some cfi memory chips Oleksij Rempel
@ 2013-04-22 16:10 ` Sascha Hauer
  2013-04-22 16:18   ` Re[2]: " Alexander Shiyan
  0 siblings, 1 reply; 3+ messages in thread
From: Sascha Hauer @ 2013-04-22 16:10 UTC (permalink / raw)
  To: Oleksij Rempel; +Cc: barebox, Oleksij Rempel

On Mon, Apr 22, 2013 at 10:53:50AM +0200, Oleksij Rempel wrote:
> From: Oleksij Rempel <bug-track@fisher-privat.net>
> 
> diff --git a/drivers/nor/cfi_flash.h b/drivers/nor/cfi_flash.h
> index 8f818ba..6c7cac4 100644
> --- a/drivers/nor/cfi_flash.h
> +++ b/drivers/nor/cfi_flash.h
> @@ -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

-- 
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
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re[2]: [PATCH 1/3] cfi_flash: add shift option for some cfi memory chips
  2013-04-22 16:10 ` Sascha Hauer
@ 2013-04-22 16:18   ` Alexander Shiyan
  0 siblings, 0 replies; 3+ messages in thread
From: Alexander Shiyan @ 2013-04-22 16:18 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox, Oleksij Rempel

> From: Oleksij Rempel <bug-track@fisher-privat.net>
> > 
> > diff --git a/drivers/nor/cfi_flash.h b/drivers/nor/cfi_flash.h
> > index 8f818ba..6c7cac4 100644
> > --- a/drivers/nor/cfi_flash.h
> > +++ b/drivers/nor/cfi_flash.h
> > @@ -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?

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
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2013-04-22 16:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-22  8:53 [PATCH 1/3] cfi_flash: add shift option for some cfi memory chips Oleksij Rempel
2013-04-22 16:10 ` Sascha Hauer
2013-04-22 16:18   ` Re[2]: " Alexander Shiyan

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