qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Crosthwaite <crosthwaitepeter@gmail.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: Kevin O'Connor <kevin@koconnor.net>,
	Peter Crosthwaite <crosthwaite.peter@gmail.com>,
	Markus Armbruster <armbru@redhat.com>,
	patches@linaro.org, qemu-devel@nongnu.org,
	Alistair Francis <alistair.francis@xilinx.com>,
	qemu-arm@nongnu.org, Paolo Bonzini <pbonzini@redhat.com>,
	"Edgar E. Iglesias" <edgar.iglesias@gmail.com>
Subject: Re: [Qemu-devel] [PATCH 07/10] hw/sd/pxa2xx_mmci: convert to SysBusDevice object
Date: Sat, 19 Dec 2015 13:41:40 -0800	[thread overview]
Message-ID: <20151219214140.GH4164@pcrost-box> (raw)
In-Reply-To: <1449851831-4966-8-git-send-email-peter.maydell@linaro.org>

On Fri, Dec 11, 2015 at 04:37:08PM +0000, Peter Maydell wrote:
> Convert the pxa2xx_mmci device to be a sysbus device.
> 
> In this commit we only change the device itself, and leave
> the interface to the SD card using the old non-SDBus APIs.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>  hw/sd/pxa2xx_mmci.c | 73 ++++++++++++++++++++++++++++++++++++++++-------------
>  1 file changed, 55 insertions(+), 18 deletions(-)
> 
> diff --git a/hw/sd/pxa2xx_mmci.c b/hw/sd/pxa2xx_mmci.c
> index b217080..b6bb390 100644
> --- a/hw/sd/pxa2xx_mmci.c
> +++ b/hw/sd/pxa2xx_mmci.c
> @@ -11,16 +11,24 @@
>   */
>  
>  #include "hw/hw.h"
> +#include "hw/sysbus.h"
>  #include "hw/arm/pxa.h"
>  #include "hw/sd/sd.h"
>  #include "hw/qdev.h"
> +#include "hw/qdev-properties.h"
> +
> +#define TYPE_PXA2XX_MMCI "pxa2xx-mmci"
> +#define PXA2XX_MMCI(obj) OBJECT_CHECK(PXA2xxMMCIState, (obj), TYPE_PXA2XX_MMCI)
> +
> +typedef struct PXA2xxMMCIState {
> +    SysBusDevice parent_obj;
>  
> -struct PXA2xxMMCIState {
>      MemoryRegion iomem;
>      qemu_irq irq;
>      qemu_irq rx_dma;
>      qemu_irq tx_dma;
>  
> +    BlockBackend *blk;
>      SDState *card;
>  
>      uint32_t status;
> @@ -48,7 +56,7 @@ struct PXA2xxMMCIState {
>      int resp_len;
>  
>      int cmdreq;
> -};
> +} PXA2xxMMCIState;
>  
>  #define MMC_STRPCL	0x00	/* MMC Clock Start/Stop register */
>  #define MMC_STAT	0x04	/* MMC Status register */
> @@ -474,31 +482,60 @@ PXA2xxMMCIState *pxa2xx_mmci_init(MemoryRegion *sysmem,
>                  BlockBackend *blk, qemu_irq irq,
>                  qemu_irq rx_dma, qemu_irq tx_dma)
>  {
> +    DeviceState *dev;
> +    SysBusDevice *sbd;
>      PXA2xxMMCIState *s;
>  
> -    s = (PXA2xxMMCIState *) g_malloc0(sizeof(PXA2xxMMCIState));
> -    s->irq = irq;
> -    s->rx_dma = rx_dma;
> -    s->tx_dma = tx_dma;
> -
> -    memory_region_init_io(&s->iomem, NULL, &pxa2xx_mmci_ops, s,
> -                          "pxa2xx-mmci", 0x00100000);
> -    memory_region_add_subregion(sysmem, base, &s->iomem);
> -
> -    /* Instantiate the actual storage */
> -    s->card = sd_init(blk, false);
> +    dev = qdev_create(NULL, TYPE_PXA2XX_MMCI);
> +    s = PXA2XX_MMCI(dev);
> +    /* Reach into the device and initialize the SD card. This is
> +     * unclean but will vanish when we update to SDBus APIs.
> +     */
> +    s->card = sd_init(s->blk, false);
>      if (s->card == NULL) {
>          exit(1);
>      }
> -
> -    register_savevm(NULL, "pxa2xx_mmci", 0, 0,
> -                    pxa2xx_mmci_save, pxa2xx_mmci_load, s);
> -
> +    qdev_init_nofail(dev);
> +    sbd = SYS_BUS_DEVICE(dev);
> +    sysbus_mmio_map(sbd, 0, base);
> +    sysbus_connect_irq(sbd, 0, irq);
> +    sysbus_connect_irq(sbd, 1, rx_dma);
> +    sysbus_connect_irq(sbd, 2, tx_dma);

This looks like heterogenous GPIOs so should be separate named GPIO
sets. Looking at the machine model, the irq goes to the "pic" but the
DMA signals go to a different IP. I would leave the IRQ as the one and
only sysbus IRQ, but implement the two DMAs as named GPIOs.

Otherwise,

Reviewed-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>

Regards,
Peter

>      return s;
>  }
>  
>  void pxa2xx_mmci_handlers(PXA2xxMMCIState *s, qemu_irq readonly,
> -                qemu_irq coverswitch)
> +                          qemu_irq coverswitch)
>  {
>      sd_set_cb(s->card, readonly, coverswitch);
>  }
> +
> +static void pxa2xx_mmci_instance_init(Object *obj)
> +{
> +    PXA2xxMMCIState *s = PXA2XX_MMCI(obj);
> +    SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
> +
> +    memory_region_init_io(&s->iomem, obj, &pxa2xx_mmci_ops, s,
> +                          "pxa2xx-mmci", 0x00100000);
> +    sysbus_init_mmio(sbd, &s->iomem);
> +    sysbus_init_irq(sbd, &s->irq);
> +    sysbus_init_irq(sbd, &s->rx_dma);
> +    sysbus_init_irq(sbd, &s->tx_dma);
> +
> +    register_savevm(NULL, "pxa2xx_mmci", 0, 0,
> +                    pxa2xx_mmci_save, pxa2xx_mmci_load, s);
> +}
> +
> +static const TypeInfo pxa2xx_mmci_info = {
> +    .name = TYPE_PXA2XX_MMCI,
> +    .parent = TYPE_SYS_BUS_DEVICE,
> +    .instance_size = sizeof(PXA2xxMMCIState),
> +    .instance_init = pxa2xx_mmci_instance_init,
> +};
> +
> +static void pxa2xx_mmci_register_types(void)
> +{
> +    type_register_static(&pxa2xx_mmci_info);
> +}
> +
> +type_init(pxa2xx_mmci_register_types)
> -- 
> 1.9.1
> 

  reply	other threads:[~2015-12-19 21:41 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-11 16:37 [Qemu-devel] [PATCH 00/10] hw/sd: QOMify sd.c (and pxa2xx_mmci) Peter Maydell
2015-12-11 16:37 ` [Qemu-devel] [PATCH 01/10] hw/sd/sdhci.c: Remove x-drive property Peter Maydell
2015-12-17 19:28   ` Alistair Francis
2015-12-19 21:33   ` Peter Crosthwaite
2015-12-11 16:37 ` [Qemu-devel] [PATCH 02/10] hw/sd/sd.c: QOMify Peter Maydell
2015-12-17 21:45   ` Alistair Francis
2015-12-17 22:11     ` Peter Maydell
2015-12-18  0:20       ` Alistair Francis
2015-12-19 21:36   ` Peter Crosthwaite
2015-12-20 17:07     ` Peter Maydell
2015-12-20 18:25       ` Peter Crosthwaite
2015-12-11 16:37 ` [Qemu-devel] [PATCH 03/10] hw/sd/sd.c: Convert sd_reset() function into Device reset method Peter Maydell
2015-12-17 23:51   ` Alistair Francis
2015-12-19 21:37   ` Peter Crosthwaite
2015-12-11 16:37 ` [Qemu-devel] [PATCH 04/10] hw/sd: Add QOM bus which SD cards plug in to Peter Maydell
2015-12-19 21:38   ` Peter Crosthwaite
2015-12-20 17:10     ` Peter Maydell
2015-12-20 20:51       ` Peter Crosthwaite
2015-12-20 23:18         ` Peter Maydell
2015-12-21  0:15           ` Peter Crosthwaite
2016-01-07 18:09         ` Peter Maydell
2016-01-08 14:51           ` Peter Crosthwaite
2015-12-11 16:37 ` [Qemu-devel] [PATCH 05/10] hw/sd/sdhci.c: Update to use SDBus APIs Peter Maydell
2015-12-11 19:01   ` Kevin O'Connor
2015-12-11 23:08     ` Peter Maydell
2015-12-19 21:39   ` Peter Crosthwaite
2015-12-20 17:10     ` Peter Maydell
2015-12-11 16:37 ` [Qemu-devel] [PATCH 06/10] sdhci_sysbus: Create SD card device in users, not the device itself Peter Maydell
2015-12-18  0:18   ` Alistair Francis
2015-12-18  9:00     ` Peter Maydell
2015-12-19 21:40     ` Peter Crosthwaite
2015-12-11 16:37 ` [Qemu-devel] [PATCH 07/10] hw/sd/pxa2xx_mmci: convert to SysBusDevice object Peter Maydell
2015-12-19 21:41   ` Peter Crosthwaite [this message]
2015-12-11 16:37 ` [Qemu-devel] [PATCH 08/10] hw/sd/pxa2xx_mmci: Update to use new SDBus APIs Peter Maydell
2015-12-19 21:42   ` Peter Crosthwaite
2015-12-20 17:14     ` Peter Maydell
2015-12-11 16:37 ` [Qemu-devel] [PATCH 09/10] hw/sd/pxa2xx_mmci: Convert to VMStateDescription Peter Maydell
2015-12-19 21:45   ` Peter Crosthwaite
2015-12-20 17:17     ` Peter Maydell
2015-12-11 16:37 ` [Qemu-devel] [PATCH 10/10] hw/sd/pxa2xx_mmci: Add reset function Peter Maydell
2015-12-19 21:45   ` Peter Crosthwaite
2015-12-17  1:25 ` [Qemu-devel] [PATCH 00/10] hw/sd: QOMify sd.c (and pxa2xx_mmci) Alistair Francis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151219214140.GH4164@pcrost-box \
    --to=crosthwaitepeter@gmail.com \
    --cc=alistair.francis@xilinx.com \
    --cc=armbru@redhat.com \
    --cc=crosthwaite.peter@gmail.com \
    --cc=edgar.iglesias@gmail.com \
    --cc=kevin@koconnor.net \
    --cc=patches@linaro.org \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).