From patchwork Fri May 22 15:29:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 48903 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 504EA21411 for ; Fri, 22 May 2015 15:39:20 +0000 (UTC) Received: by labcd2 with SMTP id cd2sf6259484lab.0 for ; Fri, 22 May 2015 08:39:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id :in-reply-to:references:cc:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version :content-type:content-transfer-encoding:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list; bh=JOlNUq66alkK9/hUYL+39CYZys5N01xfLXfqR00DwDg=; b=QO4fy92+vfCk9EquomU4ovzNTGAI/gc+p70aVBKoBVnBDL0GBJ/R1y2CmBwT0c3EHD TFo6hpW5sSPBIwI16Amrz6PGZpyKqej187oEIdSKeJToI9YTLGrgsRu7esPPj5A7KxP8 R6EA5XOefI9hcs9BwMtVw+mtElDlSGlxYrwmZ3AoeF4z2ic3c0OCKdcmIdxrk2KbJkoW 4LU+fhK7tIPzAnsiiWTJXlO1qKDGAynidZI4IKioOsgI0WZXG1cM6s3pVHNkpFnnX6vA 2135s7GkPbmodrNH6+l1/5A/qiLDxOaXQEQCG0K7jMsheSuCsxyWe9uGl+NPtW9MgEWf 2NrA== X-Gm-Message-State: ALoCoQkVHpZbo7xvtetfeikh0vK8pZEEUqPYVEBfmdODN2yP3H3bTpcYijcAni2/k58PAk/NJCl2 X-Received: by 10.112.28.111 with SMTP id a15mr8281960lbh.21.1432309159238; Fri, 22 May 2015 08:39:19 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.23.129 with SMTP id m1ls468623laf.76.gmail; Fri, 22 May 2015 08:39:19 -0700 (PDT) X-Received: by 10.112.139.130 with SMTP id qy2mr6929368lbb.33.1432309159093; Fri, 22 May 2015 08:39:19 -0700 (PDT) Received: from mail-lb0-f177.google.com (mail-lb0-f177.google.com. [209.85.217.177]) by mx.google.com with ESMTPS id g1si1614131laf.139.2015.05.22.08.39.19 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 May 2015 08:39:19 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) client-ip=209.85.217.177; Received: by lbbzk7 with SMTP id zk7so15672571lbb.0 for ; Fri, 22 May 2015 08:39:19 -0700 (PDT) X-Received: by 10.152.4.137 with SMTP id k9mr6795310lak.29.1432309158941; Fri, 22 May 2015 08:39:18 -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 hn6csp1498087lbb; Fri, 22 May 2015 08:39:17 -0700 (PDT) X-Received: by 10.68.205.33 with SMTP id ld1mr17072751pbc.22.1432309157219; Fri, 22 May 2015 08:39:17 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id rt15si3891118pab.240.2015.05.22.08.39.16 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 May 2015 08:39:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Yvp0F-0002GD-Qh; Fri, 22 May 2015 15:36:51 +0000 Received: from mail-pd0-f180.google.com ([209.85.192.180]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Yvovy-0006Xg-AA for linux-arm-kernel@lists.infradead.org; Fri, 22 May 2015 15:32:27 +0000 Received: by pdbqa5 with SMTP id qa5so22277045pdb.0 for ; Fri, 22 May 2015 08:32:05 -0700 (PDT) X-Received: by 10.66.66.197 with SMTP id h5mr16966843pat.29.1432308725096; Fri, 22 May 2015 08:32:05 -0700 (PDT) Received: from localhost.localdomain ([107.6.117.178]) by mx.google.com with ESMTPSA id as1sm2474485pbc.39.2015.05.22.08.31.58 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 22 May 2015 08:32:04 -0700 (PDT) From: Shawn Guo To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 09/12] ARM: imx: get rid of variable timer_base Date: Fri, 22 May 2015 23:29:56 +0800 Message-Id: <1432308599-28643-10-git-send-email-shawn.guo@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1432308599-28643-1-git-send-email-shawn.guo@linaro.org> References: <1432308599-28643-1-git-send-email-shawn.guo@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150522_083226_397266_D83B2911 X-CRM114-Status: GOOD ( 16.33 ) X-Spam-Score: -1.8 (-) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-1.8 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.192.180 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.1 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.192.180 listed in wl.mailspike.net] Cc: Shawn Guo , Daniel Lezcano , Arnd Bergmann , kernel@pengutronix.de, Shenwei Wang X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: shawn.guo@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.217.177 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 We now have pointer to imx_timer structure available where timer base address is needed, so we can just kill global timer_base by using imxtm->base instead. Signed-off-by: Shawn Guo --- arch/arm/mach-imx/time.c | 55 +++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 29 deletions(-) diff --git a/arch/arm/mach-imx/time.c b/arch/arm/mach-imx/time.c index da1ad20d2c1d..a4f12c75050f 100644 --- a/arch/arm/mach-imx/time.c +++ b/arch/arm/mach-imx/time.c @@ -104,45 +104,43 @@ struct imx_gpt_data { struct clock_event_device *ced); }; -static void __iomem *timer_base; - static inline struct imx_timer *to_imx_timer(struct clock_event_device *ced) { return container_of(ced, struct imx_timer, ced); } -static inline void gpt_irq_disable(void) +static inline void gpt_irq_disable(struct imx_timer *imxtm) { unsigned int tmp; if (timer_is_v2()) - writel_relaxed(0, timer_base + V2_IR); + writel_relaxed(0, imxtm->base + V2_IR); else { - tmp = readl_relaxed(timer_base + MXC_TCTL); - writel_relaxed(tmp & ~MX1_2_TCTL_IRQEN, timer_base + MXC_TCTL); + tmp = readl_relaxed(imxtm->base + MXC_TCTL); + writel_relaxed(tmp & ~MX1_2_TCTL_IRQEN, imxtm->base + MXC_TCTL); } } -static inline void gpt_irq_enable(void) +static inline void gpt_irq_enable(struct imx_timer *imxtm) { if (timer_is_v2()) - writel_relaxed(1<<0, timer_base + V2_IR); + writel_relaxed(1<<0, imxtm->base + V2_IR); else { - writel_relaxed(readl_relaxed(timer_base + MXC_TCTL) | MX1_2_TCTL_IRQEN, - timer_base + MXC_TCTL); + writel_relaxed(readl_relaxed(imxtm->base + MXC_TCTL) | MX1_2_TCTL_IRQEN, + imxtm->base + MXC_TCTL); } } -static void gpt_irq_acknowledge(void) +static void gpt_irq_acknowledge(struct imx_timer *imxtm) { if (timer_is_v1()) { if (cpu_is_mx1()) - writel_relaxed(0, timer_base + MX1_2_TSTAT); + writel_relaxed(0, imxtm->base + MX1_2_TSTAT); else writel_relaxed(MX2_TSTAT_CAPT | MX2_TSTAT_COMP, - timer_base + MX1_2_TSTAT); + imxtm->base + MX1_2_TSTAT); } else if (timer_is_v2()) - writel_relaxed(V2_TSTAT_OF1, timer_base + V2_TSTAT); + writel_relaxed(V2_TSTAT_OF1, imxtm->base + V2_TSTAT); } static void __iomem *sched_clock_reg; @@ -178,29 +176,31 @@ static int __init mxc_clocksource_init(struct imx_timer *imxtm) /* clock event */ static int mx1_2_set_next_event(unsigned long evt, - struct clock_event_device *unused) + struct clock_event_device *ced) { + struct imx_timer *imxtm = to_imx_timer(ced); unsigned long tcmp; - tcmp = readl_relaxed(timer_base + MX1_2_TCN) + evt; + tcmp = readl_relaxed(imxtm->base + MX1_2_TCN) + evt; - writel_relaxed(tcmp, timer_base + MX1_2_TCMP); + writel_relaxed(tcmp, imxtm->base + MX1_2_TCMP); - return (int)(tcmp - readl_relaxed(timer_base + MX1_2_TCN)) < 0 ? + return (int)(tcmp - readl_relaxed(imxtm->base + MX1_2_TCN)) < 0 ? -ETIME : 0; } static int v2_set_next_event(unsigned long evt, - struct clock_event_device *unused) + struct clock_event_device *ced) { + struct imx_timer *imxtm = to_imx_timer(ced); unsigned long tcmp; - tcmp = readl_relaxed(timer_base + V2_TCN) + evt; + tcmp = readl_relaxed(imxtm->base + V2_TCN) + evt; - writel_relaxed(tcmp, timer_base + V2_TCMP); + writel_relaxed(tcmp, imxtm->base + V2_TCMP); return evt < 0x7fffffff && - (int)(tcmp - readl_relaxed(timer_base + V2_TCN)) < 0 ? + (int)(tcmp - readl_relaxed(imxtm->base + V2_TCN)) < 0 ? -ETIME : 0; } @@ -227,7 +227,7 @@ static void mxc_set_mode(enum clock_event_mode mode, local_irq_save(flags); /* Disable interrupt in GPT module */ - gpt_irq_disable(); + gpt_irq_disable(imxtm); if (mode != imxtm->cem) { u32 tcn = readl_relaxed(imxtm->base + imxtm->gpt->reg_tcn); @@ -235,7 +235,7 @@ static void mxc_set_mode(enum clock_event_mode mode, writel_relaxed(tcn - 3, imxtm->base + imxtm->gpt->reg_tcmp); /* Clear pending interrupt */ - gpt_irq_acknowledge(); + gpt_irq_acknowledge(imxtm); } #ifdef DEBUG @@ -261,7 +261,7 @@ static void mxc_set_mode(enum clock_event_mode mode, * mode switching */ local_irq_save(flags); - gpt_irq_enable(); + gpt_irq_enable(imxtm); local_irq_restore(flags); break; case CLOCK_EVT_MODE_SHUTDOWN: @@ -283,7 +283,7 @@ static irqreturn_t mxc_timer_interrupt(int irq, void *dev_id) tstat = readl_relaxed(imxtm->base + imxtm->gpt->reg_tstat); - gpt_irq_acknowledge(); + gpt_irq_acknowledge(imxtm); ced->event_handler(ced); @@ -387,9 +387,6 @@ static const struct imx_gpt_data imx6dl_gpt_data = { static void __init _mxc_timer_init(struct imx_timer *imxtm) { - /* Temporary */ - timer_base = imxtm->base; - switch (imxtm->type) { case GPT_TYPE_IMX1: imxtm->gpt = &imx1_gpt_data;