From: shenwei.wang@freescale.com (Shenwei Wang)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 07/18] ARM: imx: Initialize the imx_timer structure
Date: Thu, 30 Apr 2015 09:44:22 -0500 [thread overview]
Message-ID: <1430405073-13106-8-git-send-email-shenwei.wang@freescale.com> (raw)
In-Reply-To: <1430405073-13106-1-git-send-email-shenwei.wang@freescale.com>
Initialized the imx_timer struct in the following two functions:
mxc_timer_init
mxc_timer_init_dt
Signed-off-by: Shenwei Wang <shenwei.wang@freescale.com>
---
arch/arm/mach-imx/time.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 54 insertions(+), 1 deletion(-)
diff --git a/arch/arm/mach-imx/time.c b/arch/arm/mach-imx/time.c
index 811d50a..451f761 100644
--- a/arch/arm/mach-imx/time.c
+++ b/arch/arm/mach-imx/time.c
@@ -31,6 +31,7 @@
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/of_irq.h>
+#include <linux/slab.h>
#include <asm/mach/time.h>
@@ -536,12 +537,29 @@ static void __init _mxc_timer_init(int irq,
void __init mxc_timer_init(unsigned long pbase, int irq, int ver)
{
+ struct imx_timer *timer;
struct clk *clk_per = clk_get_sys("imx-gpt.0", "per");
struct clk *clk_ipg = clk_get_sys("imx-gpt.0", "ipg");
timer_base = ioremap(pbase, SZ_4K);
BUG_ON(!timer_base);
+ timer = kzalloc(sizeof(struct imx_timer), GFP_KERNEL);
+ if (!timer)
+ panic("Can't allocate timer struct\n");
+
+ timer->timer_base = timer_base;
+ timer->version = ver;
+ timer->evt.name = "mxc_timer1";
+ timer->evt.rating = 200;
+ timer->evt.features = CLOCK_EVT_FEAT_ONESHOT;
+ timer->evt.set_mode = mxc_set_mode;
+ timer->evt.set_next_event = v2_set_next_event;
+ timer->act.name = "i.MX Timer Tick";
+ timer->act.flags = IRQF_TIMER | IRQF_IRQPOLL;
+ timer->act.dev_id = timer;
+ timer->act.handler = mxc_timer_interrupt;
+
_mxc_timer_init(irq, clk_per, clk_ipg);
}
@@ -565,11 +583,34 @@ static const struct imx_timer_ip_combo imx_timer_tables[] = {
static void __init mxc_timer_init_dt(struct device_node *np)
{
struct clk *clk_per, *clk_ipg;
- int irq;
+ int irq, i, ret, ver;
+ struct imx_timer *timer;
if (timer_base)
return;
+ for (i = 0; i < sizeof(imx_timer_tables) /
+ sizeof(struct imx_timer_ip_combo); i++) {
+ ret = of_device_is_compatible(np, imx_timer_tables[i].compat);
+ if (ret) {
+ ver = imx_timer_tables[i].version;
+ pr_err("<%s> compatible=%s timer_version=%d\r\n",
+ __func__, imx_timer_tables[i].compat, ver);
+ break;
+ }
+ }
+
+ if (!ret) {
+ pr_err("<%s> timer device node is not supported\r\n", __func__);
+ return;
+ }
+
+ timer = kzalloc(sizeof(struct imx_timer), GFP_KERNEL);
+ if (!timer)
+ panic("Can't allocate timer struct\n");
+
+ timer->timer_base = of_iomap(np, 0);
+
timer_base = of_iomap(np, 0);
WARN_ON(!timer_base);
irq = irq_of_parse_and_map(np, 0);
@@ -581,8 +622,20 @@ static void __init mxc_timer_init_dt(struct device_node *np)
if (IS_ERR(clk_per))
clk_per = of_clk_get_by_name(np, "per");
+ timer->version = ver;
+ timer->evt.name = np->name;
+ timer->evt.rating = 200;
+ timer->evt.features = CLOCK_EVT_FEAT_ONESHOT;
+ timer->evt.set_mode = mxc_set_mode;
+ timer->evt.set_next_event = v2_set_next_event;
+ timer->act.name = np->name;
+ timer->act.flags = IRQF_TIMER | IRQF_IRQPOLL;
+ timer->act.dev_id = timer;
+ timer->act.handler = mxc_timer_interrupt;
+
_mxc_timer_init(irq, clk_per, clk_ipg);
}
+
CLOCKSOURCE_OF_DECLARE(mx1_timer, "fsl,imx1-gpt", mxc_timer_init_dt);
CLOCKSOURCE_OF_DECLARE(mx25_timer, "fsl,imx25-gpt", mxc_timer_init_dt);
CLOCKSOURCE_OF_DECLARE(mx50_timer, "fsl,imx50-gpt", mxc_timer_init_dt);
--
1.9.1
next prev parent reply other threads:[~2015-04-30 14:44 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-30 14:44 [PATCH 00/18] ARM: imx: make the imx timer driver implementation independent of SoCs Shenwei Wang
2015-04-30 14:44 ` [PATCH 01/18] ARM: imx: Add a parameter to mxc_timer_init Shenwei Wang
2015-05-14 8:02 ` Shawn Guo
2015-05-14 13:48 ` Shenwei Wang
2015-04-30 14:44 ` [PATCH 02/18] ARM: imx: Add the definitions for imx_timer and its versions Shenwei Wang
2015-05-15 1:18 ` Shawn Guo
2015-05-15 15:47 ` Shenwei Wang
2015-04-30 14:44 ` [PATCH 03/18] ARM: imx: Add an array of timer IP block versions Shenwei Wang
2015-05-15 1:33 ` Shawn Guo
2015-04-30 14:44 ` [PATCH 04/18] ARM: imx: Added one more parameter for mxc_clockevent_init Shenwei Wang
2015-04-30 14:44 ` [PATCH 05/18] ARM: imx: Added one more parameter for mxc_clocksource_init Shenwei Wang
2015-04-30 14:44 ` [PATCH 06/18] ARM: imx: New timer driver APIs based on IP block Shenwei Wang
2015-05-15 1:44 ` Shawn Guo
2015-04-30 14:44 ` Shenwei Wang [this message]
2015-05-15 2:05 ` [PATCH 07/18] ARM: imx: Initialize the imx_timer structure Shawn Guo
2015-04-30 14:44 ` [PATCH 08/18] ARM: imx: Reimplemented the _mxc_timer_init based on IP version Shenwei Wang
2015-04-30 14:44 ` [PATCH 09/18] ARM: imx: Removed the SoC relating codes in mxc_timer_interrupt Shenwei Wang
2015-04-30 14:44 ` [PATCH 10/18] ARM: imx: Removed the SoC relating codes in mxc_set_mode Shenwei Wang
2015-04-30 14:44 ` [PATCH 11/18] ARM: imx: Enabled the unused parameter Shenwei Wang
2015-04-30 14:44 ` [PATCH 12/18] ARM: imx: Remove one global variable in mxc_clocksource_init Shenwei Wang
2015-04-30 14:44 ` [PATCH 13/18] ARM: imx: Removed the unused functions and variables Shenwei Wang
2015-04-30 14:44 ` [PATCH 14/18] ARM: imx: Removed the global variable "timer_base" Shenwei Wang
2015-04-30 14:44 ` [PATCH 15/18] ARM: imx: Remove the SoC relating codes in mxc_clockevent_init Shenwei Wang
2015-04-30 14:44 ` [PATCH 16/18] ARM: imx: Move the variable clockevent_mode into mxc_set_mode Shenwei Wang
2015-04-30 14:44 ` [PATCH 17/18] ARM: imx: Codes clean up Shenwei Wang
2015-04-30 14:44 ` [PATCH 18/18] ARM: imx: Move time.c into drivers/clocksources Shenwei Wang
2015-05-15 7:54 ` [PATCH 00/18] ARM: imx: make the imx timer driver implementation independent of SoCs Shawn Guo
2015-05-15 15:39 ` Shenwei Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1430405073-13106-8-git-send-email-shenwei.wang@freescale.com \
--to=shenwei.wang@freescale.com \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).