Skip to content

Commit 0931aff

Browse files
author
Shawn Guo
committed
ARM: imx: define an enum for gpt timer device type
Define an enum for gpt timer device type in include/soc/imx/timer.h to tell the gpt block differences among SoCs. Update non-DT users (clock drivers) to pass the device type. As we now have include/soc/imx/timer.h, the declaration of mxc_timer_init() is moved into there as the best fit. Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
1 parent 6dd7478 commit 0931aff

8 files changed

Lines changed: 41 additions & 13 deletions

File tree

‎arch/arm/mach-imx/time.c‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include <linux/of.h>
3333
#include <linux/of_address.h>
3434
#include <linux/of_irq.h>
35+
#include <soc/imx/timer.h>
3536

3637
#include <asm/mach/time.h>
3738

@@ -86,6 +87,7 @@ static struct clock_event_device clockevent_mxc;
8687
static enum clock_event_mode clockevent_mode = CLOCK_EVT_MODE_UNUSED;
8788

8889
struct imx_timer {
90+
enum imx_gpt_type type;
8991
void __iomem *base;
9092
int irq;
9193
struct clk *clk_per;
@@ -356,7 +358,7 @@ static void __init _mxc_timer_init(struct imx_timer *imxtm)
356358
setup_irq(imxtm->irq, &mxc_timer_irq);
357359
}
358360

359-
void __init mxc_timer_init(unsigned long pbase, int irq)
361+
void __init mxc_timer_init(unsigned long pbase, int irq, enum imx_gpt_type type)
360362
{
361363
struct imx_timer *imxtm;
362364

@@ -369,6 +371,8 @@ void __init mxc_timer_init(unsigned long pbase, int irq)
369371
imxtm->base = ioremap(pbase, SZ_4K);
370372
BUG_ON(!imxtm->base);
371373

374+
imxtm->type = type;
375+
372376
_mxc_timer_init(imxtm);
373377
}
374378

‎drivers/clk/imx/clk-imx1.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <linux/of.h>
2424
#include <linux/of_address.h>
2525
#include <dt-bindings/clock/imx1-clock.h>
26+
#include <soc/imx/timer.h>
2627
#include <asm/irq.h>
2728

2829
#include "clk.h"
@@ -102,7 +103,7 @@ int __init mx1_clocks_init(unsigned long fref)
102103
clk_register_clkdev(clk[IMX1_CLK_DUMMY], "ipg", "imx1-fb.0");
103104
clk_register_clkdev(clk[IMX1_CLK_DUMMY], "ahb", "imx1-fb.0");
104105

105-
mxc_timer_init(MX1_TIM1_BASE_ADDR, MX1_TIM1_INT);
106+
mxc_timer_init(MX1_TIM1_BASE_ADDR, MX1_TIM1_INT, GPT_TYPE_IMX1);
106107

107108
return 0;
108109
}

‎drivers/clk/imx/clk-imx21.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <linux/of.h>
1616
#include <linux/of_address.h>
1717
#include <dt-bindings/clock/imx21-clock.h>
18+
#include <soc/imx/timer.h>
1819
#include <asm/irq.h>
1920

2021
#include "clk.h"
@@ -156,7 +157,7 @@ int __init mx21_clocks_init(unsigned long lref, unsigned long href)
156157
clk_register_clkdev(clk[IMX21_CLK_I2C_GATE], NULL, "imx21-i2c.0");
157158
clk_register_clkdev(clk[IMX21_CLK_OWIRE_GATE], NULL, "mxc_w1.0");
158159

159-
mxc_timer_init(MX21_GPT1_BASE_ADDR, MX21_INT_GPT1);
160+
mxc_timer_init(MX21_GPT1_BASE_ADDR, MX21_INT_GPT1, GPT_TYPE_IMX21);
160161

161162
return 0;
162163
}

‎drivers/clk/imx/clk-imx27.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <linux/of_address.h>
77
#include <dt-bindings/clock/imx27-clock.h>
88
#include <soc/imx/revision.h>
9+
#include <soc/imx/timer.h>
910
#include <asm/irq.h>
1011

1112
#include "clk.h"
@@ -233,7 +234,7 @@ int __init mx27_clocks_init(unsigned long fref)
233234
clk_register_clkdev(clk[IMX27_CLK_EMMA_AHB_GATE], "ahb", "m2m-emmaprp.0");
234235
clk_register_clkdev(clk[IMX27_CLK_EMMA_IPG_GATE], "ipg", "m2m-emmaprp.0");
235236

236-
mxc_timer_init(MX27_GPT1_BASE_ADDR, MX27_INT_GPT1);
237+
mxc_timer_init(MX27_GPT1_BASE_ADDR, MX27_INT_GPT1, GPT_TYPE_IMX21);
237238

238239
return 0;
239240
}

‎drivers/clk/imx/clk-imx31.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <linux/err.h>
2323
#include <linux/of.h>
2424
#include <soc/imx/revision.h>
25+
#include <soc/imx/timer.h>
2526
#include <asm/irq.h>
2627

2728
#include "clk.h"
@@ -198,7 +199,7 @@ int __init mx31_clocks_init(unsigned long fref)
198199
mx31_revision();
199200
clk_disable_unprepare(clk[iim_gate]);
200201

201-
mxc_timer_init(MX31_GPT1_BASE_ADDR, MX31_INT_GPT);
202+
mxc_timer_init(MX31_GPT1_BASE_ADDR, MX31_INT_GPT, GPT_TYPE_IMX31);
202203

203204
return 0;
204205
}

‎drivers/clk/imx/clk-imx35.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <linux/of.h>
1515
#include <linux/err.h>
1616
#include <soc/imx/revision.h>
17+
#include <soc/imx/timer.h>
1718
#include <asm/irq.h>
1819

1920
#include "clk.h"
@@ -293,7 +294,7 @@ int __init mx35_clocks_init(void)
293294

294295
imx_print_silicon_rev("i.MX35", mx35_revision());
295296

296-
mxc_timer_init(MX35_GPT1_BASE_ADDR, MX35_INT_GPT);
297+
mxc_timer_init(MX35_GPT1_BASE_ADDR, MX35_INT_GPT, GPT_TYPE_IMX31);
297298

298299
return 0;
299300
}

‎drivers/clk/imx/clk.h‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,6 @@
66

77
extern spinlock_t imx_ccm_lock;
88

9-
/*
10-
* This is a stop-gap solution for clock drivers like imx1/imx21 which call
11-
* mxc_timer_init() to initialize timer for non-DT boot. It can be removed
12-
* when these legacy non-DT support is converted or dropped.
13-
*/
14-
void mxc_timer_init(unsigned long pbase, int irq);
15-
169
void imx_check_clocks(struct clk *clks[], unsigned int count);
1710

1811
extern void imx_cscmr1_fixup(u32 *val);

‎include/soc/imx/timer.h‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright 2015 Linaro Ltd.
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License version 2 as
6+
* published by the Free Software Foundation.
7+
*/
8+
9+
#ifndef __SOC_IMX_TIMER_H__
10+
#define __SOC_IMX_TIMER_H__
11+
12+
enum imx_gpt_type {
13+
GPT_TYPE_IMX1, /* i.MX1 */
14+
GPT_TYPE_IMX21, /* i.MX21/27 */
15+
GPT_TYPE_IMX31, /* i.MX31/35/25/37/51/6Q */
16+
GPT_TYPE_IMX6DL, /* i.MX6DL/SX/SL */
17+
};
18+
19+
/*
20+
* This is a stop-gap solution for clock drivers like imx1/imx21 which call
21+
* mxc_timer_init() to initialize timer for non-DT boot. It can be removed
22+
* when these legacy non-DT support is converted or dropped.
23+
*/
24+
void mxc_timer_init(unsigned long pbase, int irq, enum imx_gpt_type type);
25+
26+
#endif /* __SOC_IMX_TIMER_H__ */

0 commit comments

Comments
 (0)