qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Francisco Iglesias <frasse.iglesias@gmail.com>
To: "Cédric Le Goater" <clg@kaod.org>
Cc: qemu-devel@nongnu.org, qemu-arm@nongnu.org,
	qemu-block@nongnu.org, Peter Maydell <peter.maydell@linaro.org>,
	Joel Stanley <joel@jms.id.au>, Andrew Jeffery <andrew@aj.id.au>,
	Alistair Francis <alistair@alistair23.me>,
	Iris Chen <irischenlj@fb.com>, Michael Walle <michael@walle.cc>
Subject: Re: [PATCH v3 1/8] m25p80: Add basic support for the SFDP command
Date: Fri, 22 Jul 2022 12:02:02 +0200	[thread overview]
Message-ID: <20220722100158.GA2574@fralle-msi> (raw)
In-Reply-To: <20220722063602.128144-2-clg@kaod.org>

On [2022 Jul 22] Fri 08:35:55, Cédric Le Goater wrote:
> JEDEC STANDARD JESD216 for Serial Flash Discovery Parameters (SFDP)
> provides a mean to describe the features of a serial flash device
> using a set of internal parameter tables.
> 
> This is the initial framework for the RDSFDP command giving access to
> a private SFDP area under the flash. This area now needs to be
> populated with the flash device characteristics, using a new
> 'sfdp_read' handler under FlashPartInfo.
> 
> Signed-off-by: Cédric Le Goater <clg@kaod.org>

Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com>

> ---
>  hw/block/m25p80_sfdp.h | 18 ++++++++++++++++++
>  hw/block/m25p80.c      | 27 +++++++++++++++++++++++++++
>  MAINTAINERS            |  2 +-
>  hw/block/trace-events  |  1 +
>  4 files changed, 47 insertions(+), 1 deletion(-)
>  create mode 100644 hw/block/m25p80_sfdp.h
> 
> diff --git a/hw/block/m25p80_sfdp.h b/hw/block/m25p80_sfdp.h
> new file mode 100644
> index 000000000000..230b07ef3308
> --- /dev/null
> +++ b/hw/block/m25p80_sfdp.h
> @@ -0,0 +1,18 @@
> +/*
> + * M25P80 SFDP
> + *
> + * Copyright (c) 2020, IBM Corporation.
> + *
> + * This code is licensed under the GPL version 2 or later. See the
> + * COPYING file in the top-level directory.
> + */
> +
> +#ifndef HW_M25P80_SFDP_H
> +#define HW_M25P80_SFDP_H
> +
> +/*
> + * SFDP area has a 3 bytes address space.
> + */
> +#define M25P80_SFDP_MAX_SIZE  (1 << 24)
> +
> +#endif
> diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c
> index a8d2519141f7..abdc4c0b0da7 100644
> --- a/hw/block/m25p80.c
> +++ b/hw/block/m25p80.c
> @@ -35,6 +35,7 @@
>  #include "qapi/error.h"
>  #include "trace.h"
>  #include "qom/object.h"
> +#include "m25p80_sfdp.h"
>  
>  /* 16 MiB max in 3 byte address mode */
>  #define MAX_3BYTES_SIZE 0x1000000
> @@ -72,6 +73,7 @@ typedef struct FlashPartInfo {
>       * This field inform how many die is in the chip.
>       */
>      uint8_t die_cnt;
> +    uint8_t (*sfdp_read)(uint32_t sfdp_addr);
>  } FlashPartInfo;
>  
>  /* adapted from linux */
> @@ -355,6 +357,7 @@ typedef enum {
>      BULK_ERASE = 0xc7,
>      READ_FSR = 0x70,
>      RDCR = 0x15,
> +    RDSFDP = 0x5a,
>  
>      READ = 0x03,
>      READ4 = 0x13,
> @@ -421,6 +424,7 @@ typedef enum {
>      STATE_COLLECTING_DATA,
>      STATE_COLLECTING_VAR_LEN_DATA,
>      STATE_READING_DATA,
> +    STATE_READING_SFDP,
>  } CMDState;
>  
>  typedef enum {
> @@ -679,6 +683,8 @@ static inline int get_addr_length(Flash *s)
>      }
>  
>     switch (s->cmd_in_progress) {
> +   case RDSFDP:
> +       return 3;
>     case PP4:
>     case PP4_4:
>     case QPP_4:
> @@ -823,6 +829,11 @@ static void complete_collecting_data(Flash *s)
>                            " by device\n");
>          }
>          break;
> +
> +    case RDSFDP:
> +        s->state = STATE_READING_SFDP;
> +        break;
> +
>      default:
>          break;
>      }
> @@ -1431,6 +1442,16 @@ static void decode_new_cmd(Flash *s, uint32_t value)
>              qemu_log_mask(LOG_GUEST_ERROR, "M25P80: Unknown cmd %x\n", value);
>          }
>          break;
> +    case RDSFDP:
> +        if (s->pi->sfdp_read) {
> +            s->needed_bytes = get_addr_length(s) + 1; /* SFDP addr + dummy */
> +            s->pos = 0;
> +            s->len = 0;
> +            s->state = STATE_COLLECTING_DATA;
> +            break;
> +        }
> +        /* Fallthrough */
> +
>      default:
>          s->pos = 0;
>          s->len = 1;
> @@ -1538,6 +1559,12 @@ static uint32_t m25p80_transfer8(SSIPeripheral *ss, uint32_t tx)
>              }
>          }
>          break;
> +    case STATE_READING_SFDP:
> +        assert(s->pi->sfdp_read);
> +        r = s->pi->sfdp_read(s->cur_addr);
> +        trace_m25p80_read_sfdp(s, s->cur_addr, (uint8_t)r);
> +        s->cur_addr = (s->cur_addr + 1) & (M25P80_SFDP_MAX_SIZE - 1);
> +        break;
>  
>      default:
>      case STATE_IDLE:
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 6af9cd985cea..92f232f01e3c 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -1915,7 +1915,7 @@ SSI
>  M: Alistair Francis <alistair@alistair23.me>
>  S: Maintained
>  F: hw/ssi/*
> -F: hw/block/m25p80.c
> +F: hw/block/m25p80*
>  F: include/hw/ssi/ssi.h
>  X: hw/ssi/xilinx_*
>  F: tests/qtest/m25p80-test.c
> diff --git a/hw/block/trace-events b/hw/block/trace-events
> index d86b53520cc5..2c45a62bd59c 100644
> --- a/hw/block/trace-events
> +++ b/hw/block/trace-events
> @@ -80,5 +80,6 @@ m25p80_page_program(void *s, uint32_t addr, uint8_t tx) "[%p] page program cur_a
>  m25p80_transfer(void *s, uint8_t state, uint32_t len, uint8_t needed, uint32_t pos, uint32_t cur_addr, uint8_t t) "[%p] Transfer state 0x%"PRIx8" len 0x%"PRIx32" needed 0x%"PRIx8" pos 0x%"PRIx32" addr 0x%"PRIx32" tx 0x%"PRIx8
>  m25p80_read_byte(void *s, uint32_t addr, uint8_t v) "[%p] Read byte 0x%"PRIx32"=0x%"PRIx8
>  m25p80_read_data(void *s, uint32_t pos, uint8_t v) "[%p] Read data 0x%"PRIx32"=0x%"PRIx8
> +m25p80_read_sfdp(void *s, uint32_t addr, uint8_t v) "[%p] Read SFDP 0x%"PRIx32"=0x%"PRIx8
>  m25p80_binding(void *s) "[%p] Binding to IF_MTD drive"
>  m25p80_binding_no_bdrv(void *s) "[%p] No BDRV - binding to RAM"
> -- 
> 2.35.3
> 


  reply	other threads:[~2022-07-22 10:05 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-22  6:35 [PATCH v3 0/8] m25p80: Add SFDP support Cédric Le Goater
2022-07-22  6:35 ` [PATCH v3 1/8] m25p80: Add basic support for the SFDP command Cédric Le Goater
2022-07-22 10:02   ` Francisco Iglesias [this message]
2022-07-22  6:35 ` [PATCH v3 2/8] m25p80: Add the n25q256a SFDP table Cédric Le Goater
2022-10-07 14:03   ` Francisco Iglesias
2022-10-10  6:15     ` Cédric Le Goater
2022-07-22  6:35 ` [PATCH v3 3/8] m25p80: Add the mx25l25635e SFPD table Cédric Le Goater
2022-10-07 13:59   ` Francisco Iglesias
2022-10-10  6:09     ` Cédric Le Goater
2022-07-22  6:35 ` [PATCH v3 4/8] m25p80: Add the mx25l25635f " Cédric Le Goater
2022-10-07 14:44   ` Francisco Iglesias
2022-10-10  6:23     ` Cédric Le Goater
2022-10-10  9:58       ` Michael Walle
2022-10-10 10:51         ` Francisco Iglesias
2022-10-10 15:11           ` Cédric Le Goater
2022-10-10 15:00         ` Cédric Le Goater
2022-07-22  6:35 ` [PATCH v3 5/8] m25p80: Add the mx66l1g45g SFDP table Cédric Le Goater
2022-10-07 14:59   ` Francisco Iglesias
2022-07-22  6:36 ` [PATCH v3 6/8] m25p80: Add the w25q256 SFPD table Cédric Le Goater
2022-10-07 15:13   ` Francisco Iglesias
2022-07-22  6:36 ` [PATCH v3 7/8] m25p80: Add the w25q512jv " Cédric Le Goater
2022-10-07 15:14   ` Francisco Iglesias
2022-07-22  6:36 ` [PATCH v3 8/8] arm/aspeed: Replace mx25l25635e chip model Cédric Le Goater
2022-07-25  2:08   ` Andrew Jeffery
2022-07-25  6:32     ` Cédric Le Goater
2022-07-25  6:34       ` Andrew Jeffery
2022-10-06 22:44   ` [PATCH] m25p80: Add the w25q01jvq SFPD table Patrick Williams
2022-10-07 15:24     ` Francisco Iglesias
2022-10-07 14:04   ` [PATCH v3 8/8] arm/aspeed: Replace mx25l25635e chip model Francisco Iglesias
2022-07-22  7:05 ` [PATCH v3 0/8] m25p80: Add SFDP support Cédric Le Goater
2022-07-22  8:06   ` Ben Dooks
2022-07-22  8:14     ` Cédric Le Goater
2022-10-06 22:49 ` Patrick Williams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220722100158.GA2574@fralle-msi \
    --to=frasse.iglesias@gmail.com \
    --cc=alistair@alistair23.me \
    --cc=andrew@aj.id.au \
    --cc=clg@kaod.org \
    --cc=irischenlj@fb.com \
    --cc=joel@jms.id.au \
    --cc=michael@walle.cc \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).