Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
John Rigby | 9c14603 | 2010-01-25 23:12:56 -0700 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2002 |
| 4 | * Sysgo Real-Time Solutions, GmbH <www.elinos.com> |
| 5 | * Marius Groeger <mgroeger@sysgo.de> |
| 6 | * |
| 7 | * (C) Copyright 2002 |
| 8 | * Sysgo Real-Time Solutions, GmbH <www.elinos.com> |
| 9 | * Alex Zuepke <azu@sysgo.de> |
| 10 | * |
| 11 | * (C) Copyright 2002 |
| 12 | * Gary Jennejohn, DENX Software Engineering, <gj@denx.de> |
| 13 | * |
| 14 | * (C) Copyright 2009 |
| 15 | * Ilya Yanok, Emcraft Systems Ltd, <yanok@emcraft.com> |
| 16 | * |
| 17 | * (C) Copyright 2009 DENX Software Engineering |
| 18 | * Author: John Rigby <jrigby@gmail.com> |
Fabio Estevam | f231efb | 2011-10-13 05:34:59 +0000 | [diff] [blame] | 19 | * Add support for MX25 |
John Rigby | 9c14603 | 2010-01-25 23:12:56 -0700 | [diff] [blame] | 20 | */ |
| 21 | |
| 22 | #include <common.h> |
Simon Glass | 9758973 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 23 | #include <init.h> |
John Rigby | 9c14603 | 2010-01-25 23:12:56 -0700 | [diff] [blame] | 24 | #include <asm/io.h> |
| 25 | #include <asm/arch/imx-regs.h> |
Simon Glass | 6b9f010 | 2020-05-10 11:40:06 -0600 | [diff] [blame] | 26 | #include <asm/ptrace.h> |
John Rigby | 9c14603 | 2010-01-25 23:12:56 -0700 | [diff] [blame] | 27 | |
| 28 | /* nothing really to do with interrupts, just starts up a counter. */ |
| 29 | /* The 32KHz 32-bit timer overruns in 134217 seconds */ |
| 30 | int timer_init(void) |
| 31 | { |
| 32 | int i; |
| 33 | struct gpt_regs *gpt = (struct gpt_regs *)IMX_GPT1_BASE; |
| 34 | struct ccm_regs *ccm = (struct ccm_regs *)IMX_CCM_BASE; |
| 35 | |
| 36 | /* setup GP Timer 1 */ |
| 37 | writel(GPT_CTRL_SWR, &gpt->ctrl); |
| 38 | |
| 39 | writel(readl(&ccm->cgr1) | CCM_CGR1_GPT1, &ccm->cgr1); |
| 40 | |
| 41 | for (i = 0; i < 100; i++) |
| 42 | writel(0, &gpt->ctrl); /* We have no udelay by now */ |
| 43 | writel(0, &gpt->pre); /* prescaler = 1 */ |
| 44 | /* Freerun Mode, 32KHz input */ |
| 45 | writel(readl(&gpt->ctrl) | GPT_CTRL_CLKSOURCE_32 | GPT_CTRL_FRR, |
| 46 | &gpt->ctrl); |
| 47 | writel(readl(&gpt->ctrl) | GPT_CTRL_TEN, &gpt->ctrl); |
| 48 | |
| 49 | return 0; |
| 50 | } |