From patchwork Fri Jul 17 05:11:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 51213 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id ECCA522A28 for ; Fri, 17 Jul 2015 05:12:23 +0000 (UTC) Received: by laef2 with SMTP id f2sf23408535lae.0 for ; Thu, 16 Jul 2015 22:12:22 -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: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=eqVkZ1rayiPEiNZrC8WDfKil8JGLEv9ETUNkFd7ay4o=; b=df7NQYd3+1IUN4xSjNUAbefu6VsWbMl+i7mnkqAWMEDnXw0oJVgKtrbjbV12HukMZs /bkV6I1osXk+tuvI8UYvj2YyzF7MUhccxVmUrOXHUfCkbR9QL6K0CUqxE31KSCRAjcC7 WAKKtBBD/ZTuUarSaAmpt8T7nnyPH4FSO6NYzG7zHn+WfqoKFS+l61iCCDEowEIgvwAL +tmcwcrjZk7t8pEEpn9e0P/mg9v+mkt3d/k/oSOnl3BnUTvfEWMEvcM/PCwSoFle7yNB xqzgPg8z5Za2L6pyz8VcPzBURr38RXos3XSVVC6aRlvDCM+LRfKJXTX525tzzSdymK5u g90w== X-Gm-Message-State: ALoCoQmEz+htvveZPWcdgC2DRZ2qwbzLb8EiM8hcIlqOrvZHJ2qQBZyiYGhi4+hUjkC9sAQwNmbD X-Received: by 10.180.182.110 with SMTP id ed14mr3623840wic.5.1437109942912; Thu, 16 Jul 2015 22:12:22 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.116.116 with SMTP id jv20ls473291lab.4.gmail; Thu, 16 Jul 2015 22:12:22 -0700 (PDT) X-Received: by 10.112.220.7 with SMTP id ps7mr12562680lbc.72.1437109942645; Thu, 16 Jul 2015 22:12:22 -0700 (PDT) Received: from mail-lb0-f176.google.com (mail-lb0-f176.google.com. [209.85.217.176]) by mx.google.com with ESMTPS id d5si8856353lbv.164.2015.07.16.22.12.22 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Jul 2015 22:12:22 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.176 as permitted sender) client-ip=209.85.217.176; Received: by lbbzr7 with SMTP id zr7so55249540lbb.1 for ; Thu, 16 Jul 2015 22:12:22 -0700 (PDT) X-Received: by 10.152.4.163 with SMTP id l3mr12932735lal.35.1437109942546; Thu, 16 Jul 2015 22:12:22 -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.108.230 with SMTP id hn6csp668317lbb; Thu, 16 Jul 2015 22:12:21 -0700 (PDT) X-Received: by 10.66.119.136 with SMTP id ku8mr25347716pab.26.1437109937238; Thu, 16 Jul 2015 22:12:17 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id nm5si16574979pbc.166.2015.07.16.22.12.16; Thu, 16 Jul 2015 22:12:17 -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 S1756539AbbGQFMG (ORCPT + 28 others); Fri, 17 Jul 2015 01:12:06 -0400 Received: from mail-pd0-f182.google.com ([209.85.192.182]:36305 "EHLO mail-pd0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755714AbbGQFMD (ORCPT ); Fri, 17 Jul 2015 01:12:03 -0400 Received: by pdjr16 with SMTP id r16so56298796pdj.3 for ; Thu, 16 Jul 2015 22:12:02 -0700 (PDT) X-Received: by 10.68.178.67 with SMTP id cw3mr25696808pbc.86.1437109922012; Thu, 16 Jul 2015 22:12:02 -0700 (PDT) Received: from localhost ([122.171.186.190]) by smtp.gmail.com with ESMTPSA id p1sm9736952pdb.3.2015.07.16.22.12.01 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 16 Jul 2015 22:12:01 -0700 (PDT) From: Viresh Kumar To: arm@kernel.org, olof@lixom.net Cc: linaro-kernel@lists.linaro.org, arnd.bergmann@linaro.org, linux-arm-kernel@lists.infradead.org, Viresh Kumar , Shawn Guo , Sascha Hauer , linux-kernel@vger.kernel.org (open list), Russell King Subject: [PATCH 06/18] ARM/imx/epit: Migrate to new 'set-state' interface Date: Fri, 17 Jul 2015 10:41:00 +0530 Message-Id: <3200579fafb0400cd098e939ec664638d38e2bc9.1437101996.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.4.0 In-Reply-To: References: In-Reply-To: References: 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: viresh.kumar@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.176 as permitted sender) smtp.mail=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: , Migrate imx driver to the new 'set-state' interface provided by clockevents core, the earlier 'set-mode' interface is marked obsolete now. This also enables us to implement callbacks for new states of clockevent devices, for example: ONESHOT_STOPPED. Also drop 'clockevent_mode': It was caching the last state of the clockevent device. The same behavior can be achieved by using clockevents state helpers. These helpers are only required for oneshot mode as shutdown/resume wouldn't be done twice by the core. Cc: Shawn Guo Cc: Sascha Hauer Signed-off-by: Viresh Kumar --- arch/arm/mach-imx/epit.c | 67 +++++++++++++++++++++++++----------------------- 1 file changed, 35 insertions(+), 32 deletions(-) diff --git a/arch/arm/mach-imx/epit.c b/arch/arm/mach-imx/epit.c index 074b1a81ba76..08ce20771bb3 100644 --- a/arch/arm/mach-imx/epit.c +++ b/arch/arm/mach-imx/epit.c @@ -57,7 +57,6 @@ #include "hardware.h" static struct clock_event_device clockevent_epit; -static enum clock_event_mode clockevent_mode = CLOCK_EVT_MODE_UNUSED; static void __iomem *timer_base; @@ -106,8 +105,8 @@ static int epit_set_next_event(unsigned long evt, return 0; } -static void epit_set_mode(enum clock_event_mode mode, - struct clock_event_device *evt) +/* Left event sources disabled, no more interrupts appear */ +static int epit_shutdown(struct clock_event_device *evt) { unsigned long flags; @@ -120,39 +119,41 @@ static void epit_set_mode(enum clock_event_mode mode, /* Disable interrupt in GPT module */ epit_irq_disable(); - if (mode != clockevent_mode) { - /* Set event time into far-far future */ - - /* Clear pending interrupt */ - epit_irq_acknowledge(); - } + /* Clear pending interrupt */ + epit_irq_acknowledge(); - /* Remember timer mode */ - clockevent_mode = mode; local_irq_restore(flags); - switch (mode) { - case CLOCK_EVT_MODE_PERIODIC: - printk(KERN_ERR "epit_set_mode: Periodic mode is not " - "supported for i.MX EPIT\n"); - break; - case CLOCK_EVT_MODE_ONESHOT: + return 0; +} + +static int epit_set_oneshot(struct clock_event_device *evt) +{ + unsigned long flags; + + /* + * The timer interrupt generation is disabled at least + * for enough time to call epit_set_next_event() + */ + local_irq_save(flags); + + /* Disable interrupt in GPT module */ + epit_irq_disable(); + + /* Clear pending interrupt, only while switching mode */ + if (!clockevent_state_oneshot(evt)) + epit_irq_acknowledge(); + /* * Do not put overhead of interrupt enable/disable into * epit_set_next_event(), the core has about 4 minutes * to call epit_set_next_event() or shutdown clock after * mode switching */ - local_irq_save(flags); - epit_irq_enable(); - local_irq_restore(flags); - break; - case CLOCK_EVT_MODE_SHUTDOWN: - case CLOCK_EVT_MODE_UNUSED: - case CLOCK_EVT_MODE_RESUME: - /* Left event sources disabled, no more interrupts appear */ - break; - } + epit_irq_enable(); + local_irq_restore(flags); + + return 0; } /* @@ -176,11 +177,13 @@ static struct irqaction epit_timer_irq = { }; static struct clock_event_device clockevent_epit = { - .name = "epit", - .features = CLOCK_EVT_FEAT_ONESHOT, - .set_mode = epit_set_mode, - .set_next_event = epit_set_next_event, - .rating = 200, + .name = "epit", + .features = CLOCK_EVT_FEAT_ONESHOT, + .set_state_shutdown = epit_shutdown, + .tick_resume = epit_shutdown, + .set_state_oneshot = epit_set_oneshot, + .set_next_event = epit_set_next_event, + .rating = 200, }; static int __init epit_clockevent_init(struct clk *timer_clk)