From patchwork Fri May 22 15:29:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 48904 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3FDF121411 for ; Fri, 22 May 2015 15:40:34 +0000 (UTC) Received: by wizk4 with SMTP id k4sf14571374wiz.2 for ; Fri, 22 May 2015 08:40:33 -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=olPE7R0N8267NHiwby+Jp1Hr9sbFaSrWAxzscXJj4Y8=; b=OI6VcnEHOuOBcGHbUbcNbtr7o4nLtQVNtHCoy+AcNx7ROHaQYuYz9r1GYcWsxBJqt2 mWQVTXo3zzJF43jc7SqhWBC00Uaw+Zmk9N6hzseFqVpdPZwoe4IC3kj20NjnVSdFXJsh yYHdaXvW3VDO+cL4AghupifdN5Ug9CYZp70ECrg/NzRMxzOh3z6NpE31O0NSfazh0lfG /RktZoQ3J2NghtQjUjwHFUGMki9LfhDvilOeVUpBPJMDrRv1OvatLm9JGLcBJxSbsb2i pyw2+KJglt/juPdJMbXKmBOTpCa/+BTax3+z9c74VZsQmzSKVNzlJgfPhawIbnzDofv4 DA0w== X-Gm-Message-State: ALoCoQnfex2+RJV6msirVrYUwF6tj2jwIHKgQcTuhZdMDcbY/kAVHFomVyrxFv/zlmKHIhLtHExM X-Received: by 10.180.216.12 with SMTP id om12mr4492301wic.1.1432309233516; Fri, 22 May 2015 08:40:33 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.20.226 with SMTP id q2ls523469lae.73.gmail; Fri, 22 May 2015 08:40:33 -0700 (PDT) X-Received: by 10.112.199.195 with SMTP id jm3mr6919141lbc.38.1432309233350; Fri, 22 May 2015 08:40:33 -0700 (PDT) Received: from mail-lb0-f171.google.com (mail-lb0-f171.google.com. [209.85.217.171]) by mx.google.com with ESMTPS id wd2si1621609lbb.123.2015.05.22.08.40.33 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 May 2015 08:40:33 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.171 as permitted sender) client-ip=209.85.217.171; Received: by lbbqq2 with SMTP id qq2so15583477lbb.3 for ; Fri, 22 May 2015 08:40:33 -0700 (PDT) X-Received: by 10.112.219.70 with SMTP id pm6mr6780489lbc.41.1432309233207; Fri, 22 May 2015 08:40:33 -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 hn6csp1498906lbb; Fri, 22 May 2015 08:40:32 -0700 (PDT) X-Received: by 10.70.90.129 with SMTP id bw1mr16739433pdb.85.1432309231325; Fri, 22 May 2015 08:40:31 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id ab8si3916713pad.188.2015.05.22.08.40.30 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 May 2015 08:40:31 -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 1Yvp1J-0003JD-TM; Fri, 22 May 2015 15:37:57 +0000 Received: from mail-pd0-f169.google.com ([209.85.192.169]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Yvow5-0006c3-Ul for linux-arm-kernel@lists.infradead.org; Fri, 22 May 2015 15:32:35 +0000 Received: by pdbnk13 with SMTP id nk13so22208484pdb.1 for ; Fri, 22 May 2015 08:32:10 -0700 (PDT) X-Received: by 10.68.113.194 with SMTP id ja2mr16323684pbb.163.1432308730290; Fri, 22 May 2015 08:32:10 -0700 (PDT) Received: from localhost.localdomain ([107.6.117.178]) by mx.google.com with ESMTPSA id as1sm2474485pbc.39.2015.05.22.08.32.05 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 22 May 2015 08:32:09 -0700 (PDT) From: Shawn Guo To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 10/12] ARM: imx: provide gpt device specific irq functions Date: Fri, 22 May 2015 23:29:57 +0800 Message-Id: <1432308599-28643-11-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_083234_095035_390F67BD X-CRM114-Status: GOOD ( 14.30 ) 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.169 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.169 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.171 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 It splits irq enable/disable/acknowledge operations into device specific functions as the hooks in imx_gpt_data, so that we can save the use of timer_is_xxx() and cpu_is_xxx() checking in these irq functions. Signed-off-by: Shawn Guo --- arch/arm/mach-imx/time.c | 80 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 54 insertions(+), 26 deletions(-) diff --git a/arch/arm/mach-imx/time.c b/arch/arm/mach-imx/time.c index a4f12c75050f..5fb8397d8fe2 100644 --- a/arch/arm/mach-imx/time.c +++ b/arch/arm/mach-imx/time.c @@ -100,6 +100,9 @@ struct imx_gpt_data { int reg_tcn; int reg_tcmp; void (*gpt_setup_tctl)(struct imx_timer *imxtm); + void (*gpt_irq_enable)(struct imx_timer *imxtm); + void (*gpt_irq_disable)(struct imx_timer *imxtm); + void (*gpt_irq_acknowledge)(struct imx_timer *imxtm); int (*set_next_event)(unsigned long evt, struct clock_event_device *ced); }; @@ -109,40 +112,53 @@ 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(struct imx_timer *imxtm) +static void imx1_gpt_irq_disable(struct imx_timer *imxtm) { unsigned int tmp; - if (timer_is_v2()) - writel_relaxed(0, imxtm->base + V2_IR); - else { - tmp = readl_relaxed(imxtm->base + MXC_TCTL); - writel_relaxed(tmp & ~MX1_2_TCTL_IRQEN, imxtm->base + MXC_TCTL); - } + tmp = readl_relaxed(imxtm->base + MXC_TCTL); + writel_relaxed(tmp & ~MX1_2_TCTL_IRQEN, imxtm->base + MXC_TCTL); } +#define imx21_gpt_irq_disable imx1_gpt_irq_disable -static inline void gpt_irq_enable(struct imx_timer *imxtm) +static void imx31_gpt_irq_disable(struct imx_timer *imxtm) { - if (timer_is_v2()) - writel_relaxed(1<<0, imxtm->base + V2_IR); - else { - writel_relaxed(readl_relaxed(imxtm->base + MXC_TCTL) | MX1_2_TCTL_IRQEN, - imxtm->base + MXC_TCTL); - } + writel_relaxed(0, imxtm->base + V2_IR); +} +#define imx6dl_gpt_irq_disable imx31_gpt_irq_disable + +static void imx1_gpt_irq_enable(struct imx_timer *imxtm) +{ + unsigned int tmp; + + tmp = readl_relaxed(imxtm->base + MXC_TCTL); + writel_relaxed(tmp | MX1_2_TCTL_IRQEN, imxtm->base + MXC_TCTL); +} +#define imx21_gpt_irq_enable imx1_gpt_irq_enable + +static void imx31_gpt_irq_enable(struct imx_timer *imxtm) +{ + writel_relaxed(1<<0, imxtm->base + V2_IR); +} +#define imx6dl_gpt_irq_enable imx31_gpt_irq_enable + +static void imx1_gpt_irq_acknowledge(struct imx_timer *imxtm) +{ + writel_relaxed(0, imxtm->base + MX1_2_TSTAT); } -static void gpt_irq_acknowledge(struct imx_timer *imxtm) +static void imx21_gpt_irq_acknowledge(struct imx_timer *imxtm) { - if (timer_is_v1()) { - if (cpu_is_mx1()) - writel_relaxed(0, imxtm->base + MX1_2_TSTAT); - else - writel_relaxed(MX2_TSTAT_CAPT | MX2_TSTAT_COMP, + writel_relaxed(MX2_TSTAT_CAPT | MX2_TSTAT_COMP, imxtm->base + MX1_2_TSTAT); - } else if (timer_is_v2()) - writel_relaxed(V2_TSTAT_OF1, imxtm->base + V2_TSTAT); } +static void imx31_gpt_irq_acknowledge(struct imx_timer *imxtm) +{ + writel_relaxed(V2_TSTAT_OF1, imxtm->base + V2_TSTAT); +} +#define imx6dl_gpt_irq_acknowledge imx31_gpt_irq_acknowledge + static void __iomem *sched_clock_reg; static u64 notrace mxc_read_sched_clock(void) @@ -227,7 +243,7 @@ static void mxc_set_mode(enum clock_event_mode mode, local_irq_save(flags); /* Disable interrupt in GPT module */ - gpt_irq_disable(imxtm); + imxtm->gpt->gpt_irq_disable(imxtm); if (mode != imxtm->cem) { u32 tcn = readl_relaxed(imxtm->base + imxtm->gpt->reg_tcn); @@ -235,7 +251,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(imxtm); + imxtm->gpt->gpt_irq_acknowledge(imxtm); } #ifdef DEBUG @@ -261,7 +277,7 @@ static void mxc_set_mode(enum clock_event_mode mode, * mode switching */ local_irq_save(flags); - gpt_irq_enable(imxtm); + imxtm->gpt->gpt_irq_enable(imxtm); local_irq_restore(flags); break; case CLOCK_EVT_MODE_SHUTDOWN: @@ -283,7 +299,7 @@ static irqreturn_t mxc_timer_interrupt(int irq, void *dev_id) tstat = readl_relaxed(imxtm->base + imxtm->gpt->reg_tstat); - gpt_irq_acknowledge(imxtm); + imxtm->gpt->gpt_irq_acknowledge(imxtm); ced->event_handler(ced); @@ -357,6 +373,9 @@ static const struct imx_gpt_data imx1_gpt_data = { .reg_tstat = MX1_2_TSTAT, .reg_tcn = MX1_2_TCN, .reg_tcmp = MX1_2_TCMP, + .gpt_irq_enable = imx1_gpt_irq_enable, + .gpt_irq_disable = imx1_gpt_irq_disable, + .gpt_irq_acknowledge = imx1_gpt_irq_acknowledge, .gpt_setup_tctl = imx1_gpt_setup_tctl, .set_next_event = mx1_2_set_next_event, }; @@ -365,6 +384,9 @@ static const struct imx_gpt_data imx21_gpt_data = { .reg_tstat = MX1_2_TSTAT, .reg_tcn = MX1_2_TCN, .reg_tcmp = MX1_2_TCMP, + .gpt_irq_enable = imx21_gpt_irq_enable, + .gpt_irq_disable = imx21_gpt_irq_disable, + .gpt_irq_acknowledge = imx21_gpt_irq_acknowledge, .gpt_setup_tctl = imx21_gpt_setup_tctl, .set_next_event = mx1_2_set_next_event, }; @@ -373,6 +395,9 @@ static const struct imx_gpt_data imx31_gpt_data = { .reg_tstat = V2_TSTAT, .reg_tcn = V2_TCN, .reg_tcmp = V2_TCMP, + .gpt_irq_enable = imx31_gpt_irq_enable, + .gpt_irq_disable = imx31_gpt_irq_disable, + .gpt_irq_acknowledge = imx31_gpt_irq_acknowledge, .gpt_setup_tctl = imx31_gpt_setup_tctl, .set_next_event = v2_set_next_event, }; @@ -381,6 +406,9 @@ static const struct imx_gpt_data imx6dl_gpt_data = { .reg_tstat = V2_TSTAT, .reg_tcn = V2_TCN, .reg_tcmp = V2_TCMP, + .gpt_irq_enable = imx6dl_gpt_irq_enable, + .gpt_irq_disable = imx6dl_gpt_irq_disable, + .gpt_irq_acknowledge = imx6dl_gpt_irq_acknowledge, .gpt_setup_tctl = imx6dl_gpt_setup_tctl, .set_next_event = v2_set_next_event, };