sdhci: Add i.MX specific subtype of SDHCI
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 7/8 sdhci: Add i.MX specific subtype of SDHCI
From: Andrey Smirnov <[email protected]>
IP block found on several generations of i.MX family does not use vanilla SDHCI implementation and it comes with a number of quirks.
Introduce i.MX SDHCI subtype of SDHCI block to add code necessary to support unmodified Linux guest driver.
Cc Peter Maydell <[email protected]>
Cc Jason Wang <[email protected]>
Cc Philippe Mathieu-Daudé <[email protected]>
Cc Marcel Apfelbaum <[email protected]>
Cc Michael S. Tsirkin <[email protected]>
Reviewed-by Peter Maydell <[email protected]>
Signed-off-by Andrey Smirnov <[email protected]>
Reviewed-by Philippe Mathieu-Daudé <[email protected]>
[PMM: define and use ESDHC_UNDOCUMENTED_REG27]
Signed-off-by Peter Maydell <[email protected]>
Signed-off-by Philippe Mathieu-Daudé <[email protected]>
--- hw/sd/sdhci-internal.h | 22 +++++ hw/sd/sdhci.c | 230 ++++++++++++++++++++++++++++++++++++++++++++++++- include/hw/sd/sdhci.h | 13 +++ 3 files changed, 264 insertions(+), 1 deletion(-)
hw/sd/sdhci-internal.h +22 -0
@@ -89,6 +89,7 @@ FIELD(SDHC_PRNSTS, CMD_LVL, 24, 1);/* R/W Host control Register 0x0 */ #define SDHC_HOSTCTL 0x28 +#define SDHC_CTRL_LED 0x01#define SDHC_CTRL_DATATRANSFERWIDTH 0x02/* SD mode only */ #define SDHC_CTRL_HIGH_SPEED 0x04#define SDHC_CTRL_DMA_CHECK_MASK 0x18
@@ -97,6 +98,10 @@ FIELD(SDHC_PRNSTS, CMD_LVL, 24, 1);#define SDHC_CTRL_ADMA2_32 0x10#define SDHC_CTRL_ADMA2_64 0x18#define SDHC_DMA_TYPE (x) ((x) & SDHC_CTRL_DMA_CHECK_MASK) +#define SDHC_CTRL_4BITBUS 0x02 +#define SDHC_CTRL_8BITBUS 0x20 +#define SDHC_CTRL_CDTEST_INS 0x40 +#define SDHC_CTRL_CDTEST_EN 0x80/* R/W Power Control Register 0x0 */ #define SDHC_PWRCON 0x29
@@ -280,4 +285,21 @@ enum { sdhc_gap_write =2 /* SDHC stopped at block gap during write operation */ }; +extern const VMStateDescription sdhci_vmstate; + + +#define ESDHC_MIX_CTRL 0x48 +#define ESDHC_VENDOR_SPEC 0xc0 +#define ESDHC_DLL_CTRL 0x60 + +#define ESDHC_TUNING_CTRL 0xcc +#define ESDHC_TUNE_CTRL_STATUS 0x68 +#define ESDHC_WTMK_LVL 0x44 + +/* Undocumented register used by guests working around erratum ERR004536 */ +#define ESDHC_UNDOCUMENTED_REG27 0x6c + +#define ESDHC_CTRL_4BITBUS (0x1 << 1) +#define ESDHC_CTRL_8BITBUS (0x2 << 1) +#endif
hw/sd/sdhci.c +229 -1
259 lines not on this page · raw message
include/hw/sd/sdhci.h +13 -0
@@ -44,6 +44,7 @@ typedef struct SDHCIState {AddressSpace sysbus_dma_as;AddressSpace *dma_as;MemoryRegion *dma_mr; +const MemoryRegionOps *io_ops;QEMUTimer *insert_timer;/* timer for 'changing' sd card. */ QEMUTimer *transfer_timer;
@@ -93,10 +94,20 @@ typedef struct SDHCIState {/* Configurable properties */ bool pending_insert_quirk;/* Quirk for Raspberry Pi card insert int */ +uint32_t quirks;uint8_t sd_spec_version;uint8_t uhs_mode; } SDHCIState; +/* +* Controller does not provide transfer-complete interrupt when not +* busy. +* +* NOTE: This definition is taken out of Linux kernel and so the +* original bit number is preserved +*/ +#define SDHCI_QUIRK_NO_BUSY_IRQ BIT(14) +#define TYPE_PCI_SDHCI "sdhci-pci"#define PCI_SDHCI (obj) OBJECT_CHECK(SDHCIState, (obj), TYPE_PCI_SDHCI)
@@ -104,4 +115,6 @@ typedef struct SDHCIState {#define SYSBUS_SDHCI (obj) \ OBJECT_CHECK(SDHCIState, (obj), TYPE_SYSBUS_SDHCI) +#define TYPE_IMX_USDHC "imx-usdhc" +#endif /* SDHCI_H */
Signature · 1 line
2.7.4