qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 19/19] ppc/ppc405: QOM'ify I2C


From: Daniel Henrique Barboza
Subject: Re: [PATCH 19/19] ppc/ppc405: QOM'ify I2C
Date: Wed, 3 Aug 2022 06:46:09 -0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0



On 8/1/22 10:10, Cédric Le Goater wrote:
Having an explicit I2C model object will help if one day we want to
add I2C devices on the bus.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
---

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

  hw/ppc/ppc405.h    |  2 ++
  hw/ppc/ppc405_uc.c | 10 ++++++++--
  2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/hw/ppc/ppc405.h b/hw/ppc/ppc405.h
index c2cfccb9d106..0b1e15c18fe0 100644
--- a/hw/ppc/ppc405.h
+++ b/hw/ppc/ppc405.h
@@ -28,6 +28,7 @@
  #include "qom/object.h"
  #include "hw/ppc/ppc4xx.h"
  #include "hw/intc/ppc-uic.h"
+#include "hw/i2c/ppc4xx_i2c.h"
#define PPC405EP_SDRAM_BASE 0x00000000
  #define PPC405EP_NVRAM_BASE 0xF0000000
@@ -256,6 +257,7 @@ struct Ppc405SoCState {
      Ppc405OcmState ocm;
      Ppc405GpioState gpio;
      Ppc405DmaState dma;
+    PPC4xxI2CState i2c;
      Ppc405EbcState ebc;
      Ppc405OpbaState opba;
      Ppc405PobState pob;
diff --git a/hw/ppc/ppc405_uc.c b/hw/ppc/ppc405_uc.c
index 0336d1e08689..5372c308c227 100644
--- a/hw/ppc/ppc405_uc.c
+++ b/hw/ppc/ppc405_uc.c
@@ -1461,6 +1461,8 @@ static void ppc405_soc_instance_init(Object *obj)
object_initialize_child(obj, "dma", &s->dma, TYPE_PPC405_DMA); + object_initialize_child(obj, "i2c", &s->i2c, TYPE_PPC4xx_I2C);
+
      object_initialize_child(obj, "ebc", &s->ebc, TYPE_PPC405_EBC);
object_initialize_child(obj, "opba", &s->opba, TYPE_PPC405_OPBA);
@@ -1572,8 +1574,12 @@ static void ppc405_soc_realize(DeviceState *dev, Error 
**errp)
      }
/* I2C controller */
-    sysbus_create_simple(TYPE_PPC4xx_I2C, 0xef600500,
-                         qdev_get_gpio_in(DEVICE(&s->uic), 2));
+    if (!sysbus_realize(SYS_BUS_DEVICE(&s->i2c), errp)) {
+        return;
+    }
+    sysbus_mmio_map(SYS_BUS_DEVICE(&s->i2c), 0, 0xef600500);
+    sysbus_connect_irq(SYS_BUS_DEVICE(&s->i2c), 0,
+                       qdev_get_gpio_in(DEVICE(&s->uic), 2));
/* GPIO */
      if (!sysbus_realize(SYS_BUS_DEVICE(&s->gpio), errp)) {



reply via email to

[Prev in Thread] Current Thread [Next in Thread]