Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2648145imm; Mon, 10 Sep 2018 04:33:24 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbH45qYsA5rdzRe9ySeHjGF/4T/1fxJqaQnccZ3nPwYDHyeMJZUVcsRY3zfY+e7G27fS9Mt X-Received: by 2002:a17:902:22:: with SMTP id 31-v6mr21282214pla.190.1536579204805; Mon, 10 Sep 2018 04:33:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536579204; cv=none; d=google.com; s=arc-20160816; b=U5VtrNjMRW8xP4EYSZPagP4twGYvgLmoWUy2o4R037RIUsC1oc/IneHXoDu45syIQu 2vyraHIkM+yEtVKx61tzePrFs1zzi3MrMS3kg27YJabLACN17oKZUe9VEdHeY8sofMkt 7pRayMU3Iu6A3F3oX9Epnprw4bon4uEpKZ99NlCbh5IPvurmb5BPeQlmtuiXWniH8HT9 +XEUTTh/1bvdzn9iR/ZxaKCTFkN0IllAaPvx9zp1kcwAfgDBzFhQpCNIhXiIaVlgSzsO 0A6/vzgphdDXVBucWH7v+vuj3ECNnnISe51tGdkNtYz3uoAIfYUDSExmofMKElPvrejY nwdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=PMVAia8a3/5tOpeO9Ba7ByKpNHkpDJu5WpKoOLXdRIo=; b=j9v0xRRG+dAHvIoUSHoOyR11uZH6Y/9LE2XKeHAj+ZN59ur2bP8yksKXmsndcJyx6/ 3xIjLeb/xUZ+iNr9PrTVwaJhrOQ1VNjHM8ZynnpSE+aj1tGlzsHsI8pqyEUN6Xiksmrv IkISQOtViBDBTks9FEWJcb9l2fbpPcyiDU9iEbqGbceJSsJmssf8FiCjR3FvfBbV2rtY Y9xWxBWBZxW4jhhMRrIonQ87itYpnXHArIr7hYaGh7kNrOhvdREk/WO+xGHVSpom0Z8H T8KoW73qbuCL6rYxqU74gt5e93vvligrPWiE9oM6CmcBxyi21kLjPC6QUrjksNq4t9wH wnUg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p24-v6si15819236plo.52.2018.09.10.04.33.09; Mon, 10 Sep 2018 04:33:24 -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; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728439AbeIJQY0 (ORCPT + 99 others); Mon, 10 Sep 2018 12:24:26 -0400 Received: from shell.v3.sk ([90.176.6.54]:35866 "EHLO shell.v3.sk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728356AbeIJQYZ (ORCPT ); Mon, 10 Sep 2018 12:24:25 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.v3.sk (Postfix) with ESMTP id 2D908B82E3; Mon, 10 Sep 2018 13:30:45 +0200 (CEST) Received: from shell.v3.sk ([127.0.0.1]) by localhost (zimbra.v3.sk [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id nxQoKimiiHet; Mon, 10 Sep 2018 13:30:38 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by zimbra.v3.sk (Postfix) with ESMTP id F34CFB82E5; Mon, 10 Sep 2018 13:30:37 +0200 (CEST) X-Virus-Scanned: amavisd-new at zimbra.v3.sk Received: from shell.v3.sk ([127.0.0.1]) by localhost (zimbra.v3.sk [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 8gA-HBxJKYA9; Mon, 10 Sep 2018 13:30:36 +0200 (CEST) Received: from belphegor.brq.redhat.com (nat-pool-brq-t.redhat.com [213.175.37.10]) by zimbra.v3.sk (Postfix) with ESMTPSA id 34963B82E6; Mon, 10 Sep 2018 13:30:36 +0200 (CEST) From: Lubomir Rintel To: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, Daniel Lezcano , Thomas Gleixner , Rob Herring , Mark Rutland , Eric Miao , Haojian Zhuang , Russell King , Lubomir Rintel Subject: [PATCH 4/4] ARM: mmp/mmp2: dt: enable the clock Date: Mon, 10 Sep 2018 13:30:31 +0200 Message-Id: <20180910113031.42634-5-lkundrak@v3.sk> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180910113031.42634-1-lkundrak@v3.sk> References: <20180910113031.42634-1-lkundrak@v3.sk> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The device-tree booted MMP2 needs to enable the timer clock, otherwise the it would stop ticking when the boot finishes. It can also use the clock rate from the clk, the non-DT boards need to keep using the hardcoded rates. Signed-off-by: Lubomir Rintel --- arch/arm/mach-mmp/common.h | 2 +- arch/arm/mach-mmp/mmp2.c | 2 +- arch/arm/mach-mmp/pxa168.c | 2 +- arch/arm/mach-mmp/time.c | 29 +++++++++++++++++------------ 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/arch/arm/mach-mmp/common.h b/arch/arm/mach-mmp/common.h index 7e284d9c429f..5ac2851ef5d3 100644 --- a/arch/arm/mach-mmp/common.h +++ b/arch/arm/mach-mmp/common.h @@ -2,7 +2,7 @@ #include #define ARRAY_AND_SIZE(x) (x), ARRAY_SIZE(x) -extern void timer_init(int irq); +extern void timer_init(int irq, unsigned long rate); extern void __init mmp_map_io(void); extern void mmp_restart(enum reboot_mode, const char *); diff --git a/arch/arm/mach-mmp/mmp2.c b/arch/arm/mach-mmp/mmp2.c index afba5460cdaf..fb3e7e32c882 100644 --- a/arch/arm/mach-mmp/mmp2.c +++ b/arch/arm/mach-mmp/mmp2.c @@ -134,7 +134,7 @@ void __init mmp2_timer_init(void) clk_rst = APBC_APBCLK | APBC_FNCLK | APBC_FNCLKSEL(1); __raw_writel(clk_rst, APBC_TIMERS); - timer_init(IRQ_MMP2_TIMER1); + timer_init(IRQ_MMP2_TIMER1, 6500000); } /* on-chip devices */ diff --git a/arch/arm/mach-mmp/pxa168.c b/arch/arm/mach-mmp/pxa168.c index 0f5f16fb8c66..77a358165a56 100644 --- a/arch/arm/mach-mmp/pxa168.c +++ b/arch/arm/mach-mmp/pxa168.c @@ -79,7 +79,7 @@ void __init pxa168_timer_init(void) /* 3.25MHz, bus/functional clock enabled, release reset */ __raw_writel(TIMER_CLK_RST, APBC_TIMERS); - timer_init(IRQ_PXA168_TIMER1); + timer_init(IRQ_PXA168_TIMER1, 6500000); } void pxa168_clear_keypad_wakeup(void) diff --git a/arch/arm/mach-mmp/time.c b/arch/arm/mach-mmp/time.c index 96ad1db0b04b..ed754a8eef79 100644 --- a/arch/arm/mach-mmp/time.c +++ b/arch/arm/mach-mmp/time.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -38,12 +39,6 @@ #include "cputype.h" #include "clock.h" -#ifdef CONFIG_CPU_MMP2 -#define MMP_CLOCK_FREQ 6500000 -#else -#define MMP_CLOCK_FREQ 3250000 -#endif - #define TIMERS_VIRT_BASE TIMERS1_VIRT_BASE #define MAX_DELTA (0xfffffffe) @@ -189,19 +184,18 @@ static struct irqaction timer_irq = { .dev_id = &ckevt, }; -void __init timer_init(int irq) +void __init timer_init(int irq, unsigned long rate) { timer_config(); - sched_clock_register(mmp_read_sched_clock, 32, MMP_CLOCK_FREQ); + sched_clock_register(mmp_read_sched_clock, 32, rate); ckevt.cpumask = cpumask_of(0); setup_irq(irq, &timer_irq); - clocksource_register_hz(&cksrc, MMP_CLOCK_FREQ); - clockevents_config_and_register(&ckevt, MMP_CLOCK_FREQ, - MIN_DELTA, MAX_DELTA); + clocksource_register_hz(&cksrc, rate); + clockevents_config_and_register(&ckevt, rate, MIN_DELTA, MAX_DELTA); } #ifdef CONFIG_OF @@ -213,6 +207,7 @@ static const struct of_device_id mmp_timer_dt_ids[] = { void __init mmp_dt_init_timer(void) { struct device_node *np; + struct clk *clk; int irq, ret; np = of_find_matching_node(NULL, mmp_timer_dt_ids); @@ -221,6 +216,16 @@ void __init mmp_dt_init_timer(void) goto out; } + clk = of_clk_get(np, 0); + if (IS_ERR(clk)) { + ret = PTR_ERR(clk); + goto out; + } + + ret = clk_prepare_enable(clk); + if (ret) + goto out; + irq = irq_of_parse_and_map(np, 0); if (!irq) { ret = -EINVAL; @@ -231,7 +236,7 @@ void __init mmp_dt_init_timer(void) ret = -ENOMEM; goto out; } - timer_init(irq); + timer_init(irq, clk_get_rate(clk) / 2); return; out: pr_err("Failed to get timer from device tree with error:%d\n", ret); -- 2.17.1