Tony Lindgren | 1dbae81 | 2005-11-10 14:26:51 +0000 | [diff] [blame] | 1 | /* |
Tony Lindgren | 0f622e8 | 2011-03-29 15:54:50 -0700 | [diff] [blame] | 2 | * linux/arch/arm/mach-omap2/timer.c |
Tony Lindgren | 1dbae81 | 2005-11-10 14:26:51 +0000 | [diff] [blame] | 3 | * |
| 4 | * OMAP2 GP timer support. |
| 5 | * |
Paul Walmsley | f248076 | 2009-04-23 21:11:10 -0600 | [diff] [blame] | 6 | * Copyright (C) 2009 Nokia Corporation |
| 7 | * |
Kevin Hilman | 5a3a388 | 2007-11-12 23:24:02 -0800 | [diff] [blame] | 8 | * Update to use new clocksource/clockevent layers |
| 9 | * Author: Kevin Hilman, MontaVista Software, Inc. <source@mvista.com> |
| 10 | * Copyright (C) 2007 MontaVista Software, Inc. |
| 11 | * |
| 12 | * Original driver: |
Tony Lindgren | 1dbae81 | 2005-11-10 14:26:51 +0000 | [diff] [blame] | 13 | * Copyright (C) 2005 Nokia Corporation |
| 14 | * Author: Paul Mundt <paul.mundt@nokia.com> |
Jan Engelhardt | 96de0e2 | 2007-10-19 23:21:04 +0200 | [diff] [blame] | 15 | * Juha Yrjölä <juha.yrjola@nokia.com> |
Timo Teras | 77900a2 | 2006-06-26 16:16:12 -0700 | [diff] [blame] | 16 | * OMAP Dual-mode timer framework support by Timo Teras |
Tony Lindgren | 1dbae81 | 2005-11-10 14:26:51 +0000 | [diff] [blame] | 17 | * |
| 18 | * Some parts based off of TI's 24xx code: |
| 19 | * |
Santosh Shilimkar | 4416907 | 2009-05-28 14:16:04 -0700 | [diff] [blame] | 20 | * Copyright (C) 2004-2009 Texas Instruments, Inc. |
Tony Lindgren | 1dbae81 | 2005-11-10 14:26:51 +0000 | [diff] [blame] | 21 | * |
| 22 | * Roughly modelled after the OMAP1 MPU timer code. |
Santosh Shilimkar | 4416907 | 2009-05-28 14:16:04 -0700 | [diff] [blame] | 23 | * Added OMAP4 support - Santosh Shilimkar <santosh.shilimkar@ti.com> |
Tony Lindgren | 1dbae81 | 2005-11-10 14:26:51 +0000 | [diff] [blame] | 24 | * |
| 25 | * This file is subject to the terms and conditions of the GNU General Public |
| 26 | * License. See the file "COPYING" in the main directory of this archive |
| 27 | * for more details. |
| 28 | */ |
| 29 | #include <linux/init.h> |
| 30 | #include <linux/time.h> |
| 31 | #include <linux/interrupt.h> |
| 32 | #include <linux/err.h> |
Russell King | f8ce254 | 2006-01-07 16:15:52 +0000 | [diff] [blame] | 33 | #include <linux/clk.h> |
Timo Teras | 77900a2 | 2006-06-26 16:16:12 -0700 | [diff] [blame] | 34 | #include <linux/delay.h> |
Dirk Behme | e668729 | 2006-12-06 17:14:00 -0800 | [diff] [blame] | 35 | #include <linux/irq.h> |
Kevin Hilman | 5a3a388 | 2007-11-12 23:24:02 -0800 | [diff] [blame] | 36 | #include <linux/clocksource.h> |
| 37 | #include <linux/clockchips.h> |
Tarun Kanti DebBarma | c345c8b | 2011-09-20 17:00:18 +0530 | [diff] [blame] | 38 | #include <linux/slab.h> |
Santosh Shilimkar | eed0de2 | 2012-07-04 18:32:32 +0530 | [diff] [blame] | 39 | #include <linux/of.h> |
Russell King | f8ce254 | 2006-01-07 16:15:52 +0000 | [diff] [blame] | 40 | |
Tony Lindgren | 1dbae81 | 2005-11-10 14:26:51 +0000 | [diff] [blame] | 41 | #include <asm/mach/time.h> |
Marc Zyngier | a45c983 | 2012-01-10 19:44:19 +0000 | [diff] [blame] | 42 | #include <asm/smp_twd.h> |
Paul Walmsley | cbc9438 | 2011-02-22 19:59:49 -0700 | [diff] [blame] | 43 | #include <asm/sched_clock.h> |
Tony Lindgren | 7d7e1eb | 2012-08-27 17:43:01 -0700 | [diff] [blame] | 44 | |
Santosh Shilimkar | 3c7c5da | 2012-08-13 14:39:03 +0530 | [diff] [blame] | 45 | #include <asm/arch_timer.h> |
Tony Lindgren | 2a296c8 | 2012-10-02 17:41:35 -0700 | [diff] [blame] | 46 | #include "omap_hwmod.h" |
Tony Lindgren | 25c7d49 | 2012-10-02 17:25:48 -0700 | [diff] [blame] | 47 | #include "omap_device.h" |
Tony Lindgren | 7d7e1eb | 2012-08-27 17:43:01 -0700 | [diff] [blame] | 48 | #include <plat/dmtimer.h> |
Tony Lindgren | 1d5aef4 | 2012-10-03 16:36:40 -0700 | [diff] [blame^] | 49 | #include "omap-pm.h" |
Tarun Kanti DebBarma | b481113 | 2011-09-20 17:00:24 +0530 | [diff] [blame] | 50 | |
Tony Lindgren | dbc0416 | 2012-08-31 10:59:07 -0700 | [diff] [blame] | 51 | #include "soc.h" |
Tony Lindgren | 7d7e1eb | 2012-08-27 17:43:01 -0700 | [diff] [blame] | 52 | #include "common.h" |
Tarun Kanti DebBarma | b481113 | 2011-09-20 17:00:24 +0530 | [diff] [blame] | 53 | #include "powerdomain.h" |
Tony Lindgren | 1dbae81 | 2005-11-10 14:26:51 +0000 | [diff] [blame] | 54 | |
Tony Lindgren | aa56188 | 2011-03-29 15:54:48 -0700 | [diff] [blame] | 55 | /* Parent clocks, eventually these will come from the clock framework */ |
| 56 | |
| 57 | #define OMAP2_MPU_SOURCE "sys_ck" |
| 58 | #define OMAP3_MPU_SOURCE OMAP2_MPU_SOURCE |
| 59 | #define OMAP4_MPU_SOURCE "sys_clkin_ck" |
| 60 | #define OMAP2_32K_SOURCE "func_32k_ck" |
| 61 | #define OMAP3_32K_SOURCE "omap_32k_fck" |
| 62 | #define OMAP4_32K_SOURCE "sys_32k_ck" |
| 63 | |
| 64 | #ifdef CONFIG_OMAP_32K_TIMER |
| 65 | #define OMAP2_CLKEV_SOURCE OMAP2_32K_SOURCE |
| 66 | #define OMAP3_CLKEV_SOURCE OMAP3_32K_SOURCE |
| 67 | #define OMAP4_CLKEV_SOURCE OMAP4_32K_SOURCE |
| 68 | #define OMAP3_SECURE_TIMER 12 |
| 69 | #else |
| 70 | #define OMAP2_CLKEV_SOURCE OMAP2_MPU_SOURCE |
| 71 | #define OMAP3_CLKEV_SOURCE OMAP3_MPU_SOURCE |
| 72 | #define OMAP4_CLKEV_SOURCE OMAP4_MPU_SOURCE |
| 73 | #define OMAP3_SECURE_TIMER 1 |
| 74 | #endif |
Paul Walmsley | d8328f3 | 2011-01-15 21:32:01 -0700 | [diff] [blame] | 75 | |
Santosh Shilimkar | fa6d79d | 2012-08-13 14:24:24 +0530 | [diff] [blame] | 76 | #define REALTIME_COUNTER_BASE 0x48243200 |
| 77 | #define INCREMENTER_NUMERATOR_OFFSET 0x10 |
| 78 | #define INCREMENTER_DENUMERATOR_RELOAD_OFFSET 0x14 |
| 79 | #define NUMERATOR_DENUMERATOR_MASK 0xfffff000 |
| 80 | |
Tony Lindgren | aa56188 | 2011-03-29 15:54:48 -0700 | [diff] [blame] | 81 | /* Clockevent code */ |
| 82 | |
| 83 | static struct omap_dm_timer clkev; |
Kevin Hilman | 5a3a388 | 2007-11-12 23:24:02 -0800 | [diff] [blame] | 84 | static struct clock_event_device clockevent_gpt; |
Tony Lindgren | 1dbae81 | 2005-11-10 14:26:51 +0000 | [diff] [blame] | 85 | |
Linus Torvalds | 0cd61b6 | 2006-10-06 10:53:39 -0700 | [diff] [blame] | 86 | static irqreturn_t omap2_gp_timer_interrupt(int irq, void *dev_id) |
Tony Lindgren | 1dbae81 | 2005-11-10 14:26:51 +0000 | [diff] [blame] | 87 | { |
Kevin Hilman | 5a3a388 | 2007-11-12 23:24:02 -0800 | [diff] [blame] | 88 | struct clock_event_device *evt = &clockevent_gpt; |
Tony Lindgren | 1dbae81 | 2005-11-10 14:26:51 +0000 | [diff] [blame] | 89 | |
Tony Lindgren | ee17f11 | 2011-09-16 15:44:20 -0700 | [diff] [blame] | 90 | __omap_dm_timer_write_status(&clkev, OMAP_TIMER_INT_OVERFLOW); |
Kevin Hilman | 5a3a388 | 2007-11-12 23:24:02 -0800 | [diff] [blame] | 91 | |
| 92 | evt->event_handler(evt); |
Tony Lindgren | 1dbae81 | 2005-11-10 14:26:51 +0000 | [diff] [blame] | 93 | return IRQ_HANDLED; |
| 94 | } |
| 95 | |
| 96 | static struct irqaction omap2_gp_timer_irq = { |
Vaibhav Hiremath | f36921b | 2012-05-09 10:07:05 -0700 | [diff] [blame] | 97 | .name = "gp_timer", |
Bernhard Walle | b30faba | 2007-05-08 00:35:39 -0700 | [diff] [blame] | 98 | .flags = IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL, |
Tony Lindgren | 1dbae81 | 2005-11-10 14:26:51 +0000 | [diff] [blame] | 99 | .handler = omap2_gp_timer_interrupt, |
| 100 | }; |
| 101 | |
Kevin Hilman | 5a3a388 | 2007-11-12 23:24:02 -0800 | [diff] [blame] | 102 | static int omap2_gp_timer_set_next_event(unsigned long cycles, |
| 103 | struct clock_event_device *evt) |
Tony Lindgren | 1dbae81 | 2005-11-10 14:26:51 +0000 | [diff] [blame] | 104 | { |
Tony Lindgren | ee17f11 | 2011-09-16 15:44:20 -0700 | [diff] [blame] | 105 | __omap_dm_timer_load_start(&clkev, OMAP_TIMER_CTRL_ST, |
Tony Lindgren | aa56188 | 2011-03-29 15:54:48 -0700 | [diff] [blame] | 106 | 0xffffffff - cycles, 1); |
Tony Lindgren | 1dbae81 | 2005-11-10 14:26:51 +0000 | [diff] [blame] | 107 | |
Kevin Hilman | 5a3a388 | 2007-11-12 23:24:02 -0800 | [diff] [blame] | 108 | return 0; |
| 109 | } |
| 110 | |
| 111 | static void omap2_gp_timer_set_mode(enum clock_event_mode mode, |
| 112 | struct clock_event_device *evt) |
| 113 | { |
| 114 | u32 period; |
| 115 | |
Tony Lindgren | ee17f11 | 2011-09-16 15:44:20 -0700 | [diff] [blame] | 116 | __omap_dm_timer_stop(&clkev, 1, clkev.rate); |
Kevin Hilman | 5a3a388 | 2007-11-12 23:24:02 -0800 | [diff] [blame] | 117 | |
| 118 | switch (mode) { |
| 119 | case CLOCK_EVT_MODE_PERIODIC: |
Tony Lindgren | aa56188 | 2011-03-29 15:54:48 -0700 | [diff] [blame] | 120 | period = clkev.rate / HZ; |
Kevin Hilman | 5a3a388 | 2007-11-12 23:24:02 -0800 | [diff] [blame] | 121 | period -= 1; |
Tony Lindgren | aa56188 | 2011-03-29 15:54:48 -0700 | [diff] [blame] | 122 | /* Looks like we need to first set the load value separately */ |
Tony Lindgren | ee17f11 | 2011-09-16 15:44:20 -0700 | [diff] [blame] | 123 | __omap_dm_timer_write(&clkev, OMAP_TIMER_LOAD_REG, |
Tony Lindgren | aa56188 | 2011-03-29 15:54:48 -0700 | [diff] [blame] | 124 | 0xffffffff - period, 1); |
Tony Lindgren | ee17f11 | 2011-09-16 15:44:20 -0700 | [diff] [blame] | 125 | __omap_dm_timer_load_start(&clkev, |
Tony Lindgren | aa56188 | 2011-03-29 15:54:48 -0700 | [diff] [blame] | 126 | OMAP_TIMER_CTRL_AR | OMAP_TIMER_CTRL_ST, |
| 127 | 0xffffffff - period, 1); |
Kevin Hilman | 5a3a388 | 2007-11-12 23:24:02 -0800 | [diff] [blame] | 128 | break; |
| 129 | case CLOCK_EVT_MODE_ONESHOT: |
| 130 | break; |
| 131 | case CLOCK_EVT_MODE_UNUSED: |
| 132 | case CLOCK_EVT_MODE_SHUTDOWN: |
| 133 | case CLOCK_EVT_MODE_RESUME: |
| 134 | break; |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | static struct clock_event_device clockevent_gpt = { |
Vaibhav Hiremath | f36921b | 2012-05-09 10:07:05 -0700 | [diff] [blame] | 139 | .name = "gp_timer", |
Kevin Hilman | 5a3a388 | 2007-11-12 23:24:02 -0800 | [diff] [blame] | 140 | .features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT, |
| 141 | .shift = 32, |
Santosh Shilimkar | 11d6ec2 | 2012-03-17 15:00:16 +0530 | [diff] [blame] | 142 | .rating = 300, |
Kevin Hilman | 5a3a388 | 2007-11-12 23:24:02 -0800 | [diff] [blame] | 143 | .set_next_event = omap2_gp_timer_set_next_event, |
| 144 | .set_mode = omap2_gp_timer_set_mode, |
| 145 | }; |
| 146 | |
Tony Lindgren | aa56188 | 2011-03-29 15:54:48 -0700 | [diff] [blame] | 147 | static int __init omap_dm_timer_init_one(struct omap_dm_timer *timer, |
| 148 | int gptimer_id, |
| 149 | const char *fck_source) |
Kevin Hilman | 5a3a388 | 2007-11-12 23:24:02 -0800 | [diff] [blame] | 150 | { |
Tony Lindgren | aa56188 | 2011-03-29 15:54:48 -0700 | [diff] [blame] | 151 | char name[10]; /* 10 = sizeof("gptXX_Xck0") */ |
| 152 | struct omap_hwmod *oh; |
Paul Walmsley | 6c0c27f | 2012-04-19 04:01:50 -0600 | [diff] [blame] | 153 | struct resource irq_rsrc, mem_rsrc; |
Tony Lindgren | aa56188 | 2011-03-29 15:54:48 -0700 | [diff] [blame] | 154 | size_t size; |
| 155 | int res = 0; |
Paul Walmsley | 6c0c27f | 2012-04-19 04:01:50 -0600 | [diff] [blame] | 156 | int r; |
Kevin Hilman | 5a3a388 | 2007-11-12 23:24:02 -0800 | [diff] [blame] | 157 | |
Tony Lindgren | aa56188 | 2011-03-29 15:54:48 -0700 | [diff] [blame] | 158 | sprintf(name, "timer%d", gptimer_id); |
| 159 | omap_hwmod_setup_one(name); |
| 160 | oh = omap_hwmod_lookup(name); |
| 161 | if (!oh) |
| 162 | return -ENODEV; |
Paul Walmsley | f248076 | 2009-04-23 21:11:10 -0600 | [diff] [blame] | 163 | |
Paul Walmsley | 6c0c27f | 2012-04-19 04:01:50 -0600 | [diff] [blame] | 164 | r = omap_hwmod_get_resource_byname(oh, IORESOURCE_IRQ, NULL, &irq_rsrc); |
| 165 | if (r) |
| 166 | return -ENXIO; |
| 167 | timer->irq = irq_rsrc.start; |
| 168 | |
| 169 | r = omap_hwmod_get_resource_byname(oh, IORESOURCE_MEM, NULL, &mem_rsrc); |
| 170 | if (r) |
| 171 | return -ENXIO; |
| 172 | timer->phys_base = mem_rsrc.start; |
| 173 | size = mem_rsrc.end - mem_rsrc.start; |
Tony Lindgren | aa56188 | 2011-03-29 15:54:48 -0700 | [diff] [blame] | 174 | |
| 175 | /* Static mapping, never released */ |
| 176 | timer->io_base = ioremap(timer->phys_base, size); |
| 177 | if (!timer->io_base) |
| 178 | return -ENXIO; |
| 179 | |
| 180 | /* After the dmtimer is using hwmod these clocks won't be needed */ |
Tarun Kanti DebBarma | ae6df41 | 2012-07-05 18:10:59 +0530 | [diff] [blame] | 181 | timer->fclk = clk_get(NULL, omap_hwmod_get_main_clk(oh)); |
Tony Lindgren | aa56188 | 2011-03-29 15:54:48 -0700 | [diff] [blame] | 182 | if (IS_ERR(timer->fclk)) |
| 183 | return -ENODEV; |
| 184 | |
Tony Lindgren | aa56188 | 2011-03-29 15:54:48 -0700 | [diff] [blame] | 185 | omap_hwmod_enable(oh); |
| 186 | |
Jon Hunter | b7b4ff7 | 2012-06-05 12:34:51 -0500 | [diff] [blame] | 187 | if (omap_dm_timer_reserve_systimer(gptimer_id)) |
| 188 | return -ENODEV; |
Tony Lindgren | 11a0186 | 2011-03-29 15:54:49 -0700 | [diff] [blame] | 189 | |
Tony Lindgren | aa56188 | 2011-03-29 15:54:48 -0700 | [diff] [blame] | 190 | if (gptimer_id != 12) { |
| 191 | struct clk *src; |
| 192 | |
| 193 | src = clk_get(NULL, fck_source); |
| 194 | if (IS_ERR(src)) { |
| 195 | res = -EINVAL; |
| 196 | } else { |
| 197 | res = __omap_dm_timer_set_source(timer->fclk, src); |
| 198 | if (IS_ERR_VALUE(res)) |
| 199 | pr_warning("%s: timer%i cannot set source\n", |
| 200 | __func__, gptimer_id); |
| 201 | clk_put(src); |
| 202 | } |
| 203 | } |
Tony Lindgren | ee17f11 | 2011-09-16 15:44:20 -0700 | [diff] [blame] | 204 | __omap_dm_timer_init_regs(timer); |
| 205 | __omap_dm_timer_reset(timer, 1, 1); |
Tony Lindgren | aa56188 | 2011-03-29 15:54:48 -0700 | [diff] [blame] | 206 | timer->posted = 1; |
| 207 | |
| 208 | timer->rate = clk_get_rate(timer->fclk); |
| 209 | |
| 210 | timer->reserved = 1; |
Paul Walmsley | 38698be | 2011-02-23 00:14:08 -0700 | [diff] [blame] | 211 | |
Tony Lindgren | aa56188 | 2011-03-29 15:54:48 -0700 | [diff] [blame] | 212 | return res; |
| 213 | } |
Paul Walmsley | f248076 | 2009-04-23 21:11:10 -0600 | [diff] [blame] | 214 | |
Tony Lindgren | aa56188 | 2011-03-29 15:54:48 -0700 | [diff] [blame] | 215 | static void __init omap2_gp_clockevent_init(int gptimer_id, |
| 216 | const char *fck_source) |
| 217 | { |
| 218 | int res; |
Paul Walmsley | f248076 | 2009-04-23 21:11:10 -0600 | [diff] [blame] | 219 | |
Tony Lindgren | aa56188 | 2011-03-29 15:54:48 -0700 | [diff] [blame] | 220 | res = omap_dm_timer_init_one(&clkev, gptimer_id, fck_source); |
| 221 | BUG_ON(res); |
Paul Walmsley | f248076 | 2009-04-23 21:11:10 -0600 | [diff] [blame] | 222 | |
Paul Walmsley | a032d33 | 2012-08-03 09:21:10 -0600 | [diff] [blame] | 223 | omap2_gp_timer_irq.dev_id = &clkev; |
Tony Lindgren | aa56188 | 2011-03-29 15:54:48 -0700 | [diff] [blame] | 224 | setup_irq(clkev.irq, &omap2_gp_timer_irq); |
Kevin Hilman | 5a3a388 | 2007-11-12 23:24:02 -0800 | [diff] [blame] | 225 | |
Tony Lindgren | ee17f11 | 2011-09-16 15:44:20 -0700 | [diff] [blame] | 226 | __omap_dm_timer_int_enable(&clkev, OMAP_TIMER_INT_OVERFLOW); |
Tony Lindgren | aa56188 | 2011-03-29 15:54:48 -0700 | [diff] [blame] | 227 | |
| 228 | clockevent_gpt.mult = div_sc(clkev.rate, NSEC_PER_SEC, |
Kevin Hilman | 5a3a388 | 2007-11-12 23:24:02 -0800 | [diff] [blame] | 229 | clockevent_gpt.shift); |
| 230 | clockevent_gpt.max_delta_ns = |
| 231 | clockevent_delta2ns(0xffffffff, &clockevent_gpt); |
| 232 | clockevent_gpt.min_delta_ns = |
Aaro Koskinen | df88acb | 2009-01-29 08:57:17 -0800 | [diff] [blame] | 233 | clockevent_delta2ns(3, &clockevent_gpt); |
| 234 | /* Timer internal resynch latency. */ |
Kevin Hilman | 5a3a388 | 2007-11-12 23:24:02 -0800 | [diff] [blame] | 235 | |
Santosh Shilimkar | 11d6ec2 | 2012-03-17 15:00:16 +0530 | [diff] [blame] | 236 | clockevent_gpt.cpumask = cpu_possible_mask; |
| 237 | clockevent_gpt.irq = omap_dm_timer_get_irq(&clkev); |
Kevin Hilman | 5a3a388 | 2007-11-12 23:24:02 -0800 | [diff] [blame] | 238 | clockevents_register_device(&clockevent_gpt); |
Tony Lindgren | aa56188 | 2011-03-29 15:54:48 -0700 | [diff] [blame] | 239 | |
| 240 | pr_info("OMAP clockevent source: GPTIMER%d at %lu Hz\n", |
| 241 | gptimer_id, clkev.rate); |
Kevin Hilman | 5a3a388 | 2007-11-12 23:24:02 -0800 | [diff] [blame] | 242 | } |
| 243 | |
Paul Walmsley | f248076 | 2009-04-23 21:11:10 -0600 | [diff] [blame] | 244 | /* Clocksource code */ |
Tony Lindgren | 3d05a3e | 2011-03-29 15:54:49 -0700 | [diff] [blame] | 245 | static struct omap_dm_timer clksrc; |
Vaibhav Hiremath | 1fe97c8 | 2012-05-09 10:07:05 -0700 | [diff] [blame] | 246 | static bool use_gptimer_clksrc; |
Tony Lindgren | 3d05a3e | 2011-03-29 15:54:49 -0700 | [diff] [blame] | 247 | |
Kevin Hilman | 5a3a388 | 2007-11-12 23:24:02 -0800 | [diff] [blame] | 248 | /* |
| 249 | * clocksource |
| 250 | */ |
Magnus Damm | 8e19608 | 2009-04-21 12:24:00 -0700 | [diff] [blame] | 251 | static cycle_t clocksource_read_cycles(struct clocksource *cs) |
Kevin Hilman | 5a3a388 | 2007-11-12 23:24:02 -0800 | [diff] [blame] | 252 | { |
Tony Lindgren | ee17f11 | 2011-09-16 15:44:20 -0700 | [diff] [blame] | 253 | return (cycle_t)__omap_dm_timer_read_counter(&clksrc, 1); |
Kevin Hilman | 5a3a388 | 2007-11-12 23:24:02 -0800 | [diff] [blame] | 254 | } |
| 255 | |
| 256 | static struct clocksource clocksource_gpt = { |
Vaibhav Hiremath | f36921b | 2012-05-09 10:07:05 -0700 | [diff] [blame] | 257 | .name = "gp_timer", |
Kevin Hilman | 5a3a388 | 2007-11-12 23:24:02 -0800 | [diff] [blame] | 258 | .rating = 300, |
| 259 | .read = clocksource_read_cycles, |
| 260 | .mask = CLOCKSOURCE_MASK(32), |
Kevin Hilman | 5a3a388 | 2007-11-12 23:24:02 -0800 | [diff] [blame] | 261 | .flags = CLOCK_SOURCE_IS_CONTINUOUS, |
| 262 | }; |
| 263 | |
Marc Zyngier | 2f0778af | 2011-12-15 12:19:23 +0100 | [diff] [blame] | 264 | static u32 notrace dmtimer_read_sched_clock(void) |
Paul Walmsley | cbc9438 | 2011-02-22 19:59:49 -0700 | [diff] [blame] | 265 | { |
Tony Lindgren | 3d05a3e | 2011-03-29 15:54:49 -0700 | [diff] [blame] | 266 | if (clksrc.reserved) |
Vaibhav Hiremath | dbc3982 | 2012-01-23 12:18:14 +0530 | [diff] [blame] | 267 | return __omap_dm_timer_read_counter(&clksrc, 1); |
Kevin Hilman | 5a3a388 | 2007-11-12 23:24:02 -0800 | [diff] [blame] | 268 | |
Marc Zyngier | 2f0778af | 2011-12-15 12:19:23 +0100 | [diff] [blame] | 269 | return 0; |
Tony Lindgren | 3d05a3e | 2011-03-29 15:54:49 -0700 | [diff] [blame] | 270 | } |
Kevin Hilman | 5a3a388 | 2007-11-12 23:24:02 -0800 | [diff] [blame] | 271 | |
Igor Grinberg | 45caae7 | 2012-08-28 01:26:14 +0300 | [diff] [blame] | 272 | #ifdef CONFIG_OMAP_32K_TIMER |
Tony Lindgren | 3d05a3e | 2011-03-29 15:54:49 -0700 | [diff] [blame] | 273 | /* Setup free-running counter for clocksource */ |
Vaibhav Hiremath | 1fe97c8 | 2012-05-09 10:07:05 -0700 | [diff] [blame] | 274 | static int __init omap2_sync32k_clocksource_init(void) |
| 275 | { |
| 276 | int ret; |
| 277 | struct omap_hwmod *oh; |
| 278 | void __iomem *vbase; |
| 279 | const char *oh_name = "counter_32k"; |
| 280 | |
| 281 | /* |
| 282 | * First check hwmod data is available for sync32k counter |
| 283 | */ |
| 284 | oh = omap_hwmod_lookup(oh_name); |
| 285 | if (!oh || oh->slaves_cnt == 0) |
| 286 | return -ENODEV; |
| 287 | |
| 288 | omap_hwmod_setup_one(oh_name); |
| 289 | |
| 290 | vbase = omap_hwmod_get_mpu_rt_va(oh); |
| 291 | if (!vbase) { |
| 292 | pr_warn("%s: failed to get counter_32k resource\n", __func__); |
| 293 | return -ENXIO; |
| 294 | } |
| 295 | |
| 296 | ret = omap_hwmod_enable(oh); |
| 297 | if (ret) { |
| 298 | pr_warn("%s: failed to enable counter_32k module (%d)\n", |
| 299 | __func__, ret); |
| 300 | return ret; |
| 301 | } |
| 302 | |
| 303 | ret = omap_init_clocksource_32k(vbase); |
| 304 | if (ret) { |
| 305 | pr_warn("%s: failed to initialize counter_32k as a clocksource (%d)\n", |
| 306 | __func__, ret); |
| 307 | omap_hwmod_idle(oh); |
| 308 | } |
| 309 | |
| 310 | return ret; |
| 311 | } |
Igor Grinberg | 45caae7 | 2012-08-28 01:26:14 +0300 | [diff] [blame] | 312 | #else |
| 313 | static inline int omap2_sync32k_clocksource_init(void) |
| 314 | { |
| 315 | return -ENODEV; |
| 316 | } |
| 317 | #endif |
Vaibhav Hiremath | 1fe97c8 | 2012-05-09 10:07:05 -0700 | [diff] [blame] | 318 | |
| 319 | static void __init omap2_gptimer_clocksource_init(int gptimer_id, |
Tony Lindgren | 3d05a3e | 2011-03-29 15:54:49 -0700 | [diff] [blame] | 320 | const char *fck_source) |
| 321 | { |
| 322 | int res; |
Kevin Hilman | 5a3a388 | 2007-11-12 23:24:02 -0800 | [diff] [blame] | 323 | |
Tony Lindgren | 3d05a3e | 2011-03-29 15:54:49 -0700 | [diff] [blame] | 324 | res = omap_dm_timer_init_one(&clksrc, gptimer_id, fck_source); |
| 325 | BUG_ON(res); |
Paul Walmsley | cbc9438 | 2011-02-22 19:59:49 -0700 | [diff] [blame] | 326 | |
Tony Lindgren | ee17f11 | 2011-09-16 15:44:20 -0700 | [diff] [blame] | 327 | __omap_dm_timer_load_start(&clksrc, |
Hemant Pedanekar | e9d0b97 | 2011-08-10 13:19:35 +0000 | [diff] [blame] | 328 | OMAP_TIMER_CTRL_ST | OMAP_TIMER_CTRL_AR, 0, 1); |
Marc Zyngier | 2f0778af | 2011-12-15 12:19:23 +0100 | [diff] [blame] | 329 | setup_sched_clock(dmtimer_read_sched_clock, 32, clksrc.rate); |
Tony Lindgren | 3d05a3e | 2011-03-29 15:54:49 -0700 | [diff] [blame] | 330 | |
| 331 | if (clocksource_register_hz(&clocksource_gpt, clksrc.rate)) |
| 332 | pr_err("Could not register clocksource %s\n", |
| 333 | clocksource_gpt.name); |
Vaibhav Hiremath | 1fe97c8 | 2012-05-09 10:07:05 -0700 | [diff] [blame] | 334 | else |
| 335 | pr_info("OMAP clocksource: GPTIMER%d at %lu Hz\n", |
| 336 | gptimer_id, clksrc.rate); |
Kevin Hilman | 5a3a388 | 2007-11-12 23:24:02 -0800 | [diff] [blame] | 337 | } |
Vaibhav Hiremath | 1fe97c8 | 2012-05-09 10:07:05 -0700 | [diff] [blame] | 338 | |
| 339 | static void __init omap2_clocksource_init(int gptimer_id, |
| 340 | const char *fck_source) |
| 341 | { |
| 342 | /* |
| 343 | * First give preference to kernel parameter configuration |
| 344 | * by user (clocksource="gp_timer"). |
| 345 | * |
| 346 | * In case of missing kernel parameter for clocksource, |
| 347 | * first check for availability for 32k-sync timer, in case |
| 348 | * of failure in finding 32k_counter module or registering |
| 349 | * it as clocksource, execution will fallback to gp-timer. |
| 350 | */ |
| 351 | if (use_gptimer_clksrc == true) |
| 352 | omap2_gptimer_clocksource_init(gptimer_id, fck_source); |
| 353 | else if (omap2_sync32k_clocksource_init()) |
| 354 | /* Fall back to gp-timer code */ |
| 355 | omap2_gptimer_clocksource_init(gptimer_id, fck_source); |
| 356 | } |
Kevin Hilman | 5a3a388 | 2007-11-12 23:24:02 -0800 | [diff] [blame] | 357 | |
Santosh Shilimkar | fa6d79d | 2012-08-13 14:24:24 +0530 | [diff] [blame] | 358 | #ifdef CONFIG_SOC_HAS_REALTIME_COUNTER |
| 359 | /* |
| 360 | * The realtime counter also called master counter, is a free-running |
| 361 | * counter, which is related to real time. It produces the count used |
| 362 | * by the CPU local timer peripherals in the MPU cluster. The timer counts |
| 363 | * at a rate of 6.144 MHz. Because the device operates on different clocks |
| 364 | * in different power modes, the master counter shifts operation between |
| 365 | * clocks, adjusting the increment per clock in hardware accordingly to |
| 366 | * maintain a constant count rate. |
| 367 | */ |
| 368 | static void __init realtime_counter_init(void) |
| 369 | { |
| 370 | void __iomem *base; |
| 371 | static struct clk *sys_clk; |
| 372 | unsigned long rate; |
| 373 | unsigned int reg, num, den; |
| 374 | |
| 375 | base = ioremap(REALTIME_COUNTER_BASE, SZ_32); |
| 376 | if (!base) { |
| 377 | pr_err("%s: ioremap failed\n", __func__); |
| 378 | return; |
| 379 | } |
| 380 | sys_clk = clk_get(NULL, "sys_clkin_ck"); |
Wei Yongjun | 533b298 | 2012-10-08 15:01:41 -0700 | [diff] [blame] | 381 | if (IS_ERR(sys_clk)) { |
Santosh Shilimkar | fa6d79d | 2012-08-13 14:24:24 +0530 | [diff] [blame] | 382 | pr_err("%s: failed to get system clock handle\n", __func__); |
| 383 | iounmap(base); |
| 384 | return; |
| 385 | } |
| 386 | |
| 387 | rate = clk_get_rate(sys_clk); |
| 388 | /* Numerator/denumerator values refer TRM Realtime Counter section */ |
| 389 | switch (rate) { |
| 390 | case 1200000: |
| 391 | num = 64; |
| 392 | den = 125; |
| 393 | break; |
| 394 | case 1300000: |
| 395 | num = 768; |
| 396 | den = 1625; |
| 397 | break; |
| 398 | case 19200000: |
| 399 | num = 8; |
| 400 | den = 25; |
| 401 | break; |
| 402 | case 2600000: |
| 403 | num = 384; |
| 404 | den = 1625; |
| 405 | break; |
| 406 | case 2700000: |
| 407 | num = 256; |
| 408 | den = 1125; |
| 409 | break; |
| 410 | case 38400000: |
| 411 | default: |
| 412 | /* Program it for 38.4 MHz */ |
| 413 | num = 4; |
| 414 | den = 25; |
| 415 | break; |
| 416 | } |
| 417 | |
| 418 | /* Program numerator and denumerator registers */ |
| 419 | reg = __raw_readl(base + INCREMENTER_NUMERATOR_OFFSET) & |
| 420 | NUMERATOR_DENUMERATOR_MASK; |
| 421 | reg |= num; |
| 422 | __raw_writel(reg, base + INCREMENTER_NUMERATOR_OFFSET); |
| 423 | |
| 424 | reg = __raw_readl(base + INCREMENTER_NUMERATOR_OFFSET) & |
| 425 | NUMERATOR_DENUMERATOR_MASK; |
| 426 | reg |= den; |
| 427 | __raw_writel(reg, base + INCREMENTER_DENUMERATOR_RELOAD_OFFSET); |
| 428 | |
| 429 | iounmap(base); |
| 430 | } |
| 431 | #else |
| 432 | static inline void __init realtime_counter_init(void) |
| 433 | {} |
| 434 | #endif |
| 435 | |
Tony Lindgren | 3d05a3e | 2011-03-29 15:54:49 -0700 | [diff] [blame] | 436 | #define OMAP_SYS_TIMER_INIT(name, clkev_nr, clkev_src, \ |
| 437 | clksrc_nr, clksrc_src) \ |
Tony Lindgren | e74984e | 2011-03-29 15:54:48 -0700 | [diff] [blame] | 438 | static void __init omap##name##_timer_init(void) \ |
| 439 | { \ |
Tony Lindgren | aa56188 | 2011-03-29 15:54:48 -0700 | [diff] [blame] | 440 | omap2_gp_clockevent_init((clkev_nr), clkev_src); \ |
Vaibhav Hiremath | 1fe97c8 | 2012-05-09 10:07:05 -0700 | [diff] [blame] | 441 | omap2_clocksource_init((clksrc_nr), clksrc_src); \ |
Tony Lindgren | e74984e | 2011-03-29 15:54:48 -0700 | [diff] [blame] | 442 | } |
| 443 | |
| 444 | #define OMAP_SYS_TIMER(name) \ |
| 445 | struct sys_timer omap##name##_timer = { \ |
| 446 | .init = omap##name##_timer_init, \ |
| 447 | }; |
| 448 | |
| 449 | #ifdef CONFIG_ARCH_OMAP2 |
Tony Lindgren | 3d05a3e | 2011-03-29 15:54:49 -0700 | [diff] [blame] | 450 | OMAP_SYS_TIMER_INIT(2, 1, OMAP2_CLKEV_SOURCE, 2, OMAP2_MPU_SOURCE) |
Tony Lindgren | e74984e | 2011-03-29 15:54:48 -0700 | [diff] [blame] | 451 | OMAP_SYS_TIMER(2) |
| 452 | #endif |
| 453 | |
| 454 | #ifdef CONFIG_ARCH_OMAP3 |
Tony Lindgren | 3d05a3e | 2011-03-29 15:54:49 -0700 | [diff] [blame] | 455 | OMAP_SYS_TIMER_INIT(3, 1, OMAP3_CLKEV_SOURCE, 2, OMAP3_MPU_SOURCE) |
Tony Lindgren | e74984e | 2011-03-29 15:54:48 -0700 | [diff] [blame] | 456 | OMAP_SYS_TIMER(3) |
Tony Lindgren | 3d05a3e | 2011-03-29 15:54:49 -0700 | [diff] [blame] | 457 | OMAP_SYS_TIMER_INIT(3_secure, OMAP3_SECURE_TIMER, OMAP3_CLKEV_SOURCE, |
| 458 | 2, OMAP3_MPU_SOURCE) |
Tony Lindgren | e74984e | 2011-03-29 15:54:48 -0700 | [diff] [blame] | 459 | OMAP_SYS_TIMER(3_secure) |
| 460 | #endif |
| 461 | |
Afzal Mohammed | 08f3098 | 2012-05-11 00:38:49 +0530 | [diff] [blame] | 462 | #ifdef CONFIG_SOC_AM33XX |
| 463 | OMAP_SYS_TIMER_INIT(3_am33xx, 1, OMAP4_MPU_SOURCE, 2, OMAP4_MPU_SOURCE) |
| 464 | OMAP_SYS_TIMER(3_am33xx) |
| 465 | #endif |
| 466 | |
Tony Lindgren | e74984e | 2011-03-29 15:54:48 -0700 | [diff] [blame] | 467 | #ifdef CONFIG_ARCH_OMAP4 |
Marc Zyngier | a45c983 | 2012-01-10 19:44:19 +0000 | [diff] [blame] | 468 | #ifdef CONFIG_LOCAL_TIMERS |
| 469 | static DEFINE_TWD_LOCAL_TIMER(twd_local_timer, |
Tony Lindgren | 7d7e1eb | 2012-08-27 17:43:01 -0700 | [diff] [blame] | 470 | OMAP44XX_LOCAL_TWD_BASE, 29 + OMAP_INTC_START); |
Marc Zyngier | a45c983 | 2012-01-10 19:44:19 +0000 | [diff] [blame] | 471 | #endif |
| 472 | |
Tony Lindgren | e74984e | 2011-03-29 15:54:48 -0700 | [diff] [blame] | 473 | static void __init omap4_timer_init(void) |
Kevin Hilman | 5a3a388 | 2007-11-12 23:24:02 -0800 | [diff] [blame] | 474 | { |
Tony Lindgren | aa56188 | 2011-03-29 15:54:48 -0700 | [diff] [blame] | 475 | omap2_gp_clockevent_init(1, OMAP4_CLKEV_SOURCE); |
Vaibhav Hiremath | 1fe97c8 | 2012-05-09 10:07:05 -0700 | [diff] [blame] | 476 | omap2_clocksource_init(2, OMAP4_MPU_SOURCE); |
Marc Zyngier | a45c983 | 2012-01-10 19:44:19 +0000 | [diff] [blame] | 477 | #ifdef CONFIG_LOCAL_TIMERS |
| 478 | /* Local timers are not supprted on OMAP4430 ES1.0 */ |
| 479 | if (omap_rev() != OMAP4430_REV_ES1_0) { |
| 480 | int err; |
| 481 | |
Santosh Shilimkar | eed0de2 | 2012-07-04 18:32:32 +0530 | [diff] [blame] | 482 | if (of_have_populated_dt()) { |
| 483 | twd_local_timer_of_register(); |
| 484 | return; |
| 485 | } |
| 486 | |
Marc Zyngier | a45c983 | 2012-01-10 19:44:19 +0000 | [diff] [blame] | 487 | err = twd_local_timer_register(&twd_local_timer); |
| 488 | if (err) |
| 489 | pr_err("twd_local_timer_register failed %d\n", err); |
| 490 | } |
| 491 | #endif |
Tony Lindgren | 1dbae81 | 2005-11-10 14:26:51 +0000 | [diff] [blame] | 492 | } |
Tony Lindgren | e74984e | 2011-03-29 15:54:48 -0700 | [diff] [blame] | 493 | OMAP_SYS_TIMER(4) |
| 494 | #endif |
Tarun Kanti DebBarma | c345c8b | 2011-09-20 17:00:18 +0530 | [diff] [blame] | 495 | |
R Sricharan | 37b3280 | 2012-05-02 13:07:12 +0530 | [diff] [blame] | 496 | #ifdef CONFIG_SOC_OMAP5 |
Santosh Shilimkar | fa6d79d | 2012-08-13 14:24:24 +0530 | [diff] [blame] | 497 | static void __init omap5_timer_init(void) |
| 498 | { |
Santosh Shilimkar | 3c7c5da | 2012-08-13 14:39:03 +0530 | [diff] [blame] | 499 | int err; |
| 500 | |
Santosh Shilimkar | fa6d79d | 2012-08-13 14:24:24 +0530 | [diff] [blame] | 501 | omap2_gp_clockevent_init(1, OMAP4_CLKEV_SOURCE); |
| 502 | omap2_clocksource_init(2, OMAP4_MPU_SOURCE); |
| 503 | realtime_counter_init(); |
Santosh Shilimkar | 3c7c5da | 2012-08-13 14:39:03 +0530 | [diff] [blame] | 504 | |
| 505 | err = arch_timer_of_register(); |
| 506 | if (err) |
| 507 | pr_err("%s: arch_timer_register failed %d\n", __func__, err); |
Santosh Shilimkar | fa6d79d | 2012-08-13 14:24:24 +0530 | [diff] [blame] | 508 | } |
R Sricharan | 37b3280 | 2012-05-02 13:07:12 +0530 | [diff] [blame] | 509 | OMAP_SYS_TIMER(5) |
| 510 | #endif |
| 511 | |
Tarun Kanti DebBarma | c345c8b | 2011-09-20 17:00:18 +0530 | [diff] [blame] | 512 | /** |
Tarun Kanti DebBarma | c345c8b | 2011-09-20 17:00:18 +0530 | [diff] [blame] | 513 | * omap_timer_init - build and register timer device with an |
| 514 | * associated timer hwmod |
| 515 | * @oh: timer hwmod pointer to be used to build timer device |
| 516 | * @user: parameter that can be passed from calling hwmod API |
| 517 | * |
| 518 | * Called by omap_hwmod_for_each_by_class to register each of the timer |
| 519 | * devices present in the system. The number of timer devices is known |
| 520 | * by parsing through the hwmod database for a given class name. At the |
| 521 | * end of function call memory is allocated for timer device and it is |
| 522 | * registered to the framework ready to be proved by the driver. |
| 523 | */ |
| 524 | static int __init omap_timer_init(struct omap_hwmod *oh, void *unused) |
| 525 | { |
| 526 | int id; |
| 527 | int ret = 0; |
| 528 | char *name = "omap_timer"; |
| 529 | struct dmtimer_platform_data *pdata; |
Tony Lindgren | c541c15 | 2011-10-04 09:47:06 -0700 | [diff] [blame] | 530 | struct platform_device *pdev; |
Tarun Kanti DebBarma | c345c8b | 2011-09-20 17:00:18 +0530 | [diff] [blame] | 531 | struct omap_timer_capability_dev_attr *timer_dev_attr; |
| 532 | |
| 533 | pr_debug("%s: %s\n", __func__, oh->name); |
| 534 | |
| 535 | /* on secure device, do not register secure timer */ |
| 536 | timer_dev_attr = oh->dev_attr; |
| 537 | if (omap_type() != OMAP2_DEVICE_TYPE_GP && timer_dev_attr) |
| 538 | if (timer_dev_attr->timer_capability == OMAP_TIMER_SECURE) |
| 539 | return ret; |
| 540 | |
| 541 | pdata = kzalloc(sizeof(*pdata), GFP_KERNEL); |
| 542 | if (!pdata) { |
| 543 | pr_err("%s: No memory for [%s]\n", __func__, oh->name); |
| 544 | return -ENOMEM; |
| 545 | } |
| 546 | |
| 547 | /* |
| 548 | * Extract the IDs from name field in hwmod database |
| 549 | * and use the same for constructing ids' for the |
| 550 | * timer devices. In a way, we are avoiding usage of |
| 551 | * static variable witin the function to do the same. |
| 552 | * CAUTION: We have to be careful and make sure the |
| 553 | * name in hwmod database does not change in which case |
| 554 | * we might either make corresponding change here or |
| 555 | * switch back static variable mechanism. |
| 556 | */ |
| 557 | sscanf(oh->name, "timer%2d", &id); |
| 558 | |
Jon Hunter | d1c1691 | 2012-06-05 12:34:52 -0500 | [diff] [blame] | 559 | if (timer_dev_attr) |
| 560 | pdata->timer_capability = timer_dev_attr->timer_capability; |
Tarun Kanti DebBarma | c345c8b | 2011-09-20 17:00:18 +0530 | [diff] [blame] | 561 | |
Tony Lindgren | c541c15 | 2011-10-04 09:47:06 -0700 | [diff] [blame] | 562 | pdev = omap_device_build(name, id, oh, pdata, sizeof(*pdata), |
Benoit Cousson | c16ae1e | 2011-10-04 23:20:41 +0200 | [diff] [blame] | 563 | NULL, 0, 0); |
Tarun Kanti DebBarma | c345c8b | 2011-09-20 17:00:18 +0530 | [diff] [blame] | 564 | |
Tony Lindgren | c541c15 | 2011-10-04 09:47:06 -0700 | [diff] [blame] | 565 | if (IS_ERR(pdev)) { |
Tarun Kanti DebBarma | c345c8b | 2011-09-20 17:00:18 +0530 | [diff] [blame] | 566 | pr_err("%s: Can't build omap_device for %s: %s.\n", |
| 567 | __func__, name, oh->name); |
| 568 | ret = -EINVAL; |
| 569 | } |
| 570 | |
| 571 | kfree(pdata); |
| 572 | |
| 573 | return ret; |
| 574 | } |
Tarun Kanti DebBarma | 3392cdd | 2011-09-20 17:00:20 +0530 | [diff] [blame] | 575 | |
| 576 | /** |
| 577 | * omap2_dm_timer_init - top level regular device initialization |
| 578 | * |
| 579 | * Uses dedicated hwmod api to parse through hwmod database for |
| 580 | * given class name and then build and register the timer device. |
| 581 | */ |
| 582 | static int __init omap2_dm_timer_init(void) |
| 583 | { |
| 584 | int ret; |
| 585 | |
| 586 | ret = omap_hwmod_for_each_by_class("timer", omap_timer_init, NULL); |
| 587 | if (unlikely(ret)) { |
| 588 | pr_err("%s: device registration failed.\n", __func__); |
| 589 | return -EINVAL; |
| 590 | } |
| 591 | |
| 592 | return 0; |
| 593 | } |
| 594 | arch_initcall(omap2_dm_timer_init); |
Vaibhav Hiremath | 1fe97c8 | 2012-05-09 10:07:05 -0700 | [diff] [blame] | 595 | |
| 596 | /** |
| 597 | * omap2_override_clocksource - clocksource override with user configuration |
| 598 | * |
| 599 | * Allows user to override default clocksource, using kernel parameter |
| 600 | * clocksource="gp_timer" (For all OMAP2PLUS architectures) |
| 601 | * |
| 602 | * Note that, here we are using same standard kernel parameter "clocksource=", |
| 603 | * and not introducing any OMAP specific interface. |
| 604 | */ |
| 605 | static int __init omap2_override_clocksource(char *str) |
| 606 | { |
| 607 | if (!str) |
| 608 | return 0; |
| 609 | /* |
| 610 | * For OMAP architecture, we only have two options |
| 611 | * - sync_32k (default) |
| 612 | * - gp_timer (sys_clk based) |
| 613 | */ |
| 614 | if (!strcmp(str, "gp_timer")) |
| 615 | use_gptimer_clksrc = true; |
| 616 | |
| 617 | return 0; |
| 618 | } |
| 619 | early_param("clocksource", omap2_override_clocksource); |