aboutsummaryrefslogtreecommitdiff
path: root/hw/block/m25p80.c
diff options
context:
space:
mode:
authorMarcin Krzeminski <marcin.krzeminski@nokia.com>2016-06-27 15:37:33 +0100
committerPeter Maydell <peter.maydell@linaro.org>2016-06-27 15:37:33 +0100
commitc7cd0a6c2475edaf4659839772cf6af24338eb6f (patch)
tree10452f91c6b7581562737792c716833150e8ae7f /hw/block/m25p80.c
parent87e79af074ba96a3307447939ae196324b34eb3d (diff)
m25p80: Replace JEDEC ID masking with function.
Instead of always reading and comparing jededc ID, replace it by function. Signed-off-by: Marcin Krzeminski <marcin.krzeminski@nokia.com> Message-id: 1466755631-25201-2-git-send-email-marcin.krzeminski@nokia.com Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'hw/block/m25p80.c')
-rw-r--r--hw/block/m25p80.c49
1 files changed, 40 insertions, 9 deletions
diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c
index 51d8596056..d6bde29c62 100644
--- a/hw/block/m25p80.c
+++ b/hw/block/m25p80.c
@@ -307,6 +307,14 @@ typedef enum {
STATE_READING_DATA,
} CMDState;
+typedef enum {
+ MAN_SPANSION,
+ MAN_MACRONIX,
+ MAN_NUMONYX,
+ MAN_WINBOND,
+ MAN_GENERIC,
+} Manufacturer;
+
typedef struct Flash {
SSISlave parent_obj;
@@ -350,6 +358,22 @@ typedef struct M25P80Class {
#define M25P80_GET_CLASS(obj) \
OBJECT_GET_CLASS(M25P80Class, (obj), TYPE_M25P80)
+static inline Manufacturer get_man(Flash *s)
+{
+ switch (((s->pi->jedec >> 16) & 0xFF)) {
+ case 0x20:
+ return MAN_NUMONYX;
+ case 0xEF:
+ return MAN_WINBOND;
+ case 0x01:
+ return MAN_SPANSION;
+ case 0xC2:
+ return MAN_MACRONIX;
+ default:
+ return MAN_GENERIC;
+ }
+}
+
static void blk_sync_complete(void *opaque, int ret)
{
/* do nothing. Masters do not directly interact with the backing store,
@@ -562,7 +586,8 @@ static void reset_memory(Flash *s)
s->write_enable = false;
s->reset_enable = false;
- if (((s->pi->jedec >> 16) & 0xFF) == JEDEC_NUMONYX) {
+ switch (get_man(s)) {
+ case MAN_NUMONYX:
s->volatile_cfg = 0;
s->volatile_cfg |= VCFG_DUMMY;
s->volatile_cfg |= VCFG_WRAP_SEQUENTIAL;
@@ -594,6 +619,9 @@ static void reset_memory(Flash *s)
if (!(s->nonvolatile_cfg & NVCFG_LOWER_SEGMENT_MASK)) {
s->ear = CFG_UPPER_128MB_SEG_ENABLED;
}
+ break;
+ default:
+ break;
}
DB_PRINT_L(0, "Reset done.\n");
@@ -634,9 +662,12 @@ static void decode_new_cmd(Flash *s, uint32_t value)
case QOR:
case QOR4:
s->needed_bytes = get_addr_length(s);
- if (((s->pi->jedec >> 16) & 0xFF) == JEDEC_NUMONYX) {
- /* Dummy cycles modeled with bytes writes instead of bits */
+ switch (get_man(s)) {
+ case MAN_NUMONYX:
s->needed_bytes += extract32(s->volatile_cfg, 4, 4);
+ break;
+ default:
+ break;
}
s->pos = 0;
s->len = 0;
@@ -645,9 +676,9 @@ static void decode_new_cmd(Flash *s, uint32_t value)
case DIOR:
case DIOR4:
- switch ((s->pi->jedec >> 16) & 0xFF) {
- case JEDEC_WINBOND:
- case JEDEC_SPANSION:
+ switch (get_man(s)) {
+ case MAN_WINBOND:
+ case MAN_SPANSION:
s->needed_bytes = 4;
break;
default:
@@ -662,9 +693,9 @@ static void decode_new_cmd(Flash *s, uint32_t value)
case QIOR:
case QIOR4:
- switch ((s->pi->jedec >> 16) & 0xFF) {
- case JEDEC_WINBOND:
- case JEDEC_SPANSION:
+ switch (get_man(s)) {
+ case MAN_WINBOND:
+ case MAN_SPANSION:
s->needed_bytes = 6;
break;
default: