Freescale SDHCI Fixes
cover Freescale SDHCI Fixes
This series splits TYPE_IMX_USDHC into three device models which fixes issues in the ppce500 and some i.MX machines. In particular, it introduces uSDHC's predecessor eSDHC in big and little endian variants. Once the eSDHCs are split off, uSDHC emulation is improved which is a stepping stone towards running u-boot on the i.MX8MP (not implemented yet).
In a way this series picks up previous efforts:
* https://lore.kernel.org/qemu-devel/[email protected]
* https://lore.kernel.org/qemu-devel/[email protected]
There is quite some code churn involved to fix all the issues addressed in this series. Let me know if you have any better ideas to achieve the same.
Best regards,
Bernhard
Testing done:
* make check
* Boot https://www.qemu-advent-calendar.org/2018/download/day19.tar.xz in ppce500
* Boot guest in imx8mp-evk
Bernhard Beschow (14):
hw/sd/sdhci: Fix TYPE_IMX_USDHC to implement sd-spec-version 3 by
default
hw/arm/fsl-imx6: Remove now redundant setting of "sd-spec-version"
property
hw/arm/fsl-imx6: Fix naming of SDHCI related constants and attributes hw/arm/fsl-imx25: Apply missing reset quirk
Revert "hw/sd/sdhci: Rename ESDHC_* defines to USDHC_*" hw/sd/sdhci: Consolidate eSDHC constants
hw/sd/sdhci: Rename usdhc_ functions
hw/sd/sdhci: Add TYPE_FSL_ESDHC_BE
hw/ppc/e500: Use TYPE_FSL_ESDHC_BE
hw/arm/fsl-imx25: Extract TYPE_FSL_ESDHC_LE
hw/sd/sdhci: Remove endianness property
hw/sd/sdhci: Add uSDHC-specific quirk
hw/sd/sdhci: Remove vendor property
hw/sd/trace-events: Remove redundant "SWITCH " command name
hw/sd/sdhci-internal.h | 3 - include/hw/arm/fsl-imx6.h | 4 +- include/hw/sd/sdhci.h | 8 +- hw/arm/fsl-imx25.c | 5 +- hw/arm/fsl-imx6.c | 18 ++-- hw/ppc/e500.c | 10 +- hw/sd/sdhci.c | 201 ++++++++++++++++++++++++-------------- hw/sd/trace-events | 2 +- 8 files changed, 146 insertions(+), 105 deletions(-)
Signature · 1 line
2.52.0
PATCH 1/14 hw/sd/sdhci: Fix TYPE_IMX_USDHC to implement sd-spec-version 3 by default
Fixes TYPE_FSL_IMX6UL, TYPE_FSL_IMX7, and TYPE_FSL_IMX8MP to implement version 3 of the SD specification.
Note that TYPE_FSL_IMX6 already had "sd-spec-version" set accordingly and that TYPE_FSL_IMX25 correctly sets the same property to version 2 since the real hardware is an eSDHC which is the uSDHC's predecessor.
--- hw/sd/sdhci.c | 2 ++ 1 file changed, 2 insertions(+)
hw/sd/sdhci.c +2 -0
@@ -1884,9 +1884,11 @@ static const MemoryRegionOps usdhc_mmio_ops = {static void imx_usdhc_init (Object *obj) {SDHCIState *s =SYSBUS_SDHCI (obj); +DeviceState *dev =DEVICE (obj); s->io_ops = &usdhc_mmio_ops; s->quirks =SDHCI_QUIRK_NO_BUSY_IRQ ; +qdev_prop_set_uint8 (dev,"sd-spec-version" ,3 ); }/* --- qdev Samsung s3c --- */
Signature · 1 line
2.52.0
PATCH 2/14 hw/arm/fsl-imx6: Remove now redundant setting of "sd-spec-version" property
In reply to Bernhard BeschowNow that TYPE_IMX_USDHC sets this property internally it is not needed on the SoC level any longer.
--- hw/arm/fsl-imx6.c | 2 -- 1 file changed, 2 deletions(-)
hw/arm/fsl-imx6.c +0 -2
@@ -323,8 +323,6 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp) };/* UHS-I SDIO3.0 SDR104 1.8V ADMA */ -object_property_set_uint (OBJECT (&s->esdhc[i]),"sd-spec-version" ,3 , - &error_abort);object_property_set_uint (OBJECT (&s->esdhc[i]),"capareg" ,IMX6_ESDHC_CAPABILITIES , &error_abort);if (!sysbus_realize (SYS_BUS_DEVICE (&s->esdhc[i]), errp)) {
Signature · 1 line
2.52.0
PATCH 3/14 hw/arm/fsl-imx6: Fix naming of SDHCI related constants and attributes
In reply to Bernhard BeschowThe i.MX 6 SoC features uSDHC controllers which are the successors of eSDHC. Fix the naming to make this clear.
--- include/hw/arm/fsl-imx6.h | 4 ++-- hw/arm/fsl-imx6.c | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-)
include/hw/arm/fsl-imx6.h +2 -2
@@ -46,7 +46,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(FslIMX6State, FSL_IMX6)#define FSL_IMX6_NUM_EPITS 2#define FSL_IMX6_NUM_I2CS 3#define FSL_IMX6_NUM_GPIOS 7 -#define FSL_IMX6_NUM_ESDHCS 4 +#define FSL_IMX6_NUM_USDHCS 4#define FSL_IMX6_NUM_ECSPIS 5#define FSL_IMX6_NUM_WDTS 2#define FSL_IMX6_NUM_USB_PHYS 2
@@ -67,7 +67,7 @@ struct FslIMX6State {IMXEPITState epit[FSL_IMX6_NUM_EPITS ];IMXI2CState i2c[FSL_IMX6_NUM_I2CS ];IMXGPIOState gpio[FSL_IMX6_NUM_GPIOS ]; -SDHCIState esdhc[FSL_IMX6_NUM_ESDHCS ]; +SDHCIState usdhc[FSL_IMX6_NUM_USDHCS ];IMXSPIState spi[FSL_IMX6_NUM_ECSPIS ];IMX2WdtState wdt[FSL_IMX6_NUM_WDTS ];IMXUSBPHYState usbphy[FSL_IMX6_NUM_USB_PHYS ];
hw/arm/fsl-imx6.c +8 -8
@@ -79,9 +79,9 @@ static void fsl_imx6_init(Object *obj)object_initialize_child (obj, name, &s->gpio[i],TYPE_IMX_GPIO ); } -for (i =0 ; i <FSL_IMX6_NUM_ESDHCS ; i++) { +for (i =0 ; i <FSL_IMX6_NUM_USDHCS ; i++) {snprintf (name,NAME_SIZE ,"sdhc%d" , i +1 ); -object_initialize_child (obj, name, &s->esdhc[i],TYPE_IMX_USDHC ); +object_initialize_child (obj, name, &s->usdhc[i],TYPE_IMX_USDHC ); }for (i =0 ; i <FSL_IMX6_NUM_USB_PHYS ; i++) {
@@ -311,11 +311,11 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp) }/* Initialize all SDHC */ -for (i =0 ; i <FSL_IMX6_NUM_ESDHCS ; i++) { +for (i =0 ; i <FSL_IMX6_NUM_USDHCS ; i++) {static const struct {hwaddr addr;unsigned int irq; - } esdhc_table[FSL_IMX6_NUM_ESDHCS ] = { + } esdhc_table[FSL_IMX6_NUM_USDHCS ] = { { FSL_IMX6_uSDHC1_ADDR, FSL_IMX6_uSDHC1_IRQ }, { FSL_IMX6_uSDHC2_ADDR, FSL_IMX6_uSDHC2_IRQ }, { FSL_IMX6_uSDHC3_ADDR, FSL_IMX6_uSDHC3_IRQ },
@@ -323,13 +323,13 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp) };/* UHS-I SDIO3.0 SDR104 1.8V ADMA */ -object_property_set_uint (OBJECT (&s->esdhc[i]),"capareg" , +object_property_set_uint (OBJECT (&s->usdhc[i]),"capareg" ,IMX6_ESDHC_CAPABILITIES , &error_abort); -if (!sysbus_realize (SYS_BUS_DEVICE (&s->esdhc[i]), errp)) { +if (!sysbus_realize (SYS_BUS_DEVICE (&s->usdhc[i]), errp)) {return ; } -sysbus_mmio_map (SYS_BUS_DEVICE (&s->esdhc[i]),0 , esdhc_table[i].addr); -sysbus_connect_irq (SYS_BUS_DEVICE (&s->esdhc[i]),0 , +sysbus_mmio_map (SYS_BUS_DEVICE (&s->usdhc[i]),0 , esdhc_table[i].addr); +sysbus_connect_irq (SYS_BUS_DEVICE (&s->usdhc[i]),0 ,qdev_get_gpio_in (gic, esdhc_table[i].irq)); }
Signature · 1 line
2.52.0
PATCH 4/14 hw/arm/fsl-imx25: Apply missing reset quirk
In reply to Bernhard BeschowJust like the Freescale MPC8569E SoC the i.MX25 features an eSDHC but as little-endian variant. According to the datasheet TYPE_FSL_IMX25 requires the same reset quirk as the e500 machines. The quirk was introduced in d060b2789f71 ("hw/sd/sdhci: Set reset value of interrupt registers") for the e500 machines, so reuse it now in TYPE_FSL_IMX25.
--- hw/arm/fsl-imx25.c | 2 ++ 1 file changed, 2 insertions(+)
hw/arm/fsl-imx25.c +2 -0
@@ -243,6 +243,8 @@ static void fsl_imx25_realize(DeviceState *dev, Error **errp) &error_abort);object_property_set_uint (OBJECT (&s->esdhc[i]),"capareg" ,IMX25_ESDHC_CAPABILITIES , &error_abort); +object_property_set_uint (OBJECT (&s->esdhc[i]),"vendor" , +SDHCI_VENDOR_FSL , &error_abort);if (!sysbus_realize (SYS_BUS_DEVICE (&s->esdhc[i]), errp)) {return ; }
Signature · 1 line
2.52.0
PATCH 5/14 Revert "hw/sd/sdhci: Rename ESDHC_* defines to USDHC_*"
In reply to Bernhard BeschowThis reverts commit 1e76667f7adf48c6c3596aaa26b8886b57b8498d.
Unaware that the constants were named after Linux and U-Boot code, commit 1e76667f7adf ("hw/sd/sdhci: Rename ESDHC_* defines to USDHC_*") changed the naming to be consistent with the function names. Fix the constant naming to be consistent with Linux and U-Boot again. In the next step, the function names will be renamed according to Linux and U-Boot code as well.
--- hw/sd/sdhci.c | 66 +++++++++++++++++++++++++-------------------------- 1 file changed, 33 insertions(+), 33 deletions(-)
hw/sd/sdhci.c +33 -33
@@ -1639,24 +1639,24 @@ static void sdhci_bus_class_init(ObjectClass *klass, const void *data)/* --- qdev i.MX eSDHC --- */ -#define USDHC_MIX_CTRL 0x48 +#define ESDHC_MIX_CTRL 0x48 -#define USDHC_VENDOR_SPEC 0xc0 -#define USDHC_IMX_FRC_SDCLK_ON (1 << 8) +#define ESDHC_VENDOR_SPEC 0xc0 +#define ESDHC_IMX_FRC_SDCLK_ON (1 << 8) -#define USDHC_DLL_CTRL 0x60 +#define ESDHC_DLL_CTRL 0x60 -#define USDHC_TUNING_CTRL 0xcc -#define USDHC_TUNE_CTRL_STATUS 0x68 -#define USDHC_WTMK_LVL 0x44 +#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 USDHC_UNDOCUMENTED_REG27 0x6c +#define ESDHC_UNDOCUMENTED_REG27 0x6c -#define USDHC_CTRL_4BITBUS (0x1 << 1) -#define USDHC_CTRL_8BITBUS (0x2 << 1) +#define ESDHC_CTRL_4BITBUS (0x1 << 1) +#define ESDHC_CTRL_8BITBUS (0x2 << 1) -#define USDHC_PRNSTS_SDSTB (1 << 3) +#define ESDHC_PRNSTS_SDSTB (1 << 3)static uint64_t usdhc_read (void *opaque,hwaddr offset,unsigned size) {
@@ -1677,11 +1677,11 @@ static uint64_t usdhc_read(void *opaque, hwaddr offset, unsigned size) hostctl1 =SDHC_DMA_TYPE (s->hostctl1) << (8 -3 );if (s->hostctl1 &SDHC_CTRL_8BITBUS ) { - hostctl1 |=USDHC_CTRL_8BITBUS ; + hostctl1 |=ESDHC_CTRL_8BITBUS ; }if (s->hostctl1 &SDHC_CTRL_4BITBUS ) { - hostctl1 |=USDHC_CTRL_4BITBUS ; + hostctl1 |=ESDHC_CTRL_4BITBUS ; } ret = hostctl1;
@@ -1692,21 +1692,21 @@ static uint64_t usdhc_read(void *opaque, hwaddr offset, unsigned size)case SDHC_PRNSTS :/* Add SDSTB (SD Clock Stable) bit to PRNSTS */ - ret =sdhci_read (opaque, offset, size) & ~USDHC_PRNSTS_SDSTB ; + ret =sdhci_read (opaque, offset, size) & ~ESDHC_PRNSTS_SDSTB ;if (s->clkcon &SDHC_CLOCK_INT_STABLE ) { - ret |=USDHC_PRNSTS_SDSTB ; + ret |=ESDHC_PRNSTS_SDSTB ; }break ; -case USDHC_VENDOR_SPEC : +case ESDHC_VENDOR_SPEC : ret = s->vendor_spec;break ; -case USDHC_DLL_CTRL : -case USDHC_TUNE_CTRL_STATUS : -case USDHC_UNDOCUMENTED_REG27 : -case USDHC_TUNING_CTRL : -case USDHC_MIX_CTRL : -case USDHC_WTMK_LVL : +case ESDHC_DLL_CTRL : +case ESDHC_TUNE_CTRL_STATUS : +case ESDHC_UNDOCUMENTED_REG27 : +case ESDHC_TUNING_CTRL : +case ESDHC_MIX_CTRL : +case ESDHC_WTMK_LVL : ret =0 ;break ; }
@@ -1722,16 +1722,16 @@ usdhc_write(void *opaque, hwaddr offset, uint64_t val, unsigned size)uint32_t value = (uint32_t )val;switch (offset) { -case USDHC_DLL_CTRL : -case USDHC_TUNE_CTRL_STATUS : -case USDHC_UNDOCUMENTED_REG27 : -case USDHC_TUNING_CTRL : -case USDHC_WTMK_LVL : +case ESDHC_DLL_CTRL : +case ESDHC_TUNE_CTRL_STATUS : +case ESDHC_UNDOCUMENTED_REG27 : +case ESDHC_TUNING_CTRL : +case ESDHC_WTMK_LVL :break ; -case USDHC_VENDOR_SPEC : +case ESDHC_VENDOR_SPEC : s->vendor_spec = value; -if (value &USDHC_IMX_FRC_SDCLK_ON ) { +if (value &ESDHC_IMX_FRC_SDCLK_ON ) { s->prnsts &= ~SDHC_IMX_CLOCK_GATE_OFF ; }else { s->prnsts |=SDHC_IMX_CLOCK_GATE_OFF ;
@@ -1796,12 +1796,12 @@ usdhc_write(void *opaque, hwaddr offset, uint64_t val, unsigned size)* Second, split "Data Transfer Width" from bits 2 and 1 in to * bits 5 and 1 */ -if (value &USDHC_CTRL_8BITBUS ) { +if (value &ESDHC_CTRL_8BITBUS ) { hostctl1 |=SDHC_CTRL_8BITBUS ; } -if (value &USDHC_CTRL_4BITBUS ) { - hostctl1 |=USDHC_CTRL_4BITBUS ; +if (value &ESDHC_CTRL_4BITBUS ) { + hostctl1 |=ESDHC_CTRL_4BITBUS ; }/*
@@ -1824,7 +1824,7 @@ usdhc_write(void *opaque, hwaddr offset, uint64_t val, unsigned size)sdhci_write (opaque, offset, value, size);break ; -case USDHC_MIX_CTRL : +case ESDHC_MIX_CTRL :/* * So, when SD/MMC stack in Linux tries to write to "Transfer * Mode Register", ESDHC i.MX quirk code will translate it
Signature · 1 line
2.52.0
PATCH 6/14 hw/sd/sdhci: Consolidate eSDHC constants
In reply to Bernhard BeschowDrop the "IMX_" part of the names since these are actually {E,U}SDHC specific and apply for PowerPC-based SoCs as well. While at it consolidate all ESDHC constants into the ESDHC section.
--- hw/sd/sdhci-internal.h | 1 - hw/sd/sdhci.c | 9 +++++---- 2 files changed, 5 insertions(+), 5 deletions(-)
hw/sd/sdhci-internal.h +0 -1
@@ -75,7 +75,6 @@#define SDHC_CMD_INHIBIT 0x00000001#define SDHC_DATA_INHIBIT 0x00000002#define SDHC_DAT_LINE_ACTIVE 0x00000004 -#define SDHC_IMX_CLOCK_GATE_OFF 0x00000080#define SDHC_DOING_WRITE 0x00000100#define SDHC_DOING_READ 0x00000200#define SDHC_SPACE_AVAILABLE 0x00000400
hw/sd/sdhci.c +5 -4
@@ -1642,7 +1642,7 @@ static void sdhci_bus_class_init(ObjectClass *klass, const void *data)#define ESDHC_MIX_CTRL 0x48#define ESDHC_VENDOR_SPEC 0xc0 -#define ESDHC_IMX_FRC_SDCLK_ON (1 << 8) +#define ESDHC_FRC_SDCLK_ON (1 << 8)#define ESDHC_DLL_CTRL 0x60
@@ -1657,6 +1657,7 @@ static void sdhci_bus_class_init(ObjectClass *klass, const void *data)#define ESDHC_CTRL_8BITBUS (0x2 << 1)#define ESDHC_PRNSTS_SDSTB (1 << 3) +#define ESDHC_PRNSTS_CLOCK_GATE_OFF BIT(7)static uint64_t usdhc_read (void *opaque,hwaddr offset,unsigned size) {
@@ -1731,10 +1732,10 @@ usdhc_write(void *opaque, hwaddr offset, uint64_t val, unsigned size)case ESDHC_VENDOR_SPEC : s->vendor_spec = value; -if (value &ESDHC_IMX_FRC_SDCLK_ON ) { - s->prnsts &= ~SDHC_IMX_CLOCK_GATE_OFF ; +if (value &ESDHC_FRC_SDCLK_ON ) { + s->prnsts &= ~ESDHC_PRNSTS_CLOCK_GATE_OFF ; }else { - s->prnsts |=SDHC_IMX_CLOCK_GATE_OFF ; + s->prnsts |=ESDHC_PRNSTS_CLOCK_GATE_OFF ; }break ;
Signature · 1 line
2.52.0
PATCH 7/14 hw/sd/sdhci: Rename usdhc_ functions
In reply to Bernhard BeschowThe next patches will introduce eSDHC device models (big and little endian). Prepare for that by renaming the functions. Also, this makes the code have similar conventions as in Linux and U-Boot.
--- hw/sd/sdhci.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
hw/sd/sdhci.c +5 -5
@@ -1659,7 +1659,7 @@ static void sdhci_bus_class_init(ObjectClass *klass, const void *data)#define ESDHC_PRNSTS_SDSTB (1 << 3)#define ESDHC_PRNSTS_CLOCK_GATE_OFF BIT(7) -static uint64_t usdhc_read (void *opaque,hwaddr offset,unsigned size) +static uint64_t esdhc_read (void *opaque,hwaddr offset,unsigned size) {SDHCIState *s =SYSBUS_SDHCI (opaque);uint32_t ret;
@@ -1673,7 +1673,7 @@ static uint64_t usdhc_read(void *opaque, hwaddr offset, unsigned size)/* * For a detailed explanation on the following bit * manipulation code see comments in a similar part of -* usdhc_write() +* esdhc_write() */ hostctl1 =SDHC_DMA_TYPE (s->hostctl1) << (8 -3 );
@@ -1716,7 +1716,7 @@ static uint64_t usdhc_read(void *opaque, hwaddr offset, unsigned size) }static void -usdhc_write (void *opaque,hwaddr offset,uint64_t val,unsigned size) +esdhc_write (void *opaque,hwaddr offset,uint64_t val,unsigned size) {SDHCIState *s =SYSBUS_SDHCI (opaque);uint8_t hostctl1;
@@ -1872,8 +1872,8 @@ usdhc_write(void *opaque, hwaddr offset, uint64_t val, unsigned size) }static const MemoryRegionOps usdhc_mmio_ops = { - .read = usdhc_read, - .write = usdhc_write, + .read = esdhc_read, + .write = esdhc_write, .valid = { .min_access_size =1 , .max_access_size =4 ,
Signature · 1 line
2.52.0
PATCH 8/14 hw/sd/sdhci: Add TYPE_FSL_ESDHC_BE
In reply to Bernhard BeschowFor now, TYPE_FSL_ESDHC_BE is basically a big-endian variant of TYPE_IMX_USDHC. It will be used in the e500 machines in the next step which prevents Linux to flood the console with "mmc0: Internal clock never stabilised" messages.
--- include/hw/sd/sdhci.h | 2 ++ hw/sd/sdhci.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+)
include/hw/sd/sdhci.h +2 -0
@@ -128,6 +128,8 @@ DECLARE_INSTANCE_CHECKER(SDHCIState, PCI_SDHCI,DECLARE_INSTANCE_CHECKER (SDHCIState,SYSBUS_SDHCI , TYPE_SYSBUS_SDHCI) +#define TYPE_FSL_ESDHC_BE "fsl-esdhc-be" +#define TYPE_IMX_USDHC "imx-usdhc"#define TYPE_S3C_SDHCI "s3c-sdhci"
hw/sd/sdhci.c +31 -0
@@ -1871,6 +1871,32 @@ esdhc_write(void *opaque, hwaddr offset, uint64_t val, unsigned size) } } +static const MemoryRegionOps esdhc_mmio_be_ops = { + .read = esdhc_read, + .write = esdhc_write, + .impl = { + .min_access_size =4 , + .max_access_size =4 , + }, + .valid = { + .min_access_size =1 , + .max_access_size =4 , + .unaligned = false + }, + .endianness =DEVICE_BIG_ENDIAN , +}; + +static void fsl_esdhc_be_init (Object *obj) +{ +SDHCIState *s =SYSBUS_SDHCI (obj); +DeviceState *dev =DEVICE (obj); + + s->io_ops = &esdhc_mmio_be_ops; + s->quirks =SDHCI_QUIRK_NO_BUSY_IRQ ; +qdev_prop_set_uint8 (dev,"sd-spec-version" ,2 ); +qdev_prop_set_uint8 (dev,"vendor" ,SDHCI_VENDOR_FSL ); +} +static const MemoryRegionOps usdhc_mmio_ops = { .read = esdhc_read, .write = esdhc_write,
@@ -1965,6 +1991,11 @@ static const TypeInfo sdhci_types[] = { .instance_finalize = sdhci_sysbus_finalize, .class_init = sdhci_sysbus_class_init, }, + { + .name = TYPE_FSL_ESDHC_BE, + .parent = TYPE_SYSBUS_SDHCI, + .instance_init = fsl_esdhc_be_init, + }, { .name = TYPE_IMX_USDHC, .parent = TYPE_SYSBUS_SDHCI,
Signature · 1 line
2.52.0
PATCH 9/14 hw/ppc/e500: Use TYPE_FSL_ESDHC_BE
In reply to Bernhard BeschowTYPE_FSL_ESDHC_BE maches real hardware more closely by reusing code of TYPE_IMX_USDHC. For example, it fixes Linux to flood the guest console with "mmc0: Internal clock never stabilised" messages in the QEMU advent calendar 2018 day 19 image.
--- hw/ppc/e500.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)
hw/ppc/e500.c +1 -9
@@ -1036,15 +1036,7 @@ void ppce500_init(MachineState *machine)memory_region_add_subregion (ccsr_addr_space,MPC85XX_ESDHC_REGS_OFFSET ,sysbus_mmio_get_region (s,0 )); -/* -* Compatible with: -* - SD Host Controller Specification Version 2.0 Part A2 -* (See MPC8569E Reference Manual) -*/ - dev =qdev_new (TYPE_SYSBUS_SDHCI ); -qdev_prop_set_uint8 (dev,"sd-spec-version" ,2 ); -qdev_prop_set_uint8 (dev,"endianness" ,DEVICE_BIG_ENDIAN ); -qdev_prop_set_uint8 (dev,"vendor" ,SDHCI_VENDOR_FSL ); + dev =qdev_new (TYPE_FSL_ESDHC_BE ); s =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (s, &error_fatal);sysbus_connect_irq (s,0 ,qdev_get_gpio_in (mpicdev,MPC85XX_ESDHC_IRQ ));
Signature · 1 line
2.52.0
PATCH 10/14 hw/arm/fsl-imx25: Extract TYPE_FSL_ESDHC_LE
In reply to Bernhard BeschowExtract an eSDHC (little endian) device model since the uSDHC device model will get an uSDHC-specific MMIO quirk.
--- include/hw/sd/sdhci.h | 1 + hw/arm/fsl-imx25.c | 7 ++----- hw/sd/sdhci.c | 31 +++++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 5 deletions(-)
include/hw/sd/sdhci.h +1 -0
@@ -129,6 +129,7 @@ DECLARE_INSTANCE_CHECKER(SDHCIState, SYSBUS_SDHCI, TYPE_SYSBUS_SDHCI)#define TYPE_FSL_ESDHC_BE "fsl-esdhc-be" +#define TYPE_FSL_ESDHC_LE "fsl-esdhc-le"#define TYPE_IMX_USDHC "imx-usdhc"
hw/arm/fsl-imx25.c +2 -5
@@ -68,7 +68,8 @@ static void fsl_imx25_init(Object *obj) }for (i =0 ; i <FSL_IMX25_NUM_ESDHCS ; i++) { -object_initialize_child (obj,"sdhc[*]" , &s->esdhc[i],TYPE_IMX_USDHC ); +object_initialize_child (obj,"sdhc[*]" , &s->esdhc[i], +TYPE_FSL_ESDHC_LE ); }for (i =0 ; i <FSL_IMX25_NUM_USBS ; i++) {
@@ -239,12 +240,8 @@ static void fsl_imx25_realize(DeviceState *dev, Error **errp) { FSL_IMX25_ESDHC2_ADDR, FSL_IMX25_ESDHC2_IRQ }, }; -object_property_set_uint (OBJECT (&s->esdhc[i]),"sd-spec-version" ,2 , - &error_abort);object_property_set_uint (OBJECT (&s->esdhc[i]),"capareg" ,IMX25_ESDHC_CAPABILITIES , &error_abort); -object_property_set_uint (OBJECT (&s->esdhc[i]),"vendor" , -SDHCI_VENDOR_FSL , &error_abort);if (!sysbus_realize (SYS_BUS_DEVICE (&s->esdhc[i]), errp)) {return ; }
hw/sd/sdhci.c +31 -0
@@ -1897,6 +1897,32 @@ static void fsl_esdhc_be_init(Object *obj)qdev_prop_set_uint8 (dev,"vendor" ,SDHCI_VENDOR_FSL ); } +static const MemoryRegionOps esdhc_mmio_le_ops = { + .read = esdhc_read, + .write = esdhc_write, + .impl = { + .min_access_size =4 , + .max_access_size =4 , + }, + .valid = { + .min_access_size =1 , + .max_access_size =4 , + .unaligned = false + }, + .endianness =DEVICE_LITTLE_ENDIAN , +}; + +static void fsl_esdhc_le_init (Object *obj) +{ +SDHCIState *s =SYSBUS_SDHCI (obj); +DeviceState *dev =DEVICE (obj); + + s->io_ops = &esdhc_mmio_le_ops; + s->quirks =SDHCI_QUIRK_NO_BUSY_IRQ ; +qdev_prop_set_uint8 (dev,"sd-spec-version" ,2 ); +qdev_prop_set_uint8 (dev,"vendor" ,SDHCI_VENDOR_FSL ); +} +static const MemoryRegionOps usdhc_mmio_ops = { .read = esdhc_read, .write = esdhc_write,
@@ -1996,6 +2022,11 @@ static const TypeInfo sdhci_types[] = { .parent = TYPE_SYSBUS_SDHCI, .instance_init = fsl_esdhc_be_init, }, + { + .name = TYPE_FSL_ESDHC_LE, + .parent = TYPE_SYSBUS_SDHCI, + .instance_init = fsl_esdhc_le_init, + }, { .name = TYPE_IMX_USDHC, .parent = TYPE_SYSBUS_SDHCI,
Signature · 1 line
2.52.0
PATCH 11/14 hw/sd/sdhci: Remove endianness property
In reply to Bernhard BeschowThe endianness property was only explicitly set in the e500 machine which now instantiates TYPE_FSL_ESDHC_BE. The property could also not be used meaningfully in a hypothetical, common TYPE_FSL_ESDHC device model since sdhci_common_realize() would fail in that case or it would need to know all MMIO implementations upfront. Remove the property in favor of dedicated device models.
--- hw/sd/sdhci-internal.h | 1 - include/hw/sd/sdhci.h | 1 - hw/sd/sdhci.c | 35 ++--------------------------------- 3 files changed, 2 insertions(+), 35 deletions(-)
hw/sd/sdhci-internal.h +0 -1
@@ -307,7 +307,6 @@ extern const VMStateDescription sdhci_vmstate;#define SDHC_CAPAB_REG_DEFAULT 0x057834b4#define DEFINE_SDHCI_COMMON_PROPERTIES (_state) \ - DEFINE_PROP_UINT8("endianness", _state, endianness, DEVICE_LITTLE_ENDIAN), \ DEFINE_PROP_UINT8("sd-spec-version", _state, sd_spec_version, 2), \ DEFINE_PROP_UINT8("uhs", _state, uhs_mode, UHS_NOT_SUPPORTED), \ DEFINE_PROP_UINT8("vendor", _state, vendor, SDHCI_VENDOR_NONE), \
include/hw/sd/sdhci.h +0 -1
@@ -96,7 +96,6 @@ struct SDHCIState {/* Configurable properties */ bool pending_insert_quirk;/* Quirk for Raspberry Pi card insert int */ uint32_t quirks; -uint8_t endianness;uint8_t sd_spec_version;uint8_t uhs_mode;uint8_t vendor;/* For vendor specific functionality */
hw/sd/sdhci.c +2 -33
@@ -1374,7 +1374,7 @@ sdhci_write(void *opaque, hwaddr offset, uint64_t val, unsigned size) value >> shift, value >> shift); } -static const MemoryRegionOps sdhci_mmio_le_ops = { +static const MemoryRegionOps sdhci_mmio_ops = { .read = sdhci_read, .write = sdhci_write, .valid = {
@@ -1385,21 +1385,6 @@ static const MemoryRegionOps sdhci_mmio_le_ops = { .endianness = DEVICE_LITTLE_ENDIAN, }; -static const MemoryRegionOps sdhci_mmio_be_ops = { - .read = sdhci_read, - .write = sdhci_write, - .impl = { - .min_access_size =4 , - .max_access_size =4 , - }, - .valid = { - .min_access_size =1 , - .max_access_size =4 , - .unaligned = false - }, - .endianness =DEVICE_BIG_ENDIAN , -}; -static void sdhci_init_readonly_registers (SDHCIState *s,Error **errp) {ERRP_GUARD ();
@@ -1430,7 +1415,7 @@ void sdhci_initfn(SDHCIState *s) s->transfer_timer =timer_new_ns (QEMU_CLOCK_VIRTUAL , sdhci_data_transfer, s); - s->io_ops = &sdhci_mmio_le_ops; + s->io_ops = &sdhci_mmio_ops; }void sdhci_uninitfn (SDHCIState *s)
@@ -1446,22 +1431,6 @@ void sdhci_common_realize(SDHCIState *s, Error **errp) {ERRP_GUARD (); -switch (s->endianness) { -case DEVICE_LITTLE_ENDIAN : -/* s->io_ops is little endian by default */ -break ; -case DEVICE_BIG_ENDIAN : -if (s->io_ops != &sdhci_mmio_le_ops) { -error_setg (errp,"SD controller doesn't support big endianness" ); -return ; - } - s->io_ops = &sdhci_mmio_be_ops; -break ; -default : -error_setg (errp,"Incorrect endianness" ); -return ; - } -sdhci_init_readonly_registers (s, errp);if (*errp) {return ;
Signature · 1 line
2.52.0
PATCH 12/14 hw/sd/sdhci: Add uSDHC-specific quirk
In reply to Bernhard BeschowThis quirk is required for imx8mp-evk to boot via u-boot successfully.
--- hw/sd/sdhci.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-)
hw/sd/sdhci.c +26 -2
@@ -1892,9 +1892,33 @@ static void fsl_esdhc_le_init(Object *obj)qdev_prop_set_uint8 (dev,"vendor" ,SDHCI_VENDOR_FSL ); } +static uint64_t usdhc_read (void *opaque,hwaddr offset,unsigned size) +{ +if (offset ==SDHC_CLKCON ) { +/* we force the reset value of the lower nibble since QEMU alters it */ +return esdhc_read (opaque, offset, size) |0xf ; + } + +return esdhc_read (opaque, offset, size); +} + +static void usdhc_write (void *opaque,hwaddr offset,uint64_t val, +unsigned size) +{ +if (offset ==SDHC_CLKCON ) { +if ((val &0xf ) !=1 ) { +qemu_log_mask (LOG_GUEST_ERROR , +"%s: SYS_CTRL[3..0] shall always be written as 0xf" , +DEVICE (opaque)->canonical_path); + } + } + +esdhc_write (opaque, offset, val, size); +} +static const MemoryRegionOps usdhc_mmio_ops = { - .read = esdhc_read, - .write = esdhc_write, + .read = usdhc_read, + .write = usdhc_write, .valid = { .min_access_size =1 , .max_access_size =4 ,
Signature · 1 line
2.52.0
PATCH 13/14 hw/sd/sdhci: Remove vendor property
In reply to Bernhard BeschowNow that there are dedicated eSDHC device models it is possible to replace the "vendor" property (which is really a device-specific property) with a dynamic cast, "fishing" out only the device models which shall have the quirk applied.
--- hw/sd/sdhci-internal.h | 1 - include/hw/sd/sdhci.h | 4 ---- hw/sd/sdhci.c | 5 ++--- 3 files changed, 2 insertions(+), 8 deletions(-)
hw/sd/sdhci-internal.h +0 -1
@@ -309,7 +309,6 @@ extern const VMStateDescription sdhci_vmstate;#define DEFINE_SDHCI_COMMON_PROPERTIES (_state) \ DEFINE_PROP_UINT8("sd-spec-version", _state, sd_spec_version, 2), \ DEFINE_PROP_UINT8("uhs", _state, uhs_mode, UHS_NOT_SUPPORTED), \ - DEFINE_PROP_UINT8("vendor", _state, vendor, SDHCI_VENDOR_NONE), \ \/* Capabilities registers provide information on supported * features of this specific host controller implementation */ \
include/hw/sd/sdhci.h +0 -4
@@ -98,7 +98,6 @@ struct SDHCIState {uint32_t quirks;uint8_t sd_spec_version;uint8_t uhs_mode; -uint8_t vendor;/* For vendor specific functionality */ /* * Write Protect pin default active low for detecting SD card * to be protected. Set wp_inverted to invert the signal.
@@ -107,9 +106,6 @@ struct SDHCIState { };typedef struct SDHCIState SDHCIState ; -#define SDHCI_VENDOR_NONE 0 -#define SDHCI_VENDOR_FSL 2 -/* * Controller does not provide transfer-complete interrupt when not * busy.
hw/sd/sdhci.c +2 -3
@@ -307,7 +307,8 @@ static void sdhci_reset(SDHCIState *s) s->data_count =0 ; s->stopped_state = sdhc_not_stopped; s->pending_insert_state = false; -if (s->vendor ==SDHCI_VENDOR_FSL ) { +if (object_dynamic_cast (OBJECT (s),TYPE_FSL_ESDHC_BE ) || +object_dynamic_cast (OBJECT (s),TYPE_FSL_ESDHC_LE )) { s->norintstsen =0x013f ; s->errintstsen =0x117f ; }
@@ -1863,7 +1864,6 @@ static void fsl_esdhc_be_init(Object *obj) s->io_ops = &esdhc_mmio_be_ops; s->quirks =SDHCI_QUIRK_NO_BUSY_IRQ ;qdev_prop_set_uint8 (dev,"sd-spec-version" ,2 ); -qdev_prop_set_uint8 (dev,"vendor" ,SDHCI_VENDOR_FSL ); }static const MemoryRegionOps esdhc_mmio_le_ops = {
@@ -1889,7 +1889,6 @@ static void fsl_esdhc_le_init(Object *obj) s->io_ops = &esdhc_mmio_le_ops; s->quirks =SDHCI_QUIRK_NO_BUSY_IRQ ;qdev_prop_set_uint8 (dev,"sd-spec-version" ,2 ); -qdev_prop_set_uint8 (dev,"vendor" ,SDHCI_VENDOR_FSL ); }static uint64_t usdhc_read (void *opaque,hwaddr offset,unsigned size)
Signature · 1 line
2.52.0
PATCH 14/14 hw/sd/trace-events: Remove redundant "SWITCH " command name
In reply to Bernhard Beschow"switch" is already part of the function name. No need to repeat it.
--- hw/sd/trace-events | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/sd/trace-events +1 -1
@@ -58,7 +58,7 @@ sdcard_write_data(const char *proto, const char *cmd_desc, uint8_t cmd, uint32_t sdcard_read_data(const char *proto, const char *cmd_desc, uint8_t cmd, uint32_t offset, uint64_t size, uint32_t blklen) "%s %20s/ CMD%02d ofs %"PRIu32" size %"PRIu64" blklen %" PRIu32 sdcard_set_voltage(uint16_t millivolts) "%u mV" sdcard_ext_csd_update(unsigned index, uint8_t oval, uint8_t nval) "index %u: 0x%02x -> 0x%02x" -sdcard_switch(unsigned access, unsigned index, unsigned value, unsigned set) "SWITCH acc:%u idx:%u val:%u set:%u" +sdcard_switch(unsigned access, unsigned index, unsigned value, unsigned set) "acc:%u idx:%u val:%u set:%u" sdcard_rpmb_read_block(uint16_t resp, uint16_t read_addr, uint16_t result) "resp 0x%x read_addr 0x%x result 0x%x" sdcard_rpmb_write_block(uint16_t req, uint16_t result) "req 0x%x result 0x%x"
Signature · 1 line
2.52.0
Quoted 9 lines
Bernhard Beschow (14):
hw/sd/sdhci: FixTYPE_IMX_USDHCto implement sd-spec-version 3 by
default
hw/arm/fsl-imx6: Remove now redundant setting of "sd-spec-version"
property
hw/arm/fsl-imx6: Fix naming of SDHCI related constants and attributes hw/arm/fsl-imx25: Apply missing reset quirk
Revert "hw/sd/sdhci: Rename ESDHC_* defines to USDHC_*" hw/sd/sdhci: Consolidate eSDHC constants
Quoted 8 lines
hw/sd/sdhci: Rename
usdhc_functions
hw/sd/sdhci: AddTYPE_FSL_ESDHC_BE
hw/ppc/e500: UseTYPE_FSL_ESDHC_BEhw/arm/fsl-imx25: ExtractTYPE_FSL_ESDHC_LEhw/sd/sdhci: Remove endianness property hw/sd/sdhci: Add uSDHC-specific quirk hw/sd/sdhci: Remove vendor property hw/sd/trace-events: Remove redundant "SWITCH " command name
and queued, thanks!
Am 18. Januar 2026 18:23:11 UTC schrieb "Philippe Mathieu-Daudé" <[email protected]>:
Quoted 18 lines
Quoted 9 lines
Bernhard Beschow (14):
hw/sd/sdhci: FixTYPE_IMX_USDHCto implement sd-spec-version 3 by
default
hw/arm/fsl-imx6: Remove now redundant setting of "sd-spec-version"
property
hw/arm/fsl-imx6: Fix naming of SDHCI related constants and attributes hw/arm/fsl-imx25: Apply missing reset quirk
Revert "hw/sd/sdhci: Rename ESDHC_* defines to USDHC_*" hw/sd/sdhci: Consolidate eSDHC constantsQuoted 8 lines
hw/sd/sdhci: Rename
usdhc_functions
hw/sd/sdhci: AddTYPE_FSL_ESDHC_BE
hw/ppc/e500: UseTYPE_FSL_ESDHC_BEhw/arm/fsl-imx25: ExtractTYPE_FSL_ESDHC_LEhw/sd/sdhci: Remove endianness property hw/sd/sdhci: Add uSDHC-specific quirk hw/sd/sdhci: Remove vendor property hw/sd/trace-events: Remove redundant "SWITCH " command name
Quoted 3 lines
Reviewed-by Philippe Mathieu-Daudé <[email protected]>and queued, thanks!
Thanks, Phil!
Could you do me a favor and drop patch "hw/sd/sdhci: Add uSDHC-specific quirk" for now? Although the patch does solve a boot problem I think it needs some more thought. Thanks!
Best regards,
Bernhard
Quoted 21 lines · Bernhard Beschow
Am 18. Januar 2026 18:23:11 UTC schrieb "Philippe Mathieu-Daudé" <[email protected]>:
Quoted 18 lines
Quoted 17 lines
Bernhard Beschow (14):
hw/sd/sdhci: FixTYPE_IMX_USDHCto implement sd-spec-version 3 by
default
hw/arm/fsl-imx6: Remove now redundant setting of "sd-spec-version"
property
hw/arm/fsl-imx6: Fix naming of SDHCI related constants and attributes hw/arm/fsl-imx25: Apply missing reset quirk
Revert "hw/sd/sdhci: Rename ESDHC_* defines to USDHC_*" hw/sd/sdhci: Consolidate eSDHC constants
hw/sd/sdhci: Renameusdhc_functions
hw/sd/sdhci: AddTYPE_FSL_ESDHC_BE
hw/ppc/e500: UseTYPE_FSL_ESDHC_BE
hw/arm/fsl-imx25: ExtractTYPE_FSL_ESDHC_LE
hw/sd/sdhci: Remove endianness property
hw/sd/sdhci: Add uSDHC-specific quirk
hw/sd/sdhci: Remove vendor property
hw/sd/trace-events: Remove redundant "SWITCH " command name
Quoted 7 lines
Quoted 3 lines
Reviewed-by Philippe Mathieu-Daudé <[email protected]>and queued, thanks!
Thanks, Phil!
Could you do me a favor and drop patch "hw/sd/sdhci: Add uSDHC-specific quirk" for now? Although the patch does solve a boot problem I think it needs some more thought. Thanks!
Done.
Quoted 13 lines · Bernhard Beschow
This series splits
TYPE_IMX_USDHCinto three device models which fixes issues in the ppce500 and some i.MX machines. In particular, it introduces uSDHC's predecessor eSDHC in big and little endian variants. Once the eSDHCs are split off, uSDHC emulation is improved which is a stepping stone towards running u-boot on the i.MX8MP (not implemented yet).In a way this series picks up previous efforts:
* https://lore.kernel.org/qemu-devel/[email protected]
* https://lore.kernel.org/qemu-devel/[email protected]There is quite some code churn involved to fix all the issues addressed in this series. Let me know if you have any better ideas to achieve the same.
Quoted 8 lines
Best regards,
BernhardTesting done:
* make check
* Boot https://www.qemu-advent-calendar.org/2018/download/day19.tar.xz in ppce500
* Boot guest in imx8mp-evk
I've tried it with the A1222 U-Boot and it still works the same with this series as before so:
Looks like after this series I can revert this change:
hw/sd/sdhci.c +1 -1
@@ -614,11 +614,11 @@ static void sdhci_sdma_transfer_multi_blocks(SDHCIState *s)* XXX: Some sd/mmc drivers (for example, u-boot-slp) do not account for * possible stop at page boundary if initial address is not page aligned, * allow them to work properly */ if ((s->sdmasysad % boundary_chk) ==0 ) { -// page_aligned = true; + page_aligned = true; } s->prnsts |=SDHC_DATA_INHIBIT |SDHC_DAT_LINE_ACTIVE ;if (s->trnmod &SDHC_TRNS_READ ) { s->prnsts |=SDHC_DOING_READ ;
which needed to be commented out before but now works with or without this change. Is this XXX hack still needed?
Another change I see is that before it ended in:
SDHC wr_4b @0x44 <- 0x00000010 read-only
SDHC wr_4b @0x44 <- 0x00000010 read-only
repeated 18 times which now says:
SD: CMD12 in a wrong state: transfer (spec v3.01)
SD: CMD12 in a wrong state: transfer (spec v3.01)
repeated 17 times. But this fails after not finding a bootable device so I'm not sure this is not a bug in this U-Boot version. With more traces enabled it seems to do some transfer then get these errors when trying to continue reading:
sdcard_read_data SD READ_SINGLE_BLOCK/ CMD17 ofs 509 size 512 blklen 512sdbus_read @sd-bus value 0x00sdcard_read_data SD READ_SINGLE_BLOCK/ CMD17 ofs 510 size 512 blklen 512sdbus_read @sd-bus value 0x55sdcard_read_data SD READ_SINGLE_BLOCK/ CMD17 ofs 511 size 512 blklen 512sdbus_read @sd-bus value 0xaasdhci_end_transfer Automatically issue CMD12 0x00000000 sdbus_command @sd-bus CMD12 arg 0x00000000sdcard_normal_command SD STOP_TRANSMISSION/ CMD12 arg 0x00000000 (mode transfer, state transfer)
SD: CMD12 in a wrong state: transfer (spec v3.01) sdcard_response ILLEGAL RESP (sz:0)sdhci_access wr32: addr[0x000c] <- 0x113a0037 (289013815) sdhci_access rd32: addr[0x0030] -> 0x0000000b (11) sdhci_access rd32: addr[0x0030] -> 0x0000000b (11) sdhci_access rd32: addr[0x0010] -> 0x00000900 (2304) sdhci_access rd32: addr[0x0030] -> 0x0000000b (11) sdhci_access wr32: addr[0x0030] <- 0xfffffeff (4294967039) sdhci_access wr32: addr[0x0030] <- 0xfffffeff (4294967039) sdbus_get_dat_lines @sd-bus dat_lines: 15 sdbus_get_cmd_line @sd-bus cmd_line: 1 sdhci_access rd32: addr[0x0024] -> 0x01ff0000 (33488896) sdbus_get_dat_lines @sd-bus dat_lines: 15 sdbus_get_cmd_line @sd-bus cmd_line: 1 sdhci_access rd32: addr[0x0024] -> 0x01ff0000 (33488896) sdbus_get_dat_lines @sd-bus dat_lines: 15 sdbus_get_cmd_line @sd-bus cmd_line: 1 sdhci_access rd32: addr[0x0024] -> 0x01ff0000 (33488896) sdhci_access wr32: addr[0x0038] <- 0x00000000 (0) sdhci_access wr32: addr[0x0008] <- 0x00000200 (512) sdhci_send_command CMD16 ARG[0x00000200] sdbus_command @sd-bus CMD16 arg 0x00000200sdcard_normal_command SD SET_BLOCKLEN/ CMD16 arg 0x00000200 (mode transfer, state transfer)sdcard_set_blocklen block len 0x200 sdcard_response RESP#1 (normal cmd) (sz:4) sdhci_response4 RSPREG[31..0]=0x00400900 sdhci_access wr32: addr[0x000c] <- 0x101a0037 (270139447) sdhci_access rd32: addr[0x0030] -> 0x00000001 (1) sdhci_access rd32: addr[0x0030] -> 0x00000001 (1) sdhci_access rd32: addr[0x0010] -> 0x00400900 (4196608) sdhci_access wr32: addr[0x0030] <- 0xfffffeff (4294967039) sdhci_access wr32: addr[0x0030] <- 0xfffffeff (4294967039) sdbus_get_dat_lines @sd-bus dat_lines: 15 sdbus_get_cmd_line @sd-bus cmd_line: 1 sdhci_access rd32: addr[0x0024] -> 0x01ff0000 (33488896) sdbus_get_dat_lines @sd-bus dat_lines: 15 sdbus_get_cmd_line @sd-bus cmd_line: 1 sdhci_access rd32: addr[0x0024] -> 0x01ff0000 (33488896) sdbus_get_dat_lines @sd-bus dat_lines: 15 sdbus_get_cmd_line @sd-bus cmd_line: 1 sdhci_access rd32: addr[0x0024] -> 0x01ff0000 (33488896) sdhci_access wr32: addr[0x0000] <- 0x79401de8 (2034245096) sdhci_access wr32: addr[0x0004] <- 0x00017200 (94720) sdhci_access rd32: addr[0x002c] -> 0x000b011f (721183) sdhci_access wr32: addr[0x002c] <- 0x000b011f (721183) sdhci_access wr32: addr[0x0038] <- 0x00000000 (0) sdhci_access wr32: addr[0x0008] <- 0x00000200 (512) sdhci_send_command CMD17 ARG[0x00000200] sdbus_command @sd-bus CMD17 arg 0x00000200sdcard_normal_command SD READ_SINGLE_BLOCK/ CMD17 arg 0x00000200 (mode transfer, state transfer)sdcard_req_addr req 0x200 addr 0x200 sdcard_read_block addr 0x200 size 0x200 sdcard_response RESP#1 (normal cmd) (sz:4) sdhci_response4 RSPREG[31..0]=0x00000900sdcard_read_data SD READ_SINGLE_BLOCK/ CMD17 ofs 0 size 512 blklen 512sdbus_read @sd-bus value 0x00sdcard_read_data SD READ_SINGLE_BLOCK/ CMD17 ofs 1 size 512 blklen 512sdbus_read @sd-bus value 0x00
Regards,
BALATON Zoltan
Quoted 33 lines
Bernhard Beschow (14):
hw/sd/sdhci: FixTYPE_IMX_USDHCto implement sd-spec-version 3 by
default
hw/arm/fsl-imx6: Remove now redundant setting of "sd-spec-version"
property
hw/arm/fsl-imx6: Fix naming of SDHCI related constants and attributes hw/arm/fsl-imx25: Apply missing reset quirk
Revert "hw/sd/sdhci: Rename ESDHC_* defines to USDHC_*" hw/sd/sdhci: Consolidate eSDHC constants
hw/sd/sdhci: Renameusdhc_functions
hw/sd/sdhci: AddTYPE_FSL_ESDHC_BE
hw/ppc/e500: UseTYPE_FSL_ESDHC_BE
hw/arm/fsl-imx25: ExtractTYPE_FSL_ESDHC_LE
hw/sd/sdhci: Remove endianness property
hw/sd/sdhci: Add uSDHC-specific quirk
hw/sd/sdhci: Remove vendor property
hw/sd/trace-events: Remove redundant "SWITCH " command namehw/sd/sdhci-internal.h | 3 - include/hw/arm/fsl-imx6.h | 4 +- include/hw/sd/sdhci.h | 8 +- hw/arm/fsl-imx25.c | 5 +- hw/arm/fsl-imx6.c | 18 ++-- hw/ppc/e500.c | 10 +- hw/sd/sdhci.c | 201 ++++++++++++++++++++++++-------------- hw/sd/trace-events | 2 +- 8 files changed, 146 insertions(+), 105 deletions(-)--
2.52.0
Quoted 56 lines · BALATON Zoltan
Quoted 13 lines · Bernhard Beschow
This series splits
TYPE_IMX_USDHCinto three device models which fixes issues in the ppce500 and some i.MX machines. In particular, it introduces uSDHC's predecessor eSDHC in big and little endian variants. Once the eSDHCs are split off, uSDHC emulation is improved which is a stepping stone towards running u-boot on the i.MX8MP (not implemented yet).In a way this series picks up previous efforts:
* https://lore.kernel.org/qemu-devel/[email protected]
* https://lore.kernel.org/qemu-devel/[email protected]There is quite some code churn involved to fix all the issues addressed in this series. Let me know if you have any better ideas to achieve the same.
Quoted 8 lines
Best regards,
BernhardTesting done:
* make check
* Boot https://www.qemu-advent-calendar.org/2018/download/day19.tar.xz in ppce500
* Boot guest in imx8mp-evkI've tried it with the A1222 U-Boot and it still works the same with this series as before so:
Tested-by BALATON Zoltan <[email protected]>Looks like after this series I can revert this change:
hw/sd/sdhci.c +1
-1@@ -614,11 +614,11 @@ static void sdhci_sdma_transfer_multi_blocks(SDHCIState*s) * XXX: Some sd/mmc drivers (for example, u-boot-slp) do not account for * possible stop at page boundary if initial address is not page aligned, * allow them to work properly */ if ((s->sdmasysad % boundary_chk) ==0 ) { -// page_aligned = true; + page_aligned = true; } s->prnsts |=SDHC_DATA_INHIBIT |SDHC_DAT_LINE_ACTIVE ;if (s->trnmod & SDHC_TRNS_READ) { s->prnsts |= SDHC_DOING_READ;which needed to be commented out before but now works with or without this change. Is this XXX hack still needed?
Another change I see is that before it ended in:
SDHC
wr_4b@0x44 <-0x00000010read-only
SDHCwr_4b@0x44 <-0x00000010read-only
Quoted 6 lines
repeated 18 times which now says:
SD: CMD12 in a wrong state: transfer (spec v3.01)
SD: CMD12 in a wrong state: transfer (spec v3.01)repeated 17 times. But this fails after not finding a bootable device so I'm not sure this is not a bug in this U-Boot version. With more traces enabled it seems to do some transfer then get these errors when trying to continue reading:
In case that helps here's the beginning of this transfer that produces the above messages after the first block:
sdcard_read_data SD READ_MULTIPLE_BLOCK/ CMD18 ofs 510 size 512 blklen 512 sdbus_read @sd-bus value 0x00sdcard_read_data SD READ_MULTIPLE_BLOCK/ CMD18 ofs 511 size 512 blklen 512 sdbus_read @sd-bus value 0x00sdhci_end_transfer Automatically issue CMD12 0x00000000 sdbus_command @sd-bus CMD12 arg 0x00000000sdcard_normal_command SD STOP_TRANSMISSION/ CMD12 arg 0x00000000 (mode transfer, state sendingdata)sdcard_response RESP#1 (normal cmd) (sz:4)sdhci_access wr32: addr[0x000c] <- 0x123a0037 (305791031) sdhci_access rd32: addr[0x0030] -> 0x0000000b (11)sdhci_access rd32: addr[0x0030] -> 0x0000000b (11)sdhci_access rd32: addr[0x0010] -> 0x00000900 (2304) sdhci_access rd32: addr[0x0030] -> 0x0000000b (11)sdhci_access wr32: addr[0x0030] <- 0xfffffeff (4294967039)
## Starting application at 0x00200000 ...
Invalid read at addr 0xFFFE0F200, size 4, region '(null)', reason: rejected Invalid write at addr 0xFFFE0F200, size 4, region '(null)', reason: rejected Invalid read at addr 0xFFFE0F204, size 4, region '(null)', reason: rejected Invalid write at addr 0xFFFE0F204, size 4, region '(null)', reason: rejected Invalid read at addr 0xFFFE0F208, size 4, region '(null)', reason: rejected Invalid write at addr 0xFFFE0F208, size 4, region '(null)', reason: rejected sdhci_access wr32: addr[0x0030] <- 0xfffffeff (4294967039) sdbus_get_dat_lines @sd-bus dat_lines: 15sdbus_get_cmd_line @sd-bus cmd_line: 1sdhci_access rd32: addr[0x0024] -> 0x01ff0000 (33488896) sdbus_get_dat_lines @sd-bus dat_lines: 15sdbus_get_cmd_line @sd-bus cmd_line: 1sdhci_access rd32: addr[0x0024] -> 0x01ff0000 (33488896) sdbus_get_dat_lines @sd-bus dat_lines: 15sdbus_get_cmd_line @sd-bus cmd_line: 1sdhci_access rd32: addr[0x0024] -> 0x01ff0000 (33488896) sdhci_access wr32: addr[0x0038] <- 0x00000000 (0)sdhci_access wr32: addr[0x0008] <- 0x00000200 (512) sdhci_send_command CMD16 ARG[0x00000200]sdbus_command @sd-bus CMD16 arg 0x00000200sdcard_normal_command SD SET_BLOCKLEN/ CMD16 arg 0x00000200 (mode transfer, state transfer)sdcard_set_blocklen block len 0x200sdcard_response RESP#1 (normal cmd) (sz:4)sdhci_response4 RSPREG[31..0]=0x00000900sdhci_access wr32: addr[0x000c] <- 0x101a0037 (270139447) sdhci_access rd32: addr[0x0030] -> 0x00000001 (1)sdhci_access rd32: addr[0x0030] -> 0x00000001 (1)sdhci_access rd32: addr[0x0010] -> 0x00000900 (2304) sdhci_access wr32: addr[0x0030] <- 0xfffffeff (4294967039) sdhci_access wr32: addr[0x0030] <- 0xfffffeff (4294967039) sdbus_get_dat_lines @sd-bus dat_lines: 15sdbus_get_cmd_line @sd-bus cmd_line: 1sdhci_access rd32: addr[0x0024] -> 0x01ff0000 (33488896) sdbus_get_dat_lines @sd-bus dat_lines: 15sdbus_get_cmd_line @sd-bus cmd_line: 1sdhci_access rd32: addr[0x0024] -> 0x01ff0000 (33488896) sdbus_get_dat_lines @sd-bus dat_lines: 15sdbus_get_cmd_line @sd-bus cmd_line: 1sdhci_access rd32: addr[0x0024] -> 0x01ff0000 (33488896) sdhci_access wr32: addr[0x0000] <- 0x79401de8 (2034245096) sdhci_access wr32: addr[0x0004] <- 0x00017200 (94720) sdhci_access rd32: addr[0x002c] -> 0x000b011f (721183) sdhci_access wr32: addr[0x002c] <- 0x000b011f (721183) sdhci_access wr32: addr[0x0038] <- 0x00000000 (0)sdhci_access wr32: addr[0x0008] <- 0x00000000 (0) sdhci_send_command CMD17 ARG[0x00000000]sdbus_command @sd-bus CMD17 arg 0x00000000sdcard_normal_command SD READ_SINGLE_BLOCK/ CMD17 arg 0x00000000 (mode transfer, state transfer)sdcard_req_addr req 0x0 addr 0x0sdcard_read_block addr 0x0 size 0x200sdcard_response RESP#1 (normal cmd) (sz:4)sdhci_response4 RSPREG[31..0]=0x00000900sdcard_read_data SD READ_SINGLE_BLOCK/ CMD17 ofs 0 size 512 blklen 512sdbus_read @sd-bus value 0x00sdcard_read_data SD READ_SINGLE_BLOCK/ CMD17 ofs 1 size 512 blklen 512sdbus_read @sd-bus value 0x00
and so on with increasing ofs until:
Quoted 106 lines
sdcard_read_dataSD READ_SINGLE_BLOCK/ CMD17 ofs 509 size 512 blklen 512sdbus_read@sd-bus value0x00sdcard_read_dataSD READ_SINGLE_BLOCK/ CMD17 ofs 510 size 512 blklen 512sdbus_read@sd-bus value0x55sdcard_read_dataSD READ_SINGLE_BLOCK/ CMD17 ofs 511 size 512 blklen 512sdbus_read@sd-bus value0xaasdhci_end_transferAutomatically issue CMD120x00000000sdbus_command@sd-bus CMD12 arg0x00000000sdcard_normal_commandSD STOP_TRANSMISSION/ CMD12 arg0x00000000(mode transfer, state transfer)
SD: CMD12 in a wrong state: transfer (spec v3.01)sdcard_responseILLEGAL RESP (sz:0)sdhci_accesswr32: addr[0x000c] <-0x113a0037(289013815)sdhci_accessrd32: addr[0x0030] ->0x0000000b(11)sdhci_accessrd32: addr[0x0030] ->0x0000000b(11)sdhci_accessrd32: addr[0x0010] ->0x00000900(2304)sdhci_accessrd32: addr[0x0030] ->0x0000000b(11)sdhci_accesswr32: addr[0x0030] <-0xfffffeff(4294967039)sdhci_accesswr32: addr[0x0030] <-0xfffffeff(4294967039)sdbus_get_dat_lines@sd-busdat_lines: 15sdbus_get_cmd_line@sd-buscmd_line: 1sdhci_accessrd32: addr[0x0024] ->0x01ff0000(33488896)sdbus_get_dat_lines@sd-busdat_lines: 15sdbus_get_cmd_line@sd-buscmd_line: 1sdhci_accessrd32: addr[0x0024] ->0x01ff0000(33488896)sdbus_get_dat_lines@sd-busdat_lines: 15sdbus_get_cmd_line@sd-buscmd_line: 1sdhci_accessrd32: addr[0x0024] ->0x01ff0000(33488896)sdhci_accesswr32: addr[0x0038] <-0x00000000(0)sdhci_accesswr32: addr[0x0008] <-0x00000200(512)sdhci_send_commandCMD16 ARG[0x00000200]sdbus_command@sd-bus CMD16 arg0x00000200sdcard_normal_commandSD SET_BLOCKLEN/ CMD16 arg0x00000200(mode transfer, state transfer)sdcard_set_blocklenblock len0x200sdcard_responseRESP#1 (normal cmd) (sz:4)sdhci_response4RSPREG[31..0]=0x00400900sdhci_accesswr32: addr[0x000c] <-0x101a0037(270139447)sdhci_accessrd32: addr[0x0030] ->0x00000001(1)sdhci_accessrd32: addr[0x0030] ->0x00000001(1)sdhci_accessrd32: addr[0x0010] ->0x00400900(4196608)sdhci_accesswr32: addr[0x0030] <-0xfffffeff(4294967039)sdhci_accesswr32: addr[0x0030] <-0xfffffeff(4294967039)sdbus_get_dat_lines@sd-busdat_lines: 15sdbus_get_cmd_line@sd-buscmd_line: 1sdhci_accessrd32: addr[0x0024] ->0x01ff0000(33488896)sdbus_get_dat_lines@sd-busdat_lines: 15sdbus_get_cmd_line@sd-buscmd_line: 1sdhci_accessrd32: addr[0x0024] ->0x01ff0000(33488896)sdbus_get_dat_lines@sd-busdat_lines: 15sdbus_get_cmd_line@sd-buscmd_line: 1sdhci_accessrd32: addr[0x0024] ->0x01ff0000(33488896)sdhci_accesswr32: addr[0x0000] <-0x79401de8(2034245096)sdhci_accesswr32: addr[0x0004] <-0x00017200(94720)sdhci_accessrd32: addr[0x002c] ->0x000b011f(721183)sdhci_accesswr32: addr[0x002c] <-0x000b011f(721183)sdhci_accesswr32: addr[0x0038] <-0x00000000(0)sdhci_accesswr32: addr[0x0008] <-0x00000200(512)sdhci_send_commandCMD17 ARG[0x00000200]sdbus_command@sd-bus CMD17 arg0x00000200sdcard_normal_commandSD READ_SINGLE_BLOCK/ CMD17 arg0x00000200(mode transfer, state transfer)sdcard_req_addrreq0x200addr0x200sdcard_read_blockaddr0x200size0x200sdcard_responseRESP#1 (normal cmd) (sz:4)sdhci_response4RSPREG[31..0]=0x00000900sdcard_read_dataSD READ_SINGLE_BLOCK/ CMD17 ofs 0 size 512 blklen 512sdbus_read@sd-bus value0x00sdcard_read_dataSD READ_SINGLE_BLOCK/ CMD17 ofs 1 size 512 blklen 512sdbus_read@sd-bus value0x00Regards,
BALATON ZoltanQuoted 33 lines
Bernhard Beschow (14):
hw/sd/sdhci: FixTYPE_IMX_USDHCto implement sd-spec-version 3 by
default
hw/arm/fsl-imx6: Remove now redundant setting of "sd-spec-version"
property
hw/arm/fsl-imx6: Fix naming of SDHCI related constants and attributes hw/arm/fsl-imx25: Apply missing reset quirk
Revert "hw/sd/sdhci: Rename ESDHC_* defines to USDHC_*" hw/sd/sdhci: Consolidate eSDHC constants
hw/sd/sdhci: Renameusdhc_functions
hw/sd/sdhci: AddTYPE_FSL_ESDHC_BE
hw/ppc/e500: UseTYPE_FSL_ESDHC_BE
hw/arm/fsl-imx25: ExtractTYPE_FSL_ESDHC_LE
hw/sd/sdhci: Remove endianness property
hw/sd/sdhci: Add uSDHC-specific quirk
hw/sd/sdhci: Remove vendor property
hw/sd/trace-events: Remove redundant "SWITCH " command namehw/sd/sdhci-internal.h | 3 - include/hw/arm/fsl-imx6.h | 4 +- include/hw/sd/sdhci.h | 8 +- hw/arm/fsl-imx25.c | 5 +- hw/arm/fsl-imx6.c | 18 ++-- hw/ppc/e500.c | 10 +- hw/sd/sdhci.c | 201 ++++++++++++++++++++++++-------------- hw/sd/trace-events | 2 +- 8 files changed, 146 insertions(+), 105 deletions(-)--
2.52.0