qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Henrique Barboza <danielhb413@gmail.com>
To: "Cédric Le Goater" <clg@kaod.org>, qemu-ppc@nongnu.org
Cc: qemu-devel@nongnu.org, BALATON Zoltan <balaton@eik.bme.hu>
Subject: Re: [PATCH 10/19] ppc/ppc405: QOM'ify GPIO
Date: Wed, 3 Aug 2022 06:24:13 -0300	[thread overview]
Message-ID: <e42eb5d5-83b7-a062-2d50-b5085ecc59b9@gmail.com> (raw)
In-Reply-To: <20220801131039.1693913-11-clg@kaod.org>



On 8/1/22 10:10, Cédric Le Goater wrote:
> Signed-off-by: Cédric Le Goater <clg@kaod.org>
> ---

Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>

>   hw/ppc/ppc405.h    | 21 +++++++++++++++++++
>   hw/ppc/ppc405_uc.c | 50 +++++++++++++++++++++-------------------------
>   2 files changed, 44 insertions(+), 27 deletions(-)
> 
> diff --git a/hw/ppc/ppc405.h b/hw/ppc/ppc405.h
> index e56363366cad..46366c3b8a19 100644
> --- a/hw/ppc/ppc405.h
> +++ b/hw/ppc/ppc405.h
> @@ -65,6 +65,26 @@ struct ppc4xx_bd_info_t {
>   
>   typedef struct Ppc405SoCState Ppc405SoCState;
>   
> +/* GPIO */
> +#define TYPE_PPC405_GPIO "ppc405-gpio"
> +OBJECT_DECLARE_SIMPLE_TYPE(Ppc405GpioState, PPC405_GPIO);
> +struct Ppc405GpioState {
> +    SysBusDevice parent_obj;
> +
> +    MemoryRegion io;
> +    uint32_t or;
> +    uint32_t tcr;
> +    uint32_t osrh;
> +    uint32_t osrl;
> +    uint32_t tsrh;
> +    uint32_t tsrl;
> +    uint32_t odr;
> +    uint32_t ir;
> +    uint32_t rr1;
> +    uint32_t isr1h;
> +    uint32_t isr1l;
> +};
> +
>   /* On Chip Memory */
>   #define TYPE_PPC405_OCM "ppc405-ocm"
>   OBJECT_DECLARE_SIMPLE_TYPE(Ppc405OcmState, PPC405_OCM);
> @@ -159,6 +179,7 @@ struct Ppc405SoCState {
>       Ppc405CpcState cpc;
>       Ppc405GptState gpt;
>       Ppc405OcmState ocm;
> +    Ppc405GpioState gpio;
>   };
>   
>   /* PowerPC 405 core */
> diff --git a/hw/ppc/ppc405_uc.c b/hw/ppc/ppc405_uc.c
> index 59cade4c0680..a6c4e6934ffc 100644
> --- a/hw/ppc/ppc405_uc.c
> +++ b/hw/ppc/ppc405_uc.c
> @@ -713,23 +713,6 @@ static void ppc405_dma_init(CPUPPCState *env, qemu_irq irqs[4])
>   }
>   
>   /*****************************************************************************/
> -/* GPIO */
> -typedef struct ppc405_gpio_t ppc405_gpio_t;
> -struct ppc405_gpio_t {
> -    MemoryRegion io;
> -    uint32_t or;
> -    uint32_t tcr;
> -    uint32_t osrh;
> -    uint32_t osrl;
> -    uint32_t tsrh;
> -    uint32_t tsrl;
> -    uint32_t odr;
> -    uint32_t ir;
> -    uint32_t rr1;
> -    uint32_t isr1h;
> -    uint32_t isr1l;
> -};
> -
>   static uint64_t ppc405_gpio_read(void *opaque, hwaddr addr, unsigned size)
>   {
>       trace_ppc405_gpio_read(addr, size);
> @@ -748,20 +731,22 @@ static const MemoryRegionOps ppc405_gpio_ops = {
>       .endianness = DEVICE_NATIVE_ENDIAN,
>   };
>   
> -static void ppc405_gpio_reset (void *opaque)
> +static void ppc405_gpio_realize(DeviceState *dev, Error **errp)
>   {
> +    Ppc405GpioState *s = PPC405_GPIO(dev);
> +    SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
> +
> +    memory_region_init_io(&s->io, OBJECT(s), &ppc405_gpio_ops, s, "gpio",
> +                          0x038);
> +    sysbus_init_mmio(sbd, &s->io);
>   }
>   
> -static void ppc405_gpio_init(hwaddr base)
> +static void ppc405_gpio_class_init(ObjectClass *oc, void *data)
>   {
> -    ppc405_gpio_t *gpio;
> -
> -    trace_ppc405_gpio_init(base);
> +    DeviceClass *dc = DEVICE_CLASS(oc);
>   
> -    gpio = g_new0(ppc405_gpio_t, 1);
> -    memory_region_init_io(&gpio->io, NULL, &ppc405_gpio_ops, gpio, "pgio", 0x038);
> -    memory_region_add_subregion(get_system_memory(), base, &gpio->io);
> -    qemu_register_reset(&ppc405_gpio_reset, gpio);
> +    dc->realize = ppc405_gpio_realize;
> +    dc->user_creatable = false;
>   }
>   
>   /*****************************************************************************/
> @@ -1421,6 +1406,8 @@ static void ppc405_soc_instance_init(Object *obj)
>       object_initialize_child(obj, "gpt", &s->gpt, TYPE_PPC405_GPT);
>   
>       object_initialize_child(obj, "ocm", &s->ocm, TYPE_PPC405_OCM);
> +
> +    object_initialize_child(obj, "gpio", &s->gpio, TYPE_PPC405_GPIO);
>   }
>   
>   static void ppc405_soc_realize(DeviceState *dev, Error **errp)
> @@ -1507,8 +1494,12 @@ static void ppc405_soc_realize(DeviceState *dev, Error **errp)
>       /* I2C controller */
>       sysbus_create_simple(TYPE_PPC4xx_I2C, 0xef600500,
>                            qdev_get_gpio_in(s->uic, 2));
> +
>       /* GPIO */
> -    ppc405_gpio_init(0xef600700);
> +    if (!sysbus_realize(SYS_BUS_DEVICE(&s->gpio), errp)) {
> +        return;
> +    }
> +    sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpio), 0, 0xef600700);
>   
>       /* Serial ports */
>       if (serial_hd(0) != NULL) {
> @@ -1572,6 +1563,11 @@ static void ppc405_soc_class_init(ObjectClass *oc, void *data)
>   
>   static const TypeInfo ppc405_types[] = {
>       {
> +        .name           = TYPE_PPC405_GPIO,
> +        .parent         = TYPE_SYS_BUS_DEVICE,
> +        .instance_size  = sizeof(Ppc405GpioState),
> +        .class_init     = ppc405_gpio_class_init,
> +    }, {
>           .name           = TYPE_PPC405_OCM,
>           .parent         = TYPE_SYS_BUS_DEVICE,
>           .instance_size  = sizeof(Ppc405OcmState),


  reply	other threads:[~2022-08-03  9:30 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-01 13:10 [PATCH 00/19] ppc: QOM'ify 405 board Cédric Le Goater
2022-08-01 13:10 ` [PATCH 01/19] ppc/ppc405: Remove taihu machine Cédric Le Goater
2022-08-02 18:02   ` Daniel Henrique Barboza
2022-08-03  7:33     ` Cédric Le Goater
2022-08-01 13:10 ` [PATCH 02/19] ppc/ppc405: Introduce a PPC405 generic machine Cédric Le Goater
2022-08-02 19:07   ` Daniel Henrique Barboza
2022-08-03  7:34     ` Cédric Le Goater
2022-08-01 13:10 ` [PATCH 03/19] ppc/ppc405: Move devices under the ref405ep machine Cédric Le Goater
2022-08-02 19:08   ` Daniel Henrique Barboza
2022-08-01 13:10 ` [PATCH 04/19] ppc/ppc405: Introduce a PPC405 SoC Cédric Le Goater
2022-08-02 19:18   ` Daniel Henrique Barboza
2022-08-01 13:10 ` [PATCH 05/19] ppc/ppc405: Start QOMification of the SoC Cédric Le Goater
2022-08-02 19:18   ` Daniel Henrique Barboza
2022-08-02 21:24     ` BALATON Zoltan
2022-08-03  7:54       ` Cédric Le Goater
2022-08-03  9:23       ` Daniel Henrique Barboza
2022-08-03  8:03     ` Cédric Le Goater
2022-08-03 11:59       ` BALATON Zoltan
2022-08-03 12:28         ` Cédric Le Goater
2022-08-01 13:10 ` [PATCH 06/19] ppc/ppc405: QOM'ify CPU Cédric Le Goater
2022-08-03  9:09   ` Daniel Henrique Barboza
2022-08-01 13:10 ` [PATCH 07/19] ppc/ppc405: QOM'ify CPC Cédric Le Goater
2022-08-03  9:14   ` Daniel Henrique Barboza
2022-08-03  9:16     ` Cédric Le Goater
2022-08-01 13:10 ` [PATCH 08/19] ppc/ppc405: QOM'ify GPT Cédric Le Goater
2022-08-03  9:15   ` Daniel Henrique Barboza
2022-08-01 13:10 ` [PATCH 09/19] ppc/ppc405: QOM'ify OCM Cédric Le Goater
2022-08-03  9:16   ` Daniel Henrique Barboza
2022-08-01 13:10 ` [PATCH 10/19] ppc/ppc405: QOM'ify GPIO Cédric Le Goater
2022-08-03  9:24   ` Daniel Henrique Barboza [this message]
2022-08-01 13:10 ` [PATCH 11/19] ppc/ppc405: QOM'ify DMA Cédric Le Goater
2022-08-03  9:25   ` Daniel Henrique Barboza
2022-08-01 13:10 ` [PATCH 12/19] ppc/ppc405: QOM'ify EBC Cédric Le Goater
2022-08-03  9:26   ` Daniel Henrique Barboza
2022-08-01 13:10 ` [PATCH 13/19] ppc/ppc405: QOM'ify OPBA Cédric Le Goater
2022-08-03  9:27   ` Daniel Henrique Barboza
2022-08-01 13:10 ` [PATCH 14/19] ppc/ppc405: QOM'ify POB Cédric Le Goater
2022-08-03  9:27   ` Daniel Henrique Barboza
2022-08-01 13:10 ` [PATCH 15/19] ppc/ppc405: QOM'ify PLB Cédric Le Goater
2022-08-03  9:43   ` Daniel Henrique Barboza
2022-08-03 11:06     ` BALATON Zoltan
2022-08-01 13:10 ` [PATCH 16/19] ppc/ppc405: QOM'ify MAL Cédric Le Goater
2022-08-03  9:45   ` Daniel Henrique Barboza
2022-08-01 13:10 ` [PATCH 17/19] ppc/ppc405: QOM'ify FPGA Cédric Le Goater
2022-08-03  9:45   ` Daniel Henrique Barboza
2022-08-01 13:10 ` [PATCH 18/19] ppc/ppc405: QOM'ify UIC Cédric Le Goater
2022-08-01 13:17   ` Cédric Le Goater
2022-08-03  9:46   ` Daniel Henrique Barboza
2022-08-01 13:10 ` [PATCH 19/19] ppc/ppc405: QOM'ify I2C Cédric Le Goater
2022-08-03  9:46   ` Daniel Henrique Barboza

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=e42eb5d5-83b7-a062-2d50-b5085ecc59b9@gmail.com \
    --to=danielhb413@gmail.com \
    --cc=balaton@eik.bme.hu \
    --cc=clg@kaod.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@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).