Problems with cfi_cmdset_0002 and Atmel AT49BV642D

Ricard Wanderlof ricard.wanderlof at axis.com
Mon Aug 6 09:41:08 EDT 2007


On Thu, 10 May 2007, Michael König wrote:

>> So if you have the patch available, now would probably be a good time
>> to post it ;-)
>
> Unfortunately I don't have any experience with GIT and also don't have the 
> time to set it up right now, but I'm attaching a "diff -p" for the changes to 
> the latest cfi_cmdset_0002.c in the repository.

This was a long time ago, is there any reason the supplied patch was never 
committed?

/Ricard

(for reference, since it was a while ago, the patch follows below)

--------------8<------------------

From Michael.Koenig at ipcas.de Thu May 10 10:44:49 2007
Date: Thu, 10 May 2007 10:42:53 +0200
From: "[UTF-8] Michael König" <Michael.Koenig at ipcas.de>
To: dev-etrax at axis.com
Subject: Atmel Flash Fix: cfi_cmdset_0002.c (was: MTD problems)

     [ The following text is in the "utf-8" character set. ]
     [ Your display is set for the "ISO-8859-1" character set.  ]
     [ Some characters may be displayed incorrectly. ]

Hello again,

with the help of Hans-Christian Egtvedt from Atmel (thanks!) I was able to
track down my issues with the Atmel Flash.

On Atmel Flashes the do_write_buffer() function is not supposed to be
called, and it seems that some patches to make sure of that weren't applied
to the code in the Linux kernel GIT.

The following changes have to be applied to this file:
drivers/mtd/chips/cfi_cmdset_0002.c


Two lines (not counting the comment) are added to fixup_convert_atmel_pri():

static void fixup_convert_atmel_pri(struct mtd_info *mtd, void *param)
{
 	struct map_info *map = mtd->priv;
 	struct cfi_private *cfi = map->fldrv_priv;
 	struct cfi_pri_amdstd *extp = cfi->cmdset_priv;
 	struct cfi_pri_atmel atmel_pri;

 	memcpy(&atmel_pri, extp, sizeof(atmel_pri));
 	memset((char *)extp + 5, 0, sizeof(*extp) - 5);

 	if (atmel_pri.Features & 0x02)
 		extp->EraseSuspend = 2;

 	if (atmel_pri.BottomBoot)
 		extp->TopBottom = 2;
 	else
 		extp->TopBottom = 3;

 	/* burst write mode not supported */
 	cfi->cfiq->BufWriteTimeoutTyp = 0;
 	cfi->cfiq->BufWriteTimeoutMax = 0;
}


In the cfi_fixup_table[] "fixup_convert_atmel_pri" has to appear before
"fixup_use_write_buffers":

static struct cfi_fixup cfi_fixup_table[] = {
#ifdef AMD_BOOTLOC_BUG
 	{ CFI_MFR_AMD, CFI_ID_ANY, fixup_amd_bootblock, NULL },
#endif
 	{ CFI_MFR_AMD, 0x0050, fixup_use_secsi, NULL, },
 	{ CFI_MFR_AMD, 0x0053, fixup_use_secsi, NULL, },
 	{ CFI_MFR_AMD, 0x0055, fixup_use_secsi, NULL, },
 	{ CFI_MFR_AMD, 0x0056, fixup_use_secsi, NULL, },
 	{ CFI_MFR_AMD, 0x005C, fixup_use_secsi, NULL, },
 	{ CFI_MFR_AMD, 0x005F, fixup_use_secsi, NULL, },
 	{ CFI_MFR_ATMEL, CFI_ID_ANY, fixup_convert_atmel_pri, NULL },
#if !FORCE_WORD_WRITE
 	{ CFI_MFR_ANY, CFI_ID_ANY, fixup_use_write_buffers, NULL, },
#endif
 	{ 0, 0, NULL, NULL }
};


Now Atmel Flash chips should work correctly with the latest SDK, at least my
AT49BV642D does.

-- 
Mit freundlichen Grüßen
Best regards
Michael König

-------------8<---------

--
Ricard Wolf Wanderlöf                           ricardw(at)axis.com
Axis Communications AB, Lund, Sweden            www.axis.com
Phone +46 46 272 2016                           Fax +46 46 13 61 30



More information about the linux-mtd mailing list