Skip to contentSkip to conversation

mxs: timrot: Add support to i.MX23

PATCH Superseded Fadil Berisha 2 participants 2 messages Feb 24, 2013 – Feb 25, 2013

Subsystems (2)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 mxs: timrot: Add support to i.MX23

From: Fadil Berisha <[email protected]>

This patch add timer support to i.MX23 and complete bit fields and values on regs-timrot.h.
Testet on imx23-olinuxino board.

---
v2 - Updated the struct mxs_timrot_regs so the mapping works for all registers v3 - Revert macro MX28_INCREMENTER_HZ, MX28_HW_DIGCTL_MICROSECONDS and fix whitespaces

 arch/arm/cpu/arm926ejs/mxs/timer.c          |   23 +++++-
 arch/arm/include/asm/arch-mxs/regs-timrot.h |  101 +++++++++++++++++++++++++++
 2 files changed, 122 insertions(+), 2 deletions(-)
arch/arm/cpu/arm926ejs/mxs/timer.c +21 -2
index 4ed75e6..f41ad1c 100644
@@ -32,7 +32,11 @@
 #include <asm/arch/sys_proto.h>
 
 /* Maximum fixed count */
-#define TIMER_LOAD_VAL	0xffffffff
+#if defined(CONFIG_MX23)
+#define TIMER_LOAD_VAL 0xffff
+#elif defined(CONFIG_MX28)
+#define TIMER_LOAD_VAL 0xffffffff
+#endif
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -69,7 +73,11 @@ int timer_init(void)
 	mxs_reset_block(&timrot_regs->hw_timrot_rotctrl_reg);
 
 	/* Set fixed_count to 0 */
+#if defined(CONFIG_MX23)
+	writel(0, &timrot_regs->hw_timrot_timcount0);
+#elif defined(CONFIG_MX28)
 	writel(0, &timrot_regs->hw_timrot_fixed_count0);
+#endif
 
 	/* Set UPDATE bit and 1Khz frequency */
 	writel(TIMROT_TIMCTRLn_UPDATE | TIMROT_TIMCTRLn_RELOAD |
@@ -77,7 +85,11 @@ int timer_init(void)
 		&timrot_regs->hw_timrot_timctrl0);
 
 	/* Set fixed_count to maximal value */
+#if defined(CONFIG_MX23)
+	writel(TIMER_LOAD_VAL-1, &timrot_regs->hw_timrot_timcount0);
+#elif defined(CONFIG_MX28)
 	writel(TIMER_LOAD_VAL, &timrot_regs->hw_timrot_fixed_count0);
+#endif
 
 	return 0;
 }
@@ -86,9 +98,16 @@ unsigned long long get_ticks(void)
 {
 	struct mxs_timrot_regs *timrot_regs =
 		(struct mxs_timrot_regs *)MXS_TIMROT_BASE;
+	uint32_t now;
 
 	/* Current tick value */
-	uint32_t now = readl(&timrot_regs->hw_timrot_running_count0);
+#if defined(CONFIG_MX23)
+	/* upper bits are the valid */
+	now = readl(&timrot_regs->hw_timrot_timcount0) >>
+		TIMROT_RUNNING_COUNTn_RUNNING_COUNT_OFFSET;
+#elif defined(CONFIG_MX28)
+	now = readl(&timrot_regs->hw_timrot_running_count0);
+#endif
 
 	if (lastdec >= now) {
 		/*
arch/arm/include/asm/arch-mxs/regs-timrot.h +101 -0

184 lines not on this page · raw message

Signature · 1 line
1.7.10
#1 lore raw

PATCH v3 1/1 mxs: timrot: Add support to i.MX23

Dear Fadil Berisha,

Quoted 7 lines

From: Fadil Berisha <[email protected]>

This patch add timer support to i.MX23 and complete bit fields and values on regs-timrot.h.
Testet on imx23-olinuxino board.

Boring nits below, fix them and add my ack in the next version:

btw. if you don't want to add --cc="" to the git send-email command line, just put lines in format of:

in the git commit message just below the "Signed-off-by:". Just run git log on most of the mxs-related files and you'll see how it's done.

Quoted 40 lines

---
v2 - Updated the struct mxs_timrot_regs so the mapping works for all registers v3 - Revert macro MX28_INCREMENTER_HZ, MX28_HW_DIGCTL_MICROSECONDS and fix whitespaces

 arch/arm/cpu/arm926ejs/mxs/timer.c          |   23 +++++-
 arch/arm/include/asm/arch-mxs/regs-timrot.h |  101

+++++++++++++++++++++++++++ 2 files changed, 122 insertions(+), 2 deletions(-)

(quoted diff) +0 -0

b/arch/arm/cpu/arm926ejs/mxs/timer.c index 4ed75e6..f41ad1c 100644

arch/arm/cpu/arm926ejs/mxs/timer.c +9 -1
@@ -32,7 +32,11 @@
 #include <asm/arch/sys_proto.h>
 
 /* Maximum fixed count */
-#define TIMER_LOAD_VAL	0xffffffff
+#if defined(CONFIG_MX23)
+#define TIMER_LOAD_VAL 0xffff
+#elif defined(CONFIG_MX28)
+#define TIMER_LOAD_VAL 0xffffffff
+#endif
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -69,7 +73,11 @@ int timer_init(void)
 	mxs_reset_block(&timrot_regs->hw_timrot_rotctrl_reg);
 
 	/* Set fixed_count to 0 */
+#if defined(CONFIG_MX23)
+	writel(0, &timrot_regs->hw_timrot_timcount0);
+#elif defined(CONFIG_MX28)
 	writel(0, &timrot_regs->hw_timrot_fixed_count0);
+#endif
 
 	/* Set UPDATE bit and 1Khz frequency */
 	writel(TIMROT_TIMCTRLn_UPDATE | TIMROT_TIMCTRLn_RELOAD |

arch/arm/cpu/arm926ejs/mxs/timer.c int timer_init(void) · line 89

Quoted 5 lines
arch/arm/cpu/arm926ejs/mxs/timer.c +2 -0
@@ -77,7 +85,11 @@ int timer_init(void)
 		&timrot_regs->hw_timrot_timctrl0);
 
 	/* Set fixed_count to maximal value */
+#if defined(CONFIG_MX23)
+	writel(TIMER_LOAD_VAL-1, &timrot_regs->hw_timrot_timcount0);

Put a space here ... 'TIMER_LOAD_VAL - 1'

Quoted 7 lines
arch/arm/cpu/arm926ejs/mxs/timer.c +2 -0
+#elif defined(CONFIG_MX28)
 	writel(TIMER_LOAD_VAL, &timrot_regs->hw_timrot_fixed_count0);
+#endif
 
 	return 0;
 }

arch/arm/cpu/arm926ejs/mxs/timer.c unsigned long long get_ticks(void) · line 105

Quoted 9 lines
arch/arm/cpu/arm926ejs/mxs/timer.c +3 -1
@@ -86,9 +98,16 @@ unsigned long long get_ticks(void)
 {
 	struct mxs_timrot_regs *timrot_regs =
 		(struct mxs_timrot_regs *)MXS_TIMROT_BASE;
+	uint32_t now;
 
 	/* Current tick value */
-	uint32_t now = readl(&timrot_regs->hw_timrot_running_count0);
+#if defined(CONFIG_MX23)
+	/* upper bits are the valid */

/* Upper bits are the valid ones. */

Quoted 8 lines
arch/arm/cpu/arm926ejs/mxs/timer.c +5 -0
+	now = readl(&timrot_regs->hw_timrot_timcount0) >>
+		TIMROT_RUNNING_COUNTn_RUNNING_COUNT_OFFSET;
+#elif defined(CONFIG_MX28)
+	now = readl(&timrot_regs->hw_timrot_running_count0);
+#endif
 
 	if (lastdec >= now) {
 		/*

[...]