|
From: Russ D. <ru...@us...> - 2003-11-27 08:02:39
|
Update of /cvsroot/blob/blob/src/blob
In directory sc8-pr-cvs1:/tmp/cvs-serv9521/src/blob
Modified Files:
flash.c intel16.c amd16.c badge4.c
Log Message:
flesh out cfi probing, and only compile it in if requested by the arch file
Index: flash.c
===================================================================
RCS file: /cvsroot/blob/blob/src/blob/flash.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- flash.c 24 Jan 2003 09:26:00 -0000 1.19
+++ flash.c 27 Nov 2003 08:02:32 -0000 1.20
@@ -61,6 +61,7 @@
static flash_block_t flash_blocks[NUM_FLASH_BLOCKS];
static int num_flash_blocks;
+u32 flash_base = 0;
const flash_descriptor_t *flash_descriptors;
flash_driver_t *flash_driver;
@@ -116,11 +117,6 @@
int j;
u32 start = 0;
- if(flash_descriptors == NULL) {
- deprintf("undefined flash_descriptors\n");
- return;
- }
-
if(flash_driver == NULL) {
deprintf("undefined flash_driver\n");
return;
@@ -133,8 +129,7 @@
if(flash_driver->disable_vpp == NULL)
flash_driver->disable_vpp = flash_dummy_ok;
- if (flash_descriptors[0].num == -1) {
- u32 *flashAddr = (u32 *) flash_descriptors[0].size;
+ if (!flash_descriptors) {
flash_descriptor_t *d;
int rc;
@@ -144,7 +139,7 @@
return;
}
- rc = flash_driver->query_descriptors(flashAddr, &d);
+ rc = flash_driver->query_descriptors(flash_base, &d);
if (rc) {
deprintf("driver failed to query flash for descriptors\n");
flash_descriptors = 0;
@@ -156,6 +151,9 @@
/* initialise flash blocks table */
num_flash_blocks = 0;
+
+ /* Setup the flash base */
+ start = flash_base;
while(flash_descriptors[i].size != 0) {
dprintf("%i x 0x%08x, ",
Index: intel16.c
===================================================================
RCS file: /cvsroot/blob/blob/src/blob/intel16.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- intel16.c 4 Sep 2003 17:39:00 -0000 1.9
+++ intel16.c 27 Nov 2003 08:02:33 -0000 1.10
@@ -326,66 +326,6 @@
}
-/* automatic descriptor support */
-
-#define MAX_AUTO_DESCRIPTORS 4
-static flash_descriptor_t auto_descriptors[MAX_AUTO_DESCRIPTORS + 1];
-
-static int flash_query_descriptors_intel16(u32 *flashAddr,
- flash_descriptor_t **out)
-{
- u16 *addr = (u16 *) flashAddr;
- int result, nregions, n;
-
- addr[0x55] = READ_QUERY;
- barrier();
-
- if (addr[0x10] != 'Q' && addr[0x11] != 'R' && addr[0x12] != 'Y') {
- result = -EINVAL;
- goto out;
- }
-
- dprintf("intel16: manuf_code = %02X\n", addr[CFI_MANUF_CODE]);
- dprintf("intel16: device code = %02X\n", addr[CFI_DEVICE_CODE]);
- dprintf("intel16: device size = 2^%d bytes\n", addr[CFI_DEVICE_SIZE_LG2]);
-
- nregions = addr[CFI_ERASE_REGION_COUNT];
-
-#define READ_U16LE(off) ((addr[(off)]) | (addr[(off) + 1]<<8))
-
- for (n = 0; n < nregions && n < MAX_AUTO_DESCRIPTORS; n++) {
- u32 xcount = READ_U16LE(CFI_ERASE_REGION_XBLKS(n));
- u32 count = xcount + 1;
- u32 xsize = READ_U16LE(CFI_ERASE_REGION_XSIZE(n));
- u32 size = (xsize == 0) ? 128 : xsize * 256;
-
- dprintf("intel16: erase region #%d\n", n);
- dprintf("intel16: count = %d\n", count);
- dprintf("intel16: size = %d\n", size);
-
- auto_descriptors[n].size = size;
- auto_descriptors[n].num = count;
- auto_descriptors[n].lockable = 1; /* fix me */
- }
-
-#undef READ_U16LE
-
- auto_descriptors[n].size = 0;
- auto_descriptors[n].num = 0;
-
- *out = auto_descriptors;
- result = 0;
-
-out:
- /* put flash back into Read Array mode */
- barrier();
-
- *addr = READ_ARRAY;
- barrier();
-
- return result;
-}
-
/* flash driver structure */
flash_driver_t intel16_flash_driver = {
.erase = flash_erase_intel16,
@@ -393,5 +333,4 @@
.lock_block = flash_lock_block_intel16,
.unlock_block = flash_unlock_block_intel16,
.query_block_lock = flash_query_block_lock_intel16,
- .query_descriptors = flash_query_descriptors_intel16
};
Index: amd16.c
===================================================================
RCS file: /cvsroot/blob/blob/src/blob/amd16.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- amd16.c 3 Sep 2003 01:44:28 -0000 1.1
+++ amd16.c 27 Nov 2003 08:02:33 -0000 1.2
@@ -32,6 +32,9 @@
#include <blob/flash.h>
#include <blob/util.h>
#include <blob/serial.h>
+#include <blob/arch.h>
+#include <blob/debug.h>
+#include <blob/cfi.h>
/* flash commands for a 16 bit AMD flash chips */
@@ -39,24 +42,24 @@
#define UNLOCK1 0x00AA
#define UNLOCK2 0x0055
#define CONFIG_QUERY 0x0090
+#define CFI_QUERY 0x0098
#define EXIT_UNLOCK1 0x0090
#define EXIT_UNLOCK2 0x0000
#define ERASE_SETUP 0x0080
#define ERASE_CONFIRM 0x0030
#define PGM_SETUP 0x00A0
#define UNLOCK_BYPASS 0x0020
-#define FLASH_ADDR1 (0x00005555 << 1)
-#define FLASH_ADDR2 (0x00002AAA << 1)
+#define FLASH_ADDR1 (0x5555 << 1)
+#define FLASH_ADDR2 (0x2AAA << 1)
#define ERASE_DONE (1 << 7)
#define RDY_MASK (1 << 7)
#define TOGGLE_BIT (1 << 6)
#define STATUS_PGM_ERR (1 << 5)
#define STATUS_ERASE_ERR (1 << 0)
-
-static void flash_read_array_amd16(void)
+inline void flash_cmd_amd16(u32 offset, u16 cmd)
{
- *(u16 *)FLASH_ADDR1 = READ_ARRAY;
+ *((u16 *)(flash_base | offset)) = cmd;
barrier();
}
@@ -95,23 +98,18 @@
static int flash_erase_amd16(u32 *addr)
{
/* prepare for erase */
- *(u16 *)FLASH_ADDR1 = UNLOCK1;
- barrier();
- *(u16 *)FLASH_ADDR2 = UNLOCK2;
- barrier();
- *(u16 *)FLASH_ADDR1 = ERASE_SETUP;
- barrier();
+ flash_cmd_amd16(FLASH_ADDR1, UNLOCK1);
+ flash_cmd_amd16(FLASH_ADDR2, UNLOCK2);
+ flash_cmd_amd16(FLASH_ADDR1, ERASE_SETUP);
/* erase command */
- *(u16 *)FLASH_ADDR1 = UNLOCK1;
- barrier();
- *(u16 *)FLASH_ADDR2 = UNLOCK2;
- barrier();
+ flash_cmd_amd16(FLASH_ADDR1, UNLOCK1);
+ flash_cmd_amd16(FLASH_ADDR2, UNLOCK2);
*((u16 *) addr) = ERASE_CONFIRM;
if (get_status_amd16((u16 *) addr) < 0) {
/* put flash back into Read Array mode */
- flash_read_array_amd16();
+ flash_cmd_amd16(FLASH_ADDR1, READ_ARRAY);
return -EFLASHERASE;
}
@@ -123,12 +121,9 @@
{
int ret;
- *(u16 *)FLASH_ADDR1 = UNLOCK1;
- barrier();
- *(u16 *)FLASH_ADDR2 = UNLOCK2;
- barrier();
- *(u16 *)FLASH_ADDR1 = PGM_SETUP;
- barrier();
+ flash_cmd_amd16(FLASH_ADDR1, UNLOCK1);
+ flash_cmd_amd16(FLASH_ADDR2, UNLOCK2);
+ flash_cmd_amd16(FLASH_ADDR1, PGM_SETUP);
*dst = *src;
barrier();
@@ -138,7 +133,7 @@
barrier();
if (ret < 0 || *dst != *src) {
barrier();
- flash_read_array_amd16();
+ flash_cmd_amd16(FLASH_ADDR1, READ_ARRAY);
return -EFLASHPGM;
}
@@ -173,26 +168,22 @@
static int flash_query_block_lock_amd16(u32 *blockStart)
{
int result;
- *(u16 *)FLASH_ADDR1 = UNLOCK1;
- barrier();
- *(u16 *)FLASH_ADDR2 = UNLOCK2;
- barrier();
- *(u16 *)FLASH_ADDR1 = CONFIG_QUERY;
- barrier();
+ flash_cmd_amd16(FLASH_ADDR1, UNLOCK1);
+ flash_cmd_amd16(FLASH_ADDR2, UNLOCK2);
+ flash_cmd_amd16(FLASH_ADDR1, CONFIG_QUERY);
result = *(u16 *)(((u16 *)blockStart) + 2);
- flash_read_array_amd16();
+ flash_cmd_amd16(FLASH_ADDR1, READ_ARRAY);
return !!result;
}
-
/* flash driver structure */
flash_driver_t amd16_flash_driver = {
erase: flash_erase_amd16,
write: flash_write_amd16,
lock_block: flash_lock_block_amd16,
unlock_block: flash_unlock_block_amd16,
- query_block_lock: flash_query_block_lock_amd16
+ query_block_lock: flash_query_block_lock_amd16,
};
Index: badge4.c
===================================================================
RCS file: /cvsroot/blob/blob/src/blob/badge4.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- badge4.c 4 Sep 2003 17:39:00 -0000 1.18
+++ badge4.c 27 Nov 2003 08:02:33 -0000 1.19
@@ -39,6 +39,7 @@
#include <blob/partition.h>
#include <blob/led.h>
#include <blob/time.h>
+#include <blob/cfi.h>
#define DEBUG
@@ -57,10 +58,6 @@
.private= &badge4_i2c_bus_gpio_private
};
-/* flash descriptors for BadgePAD 4 flash */
-static const flash_descriptor_t badge4_flash_descriptors[] =
- QUERY_FLASH_FOR_DESCRIPTORS(0);
-
/* default partition table for BadgePAD 4 */
static blob_partition_t badge4_default_partition_table[] = {
@@ -141,7 +138,7 @@
timer_driver = &intelarm_timer_driver;
flash_driver = &intel16_flash_driver;
- flash_descriptors = badge4_flash_descriptors;
+ flash_driver->query_descriptors = flash_query_descriptors_cfi16;
}
__initlist(badge4_select_drivers, INIT_LEVEL_DRIVER_SELECTION);
|