AnsweredAssumed Answered

Accessing 8MB FLASH with u-boot and BF537

Question asked by MichaelWd on Apr 17, 2013
Latest reply on Apr 22, 2013 by Aaronwu

Hello,

 

I have a custom BF537 board with 8MB NOR flash on it. 4MB of FLASH directly accessible (using logic to generate ADR19, ADR20 from processor AMS0-AMS3 signals), and ADR21 flash line is connected to PH15 on blackfin. I would like to have the memory mapped to 0x20000000-0x207FFFFF.

 

I have found an example in board/cm-bf537e directory. That setup seems very similar to my, except that they using only 2MB bank size, so to access 8MB two GPIO lines are needed. I've modified the code to:

 

#include <common.h>
#include <asm/blackfin.h>
#include <asm/gpio.h>
#include <asm/io.h>
#include "gpio_cfi_flash.h"

#define GPIO_MASK       (1<<22)                         // we have ADR21 on GPIO
#define GPIO_ADR21      GPIO_PH15                       // should be PH12, but now we have broken board

void *gpio_cfi_flash_swizzle(void *vaddr)
{
        unsigned long addr = (unsigned long)vaddr;
        gpio_set_value(GPIO_ADR21, addr & GPIO_MASK);
        SSYNC();
        udelay(1);
        return (void *)(addr & ~GPIO_MASK);
}

#define __raw_writeq(value, addr) *(volatile u64 *)addr = value
#define __raw_readq(addr) *(volatile u64 *)addr

#define MAKE_FLASH(size, sfx) \
void flash_write##size(u##size value, void *addr) \
{ \
        __raw_write##sfx(value, gpio_cfi_flash_swizzle(addr)); \
} \
u##size flash_read##size(void *addr) \
{ \
        return __raw_read##sfx(gpio_cfi_flash_swizzle(addr)); \
}
MAKE_FLASH(8, b)  /* flash_write8()  flash_read8() */
MAKE_FLASH(16, w) /* flash_write16() flash_read16() */
MAKE_FLASH(32, l) /* flash_write32() flash_read32() */
MAKE_FLASH(64, q) /* flash_write64() flash_read64() */

void gpio_cfi_flash_init(void)
{
        gpio_request(GPIO_ADR21, "gpio_cfi_flash");
        gpio_direction_output(GPIO_ADR21, 0);
}

 

That should properly set PH15 when address is bigger then 0x200400000, but it does not. I've monitored the line with scope and it is never set. I think that flash_read, flash_write functions defined there are never called, and uboot uses default from mtd/cfi_flash.c. I found a thread: http://ez.analog.com/thread/12196 and http://ez.analog.com/thread/16477 - they say that it should work. Is there anything that I am missing?

By the way the hardware works OK with linux kernel and gpio-mtd driver, so I know that flash and connections are right.

 

Very best regards,

Michael Widlok

Outcomes