[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 31/34] i.MX7D: Compute clock frequency for the fixed frequency clo
From: |
Peter Maydell |
Subject: |
[PULL 31/34] i.MX7D: Compute clock frequency for the fixed frequency clocks. |
Date: |
Thu, 5 Jan 2023 16:44:14 +0000 |
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
- [PULL 22/34] target/arm: Remove unused includes from helper.c, (continued)
- [PULL 22/34] target/arm: Remove unused includes from helper.c, Peter Maydell, 2023/01/05
- [PULL 20/34] target/arm: Fix checkpatch brace errors in helper.c, Peter Maydell, 2023/01/05
- [PULL 27/34] target/arm: align exposed ID registers with Linux, Peter Maydell, 2023/01/05
- [PULL 26/34] hw/arm/nseries: Silent -Wmissing-field-initializers warning, Peter Maydell, 2023/01/05
- [PULL 30/34] i.MX7D: Connect GPT timers to IRQ, Peter Maydell, 2023/01/05
- [PULL 33/34] i.MX7D: Connect IRQs to GPIO devices., Peter Maydell, 2023/01/05
- [PULL 11/34] hw/timer/imx_epit: cleanup CR defines, Peter Maydell, 2023/01/05
- [PULL 34/34] hw/net: Fix read of uninitialized memory in imx_fec., Peter Maydell, 2023/01/05
- [PULL 18/34] target/arm: Fix checkpatch comment style warnings in helper.c, Peter Maydell, 2023/01/05
- [PULL 29/34] hw/arm/smmu-common: Avoid using inlined functions with external linkage, Peter Maydell, 2023/01/05
- [PULL 31/34] i.MX7D: Compute clock frequency for the fixed frequency clocks.,
Peter Maydell <=
- [PULL 28/34] hw/arm/smmu-common: Reduce smmu_inv_notifiers_mr() scope, Peter Maydell, 2023/01/05
- [PULL 32/34] i.MX6UL: Add a specific GPT timer instance for the i.MX6UL, Peter Maydell, 2023/01/05
- Re: [PULL 00/34] target-arm queue, Peter Maydell, 2023/01/06