From patchwork Thu Jun 18 10:54:44 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 50029 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A14B7228CC for ; Thu, 18 Jun 2015 11:02:35 +0000 (UTC) Received: by wimx15 with SMTP id x15sf2817250wim.1 for ; Thu, 18 Jun 2015 04:02:35 -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=bYdMm+xrylZUNnh8m7dTKtBtE+zL+MV12SatI2D0yts=; b=U4c+jDgOos7yzATO6VfrK7iFODVtzszcpxg0eRWZh6s1Lmecvxt01wUhsF3iIi06RV J0NsuZRxW6VOjTEM/vBnfyP9WqlMX+CoOQlSnOH/VS0BBr2MkVrxe2i5wB6vVYN4jmBs 4EabTyJwomPCPUnRaXWMKeHdBQGI2ZEgCVvrDoZHqkU5VAK1L5l+oNdbrcvAkYlYJ9up C8J3H9Z1qbNdHj0Yp355FbIa10M66UJL4+RaPvZ/H7Ipi9RTnlYbDLfD+Noi8Yehml2j NDD5xX8ZV0c0OUWAu8c0jmuzXkXZnQVRFmYFG2J7ufa881t280kpAncln+eFlOYLNyez bu5A== X-Gm-Message-State: ALoCoQkWj9mXbDraSUcgHVLVx7jZy3ekqpT18aK4mWE5Njz2+mC/j6Jb9yo+CO8iYBj1dOPVpiUT X-Received: by 10.112.203.168 with SMTP id kr8mr9837597lbc.10.1434625354965; Thu, 18 Jun 2015 04:02:34 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.21.230 with SMTP id y6ls471702lae.20.gmail; Thu, 18 Jun 2015 04:02:34 -0700 (PDT) X-Received: by 10.112.159.9 with SMTP id wy9mr12160409lbb.120.1434625354790; Thu, 18 Jun 2015 04:02:34 -0700 (PDT) Received: from mail-la0-f46.google.com (mail-la0-f46.google.com. [209.85.215.46]) by mx.google.com with ESMTPS id uh5si1993714lbc.115.2015.06.18.04.02.34 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Jun 2015 04:02:34 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) client-ip=209.85.215.46; Received: by laka10 with SMTP id a10so51932040lak.0 for ; Thu, 18 Jun 2015 04:02:34 -0700 (PDT) X-Received: by 10.152.206.75 with SMTP id lm11mr12192077lac.41.1434625354687; Thu, 18 Jun 2015 04:02:34 -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 hn6csp1098267lbb; Thu, 18 Jun 2015 04:02:33 -0700 (PDT) X-Received: by 10.66.157.71 with SMTP id wk7mr19880355pab.99.1434625352736; Thu, 18 Jun 2015 04:02:32 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e7si10870392pdl.156.2015.06.18.04.02.24; Thu, 18 Jun 2015 04:02:32 -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 S1755580AbbFRLCO (ORCPT + 30 others); Thu, 18 Jun 2015 07:02:14 -0400 Received: from mail-pa0-f46.google.com ([209.85.220.46]:33183 "EHLO mail-pa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754636AbbFRK4u (ORCPT ); Thu, 18 Jun 2015 06:56:50 -0400 Received: by padev16 with SMTP id ev16so59068923pad.0 for ; Thu, 18 Jun 2015 03:56:50 -0700 (PDT) X-Received: by 10.70.109.199 with SMTP id hu7mr20290917pdb.71.1434625010581; Thu, 18 Jun 2015 03:56:50 -0700 (PDT) Received: from localhost ([122.167.70.98]) by mx.google.com with ESMTPSA id a10sm7684253pdn.57.2015.06.18.03.56.49 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 18 Jun 2015 03:56:50 -0700 (PDT) From: Viresh Kumar To: Thomas Gleixner , Daniel Lezcano Cc: linaro-kernel@lists.linaro.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Viresh Kumar , Nicolas Ferre , Alexandre Belloni , Jean-Christophe Plagniol-Villard Subject: [PATCH 30/41] clocksource: atmel: Migrate to new 'set-state' interface Date: Thu, 18 Jun 2015 16:24:44 +0530 Message-Id: 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.215.46 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 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 --- 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 c0304ff608b0..58753223585b 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);