📄 flash_nor_device.h
字号:
#ifndef __FLASH_NOR_DEVICE_H__#define __FLASH_NOR_DEVICE_H__/********************************************************************** * flash_nor_device.h * * Flash NOR Device interface. * * * Copyright (C) 2005-2006 Qualcomm, Inc. * **********************************************************************//*=========================================================================== EDIT HISTORY FOR MODULE This section contains comments describing changes made to the module. Notice that changes are listed in reverse chronological order. $Header: //depot/asic/msmshared/drivers/flash/MSM_FLASH.01.04/flash_nor_device.h#1 $ $DateTime: 2006/03/07 12:11:34 $ $Author: dhamimp $when who what, where, why-------- --- ----------------------------------------------------------2005-11-26 dp Unification of NOR flash drivers===========================================================================*/#include "flash.h"#include "msm.h"/**************************************************************** * Defines ***************************************************************//* All uninitialized fields of fsi_nor_device structure and flash_mem_map structure are * set to this default value and are initialized during runtime */#define INIT_USING_CFI_AT_RUNTIME ((flash_geometry_info *)0x0)#define INIT_NOT_NEEDED ((flash_geometry_info *)0xFFFFFFFF)/* For Probe table */#define FLASH_PROBE_END 0xDEADBEEF#define FSD_MAX_SECTORS 280#define MAX_FLASH_REGIONS 5#define ERASE_VERIFY_BLK 128#define CFI_WORD_SIZE 96/* When we must add a value given in byte offsets to a word pointer, this * macro is used to create a word offset. */#define BYTE_TO_WORD_OFFSET(x) (x>>1)/* how to handle suspended writes */#define FSI_OPT_WRITE_WHILE_SUSPEND 0x0001/* Status return enums */typedef enum{ FLASH_SUCCESS = 0x0, FLASH_FAILURE = 0x1, FLASH_INVALID_LEN = 0x3, FLASH_TIMEOUT = 0x7, FLASH_VERIFY_FAILED = 0xA, FLASH_OP_NOT_COMPLETE = 0x15 // same value as FS_GC_IN_PROGRESS_S enum} flash_status;/* Flash family - Intel, AMD, Spansion, etc. */typedef enum{ FLASH_SPANSION_FAMILY, FLASH_INTEL_FAMILY, FLASH_UNKNOWN_FAMILY, FLASH_MAX_FAMILIES = FLASH_UNKNOWN_FAMILY,} flash_family_type;/* Flash size enum in terms of x, where flash size = 2^x */typedef enum{ FLASH_SIZE_UNKNOWN = 0, FLASH_SIZE_4MB = 22, FLASH_SIZE_8MB, FLASH_SIZE_16MB, FLASH_SIZE_32MB} flash_size_type;/* Flash device width interface capability enum */typedef enum{ FLASH_XIFACE_8 = 0, FLASH_XIFACE_16, FLASH_XIFACE_32, FLASH_XIFACE_64,} flash_xiface_type;/* Write buffer size if any in bytes */typedef enum{ FLASH_WBUF_NOT_PRESENT = 0, FLASH_WBUF_2, FLASH_WBUF_4, FLASH_WBUF_8, FLASH_WBUF_16, FLASH_WBUF_32, FLASH_WBUF_64, FLASH_WBUF_128, } flash_wbuf_size_type;/* Structure for describing a template of the block map of a * particular part flash part. This is used in building the run time * block map. We no longer keep static expanded tables for each part. */typedef struct { int numblocks; int blocksize_bytes;} block_info;/* Structure for organizing a table of block boundaries within the Flash device. */typedef struct{ dword start; /* First address of the block */ dword len; /* Length of the block in bytes */ word is_erased; /* Flag: TRUE if block is erased */} block_descriptor_type;/* Structure to store the pertinent Flash device geometry information */typedef struct{ flash_family_type family_type; /* AMD/Spansion/Intel family type */ flash_size_type device_size; /* n such that actual device size = 2^n bytes */ flash_xiface_type x_iface; /* flash device width capability */ flash_wbuf_size_type write_buf_size; /* n such that max write buffer size = 2^n bytes */ word num_erase_blk_region; /* indicates how many different size sectors avail */ block_info blk_regions[MAX_FLASH_REGIONS]; /* blk layout : number of sectors, size */} flash_geometry_info;typedef void (*flash_copy_cfi_data_func)(volatile word *baseaddr, word *dest, word count);/* The Flash device is, of course, memory mapped, so the compiler might * find the various device manipulations to be nonsense, and optimize * it all away. To prevent this, we use pointers to volatile to let * the compiler know that we're dealing with a special device and that * it is to leave the operations as written. */typedef volatile word *flash_ptr_type;typedef struct { dword efs_boffset; /* efs byte offset */ dword efs_bsize; /* efs size in bytes */ dword efs_blk_bsize; /* efs blk size in bytes */ dword efs_blk_count; /* number of efs blks */ dword efs_write_style;} flash_efs_info;struct fsi_dev_ops; /* Forward declaration */typedef struct { const char *name; /* Textual name of device. */ word num_ids; /* Number of codes that need to match */ word codes[4]; /* Manufacture's codes. */ word device_ctrl_options; /* Any device specific differentiation */ flash_efs_info efs_info; flash_geometry_info *flash_geometry; /* User returned info. */ struct fsi_dev_ops *ops; /* Flash operations */} fsi_nor_device;struct fsi_dev_ops { flash_status (*configure) (fsi_nor_device * nor_device, flash_ptr_type baseaddr); /* Perform any needed initialization. */ flash_status (*read) (byte *buffer, dword offset, dword count); /* Device read operation. */ flash_status (*write) (byte *buffer, flash_ptr_type baseaddr, dword offset, dword count); /* Device write operation. */ flash_status (*erase_start) (flash_ptr_type baseaddr, dword offset); /* Device erase start operation. */ flash_status (*erase_status) (flash_ptr_type eraseaddr); /* Progress of erase operation. */ flash_status (*suspend_erase) (flash_ptr_type eraseaddr); /* Suspend an erase operation. */ flash_status (*resume_erase) (flash_ptr_type eraseaddr); /* Resume a suspended erase. */};/* Definition of probe table structure and pointer type. Defined in * MSM specific code and initialized to tell the flash layer where * to probe with what function. */typedef struct { volatile word *probe_addr; fsi_nor_device * (*probe_fcn) (volatile word *baseaddr);} ProbeTbl;/* pointer type to Probe Table Structure */typedef ProbeTbl *ProbeTbl_t;/* Table of addresses and functions to probe for flash */extern ProbeTbl probe_info[];extern int probe_info_size;extern fsi_nor_device S29WS256N0SB;extern fsi_nor_device S71GL064A;extern const fsi_nor_device *(spansion_parts[]);/* Generic read of directly readable flash memory referred to * from the device specific dispatch tables to satisfy * read requests */extern flash_status fs_nor_device_worded_read (byte *buffer, dword offset, dword count);extern flash_status flash_geometry_init (fsi_nor_device *nor_device, flash_ptr_type baseaddr);extern void flash_read_cfi(volatile word *baseaddr, flash_geometry_info *ginfo, word *cfi_data);/* Functions for different drivers */extern fsi_nor_device *spansion_probe (volatile word *baseaddr);#endif /* End of __FLASH_NOR_DEVICE_H__ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -