海思HI3516a开发套件上spi flash硬件默认3 addr模式,需要更改u-boot代码才能正确支持3 addr模式,具体操作如下:
更改u-boot代码osdrv/opensource/uboot/u-boot/include/configs/hi3516a.h第65行后面添加宏定义#define CONFIG_CLOSE_SPI_8PIN_4IO;
更改u-boot代码osdrv/opensource/uboot/u-boot-2010.06/drivers/mtd/spi/hisfc350/hisfc350_spi_w25q256fv.c如下:
static int spi_w25q256fv_entry_4addr(struct hisfc_spi *spi, int enable)
{
struct hisfc_host *host = (struct hisfc_host *)spi->host;
if (spi->addrcycle != SPI_4BYTE_ADDR_LEN)
return 0;
/* This chip should not enable write here,
* we have confirmed with the WINBOND */
/* spi->driver->write_enable(spi); */
spi->driver->write_enable(spi);
enable=1;
hisfc_write(host, HISFC350_CMD_INS, SPI_CMD_FIRST_RESET_4ADDR);
hisfc_write(host, HISFC350_CMD_CONFIG,
HISFC350_CMD_CONFIG_SEL_CS(spi->chipselect)
| HISFC350_CMD_CONFIG_START);
HISFC350_CMD_WAIT_CPU_FINISH(host);
hisfc_write(host, HISFC350_CMD_INS, SPI_CMD_SECOND_RESET_4ADDR);
hisfc_write(host, HISFC350_CMD_CONFIG,
HISFC350_CMD_CONFIG_SEL_CS(spi->chipselect)
| HISFC350_CMD_CONFIG_START);
HISFC350_CMD_WAIT_CPU_FINISH(host);
//if (DEBUG_SPI)
printf("now W25Q256FV 6699 cmd\n");
if (enable) {
hisfc_write(host, HISFC350_CMD_INS, SPI_CMD_EN4B);
//if (DEBUG_SPI)
printf("now w25q256fv is 4-byte address mode\n");
hisfc_write(host, HISFC350_CMD_CONFIG,
HISFC350_CMD_CONFIG_SEL_CS(spi->chipselect)
| HISFC350_CMD_CONFIG_START);
HISFC350_CMD_WAIT_CPU_FINISH(host);
}
//ngs
else
{
/* reset cmd */
hisfc_write(host, HISFC350_CMD_INS, SPI_CMD_FIRST_RESET_4ADDR);
hisfc_write(host, HISFC350_CMD_CONFIG,
HISFC350_CMD_CONFIG_SEL_CS(spi->chipselect)
| HISFC350_CMD_CONFIG_START);
HISFC350_CMD_WAIT_CPU_FINISH(host);
hisfc_write(host, HISFC350_CMD_INS, SPI_CMD_SECOND_RESET_4ADDR);
hisfc_write(host, HISFC350_CMD_CONFIG,
HISFC350_CMD_CONFIG_SEL_CS(spi->chipselect)
| HISFC350_CMD_CONFIG_START);
HISFC350_CMD_WAIT_CPU_FINISH(host);
//if (DEBUG_SPI)
printf("now W25Q256FV 6699 cmd\n");
}
hisfc_write(host, HISFC350_CMD_CONFIG,
HISFC350_CMD_CONFIG_SEL_CS(spi->chipselect)
| HISFC350_CMD_CONFIG_DATA_CNT(1)
| HISFC350_CMD_CONFIG_DATA_EN
| HISFC350_CMD_CONFIG_START);
HISFC350_CMD_WAIT_CPU_FINISH(host);
host->set_host_addr_mode(host, enable);
return 0;
}
实际测试对于w25q128 spi flash可用。