public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot-Users] [PATCH] Add support for 16bit legacy AMD flash
@ 2008-03-28  7:45 Tor Krill
  2008-03-28  9:47 ` Stefan Roese
  0 siblings, 1 reply; 4+ messages in thread
From: Tor Krill @ 2008-03-28  7:45 UTC (permalink / raw)
  To: u-boot

Add entry for 512Kx16 AMD flash to jedec_table.
Read out 16bit device id if chipwidth is 16bit

Signed-off-by: Tor Krill <tor@excito.com>
---
 drivers/mtd/cfi_flash.c   |   44 +++++++++++++++++++++++++++++++++++---------
 drivers/mtd/jedec_flash.c |   19 +++++++++++++++++++
 2 files changed, 54 insertions(+), 9 deletions(-)

diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
index f04c72d..fab26b8 100644
--- a/drivers/mtd/cfi_flash.c
+++ b/drivers/mtd/cfi_flash.c
@@ -365,6 +365,20 @@ static inline uchar flash_read_uchar (flash_info_t * info, uint offset)
 }
 
 /*-----------------------------------------------------------------------
+ * read a word at a port width address, assume 16bit bus
+ */
+static inline ushort flash_read_word (flash_info_t * info, uint offset)
+{
+	ushort *addr, retval;
+
+	addr = flash_map (info, 0, offset);
+	retval = flash_read16(addr);
+	flash_unmap (info, 0, offset, addr);
+	return retval;
+}
+
+
+/*-----------------------------------------------------------------------
  * read a long word by picking the least significant byte of each maximum
  * port size word. Swap for ppc format.
  */
@@ -1449,17 +1463,29 @@ static void cmdset_amd_read_jedec_ids(flash_info_t *info)
 	flash_unlock_seq(info, 0);
 	flash_write_cmd(info, 0, info->addr_unlock1, FLASH_CMD_READ_ID);
 	udelay(1000); /* some flash are slow to respond */
+
 	info->manufacturer_id = flash_read_uchar (info,
 					FLASH_OFFSET_MANUFACTURER_ID);
-	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);
+
+	switch(info->chipwidth){
+	case FLASH_CFI_8BIT:
+		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);
+		}
+		break;
+	case FLASH_CFI_16BIT:
+		info->device_id = flash_read_word (info,
+						FLASH_OFFSET_DEVICE_ID);
+		break;
+	default:
+		break;
 	}
 	flash_write_cmd(info, 0, 0, AMD_CMD_RESET);
 }
diff --git a/drivers/mtd/jedec_flash.c b/drivers/mtd/jedec_flash.c
index 41aad3b..b958d17 100644
--- a/drivers/mtd/jedec_flash.c
+++ b/drivers/mtd/jedec_flash.c
@@ -216,6 +216,25 @@ static const struct amd_flash_info jedec_table[] = {
 		}
 	},
 #endif
+#ifdef CFG_FLASH_LEGACY_512Kx16
+	{
+		.mfr_id		= MANUFACTURER_AMD,
+		.dev_id		= AM29LV400BB,
+		.name		= "AMD AM29LV400BB",
+		.uaddr		= {
+			[1] = MTD_UADDR_0x0555_0x02AA /* x16 */
+		},
+		.DevSize	= SIZE_512KiB,
+		.CmdSet		= CFI_CMDSET_AMD_LEGACY,
+		.NumEraseRegions= 4,
+		.regions	= {
+			ERASEINFO(0x04000,1),
+			ERASEINFO(0x02000,2),
+			ERASEINFO(0x08000,1),
+			ERASEINFO(0x10000,7),
+		}
+	},
+#endif
 };
 
 static inline void fill_info(flash_info_t *info, const struct amd_flash_info *jedec_entry, ulong base)
-- 
1.5.4.4

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

* [U-Boot-Users] [PATCH] Add support for 16bit legacy AMD flash
  2008-03-28  7:45 [U-Boot-Users] [PATCH] Add support for 16bit legacy AMD flash Tor Krill
@ 2008-03-28  9:47 ` Stefan Roese
  2008-03-28 10:29   ` [U-Boot-Users] [PATCH] Add support for 16bit legacy AMD flash, V2 Tor Krill
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Roese @ 2008-03-28  9:47 UTC (permalink / raw)
  To: u-boot

On Friday 28 March 2008, Tor Krill wrote:
> Add entry for 512Kx16 AMD flash to jedec_table.
> Read out 16bit device id if chipwidth is 16bit
>
> Signed-off-by: Tor Krill <tor@excito.com>

Looks good. Just some nitpicking comments below.

> ---
>  drivers/mtd/cfi_flash.c   |   44
> +++++++++++++++++++++++++++++++++++--------- drivers/mtd/jedec_flash.c |  
> 19 +++++++++++++++++++
>  2 files changed, 54 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
> index f04c72d..fab26b8 100644
> --- a/drivers/mtd/cfi_flash.c
> +++ b/drivers/mtd/cfi_flash.c
> @@ -365,6 +365,20 @@ static inline uchar flash_read_uchar (flash_info_t *
> info, uint offset) }
>
>  /*-----------------------------------------------------------------------
> + * read a word at a port width address, assume 16bit bus
> + */
> +static inline ushort flash_read_word (flash_info_t * info, uint offset)
> +{
> +	ushort *addr, retval;
> +
> +	addr = flash_map (info, 0, offset);
> +	retval = flash_read16(addr);

No space before '(' here...

> +	flash_unmap (info, 0, offset, addr);

... and space before '(' here. Please stick to one coding style in one file. 
Since this file uses the space before the '(' you should use it on all calls.

> +	return retval;
> +}
> +
> +
> +/*-----------------------------------------------------------------------
>   * read a long word by picking the least significant byte of each maximum
>   * port size word. Swap for ppc format.
>   */
> @@ -1449,17 +1463,29 @@ static void cmdset_amd_read_jedec_ids(flash_info_t
> *info) flash_unlock_seq(info, 0);
>  	flash_write_cmd(info, 0, info->addr_unlock1, FLASH_CMD_READ_ID);
>  	udelay(1000); /* some flash are slow to respond */
> +
>  	info->manufacturer_id = flash_read_uchar (info,
>  					FLASH_OFFSET_MANUFACTURER_ID);
> -	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);
> +
> +	switch(info->chipwidth){

	switch (info->chipwidth) {

> +	case FLASH_CFI_8BIT:
> +		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);
> +		}
> +		break;
> +	case FLASH_CFI_16BIT:
> +		info->device_id = flash_read_word (info,
> +						FLASH_OFFSET_DEVICE_ID);
> +		break;
> +	default:
> +		break;
>  	}
>  	flash_write_cmd(info, 0, 0, AMD_CMD_RESET);
>  }
> diff --git a/drivers/mtd/jedec_flash.c b/drivers/mtd/jedec_flash.c
> index 41aad3b..b958d17 100644
> --- a/drivers/mtd/jedec_flash.c
> +++ b/drivers/mtd/jedec_flash.c
> @@ -216,6 +216,25 @@ static const struct amd_flash_info jedec_table[] = {
>  		}
>  	},
>  #endif
> +#ifdef CFG_FLASH_LEGACY_512Kx16
> +	{
> +		.mfr_id		= MANUFACTURER_AMD,
> +		.dev_id		= AM29LV400BB,
> +		.name		= "AMD AM29LV400BB",
> +		.uaddr		= {
> +			[1] = MTD_UADDR_0x0555_0x02AA /* x16 */
> +		},
> +		.DevSize	= SIZE_512KiB,
> +		.CmdSet		= CFI_CMDSET_AMD_LEGACY,
> +		.NumEraseRegions= 4,
> +		.regions	= {
> +			ERASEINFO(0x04000,1),
> +			ERASEINFO(0x02000,2),
> +			ERASEINFO(0x08000,1),
> +			ERASEINFO(0x10000,7),
> +		}
> +	},
> +#endif
>  };
>
>  static inline void fill_info(flash_info_t *info, const struct
> amd_flash_info *jedec_entry, ulong base)

Please fix and resubmit. Thanks.

Best regards,
Stefan

=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
=====================================================================

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

* [U-Boot-Users] [PATCH] Add support for 16bit legacy AMD flash, V2
  2008-03-28  9:47 ` Stefan Roese
@ 2008-03-28 10:29   ` Tor Krill
  2008-03-29  6:08     ` Stefan Roese
  0 siblings, 1 reply; 4+ messages in thread
From: Tor Krill @ 2008-03-28 10:29 UTC (permalink / raw)
  To: u-boot

Add entry for 512Kx16 AMD flash to jedec_table.
Read out 16bit device id if chipwidth is 16bit.
Fixed coding style after Stefans feedback

Signed-off-by: Tor Krill <tor@excito.com>
---
 drivers/mtd/cfi_flash.c   |   44 +++++++++++++++++++++++++++++++++++---------
 drivers/mtd/jedec_flash.c |   19 +++++++++++++++++++
 2 files changed, 54 insertions(+), 9 deletions(-)

diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
index f04c72d..3f8911e 100644
--- a/drivers/mtd/cfi_flash.c
+++ b/drivers/mtd/cfi_flash.c
@@ -365,6 +365,20 @@ static inline uchar flash_read_uchar (flash_info_t * info, uint offset)
 }
 
 /*-----------------------------------------------------------------------
+ * read a word at a port width address, assume 16bit bus
+ */
+static inline ushort flash_read_word (flash_info_t * info, uint offset)
+{
+	ushort *addr, retval;
+
+	addr = flash_map (info, 0, offset);
+	retval = flash_read16 (addr);
+	flash_unmap (info, 0, offset, addr);
+	return retval;
+}
+
+
+/*-----------------------------------------------------------------------
  * read a long word by picking the least significant byte of each maximum
  * port size word. Swap for ppc format.
  */
@@ -1449,17 +1463,29 @@ static void cmdset_amd_read_jedec_ids(flash_info_t *info)
 	flash_unlock_seq(info, 0);
 	flash_write_cmd(info, 0, info->addr_unlock1, FLASH_CMD_READ_ID);
 	udelay(1000); /* some flash are slow to respond */
+
 	info->manufacturer_id = flash_read_uchar (info,
 					FLASH_OFFSET_MANUFACTURER_ID);
-	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);
+
+	switch (info->chipwidth){
+	case FLASH_CFI_8BIT:
+		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);
+		}
+		break;
+	case FLASH_CFI_16BIT:
+		info->device_id = flash_read_word (info,
+						FLASH_OFFSET_DEVICE_ID);
+		break;
+	default:
+		break;
 	}
 	flash_write_cmd(info, 0, 0, AMD_CMD_RESET);
 }
diff --git a/drivers/mtd/jedec_flash.c b/drivers/mtd/jedec_flash.c
index 41aad3b..b958d17 100644
--- a/drivers/mtd/jedec_flash.c
+++ b/drivers/mtd/jedec_flash.c
@@ -216,6 +216,25 @@ static const struct amd_flash_info jedec_table[] = {
 		}
 	},
 #endif
+#ifdef CFG_FLASH_LEGACY_512Kx16
+	{
+		.mfr_id		= MANUFACTURER_AMD,
+		.dev_id		= AM29LV400BB,
+		.name		= "AMD AM29LV400BB",
+		.uaddr		= {
+			[1] = MTD_UADDR_0x0555_0x02AA /* x16 */
+		},
+		.DevSize	= SIZE_512KiB,
+		.CmdSet		= CFI_CMDSET_AMD_LEGACY,
+		.NumEraseRegions= 4,
+		.regions	= {
+			ERASEINFO(0x04000,1),
+			ERASEINFO(0x02000,2),
+			ERASEINFO(0x08000,1),
+			ERASEINFO(0x10000,7),
+		}
+	},
+#endif
 };
 
 static inline void fill_info(flash_info_t *info, const struct amd_flash_info *jedec_entry, ulong base)
-- 
1.5.4.4

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

* [U-Boot-Users] [PATCH] Add support for 16bit legacy AMD flash, V2
  2008-03-28 10:29   ` [U-Boot-Users] [PATCH] Add support for 16bit legacy AMD flash, V2 Tor Krill
@ 2008-03-29  6:08     ` Stefan Roese
  0 siblings, 0 replies; 4+ messages in thread
From: Stefan Roese @ 2008-03-29  6:08 UTC (permalink / raw)
  To: u-boot

On Friday 28 March 2008, Tor Krill wrote:
> Add entry for 512Kx16 AMD flash to jedec_table.
> Read out 16bit device id if chipwidth is 16bit.
> Fixed coding style after Stefans feedback

Added to cfi-flash repository. Thanks.

Best regards,
Stefan

=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
=====================================================================

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

end of thread, other threads:[~2008-03-29  6:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-28  7:45 [U-Boot-Users] [PATCH] Add support for 16bit legacy AMD flash Tor Krill
2008-03-28  9:47 ` Stefan Roese
2008-03-28 10:29   ` [U-Boot-Users] [PATCH] Add support for 16bit legacy AMD flash, V2 Tor Krill
2008-03-29  6:08     ` Stefan Roese

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