| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * linux/arch/ia64/sn/kernel/sn2/timer.c | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Copyright (C) 2003 Silicon Graphics, Inc. | 
					
						
							|  |  |  |  * Copyright (C) 2003 Hewlett-Packard Co | 
					
						
							|  |  |  |  *	David Mosberger <davidm@hpl.hp.com>: updated for new timer-interpolation infrastructure | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <linux/init.h>
 | 
					
						
							|  |  |  | #include <linux/kernel.h>
 | 
					
						
							|  |  |  | #include <linux/sched.h>
 | 
					
						
							|  |  |  | #include <linux/time.h>
 | 
					
						
							|  |  |  | #include <linux/interrupt.h>
 | 
					
						
							| 
									
										
										
										
											2007-07-20 11:22:30 -07:00
										 |  |  | #include <linux/clocksource.h>
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include <asm/hw_irq.h>
 | 
					
						
							| 
									
										
										
										
											2006-02-14 10:40:17 -08:00
										 |  |  | #include <asm/timex.h>
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include <asm/sn/leds.h>
 | 
					
						
							|  |  |  | #include <asm/sn/shub_mmr.h>
 | 
					
						
							|  |  |  | #include <asm/sn/clksupport.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | extern unsigned long sn_rtc_cycles_per_second; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-21 12:24:00 -07:00
										 |  |  | static cycle_t read_sn2(struct clocksource *cs) | 
					
						
							| 
									
										
										
										
											2007-07-20 11:22:30 -07:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2007-08-01 12:37:17 -07:00
										 |  |  | 	return (cycle_t)readq(RTC_COUNTER_ADDR); | 
					
						
							| 
									
										
										
										
											2007-07-20 11:22:30 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static struct clocksource clocksource_sn2 = { | 
					
						
							|  |  |  |         .name           = "sn2_rtc", | 
					
						
							| 
									
										
										
										
											2007-08-01 12:37:17 -07:00
										 |  |  |         .rating         = 450, | 
					
						
							| 
									
										
										
										
											2007-07-20 11:22:30 -07:00
										 |  |  |         .read           = read_sn2, | 
					
						
							|  |  |  |         .mask           = (1LL << 55) - 1, | 
					
						
							|  |  |  |         .flags          = CLOCK_SOURCE_IS_CONTINUOUS, | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-02-14 10:40:17 -08:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * sn udelay uses the RTC instead of the ITC because the ITC is not | 
					
						
							|  |  |  |  * synchronized across all CPUs, and the thread may migrate to another CPU | 
					
						
							|  |  |  |  * if preemption is enabled. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | static void | 
					
						
							|  |  |  | ia64_sn_udelay (unsigned long usecs) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	unsigned long start = rtc_time(); | 
					
						
							|  |  |  | 	unsigned long end = start + | 
					
						
							|  |  |  | 			usecs * sn_rtc_cycles_per_second / 1000000; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	while (time_before((unsigned long)rtc_time(), end)) | 
					
						
							|  |  |  | 		cpu_relax(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | void __init sn_timer_init(void) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2011-07-13 09:24:15 -04:00
										 |  |  | 	clocksource_sn2.archdata.fsys_mmio = RTC_COUNTER_ADDR; | 
					
						
							| 
									
										
										
										
											2010-04-26 20:20:47 -07:00
										 |  |  | 	clocksource_register_hz(&clocksource_sn2, sn_rtc_cycles_per_second); | 
					
						
							| 
									
										
										
										
											2006-02-14 10:40:17 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	ia64_udelay = &ia64_sn_udelay; | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | } |