Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp63225pxf; Tue, 9 Mar 2021 23:58:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJyqs8HXCHM7RiwxeOQKUeNHW2f0A77RBTI17V1IVhDSwdJ6wIqML5SiOAUl9CNuhN6MrJAv X-Received: by 2002:a05:6402:5255:: with SMTP id t21mr1865873edd.91.1615363131437; Tue, 09 Mar 2021 23:58:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615363131; cv=none; d=google.com; s=arc-20160816; b=qIBDeIy5dz3o0ynagrfUHAqZLyREg1D9zAMbxAnVAA6sZMTMSc1L7HBeMlbxdFaqVb VDqBQIhm+ciOKOrKfhUMkGqwBA2eiL5mdCWw8CPsloij5gc3wfh7LSYAwcL96jVcF7M2 zkbtYEK9DNweLseMI0+fhg/aaW3XaDy2eVzWXndb22coMydpcxio9OA+hRJKt19xs4fR GAurr5+xIsY3TfelreXMvkndfyjGAwo+yosh8fv4R2pnGz3/wIDREJaPCrNPcvaE9I2Z 22C2c1nL9zuX7tNii9dYKs4eJ845xLdhB9CjyCPOpFMrK6sPbxzAELyjHlw4LsuDFO2R rvJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=TqQfnjs2r3w0wrUt1hotian1DUOSt4jEA6wHpbUFISM=; b=L/6gAQE2Ar2SzeTpeIvfeJuvmVne+iq09nPCOwe2lCeByOq6RMvjFv1sw5zfLS3hVt T8aAleDnb7gy5gveQRlSzN01CFu+fE8FS/Z5Q4gn1Zmf+RqDQWPLMipApj8zpXLPVs/c V1Jxfb4J6nWU2gW0EOu1BOSmQBviaUvcQETe/558p/inYCCYdV38/D1Wr+dnLNjSah/e l7x/PXv4rD+TMCIbedaffz0FSv2iWk/42c3KDS9hbw0615djQl5cq4cA1WJtspwLBgzh T6gn2bfP1p15ZBx1V1eTju1nZUaBAEpJIcGvf64HSe/gSJADMR/dQZzSWJOa7fRSOlCS Yndw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l10si11013576edf.444.2021.03.09.23.58.29; Tue, 09 Mar 2021 23:58:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232378AbhCJH51 (ORCPT + 99 others); Wed, 10 Mar 2021 02:57:27 -0500 Received: from mail.loongson.cn ([114.242.206.163]:33346 "EHLO loongson.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229632AbhCJH4z (ORCPT ); Wed, 10 Mar 2021 02:56:55 -0500 Received: from localhost.localdomain (unknown [113.200.148.30]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9Dxn_O3e0hg6KoXAA--.12657S5; Wed, 10 Mar 2021 15:56:46 +0800 (CST) From: Qing Zhang To: Huacai Chen , Jiaxun Yang , Thomas Bogendoerfer , Thomas Gleixner , Marc Zyngier Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Ming Wang Subject: [PATCH v4 3/7] MIPS: Loongson64: Add support for the Loongson-2K1000 to get cpu_clock_freq Date: Wed, 10 Mar 2021 15:56:35 +0800 Message-Id: <20210310075639.20372-4-zhangqing@loongson.cn> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210310075639.20372-1-zhangqing@loongson.cn> References: <20210310075639.20372-1-zhangqing@loongson.cn> M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WUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87 Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjfUYXo7DUUUU X-CM-SenderInfo: x2kd0wptlqwqxorr0wxvrqhubq/ Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Get the fixed-clock from the CPU0 node of the device tree. Signed-off-by: Jiaxun Yang Signed-off-by: Qing Zhang Tested-by: Ming Wang --- v3-v4: Standard submission of information Add return after error arch/mips/loongson64/time.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/arch/mips/loongson64/time.c b/arch/mips/loongson64/time.c index 91e842b58365..2d84f9b20a9b 100644 --- a/arch/mips/loongson64/time.c +++ b/arch/mips/loongson64/time.c @@ -11,9 +11,33 @@ #include #include +#include +#include void __init plat_time_init(void) { + struct clk *clk = NULL; + struct device_node *np; + + if (loongson_sysconf.fw_interface == LOONGSON_DTB) { + of_clk_init(NULL); + + np = of_get_cpu_node(0, NULL); + if (!np) { + pr_err("Failed to get CPU node\n"); + return; + } + + clk = of_clk_get(np, 0); + if (IS_ERR(clk)) { + pr_err("Failed to get CPU clock: %ld\n", PTR_ERR(clk)); + return; + } + + cpu_clock_freq = clk_get_rate(clk); + clk_put(clk); + } + /* setup mips r4k timer */ mips_hpt_frequency = cpu_clock_freq / 2; -- 2.20.1