mirror of
https://github.com/qemu/qemu.git
synced 2024-11-25 11:53:39 +08:00
m25p80: Support for Quad SPI
Added the Quad mode read and write commands. Data remains serialized on a single wire, i.e. the quad mode instructions just behave the same as single mode, with the expection of modelling the varying number of dummy/mode bytes between the address bytes and the first data word. Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
This commit is contained in:
parent
50cd721482
commit
419336a9f9
61
hw/m25p80.c
61
hw/m25p80.c
@ -72,6 +72,10 @@ typedef struct FlashPartInfo {
|
|||||||
.page_size = 256,\
|
.page_size = 256,\
|
||||||
.flags = (_flags),\
|
.flags = (_flags),\
|
||||||
|
|
||||||
|
#define JEDEC_NUMONYX 0x20
|
||||||
|
#define JEDEC_WINBOND 0xEF
|
||||||
|
#define JEDEC_SPANSION 0x01
|
||||||
|
|
||||||
static const FlashPartInfo known_devices[] = {
|
static const FlashPartInfo known_devices[] = {
|
||||||
/* Atmel -- some are (confusingly) marketed as "DataFlash" */
|
/* Atmel -- some are (confusingly) marketed as "DataFlash" */
|
||||||
{ INFO("at25fs010", 0x1f6601, 0, 32 << 10, 4, ER_4K) },
|
{ INFO("at25fs010", 0x1f6601, 0, 32 << 10, 4, ER_4K) },
|
||||||
@ -180,17 +184,26 @@ static const FlashPartInfo known_devices[] = {
|
|||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
NOP = 0,
|
NOP = 0,
|
||||||
PP = 0x2,
|
|
||||||
READ = 0x3,
|
|
||||||
WRDI = 0x4,
|
WRDI = 0x4,
|
||||||
RDSR = 0x5,
|
RDSR = 0x5,
|
||||||
WREN = 0x6,
|
WREN = 0x6,
|
||||||
|
JEDEC_READ = 0x9f,
|
||||||
|
BULK_ERASE = 0xc7,
|
||||||
|
|
||||||
|
READ = 0x3,
|
||||||
FAST_READ = 0xb,
|
FAST_READ = 0xb,
|
||||||
|
DOR = 0x3b,
|
||||||
|
QOR = 0x6b,
|
||||||
|
DIOR = 0xbb,
|
||||||
|
QIOR = 0xeb,
|
||||||
|
|
||||||
|
PP = 0x2,
|
||||||
|
DPP = 0xa2,
|
||||||
|
QPP = 0x32,
|
||||||
|
|
||||||
ERASE_4K = 0x20,
|
ERASE_4K = 0x20,
|
||||||
ERASE_32K = 0x52,
|
ERASE_32K = 0x52,
|
||||||
ERASE_SECTOR = 0xd8,
|
ERASE_SECTOR = 0xd8,
|
||||||
JEDEC_READ = 0x9f,
|
|
||||||
BULK_ERASE = 0xc7,
|
|
||||||
} FlashCMD;
|
} FlashCMD;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
@ -346,11 +359,17 @@ static void complete_collecting_data(Flash *s)
|
|||||||
s->cur_addr |= s->data[2];
|
s->cur_addr |= s->data[2];
|
||||||
|
|
||||||
switch (s->cmd_in_progress) {
|
switch (s->cmd_in_progress) {
|
||||||
|
case DPP:
|
||||||
|
case QPP:
|
||||||
case PP:
|
case PP:
|
||||||
s->state = STATE_PAGE_PROGRAM;
|
s->state = STATE_PAGE_PROGRAM;
|
||||||
break;
|
break;
|
||||||
case READ:
|
case READ:
|
||||||
case FAST_READ:
|
case FAST_READ:
|
||||||
|
case DOR:
|
||||||
|
case QOR:
|
||||||
|
case DIOR:
|
||||||
|
case QIOR:
|
||||||
s->state = STATE_READ;
|
s->state = STATE_READ;
|
||||||
break;
|
break;
|
||||||
case ERASE_4K:
|
case ERASE_4K:
|
||||||
@ -374,6 +393,8 @@ static void decode_new_cmd(Flash *s, uint32_t value)
|
|||||||
case ERASE_32K:
|
case ERASE_32K:
|
||||||
case ERASE_SECTOR:
|
case ERASE_SECTOR:
|
||||||
case READ:
|
case READ:
|
||||||
|
case DPP:
|
||||||
|
case QPP:
|
||||||
case PP:
|
case PP:
|
||||||
s->needed_bytes = 3;
|
s->needed_bytes = 3;
|
||||||
s->pos = 0;
|
s->pos = 0;
|
||||||
@ -382,12 +403,44 @@ static void decode_new_cmd(Flash *s, uint32_t value)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case FAST_READ:
|
case FAST_READ:
|
||||||
|
case DOR:
|
||||||
|
case QOR:
|
||||||
s->needed_bytes = 4;
|
s->needed_bytes = 4;
|
||||||
s->pos = 0;
|
s->pos = 0;
|
||||||
s->len = 0;
|
s->len = 0;
|
||||||
s->state = STATE_COLLECTING_DATA;
|
s->state = STATE_COLLECTING_DATA;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case DIOR:
|
||||||
|
switch ((s->pi->jedec >> 16) & 0xFF) {
|
||||||
|
case JEDEC_WINBOND:
|
||||||
|
case JEDEC_SPANSION:
|
||||||
|
s->needed_bytes = 4;
|
||||||
|
break;
|
||||||
|
case JEDEC_NUMONYX:
|
||||||
|
default:
|
||||||
|
s->needed_bytes = 5;
|
||||||
|
}
|
||||||
|
s->pos = 0;
|
||||||
|
s->len = 0;
|
||||||
|
s->state = STATE_COLLECTING_DATA;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case QIOR:
|
||||||
|
switch ((s->pi->jedec >> 16) & 0xFF) {
|
||||||
|
case JEDEC_WINBOND:
|
||||||
|
case JEDEC_SPANSION:
|
||||||
|
s->needed_bytes = 6;
|
||||||
|
break;
|
||||||
|
case JEDEC_NUMONYX:
|
||||||
|
default:
|
||||||
|
s->needed_bytes = 8;
|
||||||
|
}
|
||||||
|
s->pos = 0;
|
||||||
|
s->len = 0;
|
||||||
|
s->state = STATE_COLLECTING_DATA;
|
||||||
|
break;
|
||||||
|
|
||||||
case WRDI:
|
case WRDI:
|
||||||
s->write_enable = false;
|
s->write_enable = false;
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user