mbox series

[v42,00/98] hw/sd/sdcard: Add eMMC support

Message ID 20240628070216.92609-1-philmd@linaro.org (mailing list archive)
Headers show
Series hw/sd/sdcard: Add eMMC support | expand

Message

Philippe Mathieu-Daudé June 28, 2024, 7 a.m. UTC
Cédric asked for one big series to review instead of
various tiny ones...

I plan to send a pull request before v9.1 soft freeze
with at least patches 1-81 (prerequisistes before the
"Basis for eMMC support" patch) except qtest patch #15.

Also available as:
https://gitlab.com/philmd/qemu/-/commits/emmc-testing/

Cédric Le Goater (5):
  hw/sd/sdcard: Introduce definitions for EXT_CSD register
  hw/sd/sdcard: Add emmc_cmd_SET_RELATIVE_ADDR() handler
  hw/sd/sdcard: Fix SET_BLOCK_COUNT command argument on eMMC (CMD23)
  hw/sd/sdcard: Adapt sd_cmd_ALL_SEND_CID handler for eMMC (CMD2)
  hw/sd/sdcard: Adapt sd_cmd_APP_CMD handler for eMMC (CMD55)

Joel Stanley (3):
  hw/sd/sdcard: Support boot area in emmc image
  hw/sd/sdcard: Subtract bootarea size from blk
  hw/sd/sdcard: Add boot config support

Luc Michel (1):
  hw/sd/sdcard: Implement eMMC sleep state (CMD5)

Philippe Mathieu-Daudé (85):
  hw/sd/sdcard: Deprecate support for spec v1.10
  hw/sd/sdcard: Use spec v3.01 by default
  hw/sd/sdcard: Track last command used to help logging
  hw/sd/sdcard: Trace block offset in READ/WRITE data accesses
  hw/sd/sdcard: Trace requested address computed by sd_req_get_address()
  hw/sd/sdcard: Do not store vendor data on block drive (CMD56)
  hw/sd/sdcard: Send WRITE_PROT bits MSB first (CMD30)
  hw/sd/sdcard: Send NUM_WR_BLOCKS bits MSB first (ACMD22)
  hw/sd/sdcard: Use READY_FOR_DATA definition instead of magic value
  hw/sd/sdcard: Assign SDCardStates enum values
  hw/sd/sdcard: Simplify sd_inactive_state handling
  hw/sd/sdcard: Restrict SWITCH_FUNCTION to sd_transfer_state (CMD6)
  hw/sd/sdcard: Add direct reference to SDProto in SDState
  hw/sd/sdcard: Extract sd_blk_len() helper
  tests/qtest: Disable npcm7xx_sdhci tests using hardcoded RCA
  hw/sd/sdcard: Generate random RCA value
  hw/sd/sdcard: Introduce sd_cmd_to_sendingdata and sd_generic_read_byte
  hw/sd/sdcard: Convert SWITCH_FUNCTION to generic_read_byte (CMD6)
  hw/sd/sdcard: Convert SEND_CSD/SEND_CID to generic_read_byte (CMD9 &
    10)
  hw/sd/sdcard: Duplicate READ_SINGLE_BLOCK / READ_MULTIPLE_BLOCK cases
  hw/sd/sdcard: Convert READ_SINGLE_BLOCK to generic_read_byte (CMD17)
  hw/sd/sdcard: Convert SEND_TUNING_BLOCK to generic_read_byte (CMD19)
  hw/sd/sdcard: Convert SEND_WRITE_PROT to generic_read_byte (CMD30)
  hw/sd/sdcard: Convert GEN_CMD to generic_read_byte (CMD56)
  hw/sd/sdcard: Convert SD_STATUS to generic_read_byte (ACMD13)
  hw/sd/sdcard: Convert SEND_NUM_WR_BLOCKS to generic_read_byte (ACMD22)
  hw/sd/sdcard: Convert SEND_SCR to generic_read_byte (ACMD51)
  hw/sd/sdcard: Introduce sd_cmd_to_receivingdata /
    sd_generic_write_byte
  hw/sd/sdcard: Duplicate WRITE_SINGLE_BLOCK / WRITE_MULTIPLE_BLOCK
    cases
  hw/sd/sdcard: Convert WRITE_SINGLE_BLOCK to generic_write_byte (CMD24)
  hw/sd/sdcard: Convert PROGRAM_CID to generic_write_byte (CMD26)
  hw/sd/sdcard: Convert PROGRAM_CSD to generic_write_byte (CMD27)
  hw/sd/sdcard: Convert LOCK_UNLOCK to generic_write_byte (CMD42)
  hw/sd/sdcard: Convert GEN_CMD to generic_write_byte (CMD56)
  hw/sd/sdcard: Move sd_[a]cmd_name() methods to sd.c
  hw/sd/sdcard: Pass SDState as argument to sd_[a]cmd_name()
  hw/sd/sdcard: Prepare SDProto to contain more fields
  hw/sd/sdcard: Store command name in SDProto
  hw/sd/sdcard: Store command type in SDProto
  hw/sd/sdcard: Store command class in SDProto
  hw/sd/sdcard: Remove SEND_DSR dead case (CMD4)
  hw/sd/sdcard: Register generic optional handlers (CMD11 and CMD20)
  hw/sd/sdcard: Register optional handlers from spec v6.00
  hw/sd/sdcard: Register SDIO optional handlers
  hw/sd/sdcard: Register Security Extension optional handlers
  hw/sd/sdcard: Add sd_cmd_SWITCH_FUNCTION handler (CMD6)
  hw/sd/sdcard: Add sd_cmd_DE/SELECT_CARD handler (CMD7)
  hw/sd/sdcard: Add sd_cmd_SEND_IF_COND handler (CMD8)
  hw/sd/sdcard: Add sd_cmd_SEND_CSD/CID handlers (CMD9 & CMD10)
  hw/sd/sdcard: Add spi_cmd_SEND_CSD/CID handlers (CMD9 & CMD10)
  hw/sd/sdcard: Add sd_cmd_STOP_TRANSMISSION handler (CMD12)
  hw/sd/sdcard: Add sd_cmd_SEND_STATUS handler (CMD13)
  hw/sd/sdcard: Add sd_cmd_GO_INACTIVE_STATE handler (CMD15)
  hw/sd/sdcard: Add sd_cmd_SET_BLOCKLEN handler (CMD16)
  hw/sd/sdcard: Add sd_cmd_READ_SINGLE_BLOCK handler (CMD17)
  hw/sd/sdcard: Add sd_cmd_WRITE_SINGLE_BLOCK handler (CMD24)
  hw/sd/sdcard: Add sd_cmd_PROGRAM_CSD handler (CMD27)
  hw/sd/sdcard: Add sd_cmd_SET/CLR_WRITE_PROT handler (CMD28 & CMD29)
  hw/sd/sdcard: Add sd_cmd_SEND_WRITE_PROT handler (CMD30)
  hw/sd/sdcard: Add sd_cmd_ERASE_WR_BLK_START/END handlers (CMD32 &
    CMD33)
  hw/sd/sdcard: Add sd_cmd_ERASE handler (CMD38)
  hw/sd/sdcard: Add sd_cmd_LOCK_UNLOCK handler (CMD42)
  hw/sd/sdcard: Add sd_cmd_APP_CMD handler (CMD55)
  hw/sd/sdcard: Add sd_cmd_GEN_CMD handler (CMD56)
  hw/sd/sdcard: Add spi_cmd_READ_OCR handler (CMD58)
  hw/sd/sdcard: Add spi_cmd_CRC_ON_OFF handler (CMD59)
  hw/sd/sdcard: Add sd_acmd_SET_BUS_WIDTH handler (ACMD6)
  hw/sd/sdcard: Add sd_acmd_SD_STATUS handler (ACMD13)
  hw/sd/sdcard: Add sd_acmd_SEND_NUM_WR_BLOCKS handler (ACMD22)
  hw/sd/sdcard: Add sd_acmd_SET_WR_BLK_ERASE_COUNT handler (ACMD23)
  hw/sd/sdcard: Add sd_acmd_SD_APP_OP_COND handler (ACMD41)
  hw/sd/sdcard: Add sd_acmd_SET_CLR_CARD_DETECT handler (ACMD42)
  hw/sd/sdcard: Add sd_acmd_SEND_SCR handler (ACMD51)
  hw/sd/sdcard: Remove sd_none enum from sd_cmd_type_t
  hw/sd/sdcard: Remove noise from sd_acmd_name()
  hw/sd/sdcard: Remove noise from sd_cmd_name()
  hw/sd/sdcard: Remove default case in read/write on DAT lines
  hw/sd/sdcard: Trace length of data read on DAT lines
  hw/sd/sdcard: Introduce set_csd/set_cid handlers
  hw/sd/sdcard: Cover more SDCardStates
  hw/sd/sdcard: Basis for eMMC support
  hw/sd/sdcard: Register generic command handlers
  hw/sd/sdcard: Register unimplemented command handlers
  hw/sd/sdcard: Add mmc_cmd_PROGRAM_CID handler (CMD26)
  hw/sd/sdcard: Add experimental 'x-aspeed-emmc-kludge' property

Sai Pavan Boddu (3):
  hw/sd/sdcard: Add emmc_cmd_SEND_OP_COND handler (CMD1)
  hw/sd/sdcard: add emmc_cmd_SEND_TUNING_BLOCK handler (CMD21)
  hw/sd/sdcard: Add mmc SWITCH function support (CMD6)

Vincent Palatin (1):
  hw/sd/sdcard: Add emmc_cmd_SEND_EXT_CSD handler (CMD8)

 docs/about/deprecated.rst        |    6 +
 hw/sd/sdmmc-internal.h           |  118 +-
 include/hw/sd/sd.h               |   10 +-
 hw/sd/sd.c                       | 1917 +++++++++++++++++++-----------
 hw/sd/sdmmc-internal.c           |   72 --
 tests/qtest/npcm7xx_sdhci-test.c |    7 +
 hw/sd/meson.build                |    2 +-
 hw/sd/trace-events               |    6 +-
 8 files changed, 1362 insertions(+), 776 deletions(-)
 delete mode 100644 hw/sd/sdmmc-internal.c

Comments

Cédric Le Goater June 28, 2024, 7:27 a.m. UTC | #1
On 6/28/24 9:00 AM, Philippe Mathieu-Daudé wrote:
> Cédric asked for one big series to review instead of
> various tiny ones...

Thanks for all this work !

> I plan to send a pull request before v9.1 soft freeze
> with at least patches 1-81 (prerequisistes before the
> "Basis for eMMC support" patch) except qtest patch #15.

I will scheme through the series for obvious flaws.

Unfortunately, I can not review for 82-98 adding the eMMC part, we will
need someone else for that. Adding Aspeed engineers.

Anyhow,

   Tested-by: Cédric Le Goater <clg@redhat.com>

> Also available as:
> https://gitlab.com/philmd/qemu/-/commits/emmc-testing/
Thanks,

C.

> 
> Cédric Le Goater (5):
>    hw/sd/sdcard: Introduce definitions for EXT_CSD register
>    hw/sd/sdcard: Add emmc_cmd_SET_RELATIVE_ADDR() handler
>    hw/sd/sdcard: Fix SET_BLOCK_COUNT command argument on eMMC (CMD23)
>    hw/sd/sdcard: Adapt sd_cmd_ALL_SEND_CID handler for eMMC (CMD2)
>    hw/sd/sdcard: Adapt sd_cmd_APP_CMD handler for eMMC (CMD55)
> 
> Joel Stanley (3):
>    hw/sd/sdcard: Support boot area in emmc image
>    hw/sd/sdcard: Subtract bootarea size from blk
>    hw/sd/sdcard: Add boot config support
> 
> Luc Michel (1):
>    hw/sd/sdcard: Implement eMMC sleep state (CMD5)
> 
> Philippe Mathieu-Daudé (85):
>    hw/sd/sdcard: Deprecate support for spec v1.10
>    hw/sd/sdcard: Use spec v3.01 by default
>    hw/sd/sdcard: Track last command used to help logging
>    hw/sd/sdcard: Trace block offset in READ/WRITE data accesses
>    hw/sd/sdcard: Trace requested address computed by sd_req_get_address()
>    hw/sd/sdcard: Do not store vendor data on block drive (CMD56)
>    hw/sd/sdcard: Send WRITE_PROT bits MSB first (CMD30)
>    hw/sd/sdcard: Send NUM_WR_BLOCKS bits MSB first (ACMD22)
>    hw/sd/sdcard: Use READY_FOR_DATA definition instead of magic value
>    hw/sd/sdcard: Assign SDCardStates enum values
>    hw/sd/sdcard: Simplify sd_inactive_state handling
>    hw/sd/sdcard: Restrict SWITCH_FUNCTION to sd_transfer_state (CMD6)
>    hw/sd/sdcard: Add direct reference to SDProto in SDState
>    hw/sd/sdcard: Extract sd_blk_len() helper
>    tests/qtest: Disable npcm7xx_sdhci tests using hardcoded RCA
>    hw/sd/sdcard: Generate random RCA value
>    hw/sd/sdcard: Introduce sd_cmd_to_sendingdata and sd_generic_read_byte
>    hw/sd/sdcard: Convert SWITCH_FUNCTION to generic_read_byte (CMD6)
>    hw/sd/sdcard: Convert SEND_CSD/SEND_CID to generic_read_byte (CMD9 &
>      10)
>    hw/sd/sdcard: Duplicate READ_SINGLE_BLOCK / READ_MULTIPLE_BLOCK cases
>    hw/sd/sdcard: Convert READ_SINGLE_BLOCK to generic_read_byte (CMD17)
>    hw/sd/sdcard: Convert SEND_TUNING_BLOCK to generic_read_byte (CMD19)
>    hw/sd/sdcard: Convert SEND_WRITE_PROT to generic_read_byte (CMD30)
>    hw/sd/sdcard: Convert GEN_CMD to generic_read_byte (CMD56)
>    hw/sd/sdcard: Convert SD_STATUS to generic_read_byte (ACMD13)
>    hw/sd/sdcard: Convert SEND_NUM_WR_BLOCKS to generic_read_byte (ACMD22)
>    hw/sd/sdcard: Convert SEND_SCR to generic_read_byte (ACMD51)
>    hw/sd/sdcard: Introduce sd_cmd_to_receivingdata /
>      sd_generic_write_byte
>    hw/sd/sdcard: Duplicate WRITE_SINGLE_BLOCK / WRITE_MULTIPLE_BLOCK
>      cases
>    hw/sd/sdcard: Convert WRITE_SINGLE_BLOCK to generic_write_byte (CMD24)
>    hw/sd/sdcard: Convert PROGRAM_CID to generic_write_byte (CMD26)
>    hw/sd/sdcard: Convert PROGRAM_CSD to generic_write_byte (CMD27)
>    hw/sd/sdcard: Convert LOCK_UNLOCK to generic_write_byte (CMD42)
>    hw/sd/sdcard: Convert GEN_CMD to generic_write_byte (CMD56)
>    hw/sd/sdcard: Move sd_[a]cmd_name() methods to sd.c
>    hw/sd/sdcard: Pass SDState as argument to sd_[a]cmd_name()
>    hw/sd/sdcard: Prepare SDProto to contain more fields
>    hw/sd/sdcard: Store command name in SDProto
>    hw/sd/sdcard: Store command type in SDProto
>    hw/sd/sdcard: Store command class in SDProto
>    hw/sd/sdcard: Remove SEND_DSR dead case (CMD4)
>    hw/sd/sdcard: Register generic optional handlers (CMD11 and CMD20)
>    hw/sd/sdcard: Register optional handlers from spec v6.00
>    hw/sd/sdcard: Register SDIO optional handlers
>    hw/sd/sdcard: Register Security Extension optional handlers
>    hw/sd/sdcard: Add sd_cmd_SWITCH_FUNCTION handler (CMD6)
>    hw/sd/sdcard: Add sd_cmd_DE/SELECT_CARD handler (CMD7)
>    hw/sd/sdcard: Add sd_cmd_SEND_IF_COND handler (CMD8)
>    hw/sd/sdcard: Add sd_cmd_SEND_CSD/CID handlers (CMD9 & CMD10)
>    hw/sd/sdcard: Add spi_cmd_SEND_CSD/CID handlers (CMD9 & CMD10)
>    hw/sd/sdcard: Add sd_cmd_STOP_TRANSMISSION handler (CMD12)
>    hw/sd/sdcard: Add sd_cmd_SEND_STATUS handler (CMD13)
>    hw/sd/sdcard: Add sd_cmd_GO_INACTIVE_STATE handler (CMD15)
>    hw/sd/sdcard: Add sd_cmd_SET_BLOCKLEN handler (CMD16)
>    hw/sd/sdcard: Add sd_cmd_READ_SINGLE_BLOCK handler (CMD17)
>    hw/sd/sdcard: Add sd_cmd_WRITE_SINGLE_BLOCK handler (CMD24)
>    hw/sd/sdcard: Add sd_cmd_PROGRAM_CSD handler (CMD27)
>    hw/sd/sdcard: Add sd_cmd_SET/CLR_WRITE_PROT handler (CMD28 & CMD29)
>    hw/sd/sdcard: Add sd_cmd_SEND_WRITE_PROT handler (CMD30)
>    hw/sd/sdcard: Add sd_cmd_ERASE_WR_BLK_START/END handlers (CMD32 &
>      CMD33)
>    hw/sd/sdcard: Add sd_cmd_ERASE handler (CMD38)
>    hw/sd/sdcard: Add sd_cmd_LOCK_UNLOCK handler (CMD42)
>    hw/sd/sdcard: Add sd_cmd_APP_CMD handler (CMD55)
>    hw/sd/sdcard: Add sd_cmd_GEN_CMD handler (CMD56)
>    hw/sd/sdcard: Add spi_cmd_READ_OCR handler (CMD58)
>    hw/sd/sdcard: Add spi_cmd_CRC_ON_OFF handler (CMD59)
>    hw/sd/sdcard: Add sd_acmd_SET_BUS_WIDTH handler (ACMD6)
>    hw/sd/sdcard: Add sd_acmd_SD_STATUS handler (ACMD13)
>    hw/sd/sdcard: Add sd_acmd_SEND_NUM_WR_BLOCKS handler (ACMD22)
>    hw/sd/sdcard: Add sd_acmd_SET_WR_BLK_ERASE_COUNT handler (ACMD23)
>    hw/sd/sdcard: Add sd_acmd_SD_APP_OP_COND handler (ACMD41)
>    hw/sd/sdcard: Add sd_acmd_SET_CLR_CARD_DETECT handler (ACMD42)
>    hw/sd/sdcard: Add sd_acmd_SEND_SCR handler (ACMD51)
>    hw/sd/sdcard: Remove sd_none enum from sd_cmd_type_t
>    hw/sd/sdcard: Remove noise from sd_acmd_name()
>    hw/sd/sdcard: Remove noise from sd_cmd_name()
>    hw/sd/sdcard: Remove default case in read/write on DAT lines
>    hw/sd/sdcard: Trace length of data read on DAT lines
>    hw/sd/sdcard: Introduce set_csd/set_cid handlers
>    hw/sd/sdcard: Cover more SDCardStates
>    hw/sd/sdcard: Basis for eMMC support
>    hw/sd/sdcard: Register generic command handlers
>    hw/sd/sdcard: Register unimplemented command handlers
>    hw/sd/sdcard: Add mmc_cmd_PROGRAM_CID handler (CMD26)
>    hw/sd/sdcard: Add experimental 'x-aspeed-emmc-kludge' property
> 
> Sai Pavan Boddu (3):
>    hw/sd/sdcard: Add emmc_cmd_SEND_OP_COND handler (CMD1)
>    hw/sd/sdcard: add emmc_cmd_SEND_TUNING_BLOCK handler (CMD21)
>    hw/sd/sdcard: Add mmc SWITCH function support (CMD6)
> 
> Vincent Palatin (1):
>    hw/sd/sdcard: Add emmc_cmd_SEND_EXT_CSD handler (CMD8)
> 
>   docs/about/deprecated.rst        |    6 +
>   hw/sd/sdmmc-internal.h           |  118 +-
>   include/hw/sd/sd.h               |   10 +-
>   hw/sd/sd.c                       | 1917 +++++++++++++++++++-----------
>   hw/sd/sdmmc-internal.c           |   72 --
>   tests/qtest/npcm7xx_sdhci-test.c |    7 +
>   hw/sd/meson.build                |    2 +-
>   hw/sd/trace-events               |    6 +-
>   8 files changed, 1362 insertions(+), 776 deletions(-)
>   delete mode 100644 hw/sd/sdmmc-internal.c
>