block: m25p80: Improve mt25qu01g chip model
v2 cover block: m25p80: Improve mt25qu01g chip model
This series introduce some improvememnt targeting mt25qu01g and adds support for n25q00 device.
v2:
* Rework die erase command functionality. Since the number of dies is constant per chip, new field to flash description structure has been added (instead of dynamic code from v1).
* Add definition for n25q00.
Marcin Krzeminski (3):
block: m25p80: Add Quad Page Program 4byte
block: m25p80: Introduce die erase command
block: m25p80: Improve 1GiB Micron flash definition
hw/block/m25p80.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 49 insertions(+), 3 deletions(-)
Signature · 1 line
2.9.3
PATCH v2 1/3 block: m25p80: Add Quad Page Program 4byte
Some flash chips have additional page program opcode that takes only 4 byte address. This commit adds support for such command in Qemu.
--- hw/block/m25p80.c | 4 ++++ 1 file changed, 4 insertions(+)
hw/block/m25p80.c +4 -0
@@ -326,6 +326,7 @@ typedef enum {PP4_4 =0x3e ,DPP =0xa2 ,QPP =0x32 , +QPP_4 =0x34 ,ERASE_4K =0x20 , ERASE4_4K = 0x21,
@@ -574,6 +575,7 @@ static inline int get_addr_length(Flash *s)switch (s->cmd_in_progress) {case PP4 :case PP4_4 : +case QPP_4 :case READ4 :case QIOR4 :case ERASE4_4K :
@@ -607,6 +609,7 @@ static void complete_collecting_data(Flash *s)switch (s->cmd_in_progress) {case DPP :case QPP : +case QPP_4 :case PP :case PP4 :case PP4_4 :
@@ -874,6 +877,7 @@ static void decode_new_cmd(Flash *s, uint32_t value)case READ4 :case DPP :case QPP : +case QPP_4 :case PP :case PP4 :case PP4_4 :
Signature · 1 line
2.9.3
PATCH v2 2/3 block: m25p80: Introduce die erase command
In reply to Marcin KrzeminskiModern big flash nor devices consist from more than one die. Some of them do not support chip erase and instead have die erase command that can erase one die only. This commit adds possibility to define number of dies in the chip and adds support for die erase command. Nor flash model is not strict thus option to disable chip eras was not added.
--- hw/block/m25p80.c | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-)
hw/block/m25p80.c +41 -1
@@ -73,6 +73,12 @@ typedef struct FlashPartInfo {uint32_t n_sectors;uint32_t page_size;uint16_t flags; +/* +* Big sized spi nor are often stacked devices, thus sometime +* replace chip erase with die erase. +* This field inform how many die is in the chip. +*/ +uint8_t die_cnt; } FlashPartInfo;/* adapted from linux */
@@ -90,7 +96,8 @@ typedef struct FlashPartInfo { .sector_size = (_sector_size),\ .n_sectors = (_n_sectors),\ .page_size = 256,\ - .flags = (_flags), + .flags = (_flags),\ + .die_cnt = 0#define INFO6 (_part_name, _jedec_id, _ext_id, _sector_size, _n_sectors, _flags)\ .part_name = _part_name,\
@@ -107,6 +114,24 @@ typedef struct FlashPartInfo { .n_sectors = (_n_sectors),\ .page_size = 256,\ .flags = (_flags),\ + .die_cnt = 0 + +#define INFO_STACKED (_part_name, _jedec_id, _ext_id, _sector_size, _n_sectors,\ + _flags, _die_cnt)\ + .part_name = _part_name,\ + .id = {\ + ((_jedec_id) >> 16) & 0xff,\ + ((_jedec_id) >> 8) & 0xff,\ + (_jedec_id) & 0xff,\ + ((_ext_id) >> 8) & 0xff,\ + (_ext_id) & 0xff,\ + },\ + .id_len = (!(_jedec_id) ? 0 : (3 + ((_ext_id) ? 2 : 0))),\ + .sector_size = (_sector_size),\ + .n_sectors = (_n_sectors),\ + .page_size = 256,\ + .flags = (_flags),\ + .die_cnt = _die_cnt#define JEDEC_NUMONYX 0x20#define JEDEC_WINBOND 0xEF
@@ -359,6 +384,8 @@ typedef enum {REVCR =0x65 ,WEVCR =0x61 , + +DIE_ERASE =0xC4 , } FlashCMD; typedef enum {
@@ -514,6 +541,17 @@ static void flash_erase(Flash *s, int offset, FlashCMD cmd)case BULK_ERASE : len = s->size;break ; +case DIE_ERASE : +if (s->pi->die_cnt) { + len = s->size / s->pi->die_cnt; + offset = offset & (~(len -1 )); +printf ("Die erase len = 0x%X offset = 0x%X!\n" , len, offset); + }else { +qemu_log_mask (LOG_GUEST_ERROR ,"M25P80: die erase is not supported" +" by device\n" ); +return ; + } +break ;default :abort (); }
@@ -635,6 +673,7 @@ static void complete_collecting_data(Flash *s)case ERASE4_32K :case ERASE_SECTOR :case ERASE4_SECTOR : +case DIE_ERASE :flash_erase (s, s->cur_addr, s->cmd_in_progress);break ;case WRSR :
@@ -881,6 +920,7 @@ static void decode_new_cmd(Flash *s, uint32_t value)case PP :case PP4 :case PP4_4 : +case DIE_ERASE : s->needed_bytes =get_addr_length (s); s->pos =0 ; s->len =0 ;
Signature · 1 line
2.9.3
Re: [Qemu-arm] [PATCH v2 2/3] block: m25p80: Introduce die erase command
Quoted 74 lines · Marcin Krzeminski
Modern big flash nor devices consist from more than one die. Some of them do not support chip erase and instead have die erase command that can erase one die only. This commit adds possibility to define number of dies in the chip and adds support for die erase command. Nor flash model is not strict thus option to disable chip eras was not added.
Signed-off-by Marcin Krzeminski <[email protected]>--- hw/block/m25p80.c | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-)hw/block/m25p80.c +28
-1@@ -73,6 +73,12 @@ typedef struct FlashPartInfo {uint32_t n_sectors;uint32_t page_size;uint16_t flags; +/* +* Big sized spi nor are often stacked devices, thus sometime +* replace chip erase with die erase. +* This field inform how many die is in the chip. +*/ +uint8_t die_cnt; } FlashPartInfo;/* adapted from linux */ @@ -90,7 +96,8 @@ typedef struct FlashPartInfo { .sector_size = (_sector_size),\ .n_sectors = (_n_sectors),\ .page_size = 256,\ - .flags = (_flags), + .flags = (_flags),\ + .die_cnt = 0#define INFO6 (_part_name, _jedec_id, _ext_id, _sector_size, _n_sectors, _flags)\ .part_name = _part_name,\@@ -107,6 +114,24 @@ typedef struct FlashPartInfo { .n_sectors = (_n_sectors),\ .page_size = 256,\ .flags = (_flags),\ + .die_cnt = 0 + +#define INFO_STACKED (_part_name, _jedec_id, _ext_id, _sector_size, _n_sectors,\ + _flags, _die_cnt)\ + .part_name = _part_name,\ + .id = {\ + ((_jedec_id) >> 16) & 0xff,\ + ((_jedec_id) >> 8) & 0xff,\ + (_jedec_id) & 0xff,\ + ((_ext_id) >> 8) & 0xff,\ + (_ext_id) & 0xff,\ + },\ + .id_len = (!(_jedec_id) ? 0 : (3 + ((_ext_id) ? 2 : 0))),\ + .sector_size = (_sector_size),\ + .n_sectors = (_n_sectors),\ + .page_size = 256,\ + .flags = (_flags),\ + .die_cnt = _die_cnt#define JEDEC_NUMONYX 0x20#define JEDEC_WINBOND 0xEF@@ -359,6 +384,8 @@ typedef enum {REVCR =0x65 ,WEVCR =0x61 , + +DIE_ERASE =0xC4 , } FlashCMD; typedef enum {
hw/block/m25p80.c static void flash_erase(Flash *s, int offset, FlashCMD cmd) · line 548
Quoted 8 lines
hw/block/m25p80.c +5
-0@@ -514,6 +541,17 @@ static void flash_erase(Flash *s, int offset, FlashCMD cmd)case BULK_ERASE : len = s->size;break ; +case DIE_ERASE : +if (s->pi->die_cnt) { + len = s->size / s->pi->die_cnt; + offset = offset & (~(len -1 )); +printf ("Die erase len = 0x%X offset = 0x%X!\n" , len, offset);
do we need this printf ?
Thanks,
C.
Quoted 26 lines
hw/block/m25p80.c +8
-0+ }else { +qemu_log_mask (LOG_GUEST_ERROR ,"M25P80: die erase is not supported" +" by device\n" ); +return ; + } +break ;default :abort (); }@@ -635,6 +673,7 @@ static void complete_collecting_data(Flash *s)case ERASE4_32K :case ERASE_SECTOR :case ERASE4_SECTOR : +case DIE_ERASE :flash_erase (s, s->cur_addr, s->cmd_in_progress);break ;case WRSR :@@ -881,6 +920,7 @@ static void decode_new_cmd(Flash *s, uint32_t value)case PP :case PP4 :case PP4_4 : +case DIE_ERASE : s->needed_bytes =get_addr_length (s); s->pos =0 ; s->len =0 ;
Re: [Qemu-arm] [PATCH v2 2/3] block: m25p80: Introduce die erase command
W dniu 07.01.2017 o 20:57, Cédric Le Goater pisze:
Quoted 73 lines · Marcin Krzeminski
Quoted 72 lines
Modern big flash nor devices consist from more than one die. Some of them do not support chip erase and instead have die erase command that can erase one die only. This commit adds possibility to define number of dies in the chip and adds support for die erase command. Nor flash model is not strict thus option to disable chip eras was not added.
Signed-off-by Marcin Krzeminski <[email protected]>--- hw/block/m25p80.c | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-)hw/block/m25p80.c +28
-1@@ -73,6 +73,12 @@ typedef struct FlashPartInfo {uint32_t n_sectors;uint32_t page_size;uint16_t flags; +/* +* Big sized spi nor are often stacked devices, thus sometime +* replace chip erase with die erase. +* This field inform how many die is in the chip. +*/ +uint8_t die_cnt; } FlashPartInfo;/* adapted from linux */ @@ -90,7 +96,8 @@ typedef struct FlashPartInfo { .sector_size = (_sector_size),\ .n_sectors = (_n_sectors),\ .page_size = 256,\ - .flags = (_flags), + .flags = (_flags),\ + .die_cnt = 0#define INFO6 (_part_name, _jedec_id, _ext_id, _sector_size, _n_sectors, _flags)\ .part_name = _part_name,\@@ -107,6 +114,24 @@ typedef struct FlashPartInfo { .n_sectors = (_n_sectors),\ .page_size = 256,\ .flags = (_flags),\ + .die_cnt = 0 + +#define INFO_STACKED (_part_name, _jedec_id, _ext_id, _sector_size, _n_sectors,\ + _flags, _die_cnt)\ + .part_name = _part_name,\ + .id = {\ + ((_jedec_id) >> 16) & 0xff,\ + ((_jedec_id) >> 8) & 0xff,\ + (_jedec_id) & 0xff,\ + ((_ext_id) >> 8) & 0xff,\ + (_ext_id) & 0xff,\ + },\ + .id_len = (!(_jedec_id) ? 0 : (3 + ((_ext_id) ? 2 : 0))),\ + .sector_size = (_sector_size),\ + .n_sectors = (_n_sectors),\ + .page_size = 256,\ + .flags = (_flags),\ + .die_cnt = _die_cnt#define JEDEC_NUMONYX 0x20#define JEDEC_WINBOND 0xEF@@ -359,6 +384,8 @@ typedef enum {REVCR =0x65 ,WEVCR =0x61 , + +DIE_ERASE =0xC4 , } FlashCMD;
Quoted 11 lines
hw/block/m25p80.c static void flash_erase(Flash *s, int offset, FlashCMD cmd) · line 548
Quoted 10 lines
hw/block/m25p80.c +5
-0typedef enum {@@ -514,6 +541,17 @@ static void flash_erase(Flash *s, int offset, FlashCMD cmd)case BULK_ERASE : len = s->size;break ; +case DIE_ERASE : +if (s->pi->die_cnt) { + len = s->size / s->pi->die_cnt; + offset = offset & (~(len -1 )); +printf ("Die erase len = 0x%X offset = 0x%X!\n" , len, offset);do we need this printf ?
Ups, testing leftover. I will delete this in next version. Thanks!
Quoted 33 lines
Thanks,
C.
Quoted 26 lines
hw/block/m25p80.c +8
-0+ }else { +qemu_log_mask (LOG_GUEST_ERROR ,"M25P80: die erase is not supported" +" by device\n" ); +return ; + } +break ;default :abort (); }@@ -635,6 +673,7 @@ static void complete_collecting_data(Flash *s)case ERASE4_32K :case ERASE_SECTOR :case ERASE4_SECTOR : +case DIE_ERASE :flash_erase (s, s->cur_addr, s->cmd_in_progress);break ;case WRSR :@@ -881,6 +920,7 @@ static void decode_new_cmd(Flash *s, uint32_t value)case PP :case PP4 :case PP4_4 : +case DIE_ERASE : s->needed_bytes =get_addr_length (s); s->pos =0 ; s->len =0 ;
PATCH v2 3/3 block: m25p80: Improve 1GiB Micron flash definition
In reply to Marcin Krzeminskin25q00 and mt25q01 devices share the same JEDEC ID. The difference between those two devices is number of dies and one bit in extended JEDEC bytes. This commit adds proper entry for both devices by introduction the number of dies and and new 25q00 entries.
--- hw/block/m25p80.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
hw/block/m25p80.c +4 -2
@@ -242,8 +242,10 @@ static const FlashPartInfo known_devices[] = { { INFO("n25q128", 0x20ba18, 0, 64 << 10, 256, 0) }, { INFO("n25q256a", 0x20ba19, 0, 64 << 10, 512, ER_4K) }, { INFO("n25q512a", 0x20ba20, 0, 64 << 10, 1024, ER_4K) }, - { INFO("mt25ql01g", 0x20ba21, 0, 64 << 10, 2048, ER_4K) }, - { INFO("mt25qu01g", 0x20bb21, 0, 64 << 10, 2048, ER_4K) }, + { INFO_STACKED("n25q00", 0x20ba21, 0x1000, 64 << 10, 2048, ER_4K, 4) }, + { INFO_STACKED("n25q00a", 0x20bb21, 0x1000, 64 << 10, 2048, ER_4K, 4) }, + { INFO_STACKED("mt25ql01g", 0x20ba21, 0x1040, 64 << 10, 2048, ER_4K, 2) }, + { INFO_STACKED("mt25qu01g", 0x20bb21, 0x1040, 64 << 10, 2048, ER_4K, 2) },/* Spansion -- single (large) sector size only, at least * for the chips listed here (without boot sectors).
Signature · 1 line
2.9.3