From 76ffaf1fb72a7c9840dddb9d17e2831d809ede99 Mon Sep 17 00:00:00 2001 From: Andrew Baumann Date: Tue, 29 Dec 2015 12:43:30 -0800 Subject: [PATCH] sdhci: add Pi-specific quirk/kludge to set card insertion insterrupt at startup This one is pretty unsavoury in its current format, but is the minimal change needed to keep UEFI booting with the common sdhci emulation. The observed behaviour of the Pi2 hardware appears to be that card insertion interrupts are visible even if they occur when the interrupt status is initially disabled (i.e., if a card is inserted at power on, then on a later write to enable the card insertion interrupt, it still appears immediately). However, the SDHCI spec (sec 1.8) is pretty clear that the interrupt status enable register acts as a mask before the interrupt state is latched; i.e. if the interrupt occurs but it is disabled, then it is forever lost. It's not yet clear to me how to resolve the hardware inconsistency with the spec / implementation, nor how to implement it in a way that's acceptable upstream. --- hw/sd/sdhci.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c index 61f919b724..1a8b1bf6dd 100644 --- a/hw/sd/sdhci.c +++ b/hw/sd/sdhci.c @@ -1310,6 +1310,11 @@ static void sdhci_sysbus_realize(DeviceState *dev, Error ** errp) memory_region_init_io(&s->iomem, OBJECT(s), &sdhci_mmio_ops, s, "sdhci", SDHC_REGISTERS_MAP_SIZE); sysbus_init_mmio(sbd, &s->iomem); + + /* XXX: kludge for Pi UEFI: set card insert at startup -AB */ + if (s->noeject_quirk && (s->prnsts & SDHC_CARD_PRESENT)) { + s->norintsts |= SDHC_NIS_INSERT; + } } static void sdhci_sysbus_class_init(ObjectClass *klass, void *data) -- 2.11.4.GIT