From patchwork Fri Jul 17 05:11:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 51225 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 ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 374EB22A28 for ; Fri, 17 Jul 2015 05:13:47 +0000 (UTC) Received: by wizo10 with SMTP id o10sf9229394wiz.0 for ; Thu, 16 Jul 2015 22:13:46 -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=3h3ipkWGboXcx8JvWlZ7SJ/CjpKbYDyTHJXzDdVk5qc=; b=GzS+HlQFcYKjrQFUo5Us8qO1YtkvGLCqUHYvXULrg0+y2qFWScUv9byIL+0G7KEAeV 6KQipgtNoCVrvKLBV/ppp7Moi0tRjkCkLxZ92xc+naAKz/yRR9McLTwProxZZM5UnnCO I9UoW8aNoigJGIGRrJegQjQR5fHcMV30/EUkXsCpAFq/NTQLOrHOe+J+Ds6ThEX45hhC QQ10U93ZsHttVUbLJbC/L93d/PTLmuAF3TLnFHaBrqXbfIJ12TfmW3L0v/vh2npVWFm+ 2+5a0prqt23m3l5qe1dNEcX+EL5Yu7lzyj2p1MOULZP4yCcYErVdoMSgNXvwVPtalTOD 8ZQA== X-Gm-Message-State: ALoCoQlY3yQ2HohMgW63rDTeXhjhgRHUzSS02hyE6l8VYUHpoPDZAo9mOOaG9VCfwDloT7TZgPzo X-Received: by 10.194.209.180 with SMTP id mn20mr6613458wjc.5.1437110026548; Thu, 16 Jul 2015 22:13:46 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.7.105 with SMTP id i9ls429840laa.96.gmail; Thu, 16 Jul 2015 22:13:46 -0700 (PDT) X-Received: by 10.112.205.1 with SMTP id lc1mr12678301lbc.94.1437110026281; Thu, 16 Jul 2015 22:13:46 -0700 (PDT) Received: from mail-la0-f47.google.com (mail-la0-f47.google.com. [209.85.215.47]) by mx.google.com with ESMTPS id k8si8877842lag.64.2015.07.16.22.13.46 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Jul 2015 22:13:46 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.47 as permitted sender) client-ip=209.85.215.47; Received: by laem6 with SMTP id m6so55082972lae.0 for ; Thu, 16 Jul 2015 22:13:46 -0700 (PDT) X-Received: by 10.112.199.133 with SMTP id jk5mr13003373lbc.32.1437110026166; Thu, 16 Jul 2015 22:13:46 -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 hn6csp668789lbb; Thu, 16 Jul 2015 22:13:45 -0700 (PDT) X-Received: by 10.66.66.172 with SMTP id g12mr25794669pat.74.1437110024412; Thu, 16 Jul 2015 22:13:44 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bk7si16689973pdb.11.2015.07.16.22.13.43; Thu, 16 Jul 2015 22:13:44 -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 S1756966AbbGQFNm (ORCPT + 28 others); Fri, 17 Jul 2015 01:13:42 -0400 Received: from mail-pa0-f45.google.com ([209.85.220.45]:34582 "EHLO mail-pa0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751962AbbGQFMp (ORCPT ); Fri, 17 Jul 2015 01:12:45 -0400 Received: by pacan13 with SMTP id an13so54835885pac.1 for ; Thu, 16 Jul 2015 22:12:44 -0700 (PDT) X-Received: by 10.68.181.163 with SMTP id dx3mr25463399pbc.5.1437109964458; Thu, 16 Jul 2015 22:12:44 -0700 (PDT) Received: from localhost ([122.171.186.190]) by smtp.gmail.com with ESMTPSA id ia3sm9697069pbc.31.2015.07.16.22.12.43 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 16 Jul 2015 22:12:43 -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 , Shiraz Hashim , linux-kernel@vger.kernel.org (open list), Russell King , spear-devel@list.st.com (open list:SPEAR PLATFORM SUPPORT), Viresh Kumar Subject: [PATCH 15/18] ARM/SPEAr/time: Migrate to new 'set-state' interface Date: Fri, 17 Jul 2015 10:41:09 +0530 Message-Id: <7639c0b8b3d5e061253936ed5279ff674be238cb.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.215.47 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 SPEAr 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 kill the unnecessary forward declaration of set-mode routine by moving 'struct clock_event_device clkevt' towards the bottom of the file. Cc: Shiraz Hashim Signed-off-by: Viresh Kumar --- arch/arm/mach-spear/time.c | 89 ++++++++++++++++++++++++++-------------------- 1 file changed, 50 insertions(+), 39 deletions(-) diff --git a/arch/arm/mach-spear/time.c b/arch/arm/mach-spear/time.c index 26fda4ed4d51..94342a0966e3 100644 --- a/arch/arm/mach-spear/time.c +++ b/arch/arm/mach-spear/time.c @@ -66,8 +66,6 @@ static __iomem void *gpt_base; static struct clk *gpt_clk; -static void clockevent_set_mode(enum clock_event_mode mode, - struct clock_event_device *clk_event_dev); static int clockevent_next_event(unsigned long evt, struct clock_event_device *clk_event_dev); @@ -95,54 +93,67 @@ static void __init spear_clocksource_init(void) 200, 16, clocksource_mmio_readw_up); } -static struct clock_event_device clkevt = { - .name = "tmr0", - .features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT, - .set_mode = clockevent_set_mode, - .set_next_event = clockevent_next_event, - .shift = 0, /* to be computed */ -}; +static inline void timer_shutdown(struct clock_event_device *evt) +{ + u16 val = readw(gpt_base + CR(CLKEVT)); + + /* stop the timer */ + val &= ~CTRL_ENABLE; + writew(val, gpt_base + CR(CLKEVT)); +} + +static int spear_shutdown(struct clock_event_device *evt) +{ + timer_shutdown(evt); + + return 0; +} + +static int spear_set_oneshot(struct clock_event_device *evt) +{ + u16 val; -static void clockevent_set_mode(enum clock_event_mode mode, - struct clock_event_device *clk_event_dev) + /* stop the timer */ + timer_shutdown(evt); + + val = readw(gpt_base + CR(CLKEVT)); + val |= CTRL_ONE_SHOT; + writew(val, gpt_base + CR(CLKEVT)); + + return 0; +} + +static int spear_set_periodic(struct clock_event_device *evt) { u32 period; u16 val; /* stop the timer */ + timer_shutdown(evt); + + period = clk_get_rate(gpt_clk) / HZ; + period >>= CTRL_PRESCALER16; + writew(period, gpt_base + LOAD(CLKEVT)); + val = readw(gpt_base + CR(CLKEVT)); - val &= ~CTRL_ENABLE; + val &= ~CTRL_ONE_SHOT; + val |= CTRL_ENABLE | CTRL_INT_ENABLE; writew(val, gpt_base + CR(CLKEVT)); - switch (mode) { - case CLOCK_EVT_MODE_PERIODIC: - period = clk_get_rate(gpt_clk) / HZ; - period >>= CTRL_PRESCALER16; - writew(period, gpt_base + LOAD(CLKEVT)); - - val = readw(gpt_base + CR(CLKEVT)); - val &= ~CTRL_ONE_SHOT; - val |= CTRL_ENABLE | CTRL_INT_ENABLE; - writew(val, gpt_base + CR(CLKEVT)); - - break; - case CLOCK_EVT_MODE_ONESHOT: - val = readw(gpt_base + CR(CLKEVT)); - val |= CTRL_ONE_SHOT; - writew(val, gpt_base + CR(CLKEVT)); - - break; - case CLOCK_EVT_MODE_UNUSED: - case CLOCK_EVT_MODE_SHUTDOWN: - case CLOCK_EVT_MODE_RESUME: - - break; - default: - pr_err("Invalid mode requested\n"); - break; - } + return 0; } +static struct clock_event_device clkevt = { + .name = "tmr0", + .features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT, + .set_state_shutdown = spear_shutdown, + .set_state_periodic = spear_set_periodic, + .set_state_oneshot = spear_set_oneshot, + .tick_resume = spear_shutdown, + .set_next_event = clockevent_next_event, + .shift = 0, /* to be computed */ +}; + static int clockevent_next_event(unsigned long cycles, struct clock_event_device *clk_event_dev) {