Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1465049imu; Wed, 28 Nov 2018 09:56:35 -0800 (PST) X-Google-Smtp-Source: AFSGD/X0UBpHul1Un7HS3FDRSTI0eRdxlJ/d25nhG6uClW7/3Hy/L3s1Nu3CfCbPBXmg2w+XN+WN X-Received: by 2002:a17:902:2867:: with SMTP id e94mr15777417plb.264.1543427795689; Wed, 28 Nov 2018 09:56:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543427795; cv=none; d=google.com; s=arc-20160816; b=xMUK3YJKTHbpX8vEVJwzxu3Pd3eQm9Mx5WpF5naBMoM9LE+X+fDC2CwSZVYvuXNJEq CzRYJ5m1fIwmTSxg89QWMYSuWOgLR3vVunChgo4c0EPtcYUy6StmNdH7Vw4NEJAphXW0 Qe69mNIluShjFT5/VewBwmObXFChAsY1M9dPsLSHAgYWyUvo4SU0aHtsz6TjPItaZ578 XmQxOOgRUho8E0vPNkin9A2EZyn89HL/c7IfcKLhoEF+LThhjrMP+iG6tUkdHgq+NSwe +ocytGcxG4wfLHfetIVj/s+Jgkqnocq8ck3l52JOT9HgIw/IEHLcRmq8zbWa6IbGHffQ WWVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=3F77iAqTCpnf+LODcQi1Mx6Sz9/eP/30oCfeZ/fk+4w=; b=dILaZB5D+amxFH/qn+w2DvwDItJ1MsoDM6+Daq2m2P7LYb9QWeHrYatys+8sVD3jPg fqDzqPkWzEu6JY+X2L1RX+VpjdkXT+DbmkZ6hxtfZvxZPUZswR0Ok3NlAn2t5JzVbNlo TKhXrzfnLNDEa+tXUTCBSV70sglF2HTKJHcUxaHGLj0sO5IWc2TxZrYb/4WRvCWZR8+t vDA98x3CbjNBc2MSAPGW1lUftX1DlWkA4MNnENV2g1qvUytgVvGKR3n3zWmBAUpCtivg nDqA2KW748CXd+BtVf1I+j610eFr7kz3fqJey/c1UOykIB5I67uoJc4PkoFNdMHvm5M+ 4e1g== 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 g15si7835554pgl.141.2018.11.28.09.56.17; Wed, 28 Nov 2018 09:56:35 -0800 (PST) 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 S1729552AbeK2E4t (ORCPT + 99 others); Wed, 28 Nov 2018 23:56:49 -0500 Received: from shell.v3.sk ([90.176.6.54]:39489 "EHLO shell.v3.sk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728807AbeK2E4s (ORCPT ); Wed, 28 Nov 2018 23:56:48 -0500 Received: from localhost (localhost [127.0.0.1]) by zimbra.v3.sk (Postfix) with ESMTP id 3C77399C7E; Wed, 28 Nov 2018 18:54:18 +0100 (CET) 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 zI2nU5Q9Rce1; Wed, 28 Nov 2018 18:53:59 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by zimbra.v3.sk (Postfix) with ESMTP id 78FE7999FD; Wed, 28 Nov 2018 18:53:41 +0100 (CET) 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 smAYdk7ILxdn; Wed, 28 Nov 2018 18:53:38 +0100 (CET) Received: from belphegor.brq.redhat.com (nat-pool-brq-t.redhat.com [213.175.37.10]) by zimbra.v3.sk (Postfix) with ESMTPSA id B2A0399994; Wed, 28 Nov 2018 18:53:32 +0100 (CET) From: Lubomir Rintel To: arm@kernel.org, Olof Johansson , Arnd Bergmann Cc: Eric Miao , Haojian Zhuang , Russell King , Robert Jarzmik , Pavel Machek , James Cameron , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Lubomir Rintel Subject: [PATCH v4 16/20] ARM: mmp/mmp2: dt: enable the clock Date: Wed, 28 Nov 2018 18:53:20 +0100 Message-Id: <20181128175324.163202-17-lkundrak@v3.sk> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181128175324.163202-1-lkundrak@v3.sk> References: <20181128175324.163202-1-lkundrak@v3.sk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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 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 Acked-by: Pavel Machek --- Changes since v2: - Wording improvement, whitespace fix and an ack from Pavel Changes since v1: - Made the clock optional, to keep compatibility with DTs without it 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 | 32 ++++++++++++++++++++------------ 4 files changed, 23 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) =20 -extern void timer_init(int irq); +extern void timer_init(int irq, unsigned long rate); =20 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 b670fafedeac..8717de7d0757 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 =3D APBC_APBCLK | APBC_FNCLK | APBC_FNCLKSEL(1); __raw_writel(clk_rst, APBC_TIMERS); =20 - timer_init(IRQ_MMP2_TIMER1); + timer_init(IRQ_MMP2_TIMER1, 6500000); } =20 /* 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); =20 - timer_init(IRQ_PXA168_TIMER1); + timer_init(IRQ_PXA168_TIMER1, 6500000); } =20 void pxa168_clear_keypad_wakeup(void) diff --git a/arch/arm/mach-mmp/time.c b/arch/arm/mach-mmp/time.c index 0f49ac579a17..007b94a92923 100644 --- a/arch/arm/mach-mmp/time.c +++ b/arch/arm/mach-mmp/time.c @@ -22,6 +22,7 @@ #include #include #include +#include =20 #include #include @@ -38,12 +39,6 @@ #include "cputype.h" #include "clock.h" =20 -#ifdef CONFIG_CPU_MMP2 -#define MMP_CLOCK_FREQ 6500000 -#else -#define MMP_CLOCK_FREQ 3250000 -#endif - #define TIMERS_VIRT_BASE TIMERS1_VIRT_BASE =20 #define MAX_DELTA (0xfffffffe) @@ -189,19 +184,18 @@ static struct irqaction timer_irq =3D { .dev_id =3D &ckevt, }; =20 -void __init timer_init(int irq) +void __init timer_init(int irq, unsigned long rate) { timer_config(); =20 - sched_clock_register(mmp_read_sched_clock, 32, MMP_CLOCK_FREQ); + sched_clock_register(mmp_read_sched_clock, 32, rate); =20 ckevt.cpumask =3D cpumask_of(0); =20 setup_irq(irq, &timer_irq); =20 - 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); } =20 #ifdef CONFIG_OF @@ -213,7 +207,9 @@ static const struct of_device_id mmp_timer_dt_ids[] =3D= { void __init mmp_dt_init_timer(void) { struct device_node *np; + struct clk *clk; int irq, ret; + unsigned long rate; =20 np =3D of_find_matching_node(NULL, mmp_timer_dt_ids); if (!np) { @@ -221,6 +217,18 @@ void __init mmp_dt_init_timer(void) goto out; } =20 + clk =3D of_clk_get(np, 0); + if (!IS_ERR(clk)) { + ret =3D clk_prepare_enable(clk); + if (ret) + goto out; + rate =3D clk_get_rate(clk) / 2; + } else if (cpu_is_pj4()) { + rate =3D 6500000; + } else { + rate =3D 3250000; + } + irq =3D irq_of_parse_and_map(np, 0); if (!irq) { ret =3D -EINVAL; @@ -231,7 +239,7 @@ void __init mmp_dt_init_timer(void) ret =3D -ENOMEM; goto out; } - timer_init(irq); + timer_init(irq, rate); return; out: pr_err("Failed to get timer from device tree with error:%d\n", ret); --=20 2.19.1