From patchwork Sat Jul 20 00:04:16 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Figa X-Patchwork-Id: 2830727 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 1BFDBC0319 for ; Sat, 20 Jul 2013 00:04:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3CA39201EB for ; Sat, 20 Jul 2013 00:04:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2EF30201C6 for ; Sat, 20 Jul 2013 00:04:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751786Ab3GTAE4 (ORCPT ); Fri, 19 Jul 2013 20:04:56 -0400 Received: from mail-ea0-f175.google.com ([209.85.215.175]:63075 "EHLO mail-ea0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752374Ab3GTAE4 (ORCPT ); Fri, 19 Jul 2013 20:04:56 -0400 Received: by mail-ea0-f175.google.com with SMTP id z7so2675917eaf.34 for ; Fri, 19 Jul 2013 17:04:54 -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=5YrzgCrrJHCQuMz37J+B2fz9yV6p3cvTOr4yTX7wH3M=; b=ycfaRTHSV8BeddqsmaizDCxXsFPRtRzReMOfJYbbzHMhCb12HVfz7OQ8lb/IzxnsrW wzOFtjbEZBLPTINF8IBU+hPtUz1bIbjZjesrgXqbNXd2b6YAt78Ry+bioB0vOE5Uu6M+ YI0NmGOEAjB/yEAQR1CV0eJEmM5G1L/htCULx6sWmoRUXW0rZ/iRokzWbe9YiY3IdHnT 8SpF3vyphGv469R4A44zOOISIaOeCjLEeRIskRSEM5g/GSw+6tRugfpOmhVaXS46xuWE luoS/CN7tQgvC1X74svrGVIJKyW0frDaPgcysi5tUST0QJ+VMNNPJ0TviCmvFoRayltB NvGA== X-Received: by 10.14.0.131 with SMTP id 3mr17722494eeb.98.1374278694754; Fri, 19 Jul 2013 17:04:54 -0700 (PDT) Received: from flatron.tomeq (87-207-52-162.dynamic.chello.pl. [87.207.52.162]) by mx.google.com with ESMTPSA id bj46sm31186249eeb.13.2013.07.19.17.04.52 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 19 Jul 2013 17:04:53 -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 , Thierry Reding , Tomasz Figa Subject: [PATCH v4 03/20] clocksource: samsung_pwm_timer: Cache clocksource register address Date: Sat, 20 Jul 2013 02:04:16 +0200 Message-Id: <1374278673-25615-5-git-send-email-tomasz.figa@gmail.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1374278673-25615-1-git-send-email-tomasz.figa@gmail.com> References: <1374278673-25615-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=-7.2 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 e238fb0..823279b 100644 --- a/drivers/clocksource/samsung_pwm_timer.c +++ b/drivers/clocksource/samsung_pwm_timer.c @@ -55,6 +55,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; @@ -287,23 +288,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 @@ -313,17 +297,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; @@ -338,10 +316,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)