Skip to content

Commit 506a7be

Browse files
Anson-Huangdlezcano
authored andcommitted
clocksource/drivers/imx-tpm: Correct some registers operation flow
According to i.MX7ULP reference manual, TPM_SC_CPWMS can ONLY be written when counter is disabled, TPM_SC_TOF is write-1-clear, TPM_C0SC_CHF is also write-1-clear, correct these registers initialization flow; Signed-off-by: Anson Huang <[email protected]> Signed-off-by: Daniel Lezcano <[email protected]>
1 parent 16328e7 commit 506a7be

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

drivers/clocksource/timer-imx-tpm.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#define TPM_SC 0x10
2121
#define TPM_SC_CMOD_INC_PER_CNT (0x1 << 3)
2222
#define TPM_SC_CMOD_DIV_DEFAULT 0x3
23+
#define TPM_SC_TOF_MASK (0x1 << 7)
2324
#define TPM_CNT 0x14
2425
#define TPM_MOD 0x18
2526
#define TPM_STATUS 0x1c
@@ -29,6 +30,7 @@
2930
#define TPM_C0SC_MODE_SHIFT 2
3031
#define TPM_C0SC_MODE_MASK 0x3c
3132
#define TPM_C0SC_MODE_SW_COMPARE 0x4
33+
#define TPM_C0SC_CHF_MASK (0x1 << 7)
3234
#define TPM_C0V 0x24
3335

3436
static void __iomem *timer_base;
@@ -205,9 +207,13 @@ static int __init tpm_timer_init(struct device_node *np)
205207
* 4) Channel0 disabled
206208
* 5) DMA transfers disabled
207209
*/
210+
/* make sure counter is disabled */
208211
writel(0, timer_base + TPM_SC);
212+
/* TOF is W1C */
213+
writel(TPM_SC_TOF_MASK, timer_base + TPM_SC);
209214
writel(0, timer_base + TPM_CNT);
210-
writel(0, timer_base + TPM_C0SC);
215+
/* CHF is W1C */
216+
writel(TPM_C0SC_CHF_MASK, timer_base + TPM_C0SC);
211217

212218
/* increase per cnt, div 8 by default */
213219
writel(TPM_SC_CMOD_INC_PER_CNT | TPM_SC_CMOD_DIV_DEFAULT,

0 commit comments

Comments
 (0)