gk7205v200-uboot/drivers/mtd/spi/spi_nor.c

70 lines
1.6 KiB
C
Raw Normal View History

2025-08-07 17:13:54 +08:00
/*
* Copyright (c) Hunan Goke,Chengdu Goke,Shandong Goke. 2021. All rights reserved.
*/
#include <common.h>
#include <malloc.h>
#include <asm/io.h>
#include <spi_flash.h>
#include <errno.h>
#include <linux/mtd/mtd.h>
#include "spi.h"
/*****************************************************************************/
static struct spi_flash *spiflash;
static struct mtd_info_ex *spiinfo_ex;
/*****************************************************************************/
struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
unsigned int max_hz, unsigned int spi_mode)
{
if (get_boot_media() != BOOT_MEDIA_SPIFLASH) {
puts("Boot Media isn't SPI Nor\n");
return NULL;
}
if (spiflash)
return spiflash;
#ifdef CONFIG_FMC_SPI_NOR
spiflash = fmc100_spi_nor_probe(&spiinfo_ex);
spiflash->erase_size = spiinfo_ex->erasesize;
#endif
return spiflash;
}
/*****************************************************************************/
struct mtd_info_ex *get_spiflash_info(void)
{
if (spiinfo_ex)
return spiinfo_ex;
#ifdef CONFIG_FMC_SPI_NOR
spiinfo_ex = fmc100_get_spi_nor_info(spiflash);
#endif
return spiinfo_ex;
}
/*****************************************************************************/
void spi_flash_free(struct spi_flash *flash)
{
}
/*****************************************************************************/
#ifdef CONFIG_SPI_BLOCK_PROTECT
void spi_flash_lock(unsigned char cmp, unsigned char level, unsigned char op)
{
cmp = BP_CMP_BOTTOM;
if (spiflash->lock)
spiflash->lock(cmp, level, op);
return;
}
/*****************************************************************************/
#endif /* CONFIG_SPI_BLOCK_PROTECT */