[PATCH 5/5] Clocksource: Flextimer: Use Macro for clock source selection.

From: Xiubo Li
Date: Tue Aug 26 2014 - 01:50:34 EST


FTM source clock is selectable:
Source clock can be the system clock, the fixed frequency clock,
or an external clock.
Fixed frequency clock is an additional clock input to allow the
selection of an on chip clock source other than the system clock.
Selecting external clock connects FTM clock to a chip level input
pin therefore allowing to synchronize the FTM counter with an off
chip clock source

Clock Source Selection:
Selects one of the three FTM counter clock sources.

00 No clock selected. This in effect disables the FTM counter.
01 System clock
---
10 Fixed frequency clock
11 External clock

These two will be useful for the alarm on LS1 platform in late future,
the system clock's frequency is too high to get a long delay timer when
go to sleep, so the fixed or external clock could be used instead.

Signed-off-by: Xiubo Li <Li.Xiubo@xxxxxxxxxxxxx>
Signed-off-by: Jingchang Lu <jingchang.lu@xxxxxxxxxxxxx>
Cc: Wang Dongsheng <dongsheng.wang@xxxxxxxxxxxxx>
---
drivers/clocksource/fsl_ftm_timer.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/clocksource/fsl_ftm_timer.c b/drivers/clocksource/fsl_ftm_timer.c
index 974890e..3935ba2 100644
--- a/drivers/clocksource/fsl_ftm_timer.c
+++ b/drivers/clocksource/fsl_ftm_timer.c
@@ -21,6 +21,8 @@
#include <linux/slab.h>

#define FTM_SC 0x00
+#define FTM_SC_CLKS_NON 0
+#define FTM_SC_CLKS_SYS 1
#define FTM_SC_CLK_SHIFT 3
#define FTM_SC_CLK_MASK (0x3 << FTM_SC_CLK_SHIFT)
#define FTM_SC_CLK(c) ((c) << FTM_SC_CLK_SHIFT)
@@ -67,7 +69,7 @@ static inline void ftm_counter_enable(void __iomem *base)
/* select and enable counter clock source */
val = ftm_readl(base + FTM_SC);
val &= ~(FTM_SC_PS_MASK | FTM_SC_CLK_MASK);
- val |= priv->ps | FTM_SC_CLK(1);
+ val |= priv->ps | FTM_SC_CLK(FTM_SC_CLKS_SYS);
ftm_writel(val, base + FTM_SC);
}

@@ -77,7 +79,8 @@ static inline void ftm_counter_disable(void __iomem *base)

/* disable counter clock source */
val = ftm_readl(base + FTM_SC);
- val &= ~(FTM_SC_PS_MASK | FTM_SC_CLK_MASK);
+ val &= ~(FTM_SC_CLK_MASK);
+ val |= FTM_SC_CLK(FTM_SC_CLKS_NON);
ftm_writel(val, base + FTM_SC);
}

--
1.8.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/