1 // SPDX-License-Identifier: GPL-2.0+
3 * linux/arch/arm/plat-omap/dmtimer.c
5 * OMAP Dual-Mode Timers
7 * Copyright (C) 2010 Texas Instruments Incorporated - https://www.ti.com/
8 * Tarun Kanti DebBarma <tarun.kanti@ti.com>
9 * Thara Gopinath <thara@ti.com>
11 * dmtimer adaptation to platform_driver.
13 * Copyright (C) 2005 Nokia Corporation
14 * OMAP2 support by Juha Yrjola
15 * API improvements and OMAP2 clock framework support by Timo Teras
17 * Copyright (C) 2009 Texas Instruments
18 * Added OMAP4 support - Santosh Shilimkar <santosh.shilimkar@ti.com>
21 #include <linux/clk.h>
22 #include <linux/clk-provider.h>
23 #include <linux/cpu_pm.h>
24 #include <linux/module.h>
26 #include <linux/device.h>
27 #include <linux/err.h>
28 #include <linux/pm_runtime.h>
30 #include <linux/of_device.h>
31 #include <linux/platform_device.h>
32 #include <linux/platform_data/dmtimer-omap.h>
34 #include <clocksource/timer-ti-dm.h>
36 static u32 omap_reserved_systimers
;
37 static LIST_HEAD(omap_timer_list
);
38 static DEFINE_SPINLOCK(dm_timer_lock
);
48 * omap_dm_timer_read_reg - read timer registers in posted and non-posted mode
49 * @timer: timer pointer over which read operation to perform
50 * @reg: lowest byte holds the register offset
52 * The posted mode bit is encoded in reg. Note that in posted mode write
53 * pending bit must be checked. Otherwise a read of a non completed write
54 * will produce an error.
56 static inline u32
omap_dm_timer_read_reg(struct omap_dm_timer
*timer
, u32 reg
)
58 WARN_ON((reg
& 0xff) < _OMAP_TIMER_WAKEUP_EN_OFFSET
);
59 return __omap_dm_timer_read(timer
, reg
, timer
->posted
);
63 * omap_dm_timer_write_reg - write timer registers in posted and non-posted mode
64 * @timer: timer pointer over which write operation is to perform
65 * @reg: lowest byte holds the register offset
66 * @value: data to write into the register
68 * The posted mode bit is encoded in reg. Note that in posted mode the write
69 * pending bit must be checked. Otherwise a write on a register which has a
70 * pending write will be lost.
72 static void omap_dm_timer_write_reg(struct omap_dm_timer
*timer
, u32 reg
,
75 WARN_ON((reg
& 0xff) < _OMAP_TIMER_WAKEUP_EN_OFFSET
);
76 __omap_dm_timer_write(timer
, reg
, value
, timer
->posted
);
79 static void omap_timer_restore_context(struct omap_dm_timer
*timer
)
81 omap_dm_timer_write_reg(timer
, OMAP_TIMER_WAKEUP_EN_REG
,
83 omap_dm_timer_write_reg(timer
, OMAP_TIMER_COUNTER_REG
,
85 omap_dm_timer_write_reg(timer
, OMAP_TIMER_LOAD_REG
,
87 omap_dm_timer_write_reg(timer
, OMAP_TIMER_MATCH_REG
,
89 omap_dm_timer_write_reg(timer
, OMAP_TIMER_IF_CTRL_REG
,
90 timer
->context
.tsicr
);
91 writel_relaxed(timer
->context
.tier
, timer
->irq_ena
);
92 omap_dm_timer_write_reg(timer
, OMAP_TIMER_CTRL_REG
,
96 static void omap_timer_save_context(struct omap_dm_timer
*timer
)
99 omap_dm_timer_read_reg(timer
, OMAP_TIMER_CTRL_REG
);
100 timer
->context
.twer
=
101 omap_dm_timer_read_reg(timer
, OMAP_TIMER_WAKEUP_EN_REG
);
102 timer
->context
.tldr
=
103 omap_dm_timer_read_reg(timer
, OMAP_TIMER_LOAD_REG
);
104 timer
->context
.tmar
=
105 omap_dm_timer_read_reg(timer
, OMAP_TIMER_MATCH_REG
);
106 timer
->context
.tier
= readl_relaxed(timer
->irq_ena
);
107 timer
->context
.tsicr
=
108 omap_dm_timer_read_reg(timer
, OMAP_TIMER_IF_CTRL_REG
);
111 static int omap_timer_context_notifier(struct notifier_block
*nb
,
112 unsigned long cmd
, void *v
)
114 struct omap_dm_timer
*timer
;
116 timer
= container_of(nb
, struct omap_dm_timer
, nb
);
119 case CPU_CLUSTER_PM_ENTER
:
120 if ((timer
->capability
& OMAP_TIMER_ALWON
) ||
121 !atomic_read(&timer
->enabled
))
123 omap_timer_save_context(timer
);
125 case CPU_CLUSTER_PM_ENTER_FAILED
:
126 case CPU_CLUSTER_PM_EXIT
:
127 if ((timer
->capability
& OMAP_TIMER_ALWON
) ||
128 !atomic_read(&timer
->enabled
))
130 omap_timer_restore_context(timer
);
137 static int omap_dm_timer_reset(struct omap_dm_timer
*timer
)
139 u32 l
, timeout
= 100000;
141 if (timer
->revision
!= 1)
144 omap_dm_timer_write_reg(timer
, OMAP_TIMER_IF_CTRL_REG
, 0x06);
147 l
= __omap_dm_timer_read(timer
,
148 OMAP_TIMER_V1_SYS_STAT_OFFSET
, 0);
149 } while (!l
&& timeout
--);
152 dev_err(&timer
->pdev
->dev
, "Timer failed to reset\n");
156 /* Configure timer for smart-idle mode */
157 l
= __omap_dm_timer_read(timer
, OMAP_TIMER_OCP_CFG_OFFSET
, 0);
159 __omap_dm_timer_write(timer
, OMAP_TIMER_OCP_CFG_OFFSET
, l
, 0);
166 static int omap_dm_timer_set_source(struct omap_dm_timer
*timer
, int source
)
169 const char *parent_name
;
171 struct dmtimer_platform_data
*pdata
;
173 if (unlikely(!timer
) || IS_ERR(timer
->fclk
))
177 case OMAP_TIMER_SRC_SYS_CLK
:
178 parent_name
= "timer_sys_ck";
180 case OMAP_TIMER_SRC_32_KHZ
:
181 parent_name
= "timer_32k_ck";
183 case OMAP_TIMER_SRC_EXT_CLK
:
184 parent_name
= "timer_ext_ck";
190 pdata
= timer
->pdev
->dev
.platform_data
;
193 * FIXME: Used for OMAP1 devices only because they do not currently
194 * use the clock framework to set the parent clock. To be removed
195 * once OMAP1 migrated to using clock framework for dmtimers
197 if (pdata
&& pdata
->set_timer_src
)
198 return pdata
->set_timer_src(timer
->pdev
, source
);
200 #if defined(CONFIG_COMMON_CLK)
201 /* Check if the clock has configurable parents */
202 if (clk_hw_get_num_parents(__clk_get_hw(timer
->fclk
)) < 2)
206 parent
= clk_get(&timer
->pdev
->dev
, parent_name
);
207 if (IS_ERR(parent
)) {
208 pr_err("%s: %s not found\n", __func__
, parent_name
);
212 ret
= clk_set_parent(timer
->fclk
, parent
);
214 pr_err("%s: failed to set %s as parent\n", __func__
,
222 static void omap_dm_timer_enable(struct omap_dm_timer
*timer
)
224 pm_runtime_get_sync(&timer
->pdev
->dev
);
227 static void omap_dm_timer_disable(struct omap_dm_timer
*timer
)
229 pm_runtime_put_sync(&timer
->pdev
->dev
);
232 static int omap_dm_timer_prepare(struct omap_dm_timer
*timer
)
237 * FIXME: OMAP1 devices do not use the clock framework for dmtimers so
238 * do not call clk_get() for these devices.
240 if (!(timer
->capability
& OMAP_TIMER_NEEDS_RESET
)) {
241 timer
->fclk
= clk_get(&timer
->pdev
->dev
, "fck");
242 if (WARN_ON_ONCE(IS_ERR(timer
->fclk
))) {
243 dev_err(&timer
->pdev
->dev
, ": No fclk handle.\n");
248 omap_dm_timer_enable(timer
);
250 if (timer
->capability
& OMAP_TIMER_NEEDS_RESET
) {
251 rc
= omap_dm_timer_reset(timer
);
253 omap_dm_timer_disable(timer
);
258 __omap_dm_timer_enable_posted(timer
);
259 omap_dm_timer_disable(timer
);
264 static inline u32
omap_dm_timer_reserved_systimer(int id
)
266 return (omap_reserved_systimers
& (1 << (id
- 1))) ? 1 : 0;
269 int omap_dm_timer_reserve_systimer(int id
)
271 if (omap_dm_timer_reserved_systimer(id
))
274 omap_reserved_systimers
|= (1 << (id
- 1));
279 static struct omap_dm_timer
*_omap_dm_timer_request(int req_type
, void *data
)
281 struct omap_dm_timer
*timer
= NULL
, *t
;
282 struct device_node
*np
= NULL
;
294 case REQUEST_BY_NODE
:
295 np
= (struct device_node
*)data
;
302 spin_lock_irqsave(&dm_timer_lock
, flags
);
303 list_for_each_entry(t
, &omap_timer_list
, node
) {
309 if (id
== t
->pdev
->id
) {
316 if (cap
== (t
->capability
& cap
)) {
318 * If timer is not NULL, we have already found
319 * one timer. But it was not an exact match
320 * because it had more capabilities than what
321 * was required. Therefore, unreserve the last
322 * timer found and see if this one is a better
330 /* Exit loop early if we find an exact match */
331 if (t
->capability
== cap
)
335 case REQUEST_BY_NODE
:
336 if (np
== t
->pdev
->dev
.of_node
) {
350 spin_unlock_irqrestore(&dm_timer_lock
, flags
);
352 if (timer
&& omap_dm_timer_prepare(timer
)) {
358 pr_debug("%s: timer request failed!\n", __func__
);
363 static struct omap_dm_timer
*omap_dm_timer_request(void)
365 return _omap_dm_timer_request(REQUEST_ANY
, NULL
);
368 static struct omap_dm_timer
*omap_dm_timer_request_specific(int id
)
370 /* Requesting timer by ID is not supported when device tree is used */
371 if (of_have_populated_dt()) {
372 pr_warn("%s: Please use omap_dm_timer_request_by_node()\n",
377 return _omap_dm_timer_request(REQUEST_BY_ID
, &id
);
381 * omap_dm_timer_request_by_cap - Request a timer by capability
382 * @cap: Bit mask of capabilities to match
384 * Find a timer based upon capabilities bit mask. Callers of this function
385 * should use the definitions found in the plat/dmtimer.h file under the
386 * comment "timer capabilities used in hwmod database". Returns pointer to
387 * timer handle on success and a NULL pointer on failure.
389 struct omap_dm_timer
*omap_dm_timer_request_by_cap(u32 cap
)
391 return _omap_dm_timer_request(REQUEST_BY_CAP
, &cap
);
395 * omap_dm_timer_request_by_node - Request a timer by device-tree node
396 * @np: Pointer to device-tree timer node
398 * Request a timer based upon a device node pointer. Returns pointer to
399 * timer handle on success and a NULL pointer on failure.
401 static struct omap_dm_timer
*omap_dm_timer_request_by_node(struct device_node
*np
)
406 return _omap_dm_timer_request(REQUEST_BY_NODE
, np
);
409 static int omap_dm_timer_free(struct omap_dm_timer
*timer
)
411 if (unlikely(!timer
))
414 clk_put(timer
->fclk
);
416 WARN_ON(!timer
->reserved
);
421 int omap_dm_timer_get_irq(struct omap_dm_timer
*timer
)
428 #if defined(CONFIG_ARCH_OMAP1)
429 #include <mach/hardware.h>
431 static struct clk
*omap_dm_timer_get_fclk(struct omap_dm_timer
*timer
)
437 * omap_dm_timer_modify_idlect_mask - Check if any running timers use ARMXOR
438 * @inputmask: current value of idlect mask
440 __u32
omap_dm_timer_modify_idlect_mask(__u32 inputmask
)
443 struct omap_dm_timer
*timer
= NULL
;
446 /* If ARMXOR cannot be idled this function call is unnecessary */
447 if (!(inputmask
& (1 << 1)))
450 /* If any active timer is using ARMXOR return modified mask */
451 spin_lock_irqsave(&dm_timer_lock
, flags
);
452 list_for_each_entry(timer
, &omap_timer_list
, node
) {
455 l
= omap_dm_timer_read_reg(timer
, OMAP_TIMER_CTRL_REG
);
456 if (l
& OMAP_TIMER_CTRL_ST
) {
457 if (((omap_readl(MOD_CONF_CTRL_1
) >> (i
* 2)) & 0x03) == 0)
458 inputmask
&= ~(1 << 1);
460 inputmask
&= ~(1 << 2);
464 spin_unlock_irqrestore(&dm_timer_lock
, flags
);
471 static struct clk
*omap_dm_timer_get_fclk(struct omap_dm_timer
*timer
)
473 if (timer
&& !IS_ERR(timer
->fclk
))
478 __u32
omap_dm_timer_modify_idlect_mask(__u32 inputmask
)
487 int omap_dm_timer_trigger(struct omap_dm_timer
*timer
)
489 if (unlikely(!timer
|| !atomic_read(&timer
->enabled
))) {
490 pr_err("%s: timer not available or enabled.\n", __func__
);
494 omap_dm_timer_write_reg(timer
, OMAP_TIMER_TRIGGER_REG
, 0);
498 static int omap_dm_timer_start(struct omap_dm_timer
*timer
)
502 if (unlikely(!timer
))
505 omap_dm_timer_enable(timer
);
507 l
= omap_dm_timer_read_reg(timer
, OMAP_TIMER_CTRL_REG
);
508 if (!(l
& OMAP_TIMER_CTRL_ST
)) {
509 l
|= OMAP_TIMER_CTRL_ST
;
510 omap_dm_timer_write_reg(timer
, OMAP_TIMER_CTRL_REG
, l
);
516 static int omap_dm_timer_stop(struct omap_dm_timer
*timer
)
518 unsigned long rate
= 0;
520 if (unlikely(!timer
))
523 if (!(timer
->capability
& OMAP_TIMER_NEEDS_RESET
))
524 rate
= clk_get_rate(timer
->fclk
);
526 __omap_dm_timer_stop(timer
, timer
->posted
, rate
);
528 omap_dm_timer_disable(timer
);
532 static int omap_dm_timer_set_load(struct omap_dm_timer
*timer
,
535 if (unlikely(!timer
))
538 omap_dm_timer_enable(timer
);
539 omap_dm_timer_write_reg(timer
, OMAP_TIMER_LOAD_REG
, load
);
541 omap_dm_timer_disable(timer
);
545 static int omap_dm_timer_set_match(struct omap_dm_timer
*timer
, int enable
,
550 if (unlikely(!timer
))
553 omap_dm_timer_enable(timer
);
554 l
= omap_dm_timer_read_reg(timer
, OMAP_TIMER_CTRL_REG
);
556 l
|= OMAP_TIMER_CTRL_CE
;
558 l
&= ~OMAP_TIMER_CTRL_CE
;
559 omap_dm_timer_write_reg(timer
, OMAP_TIMER_MATCH_REG
, match
);
560 omap_dm_timer_write_reg(timer
, OMAP_TIMER_CTRL_REG
, l
);
562 omap_dm_timer_disable(timer
);
566 static int omap_dm_timer_set_pwm(struct omap_dm_timer
*timer
, int def_on
,
567 int toggle
, int trigger
, int autoreload
)
571 if (unlikely(!timer
))
574 omap_dm_timer_enable(timer
);
575 l
= omap_dm_timer_read_reg(timer
, OMAP_TIMER_CTRL_REG
);
576 l
&= ~(OMAP_TIMER_CTRL_GPOCFG
| OMAP_TIMER_CTRL_SCPWM
|
577 OMAP_TIMER_CTRL_PT
| (0x03 << 10) | OMAP_TIMER_CTRL_AR
);
579 l
|= OMAP_TIMER_CTRL_SCPWM
;
581 l
|= OMAP_TIMER_CTRL_PT
;
584 l
|= OMAP_TIMER_CTRL_AR
;
585 omap_dm_timer_write_reg(timer
, OMAP_TIMER_CTRL_REG
, l
);
587 omap_dm_timer_disable(timer
);
591 static int omap_dm_timer_get_pwm_status(struct omap_dm_timer
*timer
)
595 if (unlikely(!timer
))
598 omap_dm_timer_enable(timer
);
599 l
= omap_dm_timer_read_reg(timer
, OMAP_TIMER_CTRL_REG
);
600 omap_dm_timer_disable(timer
);
605 static int omap_dm_timer_set_prescaler(struct omap_dm_timer
*timer
,
610 if (unlikely(!timer
) || prescaler
< -1 || prescaler
> 7)
613 omap_dm_timer_enable(timer
);
614 l
= omap_dm_timer_read_reg(timer
, OMAP_TIMER_CTRL_REG
);
615 l
&= ~(OMAP_TIMER_CTRL_PRE
| (0x07 << 2));
616 if (prescaler
>= 0) {
617 l
|= OMAP_TIMER_CTRL_PRE
;
620 omap_dm_timer_write_reg(timer
, OMAP_TIMER_CTRL_REG
, l
);
622 omap_dm_timer_disable(timer
);
626 static int omap_dm_timer_set_int_enable(struct omap_dm_timer
*timer
,
629 if (unlikely(!timer
))
632 omap_dm_timer_enable(timer
);
633 __omap_dm_timer_int_enable(timer
, value
);
635 omap_dm_timer_disable(timer
);
640 * omap_dm_timer_set_int_disable - disable timer interrupts
641 * @timer: pointer to timer handle
642 * @mask: bit mask of interrupts to be disabled
644 * Disables the specified timer interrupts for a timer.
646 static int omap_dm_timer_set_int_disable(struct omap_dm_timer
*timer
, u32 mask
)
650 if (unlikely(!timer
))
653 omap_dm_timer_enable(timer
);
655 if (timer
->revision
== 1)
656 l
= readl_relaxed(timer
->irq_ena
) & ~mask
;
658 writel_relaxed(l
, timer
->irq_dis
);
659 l
= omap_dm_timer_read_reg(timer
, OMAP_TIMER_WAKEUP_EN_REG
) & ~mask
;
660 omap_dm_timer_write_reg(timer
, OMAP_TIMER_WAKEUP_EN_REG
, l
);
662 omap_dm_timer_disable(timer
);
666 static unsigned int omap_dm_timer_read_status(struct omap_dm_timer
*timer
)
670 if (unlikely(!timer
|| !atomic_read(&timer
->enabled
))) {
671 pr_err("%s: timer not available or enabled.\n", __func__
);
675 l
= readl_relaxed(timer
->irq_stat
);
680 static int omap_dm_timer_write_status(struct omap_dm_timer
*timer
, unsigned int value
)
682 if (unlikely(!timer
|| !atomic_read(&timer
->enabled
)))
685 __omap_dm_timer_write_status(timer
, value
);
690 static unsigned int omap_dm_timer_read_counter(struct omap_dm_timer
*timer
)
692 if (unlikely(!timer
|| !atomic_read(&timer
->enabled
))) {
693 pr_err("%s: timer not iavailable or enabled.\n", __func__
);
697 return __omap_dm_timer_read_counter(timer
, timer
->posted
);
700 static int omap_dm_timer_write_counter(struct omap_dm_timer
*timer
, unsigned int value
)
702 if (unlikely(!timer
|| !atomic_read(&timer
->enabled
))) {
703 pr_err("%s: timer not available or enabled.\n", __func__
);
707 omap_dm_timer_write_reg(timer
, OMAP_TIMER_COUNTER_REG
, value
);
709 /* Save the context */
710 timer
->context
.tcrr
= value
;
714 int omap_dm_timers_active(void)
716 struct omap_dm_timer
*timer
;
718 list_for_each_entry(timer
, &omap_timer_list
, node
) {
719 if (!timer
->reserved
)
722 if (omap_dm_timer_read_reg(timer
, OMAP_TIMER_CTRL_REG
) &
723 OMAP_TIMER_CTRL_ST
) {
730 static int __maybe_unused
omap_dm_timer_runtime_suspend(struct device
*dev
)
732 struct omap_dm_timer
*timer
= dev_get_drvdata(dev
);
734 atomic_set(&timer
->enabled
, 0);
736 if (timer
->capability
& OMAP_TIMER_ALWON
|| !timer
->func_base
)
739 omap_timer_save_context(timer
);
744 static int __maybe_unused
omap_dm_timer_runtime_resume(struct device
*dev
)
746 struct omap_dm_timer
*timer
= dev_get_drvdata(dev
);
748 if (!(timer
->capability
& OMAP_TIMER_ALWON
) && timer
->func_base
)
749 omap_timer_restore_context(timer
);
751 atomic_set(&timer
->enabled
, 1);
756 static const struct dev_pm_ops omap_dm_timer_pm_ops
= {
757 SET_RUNTIME_PM_OPS(omap_dm_timer_runtime_suspend
,
758 omap_dm_timer_runtime_resume
, NULL
)
761 static const struct of_device_id omap_timer_match
[];
764 * omap_dm_timer_probe - probe function called for every registered device
765 * @pdev: pointer to current timer platform device
767 * Called by driver framework at the end of device registration for all
770 static int omap_dm_timer_probe(struct platform_device
*pdev
)
773 struct omap_dm_timer
*timer
;
774 struct device
*dev
= &pdev
->dev
;
775 const struct dmtimer_platform_data
*pdata
;
778 pdata
= of_device_get_match_data(dev
);
780 pdata
= dev_get_platdata(dev
);
782 dev
->platform_data
= (void *)pdata
;
785 dev_err(dev
, "%s: no platform data.\n", __func__
);
789 timer
= devm_kzalloc(dev
, sizeof(*timer
), GFP_KERNEL
);
793 timer
->irq
= platform_get_irq(pdev
, 0);
797 timer
->fclk
= ERR_PTR(-ENODEV
);
798 timer
->io_base
= devm_platform_ioremap_resource(pdev
, 0);
799 if (IS_ERR(timer
->io_base
))
800 return PTR_ERR(timer
->io_base
);
802 platform_set_drvdata(pdev
, timer
);
805 if (of_find_property(dev
->of_node
, "ti,timer-alwon", NULL
))
806 timer
->capability
|= OMAP_TIMER_ALWON
;
807 if (of_find_property(dev
->of_node
, "ti,timer-dsp", NULL
))
808 timer
->capability
|= OMAP_TIMER_HAS_DSP_IRQ
;
809 if (of_find_property(dev
->of_node
, "ti,timer-pwm", NULL
))
810 timer
->capability
|= OMAP_TIMER_HAS_PWM
;
811 if (of_find_property(dev
->of_node
, "ti,timer-secure", NULL
))
812 timer
->capability
|= OMAP_TIMER_SECURE
;
814 timer
->id
= pdev
->id
;
815 timer
->capability
= pdata
->timer_capability
;
816 timer
->reserved
= omap_dm_timer_reserved_systimer(timer
->id
);
819 if (!(timer
->capability
& OMAP_TIMER_ALWON
)) {
820 timer
->nb
.notifier_call
= omap_timer_context_notifier
;
821 cpu_pm_register_notifier(&timer
->nb
);
825 timer
->errata
= pdata
->timer_errata
;
829 pm_runtime_enable(dev
);
831 if (!timer
->reserved
) {
832 ret
= pm_runtime_get_sync(dev
);
834 dev_err(dev
, "%s: pm_runtime_get_sync failed!\n",
838 __omap_dm_timer_init_regs(timer
);
842 /* add the timer element to the list */
843 spin_lock_irqsave(&dm_timer_lock
, flags
);
844 list_add_tail(&timer
->node
, &omap_timer_list
);
845 spin_unlock_irqrestore(&dm_timer_lock
, flags
);
847 dev_dbg(dev
, "Device Probed.\n");
852 pm_runtime_put_noidle(dev
);
853 pm_runtime_disable(dev
);
858 * omap_dm_timer_remove - cleanup a registered timer device
859 * @pdev: pointer to current timer platform device
861 * Called by driver framework whenever a timer device is unregistered.
862 * In addition to freeing platform resources it also deletes the timer
863 * entry from the local list.
865 static int omap_dm_timer_remove(struct platform_device
*pdev
)
867 struct omap_dm_timer
*timer
;
871 spin_lock_irqsave(&dm_timer_lock
, flags
);
872 list_for_each_entry(timer
, &omap_timer_list
, node
)
873 if (!strcmp(dev_name(&timer
->pdev
->dev
),
874 dev_name(&pdev
->dev
))) {
875 if (!(timer
->capability
& OMAP_TIMER_ALWON
))
876 cpu_pm_unregister_notifier(&timer
->nb
);
877 list_del(&timer
->node
);
881 spin_unlock_irqrestore(&dm_timer_lock
, flags
);
883 pm_runtime_disable(&pdev
->dev
);
888 static const struct omap_dm_timer_ops dmtimer_ops
= {
889 .request_by_node
= omap_dm_timer_request_by_node
,
890 .request_specific
= omap_dm_timer_request_specific
,
891 .request
= omap_dm_timer_request
,
892 .set_source
= omap_dm_timer_set_source
,
893 .get_irq
= omap_dm_timer_get_irq
,
894 .set_int_enable
= omap_dm_timer_set_int_enable
,
895 .set_int_disable
= omap_dm_timer_set_int_disable
,
896 .free
= omap_dm_timer_free
,
897 .enable
= omap_dm_timer_enable
,
898 .disable
= omap_dm_timer_disable
,
899 .get_fclk
= omap_dm_timer_get_fclk
,
900 .start
= omap_dm_timer_start
,
901 .stop
= omap_dm_timer_stop
,
902 .set_load
= omap_dm_timer_set_load
,
903 .set_match
= omap_dm_timer_set_match
,
904 .set_pwm
= omap_dm_timer_set_pwm
,
905 .get_pwm_status
= omap_dm_timer_get_pwm_status
,
906 .set_prescaler
= omap_dm_timer_set_prescaler
,
907 .read_counter
= omap_dm_timer_read_counter
,
908 .write_counter
= omap_dm_timer_write_counter
,
909 .read_status
= omap_dm_timer_read_status
,
910 .write_status
= omap_dm_timer_write_status
,
913 static const struct dmtimer_platform_data omap3plus_pdata
= {
914 .timer_errata
= OMAP_TIMER_ERRATA_I103_I767
,
915 .timer_ops
= &dmtimer_ops
,
918 static const struct of_device_id omap_timer_match
[] = {
920 .compatible
= "ti,omap2420-timer",
923 .compatible
= "ti,omap3430-timer",
924 .data
= &omap3plus_pdata
,
927 .compatible
= "ti,omap4430-timer",
928 .data
= &omap3plus_pdata
,
931 .compatible
= "ti,omap5430-timer",
932 .data
= &omap3plus_pdata
,
935 .compatible
= "ti,am335x-timer",
936 .data
= &omap3plus_pdata
,
939 .compatible
= "ti,am335x-timer-1ms",
940 .data
= &omap3plus_pdata
,
943 .compatible
= "ti,dm816-timer",
944 .data
= &omap3plus_pdata
,
948 MODULE_DEVICE_TABLE(of
, omap_timer_match
);
950 static struct platform_driver omap_dm_timer_driver
= {
951 .probe
= omap_dm_timer_probe
,
952 .remove
= omap_dm_timer_remove
,
954 .name
= "omap_timer",
955 .of_match_table
= of_match_ptr(omap_timer_match
),
956 .pm
= &omap_dm_timer_pm_ops
,
960 module_platform_driver(omap_dm_timer_driver
);
962 MODULE_DESCRIPTION("OMAP Dual-Mode Timer Driver");
963 MODULE_LICENSE("GPL");
964 MODULE_AUTHOR("Texas Instruments Inc");