blob: c4ed35e89fbde45ee252263b47846d70c11d1f7a [file] [log] [blame]
Tony Lindgren92105bb2005-09-07 17:20:26 +01001/*
2 * linux/arch/arm/plat-omap/dmtimer.c
3 *
4 * OMAP Dual-Mode Timers
5 *
Tarun Kanti DebBarma97933d62011-09-20 17:00:17 +05306 * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
7 * Tarun Kanti DebBarma <tarun.kanti@ti.com>
8 * Thara Gopinath <thara@ti.com>
9 *
10 * dmtimer adaptation to platform_driver.
11 *
Tony Lindgren92105bb2005-09-07 17:20:26 +010012 * Copyright (C) 2005 Nokia Corporation
Timo Teras77900a22006-06-26 16:16:12 -070013 * OMAP2 support by Juha Yrjola
14 * API improvements and OMAP2 clock framework support by Timo Teras
Tony Lindgren92105bb2005-09-07 17:20:26 +010015 *
Santosh Shilimkar44169072009-05-28 14:16:04 -070016 * Copyright (C) 2009 Texas Instruments
17 * Added OMAP4 support - Santosh Shilimkar <santosh.shilimkar@ti.com>
18 *
Tony Lindgren92105bb2005-09-07 17:20:26 +010019 * This program is free software; you can redistribute it and/or modify it
20 * under the terms of the GNU General Public License as published by the
21 * Free Software Foundation; either version 2 of the License, or (at your
22 * option) any later version.
23 *
24 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
25 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
26 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
27 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
28 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
29 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33 * You should have received a copy of the GNU General Public License along
34 * with this program; if not, write to the Free Software Foundation, Inc.,
35 * 675 Mass Ave, Cambridge, MA 02139, USA.
36 */
37
Axel Lin869dec12011-11-02 09:49:46 +080038#include <linux/module.h>
Russell Kingfced80c2008-09-06 12:10:45 +010039#include <linux/io.h>
Tarun Kanti DebBarmadf284722011-09-20 17:00:19 +053040#include <linux/slab.h>
Tarun Kanti DebBarma3392cdd2011-09-20 17:00:20 +053041#include <linux/err.h>
Tarun Kanti DebBarmaffe07ce2011-09-20 17:00:21 +053042#include <linux/pm_runtime.h>
Tarun Kanti DebBarma3392cdd2011-09-20 17:00:20 +053043
Tony Lindgrence491cf2009-10-20 09:40:47 -070044#include <plat/dmtimer.h>
Tony Lindgren92105bb2005-09-07 17:20:26 +010045
Tony Lindgren2c799ce2012-02-24 10:34:35 -080046#include <mach/hardware.h>
47
Tarun Kanti DebBarmadf284722011-09-20 17:00:19 +053048static LIST_HEAD(omap_timer_list);
Tarun Kanti DebBarma3392cdd2011-09-20 17:00:20 +053049static DEFINE_SPINLOCK(dm_timer_lock);
Tony Lindgren92105bb2005-09-07 17:20:26 +010050
Tarun Kanti DebBarma3392cdd2011-09-20 17:00:20 +053051/**
52 * omap_dm_timer_read_reg - read timer registers in posted and non-posted mode
53 * @timer: timer pointer over which read operation to perform
54 * @reg: lowest byte holds the register offset
55 *
56 * The posted mode bit is encoded in reg. Note that in posted mode write
57 * pending bit must be checked. Otherwise a read of a non completed write
58 * will produce an error.
Richard Woodruff0f0d0802008-07-03 12:24:30 +030059 */
60static inline u32 omap_dm_timer_read_reg(struct omap_dm_timer *timer, u32 reg)
Tony Lindgren92105bb2005-09-07 17:20:26 +010061{
Tony Lindgrenee17f112011-09-16 15:44:20 -070062 WARN_ON((reg & 0xff) < _OMAP_TIMER_WAKEUP_EN_OFFSET);
63 return __omap_dm_timer_read(timer, reg, timer->posted);
Timo Teras77900a22006-06-26 16:16:12 -070064}
65
Tarun Kanti DebBarma3392cdd2011-09-20 17:00:20 +053066/**
67 * omap_dm_timer_write_reg - write timer registers in posted and non-posted mode
68 * @timer: timer pointer over which write operation is to perform
69 * @reg: lowest byte holds the register offset
70 * @value: data to write into the register
71 *
72 * The posted mode bit is encoded in reg. Note that in posted mode the write
73 * pending bit must be checked. Otherwise a write on a register which has a
74 * pending write will be lost.
Richard Woodruff0f0d0802008-07-03 12:24:30 +030075 */
76static void omap_dm_timer_write_reg(struct omap_dm_timer *timer, u32 reg,
77 u32 value)
Timo Teras77900a22006-06-26 16:16:12 -070078{
Tony Lindgrenee17f112011-09-16 15:44:20 -070079 WARN_ON((reg & 0xff) < _OMAP_TIMER_WAKEUP_EN_OFFSET);
80 __omap_dm_timer_write(timer, reg, value, timer->posted);
Tony Lindgren92105bb2005-09-07 17:20:26 +010081}
82
Tarun Kanti DebBarmab4811132011-09-20 17:00:24 +053083static void omap_timer_restore_context(struct omap_dm_timer *timer)
84{
Tarun Kanti DebBarmadffc9da2012-03-05 16:11:00 -080085 __raw_writel(timer->context.tiocp_cfg,
86 timer->io_base + OMAP_TIMER_OCP_CFG_OFFSET);
87 if (timer->revision == 1)
Tarun Kanti DebBarmab4811132011-09-20 17:00:24 +053088 __raw_writel(timer->context.tistat, timer->sys_stat);
89
90 __raw_writel(timer->context.tisr, timer->irq_stat);
91 omap_dm_timer_write_reg(timer, OMAP_TIMER_WAKEUP_EN_REG,
92 timer->context.twer);
93 omap_dm_timer_write_reg(timer, OMAP_TIMER_COUNTER_REG,
94 timer->context.tcrr);
95 omap_dm_timer_write_reg(timer, OMAP_TIMER_LOAD_REG,
96 timer->context.tldr);
97 omap_dm_timer_write_reg(timer, OMAP_TIMER_MATCH_REG,
98 timer->context.tmar);
99 omap_dm_timer_write_reg(timer, OMAP_TIMER_IF_CTRL_REG,
100 timer->context.tsicr);
101 __raw_writel(timer->context.tier, timer->irq_ena);
102 omap_dm_timer_write_reg(timer, OMAP_TIMER_CTRL_REG,
103 timer->context.tclr);
104}
105
Timo Teras77900a22006-06-26 16:16:12 -0700106static void omap_dm_timer_wait_for_reset(struct omap_dm_timer *timer)
Tony Lindgren92105bb2005-09-07 17:20:26 +0100107{
Timo Teras77900a22006-06-26 16:16:12 -0700108 int c;
109
Tony Lindgrenee17f112011-09-16 15:44:20 -0700110 if (!timer->sys_stat)
111 return;
112
Timo Teras77900a22006-06-26 16:16:12 -0700113 c = 0;
Tony Lindgrenee17f112011-09-16 15:44:20 -0700114 while (!(__raw_readl(timer->sys_stat) & 1)) {
Timo Teras77900a22006-06-26 16:16:12 -0700115 c++;
116 if (c > 100000) {
117 printk(KERN_ERR "Timer failed to reset\n");
118 return;
119 }
120 }
Tony Lindgren92105bb2005-09-07 17:20:26 +0100121}
122
Timo Teras77900a22006-06-26 16:16:12 -0700123static void omap_dm_timer_reset(struct omap_dm_timer *timer)
124{
Tarun Kanti DebBarmab4811132011-09-20 17:00:24 +0530125 omap_dm_timer_enable(timer);
Tarun Kanti DebBarma3392cdd2011-09-20 17:00:20 +0530126 if (timer->pdev->id != 1) {
Timo Terase32f7ec2006-06-26 16:16:13 -0700127 omap_dm_timer_write_reg(timer, OMAP_TIMER_IF_CTRL_REG, 0x06);
128 omap_dm_timer_wait_for_reset(timer);
129 }
Timo Teras77900a22006-06-26 16:16:12 -0700130
Tarun Kanti DebBarma3392cdd2011-09-20 17:00:20 +0530131 __omap_dm_timer_reset(timer, 0, 0);
Tarun Kanti DebBarmab4811132011-09-20 17:00:24 +0530132 omap_dm_timer_disable(timer);
Richard Woodruff0f0d0802008-07-03 12:24:30 +0300133 timer->posted = 1;
Timo Teras77900a22006-06-26 16:16:12 -0700134}
135
Tarun Kanti DebBarma3392cdd2011-09-20 17:00:20 +0530136int omap_dm_timer_prepare(struct omap_dm_timer *timer)
Timo Teras77900a22006-06-26 16:16:12 -0700137{
Tarun Kanti DebBarma3392cdd2011-09-20 17:00:20 +0530138 struct dmtimer_platform_data *pdata = timer->pdev->dev.platform_data;
139 int ret;
140
141 timer->fclk = clk_get(&timer->pdev->dev, "fck");
142 if (WARN_ON_ONCE(IS_ERR_OR_NULL(timer->fclk))) {
143 timer->fclk = NULL;
144 dev_err(&timer->pdev->dev, ": No fclk handle.\n");
145 return -EINVAL;
146 }
147
Tarun Kanti DebBarma3392cdd2011-09-20 17:00:20 +0530148 if (pdata->needs_manual_reset)
149 omap_dm_timer_reset(timer);
150
151 ret = omap_dm_timer_set_source(timer, OMAP_TIMER_SRC_32_KHZ);
152
153 timer->posted = 1;
154 return ret;
Timo Teras77900a22006-06-26 16:16:12 -0700155}
156
157struct omap_dm_timer *omap_dm_timer_request(void)
158{
Tarun Kanti DebBarma3392cdd2011-09-20 17:00:20 +0530159 struct omap_dm_timer *timer = NULL, *t;
Timo Teras77900a22006-06-26 16:16:12 -0700160 unsigned long flags;
Tarun Kanti DebBarma3392cdd2011-09-20 17:00:20 +0530161 int ret = 0;
Timo Teras77900a22006-06-26 16:16:12 -0700162
163 spin_lock_irqsave(&dm_timer_lock, flags);
Tarun Kanti DebBarma3392cdd2011-09-20 17:00:20 +0530164 list_for_each_entry(t, &omap_timer_list, node) {
165 if (t->reserved)
Timo Teras77900a22006-06-26 16:16:12 -0700166 continue;
167
Tarun Kanti DebBarma3392cdd2011-09-20 17:00:20 +0530168 timer = t;
Timo Teras83379c82006-06-26 16:16:23 -0700169 timer->reserved = 1;
Timo Teras77900a22006-06-26 16:16:12 -0700170 break;
171 }
Tarun Kanti DebBarma3392cdd2011-09-20 17:00:20 +0530172
173 if (timer) {
174 ret = omap_dm_timer_prepare(timer);
175 if (ret) {
176 timer->reserved = 0;
177 timer = NULL;
178 }
179 }
Timo Teras77900a22006-06-26 16:16:12 -0700180 spin_unlock_irqrestore(&dm_timer_lock, flags);
181
Tarun Kanti DebBarma3392cdd2011-09-20 17:00:20 +0530182 if (!timer)
183 pr_debug("%s: timer request failed!\n", __func__);
Timo Teras83379c82006-06-26 16:16:23 -0700184
Timo Teras77900a22006-06-26 16:16:12 -0700185 return timer;
186}
Timo Kokkonen6c366e32009-03-23 18:07:46 -0700187EXPORT_SYMBOL_GPL(omap_dm_timer_request);
Timo Teras77900a22006-06-26 16:16:12 -0700188
189struct omap_dm_timer *omap_dm_timer_request_specific(int id)
Tony Lindgren92105bb2005-09-07 17:20:26 +0100190{
Tarun Kanti DebBarma3392cdd2011-09-20 17:00:20 +0530191 struct omap_dm_timer *timer = NULL, *t;
Timo Teras77900a22006-06-26 16:16:12 -0700192 unsigned long flags;
Tarun Kanti DebBarma3392cdd2011-09-20 17:00:20 +0530193 int ret = 0;
Tony Lindgren92105bb2005-09-07 17:20:26 +0100194
Timo Teras77900a22006-06-26 16:16:12 -0700195 spin_lock_irqsave(&dm_timer_lock, flags);
Tarun Kanti DebBarma3392cdd2011-09-20 17:00:20 +0530196 list_for_each_entry(t, &omap_timer_list, node) {
197 if (t->pdev->id == id && !t->reserved) {
198 timer = t;
199 timer->reserved = 1;
200 break;
201 }
Timo Teras77900a22006-06-26 16:16:12 -0700202 }
Tony Lindgren92105bb2005-09-07 17:20:26 +0100203
Tarun Kanti DebBarma3392cdd2011-09-20 17:00:20 +0530204 if (timer) {
205 ret = omap_dm_timer_prepare(timer);
206 if (ret) {
207 timer->reserved = 0;
208 timer = NULL;
209 }
210 }
Timo Teras77900a22006-06-26 16:16:12 -0700211 spin_unlock_irqrestore(&dm_timer_lock, flags);
212
Tarun Kanti DebBarma3392cdd2011-09-20 17:00:20 +0530213 if (!timer)
214 pr_debug("%s: timer%d request failed!\n", __func__, id);
Timo Teras83379c82006-06-26 16:16:23 -0700215
Timo Teras77900a22006-06-26 16:16:12 -0700216 return timer;
Tony Lindgren92105bb2005-09-07 17:20:26 +0100217}
Timo Kokkonen6c366e32009-03-23 18:07:46 -0700218EXPORT_SYMBOL_GPL(omap_dm_timer_request_specific);
Tony Lindgren92105bb2005-09-07 17:20:26 +0100219
Tarun Kanti DebBarmaab4eb8b2011-09-20 17:00:26 +0530220int omap_dm_timer_free(struct omap_dm_timer *timer)
Timo Teras77900a22006-06-26 16:16:12 -0700221{
Tarun Kanti DebBarmaab4eb8b2011-09-20 17:00:26 +0530222 if (unlikely(!timer))
223 return -EINVAL;
224
Tarun Kanti DebBarma3392cdd2011-09-20 17:00:20 +0530225 clk_put(timer->fclk);
Timo Terasfa4bb622006-09-25 12:41:35 +0300226
Timo Teras77900a22006-06-26 16:16:12 -0700227 WARN_ON(!timer->reserved);
228 timer->reserved = 0;
Tarun Kanti DebBarmaab4eb8b2011-09-20 17:00:26 +0530229 return 0;
Timo Teras77900a22006-06-26 16:16:12 -0700230}
Timo Kokkonen6c366e32009-03-23 18:07:46 -0700231EXPORT_SYMBOL_GPL(omap_dm_timer_free);
Timo Teras77900a22006-06-26 16:16:12 -0700232
Timo Teras12583a72006-09-25 12:41:42 +0300233void omap_dm_timer_enable(struct omap_dm_timer *timer)
234{
Tarun Kanti DebBarmaffe07ce2011-09-20 17:00:21 +0530235 pm_runtime_get_sync(&timer->pdev->dev);
Timo Teras12583a72006-09-25 12:41:42 +0300236}
Timo Kokkonen6c366e32009-03-23 18:07:46 -0700237EXPORT_SYMBOL_GPL(omap_dm_timer_enable);
Timo Teras12583a72006-09-25 12:41:42 +0300238
239void omap_dm_timer_disable(struct omap_dm_timer *timer)
240{
Tarun Kanti DebBarmaffe07ce2011-09-20 17:00:21 +0530241 pm_runtime_put(&timer->pdev->dev);
Timo Teras12583a72006-09-25 12:41:42 +0300242}
Timo Kokkonen6c366e32009-03-23 18:07:46 -0700243EXPORT_SYMBOL_GPL(omap_dm_timer_disable);
Timo Teras12583a72006-09-25 12:41:42 +0300244
Timo Teras77900a22006-06-26 16:16:12 -0700245int omap_dm_timer_get_irq(struct omap_dm_timer *timer)
246{
Tarun Kanti DebBarmaab4eb8b2011-09-20 17:00:26 +0530247 if (timer)
248 return timer->irq;
249 return -EINVAL;
Timo Teras77900a22006-06-26 16:16:12 -0700250}
Timo Kokkonen6c366e32009-03-23 18:07:46 -0700251EXPORT_SYMBOL_GPL(omap_dm_timer_get_irq);
Timo Teras77900a22006-06-26 16:16:12 -0700252
253#if defined(CONFIG_ARCH_OMAP1)
254
Tony Lindgrena569c6e2006-04-02 17:46:21 +0100255/**
256 * omap_dm_timer_modify_idlect_mask - Check if any running timers use ARMXOR
257 * @inputmask: current value of idlect mask
258 */
259__u32 omap_dm_timer_modify_idlect_mask(__u32 inputmask)
260{
Tarun Kanti DebBarma3392cdd2011-09-20 17:00:20 +0530261 int i = 0;
262 struct omap_dm_timer *timer = NULL;
263 unsigned long flags;
Tony Lindgrena569c6e2006-04-02 17:46:21 +0100264
265 /* If ARMXOR cannot be idled this function call is unnecessary */
266 if (!(inputmask & (1 << 1)))
267 return inputmask;
268
269 /* If any active timer is using ARMXOR return modified mask */
Tarun Kanti DebBarma3392cdd2011-09-20 17:00:20 +0530270 spin_lock_irqsave(&dm_timer_lock, flags);
271 list_for_each_entry(timer, &omap_timer_list, node) {
Timo Teras77900a22006-06-26 16:16:12 -0700272 u32 l;
273
Tarun Kanti DebBarma3392cdd2011-09-20 17:00:20 +0530274 l = omap_dm_timer_read_reg(timer, OMAP_TIMER_CTRL_REG);
Timo Teras77900a22006-06-26 16:16:12 -0700275 if (l & OMAP_TIMER_CTRL_ST) {
276 if (((omap_readl(MOD_CONF_CTRL_1) >> (i * 2)) & 0x03) == 0)
Tony Lindgrena569c6e2006-04-02 17:46:21 +0100277 inputmask &= ~(1 << 1);
278 else
279 inputmask &= ~(1 << 2);
280 }
Tarun Kanti DebBarma3392cdd2011-09-20 17:00:20 +0530281 i++;
Timo Teras77900a22006-06-26 16:16:12 -0700282 }
Tarun Kanti DebBarma3392cdd2011-09-20 17:00:20 +0530283 spin_unlock_irqrestore(&dm_timer_lock, flags);
Tony Lindgrena569c6e2006-04-02 17:46:21 +0100284
285 return inputmask;
286}
Timo Kokkonen6c366e32009-03-23 18:07:46 -0700287EXPORT_SYMBOL_GPL(omap_dm_timer_modify_idlect_mask);
Tony Lindgrena569c6e2006-04-02 17:46:21 +0100288
Tony Lindgren140455f2010-02-12 12:26:48 -0800289#else
Timo Teras77900a22006-06-26 16:16:12 -0700290
291struct clk *omap_dm_timer_get_fclk(struct omap_dm_timer *timer)
292{
Tarun Kanti DebBarmaab4eb8b2011-09-20 17:00:26 +0530293 if (timer)
294 return timer->fclk;
295 return NULL;
Timo Teras77900a22006-06-26 16:16:12 -0700296}
Timo Kokkonen6c366e32009-03-23 18:07:46 -0700297EXPORT_SYMBOL_GPL(omap_dm_timer_get_fclk);
Timo Teras77900a22006-06-26 16:16:12 -0700298
299__u32 omap_dm_timer_modify_idlect_mask(__u32 inputmask)
300{
301 BUG();
Dirk Behme21218802006-12-06 17:14:00 -0800302
303 return 0;
Timo Teras77900a22006-06-26 16:16:12 -0700304}
Timo Kokkonen6c366e32009-03-23 18:07:46 -0700305EXPORT_SYMBOL_GPL(omap_dm_timer_modify_idlect_mask);
Timo Teras77900a22006-06-26 16:16:12 -0700306
307#endif
308
Tarun Kanti DebBarmaab4eb8b2011-09-20 17:00:26 +0530309int omap_dm_timer_trigger(struct omap_dm_timer *timer)
Timo Teras77900a22006-06-26 16:16:12 -0700310{
Tarun Kanti DebBarmaab4eb8b2011-09-20 17:00:26 +0530311 if (unlikely(!timer || pm_runtime_suspended(&timer->pdev->dev))) {
312 pr_err("%s: timer not available or enabled.\n", __func__);
313 return -EINVAL;
Tarun Kanti DebBarmab4811132011-09-20 17:00:24 +0530314 }
315
Timo Teras77900a22006-06-26 16:16:12 -0700316 omap_dm_timer_write_reg(timer, OMAP_TIMER_TRIGGER_REG, 0);
Tarun Kanti DebBarmaab4eb8b2011-09-20 17:00:26 +0530317 return 0;
Timo Teras77900a22006-06-26 16:16:12 -0700318}
Timo Kokkonen6c366e32009-03-23 18:07:46 -0700319EXPORT_SYMBOL_GPL(omap_dm_timer_trigger);
Timo Teras77900a22006-06-26 16:16:12 -0700320
Tarun Kanti DebBarmaab4eb8b2011-09-20 17:00:26 +0530321int omap_dm_timer_start(struct omap_dm_timer *timer)
Timo Teras77900a22006-06-26 16:16:12 -0700322{
323 u32 l;
324
Tarun Kanti DebBarmaab4eb8b2011-09-20 17:00:26 +0530325 if (unlikely(!timer))
326 return -EINVAL;
327
Tarun Kanti DebBarmab4811132011-09-20 17:00:24 +0530328 omap_dm_timer_enable(timer);
329
330 if (timer->loses_context) {
331 u32 ctx_loss_cnt_after =
332 timer->get_context_loss_count(&timer->pdev->dev);
333 if (ctx_loss_cnt_after != timer->ctx_loss_count)
334 omap_timer_restore_context(timer);
335 }
336
Timo Teras77900a22006-06-26 16:16:12 -0700337 l = omap_dm_timer_read_reg(timer, OMAP_TIMER_CTRL_REG);
338 if (!(l & OMAP_TIMER_CTRL_ST)) {
339 l |= OMAP_TIMER_CTRL_ST;
340 omap_dm_timer_write_reg(timer, OMAP_TIMER_CTRL_REG, l);
341 }
Tarun Kanti DebBarmab4811132011-09-20 17:00:24 +0530342
343 /* Save the context */
344 timer->context.tclr = l;
Tarun Kanti DebBarmaab4eb8b2011-09-20 17:00:26 +0530345 return 0;
Timo Teras77900a22006-06-26 16:16:12 -0700346}
Timo Kokkonen6c366e32009-03-23 18:07:46 -0700347EXPORT_SYMBOL_GPL(omap_dm_timer_start);
Timo Teras77900a22006-06-26 16:16:12 -0700348
Tarun Kanti DebBarmaab4eb8b2011-09-20 17:00:26 +0530349int omap_dm_timer_stop(struct omap_dm_timer *timer)
Timo Teras77900a22006-06-26 16:16:12 -0700350{
Tony Lindgrencaf64f22011-03-29 15:54:48 -0700351 unsigned long rate = 0;
Paul Walmsleyeeb37112012-04-13 06:34:32 -0600352 struct dmtimer_platform_data *pdata;
Timo Teras77900a22006-06-26 16:16:12 -0700353
Tarun Kanti DebBarmaab4eb8b2011-09-20 17:00:26 +0530354 if (unlikely(!timer))
355 return -EINVAL;
356
Paul Walmsleyeeb37112012-04-13 06:34:32 -0600357 pdata = timer->pdev->dev.platform_data;
Tarun Kanti DebBarma3392cdd2011-09-20 17:00:20 +0530358 if (!pdata->needs_manual_reset)
359 rate = clk_get_rate(timer->fclk);
Tony Lindgrencaf64f22011-03-29 15:54:48 -0700360
Tony Lindgrenee17f112011-09-16 15:44:20 -0700361 __omap_dm_timer_stop(timer, timer->posted, rate);
Tarun Kanti DebBarmaab4eb8b2011-09-20 17:00:26 +0530362
Tarun Kanti DebBarmadffc9da2012-03-05 16:11:00 -0800363 if (timer->loses_context && timer->get_context_loss_count)
364 timer->ctx_loss_count =
365 timer->get_context_loss_count(&timer->pdev->dev);
366
367 /*
368 * Since the register values are computed and written within
369 * __omap_dm_timer_stop, we need to use read to retrieve the
370 * context.
371 */
372 timer->context.tclr =
373 omap_dm_timer_read_reg(timer, OMAP_TIMER_CTRL_REG);
374 timer->context.tisr = __raw_readl(timer->irq_stat);
375 omap_dm_timer_disable(timer);
Tarun Kanti DebBarmaab4eb8b2011-09-20 17:00:26 +0530376 return 0;
Timo Teras77900a22006-06-26 16:16:12 -0700377}
Timo Kokkonen6c366e32009-03-23 18:07:46 -0700378EXPORT_SYMBOL_GPL(omap_dm_timer_stop);
Timo Teras77900a22006-06-26 16:16:12 -0700379
Paul Walmsleyf2480762009-04-23 21:11:10 -0600380int omap_dm_timer_set_source(struct omap_dm_timer *timer, int source)
Tony Lindgren92105bb2005-09-07 17:20:26 +0100381{
Tarun Kanti DebBarma3392cdd2011-09-20 17:00:20 +0530382 int ret;
Tarun Kanti DebBarmaab4eb8b2011-09-20 17:00:26 +0530383 struct dmtimer_platform_data *pdata;
384
385 if (unlikely(!timer))
386 return -EINVAL;
387
388 pdata = timer->pdev->dev.platform_data;
Tarun Kanti DebBarma3392cdd2011-09-20 17:00:20 +0530389
Timo Teras77900a22006-06-26 16:16:12 -0700390 if (source < 0 || source >= 3)
Paul Walmsleyf2480762009-04-23 21:11:10 -0600391 return -EINVAL;
Timo Teras77900a22006-06-26 16:16:12 -0700392
Tarun Kanti DebBarma3392cdd2011-09-20 17:00:20 +0530393 ret = pdata->set_timer_src(timer->pdev, source);
Tarun Kanti DebBarma3392cdd2011-09-20 17:00:20 +0530394
395 return ret;
Timo Teras77900a22006-06-26 16:16:12 -0700396}
Timo Kokkonen6c366e32009-03-23 18:07:46 -0700397EXPORT_SYMBOL_GPL(omap_dm_timer_set_source);
Timo Teras77900a22006-06-26 16:16:12 -0700398
Tarun Kanti DebBarmaab4eb8b2011-09-20 17:00:26 +0530399int omap_dm_timer_set_load(struct omap_dm_timer *timer, int autoreload,
Timo Teras77900a22006-06-26 16:16:12 -0700400 unsigned int load)
401{
402 u32 l;
403
Tarun Kanti DebBarmaab4eb8b2011-09-20 17:00:26 +0530404 if (unlikely(!timer))
405 return -EINVAL;
406
Tarun Kanti DebBarmab4811132011-09-20 17:00:24 +0530407 omap_dm_timer_enable(timer);
Timo Teras77900a22006-06-26 16:16:12 -0700408 l = omap_dm_timer_read_reg(timer, OMAP_TIMER_CTRL_REG);
409 if (autoreload)
410 l |= OMAP_TIMER_CTRL_AR;
411 else
412 l &= ~OMAP_TIMER_CTRL_AR;
413 omap_dm_timer_write_reg(timer, OMAP_TIMER_CTRL_REG, l);
414 omap_dm_timer_write_reg(timer, OMAP_TIMER_LOAD_REG, load);
Richard Woodruff0f0d0802008-07-03 12:24:30 +0300415
Timo Teras77900a22006-06-26 16:16:12 -0700416 omap_dm_timer_write_reg(timer, OMAP_TIMER_TRIGGER_REG, 0);
Tarun Kanti DebBarmab4811132011-09-20 17:00:24 +0530417 /* Save the context */
418 timer->context.tclr = l;
419 timer->context.tldr = load;
420 omap_dm_timer_disable(timer);
Tarun Kanti DebBarmaab4eb8b2011-09-20 17:00:26 +0530421 return 0;
Timo Teras77900a22006-06-26 16:16:12 -0700422}
Timo Kokkonen6c366e32009-03-23 18:07:46 -0700423EXPORT_SYMBOL_GPL(omap_dm_timer_set_load);
Timo Teras77900a22006-06-26 16:16:12 -0700424
Richard Woodruff3fddd092008-07-03 12:24:30 +0300425/* Optimized set_load which removes costly spin wait in timer_start */
Tarun Kanti DebBarmaab4eb8b2011-09-20 17:00:26 +0530426int omap_dm_timer_set_load_start(struct omap_dm_timer *timer, int autoreload,
Richard Woodruff3fddd092008-07-03 12:24:30 +0300427 unsigned int load)
428{
429 u32 l;
430
Tarun Kanti DebBarmaab4eb8b2011-09-20 17:00:26 +0530431 if (unlikely(!timer))
432 return -EINVAL;
433
Tarun Kanti DebBarmab4811132011-09-20 17:00:24 +0530434 omap_dm_timer_enable(timer);
435
436 if (timer->loses_context) {
437 u32 ctx_loss_cnt_after =
438 timer->get_context_loss_count(&timer->pdev->dev);
439 if (ctx_loss_cnt_after != timer->ctx_loss_count)
440 omap_timer_restore_context(timer);
441 }
442
Richard Woodruff3fddd092008-07-03 12:24:30 +0300443 l = omap_dm_timer_read_reg(timer, OMAP_TIMER_CTRL_REG);
Paul Walmsley64ce2902008-12-10 17:36:34 -0800444 if (autoreload) {
Richard Woodruff3fddd092008-07-03 12:24:30 +0300445 l |= OMAP_TIMER_CTRL_AR;
Paul Walmsley64ce2902008-12-10 17:36:34 -0800446 omap_dm_timer_write_reg(timer, OMAP_TIMER_LOAD_REG, load);
447 } else {
Richard Woodruff3fddd092008-07-03 12:24:30 +0300448 l &= ~OMAP_TIMER_CTRL_AR;
Paul Walmsley64ce2902008-12-10 17:36:34 -0800449 }
Richard Woodruff3fddd092008-07-03 12:24:30 +0300450 l |= OMAP_TIMER_CTRL_ST;
451
Tony Lindgrenee17f112011-09-16 15:44:20 -0700452 __omap_dm_timer_load_start(timer, l, load, timer->posted);
Tarun Kanti DebBarmab4811132011-09-20 17:00:24 +0530453
454 /* Save the context */
455 timer->context.tclr = l;
456 timer->context.tldr = load;
457 timer->context.tcrr = load;
Tarun Kanti DebBarmaab4eb8b2011-09-20 17:00:26 +0530458 return 0;
Richard Woodruff3fddd092008-07-03 12:24:30 +0300459}
Timo Kokkonen6c366e32009-03-23 18:07:46 -0700460EXPORT_SYMBOL_GPL(omap_dm_timer_set_load_start);
Richard Woodruff3fddd092008-07-03 12:24:30 +0300461
Tarun Kanti DebBarmaab4eb8b2011-09-20 17:00:26 +0530462int omap_dm_timer_set_match(struct omap_dm_timer *timer, int enable,
Timo Teras77900a22006-06-26 16:16:12 -0700463 unsigned int match)
464{
465 u32 l;
466
Tarun Kanti DebBarmaab4eb8b2011-09-20 17:00:26 +0530467 if (unlikely(!timer))
468 return -EINVAL;
469
Tarun Kanti DebBarmab4811132011-09-20 17:00:24 +0530470 omap_dm_timer_enable(timer);
Timo Teras77900a22006-06-26 16:16:12 -0700471 l = omap_dm_timer_read_reg(timer, OMAP_TIMER_CTRL_REG);
Timo Teras83379c82006-06-26 16:16:23 -0700472 if (enable)
Timo Teras77900a22006-06-26 16:16:12 -0700473 l |= OMAP_TIMER_CTRL_CE;
474 else
475 l &= ~OMAP_TIMER_CTRL_CE;
476 omap_dm_timer_write_reg(timer, OMAP_TIMER_CTRL_REG, l);
477 omap_dm_timer_write_reg(timer, OMAP_TIMER_MATCH_REG, match);
Tarun Kanti DebBarmab4811132011-09-20 17:00:24 +0530478
479 /* Save the context */
480 timer->context.tclr = l;
481 timer->context.tmar = match;
482 omap_dm_timer_disable(timer);
Tarun Kanti DebBarmaab4eb8b2011-09-20 17:00:26 +0530483 return 0;
Tony Lindgren92105bb2005-09-07 17:20:26 +0100484}
Timo Kokkonen6c366e32009-03-23 18:07:46 -0700485EXPORT_SYMBOL_GPL(omap_dm_timer_set_match);
Tony Lindgren92105bb2005-09-07 17:20:26 +0100486
Tarun Kanti DebBarmaab4eb8b2011-09-20 17:00:26 +0530487int omap_dm_timer_set_pwm(struct omap_dm_timer *timer, int def_on,
Timo Teras77900a22006-06-26 16:16:12 -0700488 int toggle, int trigger)
Tony Lindgren92105bb2005-09-07 17:20:26 +0100489{
Timo Teras77900a22006-06-26 16:16:12 -0700490 u32 l;
Tony Lindgren92105bb2005-09-07 17:20:26 +0100491
Tarun Kanti DebBarmaab4eb8b2011-09-20 17:00:26 +0530492 if (unlikely(!timer))
493 return -EINVAL;
494
Tarun Kanti DebBarmab4811132011-09-20 17:00:24 +0530495 omap_dm_timer_enable(timer);
Timo Teras77900a22006-06-26 16:16:12 -0700496 l = omap_dm_timer_read_reg(timer, OMAP_TIMER_CTRL_REG);
497 l &= ~(OMAP_TIMER_CTRL_GPOCFG | OMAP_TIMER_CTRL_SCPWM |
498 OMAP_TIMER_CTRL_PT | (0x03 << 10));
499 if (def_on)
500 l |= OMAP_TIMER_CTRL_SCPWM;
501 if (toggle)
502 l |= OMAP_TIMER_CTRL_PT;
503 l |= trigger << 10;
504 omap_dm_timer_write_reg(timer, OMAP_TIMER_CTRL_REG, l);
Tarun Kanti DebBarmab4811132011-09-20 17:00:24 +0530505
506 /* Save the context */
507 timer->context.tclr = l;
508 omap_dm_timer_disable(timer);
Tarun Kanti DebBarmaab4eb8b2011-09-20 17:00:26 +0530509 return 0;
Timo Teras77900a22006-06-26 16:16:12 -0700510}
Timo Kokkonen6c366e32009-03-23 18:07:46 -0700511EXPORT_SYMBOL_GPL(omap_dm_timer_set_pwm);
Timo Teras77900a22006-06-26 16:16:12 -0700512
Tarun Kanti DebBarmaab4eb8b2011-09-20 17:00:26 +0530513int omap_dm_timer_set_prescaler(struct omap_dm_timer *timer, int prescaler)
Timo Teras77900a22006-06-26 16:16:12 -0700514{
515 u32 l;
516
Tarun Kanti DebBarmaab4eb8b2011-09-20 17:00:26 +0530517 if (unlikely(!timer))
518 return -EINVAL;
519
Tarun Kanti DebBarmab4811132011-09-20 17:00:24 +0530520 omap_dm_timer_enable(timer);
Timo Teras77900a22006-06-26 16:16:12 -0700521 l = omap_dm_timer_read_reg(timer, OMAP_TIMER_CTRL_REG);
522 l &= ~(OMAP_TIMER_CTRL_PRE | (0x07 << 2));
523 if (prescaler >= 0x00 && prescaler <= 0x07) {
524 l |= OMAP_TIMER_CTRL_PRE;
525 l |= prescaler << 2;
Tony Lindgren92105bb2005-09-07 17:20:26 +0100526 }
Timo Teras77900a22006-06-26 16:16:12 -0700527 omap_dm_timer_write_reg(timer, OMAP_TIMER_CTRL_REG, l);
Tarun Kanti DebBarmab4811132011-09-20 17:00:24 +0530528
529 /* Save the context */
530 timer->context.tclr = l;
531 omap_dm_timer_disable(timer);
Tarun Kanti DebBarmaab4eb8b2011-09-20 17:00:26 +0530532 return 0;
Tony Lindgren92105bb2005-09-07 17:20:26 +0100533}
Timo Kokkonen6c366e32009-03-23 18:07:46 -0700534EXPORT_SYMBOL_GPL(omap_dm_timer_set_prescaler);
Tony Lindgren92105bb2005-09-07 17:20:26 +0100535
Tarun Kanti DebBarmaab4eb8b2011-09-20 17:00:26 +0530536int omap_dm_timer_set_int_enable(struct omap_dm_timer *timer,
Timo Teras77900a22006-06-26 16:16:12 -0700537 unsigned int value)
Tony Lindgren92105bb2005-09-07 17:20:26 +0100538{
Tarun Kanti DebBarmaab4eb8b2011-09-20 17:00:26 +0530539 if (unlikely(!timer))
540 return -EINVAL;
541
Tarun Kanti DebBarmab4811132011-09-20 17:00:24 +0530542 omap_dm_timer_enable(timer);
Tony Lindgrenee17f112011-09-16 15:44:20 -0700543 __omap_dm_timer_int_enable(timer, value);
Tarun Kanti DebBarmab4811132011-09-20 17:00:24 +0530544
545 /* Save the context */
546 timer->context.tier = value;
547 timer->context.twer = value;
548 omap_dm_timer_disable(timer);
Tarun Kanti DebBarmaab4eb8b2011-09-20 17:00:26 +0530549 return 0;
Tony Lindgren92105bb2005-09-07 17:20:26 +0100550}
Timo Kokkonen6c366e32009-03-23 18:07:46 -0700551EXPORT_SYMBOL_GPL(omap_dm_timer_set_int_enable);
Tony Lindgren92105bb2005-09-07 17:20:26 +0100552
553unsigned int omap_dm_timer_read_status(struct omap_dm_timer *timer)
554{
Timo Terasfa4bb622006-09-25 12:41:35 +0300555 unsigned int l;
556
Tarun Kanti DebBarmaab4eb8b2011-09-20 17:00:26 +0530557 if (unlikely(!timer || pm_runtime_suspended(&timer->pdev->dev))) {
558 pr_err("%s: timer not available or enabled.\n", __func__);
Tarun Kanti DebBarmab4811132011-09-20 17:00:24 +0530559 return 0;
560 }
561
Tony Lindgrenee17f112011-09-16 15:44:20 -0700562 l = __raw_readl(timer->irq_stat);
Timo Terasfa4bb622006-09-25 12:41:35 +0300563
564 return l;
Tony Lindgren92105bb2005-09-07 17:20:26 +0100565}
Timo Kokkonen6c366e32009-03-23 18:07:46 -0700566EXPORT_SYMBOL_GPL(omap_dm_timer_read_status);
Tony Lindgren92105bb2005-09-07 17:20:26 +0100567
Tarun Kanti DebBarmaab4eb8b2011-09-20 17:00:26 +0530568int omap_dm_timer_write_status(struct omap_dm_timer *timer, unsigned int value)
Tony Lindgren92105bb2005-09-07 17:20:26 +0100569{
Tarun Kanti DebBarmaab4eb8b2011-09-20 17:00:26 +0530570 if (unlikely(!timer || pm_runtime_suspended(&timer->pdev->dev)))
571 return -EINVAL;
572
Tony Lindgrenee17f112011-09-16 15:44:20 -0700573 __omap_dm_timer_write_status(timer, value);
Tarun Kanti DebBarmab4811132011-09-20 17:00:24 +0530574 /* Save the context */
575 timer->context.tisr = value;
Tarun Kanti DebBarmaab4eb8b2011-09-20 17:00:26 +0530576 return 0;
Tony Lindgren92105bb2005-09-07 17:20:26 +0100577}
Timo Kokkonen6c366e32009-03-23 18:07:46 -0700578EXPORT_SYMBOL_GPL(omap_dm_timer_write_status);
Tony Lindgren92105bb2005-09-07 17:20:26 +0100579
Tony Lindgren92105bb2005-09-07 17:20:26 +0100580unsigned int omap_dm_timer_read_counter(struct omap_dm_timer *timer)
581{
Tarun Kanti DebBarmaab4eb8b2011-09-20 17:00:26 +0530582 if (unlikely(!timer || pm_runtime_suspended(&timer->pdev->dev))) {
583 pr_err("%s: timer not iavailable or enabled.\n", __func__);
Tarun Kanti DebBarmab4811132011-09-20 17:00:24 +0530584 return 0;
585 }
586
Tony Lindgrenee17f112011-09-16 15:44:20 -0700587 return __omap_dm_timer_read_counter(timer, timer->posted);
Tony Lindgren92105bb2005-09-07 17:20:26 +0100588}
Timo Kokkonen6c366e32009-03-23 18:07:46 -0700589EXPORT_SYMBOL_GPL(omap_dm_timer_read_counter);
Tony Lindgren92105bb2005-09-07 17:20:26 +0100590
Tarun Kanti DebBarmaab4eb8b2011-09-20 17:00:26 +0530591int omap_dm_timer_write_counter(struct omap_dm_timer *timer, unsigned int value)
Timo Teras83379c82006-06-26 16:16:23 -0700592{
Tarun Kanti DebBarmaab4eb8b2011-09-20 17:00:26 +0530593 if (unlikely(!timer || pm_runtime_suspended(&timer->pdev->dev))) {
594 pr_err("%s: timer not available or enabled.\n", __func__);
595 return -EINVAL;
Tarun Kanti DebBarmab4811132011-09-20 17:00:24 +0530596 }
597
Timo Terasfa4bb622006-09-25 12:41:35 +0300598 omap_dm_timer_write_reg(timer, OMAP_TIMER_COUNTER_REG, value);
Tarun Kanti DebBarmab4811132011-09-20 17:00:24 +0530599
600 /* Save the context */
601 timer->context.tcrr = value;
Tarun Kanti DebBarmaab4eb8b2011-09-20 17:00:26 +0530602 return 0;
Timo Teras83379c82006-06-26 16:16:23 -0700603}
Timo Kokkonen6c366e32009-03-23 18:07:46 -0700604EXPORT_SYMBOL_GPL(omap_dm_timer_write_counter);
Timo Teras83379c82006-06-26 16:16:23 -0700605
Timo Teras77900a22006-06-26 16:16:12 -0700606int omap_dm_timers_active(void)
Tony Lindgren92105bb2005-09-07 17:20:26 +0100607{
Tarun Kanti DebBarma3392cdd2011-09-20 17:00:20 +0530608 struct omap_dm_timer *timer;
Tony Lindgren92105bb2005-09-07 17:20:26 +0100609
Tarun Kanti DebBarma3392cdd2011-09-20 17:00:20 +0530610 list_for_each_entry(timer, &omap_timer_list, node) {
Tarun Kanti DebBarmaffe07ce2011-09-20 17:00:21 +0530611 if (!timer->reserved)
Timo Teras12583a72006-09-25 12:41:42 +0300612 continue;
613
Timo Teras77900a22006-06-26 16:16:12 -0700614 if (omap_dm_timer_read_reg(timer, OMAP_TIMER_CTRL_REG) &
Timo Terasfa4bb622006-09-25 12:41:35 +0300615 OMAP_TIMER_CTRL_ST) {
Timo Teras77900a22006-06-26 16:16:12 -0700616 return 1;
Timo Terasfa4bb622006-09-25 12:41:35 +0300617 }
Tony Lindgren92105bb2005-09-07 17:20:26 +0100618 }
Tony Lindgren92105bb2005-09-07 17:20:26 +0100619 return 0;
620}
Timo Kokkonen6c366e32009-03-23 18:07:46 -0700621EXPORT_SYMBOL_GPL(omap_dm_timers_active);
Tony Lindgren92105bb2005-09-07 17:20:26 +0100622
Tarun Kanti DebBarmadf284722011-09-20 17:00:19 +0530623/**
624 * omap_dm_timer_probe - probe function called for every registered device
625 * @pdev: pointer to current timer platform device
626 *
627 * Called by driver framework at the end of device registration for all
628 * timer devices.
629 */
630static int __devinit omap_dm_timer_probe(struct platform_device *pdev)
631{
632 int ret;
633 unsigned long flags;
634 struct omap_dm_timer *timer;
635 struct resource *mem, *irq, *ioarea;
636 struct dmtimer_platform_data *pdata = pdev->dev.platform_data;
637
638 if (!pdata) {
639 dev_err(&pdev->dev, "%s: no platform data.\n", __func__);
640 return -ENODEV;
641 }
642
643 irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
644 if (unlikely(!irq)) {
645 dev_err(&pdev->dev, "%s: no IRQ resource.\n", __func__);
646 return -ENODEV;
647 }
648
649 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
650 if (unlikely(!mem)) {
651 dev_err(&pdev->dev, "%s: no memory resource.\n", __func__);
652 return -ENODEV;
653 }
654
655 ioarea = request_mem_region(mem->start, resource_size(mem),
656 pdev->name);
657 if (!ioarea) {
658 dev_err(&pdev->dev, "%s: region already claimed.\n", __func__);
659 return -EBUSY;
660 }
661
662 timer = kzalloc(sizeof(struct omap_dm_timer), GFP_KERNEL);
663 if (!timer) {
664 dev_err(&pdev->dev, "%s: no memory for omap_dm_timer.\n",
665 __func__);
666 ret = -ENOMEM;
667 goto err_free_ioregion;
668 }
669
670 timer->io_base = ioremap(mem->start, resource_size(mem));
671 if (!timer->io_base) {
672 dev_err(&pdev->dev, "%s: ioremap failed.\n", __func__);
673 ret = -ENOMEM;
674 goto err_free_mem;
675 }
676
677 timer->id = pdev->id;
678 timer->irq = irq->start;
Tony Lindgren0dad9fa2011-09-21 16:38:51 -0700679 timer->reserved = pdata->reserved;
Tarun Kanti DebBarmadf284722011-09-20 17:00:19 +0530680 timer->pdev = pdev;
Tarun Kanti DebBarmab4811132011-09-20 17:00:24 +0530681 timer->loses_context = pdata->loses_context;
682 timer->get_context_loss_count = pdata->get_context_loss_count;
Tarun Kanti DebBarmadf284722011-09-20 17:00:19 +0530683
Tarun Kanti DebBarmaffe07ce2011-09-20 17:00:21 +0530684 /* Skip pm_runtime_enable for OMAP1 */
685 if (!pdata->needs_manual_reset) {
686 pm_runtime_enable(&pdev->dev);
687 pm_runtime_irq_safe(&pdev->dev);
688 }
689
Tony Lindgren0dad9fa2011-09-21 16:38:51 -0700690 if (!timer->reserved) {
691 pm_runtime_get_sync(&pdev->dev);
692 __omap_dm_timer_init_regs(timer);
693 pm_runtime_put(&pdev->dev);
694 }
695
Tarun Kanti DebBarmadf284722011-09-20 17:00:19 +0530696 /* add the timer element to the list */
697 spin_lock_irqsave(&dm_timer_lock, flags);
698 list_add_tail(&timer->node, &omap_timer_list);
699 spin_unlock_irqrestore(&dm_timer_lock, flags);
700
701 dev_dbg(&pdev->dev, "Device Probed.\n");
702
703 return 0;
704
705err_free_mem:
706 kfree(timer);
707
708err_free_ioregion:
709 release_mem_region(mem->start, resource_size(mem));
710
711 return ret;
712}
713
714/**
715 * omap_dm_timer_remove - cleanup a registered timer device
716 * @pdev: pointer to current timer platform device
717 *
718 * Called by driver framework whenever a timer device is unregistered.
719 * In addition to freeing platform resources it also deletes the timer
720 * entry from the local list.
721 */
722static int __devexit omap_dm_timer_remove(struct platform_device *pdev)
723{
724 struct omap_dm_timer *timer;
725 unsigned long flags;
726 int ret = -EINVAL;
727
728 spin_lock_irqsave(&dm_timer_lock, flags);
729 list_for_each_entry(timer, &omap_timer_list, node)
730 if (timer->pdev->id == pdev->id) {
731 list_del(&timer->node);
732 kfree(timer);
733 ret = 0;
734 break;
735 }
736 spin_unlock_irqrestore(&dm_timer_lock, flags);
737
738 return ret;
739}
740
741static struct platform_driver omap_dm_timer_driver = {
742 .probe = omap_dm_timer_probe,
Arnd Bergmann4c23c8d2011-10-01 18:42:47 +0200743 .remove = __devexit_p(omap_dm_timer_remove),
Tarun Kanti DebBarmadf284722011-09-20 17:00:19 +0530744 .driver = {
745 .name = "omap_timer",
746 },
747};
748
749static int __init omap_dm_timer_driver_init(void)
750{
751 return platform_driver_register(&omap_dm_timer_driver);
752}
753
754static void __exit omap_dm_timer_driver_exit(void)
755{
756 platform_driver_unregister(&omap_dm_timer_driver);
757}
758
759early_platform_init("earlytimer", &omap_dm_timer_driver);
760module_init(omap_dm_timer_driver_init);
761module_exit(omap_dm_timer_driver_exit);
762
763MODULE_DESCRIPTION("OMAP Dual-Mode Timer Driver");
764MODULE_LICENSE("GPL");
765MODULE_ALIAS("platform:" DRIVER_NAME);
766MODULE_AUTHOR("Texas Instruments Inc");