AnsweredAssumed Answered

P1010 legacy u-boot

Question asked by Naiying Koong on Dec 19, 2017
Latest reply on Jan 11, 2018 by Tc Liew


I would like to add MX25L25635F flash in to the legacy u-boot with the old architecture.

Because the SDK supports the espi only, I can not use the spi function in it.


static int macronix_wait_ready(struct spi_flash *flash, unsigned long timeout)
struct spi_slave *spi = flash->spi;
unsigned long timebase;
int ret;
u8 status;

timebase = get_timer(0);
do {
ret = spi_flash_cmd(spi, CMD_MX25XX_RDSR, &status, sizeof(status));
if (ret)
return -1;

if ((status & MACRONIX_SR_WIP) == 0)

} while (get_timer(timebase) < timeout);

if ((status & MACRONIX_SR_WIP) == 0)
return 0;

/* Timed out */
return -1;



  • About the 32-bit access, I also tried to modify the read-write command:

static int macronix_read_fast(struct spi_flash *flash,
u32 offset, size_t len, void *buf)
struct macronix_spi_flash *mcx = to_macronix_spi_flash(flash);
unsigned long page_addr;
unsigned long page_size;
int ret=0;
u8 cmd[6];
const u8 Wreg=0xC5;
const u8 EXTE=0x80;
const u8 EXTD=0x00;
spi_flash_cmd_write(flash->spi, &Wreg, 0x1, &EXTE, 0x1);

page_size = mcx->params->page_size;
page_addr = offset / page_size;


cmd[1] = page_addr >> 16;
cmd[2] = page_addr >> 8;
cmd[3] = page_addr;
cmd[4] = offset % page_size;
cmd[5] = 0x00;

ret=spi_flash_read_common(flash, cmd, sizeof(cmd), buf, len);

spi_flash_cmd_write(flash->spi, &Wreg, 0x1, &EXTD, 0x1);
return ret;


Could you help to check? Do I miss anything?

Thank you.