From patchwork Tue Jan 9 09:09:11 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: 123816 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp3781819qgn; Tue, 9 Jan 2018 01:09:54 -0800 (PST) X-Google-Smtp-Source: ACJfBotRyNOaYVqLfJve85JgBjXWmSGfCXFecpY1UeTIl5lVFwhr76QXrI9f/AjVfEVVVBtpzvYO X-Received: by 10.159.198.73 with SMTP id y9mr15206443plt.385.1515488994535; Tue, 09 Jan 2018 01:09:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515488994; cv=none; d=google.com; s=arc-20160816; b=UBfLbSDLoIB222mRcqBhVjLoAhqSVvXS0kMkH5S3n4v1OMw+QPgsdaIwH55Cit8JDt az3AhH+X2M1F+87LxTToLQVwN9ffkClhO1SwvXzPkx+DY9//CZSBqPdHMQEBHxkBoE7u GRKCSlY/T95hw7owjLs6adKa6G+U5N8hkthOHKdbIolynj4HKmLuwWjPL8k1ognP0dyu ycJuKecjRslslNr5egBVZRl+Rzkz5SB7VIYlxmMbhZNm1dM5z2Va+/TvnmhaXTQVVLTN zfAlCUelt56cKrkZ1wuhmJp5XUPz2bh9ErAtE5bUxkqodNgEnktV2xR2LEsnUNo1UL5p GKIg== 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=YB2YIQHrThH4Ps2ZDyO2srGzU+Tf03OmNfj3UOO2SR8=; b=KT+q+Gu/3pbIABAIiCpyw0SCExJFosAKS5kN3ugLnjqq43wAKxAsSw8KrYya7Vwl5z Ayi4UwQNu96uvgF27JdtUoxR0hMTRknER8Rgb0TQA5H6um43Cw7XokhmSL8YNHiszK+s EpIP8mDNpt8+FZVKsK4bb0kKXHc3HLc3FJm2BisDdXXOAHHHAFQJtGrpZ/DWW0lmjYaU ynXryatnv04xfAHJ75913nR+sQUqS4MqZc7CnpAtY4W0U//H6BbVqHzqeRQHiwvyIi8b HAgauwcD/7Xyfmpm3ep35e7IJX3DiQatpePShu3c7+SziB5+/lVfZCkWGA8TpTnpfDCW yBww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Yt5pj4wl; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (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 l81si9807982pfb.91.2018.01.09.01.09.54; Tue, 09 Jan 2018 01:09:54 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Yt5pj4wl; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751490AbeAIJJw (ORCPT + 28 others); Tue, 9 Jan 2018 04:09:52 -0500 Received: from mail-pg0-f67.google.com ([74.125.83.67]:37722 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751008AbeAIJJp (ORCPT ); Tue, 9 Jan 2018 04:09:45 -0500 Received: by mail-pg0-f67.google.com with SMTP id z17so1642384pgc.4 for ; Tue, 09 Jan 2018 01:09:44 -0800 (PST) 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=YB2YIQHrThH4Ps2ZDyO2srGzU+Tf03OmNfj3UOO2SR8=; b=Yt5pj4wlxZF9bOEPzvspIGq5cF+vl+mUxBOJd6B4/VIx1UUq+v6n0xyVpm2GyxNyri h9JSoAEOgN9hKOsrNu91QGZvMdaA9Qqv0fL3OsWQ6XPCiiIB1WsXI7WLpn6zKET+eRKF S6aUjKfbZjSiVQZFSbnKzmZDDuQqikxbhWDTw= 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=YB2YIQHrThH4Ps2ZDyO2srGzU+Tf03OmNfj3UOO2SR8=; b=ejQGePnJ1ok8V/U55Vq+heoGd9Gqvm6NnHyjktH8/yJp52RscfQInopMin1yPnFrNf aJ8talh/7exK87rD9T11TIpqOjdiJyqHRBG5T9/gGodNOmH5RyqB28WNJ0+cKYcBdYKy N/kTBcImucdsLbrto3P3AX0rb8D5Nl/a4gAKqwa+K/bNh5VzHHA8Ggj9iBxMl5N6nKDh dAI1rP5+5TB+igFPy7SY51T0OywJ6/LnYmRRIkHlVRP7Sn4nV+SIvAIz7Qwwb8FVTWhD OGglRoLWVTmz+OueK1UECUJFWqRp8AUj4LnolayJ3U/YROToO0YmD4dJ/V26tfgtE9O0 brmQ== X-Gm-Message-State: AKGB3mJ0PSzbqWH8EOnP5yqfykn78ja0FPEItHF1P8mOSmSqVcvHZqTD XN7kOh/ZmvKGUZzzJorczm2Sv/AlASg= X-Received: by 10.84.132.33 with SMTP id 30mr15276529ple.126.1515488984511; Tue, 09 Jan 2018 01:09:44 -0800 (PST) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id m69sm15472964pfc.36.2018.01.09.01.09.42 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 09 Jan 2018 01:09:44 -0800 (PST) From: Baolin Wang To: daniel.lezcano@linaro.org, tglx@linutronix.de Cc: broonie@kernel.org, arnd@arndb.de, baolin.wang@linaro.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] clocksource: sprd: Add one persistent timer for Spreadtrum SC9860 platform Date: Tue, 9 Jan 2018 17:09:11 +0800 Message-Id: <3dd35afbcc2bc69bbc7a625e56257435b22dbc4c.1515486685.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Spreadtrum SC9860 platform, we need one persistent timer to calculate the suspend time to compensate the OS time. This patch registers one Spreadtrum AON timer as persistent timer, which runs at 32bit and periodic mode. Signed-off-by: Baolin Wang --- drivers/clocksource/Kconfig | 1 + drivers/clocksource/timer-sprd.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) -- 1.7.9.5 diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig index 9cf3d41..322c02d 100644 --- a/drivers/clocksource/Kconfig +++ b/drivers/clocksource/Kconfig @@ -448,6 +448,7 @@ config SPRD_TIMER bool "Spreadtrum timer driver" if COMPILE_TEST depends on HAS_IOMEM select TIMER_OF + select PERSISTENT_TIMER help Enables the support for the Spreadtrum timer driver. diff --git a/drivers/clocksource/timer-sprd.c b/drivers/clocksource/timer-sprd.c index ef9ebea..2304a7c 100644 --- a/drivers/clocksource/timer-sprd.c +++ b/drivers/clocksource/timer-sprd.c @@ -7,6 +7,7 @@ #include #include "timer-of.h" +#include "persistent-timer.h" #define TIMER_NAME "sprd_timer" @@ -157,3 +158,37 @@ static int __init sprd_timer_init(struct device_node *np) } TIMER_OF_DECLARE(sc9860_timer, "sprd,sc9860-timer", sprd_timer_init); + +static u64 sprd_persistent_timer_read(struct persistent_timer *p) +{ + return ~(u64)readl_relaxed(p->base + TIMER_VALUE_SHDW_LO) & p->mask; +} + +static void sprd_persistent_timer_enable(struct persistent_timer *p) +{ + sprd_timer_disable(p->base); + sprd_timer_update_counter(p->base, TIMER_VALUE_LO_MASK); + sprd_timer_enable(p->base, TIMER_CTL_PERIOD_MODE); +} + +static struct persistent_timer p = { + .read = sprd_persistent_timer_read, + .mask = CLOCKSOURCE_MASK(32), + .flags = PERSISTENT_TIMER_BASE | PERSISTENT_TIMER_CLOCK | + PERSISTENT_TIMER_MULT_SHIFT, +}; + +static int __init sprd_persistent_timer_init(struct device_node *np) +{ + int ret; + + ret = persistent_timer_init_and_register(np, &p); + if (ret) + return ret; + + sprd_persistent_timer_enable(&p); + return 0; +} + +TIMER_OF_DECLARE(sc9860_persistent_timer, "sprd,sc9860-persistent-timer", + sprd_persistent_timer_init);