mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 0/2] cfi fixes
@ 2013-05-22  7:53 Oleksij Rempel
  2013-05-22  7:53 ` [PATCH 1/2 v2] cfi_flash: add shift option for some cfi memory chips Oleksij Rempel
  2013-05-22  7:53 ` [PATCH 2/2] cfi_flash: size_ratio should not be 0 Oleksij Rempel
  0 siblings, 2 replies; 7+ messages in thread
From: Oleksij Rempel @ 2013-05-22  7:53 UTC (permalink / raw)
  To: barebox

this patch set will fix autodetection of cfi flash devicese
with extra LSB bit.

Oleksij Rempel (2):
  cfi_flash: add shift option for some cfi memory chips
  cfi_flash: size_ratio should not be 0

 drivers/mtd/nor/cfi_flash.c | 26 +++++++++++++++++++++-----
 drivers/mtd/nor/cfi_flash.h |  4 +++-
 2 files changed, 24 insertions(+), 6 deletions(-)

-- 
1.8.1.2


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

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

* [PATCH 1/2 v2] cfi_flash: add shift option for some cfi memory chips
  2013-05-22  7:53 [PATCH 0/2] cfi fixes Oleksij Rempel
@ 2013-05-22  7:53 ` Oleksij Rempel
  2013-05-23 13:13   ` Sascha Hauer
  2013-05-22  7:53 ` [PATCH 2/2] cfi_flash: size_ratio should not be 0 Oleksij Rempel
  1 sibling, 1 reply; 7+ messages in thread
From: Oleksij Rempel @ 2013-05-22  7: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

Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
---
 drivers/mtd/nor/cfi_flash.c | 23 +++++++++++++++++++----
 drivers/mtd/nor/cfi_flash.h |  4 +++-
 2 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/drivers/mtd/nor/cfi_flash.c b/drivers/mtd/nor/cfi_flash.c
index 0cfac2d..4b4e29d 100644
--- a/drivers/mtd/nor/cfi_flash.c
+++ b/drivers/mtd/nor/cfi_flash.c
@@ -240,10 +240,10 @@ static void flash_read_cfi (struct flash_info *info, void *buf,
 		p[i] = flash_read_uchar(info, start + i);
 }
 
-static int flash_detect_cfi (struct flash_info *info, struct cfi_qry *qry)
+static int flash_detect_width (struct flash_info *info, struct cfi_qry *qry)
 {
 	int cfi_offset;
-	debug ("flash detect cfi\n");
+
 
 	for (info->portwidth = CFG_FLASH_CFI_WIDTH;
 	     info->portwidth <= FLASH_CFI_64BIT; info->portwidth <<= 1) {
@@ -264,8 +264,8 @@ static int flash_detect_cfi (struct flash_info *info, struct cfi_qry *qry)
 					info->cfi_offset=flash_offset_cfi[cfi_offset];
 					debug ("device interface is %d\n",
 						info->interface);
-					debug ("found port %d chip %d ",
-						info->portwidth, info->chipwidth);
+					debug ("found port %d chip %d chip_lsb %d ",
+						info->portwidth, info->chipwidth, info->chip_lsb);
 					debug ("port %d bits chip %d bits\n",
 						info->portwidth << CFI_FLASH_SHIFT_WIDTH,
 						info->chipwidth << CFI_FLASH_SHIFT_WIDTH);
@@ -278,6 +278,21 @@ static int flash_detect_cfi (struct flash_info *info, struct cfi_qry *qry)
 	return 0;
 }
 
+static int flash_detect_cfi (struct flash_info *info, struct cfi_qry *qry)
+{
+	int ret;
+
+	debug ("flash detect cfi\n");
+
+	info->chip_lsb = 0;
+	ret = flash_detect_width (info, qry);
+	if (!ret) {
+		info->chip_lsb = 1;
+		ret = flash_detect_width (info, qry);
+	}
+	return ret;
+}
+
 /*
  * The following code cannot be run from FLASH!
  */
diff --git a/drivers/mtd/nor/cfi_flash.h b/drivers/mtd/nor/cfi_flash.h
index bcf5c40..2a2454c 100644
--- a/drivers/mtd/nor/cfi_flash.h
+++ b/drivers/mtd/nor/cfi_flash.h
@@ -57,6 +57,8 @@ struct flash_info {
 
 	uchar	portwidth;		/* the width of the port		*/
 	uchar	chipwidth;		/* the width of the chip		*/
+	uchar	chip_lsb;		/* extra Least Significant Bit in the	*/
+					/*   address of chip.			*/
 	ushort	buffer_size;		/* # of bytes in write buffer		*/
 	ulong	erase_blk_tout;		/* maximum block erase timeout		*/
 	ulong	write_tout;		/* maximum write timeout		*/
@@ -298,7 +300,7 @@ static inline u64 flash_read64(void *addr)
  */
 static inline uchar *flash_make_addr (struct flash_info *info, flash_sect_t sect, uint offset)
 {
-	return ((uchar *) (info->start[sect] + (offset * info->portwidth)));
+	return ((uchar *) (info->start[sect] + ((offset * info->portwidth) << info->chip_lsb)));
 }
 
 uchar flash_read_uchar (struct flash_info *info, uint offset);
-- 
1.8.1.2


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

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

* [PATCH 2/2] cfi_flash: size_ratio should not be 0
  2013-05-22  7:53 [PATCH 0/2] cfi fixes Oleksij Rempel
  2013-05-22  7:53 ` [PATCH 1/2 v2] cfi_flash: add shift option for some cfi memory chips Oleksij Rempel
@ 2013-05-22  7:53 ` Oleksij Rempel
  2013-05-23 13:13   ` Sascha Hauer
  2013-05-27  8:30   ` Sascha Hauer
  1 sibling, 2 replies; 7+ messages in thread
From: Oleksij Rempel @ 2013-05-22  7:53 UTC (permalink / raw)
  To: barebox

We will get size = 0 if size_ratio = 0

Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
---
 drivers/mtd/nor/cfi_flash.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/nor/cfi_flash.c b/drivers/mtd/nor/cfi_flash.c
index 4b4e29d..85e96ce 100644
--- a/drivers/mtd/nor/cfi_flash.c
+++ b/drivers/mtd/nor/cfi_flash.c
@@ -371,7 +371,8 @@ static ulong flash_get_size (struct flash_info *info)
 		size_ratio = info->portwidth / info->chipwidth;
 		/* if the chip is x8/x16 reduce the ratio by half */
 		if ((info->interface == FLASH_CFI_X8X16)
-		    && (info->chipwidth == FLASH_CFI_BY8)) {
+		    && (info->chipwidth == FLASH_CFI_BY8)
+		    && (size_ratio != 1)) {
 			size_ratio >>= 1;
 		}
 		debug ("size_ratio %d port %d bits chip %d bits\n",
-- 
1.8.1.2


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

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

* Re: [PATCH 1/2 v2] cfi_flash: add shift option for some cfi memory chips
  2013-05-22  7:53 ` [PATCH 1/2 v2] cfi_flash: add shift option for some cfi memory chips Oleksij Rempel
@ 2013-05-23 13:13   ` Sascha Hauer
  0 siblings, 0 replies; 7+ messages in thread
From: Sascha Hauer @ 2013-05-23 13:13 UTC (permalink / raw)
  To: Oleksij Rempel; +Cc: barebox, Oleksij Rempel

On Wed, May 22, 2013 at 09:53:39AM +0200, Oleksij Rempel wrote:
> 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
> 
> Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>

Applied, thanks

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] 7+ messages in thread

* Re: [PATCH 2/2] cfi_flash: size_ratio should not be 0
  2013-05-22  7:53 ` [PATCH 2/2] cfi_flash: size_ratio should not be 0 Oleksij Rempel
@ 2013-05-23 13:13   ` Sascha Hauer
  2013-05-23 13:37     ` Oleksij Rempel
  2013-05-27  8:30   ` Sascha Hauer
  1 sibling, 1 reply; 7+ messages in thread
From: Sascha Hauer @ 2013-05-23 13:13 UTC (permalink / raw)
  To: Oleksij Rempel; +Cc: barebox

On Wed, May 22, 2013 at 09:53:40AM +0200, Oleksij Rempel wrote:
> We will get size = 0 if size_ratio = 0
> 
> Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
> ---
>  drivers/mtd/nor/cfi_flash.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mtd/nor/cfi_flash.c b/drivers/mtd/nor/cfi_flash.c
> index 4b4e29d..85e96ce 100644
> --- a/drivers/mtd/nor/cfi_flash.c
> +++ b/drivers/mtd/nor/cfi_flash.c
> @@ -371,7 +371,8 @@ static ulong flash_get_size (struct flash_info *info)
>  		size_ratio = info->portwidth / info->chipwidth;
>  		/* if the chip is x8/x16 reduce the ratio by half */
>  		if ((info->interface == FLASH_CFI_X8X16)
> -		    && (info->chipwidth == FLASH_CFI_BY8)) {
> +		    && (info->chipwidth == FLASH_CFI_BY8)
> +		    && (size_ratio != 1)) {
>  			size_ratio >>= 1;
>  		}

Could you elaborate in which constellation this happens?

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] 7+ messages in thread

* Re: [PATCH 2/2] cfi_flash: size_ratio should not be 0
  2013-05-23 13:13   ` Sascha Hauer
@ 2013-05-23 13:37     ` Oleksij Rempel
  0 siblings, 0 replies; 7+ messages in thread
From: Oleksij Rempel @ 2013-05-23 13:37 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

Am 23.05.2013 15:13, schrieb Sascha Hauer:
> On Wed, May 22, 2013 at 09:53:40AM +0200, Oleksij Rempel wrote:
>> We will get size = 0 if size_ratio = 0
>>
>> Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
>> ---
>>   drivers/mtd/nor/cfi_flash.c | 3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/mtd/nor/cfi_flash.c b/drivers/mtd/nor/cfi_flash.c
>> index 4b4e29d..85e96ce 100644
>> --- a/drivers/mtd/nor/cfi_flash.c
>> +++ b/drivers/mtd/nor/cfi_flash.c
>> @@ -371,7 +371,8 @@ static ulong flash_get_size (struct flash_info *info)
>>   		size_ratio = info->portwidth / info->chipwidth;
>>   		/* if the chip is x8/x16 reduce the ratio by half */
>>   		if ((info->interface == FLASH_CFI_X8X16)
>> -		    && (info->chipwidth == FLASH_CFI_BY8)) {
>> +		    && (info->chipwidth == FLASH_CFI_BY8)
>> +		    && (size_ratio != 1)) {
>>   			size_ratio >>= 1;
>>   		}
>
> Could you elaborate in which constellation this happens?

It happens in my case with MX29LV320MBTC attached to atheros ar2313. 
Both of them support x8 and x16 modes, but attached only in x8. Plus 
this chip enables LSB in 8 bit mode.

-- 
Regards,
Oleksij

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

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

* Re: [PATCH 2/2] cfi_flash: size_ratio should not be 0
  2013-05-22  7:53 ` [PATCH 2/2] cfi_flash: size_ratio should not be 0 Oleksij Rempel
  2013-05-23 13:13   ` Sascha Hauer
@ 2013-05-27  8:30   ` Sascha Hauer
  1 sibling, 0 replies; 7+ messages in thread
From: Sascha Hauer @ 2013-05-27  8:30 UTC (permalink / raw)
  To: Oleksij Rempel; +Cc: barebox

On Wed, May 22, 2013 at 09:53:40AM +0200, Oleksij Rempel wrote:
> We will get size = 0 if size_ratio = 0
> 
> Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>

Applied, thanks

Sascha

> ---
>  drivers/mtd/nor/cfi_flash.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mtd/nor/cfi_flash.c b/drivers/mtd/nor/cfi_flash.c
> index 4b4e29d..85e96ce 100644
> --- a/drivers/mtd/nor/cfi_flash.c
> +++ b/drivers/mtd/nor/cfi_flash.c
> @@ -371,7 +371,8 @@ static ulong flash_get_size (struct flash_info *info)
>  		size_ratio = info->portwidth / info->chipwidth;
>  		/* if the chip is x8/x16 reduce the ratio by half */
>  		if ((info->interface == FLASH_CFI_X8X16)
> -		    && (info->chipwidth == FLASH_CFI_BY8)) {
> +		    && (info->chipwidth == FLASH_CFI_BY8)
> +		    && (size_ratio != 1)) {
>  			size_ratio >>= 1;
>  		}
>  		debug ("size_ratio %d port %d bits chip %d bits\n",
> -- 
> 1.8.1.2
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
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] 7+ messages in thread

end of thread, other threads:[~2013-05-27  8:30 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-22  7:53 [PATCH 0/2] cfi fixes Oleksij Rempel
2013-05-22  7:53 ` [PATCH 1/2 v2] cfi_flash: add shift option for some cfi memory chips Oleksij Rempel
2013-05-23 13:13   ` Sascha Hauer
2013-05-22  7:53 ` [PATCH 2/2] cfi_flash: size_ratio should not be 0 Oleksij Rempel
2013-05-23 13:13   ` Sascha Hauer
2013-05-23 13:37     ` Oleksij Rempel
2013-05-27  8:30   ` Sascha Hauer

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