From patchwork Mon May 14 08:55:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 135691 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1483931lji; Mon, 14 May 2018 01:56:39 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpkqsWnPcDe/YkD50GVWi5siFCpiCXBmSfyGQNR+jd9lMr+M0RjlqI2+EtyqbXlWcEDnxno X-Received: by 2002:a62:3745:: with SMTP id e66-v6mr9511345pfa.43.1526288199715; Mon, 14 May 2018 01:56:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526288199; cv=none; d=google.com; s=arc-20160816; b=0ghkrfCQnFuTImBQV88RZcdyqJhxecPvkcSKxAOLoe51ZvXz/g4pY3tb/dL5NfA8BJ kmGG1bnJjef1V7WKpGXaYVvd2dBeM+7dyHk+znaioVUznW9Y0iqVeRzMOkEFPAr8Brrd 6uX3VouRoaOT270/WrBPb9NlL8Z44Rehocxmi1xWU6TpRkT2VospeMuDB0y8cgdz69Qh fR0R+gEbDg3XWUeOLoOSlfvbHTLjHIKLMQt6z6Z5RuzRoz0XSFxmZEnjGADOx3TijZae wBgx4LzIuqHCZYQcdvbdLBIK0hgobjm/v1xDL6DT2G8yBSZ5iEP7i90plHJgih/8wbnF xV/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=NdTVm6s/SJ/+b7++NO8SpLVqKE1EBmqR0A6Zlp8v4I4=; b=N+SpdiftaAGhmd2xTP7oWy7LOwssnP6MU6fgdvsRNot18TxSBShsiFGWBJ1M9cUh5L ZWBPDgQAuFSYrwRbzepGCz/DE8ia6n0IXNVjnwJgXSrcd4lkEAQ1bXEd6lZCP/4K/pX9 qV8NSVnSvzKEu3J5IZ7g1JBAnZDPlXlyiBc+zGMAaTBUGPWvUC6QXayQ7WUYGfBng699 1roYUqoThQzJTJUkSFmErX4u4jbs1MvH/7kbdFT8Ik0VijjSEAXCpJ/bXJWFRJT2PlZG f+paurQaQwNLXzeSOPIDoNAVxydFNiLOdvB9oNcUts3VTTSILd9b2dqatW9w/+wDBUtY JUEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=XNU2+vEU; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f59-v6si9464172plf.38.2018.05.14.01.56.39; Mon, 14 May 2018 01:56:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=XNU2+vEU; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752175AbeENI4h (ORCPT + 5 others); Mon, 14 May 2018 04:56:37 -0400 Received: from mail-pl0-f65.google.com ([209.85.160.65]:43355 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752161AbeENI4d (ORCPT ); Mon, 14 May 2018 04:56:33 -0400 Received: by mail-pl0-f65.google.com with SMTP id c41-v6so1753447plj.10 for ; Mon, 14 May 2018 01:56:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=2Qu1jnyodM33FX6lpiVLTbtDw5ni5cVDxwCgCDaodfs=; b=XNU2+vEU9pkOF50orsNJJ5kxL+oDeoSRglRc+u/p7NKdFFCyrSamXC91u8InWTxbEA uqTUvbStGgLkCr1QJI/DEgrgD7izDGiCMg3m70gbvdZcH4NB5gksohRNSyIMuRd1dpxq TuMOzFm2p1lR13tKYEb3VqKGGeH7sUVEDTymU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=2Qu1jnyodM33FX6lpiVLTbtDw5ni5cVDxwCgCDaodfs=; b=pa/c9JSF0NLpbdOwPRPxK58V/qSpbinJoU9QGRT24G01nMnSDbxsL1nLnmMJwizelT /8E5v2RZYdphJgdk0qesDd62viUmDOu7rh78FJKygRY2xra01BTijWEeR9+XTa6wam4z 4bSaGHDgIzd3n2OYUlplQGCG5eJiWQDkXJf1npSTAAt5btHM/HRCVXei5PZWT/PUugb7 iHZob0+VQJt8CXNrk2N7uwiauXO+8FuGXYHdkVniGeFhrnabMHceGBevLtdHV/yEEJ5K YSrpxHFkws/vmNLyT18Jg5wfi5ABLhn8/5sENZXkxAynoJqEM0/cVWzd+QtKuifekd04 KNMQ== X-Gm-Message-State: ALKqPwcaT32j0BmI7QyjdD8rVNvyOwTwiRpqvtzaCD5mLPIal/1gmjgi McjUzN1AmADd4YDxqLwXBJYDNg== X-Received: by 2002:a17:902:76c3:: with SMTP id j3-v6mr5763144plt.15.1526288193314; Mon, 14 May 2018 01:56:33 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id x71-v6sm23308158pfe.47.2018.05.14.01.56.25 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 14 May 2018 01:56:32 -0700 (PDT) From: Baolin Wang To: tglx@linutronix.de, john.stultz@linaro.org, daniel.lezcano@linaro.org, arnd@arndb.de, tony@atomide.com, aaro.koskinen@iki.fi, linux@armlinux.org.uk, mark.rutland@arm.com, marc.zyngier@arm.com Cc: baolin.wang@linaro.org, broonie@kernel.org, paulmck@linux.vnet.ibm.com, mlichvar@redhat.com, rdunlap@infradead.org, kstewart@linuxfoundation.org, gregkh@linuxfoundation.org, pombredanne@nexb.com, thierry.reding@gmail.com, jonathanh@nvidia.com, heiko@sntech.de, linus.walleij@linaro.org, viresh.kumar@linaro.org, mingo@kernel.org, hpa@zytor.com, peterz@infradead.org, douly.fnst@cn.fujitsu.com, len.brown@intel.com, rajvi.jingar@intel.com, alexandre.belloni@bootlin.com, x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org Subject: [RFC PATCH 03/10] arm: omap: Convert 32K counter to use persistent clock Date: Mon, 14 May 2018 16:55:29 +0800 Message-Id: X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org We have introduced the persistent clock framework to support the OS time compensating from persistent clock, so this patch converts the 32k counter to use persistent clock framework to save lots of duplicate code. Signed-off-by: Baolin Wang --- arch/arm/plat-omap/Kconfig | 1 + arch/arm/plat-omap/counter_32k.c | 44 ++++++-------------------------------- 2 files changed, 8 insertions(+), 37 deletions(-) -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/arm/plat-omap/Kconfig b/arch/arm/plat-omap/Kconfig index afc1a1d..0e4e385 100644 --- a/arch/arm/plat-omap/Kconfig +++ b/arch/arm/plat-omap/Kconfig @@ -1,5 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 config ARCH_OMAP + select PERSISTENT_CLOCK bool if ARCH_OMAP diff --git a/arch/arm/plat-omap/counter_32k.c b/arch/arm/plat-omap/counter_32k.c index 2438b96..5d52f7c 100644 --- a/arch/arm/plat-omap/counter_32k.c +++ b/arch/arm/plat-omap/counter_32k.c @@ -19,8 +19,7 @@ #include #include #include - -#include +#include #include @@ -44,33 +43,6 @@ static u64 notrace omap_32k_read_sched_clock(void) } /** - * omap_read_persistent_clock64 - Return time from a persistent clock. - * - * Reads the time from a source which isn't disabled during PM, the - * 32k sync timer. Convert the cycles elapsed since last read into - * nsecs and adds to a monotonically increasing timespec64. - */ -static struct timespec64 persistent_ts; -static cycles_t cycles; -static unsigned int persistent_mult, persistent_shift; - -static void omap_read_persistent_clock64(struct timespec64 *ts) -{ - unsigned long long nsecs; - cycles_t last_cycles; - - last_cycles = cycles; - cycles = sync32k_cnt_reg ? readl_relaxed(sync32k_cnt_reg) : 0; - - nsecs = clocksource_cyc2ns(cycles - last_cycles, - persistent_mult, persistent_shift); - - timespec64_add_ns(&persistent_ts, nsecs); - - *ts = persistent_ts; -} - -/** * omap_init_clocksource_32k - setup and register counter 32k as a * kernel clocksource * @pbase: base addr of counter_32k module @@ -95,13 +67,6 @@ int __init omap_init_clocksource_32k(void __iomem *vbase) else sync32k_cnt_reg = vbase + OMAP2_32KSYNCNT_CR_OFF_LOW; - /* - * 120000 rough estimate from the calculations in - * __clocksource_update_freq_scale. - */ - clocks_calc_mult_shift(&persistent_mult, &persistent_shift, - 32768, NSEC_PER_SEC, 120000); - ret = clocksource_mmio_init(sync32k_cnt_reg, "32k_counter", 32768, 250, 32, clocksource_mmio_readl_up); if (ret) { @@ -110,7 +75,12 @@ int __init omap_init_clocksource_32k(void __iomem *vbase) } sched_clock_register(omap_32k_read_sched_clock, 32, 32768); - register_persistent_clock(NULL, omap_read_persistent_clock64); + /* + * 120000 rough estimate from the calculations in + * __clocksource_update_freq_scale. + */ + persistent_clock_init_and_register(omap_32k_read_sched_clock, + CLOCKSOURCE_MASK(32), 32768, 120000); pr_info("OMAP clocksource: 32k_counter at 32768 Hz\n"); return 0;