qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: qemu-devel@nongnu.org
Cc: "Damien Hedde" <damien.hedde@greensocs.com>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	"Luc Michel" <luc@lmichel.fr>,
	"Eduardo Habkost" <ehabkost@redhat.com>,
	"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
	"Andrew Baumann" <Andrew.Baumann@microsoft.com>,
	qemu-arm@nongnu.org, "Paolo Bonzini" <pbonzini@redhat.com>
Subject: [RFC PATCH-for-6.1 7/9] hw/misc/bcm2835_cprman: Feed 'xosc' from the board
Date: Fri,  9 Apr 2021 08:23:59 +0200	[thread overview]
Message-ID: <20210409062401.2350436-8-f4bug@amsat.org> (raw)
In-Reply-To: <20210409062401.2350436-1-f4bug@amsat.org>

The XOsc signal isn't a part of the CPRMAN, but comes from a
crystal oscillator external to the SoC.

Create the oscillator on the board, and propagate it to the
CPRMAN.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 include/hw/misc/bcm2835_cprman.h | 1 -
 hw/arm/bcm2835_peripherals.c     | 1 +
 hw/arm/bcm2836.c                 | 1 +
 hw/arm/raspi.c                   | 4 ++++
 hw/misc/bcm2835_cprman.c         | 5 +----
 5 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/include/hw/misc/bcm2835_cprman.h b/include/hw/misc/bcm2835_cprman.h
index 2996ccb4632..52f76489f36 100644
--- a/include/hw/misc/bcm2835_cprman.h
+++ b/include/hw/misc/bcm2835_cprman.h
@@ -201,7 +201,6 @@ struct BCM2835CprmanState {
     CprmanDsi0HsckMuxState dsi0hsck_mux;
 
     uint32_t regs[CPRMAN_NUM_REGS];
-    uint32_t xosc_freq;
 
     Clock *xosc;
 };
diff --git a/hw/arm/bcm2835_peripherals.c b/hw/arm/bcm2835_peripherals.c
index dcff13433e5..a82f2b42f5a 100644
--- a/hw/arm/bcm2835_peripherals.c
+++ b/hw/arm/bcm2835_peripherals.c
@@ -123,6 +123,7 @@ static void bcm2835_peripherals_init(Object *obj)
 
     /* CPRMAN clock manager */
     object_initialize_child(obj, "cprman", &s->cprman, TYPE_BCM2835_CPRMAN);
+    qdev_alias_clock(DEVICE(&s->cprman), "xosc-in", DEVICE(s), "xosc-in");
 
     object_property_add_const_link(OBJECT(&s->dwc2), "dma-mr",
                                    OBJECT(&s->gpu_bus_mr));
diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c
index de7ade2878e..6c238ecb949 100644
--- a/hw/arm/bcm2836.c
+++ b/hw/arm/bcm2836.c
@@ -63,6 +63,7 @@ static void bcm2836_init(Object *obj)
                               "board-rev");
     object_property_add_alias(obj, "vcram-size", OBJECT(&s->peripherals),
                               "vcram-size");
+    qdev_alias_clock(DEVICE(&s->peripherals), "xosc-in", DEVICE(s), "xosc-in");
 }
 
 static bool bcm283x_common_realize(DeviceState *dev, Error **errp)
diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
index 990509d3852..a89f7e17c3a 100644
--- a/hw/arm/raspi.c
+++ b/hw/arm/raspi.c
@@ -40,6 +40,7 @@ struct RaspiMachineState {
     /*< private >*/
     MachineState parent_obj;
     /*< public >*/
+    Clock *xosc;
     BCM283XState soc;
     struct arm_boot_info binfo;
 };
@@ -277,12 +278,15 @@ static void raspi_machine_init(MachineState *machine)
     memory_region_add_subregion_overlap(get_system_memory(), 0,
                                         machine->ram, 0);
 
+    s->xosc = machine_create_constant_clock(machine, "xosc", 19200000);
+
     /* Setup the SOC */
     object_initialize_child(OBJECT(machine), "soc", &s->soc,
                             board_soc_type(board_rev));
     object_property_add_const_link(OBJECT(&s->soc), "ram", OBJECT(machine->ram));
     object_property_set_int(OBJECT(&s->soc), "board-rev", board_rev,
                             &error_abort);
+    qdev_connect_clock_in(DEVICE(&s->soc), "xosc-in", s->xosc);
     qdev_realize(DEVICE(&s->soc), NULL, &error_abort);
 
     /* Create and plug in the SD cards */
diff --git a/hw/misc/bcm2835_cprman.c b/hw/misc/bcm2835_cprman.c
index 5039b7632b4..33f15d99f63 100644
--- a/hw/misc/bcm2835_cprman.c
+++ b/hw/misc/bcm2835_cprman.c
@@ -637,8 +637,6 @@ static void cprman_reset(DeviceState *dev)
     for (i = 0; i < CPRMAN_NUM_CLOCK_MUX; i++) {
         device_cold_reset(DEVICE(&s->clock_muxes[i]));
     }
-
-    clock_update_hz(s->xosc, s->xosc_freq);
 }
 
 static void cprman_init(Object *obj)
@@ -677,7 +675,7 @@ static void cprman_init(Object *obj)
         g_free(alias);
     }
 
-    s->xosc = clock_new(obj, "xosc");
+    s->xosc = qdev_init_clock_in(DEVICE(obj), "xosc-in", NULL, s, ClockUpdate);
 
     memory_region_init_io(&s->iomem, obj, &cprman_ops,
                           s, "bcm2835-cprman", 0x2000);
@@ -776,7 +774,6 @@ static const VMStateDescription cprman_vmstate = {
 };
 
 static Property cprman_properties[] = {
-    DEFINE_PROP_UINT32("xosc-freq-hz", BCM2835CprmanState, xosc_freq, 19200000),
     DEFINE_PROP_END_OF_LIST()
 };
 
-- 
2.26.3



  parent reply	other threads:[~2021-04-09  6:34 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-09  6:23 [RFC PATCH-for-6.1 0/9] hw/clock: Strengthen machine (non-qdev) clock propagation Philippe Mathieu-Daudé
2021-04-09  6:23 ` [RFC PATCH-for-6.1 1/9] hw/core/clock: Increase clock propagation trace events verbosity Philippe Mathieu-Daudé
2021-04-09  6:23 ` [RFC PATCH-for-6.1 2/9] hw/core/machine: Add machine_create_constant_clock() helper Philippe Mathieu-Daudé
2021-04-09  6:23 ` [RFC PATCH-for-6.1 3/9] hw/arm: Use new " Philippe Mathieu-Daudé
2021-04-09  6:23 ` [RFC PATCH-for-6.1 4/9] hw/mips: " Philippe Mathieu-Daudé
2021-04-09  6:23 ` [RFC PATCH-for-6.1 5/9] hw/core/qdev-clock: Add qdev_ground_clock() helper Philippe Mathieu-Daudé
2021-04-19 14:22   ` Peter Maydell
2021-04-09  6:23 ` [RFC PATCH-for-6.1 6/9] hw/misc/bcm2835_cprman: Use " Philippe Mathieu-Daudé
2021-04-09  6:23 ` Philippe Mathieu-Daudé [this message]
2021-04-19 14:24   ` [RFC PATCH-for-6.1 7/9] hw/misc/bcm2835_cprman: Feed 'xosc' from the board Peter Maydell
2021-04-09  6:24 ` [RFC PATCH-for-6.1 8/9] hw/clock: Declare clock_new() internally Philippe Mathieu-Daudé
2021-04-19 14:26   ` Peter Maydell
2021-04-20  9:27     ` Philippe Mathieu-Daudé
2021-04-09  6:24 ` [RFC PATCH-for-6.1 9/9] hw/core/machine: Reset machine clocks using qemu_register_reset() Philippe Mathieu-Daudé
2021-04-19 14:27   ` Peter Maydell
2021-04-09 13:12 ` [RFC PATCH-for-6.1 0/9] hw/clock: Strengthen machine (non-qdev) clock propagation Philippe Mathieu-Daudé
2021-04-09 14:11   ` Philippe Mathieu-Daudé
2021-04-09 14:20     ` Philippe Mathieu-Daudé
2021-04-10 13:19 ` Luc Michel
2021-04-10 13:53   ` Philippe Mathieu-Daudé
2021-04-10 15:15     ` Peter Maydell
2021-04-10 16:14       ` Philippe Mathieu-Daudé
2021-04-12 10:11       ` Peter Maydell
2021-04-12 10:31         ` Philippe Mathieu-Daudé
2021-04-12 10:44           ` Peter Maydell
2021-04-12 11:00             ` Philippe Mathieu-Daudé
2021-04-13 19:43             ` Eduardo Habkost
2021-05-03 15:20               ` Igor Mammedov
2021-05-03 16:37                 ` Philippe Mathieu-Daudé
2021-04-19 19:39     ` Luc Michel

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=20210409062401.2350436-8-f4bug@amsat.org \
    --to=f4bug@amsat.org \
    --cc=Andrew.Baumann@microsoft.com \
    --cc=damien.hedde@greensocs.com \
    --cc=ehabkost@redhat.com \
    --cc=luc@lmichel.fr \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@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).