hw/sd/sdhci: Set reset value of interrupt registers
PATCH v2 1/1 hw/sd/sdhci: Set reset value of interrupt registers
The interrupt enable registers are not reset to 0 on Freescale eSDHC but some bits are enabled on reset. At least some U-Boot versions seem to expect this and not initialise these registers before expecting interrupts. Use existing vendor property for Freescale eSDHC and set the reset value of the interrupt registers to match Freescale documentation.
---
v2: Restrict to e500. Adding a reset method in a subclass does not work because the common reset function is called directly on register write from the guest but there's already provision for vendor specific behaviour which can be used to restrict this to Freescale SoCs.
hw/ppc/e500.c | 1 + hw/sd/sdhci.c | 4 ++++ include/hw/sd/sdhci.h | 1 + 3 files changed, 6 insertions(+)
hw/ppc/e500.c +1 -0
@@ -1044,6 +1044,7 @@ void ppce500_init(MachineState *machine) 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 ); 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 ));
hw/sd/sdhci.c +4 -0
@@ -307,6 +307,10 @@ 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 ) { + s->norintstsen =0x013f ; + s->errintstsen =0x117f ; + } }static void sdhci_poweron_reset (DeviceState *dev)
include/hw/sd/sdhci.h +1 -0
@@ -110,6 +110,7 @@ typedef struct SDHCIState SDHCIState;#define SDHCI_VENDOR_NONE 0#define SDHCI_VENDOR_IMX 1 +#define SDHCI_VENDOR_FSL 2/* * Controller does not provide transfer-complete interrupt when not
Signature · 1 line
2.30.9
Quoted 6 lines · BALATON Zoltan
The interrupt enable registers are not reset to 0 on Freescale eSDHC but some bits are enabled on reset. At least some U-Boot versions seem to expect this and not initialise these registers before expecting interrupts. Use existing vendor property for Freescale eSDHC and set the reset value of the interrupt registers to match Freescale documentation.
Ping?
Quoted 52 lines
Signed-off-by BALATON Zoltan <[email protected]>---
v2: Restrict to e500. Adding a reset method in a subclass does not work because the common reset function is called directly on register write from the guest but there's already provision for vendor specific behaviour which can be used to restrict this to Freescale SoCs.hw/ppc/e500.c | 1 + hw/sd/sdhci.c | 4 ++++ include/hw/sd/sdhci.h | 1 + 3 files changed, 6 insertions(+)hw/ppc/e500.c +1
-0@@ -1044,6 +1044,7 @@ void ppce500_init(MachineState *machine) 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 ); 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 ));hw/sd/sdhci.c +4
-0@@ -307,6 +307,10 @@ 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 ) { + s->norintstsen =0x013f ; + s->errintstsen =0x117f ; + } }static void sdhci_poweron_reset (DeviceState *dev)include/hw/sd/sdhci.h +1
-0@@ -110,6 +110,7 @@ typedef struct SDHCIState SDHCIState;#define SDHCI_VENDOR_NONE 0#define SDHCI_VENDOR_IMX 1 +#define SDHCI_VENDOR_FSL 2/* * Controller does not provide transfer-complete interrupt when not
Am 1. März 2025 16:02:05 UTC schrieb BALATON Zoltan <[email protected]>:
Quoted 55 lines · BALATON Zoltan
Quoted 6 lines
The interrupt enable registers are not reset to 0 on Freescale eSDHC but some bits are enabled on reset. At least some U-Boot versions seem to expect this and not initialise these registers before expecting interrupts. Use existing vendor property for Freescale eSDHC and set the reset value of the interrupt registers to match Freescale documentation.
Ping?
Quoted 45 lines
Signed-off-by BALATON Zoltan <[email protected]>---
v2: Restrict to e500. Adding a reset method in a subclass does not work because the common reset function is called directly on register write from the guest but there's already provision for vendor specific behaviour which can be used to restrict this to Freescale SoCs.hw/ppc/e500.c | 1 + hw/sd/sdhci.c | 4 ++++ include/hw/sd/sdhci.h | 1 + 3 files changed, 6 insertions(+)hw/ppc/e500.c +1
-0@@ -1044,6 +1044,7 @@ void ppce500_init(MachineState *machine) 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 ); 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 ));hw/sd/sdhci.c +4
-0@@ -307,6 +307,10 @@ 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 ) { + s->norintstsen =0x013f ; + s->errintstsen =0x117f ; + } }static void sdhci_poweron_reset (DeviceState *dev)include/hw/sd/sdhci.h +0
-0@@ -110,6 +110,7 @@ typedef struct SDHCIState SDHCIState;
Quoted 3 lines
include/hw/sd/sdhci.h typedef struct SDHCIState SDHCIState; · line 113
Quoted 3 lines
include/hw/sd/sdhci.h +1
-0#define SDHCI_VENDOR_NONE 0#define SDHCI_VENDOR_IMX 1 +#define SDHCI_VENDOR_FSL 2
From an i.MX point of view the sole "FSL" postfix seems confusing since these SoCs are from the same vendor. What about "FSL_ESDHC"?
Best regards,
Bernhard
Quoted 4 lines
Quoted 4 lines
include/hw/sd/sdhci.h +0
-0/* * Controller does not provide transfer-complete interrupt when not
Quoted 56 lines · Bernhard Beschow
Am 1. März 2025 16:02:05 UTC schrieb BALATON Zoltan <[email protected]>:
Quoted 55 lines · BALATON Zoltan
Quoted 6 lines
The interrupt enable registers are not reset to 0 on Freescale eSDHC but some bits are enabled on reset. At least some U-Boot versions seem to expect this and not initialise these registers before expecting interrupts. Use existing vendor property for Freescale eSDHC and set the reset value of the interrupt registers to match Freescale documentation.
Ping?
Quoted 45 lines
Signed-off-by BALATON Zoltan <[email protected]>---
v2: Restrict to e500. Adding a reset method in a subclass does not work because the common reset function is called directly on register write from the guest but there's already provision for vendor specific behaviour which can be used to restrict this to Freescale SoCs.hw/ppc/e500.c | 1 + hw/sd/sdhci.c | 4 ++++ include/hw/sd/sdhci.h | 1 + 3 files changed, 6 insertions(+)hw/ppc/e500.c +1
-0@@ -1044,6 +1044,7 @@ void ppce500_init(MachineState *machine) 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 ); 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 ));hw/sd/sdhci.c +4
-0@@ -307,6 +307,10 @@ 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 ) { + s->norintstsen =0x013f ; + s->errintstsen =0x117f ; + } }static void sdhci_poweron_reset (DeviceState *dev)include/hw/sd/sdhci.h +0
-0@@ -110,6 +110,7 @@ typedef struct SDHCIState SDHCIState;
Quoted 5 lines
Quoted 3 lines
include/hw/sd/sdhci.h typedef struct SDHCIState SDHCIState; · line 113
Quoted 3 lines
include/hw/sd/sdhci.h +1
-0#define SDHCI_VENDOR_NONE 0#define SDHCI_VENDOR_IMX 1 +#define SDHCI_VENDOR_FSL 2From an i.MX point of view the sole "FSL" postfix seems confusing since these SoCs are from the same vendor. What about "
FSL_ESDHC"?
That's too long and not a vendor. How about FSL_IMX instead? But maybe it's not really a problem as IMX is already a separate define and other devices use the FSL prefix so maybe it's not that confusing to worth changing.
Regards,
BALATON Zoltan
Hi Zoltan,
Quoted 36 lines · BALATON Zoltan
The interrupt enable registers are not reset to 0 on Freescale eSDHC but some bits are enabled on reset. At least some U-Boot versions seem to expect this and not initialise these registers before expecting interrupts. Use existing vendor property for Freescale eSDHC and set the reset value of the interrupt registers to match Freescale documentation.
Signed-off-by BALATON Zoltan <[email protected]>---
v2: Restrict to e500. Adding a reset method in a subclass does not work because the common reset function is called directly on register write from the guest but there's already provision for vendor specific behaviour which can be used to restrict this to Freescale SoCs.hw/ppc/e500.c | 1 + hw/sd/sdhci.c | 4 ++++ include/hw/sd/sdhci.h | 1 + 3 files changed, 6 insertions(+)hw/ppc/e500.c +1
-0@@ -1044,6 +1044,7 @@ void ppce500_init(MachineState *machine) 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 ); 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 ));hw/sd/sdhci.c +0
-0
hw/sd/sdhci.c static void sdhci_reset(SDHCIState *s) · line 312
Quoted 6 lines
hw/sd/sdhci.c +3
-0@@ -307,6 +307,10 @@ 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 ) { + s->norintstsen =0x013f ; + s->errintstsen =0x117f ;
I'd rather do like capareg, and add:
DEFINE_PROP_UINT16("norintstsen", _state, norintstsen, 0),
...
Then SoC code sets it:
qdev_prop_set_uint16(dev, "norintstsen", 0x013f); ...
WDYT?
Quoted 2 lines
hw/sd/sdhci.c +1
-0+ } }
Quoted 49 lines · Philippe Mathieu-Daudé
Hi Zoltan,
Quoted 37 lines · BALATON Zoltan
The interrupt enable registers are not reset to 0 on Freescale eSDHC but some bits are enabled on reset. At least some U-Boot versions seem to expect this and not initialise these registers before expecting interrupts. Use existing vendor property for Freescale eSDHC and set the reset value of the interrupt registers to match Freescale documentation.
Signed-off-by BALATON Zoltan <[email protected]>---
v2: Restrict to e500. Adding a reset method in a subclass does not work because the common reset function is called directly on register write from the guest but there's already provision for vendor specific behaviour which can be used to restrict this to Freescale SoCs.hw/ppc/e500.c | 1 + hw/sd/sdhci.c | 4 ++++ include/hw/sd/sdhci.h | 1 + 3 files changed, 6 insertions(+)hw/ppc/e500.c +1
-0@@ -1044,6 +1044,7 @@ void ppce500_init(MachineState *machine) 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 ); 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));hw/sd/sdhci.c +0
-0hw/sd/sdhci.c static void sdhci_reset(SDHCIState *s) · line 312
Quoted 6 lines
hw/sd/sdhci.c +3
-0@@ -307,6 +307,10 @@ 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 ) { + s->norintstsen =0x013f ; + s->errintstsen =0x117f ;I'd rather do like capareg, and add:
Quoted 2 lines
DEFINE_PROP_UINT16("norintstsen", _state, norintstsen, 0),
...
I don't see what you mean. capareg does not seem to be set via a property.
Quoted 6 lines
Then SoC code sets it:
qdev_prop_set_uint16(dev, "norintstsen", 0x013f);
...WDYT?
I think it may be overkill to add properties for this if there are no other vendor or variant that needs this. Also properties are for something the user may want to set as those can be changed with QEMU command line and these reset values aren't something the user should change so I think this patch is the simplest solution now.
Regards,
BALATON Zoltan
Quoted 55 lines · BALATON Zoltan
Quoted 49 lines · Philippe Mathieu-Daudé
Hi Zoltan,
Quoted 37 lines · BALATON Zoltan
The interrupt enable registers are not reset to 0 on Freescale eSDHC but some bits are enabled on reset. At least some U-Boot versions seem to expect this and not initialise these registers before expecting interrupts. Use existing vendor property for Freescale eSDHC and set the reset value of the interrupt registers to match Freescale documentation.
Signed-off-by BALATON Zoltan <[email protected]>---
v2: Restrict to e500. Adding a reset method in a subclass does not work because the common reset function is called directly on register write from the guest but there's already provision for vendor specific behaviour which can be used to restrict this to Freescale SoCs.hw/ppc/e500.c | 1 + hw/sd/sdhci.c | 4 ++++ include/hw/sd/sdhci.h | 1 + 3 files changed, 6 insertions(+)hw/ppc/e500.c +1
-0@@ -1044,6 +1044,7 @@ void ppce500_init(MachineState *machine) 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 ); 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));hw/sd/sdhci.c +0
-0hw/sd/sdhci.c static void sdhci_reset(SDHCIState *s) · line 312
Quoted 6 lines
hw/sd/sdhci.c +3
-0@@ -307,6 +307,10 @@ 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 ) { + s->norintstsen =0x013f ; + s->errintstsen =0x117f ;I'd rather do like capareg, and add:
Quoted 2 lines
DEFINE_PROP_UINT16("norintstsen", _state, norintstsen, 0),
...I don't see what you mean. capareg does not seem to be set via a property.
Quoted 8 lines
Quoted 6 lines
Then SoC code sets it:
qdev_prop_set_uint16(dev, "norintstsen", 0x013f);
...WDYT?
I think it may be overkill to add properties for this if there are no other vendor or variant that needs this. Also properties are for something the user may want to set as those can be changed with QEMU command line and these reset values aren't something the user should change so I think this patch is the simplest solution now.
This patch wasn't in the pull request but I haven't seen an answer to this message either so was it missed or do you have furhter comments? Bernhard has a comment about naming of SDHCI_VENDOR_FSL but I think the already existing IMX name is what's wrong not the one added in this patch but I don't think that's really that confusing to worth further effort. We still have time as this can be considered a fix but I'd like this to not get forgotten so I bring it up again.
Regards,
BALATON Zoltan
Quoted 57 lines · BALATON Zoltan
Quoted 56 lines · BALATON Zoltan
Quoted 48 lines · Philippe Mathieu-Daudé
Hi Zoltan,
Quoted 36 lines · BALATON Zoltan
The interrupt enable registers are not reset to 0 on Freescale eSDHC but some bits are enabled on reset. At least some U-Boot versions seem to expect this and not initialise these registers before expecting interrupts. Use existing vendor property for Freescale eSDHC and set the reset value of the interrupt registers to match Freescale documentation.
Signed-off-by BALATON Zoltan <[email protected]>---
v2: Restrict to e500. Adding a reset method in a subclass does not work because the common reset function is called directly on register write from the guest but there's already provision for vendor specific behaviour which can be used to restrict this to Freescale SoCs.hw/ppc/e500.c | 1 +
hw/sd/sdhci.c | 4 ++++
include/hw/sd/sdhci.h| 1 +3 files changed, 6 insertions(+)hw/ppc/e500.c +1
-0@@ -1044,6 +1044,7 @@ void ppce500_init(MachineState *machine) 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); 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));hw/sd/sdhci.c +0
-0hw/sd/sdhci.c static void sdhci_reset(SDHCIState *s) · line 312
Quoted 6 lines
hw/sd/sdhci.c +3
-0@@ -307,6 +307,10 @@ 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) { + s->norintstsen = 0x013f; + s->errintstsen = 0x117f;I'd rather do like capareg, and add:
Quoted 2 lines
DEFINE_PROP_UINT16("norintstsen",
_state, norintstsen, 0),
...I don't see what you mean. capareg does not seem to be set via a property.
Quoted 2 lines
Then SoC code sets it:
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
qdev_prop_set_uint16(dev, "norintstsen",
0x013f);
...WDYT?
I think it may be overkill to add properties for this if there are no other vendor or variant that needs this. Also properties are for something the user may want to set as those can be changed with QEMU command line and these reset values aren't something the user should change so I think this patch is the simplest solution now.
This patch wasn't in the pull request but I haven't seen an answer to this message either so was it missed or do you have furhter comments? Bernhard has a comment about naming of
SDHCI_VENDOR_FSLbut I think the already existing IMX name is what's wrong not the one added in this patch but I don't think that's really that confusing to worth further effort. We still have time as this can be considered a fix but I'd like this to not get forgotten so I bring it up again.
I'll post a v3 with what I had in mind.
Quoted 19 lines · BALATON Zoltan
Quoted 18 lines · BALATON Zoltan
Quoted 17 lines · Philippe Mathieu-Daudé
Hi Zoltan,
Quoted 14 lines · BALATON Zoltan
The interrupt enable registers are not reset to 0 on Freescale eSDHC but some bits are enabled on reset. At least some U-Boot versions seem to expect this and not initialise these registers before expecting interrupts. Use existing vendor property for Freescale eSDHC and set the reset value of the interrupt registers to match Freescale documentation.
Signed-off-by BALATON Zoltan <[email protected]>---
v2: Restrict to e500. Adding a reset method in a subclass does not work because the common reset function is called directly on register write from the guest but there's already provision for vendor specific behaviour which can be used to restrict this to Freescale SoCs.
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
hw/ppc/e500.c | 1 +
hw/sd/sdhci.c | 4 ++++
include/hw/sd/sdhci.h| 1 +3 files changed, 6 insertions(+)This patch wasn't in the pull request but I haven't seen an answer to this message either so was it missed or do you have furhter comments? Bernhard has a comment about naming of
SDHCI_VENDOR_FSLbut I think the already existing IMX name is what's wrong not the one added in this patch but I don't think that's really that confusing to worth further effort. We still have time as this can be considered a fix but I'd like this to not get forgotten so I bring it up again.
Patch queued, thanks.