From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:48897) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T20Oj-0006St-TJ for qemu-devel@nongnu.org; Thu, 16 Aug 2012 09:46:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T20Od-0004FY-V1 for qemu-devel@nongnu.org; Thu, 16 Aug 2012 09:46:05 -0400 Received: from mnementh.archaic.org.uk ([81.2.115.146]:35576) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T20Od-0004FF-M4 for qemu-devel@nongnu.org; Thu, 16 Aug 2012 09:45:59 -0400 From: Peter Maydell Date: Thu, 16 Aug 2012 14:45:53 +0100 Message-Id: <1345124754-4173-3-git-send-email-peter.maydell@linaro.org> In-Reply-To: <1345124754-4173-1-git-send-email-peter.maydell@linaro.org> References: <1345124754-4173-1-git-send-email-peter.maydell@linaro.org> Subject: [Qemu-devel] [PATCH 2/3] pxa2xx: Get BlockDriverState* in mmc controller init, not board init List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Paul Brook , Markus Armbruster , patches@linaro.org Instead of getting the BlockDriverState* in the pxa2xx board init and passing it to the mmc controller's init function, have the mmc controller get the next IF_SD device and use it if present. This brings us into line with other SD controller models and means that we correctly emulate an SD controller with no card present if the user didn't ask for an SD card. Signed-off-by: Peter Maydell --- hw/pxa.h | 2 +- hw/pxa2xx.c | 16 ++-------------- hw/pxa2xx_mmci.c | 7 +++++-- 3 files changed, 8 insertions(+), 17 deletions(-) diff --git a/hw/pxa.h b/hw/pxa.h index 6a21205..569994b 100644 --- a/hw/pxa.h +++ b/hw/pxa.h @@ -87,7 +87,7 @@ void pxa2xx_lcdc_oritentation(void *opaque, int angle); typedef struct PXA2xxMMCIState PXA2xxMMCIState; PXA2xxMMCIState *pxa2xx_mmci_init(MemoryRegion *sysmem, target_phys_addr_t base, - BlockDriverState *bd, qemu_irq irq, + qemu_irq irq, qemu_irq rx_dma, qemu_irq tx_dma); void pxa2xx_mmci_handlers(PXA2xxMMCIState *s, qemu_irq readonly, qemu_irq coverswitch); diff --git a/hw/pxa2xx.c b/hw/pxa2xx.c index d5f1420..2c3ef1f 100644 --- a/hw/pxa2xx.c +++ b/hw/pxa2xx.c @@ -2006,7 +2006,6 @@ PXA2xxState *pxa270_init(MemoryRegion *address_space, { PXA2xxState *s; int i; - DriveInfo *dinfo; s = (PXA2xxState *) g_malloc0(sizeof(PXA2xxState)); if (revision && strncmp(revision, "pxa27", 5)) { @@ -2047,12 +2046,7 @@ PXA2xxState *pxa270_init(MemoryRegion *address_space, s->gpio = pxa2xx_gpio_init(0x40e00000, &s->cpu->env, s->pic, 121); - dinfo = drive_get(IF_SD, 0, 0); - if (!dinfo) { - fprintf(stderr, "qemu: missing SecureDigital device\n"); - exit(1); - } - s->mmc = pxa2xx_mmci_init(address_space, 0x41100000, dinfo->bdrv, + s->mmc = pxa2xx_mmci_init(address_space, 0x41100000, qdev_get_gpio_in(s->pic, PXA2XX_PIC_MMC), qdev_get_gpio_in(s->dma, PXA2XX_RX_RQ_MMCI), qdev_get_gpio_in(s->dma, PXA2XX_TX_RQ_MMCI)); @@ -2143,7 +2137,6 @@ PXA2xxState *pxa255_init(MemoryRegion *address_space, unsigned int sdram_size) { PXA2xxState *s; int i; - DriveInfo *dinfo; s = (PXA2xxState *) g_malloc0(sizeof(PXA2xxState)); @@ -2178,12 +2171,7 @@ PXA2xxState *pxa255_init(MemoryRegion *address_space, unsigned int sdram_size) s->gpio = pxa2xx_gpio_init(0x40e00000, &s->cpu->env, s->pic, 85); - dinfo = drive_get(IF_SD, 0, 0); - if (!dinfo) { - fprintf(stderr, "qemu: missing SecureDigital device\n"); - exit(1); - } - s->mmc = pxa2xx_mmci_init(address_space, 0x41100000, dinfo->bdrv, + s->mmc = pxa2xx_mmci_init(address_space, 0x41100000, qdev_get_gpio_in(s->pic, PXA2XX_PIC_MMC), qdev_get_gpio_in(s->dma, PXA2XX_RX_RQ_MMCI), qdev_get_gpio_in(s->dma, PXA2XX_TX_RQ_MMCI)); diff --git a/hw/pxa2xx_mmci.c b/hw/pxa2xx_mmci.c index b505a4c..f645773 100644 --- a/hw/pxa2xx_mmci.c +++ b/hw/pxa2xx_mmci.c @@ -14,6 +14,7 @@ #include "pxa.h" #include "sd.h" #include "qdev.h" +#include "blockdev.h" struct PXA2xxMMCIState { MemoryRegion iomem; @@ -523,10 +524,11 @@ static int pxa2xx_mmci_load(QEMUFile *f, void *opaque, int version_id) PXA2xxMMCIState *pxa2xx_mmci_init(MemoryRegion *sysmem, target_phys_addr_t base, - BlockDriverState *bd, qemu_irq irq, + qemu_irq irq, qemu_irq rx_dma, qemu_irq tx_dma) { PXA2xxMMCIState *s; + DriveInfo *dinfo; s = (PXA2xxMMCIState *) g_malloc0(sizeof(PXA2xxMMCIState)); s->irq = irq; @@ -538,7 +540,8 @@ PXA2xxMMCIState *pxa2xx_mmci_init(MemoryRegion *sysmem, memory_region_add_subregion(sysmem, base, &s->iomem); /* Instantiate the actual storage */ - s->card = sd_init(bd, 0); + dinfo = drive_get_next(IF_SD); + s->card = sd_init(dinfo ? dinfo->bdrv : NULL, 0); register_savevm(NULL, "pxa2xx_mmci", 0, 0, pxa2xx_mmci_save, pxa2xx_mmci_load, s); -- 1.7.9.5