view loadtools/flash.h @ 401:7ceeec049be4

fc-loadtool flash: bank configurations for CFI
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sun, 15 Jun 2014 20:24:51 +0000
parents f027c6fbe37e
children a212b4968b29
line wrap: on
line source

/* this header file contains definitions for fc-loadtool flash support */

/*
 * The following structures represent an "abstract"
 * description of flash devices.
 *
 * A "region" is a consecutive group of erase units of the same size.
 */

struct flash_region_desc {
	uint32_t	sector_size;
	unsigned	nsectors;
};

#define	CFI_MAX_REGIONS		4

/* The info in struct cfi_info can be either gathered from CFI or hard-coded. */
struct cfi_info {
	uint16_t			cmdset_style;
	uint32_t			total_size;
	unsigned			nregions;
	struct flash_region_desc	regions[CFI_MAX_REGIONS];
	unsigned			total_sectors;
};

struct flash_idcheck {
	uint16_t	offset;
	uint16_t	expect_val;
};

struct flash_bank_desc {
	uint32_t		align_size;
	struct cfi_info		*hard_cfi;
	struct flash_idcheck	*idcheck_table;
	unsigned		idcheck_num;
};

struct flash_device_desc {
	char			*name;
	struct flash_bank_desc	*bank_desc;
	unsigned		nbanks;
};

/* the following structures describe flash banks as accessible to us */

struct sector_info {
	uint32_t	start;
	uint32_t	size;
};

struct flash_bank_info {
	uint32_t		base_addr;
	struct flash_bank_desc	*bank_desc;
	struct cfi_info		*cfi;
	struct sector_info	*sectors;
	int			idcheck_done;
};