All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-devel@nongnu.org
Subject: [PULL 31/34] i.MX7D: Compute clock frequency for the fixed frequency clocks.
Date: Thu,  5 Jan 2023 16:44:14 +0000	[thread overview]
Message-ID: <20230105164417.3994639-32-peter.maydell@linaro.org> (raw)
In-Reply-To: <20230105164417.3994639-1-peter.maydell@linaro.org>

From: Jean-Christophe Dubois <jcd@tribudubois.net>

CCM derived clocks will have to be added later.

Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 hw/misc/imx7_ccm.c | 49 +++++++++++++++++++++++++++++++++++++---------
 1 file changed, 40 insertions(+), 9 deletions(-)

diff --git a/hw/misc/imx7_ccm.c b/hw/misc/imx7_ccm.c
index 075159e497b..f135ec7b7e4 100644
--- a/hw/misc/imx7_ccm.c
+++ b/hw/misc/imx7_ccm.c
@@ -16,6 +16,10 @@
 #include "hw/misc/imx7_ccm.h"
 #include "migration/vmstate.h"
 
+#include "trace.h"
+
+#define CKIH_FREQ 24000000 /* 24MHz crystal input */
+
 static void imx7_analog_reset(DeviceState *dev)
 {
     IMX7AnalogState *s = IMX7_ANALOG(dev);
@@ -219,16 +223,43 @@ static const VMStateDescription vmstate_imx7_ccm = {
 static uint32_t imx7_ccm_get_clock_frequency(IMXCCMState *dev, IMXClk clock)
 {
     /*
-     * This function is "consumed" by GPT emulation code, however on
-     * i.MX7 each GPT block can have their own clock root. This means
-     * that this functions needs somehow to know requester's identity
-     * and the way to pass it: be it via additional IMXClk constants
-     * or by adding another argument to this method needs to be
-     * figured out
+     * This function is "consumed" by GPT emulation code. Some clocks
+     * have fixed frequencies and we can provide requested frequency
+     * easily. However for CCM provided clocks (like IPG) each GPT
+     * timer can have its own clock root.
+     * This means we need additionnal information when calling this
+     * function to know the requester's identity.
      */
-    qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: Not implemented\n",
-                  TYPE_IMX7_CCM, __func__);
-    return 0;
+    uint32_t freq = 0;
+
+    switch (clock) {
+    case CLK_NONE:
+        break;
+    case CLK_32k:
+        freq = CKIL_FREQ;
+        break;
+    case CLK_HIGH:
+        freq = CKIH_FREQ;
+        break;
+    case CLK_IPG:
+    case CLK_IPG_HIGH:
+        /*
+         * For now we don't have a way to figure out the device this
+         * function is called for. Until then the IPG derived clocks
+         * are left unimplemented.
+         */
+        qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: Clock %d Not implemented\n",
+                      TYPE_IMX7_CCM, __func__, clock);
+        break;
+    default:
+        qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: unsupported clock %d\n",
+                      TYPE_IMX7_CCM, __func__, clock);
+        break;
+    }
+
+    trace_ccm_clock_freq(clock, freq);
+
+    return freq;
 }
 
 static void imx7_ccm_class_init(ObjectClass *klass, void *data)
-- 
2.25.1



  parent reply	other threads:[~2023-01-05 17:07 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-05 16:43 [PULL 00/34] target-arm queue Peter Maydell
2023-01-05 16:43 ` [PULL 01/34] target/arm:Set lg_page_size to 0 if either S1 or S2 asks for it Peter Maydell
2023-01-05 16:43 ` [PULL 02/34] target/arm: Don't add all MIDR aliases for cores that implement PMSA Peter Maydell
2023-01-05 16:43 ` [PULL 03/34] target/arm: Make RVBAR available for all ARMv8 CPUs Peter Maydell
2023-01-05 16:43 ` [PULL 04/34] target/arm: Make stage_2_format for cache attributes optional Peter Maydell
2023-01-05 16:43 ` [PULL 05/34] target/arm: Enable TTBCR_EAE for ARMv8-R AArch32 Peter Maydell
2023-01-05 16:43 ` [PULL 06/34] target/arm: Add PMSAv8r registers Peter Maydell
2023-01-05 16:43 ` [PULL 07/34] target/arm: Add PMSAv8r functionality Peter Maydell
2023-01-05 16:43 ` [PULL 08/34] target/arm: Add ARM Cortex-R52 CPU Peter Maydell
2023-01-05 16:43 ` [PULL 09/34] target/arm: fix handling of HLT semihosting in system mode Peter Maydell
2023-01-05 16:43 ` [PULL 10/34] hw/timer/imx_epit: improve comments Peter Maydell
2023-01-05 16:43 ` [PULL 11/34] hw/timer/imx_epit: cleanup CR defines Peter Maydell
2023-01-05 16:43 ` [PULL 12/34] hw/timer/imx_epit: define SR_OCIF Peter Maydell
2023-01-05 16:43 ` [PULL 13/34] hw/timer/imx_epit: update interrupt state on CR write access Peter Maydell
2023-01-05 16:43 ` [PULL 14/34] hw/timer/imx_epit: hard reset initializes CR with 0 Peter Maydell
2023-01-05 16:43 ` [PULL 15/34] hw/timer/imx_epit: factor out register write handlers Peter Maydell
2023-01-05 16:43 ` [PULL 16/34] hw/timer/imx_epit: remove explicit fields cnt and freq Peter Maydell
2023-01-05 16:44 ` [PULL 17/34] hw/timer/imx_epit: fix compare timer handling Peter Maydell
2023-01-05 16:44 ` [PULL 18/34] target/arm: Fix checkpatch comment style warnings in helper.c Peter Maydell
2023-01-05 16:44 ` [PULL 19/34] target/arm: Fix checkpatch space errors " Peter Maydell
2023-01-05 16:44 ` [PULL 20/34] target/arm: Fix checkpatch brace " Peter Maydell
2023-01-05 16:44 ` [PULL 21/34] target/arm: Remove unused includes from m_helper.c Peter Maydell
2023-01-05 16:44 ` [PULL 22/34] target/arm: Remove unused includes from helper.c Peter Maydell
2023-01-05 16:44 ` [PULL 23/34] target/arm: cleanup cpu includes Peter Maydell
2023-01-05 16:44 ` [PULL 24/34] hw/input/tsc2xxx: Constify set_transform()'s MouseTransformInfo arg Peter Maydell
2023-01-05 16:44 ` [PULL 25/34] hw/arm/nseries: Constify various read-only arrays Peter Maydell
2023-01-05 16:44 ` [PULL 26/34] hw/arm/nseries: Silent -Wmissing-field-initializers warning Peter Maydell
2023-01-05 16:44 ` [PULL 27/34] target/arm: align exposed ID registers with Linux Peter Maydell
2023-01-05 16:44 ` [PULL 28/34] hw/arm/smmu-common: Reduce smmu_inv_notifiers_mr() scope Peter Maydell
2023-01-05 16:44 ` [PULL 29/34] hw/arm/smmu-common: Avoid using inlined functions with external linkage Peter Maydell
2023-01-05 16:44 ` [PULL 30/34] i.MX7D: Connect GPT timers to IRQ Peter Maydell
2023-01-05 16:44 ` Peter Maydell [this message]
2023-01-05 16:44 ` [PULL 32/34] i.MX6UL: Add a specific GPT timer instance for the i.MX6UL Peter Maydell
2023-01-05 16:44 ` [PULL 33/34] i.MX7D: Connect IRQs to GPIO devices Peter Maydell
2023-01-05 16:44 ` [PULL 34/34] hw/net: Fix read of uninitialized memory in imx_fec Peter Maydell
2023-01-06 12:10 ` [PULL 00/34] target-arm queue Peter Maydell

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=20230105164417.3994639-32-peter.maydell@linaro.org \
    --to=peter.maydell@linaro.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 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.