[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v4 33/37] omap-i2c: remove PROP_PTR
From: |
Marc-André Lureau |
Subject: |
[PATCH v4 33/37] omap-i2c: remove PROP_PTR |
Date: |
Wed, 20 Nov 2019 19:24:38 +0400 |
Since clocks are not QOM objects, replace PROP_PTR of clocks with
setters methods.
Reviewed-by: Peter Maydell <address@hidden>
Reviewed-by: Corey Minyard <address@hidden>
Signed-off-by: Marc-André Lureau <address@hidden>
---
hw/arm/omap1.c | 2 +-
hw/arm/omap2.c | 8 ++++----
hw/i2c/omap_i2c.c | 19 ++++++++++++-------
include/hw/arm/omap.h | 13 +++++++++++++
4 files changed, 30 insertions(+), 12 deletions(-)
diff --git a/hw/arm/omap1.c b/hw/arm/omap1.c
index 1afd1d3d7f..807e5f70d1 100644
--- a/hw/arm/omap1.c
+++ b/hw/arm/omap1.c
@@ -4030,7 +4030,7 @@ struct omap_mpu_state_s *omap310_mpu_init(MemoryRegion
*dram,
s->i2c[0] = qdev_create(NULL, "omap_i2c");
qdev_prop_set_uint8(s->i2c[0], "revision", 0x11);
- qdev_prop_set_ptr(s->i2c[0], "fclk", omap_findclk(s, "mpuper_ck"));
+ omap_i2c_set_fclk(OMAP_I2C(s->i2c[0]), omap_findclk(s, "mpuper_ck"));
qdev_init_nofail(s->i2c[0]);
busdev = SYS_BUS_DEVICE(s->i2c[0]);
sysbus_connect_irq(busdev, 0, qdev_get_gpio_in(s->ih[1], OMAP_INT_I2C));
diff --git a/hw/arm/omap2.c b/hw/arm/omap2.c
index 1d7cc435ef..171e2d0472 100644
--- a/hw/arm/omap2.c
+++ b/hw/arm/omap2.c
@@ -2425,8 +2425,8 @@ struct omap_mpu_state_s *omap2420_mpu_init(MemoryRegion
*sdram,
s->i2c[0] = qdev_create(NULL, "omap_i2c");
qdev_prop_set_uint8(s->i2c[0], "revision", 0x34);
- qdev_prop_set_ptr(s->i2c[0], "iclk", omap_findclk(s, "i2c1.iclk"));
- qdev_prop_set_ptr(s->i2c[0], "fclk", omap_findclk(s, "i2c1.fclk"));
+ omap_i2c_set_iclk(OMAP_I2C(s->i2c[0]), omap_findclk(s, "i2c1.iclk"));
+ omap_i2c_set_fclk(OMAP_I2C(s->i2c[0]), omap_findclk(s, "i2c1.fclk"));
qdev_init_nofail(s->i2c[0]);
busdev = SYS_BUS_DEVICE(s->i2c[0]);
sysbus_connect_irq(busdev, 0,
@@ -2437,8 +2437,8 @@ struct omap_mpu_state_s *omap2420_mpu_init(MemoryRegion
*sdram,
s->i2c[1] = qdev_create(NULL, "omap_i2c");
qdev_prop_set_uint8(s->i2c[1], "revision", 0x34);
- qdev_prop_set_ptr(s->i2c[1], "iclk", omap_findclk(s, "i2c2.iclk"));
- qdev_prop_set_ptr(s->i2c[1], "fclk", omap_findclk(s, "i2c2.fclk"));
+ omap_i2c_set_iclk(OMAP_I2C(s->i2c[1]), omap_findclk(s, "i2c2.iclk"));
+ omap_i2c_set_fclk(OMAP_I2C(s->i2c[1]), omap_findclk(s, "i2c2.fclk"));
qdev_init_nofail(s->i2c[1]);
busdev = SYS_BUS_DEVICE(s->i2c[1]);
sysbus_connect_irq(busdev, 0,
diff --git a/hw/i2c/omap_i2c.c b/hw/i2c/omap_i2c.c
index 3ba965a58f..3ccbd5cc2c 100644
--- a/hw/i2c/omap_i2c.c
+++ b/hw/i2c/omap_i2c.c
@@ -28,10 +28,7 @@
#include "qemu/error-report.h"
#include "qapi/error.h"
-#define TYPE_OMAP_I2C "omap_i2c"
-#define OMAP_I2C(obj) OBJECT_CHECK(OMAPI2CState, (obj), TYPE_OMAP_I2C)
-
-typedef struct OMAPI2CState {
+struct OMAPI2CState {
SysBusDevice parent_obj;
MemoryRegion iomem;
@@ -56,7 +53,7 @@ typedef struct OMAPI2CState {
uint8_t divider;
uint8_t times[2];
uint16_t test;
-} OMAPI2CState;
+};
#define OMAP2_INTR_REV 0x34
#define OMAP2_GC_REV 0x34
@@ -504,10 +501,18 @@ static void omap_i2c_realize(DeviceState *dev, Error
**errp)
}
}
+void omap_i2c_set_iclk(OMAPI2CState *i2c, omap_clk clk)
+{
+ i2c->iclk = clk;
+}
+
+void omap_i2c_set_fclk(OMAPI2CState *i2c, omap_clk clk)
+{
+ i2c->fclk = clk;
+}
+
static Property omap_i2c_properties[] = {
DEFINE_PROP_UINT8("revision", OMAPI2CState, revision, 0),
- DEFINE_PROP_PTR("iclk", OMAPI2CState, iclk),
- DEFINE_PROP_PTR("fclk", OMAPI2CState, fclk),
DEFINE_PROP_END_OF_LIST(),
};
diff --git a/include/hw/arm/omap.h b/include/hw/arm/omap.h
index bcecf19f89..39a295ba20 100644
--- a/include/hw/arm/omap.h
+++ b/include/hw/arm/omap.h
@@ -81,6 +81,19 @@ typedef struct omap_intr_handler_s omap_intr_handler;
void omap_intc_set_iclk(omap_intr_handler *intc, omap_clk clk);
void omap_intc_set_fclk(omap_intr_handler *intc, omap_clk clk);
+/* omap_i2c.c */
+#define TYPE_OMAP_I2C "omap_i2c"
+#define OMAP_I2C(obj) OBJECT_CHECK(OMAPI2CState, (obj), TYPE_OMAP_I2C)
+
+typedef struct OMAPI2CState OMAPI2CState;
+
+/*
+ * TODO: Ideally we should have a clock framework that
+ * let us wire these clocks up with QOM properties or links.
+ */
+void omap_i2c_set_iclk(OMAPI2CState *i2c, omap_clk clk);
+void omap_i2c_set_fclk(OMAPI2CState *i2c, omap_clk clk);
+
/* OMAP2 l4 Interconnect */
struct omap_l4_s;
struct omap_l4_region_s {
--
2.24.0
- [PATCH v4 26/37] leon3: use qemu_irq framework instead of callback as property, (continued)
- [PATCH v4 26/37] leon3: use qemu_irq framework instead of callback as property, Marc-André Lureau, 2019/11/20
- [PATCH v4 27/37] leon3: use qdev gpio facilities for the PIL, Marc-André Lureau, 2019/11/20
- [PATCH v4 28/37] qdev: use g_strcmp0() instead of open-coding it, Marc-André Lureau, 2019/11/20
- [PATCH v4 29/37] RFC: mips/cps: fix setting saar property, Marc-André Lureau, 2019/11/20
- [PATCH v4 30/37] cris: improve passing PIC interrupt vector to the CPU, Marc-André Lureau, 2019/11/20
- [PATCH v4 31/37] smbus-eeprom: remove PROP_PTR, Marc-André Lureau, 2019/11/20
- [PATCH v4 32/37] omap-intc: remove PROP_PTR, Marc-André Lureau, 2019/11/20
- [PATCH v4 33/37] omap-i2c: remove PROP_PTR,
Marc-André Lureau <=
- [PATCH v4 34/37] omap-gpio: remove PROP_PTR, Marc-André Lureau, 2019/11/20
- [PATCH v4 35/37] qdev: remove PROP_MEMORY_REGION, Marc-André Lureau, 2019/11/20
- [PATCH v4 36/37] qdev: remove QDEV_PROP_PTR, Marc-André Lureau, 2019/11/20
- [PATCH v4 37/37] qdev/qom: remove some TODO limitations now that PROP_PTR is gone, Marc-André Lureau, 2019/11/20