From patchwork Mon Oct 19 20:59:27 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 55257 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by patches.linaro.org (Postfix) with ESMTPS id 48A1322F11 for ; Mon, 19 Oct 2015 21:00:32 +0000 (UTC) Received: by lbcao8 with SMTP id ao8sf50275483lbc.1 for ; Mon, 19 Oct 2015 14:00:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=GjBEkWGnF0jShP0yqUbwncFkaIIckgiRlmbANuNxs94=; b=cyKGTsgLTqnSM/MmWsXD+xsDdb5EnZP8ecawQsl/7Hp5E3jAAn5TW1h+urjJjHGlCJ A60urBGSI8fSwRyaw3lSTNaxmc6CQPsxnbD9m+cZ+0fhjZkVzN7b9AWpZ64+3Vi1cXRg C6otXQveW4F3v4IHrnDzDduyq/rcmoHt0G+rXidzg1h7tGxjP+Sr2NIQRAuBlgMUffB7 /0KnUeMeYCVKj4aN6yE2k9I4NKIWHbMgm6lMdEGCe4cO0ibxAD/wBulc7AuezkfnuU1Q UDxzkr7ORFee0SH9tWv9I5C+Hpuf3W6pBEfWgth0uk8vi9/GjBigisQrkzVg9GtqrXKd AfXQ== X-Gm-Message-State: ALoCoQn/7xOSr3S1ZXegDChcfmN6vXfzhfSSqCf4m3dnD1bb54HQObwk79BMXxhpFRixsD4Lzcn9 X-Received: by 10.112.145.227 with SMTP id sx3mr2218986lbb.12.1445288431239; Mon, 19 Oct 2015 14:00:31 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.205.7 with SMTP id d7ls669659lfg.82.gmail; Mon, 19 Oct 2015 14:00:31 -0700 (PDT) X-Received: by 10.112.72.40 with SMTP id a8mr3715305lbv.55.1445288431074; Mon, 19 Oct 2015 14:00:31 -0700 (PDT) Received: from mail-lb0-f180.google.com (mail-lb0-f180.google.com. [209.85.217.180]) by mx.google.com with ESMTPS id rq10si24261531lbb.158.2015.10.19.14.00.31 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Oct 2015 14:00:31 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.180 as permitted sender) client-ip=209.85.217.180; Received: by lbbwb3 with SMTP id wb3so95857491lbb.1 for ; Mon, 19 Oct 2015 14:00:30 -0700 (PDT) X-Received: by 10.25.28.73 with SMTP id c70mr8455292lfc.76.1445288430894; Mon, 19 Oct 2015 14:00:30 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp1696959lbq; Mon, 19 Oct 2015 14:00:29 -0700 (PDT) X-Received: by 10.66.139.201 with SMTP id ra9mr37015555pab.153.1445288429226; Mon, 19 Oct 2015 14:00:29 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id pn2si55302872pac.121.2015.10.19.14.00.28; Mon, 19 Oct 2015 14:00:29 -0700 (PDT) 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; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932183AbbJSVAJ (ORCPT + 28 others); Mon, 19 Oct 2015 17:00:09 -0400 Received: from mail-wi0-f182.google.com ([209.85.212.182]:32827 "EHLO mail-wi0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932075AbbJSVAG (ORCPT ); Mon, 19 Oct 2015 17:00:06 -0400 Received: by wijp11 with SMTP id p11so18146694wij.0 for ; Mon, 19 Oct 2015 14:00:05 -0700 (PDT) X-Received: by 10.180.102.226 with SMTP id fr2mr24383385wib.3.1445288405091; Mon, 19 Oct 2015 14:00:05 -0700 (PDT) Received: from mai.telefonica.net (185.Red-213-96-199.staticIP.rima-tde.net. [213.96.199.185]) by smtp.gmail.com with ESMTPSA id xt1sm42296501wjb.32.2015.10.19.14.00.04 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 19 Oct 2015 14:00:04 -0700 (PDT) From: Daniel Lezcano To: tglx@linutronix.de Cc: linux-kernel@vger.kernel.org, mingo@kernel.org, Marc Gonzalez Subject: [PATCH 8/9] clocksource/drivers/tango_xtal: Add new timer for Tango SoCs Date: Mon, 19 Oct 2015 22:59:27 +0200 Message-Id: <1445288368-6440-8-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1445288368-6440-1-git-send-email-daniel.lezcano@linaro.org> References: <56255943.6060807@linaro.org> <1445288368-6440-1-git-send-email-daniel.lezcano@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: daniel.lezcano@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.180 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Marc Gonzalez Sigma Designs Tango platforms provide a 27 MHz crystal oscillator. Use it for clocksource, sched_clock, and delay_timer. Signed-off-by: Marc Gonzalez Signed-off-by: Daniel Lezcano --- drivers/clocksource/Kconfig | 4 +++ drivers/clocksource/Makefile | 1 + drivers/clocksource/tango_xtal.c | 66 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+) create mode 100644 drivers/clocksource/tango_xtal.c diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig index a7726db..50b68bc 100644 --- a/drivers/clocksource/Kconfig +++ b/drivers/clocksource/Kconfig @@ -279,6 +279,10 @@ config CLKSRC_MIPS_GIC depends on MIPS_GIC select CLKSRC_OF +config CLKSRC_TANGO_XTAL + bool + select CLKSRC_OF + config CLKSRC_PXA def_bool y if ARCH_PXA || ARCH_SA1100 select CLKSRC_OF if OF diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile index 5c00863..fc9348d 100644 --- a/drivers/clocksource/Makefile +++ b/drivers/clocksource/Makefile @@ -56,6 +56,7 @@ obj-$(CONFIG_ARCH_KEYSTONE) += timer-keystone.o obj-$(CONFIG_ARCH_INTEGRATOR_AP) += timer-integrator-ap.o obj-$(CONFIG_CLKSRC_VERSATILE) += versatile.o obj-$(CONFIG_CLKSRC_MIPS_GIC) += mips-gic-timer.o +obj-$(CONFIG_CLKSRC_TANGO_XTAL) += tango_xtal.o obj-$(CONFIG_CLKSRC_IMX_GPT) += timer-imx-gpt.o obj-$(CONFIG_ASM9260_TIMER) += asm9260_timer.o obj-$(CONFIG_H8300) += h8300_timer8.o diff --git a/drivers/clocksource/tango_xtal.c b/drivers/clocksource/tango_xtal.c new file mode 100644 index 0000000..d297b30 --- /dev/null +++ b/drivers/clocksource/tango_xtal.c @@ -0,0 +1,66 @@ +#include +#include +#include +#include +#include +#include +#include + +static void __iomem *xtal_in_cnt; +static struct delay_timer delay_timer; + +static unsigned long notrace read_xtal_counter(void) +{ + return readl_relaxed(xtal_in_cnt); +} + +static u64 notrace read_sched_clock(void) +{ + return read_xtal_counter(); +} + +static cycle_t read_clocksource(struct clocksource *cs) +{ + return read_xtal_counter(); +} + +static struct clocksource tango_xtal = { + .name = "tango-xtal", + .rating = 350, + .read = read_clocksource, + .mask = CLOCKSOURCE_MASK(32), + .flags = CLOCK_SOURCE_IS_CONTINUOUS, +}; + +static void __init tango_clocksource_init(struct device_node *np) +{ + struct clk *clk; + int xtal_freq, ret; + + xtal_in_cnt = of_iomap(np, 0); + if (xtal_in_cnt == NULL) { + pr_err("%s: invalid address\n", np->full_name); + return; + } + + clk = of_clk_get(np, 0); + if (IS_ERR(clk)) { + pr_err("%s: invalid clock\n", np->full_name); + return; + } + + xtal_freq = clk_get_rate(clk); + delay_timer.freq = xtal_freq; + delay_timer.read_current_timer = read_xtal_counter; + + ret = clocksource_register_hz(&tango_xtal, xtal_freq); + if (ret != 0) { + pr_err("%s: registration failed\n", np->full_name); + return; + } + + sched_clock_register(read_sched_clock, 32, xtal_freq); + register_current_timer_delay(&delay_timer); +} + +CLOCKSOURCE_OF_DECLARE(tango, "sigma,tick-counter", tango_clocksource_init);