From patchwork Thu Jul 16 11:26:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 51158 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 8F3F022A28 for ; Thu, 16 Jul 2015 11:28:24 +0000 (UTC) Received: by widjy10 with SMTP id jy10sf3861888wid.3 for ; Thu, 16 Jul 2015 04:28:23 -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=SXtVQzVuMDACQB+87cfvmURHahA9MeMtFzZMBGFj838=; b=PADacVY/iIWdD1spM6qmjj7AyURup4H0IF8hv3HUBMFHM0qbZYQ/XBjcX/xUkHVSpV 3pd+gE/Ki4WYE5nRdKPmJtyfVIM7218Z69pmbO7NAFwuWhTvwfT5Col6k2J0y2fEu+VL N36COk1Rm/vGi8IeiVXrDi9hrUPzfvJ2gboha5FbB/ciQtEfcQPlzlJe3FiTDpSVk3A8 VUklsw+sohBuz6Ch0sGU0qE37n4dssIqDutKRmUxf1i5hJgwr/JS0Gu231gvQ2rXgb/s d6em1LEYVqcwZ4OjFEbOMPsHi9WsX8oMt76t0XvINiSehhc7vxSbZGg58mTKznKxyQqI FO0A== X-Gm-Message-State: ALoCoQk1VPrmC+rMUkIlU8Ky0lQhPfWo7OIVlPPb7kP+QoIjVCm+exkpOcuAbf0cKVB0pVGG0wIy X-Received: by 10.112.13.200 with SMTP id j8mr4639840lbc.14.1437046103836; Thu, 16 Jul 2015 04:28:23 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.180.135 with SMTP id do7ls353070lac.109.gmail; Thu, 16 Jul 2015 04:28:23 -0700 (PDT) X-Received: by 10.152.28.194 with SMTP id d2mr9071886lah.122.1437046103575; Thu, 16 Jul 2015 04:28:23 -0700 (PDT) Received: from mail-la0-f49.google.com (mail-la0-f49.google.com. [209.85.215.49]) by mx.google.com with ESMTPS id o10si5134808lao.165.2015.07.16.04.28.23 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Jul 2015 04:28:23 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) client-ip=209.85.215.49; Received: by lagx9 with SMTP id x9so41553773lag.1 for ; Thu, 16 Jul 2015 04:28:23 -0700 (PDT) X-Received: by 10.152.22.99 with SMTP id c3mr9123528laf.32.1437046103467; Thu, 16 Jul 2015 04:28:23 -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 hn6csp191631lbb; Thu, 16 Jul 2015 04:28:22 -0700 (PDT) X-Received: by 10.70.133.98 with SMTP id pb2mr17537613pdb.2.1437046101569; Thu, 16 Jul 2015 04:28:21 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y6si12536145pbt.113.2015.07.16.04.28.20; Thu, 16 Jul 2015 04:28:21 -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 S932243AbbGPL2P (ORCPT + 27 others); Thu, 16 Jul 2015 07:28:15 -0400 Received: from mail-pd0-f170.google.com ([209.85.192.170]:33256 "EHLO mail-pd0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932087AbbGPL2M (ORCPT ); Thu, 16 Jul 2015 07:28:12 -0400 Received: by pdbqm3 with SMTP id qm3so43012595pdb.0 for ; Thu, 16 Jul 2015 04:28:12 -0700 (PDT) X-Received: by 10.66.102.103 with SMTP id fn7mr17829704pab.85.1437046092559; Thu, 16 Jul 2015 04:28:12 -0700 (PDT) Received: from localhost ([122.171.186.190]) by smtp.gmail.com with ESMTPSA id kk6sm7643224pdb.94.2015.07.16.04.28.10 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 16 Jul 2015 04:28:11 -0700 (PDT) From: Viresh Kumar To: Thomas Gleixner , Daniel Lezcano Cc: linaro-kernel@lists.linaro.org, linux-kernel@vger.kernel.org, Viresh Kumar , Ley Foon Tan , Tobias Klauser , Herbert Xu , Dmitry Torokhov , nios2-dev@lists.rocketboards.org Subject: [PATCH 11/23] nios2/time: Migrate to new 'set-state' interface Date: Thu, 16 Jul 2015 16:56:23 +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.49 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 nios2 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: Ley Foon Tan Cc: Tobias Klauser Cc: Herbert Xu Cc: Dmitry Torokhov Cc: nios2-dev@lists.rocketboards.org Signed-off-by: Viresh Kumar --- arch/nios2/kernel/time.c | 49 ++++++++++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/arch/nios2/kernel/time.c b/arch/nios2/kernel/time.c index 9e3cc8a40ee9..bbc3f9157f9c 100644 --- a/arch/nios2/kernel/time.c +++ b/arch/nios2/kernel/time.c @@ -130,7 +130,7 @@ static void nios2_timer_stop(struct nios2_timer *timer) } static void nios2_timer_config(struct nios2_timer *timer, unsigned long period, - enum clock_event_mode mode) + bool periodic) { u16 ctrl; @@ -148,7 +148,7 @@ static void nios2_timer_config(struct nios2_timer *timer, unsigned long period, timer_writew(timer, period >> 16, ALTERA_TIMER_PERIODH_REG); ctrl |= ALTERA_TIMER_CONTROL_START_MSK | ALTERA_TIMER_CONTROL_ITO_MSK; - if (mode == CLOCK_EVT_MODE_PERIODIC) + if (periodic) ctrl |= ALTERA_TIMER_CONTROL_CONT_MSK; else ctrl &= ~ALTERA_TIMER_CONTROL_CONT_MSK; @@ -160,32 +160,38 @@ static int nios2_timer_set_next_event(unsigned long delta, { struct nios2_clockevent_dev *nios2_ced = to_nios2_clkevent(evt); - nios2_timer_config(&nios2_ced->timer, delta, evt->mode); + nios2_timer_config(&nios2_ced->timer, delta, false); return 0; } -static void nios2_timer_set_mode(enum clock_event_mode mode, - struct clock_event_device *evt) +static int nios2_timer_shutdown(struct clock_event_device *evt) +{ + struct nios2_clockevent_dev *nios2_ced = to_nios2_clkevent(evt); + struct nios2_timer *timer = &nios2_ced->timer; + + nios2_timer_stop(timer); + return 0; +} + +static int nios2_timer_set_periodic(struct clock_event_device *evt) { unsigned long period; struct nios2_clockevent_dev *nios2_ced = to_nios2_clkevent(evt); struct nios2_timer *timer = &nios2_ced->timer; - switch (mode) { - case CLOCK_EVT_MODE_PERIODIC: - period = DIV_ROUND_UP(timer->freq, HZ); - nios2_timer_config(timer, period, CLOCK_EVT_MODE_PERIODIC); - break; - case CLOCK_EVT_MODE_ONESHOT: - case CLOCK_EVT_MODE_UNUSED: - case CLOCK_EVT_MODE_SHUTDOWN: - nios2_timer_stop(timer); - break; - case CLOCK_EVT_MODE_RESUME: - nios2_timer_start(timer); - break; - } + period = DIV_ROUND_UP(timer->freq, HZ); + nios2_timer_config(timer, period, true); + return 0; +} + +static int nios2_timer_resume(struct clock_event_device *evt) +{ + struct nios2_clockevent_dev *nios2_ced = to_nios2_clkevent(evt); + struct nios2_timer *timer = &nios2_ced->timer; + + nios2_timer_start(timer); + return 0; } irqreturn_t timer_interrupt(int irq, void *dev_id) @@ -218,7 +224,10 @@ static struct nios2_clockevent_dev nios2_ce = { .rating = 250, .shift = 32, .set_next_event = nios2_timer_set_next_event, - .set_mode = nios2_timer_set_mode, + .set_state_shutdown = nios2_timer_shutdown, + .set_state_periodic = nios2_timer_set_periodic, + .set_state_oneshot = nios2_timer_shutdown, + .tick_resume = nios2_timer_resume, }, };