mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] read cfi device id according the bus width
@ 2012-11-22  6:49 张忠山
  2012-11-22  7:25 ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 1 reply; 9+ messages in thread
From: 张忠山 @ 2012-11-22  6:49 UTC (permalink / raw)
  To: barebox

Signed-off-by: 张忠山 <zzs213@126.com>
---
 drivers/nor/cfi_flash_amd.c   |    7 +++++--
 drivers/nor/cfi_flash_intel.c |    7 +++++--
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/nor/cfi_flash_amd.c b/drivers/nor/cfi_flash_amd.c
index 45c59b9..3ab4be0 100644
--- a/drivers/nor/cfi_flash_amd.c
+++ b/drivers/nor/cfi_flash_amd.c
@@ -62,8 +62,11 @@ static void amd_read_jedec_ids (struct flash_info *info)
 	udelay(1000); /* some flash are slow to respond */
 
 	info->manufacturer_id = jedec_read_mfr(info);
-	info->device_id = flash_read_uchar (info,
-					FLASH_OFFSET_DEVICE_ID);
+	if(info->chipwidth == FLASH_CFI_BY16)
+		info->device_id = flash_read16(flash_make_addr(info, 0, FLASH_OFFSET_DEVICE_ID));
+	else
+		info->device_id = flash_read_uchar (info,
+						FLASH_OFFSET_DEVICE_ID);
 	if (info->device_id == 0x7E) {
 		/* AMD 3-byte (expanded) device ids */
 		info->device_id2 = flash_read_uchar (info,
diff --git a/drivers/nor/cfi_flash_intel.c b/drivers/nor/cfi_flash_intel.c
index 32e581a..75dc5a8 100644
--- a/drivers/nor/cfi_flash_intel.c
+++ b/drivers/nor/cfi_flash_intel.c
@@ -19,8 +19,11 @@ static void intel_read_jedec_ids (struct flash_info *info)
 	udelay(1000); /* some flash are slow to respond */
 
 	info->manufacturer_id = jedec_read_mfr(info);
-	info->device_id = flash_read_uchar (info,
-					FLASH_OFFSET_DEVICE_ID);
+	if(info->chipwidth == FLASH_CFI_BY16)
+		info->device_id = flash_read16(flash_make_addr(info, 0, FLASH_OFFSET_DEVICE_ID));
+	else
+		info->device_id = flash_read_uchar (info,
+						FLASH_OFFSET_DEVICE_ID);
 	flash_write_cmd(info, 0, 0, info->cmd_reset);
 }
 
-- 
1.7.4.4



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

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

* Re: [PATCH] read cfi device id according the bus width
  2012-11-22  6:49 [PATCH] read cfi device id according the bus width 张忠山
@ 2012-11-22  7:25 ` Jean-Christophe PLAGNIOL-VILLARD
  2012-11-22  8:06   ` 张忠山
  0 siblings, 1 reply; 9+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-11-22  7:25 UTC (permalink / raw)
  To: 张忠山; +Cc: barebox

On 14:49 Thu 22 Nov     , 张忠山 wrote:
> Signed-off-by: 张忠山 <zzs213@126.com>
> ---
>  drivers/nor/cfi_flash_amd.c   |    7 +++++--
>  drivers/nor/cfi_flash_intel.c |    7 +++++--
>  2 files changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/nor/cfi_flash_amd.c b/drivers/nor/cfi_flash_amd.c
> index 45c59b9..3ab4be0 100644
> --- a/drivers/nor/cfi_flash_amd.c
> +++ b/drivers/nor/cfi_flash_amd.c
> @@ -62,8 +62,11 @@ static void amd_read_jedec_ids (struct flash_info *info)
>  	udelay(1000); /* some flash are slow to respond */
>  
>  	info->manufacturer_id = jedec_read_mfr(info);
> -	info->device_id = flash_read_uchar (info,
> -					FLASH_OFFSET_DEVICE_ID);
> +	if(info->chipwidth == FLASH_CFI_BY16)
> +		info->device_id = flash_read16(flash_make_addr(info, 0, FLASH_OFFSET_DEVICE_ID));
> +	else
> +		info->device_id = flash_read_uchar (info,
> +						FLASH_OFFSET_DEVICE_ID);
>  	if (info->device_id == 0x7E) {
>  		/* AMD 3-byte (expanded) device ids */
>  		info->device_id2 = flash_read_uchar (info,
> diff --git a/drivers/nor/cfi_flash_intel.c b/drivers/nor/cfi_flash_intel.c
> index 32e581a..75dc5a8 100644
> --- a/drivers/nor/cfi_flash_intel.c
> +++ b/drivers/nor/cfi_flash_intel.c
> @@ -19,8 +19,11 @@ static void intel_read_jedec_ids (struct flash_info *info)
>  	udelay(1000); /* some flash are slow to respond */
>  
>  	info->manufacturer_id = jedec_read_mfr(info);
> -	info->device_id = flash_read_uchar (info,
> -					FLASH_OFFSET_DEVICE_ID);
> +	if(info->chipwidth == FLASH_CFI_BY16)
> +		info->device_id = flash_read16(flash_make_addr(info, 0, FLASH_OFFSET_DEVICE_ID));
> +	else
> +		info->device_id = flash_read_uchar (info,
> +						FLASH_OFFSET_DEVICE_ID);
>  	flash_write_cmd(info, 0, 0, info->cmd_reset);

I said factorize not duplicate

and you need to handle all the with not only 8 and 16

Best Regards,
J.
>  }
>  
> -- 
> 1.7.4.4
> 
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox

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

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

* Re: [PATCH] read cfi device id according the bus width
  2012-11-22  7:25 ` Jean-Christophe PLAGNIOL-VILLARD
@ 2012-11-22  8:06   ` 张忠山
  0 siblings, 0 replies; 9+ messages in thread
From: 张忠山 @ 2012-11-22  8:06 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox

> I said factorize not duplicate
>
> and you need to handle all the with not only 8 and 16
>
I check the kernel code, th id defined in cfi_private is "int",
but in barebox is a ushort.

When width is 32, How to save the id?

-- 
Best Regards,
zzs



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

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

* Re: [PATCH] read cfi device id according the bus width
  2012-11-22  6:26   ` 张忠山
@ 2012-11-22  6:38     ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 0 replies; 9+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-11-22  6:38 UTC (permalink / raw)
  To: barebox

On 14:26 Thu 22 Nov     , 张忠山 wrote:
> In message <20121122061438.GR8327@game.jcrosoft.org> Jean-Christophe PLAGNIOL-VILLARD wrote:
> > On 14:01 Thu 22 Nov     , 张忠山 wrote:
> > > Signed-off-by: 张忠山 <zzs213@126.com>
> > > ---
> > >  drivers/nor/cfi_flash_amd.c |    7 +++++--
> > >  1 files changed, 5 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/drivers/nor/cfi_flash_amd.c b/drivers/nor/cfi_flash_amd.c
> > > index 45c59b9..3ab4be0 100644
> > > --- a/drivers/nor/cfi_flash_amd.c
> > > +++ b/drivers/nor/cfi_flash_amd.c
> > > @@ -62,8 +62,11 @@ static void amd_read_jedec_ids (struct flash_info *info)
> > >  	udelay(1000); /* some flash are slow to respond */
> > >
> > >  	info->manufacturer_id = jedec_read_mfr(info);
> > > -	info->device_id = flash_read_uchar (info,
> > > -					FLASH_OFFSET_DEVICE_ID);
> > > +	if(info->chipwidth == FLASH_CFI_BY16)
> > > +		info->device_id = flash_read16(flash_make_addr(info, 0, FLASH_OFFSET_DEVICE_ID));
> > > +	else
> > > +		info->device_id = flash_read_uchar (info,
> > > +						FLASH_OFFSET_DEVICE_ID);
> >
> > make this global with all with support
> > as don in linux
> >
> > as this is valid for amd and intel and st
> >
> Does this mean cp this code to the function
> drivers/nor/cfi_flash_intel.c:intel_read_jedec_ids() ?
you can not as the reset is flash depedent

just factorise teh device_id read

Best Regards,
J.

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

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

* Re: [PATCH] read cfi device id according the bus width
  2012-11-22  6:14 ` Jean-Christophe PLAGNIOL-VILLARD
@ 2012-11-22  6:26   ` 张忠山
  2012-11-22  6:38     ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 1 reply; 9+ messages in thread
From: 张忠山 @ 2012-11-22  6:26 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox

In message <20121122061438.GR8327@game.jcrosoft.org> Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 14:01 Thu 22 Nov     , 张忠山 wrote:
> > Signed-off-by: 张忠山 <zzs213@126.com>
> > ---
> >  drivers/nor/cfi_flash_amd.c |    7 +++++--
> >  1 files changed, 5 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/nor/cfi_flash_amd.c b/drivers/nor/cfi_flash_amd.c
> > index 45c59b9..3ab4be0 100644
> > --- a/drivers/nor/cfi_flash_amd.c
> > +++ b/drivers/nor/cfi_flash_amd.c
> > @@ -62,8 +62,11 @@ static void amd_read_jedec_ids (struct flash_info *info)
> >  	udelay(1000); /* some flash are slow to respond */
> >
> >  	info->manufacturer_id = jedec_read_mfr(info);
> > -	info->device_id = flash_read_uchar (info,
> > -					FLASH_OFFSET_DEVICE_ID);
> > +	if(info->chipwidth == FLASH_CFI_BY16)
> > +		info->device_id = flash_read16(flash_make_addr(info, 0, FLASH_OFFSET_DEVICE_ID));
> > +	else
> > +		info->device_id = flash_read_uchar (info,
> > +						FLASH_OFFSET_DEVICE_ID);
>
> make this global with all with support
> as don in linux
>
> as this is valid for amd and intel and st
>
Does this mean cp this code to the function
drivers/nor/cfi_flash_intel.c:intel_read_jedec_ids() ?
-- 
Best Regards,
zzs



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

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

* Re: [PATCH] read cfi device id according the bus width
  2012-11-22  6:01 张忠山
@ 2012-11-22  6:14 ` Jean-Christophe PLAGNIOL-VILLARD
  2012-11-22  6:26   ` 张忠山
  0 siblings, 1 reply; 9+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-11-22  6:14 UTC (permalink / raw)
  To: 张忠山; +Cc: barebox

On 14:01 Thu 22 Nov     , 张忠山 wrote:
> Signed-off-by: 张忠山 <zzs213@126.com>
> ---
>  drivers/nor/cfi_flash_amd.c |    7 +++++--
>  1 files changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/nor/cfi_flash_amd.c b/drivers/nor/cfi_flash_amd.c
> index 45c59b9..3ab4be0 100644
> --- a/drivers/nor/cfi_flash_amd.c
> +++ b/drivers/nor/cfi_flash_amd.c
> @@ -62,8 +62,11 @@ static void amd_read_jedec_ids (struct flash_info *info)
>  	udelay(1000); /* some flash are slow to respond */
>  
>  	info->manufacturer_id = jedec_read_mfr(info);
> -	info->device_id = flash_read_uchar (info,
> -					FLASH_OFFSET_DEVICE_ID);
> +	if(info->chipwidth == FLASH_CFI_BY16)
> +		info->device_id = flash_read16(flash_make_addr(info, 0, FLASH_OFFSET_DEVICE_ID));
> +	else
> +		info->device_id = flash_read_uchar (info,
> +						FLASH_OFFSET_DEVICE_ID);

make this global with all with support
as don in linux

as this is valid for amd and intel and st

Best Regards.
J.
>  	if (info->device_id == 0x7E) {
>  		/* AMD 3-byte (expanded) device ids */
>  		info->device_id2 = flash_read_uchar (info,
> -- 
> 1.7.4.4
> 
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox

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

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

* [PATCH] read cfi device id according the bus width
@ 2012-11-22  6:01 张忠山
  2012-11-22  6:14 ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 1 reply; 9+ messages in thread
From: 张忠山 @ 2012-11-22  6:01 UTC (permalink / raw)
  To: barebox

Signed-off-by: 张忠山 <zzs213@126.com>
---
 drivers/nor/cfi_flash_amd.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/nor/cfi_flash_amd.c b/drivers/nor/cfi_flash_amd.c
index 45c59b9..3ab4be0 100644
--- a/drivers/nor/cfi_flash_amd.c
+++ b/drivers/nor/cfi_flash_amd.c
@@ -62,8 +62,11 @@ static void amd_read_jedec_ids (struct flash_info *info)
 	udelay(1000); /* some flash are slow to respond */
 
 	info->manufacturer_id = jedec_read_mfr(info);
-	info->device_id = flash_read_uchar (info,
-					FLASH_OFFSET_DEVICE_ID);
+	if(info->chipwidth == FLASH_CFI_BY16)
+		info->device_id = flash_read16(flash_make_addr(info, 0, FLASH_OFFSET_DEVICE_ID));
+	else
+		info->device_id = flash_read_uchar (info,
+						FLASH_OFFSET_DEVICE_ID);
 	if (info->device_id == 0x7E) {
 		/* AMD 3-byte (expanded) device ids */
 		info->device_id2 = flash_read_uchar (info,
-- 
1.7.4.4



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

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

* Re: [PATCH] read cfi device id according the bus width
  2012-11-22  1:48 张忠山
@ 2012-11-22  5:46 ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 0 replies; 9+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-11-22  5:46 UTC (permalink / raw)
  To: 张忠山; +Cc: barebox

On 09:48 Thu 22 Nov     , 张忠山 wrote:
> Signed-off-by: 张忠山 <zzs213@126.com>
> ---
>  drivers/nor/cfi_flash_amd.c |   22 +++++++++++++---------
>  1 files changed, 13 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/nor/cfi_flash_amd.c b/drivers/nor/cfi_flash_amd.c
> index 45c59b9..8384f46 100644
> --- a/drivers/nor/cfi_flash_amd.c
> +++ b/drivers/nor/cfi_flash_amd.c
> @@ -62,15 +62,19 @@ static void amd_read_jedec_ids (struct flash_info *info)
>  	udelay(1000); /* some flash are slow to respond */
>  
>  	info->manufacturer_id = jedec_read_mfr(info);
> -	info->device_id = flash_read_uchar (info,
> -					FLASH_OFFSET_DEVICE_ID);
> -	if (info->device_id == 0x7E) {
> -		/* AMD 3-byte (expanded) device ids */
> -		info->device_id2 = flash_read_uchar (info,
> -					FLASH_OFFSET_DEVICE_ID2);
> -		info->device_id2 <<= 8;
> -		info->device_id2 |= flash_read_uchar (info,
> -					FLASH_OFFSET_DEVICE_ID3);
> +	if(info->chipwidth == FLASH_CFI_BY16) {
> +		info->device_id = flash_read16(flash_make_addr(info, 0, FLASH_OFFSET_DEVICE_ID));
> +	} else {
> +		info->device_id = flash_read_uchar (info,
> +						FLASH_OFFSET_DEVICE_ID);
> +		if (info->device_id == 0x7E) {
> +			/* AMD 3-byte (expanded) device ids */
> +			info->device_id2 = flash_read_uchar (info,
> +						FLASH_OFFSET_DEVICE_ID2);
> +			info->device_id2 <<= 8;
> +			info->device_id2 |= flash_read_uchar (info,
> +						FLASH_OFFSET_DEVICE_ID3);
> +		}
id2 is present nom matter the bus width

Best Regards,
J.
>  	}
>  	flash_write_cmd(info, 0, 0, info->cmd_reset);
>  }
> -- 
> 1.7.4.4
> 
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox

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

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

* [PATCH] read cfi device id according the bus width
@ 2012-11-22  1:48 张忠山
  2012-11-22  5:46 ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 1 reply; 9+ messages in thread
From: 张忠山 @ 2012-11-22  1:48 UTC (permalink / raw)
  To: barebox

Signed-off-by: 张忠山 <zzs213@126.com>
---
 drivers/nor/cfi_flash_amd.c |   22 +++++++++++++---------
 1 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/drivers/nor/cfi_flash_amd.c b/drivers/nor/cfi_flash_amd.c
index 45c59b9..8384f46 100644
--- a/drivers/nor/cfi_flash_amd.c
+++ b/drivers/nor/cfi_flash_amd.c
@@ -62,15 +62,19 @@ static void amd_read_jedec_ids (struct flash_info *info)
 	udelay(1000); /* some flash are slow to respond */
 
 	info->manufacturer_id = jedec_read_mfr(info);
-	info->device_id = flash_read_uchar (info,
-					FLASH_OFFSET_DEVICE_ID);
-	if (info->device_id == 0x7E) {
-		/* AMD 3-byte (expanded) device ids */
-		info->device_id2 = flash_read_uchar (info,
-					FLASH_OFFSET_DEVICE_ID2);
-		info->device_id2 <<= 8;
-		info->device_id2 |= flash_read_uchar (info,
-					FLASH_OFFSET_DEVICE_ID3);
+	if(info->chipwidth == FLASH_CFI_BY16) {
+		info->device_id = flash_read16(flash_make_addr(info, 0, FLASH_OFFSET_DEVICE_ID));
+	} else {
+		info->device_id = flash_read_uchar (info,
+						FLASH_OFFSET_DEVICE_ID);
+		if (info->device_id == 0x7E) {
+			/* AMD 3-byte (expanded) device ids */
+			info->device_id2 = flash_read_uchar (info,
+						FLASH_OFFSET_DEVICE_ID2);
+			info->device_id2 <<= 8;
+			info->device_id2 |= flash_read_uchar (info,
+						FLASH_OFFSET_DEVICE_ID3);
+		}
 	}
 	flash_write_cmd(info, 0, 0, info->cmd_reset);
 }
-- 
1.7.4.4



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

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

end of thread, other threads:[~2012-11-22  8:08 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-22  6:49 [PATCH] read cfi device id according the bus width 张忠山
2012-11-22  7:25 ` Jean-Christophe PLAGNIOL-VILLARD
2012-11-22  8:06   ` 张忠山
  -- strict thread matches above, loose matches on Subject: below --
2012-11-22  6:01 张忠山
2012-11-22  6:14 ` Jean-Christophe PLAGNIOL-VILLARD
2012-11-22  6:26   ` 张忠山
2012-11-22  6:38     ` Jean-Christophe PLAGNIOL-VILLARD
2012-11-22  1:48 张忠山
2012-11-22  5:46 ` Jean-Christophe PLAGNIOL-VILLARD

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