From patchwork Mon Aug 10 09:51:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 52150 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by patches.linaro.org (Postfix) with ESMTPS id 17C2A2152A for ; Mon, 10 Aug 2015 09:54:26 +0000 (UTC) Received: by wicja10 with SMTP id ja10sf12208950wic.2 for ; Mon, 10 Aug 2015 02:54:25 -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=f2sjwVFrF+jBXO2yeT5J6OJkYsN6jUeXiiZu71Klm1Y=; b=bP6AC9vD99odQ4y6PFSiQu9KS4Q2/tRuMXKXFaNR/GoKyUzRpio9/SnTESXFLjkLCN JJTFrYfH3JssnXK6To12VgH5Jr+rj2ALN0/EgXbGRsSC+rUR6CIBs8jqsp0I05v3YtT+ Ik5i4BDlD0iVQ9Ivm8/8qQZMGY29/S3Em67A9CmA9i0m6oxMdiCzmh/ok/cTZ5L6XYXw FnchzbgegHXveoKMXeSuOTORHv3zklRJijveJQPgFRvqy/jVS2u2HaOEpuKTdAV4SxzD e0aB5nQHbNGCM6pPj/6aHa4XyyG4DofMlJIqe41uHDqafOr8pEd9p0foAL8mDf8FVOis yHrg== X-Gm-Message-State: ALoCoQliR+dgn5sWuQphATLHSpcZYExM56lHsBCGO6ezTfdobDsWH4mRNhBF9w3lUJe8dYo5oDhd X-Received: by 10.180.90.106 with SMTP id bv10mr3439078wib.6.1439200465424; Mon, 10 Aug 2015 02:54:25 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.206.33 with SMTP id ll1ls363250lac.98.gmail; Mon, 10 Aug 2015 02:54:25 -0700 (PDT) X-Received: by 10.112.125.200 with SMTP id ms8mr19185601lbb.60.1439200465090; Mon, 10 Aug 2015 02:54:25 -0700 (PDT) Received: from mail-lb0-f169.google.com (mail-lb0-f169.google.com. [209.85.217.169]) by mx.google.com with ESMTPS id j5si13719147laf.127.2015.08.10.02.54.25 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Aug 2015 02:54:25 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.169 as permitted sender) client-ip=209.85.217.169; Received: by lbbpo9 with SMTP id po9so92150573lbb.2 for ; Mon, 10 Aug 2015 02:54:25 -0700 (PDT) X-Received: by 10.112.166.2 with SMTP id zc2mr19294048lbb.29.1439200464986; Mon, 10 Aug 2015 02:54:24 -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.7.198 with SMTP id l6csp1827615lba; Mon, 10 Aug 2015 02:54:24 -0700 (PDT) X-Received: by 10.66.101.71 with SMTP id fe7mr42813400pab.89.1439200459200; Mon, 10 Aug 2015 02:54:19 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id yq3si32145746pbb.250.2015.08.10.02.54.18; Mon, 10 Aug 2015 02:54:19 -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 S933149AbbHJJyG (ORCPT + 28 others); Mon, 10 Aug 2015 05:54:06 -0400 Received: from mail-wi0-f179.google.com ([209.85.212.179]:37784 "EHLO mail-wi0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933043AbbHJJyA (ORCPT ); Mon, 10 Aug 2015 05:54:00 -0400 Received: by wibhh20 with SMTP id hh20so142934618wib.0 for ; Mon, 10 Aug 2015 02:53:58 -0700 (PDT) X-Received: by 10.194.11.7 with SMTP id m7mr42466292wjb.56.1439200438820; Mon, 10 Aug 2015 02:53:58 -0700 (PDT) Received: from localhost.localdomain (sju31-1-78-210-255-2.fbx.proxad.net. [78.210.255.2]) by smtp.gmail.com with ESMTPSA id jr5sm28598154wjc.14.2015.08.10.02.53.57 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 10 Aug 2015 02:53:58 -0700 (PDT) From: Daniel Lezcano To: mingo@kernel.org Cc: tglx@linutronix.de, linux-kernel@vger.kernel.org, Viresh Kumar , Shawn Guo Subject: [PATCH 23/74] clockevents/drivers/mxs: Migrate to new 'set-state' interface Date: Mon, 10 Aug 2015 11:51:40 +0200 Message-Id: <1439200352-26767-23-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1439200352-26767-1-git-send-email-daniel.lezcano@linaro.org> References: <55C87382.4070309@linaro.org> <1439200352-26767-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.169 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: , From: Viresh Kumar Migrate mxs 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: - 'mxs_clockevent_mode': as we have helpers available from core for the same. same state twice and so perhaps the check wasn't required. - 'clock_event_mode_label': CLOCK_EVT_MODE_* shouldn't be used anymore by drivers and it was used just to print old-state:new-state. The debug prints are called from mxs_irq_clear() now based on the state-name passed to it. The printed name will be same for shutdown and resume states as they use the same callback pointer. Cc: Shawn Guo Signed-off-by: Viresh Kumar Signed-off-by: Daniel Lezcano --- drivers/clocksource/mxs_timer.c | 80 +++++++++++++++++------------------------ 1 file changed, 32 insertions(+), 48 deletions(-) diff --git a/drivers/clocksource/mxs_timer.c b/drivers/clocksource/mxs_timer.c index 445b68a..f5ce296 100644 --- a/drivers/clocksource/mxs_timer.c +++ b/drivers/clocksource/mxs_timer.c @@ -77,7 +77,6 @@ #define BV_TIMROTv2_TIMCTRLn_SELECT__TICK_ALWAYS 0xf static struct clock_event_device mxs_clockevent_device; -static enum clock_event_mode mxs_clockevent_mode = CLOCK_EVT_MODE_UNUSED; static void __iomem *mxs_timrot_base; static u32 timrot_major_version; @@ -141,64 +140,49 @@ static struct irqaction mxs_timer_irq = { .handler = mxs_timer_interrupt, }; -#ifdef DEBUG -static const char *clock_event_mode_label[] const = { - [CLOCK_EVT_MODE_PERIODIC] = "CLOCK_EVT_MODE_PERIODIC", - [CLOCK_EVT_MODE_ONESHOT] = "CLOCK_EVT_MODE_ONESHOT", - [CLOCK_EVT_MODE_SHUTDOWN] = "CLOCK_EVT_MODE_SHUTDOWN", - [CLOCK_EVT_MODE_UNUSED] = "CLOCK_EVT_MODE_UNUSED" -}; -#endif /* DEBUG */ - -static void mxs_set_mode(enum clock_event_mode mode, - struct clock_event_device *evt) +static void mxs_irq_clear(char *state) { /* Disable interrupt in timer module */ timrot_irq_disable(); - if (mode != mxs_clockevent_mode) { - /* Set event time into the furthest future */ - if (timrot_is_v1()) - __raw_writel(0xffff, - mxs_timrot_base + HW_TIMROT_TIMCOUNTn(1)); - else - __raw_writel(0xffffffff, - mxs_timrot_base + HW_TIMROT_FIXED_COUNTn(1)); - - /* Clear pending interrupt */ - timrot_irq_acknowledge(); - } + /* Set event time into the furthest future */ + if (timrot_is_v1()) + __raw_writel(0xffff, mxs_timrot_base + HW_TIMROT_TIMCOUNTn(1)); + else + __raw_writel(0xffffffff, + mxs_timrot_base + HW_TIMROT_FIXED_COUNTn(1)); + + /* Clear pending interrupt */ + timrot_irq_acknowledge(); #ifdef DEBUG - pr_info("%s: changing mode from %s to %s\n", __func__, - clock_event_mode_label[mxs_clockevent_mode], - clock_event_mode_label[mode]); + pr_info("%s: changing mode to %s\n", __func__, state) #endif /* DEBUG */ +} - /* Remember timer mode */ - mxs_clockevent_mode = mode; - - switch (mode) { - case CLOCK_EVT_MODE_PERIODIC: - pr_err("%s: Periodic mode is not implemented\n", __func__); - break; - case CLOCK_EVT_MODE_ONESHOT: - timrot_irq_enable(); - 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; - } +static int mxs_shutdown(struct clock_event_device *evt) +{ + mxs_irq_clear("shutdown"); + + return 0; +} + +static int mxs_set_oneshot(struct clock_event_device *evt) +{ + if (clockevent_state_oneshot(evt)) + mxs_irq_clear("oneshot"); + timrot_irq_enable(); + return 0; } static struct clock_event_device mxs_clockevent_device = { - .name = "mxs_timrot", - .features = CLOCK_EVT_FEAT_ONESHOT, - .set_mode = mxs_set_mode, - .set_next_event = timrotv2_set_next_event, - .rating = 200, + .name = "mxs_timrot", + .features = CLOCK_EVT_FEAT_ONESHOT, + .set_state_shutdown = mxs_shutdown, + .set_state_oneshot = mxs_set_oneshot, + .tick_resume = mxs_shutdown, + .set_next_event = timrotv2_set_next_event, + .rating = 200, }; static int __init mxs_clockevent_init(struct clk *timer_clk)