From patchwork Thu Jun 20 22:12:49 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Figa X-Patchwork-Id: 2758831 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 310F49F472 for ; Thu, 20 Jun 2013 22:14:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5F6F4201FC for ; Thu, 20 Jun 2013 22:14:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A579E20205 for ; Thu, 20 Jun 2013 22:14:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758510Ab3FTWOJ (ORCPT ); Thu, 20 Jun 2013 18:14:09 -0400 Received: from mail-bk0-f49.google.com ([209.85.214.49]:63756 "EHLO mail-bk0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758502Ab3FTWOI (ORCPT ); Thu, 20 Jun 2013 18:14:08 -0400 Received: by mail-bk0-f49.google.com with SMTP id mz10so3095258bkb.8 for ; Thu, 20 Jun 2013 15:14:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=qbQeaX8XksQcmikKcszrZbOdljmd86vNqt7FS6ZGaTU=; b=M194sem8Q9b118PHyN42JZvYBDaZZOUfK+cYQkTzpDHskiOHzzFy51Zz8DBH88WoDr W4vTlCoriuVp3+sbry3dI0qaRUHDog50FM845hVwxRja4CAXnfQiWmWLUkLnH+6hRCqi jeZmXw1XBZt6q0i5sgComIMn9j1CuwXDRMUUV8pJDXNKnaANQqdUXNqcADSTBgA34NJM Tuo7M4lFZcTFDdYbfqRL03ym/c3/ySOTU66X9xMUqM+EyK+I6i9FxFCB10HEtiFMpSzH Qef5llOYjfO7ASRD5Wh69ZE3lSQOHzK3wo4XRUJKThqvYYxZStZlggchBoWZ46ZJOZWR b1Iw== X-Received: by 10.205.32.198 with SMTP id sl6mr1441537bkb.20.1371766446966; Thu, 20 Jun 2013 15:14:06 -0700 (PDT) Received: from flatron.tomeq (87-207-52-162.dynamic.chello.pl. [87.207.52.162]) by mx.google.com with ESMTPSA id fc7sm864232bkc.3.2013.06.20.15.14.04 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 20 Jun 2013 15:14:06 -0700 (PDT) From: Tomasz Figa To: linux-samsung-soc@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-pwm@vger.kernel.org, Kukjin Kim , Arnd Bergmann , Olof Johansson , Sylwester Nawrocki , =?UTF-8?q?Heiko=20St=C3=BCbner?= , Mark Brown , Thomas Abraham , Thierry Reding , Tomasz Figa Subject: [PATCH v2 04/18] clocksource: samsung_pwm_timer: Cache clocksource register address Date: Fri, 21 Jun 2013 00:12:49 +0200 Message-Id: <1371766383-29077-5-git-send-email-tomasz.figa@gmail.com> X-Mailer: git-send-email 1.8.2.1 In-Reply-To: <1371766383-29077-1-git-send-email-tomasz.figa@gmail.com> References: <1371766383-29077-1-git-send-email-tomasz.figa@gmail.com> Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-8.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Instead of calculating register every time the timer should be read, we can just do it one time at initialization and store the address in driver data. Signed-off-by: Tomasz Figa --- drivers/clocksource/samsung_pwm_timer.c | 33 ++++++++------------------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/drivers/clocksource/samsung_pwm_timer.c b/drivers/clocksource/samsung_pwm_timer.c index 553115b..d361b5e 100644 --- a/drivers/clocksource/samsung_pwm_timer.c +++ b/drivers/clocksource/samsung_pwm_timer.c @@ -54,6 +54,7 @@ EXPORT_SYMBOL(samsung_pwm_lock); struct samsung_pwm_clocksource { void __iomem *base; + void __iomem *source_reg; unsigned int irq[SAMSUNG_PWM_NUM]; struct samsung_pwm_variant variant; @@ -286,23 +287,6 @@ static void __init samsung_clockevent_init(void) } } -static void __iomem *samsung_timer_reg(void) -{ - switch (pwm.source_id) { - case 0: - case 1: - case 2: - case 3: - return pwm.base + pwm.source_id * 0x0c + 0x14; - - case 4: - return pwm.base + 0x40; - - default: - BUG(); - } -} - /* * Override the global weak sched_clock symbol with this * local implementation which uses the clocksource to get some @@ -312,17 +296,11 @@ static void __iomem *samsung_timer_reg(void) */ static u32 notrace samsung_read_sched_clock(void) { - void __iomem *reg = samsung_timer_reg(); - - if (!reg) - return 0; - - return ~__raw_readl(reg); + return ~__raw_readl(pwm.source_reg); } static void __init samsung_clocksource_init(void) { - void __iomem *reg = samsung_timer_reg(); unsigned long pclk; unsigned long clock_rate; int ret; @@ -337,10 +315,15 @@ static void __init samsung_clocksource_init(void) samsung_time_setup(pwm.source_id, pwm.tcnt_max); samsung_time_start(pwm.source_id, true); + if (pwm.source_id == 4) + pwm.source_reg = pwm.base + 0x40; + else + pwm.source_reg = pwm.base + pwm.source_id * 0x0c + 0x14; + setup_sched_clock(samsung_read_sched_clock, pwm.variant.bits, clock_rate); - ret = clocksource_mmio_init(reg, "samsung_clocksource_timer", + ret = clocksource_mmio_init(pwm.source_reg, "samsung_clocksource_timer", clock_rate, 250, pwm.variant.bits, clocksource_mmio_readl_down); if (ret)