All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Marc-André Lureau" <marcandre.lureau@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Corey Minyard" <cminyard@mvista.com>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Jason Wang" <jasowang@redhat.com>,
	"Mark Cave-Ayland" <mark.cave-ayland@ilande.co.uk>,
	"KONRAD Frederic" <frederic.konrad@adacore.com>,
	"Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
	"Paul Burton" <pburton@wavecomp.com>,
	"Aleksandar Rikalo" <arikalo@wavecomp.com>,
	"Magnus Damm" <magnus.damm@gmail.com>,
	"Hervé Poussineau" <hpoussin@reactos.org>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Artyom Tarasenko" <atar4qemu@gmail.com>,
	"Eduardo Habkost" <ehabkost@redhat.com>,
	"Fabien Chouteau" <chouteau@adacore.com>,
	qemu-arm@nongnu.org, "Richard Henderson" <rth@twiddle.net>,
	"Daniel P. Berrangé" <berrange@redhat.com>,
	qemu-ppc@nongnu.org,
	"Aleksandar Markovic" <amarkovic@wavecomp.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Aurelien Jarno" <aurelien@aurel32.net>
Subject: [PATCH v3 31/33] omap-gpio: remove PROP_PTR
Date: Wed, 23 Oct 2019 19:31:52 +0200	[thread overview]
Message-ID: <20191023173154.30051-32-marcandre.lureau@redhat.com> (raw)
In-Reply-To: <20191023173154.30051-1-marcandre.lureau@redhat.com>

Since clocks are not QOM objects, replace PROP_PTR of clocks with
setters methods.

Move/adapt the existing TODO comment about a clock framework.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 hw/arm/omap1.c        |  2 +-
 hw/arm/omap2.c        | 13 +++++++------
 hw/gpio/omap_gpio.c   | 42 +++++++++++++++---------------------------
 include/hw/arm/omap.h | 33 +++++++++++++++++++++++++++++----
 4 files changed, 52 insertions(+), 38 deletions(-)

diff --git a/hw/arm/omap1.c b/hw/arm/omap1.c
index 807e5f70d1..761cc17ea9 100644
--- a/hw/arm/omap1.c
+++ b/hw/arm/omap1.c
@@ -4012,7 +4012,7 @@ struct omap_mpu_state_s *omap310_mpu_init(MemoryRegion *dram,
 
     s->gpio = qdev_create(NULL, "omap-gpio");
     qdev_prop_set_int32(s->gpio, "mpu_model", s->mpu_model);
-    qdev_prop_set_ptr(s->gpio, "clk", omap_findclk(s, "arm_gpio_ck"));
+    omap_gpio_set_clk(OMAP1_GPIO(s->gpio), omap_findclk(s, "arm_gpio_ck"));
     qdev_init_nofail(s->gpio);
     sysbus_connect_irq(SYS_BUS_DEVICE(s->gpio), 0,
                        qdev_get_gpio_in(s->ih[0], OMAP_INT_GPIO_BANK1));
diff --git a/hw/arm/omap2.c b/hw/arm/omap2.c
index 171e2d0472..e1c11de5ce 100644
--- a/hw/arm/omap2.c
+++ b/hw/arm/omap2.c
@@ -2449,13 +2449,14 @@ struct omap_mpu_state_s *omap2420_mpu_init(MemoryRegion *sdram,
 
     s->gpio = qdev_create(NULL, "omap2-gpio");
     qdev_prop_set_int32(s->gpio, "mpu_model", s->mpu_model);
-    qdev_prop_set_ptr(s->gpio, "iclk", omap_findclk(s, "gpio_iclk"));
-    qdev_prop_set_ptr(s->gpio, "fclk0", omap_findclk(s, "gpio1_dbclk"));
-    qdev_prop_set_ptr(s->gpio, "fclk1", omap_findclk(s, "gpio2_dbclk"));
-    qdev_prop_set_ptr(s->gpio, "fclk2", omap_findclk(s, "gpio3_dbclk"));
-    qdev_prop_set_ptr(s->gpio, "fclk3", omap_findclk(s, "gpio4_dbclk"));
+    omap2_gpio_set_iclk(OMAP2_GPIO(s->gpio), omap_findclk(s, "gpio_iclk"));
+    omap2_gpio_set_fclk(OMAP2_GPIO(s->gpio), 0, omap_findclk(s, "gpio1_dbclk"));
+    omap2_gpio_set_fclk(OMAP2_GPIO(s->gpio), 1, omap_findclk(s, "gpio2_dbclk"));
+    omap2_gpio_set_fclk(OMAP2_GPIO(s->gpio), 2, omap_findclk(s, "gpio3_dbclk"));
+    omap2_gpio_set_fclk(OMAP2_GPIO(s->gpio), 3, omap_findclk(s, "gpio4_dbclk"));
     if (s->mpu_model == omap2430) {
-        qdev_prop_set_ptr(s->gpio, "fclk4", omap_findclk(s, "gpio5_dbclk"));
+        omap2_gpio_set_fclk(OMAP2_GPIO(s->gpio), 4,
+                            omap_findclk(s, "gpio5_dbclk"));
     }
     qdev_init_nofail(s->gpio);
     busdev = SYS_BUS_DEVICE(s->gpio);
diff --git a/hw/gpio/omap_gpio.c b/hw/gpio/omap_gpio.c
index 41e1aa798c..85c16897ae 100644
--- a/hw/gpio/omap_gpio.c
+++ b/hw/gpio/omap_gpio.c
@@ -40,10 +40,6 @@ struct omap_gpio_s {
     uint16_t pins;
 };
 
-#define TYPE_OMAP1_GPIO "omap-gpio"
-#define OMAP1_GPIO(obj) \
-    OBJECT_CHECK(struct omap_gpif_s, (obj), TYPE_OMAP1_GPIO)
-
 struct omap_gpif_s {
     SysBusDevice parent_obj;
 
@@ -212,10 +208,6 @@ struct omap2_gpio_s {
     uint8_t delay;
 };
 
-#define TYPE_OMAP2_GPIO "omap2-gpio"
-#define OMAP2_GPIO(obj) \
-    OBJECT_CHECK(struct omap2_gpif_s, (obj), TYPE_OMAP2_GPIO)
-
 struct omap2_gpif_s {
     SysBusDevice parent_obj;
 
@@ -747,21 +739,13 @@ static void omap2_gpio_realize(DeviceState *dev, Error **errp)
     }
 }
 
-/* Using qdev pointer properties for the clocks is not ideal.
- * qdev should support a generic means of defining a 'port' with
- * an arbitrary interface for connecting two devices. Then we
- * could reframe the omap clock API in terms of clock ports,
- * and get some type safety. For now the best qdev provides is
- * passing an arbitrary pointer.
- * (It's not possible to pass in the string which is the clock
- * name, because this device does not have the necessary information
- * (ie the struct omap_mpu_state_s*) to do the clockname to pointer
- * translation.)
- */
+void omap_gpio_set_clk(omap_gpif *gpio, omap_clk clk)
+{
+    gpio->clk = clk;
+}
 
 static Property omap_gpio_properties[] = {
     DEFINE_PROP_INT32("mpu_model", struct omap_gpif_s, mpu_model, 0),
-    DEFINE_PROP_PTR("clk", struct omap_gpif_s, clk),
     DEFINE_PROP_END_OF_LIST(),
 };
 
@@ -784,15 +768,19 @@ static const TypeInfo omap_gpio_info = {
     .class_init    = omap_gpio_class_init,
 };
 
+void omap2_gpio_set_iclk(omap2_gpif *gpio, omap_clk clk)
+{
+    gpio->iclk = clk;
+}
+
+void omap2_gpio_set_fclk(omap2_gpif *gpio, uint8_t i, omap_clk clk)
+{
+    assert(i <= 5);
+    gpio->fclk[i] = clk;
+}
+
 static Property omap2_gpio_properties[] = {
     DEFINE_PROP_INT32("mpu_model", struct omap2_gpif_s, mpu_model, 0),
-    DEFINE_PROP_PTR("iclk", struct omap2_gpif_s, iclk),
-    DEFINE_PROP_PTR("fclk0", struct omap2_gpif_s, fclk[0]),
-    DEFINE_PROP_PTR("fclk1", struct omap2_gpif_s, fclk[1]),
-    DEFINE_PROP_PTR("fclk2", struct omap2_gpif_s, fclk[2]),
-    DEFINE_PROP_PTR("fclk3", struct omap2_gpif_s, fclk[3]),
-    DEFINE_PROP_PTR("fclk4", struct omap2_gpif_s, fclk[4]),
-    DEFINE_PROP_PTR("fclk5", struct omap2_gpif_s, fclk[5]),
     DEFINE_PROP_END_OF_LIST(),
 };
 
diff --git a/include/hw/arm/omap.h b/include/hw/arm/omap.h
index 39a295ba20..6be386d0e2 100644
--- a/include/hw/arm/omap.h
+++ b/include/hw/arm/omap.h
@@ -77,6 +77,16 @@ typedef struct omap_intr_handler_s omap_intr_handler;
 /*
  * TODO: Ideally we should have a clock framework that
  * let us wire these clocks up with QOM properties or links.
+ *
+ * qdev should support a generic means of defining a 'port' with
+ * an arbitrary interface for connecting two devices. Then we
+ * could reframe the omap clock API in terms of clock ports,
+ * and get some type safety. For now the best qdev provides is
+ * passing an arbitrary pointer.
+ * (It's not possible to pass in the string which is the clock
+ * name, because this device does not have the necessary information
+ * (ie the struct omap_mpu_state_s*) to do the clockname to pointer
+ * translation.)
  */
 void omap_intc_set_iclk(omap_intr_handler *intc, omap_clk clk);
 void omap_intc_set_fclk(omap_intr_handler *intc, omap_clk clk);
@@ -87,13 +97,28 @@ void omap_intc_set_fclk(omap_intr_handler *intc, omap_clk clk);
 
 typedef struct OMAPI2CState OMAPI2CState;
 
-/*
- * TODO: Ideally we should have a clock framework that
- * let us wire these clocks up with QOM properties or links.
- */
+/* TODO: clock framework (see above) */
 void omap_i2c_set_iclk(OMAPI2CState *i2c, omap_clk clk);
 void omap_i2c_set_fclk(OMAPI2CState *i2c, omap_clk clk);
 
+/* omap_gpio.c */
+#define TYPE_OMAP1_GPIO "omap-gpio"
+#define OMAP1_GPIO(obj)                                         \
+    OBJECT_CHECK(struct omap_gpif_s, (obj), TYPE_OMAP1_GPIO)
+
+#define TYPE_OMAP2_GPIO "omap2-gpio"
+#define OMAP2_GPIO(obj)                                         \
+    OBJECT_CHECK(struct omap2_gpif_s, (obj), TYPE_OMAP2_GPIO)
+
+typedef struct omap_gpif_s omap_gpif;
+typedef struct omap2_gpif_s omap2_gpif;
+
+/* TODO: clock framework (see above) */
+void omap_gpio_set_clk(omap_gpif *gpio, omap_clk clk);
+
+void omap2_gpio_set_iclk(omap2_gpif *gpio, omap_clk clk);
+void omap2_gpio_set_fclk(omap2_gpif *gpio, uint8_t i, omap_clk clk);
+
 /* OMAP2 l4 Interconnect */
 struct omap_l4_s;
 struct omap_l4_region_s {
-- 
2.23.0.606.g08da6496b6



  parent reply	other threads:[~2019-10-23 20:58 UTC|newest]

Thread overview: 99+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-23 17:31 [PATCH v3 00/33] Clean-ups: qom-ify serial and remove QDEV_PROP_PTR Marc-André Lureau
2019-10-23 17:31 ` [PATCH v3 01/33] qdev: remove unused qdev_prop_int64 Marc-André Lureau
2019-11-18 14:01   ` Peter Maydell
2019-11-20  3:36     ` Marc-André Lureau
2019-10-23 17:31 ` [PATCH v3 02/33] sysbus: remove unused sysbus_try_create* Marc-André Lureau
2019-10-23 22:35   ` Philippe Mathieu-Daudé
2019-11-18 14:02   ` Peter Maydell
2019-10-23 17:31 ` [PATCH v3 03/33] sysbus: remove outdated comment Marc-André Lureau
2019-10-23 22:36   ` Philippe Mathieu-Daudé
2019-10-23 17:31 ` [PATCH v3 04/33] chardev: generate an internal id when none given Marc-André Lureau
2019-11-18 14:12   ` Peter Maydell
2019-11-18 18:54     ` Marc-André Lureau
2019-10-23 17:31 ` [PATCH v3 05/33] serial-pci-multi: factor out multi_serial_get_nr_ports Marc-André Lureau
2019-10-23 22:41   ` Philippe Mathieu-Daudé
2019-10-24  9:59     ` Marc-André Lureau
2019-10-23 17:31 ` [PATCH v3 06/33] serial: initial qom-ification Marc-André Lureau
2019-10-24  8:48   ` Marc-André Lureau
2019-10-23 17:31 ` [PATCH v3 07/33] serial: register vmsd with DeviceClass Marc-André Lureau
2019-11-18 14:21   ` Peter Maydell
2019-11-19 10:22     ` Marc-André Lureau
2019-11-19 10:33       ` Peter Maydell
2019-11-19 11:57         ` Marc-André Lureau
2019-11-20 18:54           ` Dr. David Alan Gilbert
2019-11-21  6:49             ` Marc-André Lureau
2019-10-23 17:31 ` [PATCH v3 08/33] serial: add "chardev" property Marc-André Lureau
2019-10-23 22:39   ` Philippe Mathieu-Daudé
2019-11-18 14:23   ` Peter Maydell
2019-10-23 17:31 ` [PATCH v3 09/33] serial: add "baudbase" property Marc-André Lureau
2019-10-23 22:40   ` Philippe Mathieu-Daudé
2019-11-18 14:26   ` Peter Maydell
2019-10-23 17:31 ` [PATCH v3 10/33] serial: add "instance-id" property Marc-André Lureau
2019-11-18 14:29   ` Peter Maydell
2019-11-19 10:32     ` Marc-André Lureau
2019-11-20  9:06   ` Marc-André Lureau
2019-10-23 17:31 ` [PATCH v3 11/33] serial: realize the serial device Marc-André Lureau
2019-10-23 17:31 ` [PATCH v3 12/33] serial: replace serial_exit_core() with unrealize Marc-André Lureau
2019-11-18 14:32   ` Peter Maydell
2019-11-20 12:32   ` Philippe Mathieu-Daudé
2019-10-23 17:31 ` [PATCH v3 13/33] serial: start making SerialMM a sysbus device Marc-André Lureau
2019-11-18 14:43   ` Peter Maydell
2019-11-20  7:34     ` Marc-André Lureau
2019-11-20 10:36       ` Peter Maydell
2019-11-20 10:40         ` Marc-André Lureau
2019-11-20 10:58           ` Peter Maydell
2019-11-20 11:03             ` Marc-André Lureau
2019-10-23 17:31 ` [PATCH v3 14/33] serial-mm: add "regshift" property Marc-André Lureau
2019-11-18 14:54   ` Peter Maydell
2019-11-20  7:53     ` Marc-André Lureau
2019-11-20 10:43       ` Peter Maydell
2019-10-23 17:31 ` [PATCH v3 15/33] serial-mm: add endianness property Marc-André Lureau
2019-11-18 15:02   ` Peter Maydell
2019-11-18 15:07   ` Peter Maydell
2019-11-20  7:59     ` Marc-André Lureau
2019-11-20 12:57   ` Philippe Mathieu-Daudé
2019-10-23 17:31 ` [PATCH v3 16/33] serial-mm: use sysbus facilities Marc-André Lureau
2019-11-18 15:09   ` Peter Maydell
2019-11-20  8:30     ` Marc-André Lureau
2019-11-20 10:46       ` Peter Maydell
2019-10-23 17:31 ` [PATCH v3 17/33] serial: make SerialIO a sysbus device Marc-André Lureau
2019-11-18 15:16   ` Peter Maydell
2019-11-20  8:41     ` Marc-André Lureau
2019-10-23 17:31 ` [PATCH v3 18/33] mips: inline serial_init Marc-André Lureau
2019-11-18 15:24   ` Peter Maydell
2019-11-20 11:14     ` Marc-André Lureau
2019-11-20  0:07   ` Aleksandar Markovic
2019-10-23 17:31 ` [PATCH v3 19/33] sm501: make SerialMM a child, export chardev property Marc-André Lureau
2019-10-23 22:57   ` Philippe Mathieu-Daudé
2019-10-24 10:28     ` Marc-André Lureau
2019-10-23 17:31 ` [PATCH v3 20/33] vmmouse: replace PROP_PTR with PROP_LINK Marc-André Lureau
2019-10-23 22:59   ` Philippe Mathieu-Daudé
2019-10-23 17:31 ` [PATCH v3 21/33] lance: " Marc-André Lureau
2019-10-23 23:00   ` Philippe Mathieu-Daudé
2019-10-24 11:09     ` Marc-André Lureau
2019-10-24 11:47       ` Philippe Mathieu-Daudé
2019-10-24 11:52         ` Peter Maydell
2019-10-24 18:07           ` Eduardo Habkost
2019-10-25  7:31             ` Peter Maydell
2019-10-24 12:25         ` Marc-André Lureau
2019-10-23 17:31 ` [PATCH v3 22/33] etraxfs: remove PROP_PTR usage Marc-André Lureau
2019-11-18 15:28   ` Peter Maydell
2019-10-23 17:31 ` [PATCH v3 23/33] dp8393x: replace PROP_PTR with PROP_LINK Marc-André Lureau
2019-10-23 23:02   ` Philippe Mathieu-Daudé
2019-10-24 11:12     ` Marc-André Lureau
2019-10-24 11:48       ` Philippe Mathieu-Daudé
2019-10-23 17:31 ` [PATCH v3 24/33] leon3: use qemu_irq framework instead of callback as property Marc-André Lureau
2019-11-18 14:15   ` KONRAD Frederic
2019-11-18 15:34   ` Peter Maydell
2019-10-23 17:31 ` [PATCH v3 25/33] sparc: move PIL irq handling to cpu.c Marc-André Lureau
2019-11-18 15:38   ` Peter Maydell
2019-10-23 17:31 ` [PATCH v3 26/33] RFC: mips/cps: fix setting saar property Marc-André Lureau
2019-10-23 17:31 ` [PATCH v3 27/33] cris: improve passing PIC interrupt vector to the CPU Marc-André Lureau
2019-11-18 15:40   ` Peter Maydell
2019-10-23 17:31 ` [PATCH v3 28/33] smbus-eeprom: remove PROP_PTR Marc-André Lureau
2019-10-23 17:31 ` [PATCH v3 29/33] omap-intc: " Marc-André Lureau
2019-10-23 17:31 ` [PATCH v3 30/33] omap-i2c: " Marc-André Lureau
2019-10-23 17:31 ` Marc-André Lureau [this message]
2019-10-23 17:31 ` [PATCH v3 32/33] qdev: remove PROP_MEMORY_REGION Marc-André Lureau
2019-10-23 23:07   ` Philippe Mathieu-Daudé
2019-10-23 17:31 ` [PATCH v3 33/33] qdev: remove QDEV_PROP_PTR Marc-André Lureau

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=20191023173154.30051-32-marcandre.lureau@redhat.com \
    --to=marcandre.lureau@redhat.com \
    --cc=amarkovic@wavecomp.com \
    --cc=arikalo@wavecomp.com \
    --cc=atar4qemu@gmail.com \
    --cc=aurelien@aurel32.net \
    --cc=berrange@redhat.com \
    --cc=chouteau@adacore.com \
    --cc=cminyard@mvista.com \
    --cc=edgar.iglesias@gmail.com \
    --cc=ehabkost@redhat.com \
    --cc=frederic.konrad@adacore.com \
    --cc=hpoussin@reactos.org \
    --cc=jasowang@redhat.com \
    --cc=magnus.damm@gmail.com \
    --cc=mark.cave-ayland@ilande.co.uk \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=pburton@wavecomp.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=rth@twiddle.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.