From patchwork Thu Jan 5 16:44:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 639299 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp331224pvb; Thu, 5 Jan 2023 09:07:03 -0800 (PST) X-Google-Smtp-Source: AMrXdXuXpHqMvsq6hjeJHNLVRc/KhcE/tjAiIBB6VoA+DX2bxl3kKboyk2grxkDQ+wn+Le8HSDaN X-Received: by 2002:ac8:4f49:0:b0:3a8:991:bfa5 with SMTP id i9-20020ac84f49000000b003a80991bfa5mr76233832qtw.44.1672938423635; Thu, 05 Jan 2023 09:07:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672938423; cv=none; d=google.com; s=arc-20160816; b=aa2/uFJtdkiylcw4sn23tB1rClESALPeumsoMD0pCYDoF50Lt70j6TS/C1YKMbTNx4 H5d5snmH3wr42u560rjNIRkz5y8UVreOOvKZ+A+p9gJgPp18EAGE2/pZ62rKyyD/Q0Zb oTWmGpWlNv6SOmpu5qhowYIfjt2VpzpdI27n/LK2kDy/XW9clwo5kblEIaAjforSubbD 0b5ZfqC6oynpLO1eMbmHUD2l/ZFFGGv4gm2FCiUkrKNSI2Qp+vEvRtSnrnyQfxZwSrbq buz6ABZE0nYyC4etozTuCz64p96McQ5kZ6Ruje1ZQDtNA3lwM+DYKn7llwmOpYo49zrU wfyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=0uX5qcSlWxkIv6XFcZG4vEVBT2aV30N7UKGbpRe6IA0=; b=D8AZrS9rhW65BPvkVtPzjtfe/s6lx8lHNoUsYc02rNy4aFdvuLeYTyzq0ixE38kdaf 10PuoeaFZN2dFlhsIDa/n140teFX7AVlN5hZsK+7yA1SRv0QESAm6M6U1g9Cvxkfe8pm m8I1LAyz65zttIAgOSkBkY+xe4T+ShXMeIUgC09aj5/2p+fz9yw5vcDWxY2ExOjIS5pi 6jOXXx+hWg3WdRSjD9ArNj9GzKPqm6d8jFhtt+tozK8npXV3+9dSlXjCmL+OI0xVjcrP 3kdysjTGW/N/97hxadFLA71wlEGvrZXp8CHoatMyFF8g8uROwYxerW0w2vJYICwFzTLi /Ohg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=o+90ALjo; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id h6-20020ac87446000000b003a7e92f779dsi19060485qtr.98.2023.01.05.09.07.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 05 Jan 2023 09:07:03 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=o+90ALjo; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pDTMf-0001M0-Ci; Thu, 05 Jan 2023 11:45:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pDTMJ-0000oG-Dg for qemu-devel@nongnu.org; Thu, 05 Jan 2023 11:44:51 -0500 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pDTMF-0007Pb-1r for qemu-devel@nongnu.org; Thu, 05 Jan 2023 11:44:51 -0500 Received: by mail-wm1-x32c.google.com with SMTP id m3so19556073wmq.0 for ; Thu, 05 Jan 2023 08:44:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=0uX5qcSlWxkIv6XFcZG4vEVBT2aV30N7UKGbpRe6IA0=; b=o+90ALjoozOnofJKn5PdDOdOKiJRyPHwHIvFdCUomRnMG8Jg/3KyxxBOqWdooRQiwp 3+0fjKYSNcVJdw4dvJnmGuHatud6KE0nlqAZb18wyvKyx7uHG504M4qjmiVIAeqWnWnH YPZlhF+RYsNHSOQi9/dcTOnhW77uzWWi7TtjdmUBSwIniCvt+8kAvpiPX40p5hmzU5e5 9Q+VLKwNM4RdyTFDxzz4k2mapbCZw93n2dA89MqRxo8gxQMlo1wNjwA69bhhmPaX/+l0 aEcEJw8b1RLcu8elRX+rXwlwBcZJ4gb4I4VmOrFtdbZFjMC4JigFn+BnMTd16VBqXtEE YvNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0uX5qcSlWxkIv6XFcZG4vEVBT2aV30N7UKGbpRe6IA0=; b=FD2A6Sfm5mIqJ43iAIzhTKEzr0r9hv32GL3nTPfhoOQO/jopjoDQ3wvK2JC7XFUgdt NsZE+GefTHxCcHu78hZA5NrguWYl7Te4cJiJcs9XWXoj3E/P9yjfSMtV8iZTA+g+SCYb wSZepFPY2fhemVkiACPqbLMcuw1q61x6OS6Ad3EaxBYg2pYbdYltx+Bk9NzZmo1XHRG5 S47B+RP686txZvTz1D/H9Z3aZ/7ikDIFn4CJhNzNq9Q5NaNmZKO0bcqxOOKe1k54g0qc rkmYz/7EgG10cvbKNW9bzCbAzNdD8DG3bwh9McMIwc/K71PdB3s5W3hNvslbk29CgIrr Am/Q== X-Gm-Message-State: AFqh2krb8FXt1CxO65SG1TqVlzYCSFjd96XJZz5nCX+2VsGMCQs+Z824 mUW/sxxLHBbdCPVYhDawuwnTDe1VQR6JdGis X-Received: by 2002:a05:600c:1f11:b0:3d0:57ea:319c with SMTP id bd17-20020a05600c1f1100b003d057ea319cmr36874405wmb.13.1672937084993; Thu, 05 Jan 2023 08:44:44 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id hg9-20020a05600c538900b003cf71b1f66csm3055547wmb.0.2023.01.05.08.44.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Jan 2023 08:44:44 -0800 (PST) From: Peter Maydell 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 Message-Id: <20230105164417.3994639-32-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230105164417.3994639-1-peter.maydell@linaro.org> References: <20230105164417.3994639-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Jean-Christophe Dubois CCM derived clocks will have to be added later. Signed-off-by: Jean-Christophe Dubois Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- 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)