Flash Mapping and gpio

Allon Stern allon.stern at argonst.com
Fri Sep 12 10:00:02 EDT 2008


On Sep 11, 2008, at 6:23 PM, Fundu wrote:
>
> these are on 2.6 kernel. i'm using 2.4.20.
>
> how about this error
>
> MTD do_erase_oneblock(): Wacky!  Unable to decode failure status
> MTD do_erase_oneblock(): 0x07f40000(0x00ff00ff): 0x27051956
> 0x27051956 0x27051956 0x27051956
>
> any ideas here, this hasn't changed much.  i still get these even  
> after backing out my changes that i mentioned in the original post.


Dunno about that one, but here is what I did on my system, where I
have a 64MB part in a 16MB address window. It was on 2.6.26 (get
current, man!) so I don't know how closely it will match what you
need, but the basic technique should be very similar.


in drivers/mtd/maps, I added a new mapping, let's call it "custom.c".
Add it to the makefile and KConfig so you can select it.

in custom.c, I added a "CUSTOM_BANKSWITCH(x)" macro, which takes an
address, and sets the GPIOs for the flash to access that address.

In my case, I based it on the "avnet5282.c" map file, except instead
of using

simple_map_init(&avnet5282_map);

I created my own "custom_map_init", which looks something like:

void custom_map_init(struct map_info *map)
{
	BUG_ON(!map_bankwidth_supported(map->bankwidth));

	map->read = custom_map_read;
	map->write = custom_map_write;
	map->copy_from = custom_map_copy_from;
	map->copy_to = custom_map_copy_to;
}


then for the individual map functions, implemented them something like:

static map_word __xipram custom_map_read(struct map_info *map,
unsigned long ofs)
{
      CUSTOM_BANKSWITCH(ofs);
      return inline_map_read(map, ofs & BANK_MASK); // mask out the bank
}

individual
The inline_map will do 99% of what you need - you just have to bank
switch.

Note that in the custom_map_copy_from and custom_map_copy_to, you
need to figure out what happens if a read or read spans banks.
In my case, I asserted that a copy won't be more than 16MB, and two
the copy in two chunks, switching banks in the middle, if need be.

HTH.
-
allon




More information about the linux-mtd mailing list