Files

104 lines
3.1 KiB
C

#ifndef __FLASHINFO_H__
#define __FLASHINFO_H__
//copy from bootloader, used to get SPI pinmux config from bootloader
#ifdef __cplusplus
extern "C" {
#endif
#ifndef FLASH_VERIFY_EN
#define FLASH_VERIFY_EN (1) /* defaultly need verify flash written data */
#endif
#ifndef FLASH_CHECK_FF_EN
#define FLASH_CHECK_FF_EN (1) /* defaultly need read flash and check whether are erased, all 0xFF */
#endif
#define FLASH_INFO_MAGIC 0x46494E46
#define MAX_FLASH_DEVICE_NAME 64
#define MAX_FLASH_DEVICE_TYPE 32
#define FLASH_TYPE_QSPI_NAND "QSPI_NAND"
/* the first QSPI flash, crane is extern QSPI flash, craneM/craneG is internal QSPI flash.*/
#define FLASH_TYPE_QSPI_NOR "QSPI_NOR"
#define FLASH_TYPE_SPI_NOR "SPI_NOR"
#define FLASH_TYPE_EMMC "EMMC"
#define FLASH_TYPE_MEM "MEM"
#define FLASH_TYPE_DUMMY "DUMMY"
#define FLASH_TYPE_QSPI2_NOR "QSPI2_NOR"
#define FLASH_ERR_OTHERS (-1)
#define FLASH_ERR_BAD_BLOCK (-2)
#define FLASH_ERR_BAD_PARAMETER (-3)
#define FLASH_ERR_ECC_ERR (-4)
#define FLASH_ERR_PROGRAM_ERR (-5)
#define FLASH_ERR_ERASE_ERR (-6)
#define SPI_PORT_QSPI 0
#define SPI_PORT_SSP0 1
#define SPI_PORT_SSP1 2
#define SPI_PORT_SSP2 3
#define SPI_PORT_QSPI2 4
#define SPI_PORT_EMMC 5
#define SPI_PORT_MEM 6
/* SSP_<CLK>_<FRM>_<RXD>_<TXD> */
typedef enum {
SSP_GPIO_CONFIG_DEFAULT,
SSP_GPIO4_FUNC2_GPIO5_FUNC2_GPIO6_FUNC2_GPIO7_FUNC2,
SSP_GPIO4_FUNC7_GPIO5_FUNC7_GPIO6_FUNC7_GPIO7_FUNC7,
SSP_GPIO12_FUNC1_GPIO13_FUNC1_GPIO14_FUNC1_GPIO15_FUNC1,
SSP_GPIO16_FUNC2_GPIO17_FUNC2_GPIO19_FUNC2_GPIO18_FUNC2,
SSP_GPIO16_FUNC2_GPIO17_FUNC2_GPIO18_FUNC4_GPIO19_FUNC4,
SSP_GPIO33_FUNC1_GPIO34_FUNC1_GPIO35_FUNC1_GPIO36_FUNC1,
SSP_GPIO33_FUNC2_GPIO34_FUNC2_GPIO35_FUNC2_GPIO36_FUNC2,
SSP_GPIO64_FUNC7_GPIO63_FUNC7_GPIO61_FUNC7_GPIO62_FUNC7,
SSP_GPIO71_FUNC2_GPIO72_FUNC2_GPIO73_FUNC2_GPIO74_FUNC2,
SSP_QSPI_CLK_FUNC2_QSPI_CS1_FUNC2_QSPI_DAT1_FUNC2_QSPI_DAT0_FUNC2,
SSP_QSPI_CLK_FUNC4_QSPI_CS1_FUNC4_QSPI_DAT1_FUNC4_QSPI_DAT0_FUNC4,
} ssp_gpio_config_t;
struct compatible_device {
uint16_t vendor_id;
uint16_t device_id;
uint32_t reserved1;
char device_name[MAX_FLASH_DEVICE_NAME];
};
/**
* \brief Flash information
*/
struct flash_info {
uint32_t magic;
uint16_t vendor_id;
uint16_t device_id;
char device_name[MAX_FLASH_DEVICE_NAME];
char device_type[MAX_FLASH_DEVICE_TYPE];
/* the following two parameters are used by ubi */
uint32_t min_io_size;
uint32_t peb_size;
/* the following three parameters are used by erase and program */
uint32_t page_size;
uint32_t sector_size;
uint32_t block_size;
uint8_t reserved1[3];
uint8_t ssp_gpio : 6;
uint8_t ssp_clk : 2;
/* total flash size */
uint64_t flash_size;
uint8_t erased_value; /*/< Contents of erased memory (usually 0xFF) */
uint8_t chained;
uint8_t spi_port;
uint8_t combined_flash_size_in_mb; /* combined flash size in MB */
uint32_t compatible_device_num;
struct compatible_device compatible_device_list[1];
};
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* __FLASHINFO_H__ */