From patchwork Thu Sep 8 20:13:07 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 3991 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 046E523EF9 for ; Thu, 8 Sep 2011 20:13:18 +0000 (UTC) Received: from mail-fx0-f52.google.com (mail-fx0-f52.google.com [209.85.161.52]) by fiordland.canonical.com (Postfix) with ESMTP id E463DA1842B for ; Thu, 8 Sep 2011 20:13:17 +0000 (UTC) Received: by fxd18 with SMTP id 18so2780659fxd.11 for ; Thu, 08 Sep 2011 13:13:17 -0700 (PDT) Received: by 10.223.62.8 with SMTP id v8mr254883fah.43.1315512797730; Thu, 08 Sep 2011 13:13:17 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.152.11.8 with SMTP id m8cs188668lab; Thu, 8 Sep 2011 13:13:17 -0700 (PDT) Received: by 10.204.7.84 with SMTP id c20mr841798bkc.257.1315512796537; Thu, 08 Sep 2011 13:13:16 -0700 (PDT) Received: from mail.df.lth.se (mail.df.lth.se [194.47.250.12]) by mx.google.com with ESMTPS id ag3si3225392bkc.19.2011.09.08.13.13.15 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 08 Sep 2011 13:13:16 -0700 (PDT) Received-SPF: pass (google.com: domain of triad@df.lth.se designates 194.47.250.12 as permitted sender) client-ip=194.47.250.12; Authentication-Results: mx.google.com; spf=pass (google.com: domain of triad@df.lth.se designates 194.47.250.12 as permitted sender) smtp.mail=triad@df.lth.se Received: from mer.df.lth.se (mer.df.lth.se [194.47.250.37]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.df.lth.se (Postfix) with ESMTPS id 4FC9565D6B; Thu, 8 Sep 2011 22:13:15 +0200 (CEST) Received: from mer.df.lth.se (triad@localhost.localdomain [127.0.0.1]) by mer.df.lth.se (8.14.3/8.14.3/Debian-9.4) with ESMTP id p88KDEJ3021018; Thu, 8 Sep 2011 22:13:14 +0200 Received: (from triad@localhost) by mer.df.lth.se (8.14.3/8.14.3/Submit) id p88KDE6Q021017; Thu, 8 Sep 2011 22:13:14 +0200 From: Linus Walleij To: linux-arm-kernel@lists.infradead.org Cc: Lee Jones , Linus Walleij , Russell King , Thomas Gleixner Subject: [PATCH 2/4 v2] mach-integrator: clockevent supports oneshot mode Date: Thu, 8 Sep 2011 22:13:07 +0200 Message-Id: <1315512787-20991-1-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 1.7.2.5 The Integrator AP timer has no problem supporting oneshot ticks with proper code, so let's do it so we can have NOHZ configured in for this platform too. Cc: Russell King Cc: Thomas Gleixner Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Make sure that setting the periodic mode arms and fires a periodic timer, and have the oneshot mode leave the timer disabled until the .set_next_event occurs. - Tested in both in explicit periodic and oneshot mode, by removing the CLOCK_EVT_FEAT_ONESHOT and testing, and removing CLOCK_EVT_FEAT_PERIODIC and testing. In periodic mode I get ~6050 timer interrupts per minute, in oneshot mode with NOHZ I get ~3066 timer interrups per minute so it seems to be working. --- arch/arm/mach-integrator/integrator_ap.c | 24 +++++++++++++++++++----- 1 files changed, 19 insertions(+), 5 deletions(-) diff --git a/arch/arm/mach-integrator/integrator_ap.c b/arch/arm/mach-integrator/integrator_ap.c index aa30ab6..e66a8bc 100644 --- a/arch/arm/mach-integrator/integrator_ap.c +++ b/arch/arm/mach-integrator/integrator_ap.c @@ -360,15 +360,29 @@ static void clkevt_set_mode(enum clock_event_mode mode, struct clock_event_devic { u32 ctrl = readl(clkevt_base + TIMER_CTRL) & ~TIMER_CTRL_ENABLE; - BUG_ON(mode == CLOCK_EVT_MODE_ONESHOT); + /* Disable timer */ + writel(ctrl, clkevt_base + TIMER_CTRL); - if (mode == CLOCK_EVT_MODE_PERIODIC) { - writel(ctrl, clkevt_base + TIMER_CTRL); + switch (mode) { + case CLOCK_EVT_MODE_PERIODIC: + /* Enable the timer and start the periodic tick */ writel(timer_reload, clkevt_base + TIMER_LOAD); ctrl |= TIMER_CTRL_PERIODIC | TIMER_CTRL_ENABLE; + writel(ctrl, clkevt_base + TIMER_CTRL); + break; + case CLOCK_EVT_MODE_ONESHOT: + /* Leave the timer disabled, .set_next_event will enable it */ + ctrl &= ~TIMER_CTRL_PERIODIC; + writel(ctrl, clkevt_base + TIMER_CTRL); + break; + case CLOCK_EVT_MODE_UNUSED: + case CLOCK_EVT_MODE_SHUTDOWN: + case CLOCK_EVT_MODE_RESUME: + default: + /* Just leave in disabled state */ + break; } - writel(ctrl, clkevt_base + TIMER_CTRL); } static int clkevt_set_next_event(unsigned long next, struct clock_event_device *evt) @@ -385,7 +399,7 @@ static int clkevt_set_next_event(unsigned long next, struct clock_event_device * static struct clock_event_device integrator_clockevent = { .name = "timer1", .shift = 34, - .features = CLOCK_EVT_FEAT_PERIODIC, + .features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT, .set_mode = clkevt_set_mode, .set_next_event = clkevt_set_next_event, .rating = 300,