From patchwork Mon Aug 10 09:51:55 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 52198 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by patches.linaro.org (Postfix) with ESMTPS id 86BA02152A for ; Mon, 10 Aug 2015 10:04:44 +0000 (UTC) Received: by labth1 with SMTP id th1sf59740167lab.2 for ; Mon, 10 Aug 2015 03:04:43 -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=3+S+zBk6oUHSND/4UJ0TXQKjKo3pB0+U06NYTxpfvf8=; b=dpNnPxXYtuKt8hYHVgs8FnTNsBSmn08V+gshQUGHSR6th/fOETBtFSQW5eCrL/Gw3o UFX1u/r++XksS+SqpkM34ZrneA519S9ezp5Z+y+hcO45pTXv76uZ4K0Bh5r+RKjqPqvP CBmGrqHoUgSPzS0/jpMHDQ82AUO4hS+bYPim4muT7ih/wI+YpCL5n0x4JfWT5DF/JvmW GpCrEzUeINjxXMR7gbHBvRIxE3VicpafQeO0tU/Vi37JJrPQAkSsBWP2UqQBAeR4QZjS eI6v2mWHWjun97/DTfXwBrvirIOFnHvYwsea+oUapykph51gvd4FJ1a2QQQIVMdwawo0 4zoQ== X-Gm-Message-State: ALoCoQm3Uzg2TOnnrnrPrkpgxb4e+8RpkL7H2xdLB+UTec0gG1QQOBvIAo70zNFWsisQOvb9gRfx X-Received: by 10.152.115.196 with SMTP id jq4mr6077147lab.1.1439201083468; Mon, 10 Aug 2015 03:04:43 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.36.1 with SMTP id m1ls329438laj.32.gmail; Mon, 10 Aug 2015 03:04:43 -0700 (PDT) X-Received: by 10.112.64.38 with SMTP id l6mr7882538lbs.111.1439201083222; Mon, 10 Aug 2015 03:04:43 -0700 (PDT) Received: from mail-lb0-f178.google.com (mail-lb0-f178.google.com. [209.85.217.178]) by mx.google.com with ESMTPS id dm4si1209824lbc.67.2015.08.10.03.04.42 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Aug 2015 03:04:42 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.178 as permitted sender) client-ip=209.85.217.178; Received: by lbbpo9 with SMTP id po9so92288447lbb.2 for ; Mon, 10 Aug 2015 03:04:42 -0700 (PDT) X-Received: by 10.152.170.230 with SMTP id ap6mr2910217lac.73.1439201082775; Mon, 10 Aug 2015 03:04:42 -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 l6csp1832702lba; Mon, 10 Aug 2015 03:04:41 -0700 (PDT) X-Received: by 10.66.253.170 with SMTP id ab10mr42925133pad.135.1439201081640; Mon, 10 Aug 2015 03:04:41 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id qb10si32361443pdb.150.2015.08.10.03.04.40; Mon, 10 Aug 2015 03:04:41 -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 S1755398AbbHJKE1 (ORCPT + 28 others); Mon, 10 Aug 2015 06:04:27 -0400 Received: from mail-wi0-f178.google.com ([209.85.212.178]:35207 "EHLO mail-wi0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933279AbbHJJyW (ORCPT ); Mon, 10 Aug 2015 05:54:22 -0400 Received: by wicne3 with SMTP id ne3so15338570wic.0 for ; Mon, 10 Aug 2015 02:54:21 -0700 (PDT) X-Received: by 10.180.87.99 with SMTP id w3mr22689928wiz.4.1439200461005; Mon, 10 Aug 2015 02:54:21 -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.54.19 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 10 Aug 2015 02:54:20 -0700 (PDT) From: Daniel Lezcano To: mingo@kernel.org Cc: tglx@linutronix.de, linux-kernel@vger.kernel.org, Viresh Kumar , Nicolas Ferre , Alexandre Belloni , Jean-Christophe Plagniol-Villard Subject: [PATCH 38/74] clockevents/drivers/atmel: Migrate to new 'set-state' interface Date: Mon, 10 Aug 2015 11:51:55 +0200 Message-Id: <1439200352-26767-38-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.178 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 atmel 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. Cc: Nicolas Ferre Cc: Alexandre Belloni Cc: Jean-Christophe Plagniol-Villard Signed-off-by: Viresh Kumar Signed-off-by: Daniel Lezcano Acked-by: Alexandre Belloni --- drivers/clocksource/timer-atmel-pit.c | 41 +++++++++++++++-------------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/drivers/clocksource/timer-atmel-pit.c b/drivers/clocksource/timer-atmel-pit.c index c0304ff..5875322 100644 --- a/drivers/clocksource/timer-atmel-pit.c +++ b/drivers/clocksource/timer-atmel-pit.c @@ -90,33 +90,27 @@ static cycle_t read_pit_clk(struct clocksource *cs) return elapsed; } +static int pit_clkevt_shutdown(struct clock_event_device *dev) +{ + struct pit_data *data = clkevt_to_pit_data(dev); + + /* disable irq, leaving the clocksource active */ + pit_write(data->base, AT91_PIT_MR, (data->cycle - 1) | AT91_PIT_PITEN); + return 0; +} + /* * Clockevent device: interrupts every 1/HZ (== pit_cycles * MCK/16) */ -static void -pit_clkevt_mode(enum clock_event_mode mode, struct clock_event_device *dev) +static int pit_clkevt_set_periodic(struct clock_event_device *dev) { struct pit_data *data = clkevt_to_pit_data(dev); - switch (mode) { - case CLOCK_EVT_MODE_PERIODIC: - /* update clocksource counter */ - data->cnt += data->cycle * PIT_PICNT(pit_read(data->base, AT91_PIT_PIVR)); - pit_write(data->base, AT91_PIT_MR, - (data->cycle - 1) | AT91_PIT_PITEN | AT91_PIT_PITIEN); - break; - case CLOCK_EVT_MODE_ONESHOT: - BUG(); - /* FALLTHROUGH */ - case CLOCK_EVT_MODE_SHUTDOWN: - case CLOCK_EVT_MODE_UNUSED: - /* disable irq, leaving the clocksource active */ - pit_write(data->base, AT91_PIT_MR, - (data->cycle - 1) | AT91_PIT_PITEN); - break; - case CLOCK_EVT_MODE_RESUME: - break; - } + /* update clocksource counter */ + data->cnt += data->cycle * PIT_PICNT(pit_read(data->base, AT91_PIT_PIVR)); + pit_write(data->base, AT91_PIT_MR, + (data->cycle - 1) | AT91_PIT_PITEN | AT91_PIT_PITIEN); + return 0; } static void at91sam926x_pit_suspend(struct clock_event_device *cedev) @@ -162,7 +156,7 @@ static irqreturn_t at91sam926x_pit_interrupt(int irq, void *dev_id) WARN_ON_ONCE(!irqs_disabled()); /* The PIT interrupt may be disabled, and is shared */ - if ((data->clkevt.mode == CLOCK_EVT_MODE_PERIODIC) && + if (clockevent_state_periodic(&data->clkevt) && (pit_read(data->base, AT91_PIT_SR) & AT91_PIT_PITS)) { unsigned nr_ticks; @@ -227,7 +221,8 @@ static void __init at91sam926x_pit_common_init(struct pit_data *data) data->clkevt.rating = 100; data->clkevt.cpumask = cpumask_of(0); - data->clkevt.set_mode = pit_clkevt_mode; + data->clkevt.set_state_shutdown = pit_clkevt_shutdown; + data->clkevt.set_state_periodic = pit_clkevt_set_periodic; data->clkevt.resume = at91sam926x_pit_resume; data->clkevt.suspend = at91sam926x_pit_suspend; clockevents_register_device(&data->clkevt);