[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 16/22] ppc/ppc405: Use an explicit I2C object
From: |
BALATON Zoltan |
Subject: |
[PATCH 16/22] ppc/ppc405: Use an explicit I2C object |
Date: |
Sat, 13 Aug 2022 17:34:43 +0200 (CEST) |
From: Cédric Le Goater <clg@kaod.org>
Having an explicit I2C model object will help if one day we want to
add I2C devices on the bus from the machine init routine.
Signed-off-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
---
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 5bcbce2893..12eee97169 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
@@ -215,6 +216,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 aa3617f876..a7a7d7e65b 100644
--- a/hw/ppc/ppc405_uc.c
+++ b/hw/ppc/ppc405_uc.c
@@ -1093,6 +1093,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);
@@ -1185,8 +1187,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));
+ sbd = SYS_BUS_DEVICE(&s->i2c);
+ if (!sysbus_realize(sbd, errp)) {
+ return;
+ }
+ sysbus_mmio_map(sbd, 0, 0xef600500);
+ sysbus_connect_irq(sbd, 0, qdev_get_gpio_in(DEVICE(&s->uic), 2));
/* GPIO */
sbd = SYS_BUS_DEVICE(&s->gpio);
--
2.30.4
- Re: [PATCH 12/22] ppc4xx: Move PLB model to ppc4xx_devs.c, (continued)
- [PATCH 13/22] ppc4xx: Move EBC model to ppc4xx_devs.c, BALATON Zoltan, 2022/08/13
- [PATCH 14/22] ppc/ppc405: Use an embedded PPCUIC model in SoC state, BALATON Zoltan, 2022/08/13
- [PATCH 15/22] hw/intc/ppc-uic: Convert ppc-uic to a PPC4xx DCR device, BALATON Zoltan, 2022/08/13
- [PATCH 17/22] ppc/ppc405: QOM'ify FPGA, BALATON Zoltan, 2022/08/13
- [PATCH 18/22] ppc405: Move machine specific code to ppc405_boards.c, BALATON Zoltan, 2022/08/13
- [PATCH 16/22] ppc/ppc405: Use an explicit I2C object,
BALATON Zoltan <=
- [PATCH 21/22] ppc4xx: Drop empty default cases, BALATON Zoltan, 2022/08/13
- [PATCH 22/22] ppc/ppc4xx: Fix sdram trace events, BALATON Zoltan, 2022/08/13
- [PATCH 19/22] hw/ppc/Kconfig: Remove PPC405 dependency from sam460ex, BALATON Zoltan, 2022/08/13
- [PATCH 20/22] hw/ppc/Kconfig: Move imply before select, BALATON Zoltan, 2022/08/13
- Re: [PATCH 00/22] QOMify PPC4xx devices and minor clean ups, Cédric Le Goater, 2022/08/16