Update of /cvsroot/blob/blob/include/blob
In directory sc8-pr-cvs1:/tmp/cvs-serv14402/include/blob
Modified Files:
flash.h
Log Message:
add (optional) support for cfi query to build flash descriptors automagically; implemented for 16-bit wide intel parts
Index: flash.h
===================================================================
RCS file: /cvsroot/blob/blob/include/blob/flash.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- flash.h 9 May 2002 13:27:26 -0000 1.12
+++ flash.h 24 Jan 2003 09:26:02 -0000 1.13
@@ -42,7 +42,6 @@
int lockable;
} flash_descriptor_t;
-
typedef int (*flash_erase_func_t)(u32 *);
typedef int (*flash_write_func_t)(u32 *, const u32 *);
typedef int (*flash_lock_block_func_t)(u32 *);
@@ -50,7 +49,7 @@
typedef int (*flash_query_block_lock_func_t)(u32 *);
typedef int (*flash_enable_vpp_func_t)(void);
typedef int (*flash_disable_vpp_func_t)(void);
-
+typedef int (*flash_query_descriptors_func_t)(u32 *, flash_descriptor_t **out);
typedef struct {
/* the following functions should be implemented by all flash
@@ -67,8 +66,10 @@
* functions unimplemented, blob will safely work around it */
flash_enable_vpp_func_t enable_vpp;
flash_disable_vpp_func_t disable_vpp;
-} flash_driver_t;
+ /* optional: determine the descriptors automagically */
+ flash_query_descriptors_func_t query_descriptors;
+} flash_driver_t;
/* implemented flash drivers */
extern flash_driver_t amd32_flash_driver;
@@ -78,9 +79,14 @@
/* should be filled out by the architecture dependent files */
-extern const flash_descriptor_t *flash_descriptors;
extern flash_driver_t *flash_driver;
+/* should be filled out by the architecture dependent files; can
+ * be set to QUERY_FLASH_FOR_DESCRIPTORS() if driver supports that */
+#define QUERY_FLASH_FOR_DESCRIPTORS(flash_addr) \
+ { { .size = (u32) flash_addr, .num = -1 } }
+extern const flash_descriptor_t *flash_descriptors;
+
/* flash data mangle functions */
u32 data_from_flash(u32 what);
@@ -98,5 +104,13 @@
int flash_get_next_block_address(u32* addr, u32 current);
int flash_get_block_size(u32 address);
u32 flash_get_size( void );
+
+/* CFI offsets ... useful to many flavors of flash */
+#define CFI_MANUF_CODE 0x00
+#define CFI_DEVICE_CODE 0x01
+#define CFI_DEVICE_SIZE_LG2 0x27
+#define CFI_ERASE_REGION_COUNT 0x2c
+#define CFI_ERASE_REGION_XBLKS(n) (0x2d + 4 * (n))
+#define CFI_ERASE_REGION_XSIZE(n) (0x2f + 4 * (n))
#endif
|