base/include/asm-arm/arch-at91/rtai_timer.h

Go to the documentation of this file.
00001 /* 020222 asm-arm/arch-at91/timer.h - ARM/AT91 specific timer
00002 Don't include directly - it's included through asm-arm/rtai.h
00003 
00004 Copyright (c) 2005 Luca Pizzi, (lucapizzi@hotmail.com)
00005 Copyright (c) 2005 Stefano Gafforelli, (stefano.gafforelli@tiscali.it)
00006 COPYRIGHT (C) 2002 Guennadi Liakhovetski, DSA GmbH (gl@dsa-ac.de)
00007 COPYRIGHT (C) 2002 Wolfgang Müller (wolfgang.mueller@dsa-ac.de)
00008 Copyright (c) 2001 Alex Züpke, SYSGO RTS GmbH (azu@sysgo.de)
00009 Copyright (C) 2007 Adeneo
00010 
00011 This program is free software; you can redistribute it and/or modify
00012 it under the terms of version 2 of the GNU General Public License as
00013 published by the Free Software Foundation.
00014 
00015 This program is distributed in the hope that it will be useful,
00016 but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 GNU General Public License for more details.
00019 
00020 You should have received a copy of the GNU General Public License
00021 along with this program; if not, write to the Free Software
00022 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023 */
00024 /*
00025 --------------------------------------------------------------------------
00026 Acknowledgements
00027 - Paolo Mantegazza  (mantegazza@aero.polimi.it)
00028     creator of RTAI 
00029 */
00030 
00031 #ifndef _ASM_ARCH_RTAI_TIMER_H_
00032 #define _ASM_ARCH_RTAI_TIMER_H_
00033 
00034 #include <linux/time.h>
00035 #include <linux/timer.h>
00036 #include <asm/mach/irq.h>
00037 #include <linux/timex.h>
00038 
00039 #include <asm/arch/rtai_arch.h>
00040 #include <asm/arch/at91_tc.h>
00041 
00042 /* specific at91 tc registers read/write functions */
00043 
00044 static inline unsigned int at91_tc_read(unsigned int reg_offset)
00045 {
00046     unsigned long addr =
00047         (AT91_VA_BASE_TCB0 + 0x40 * CONFIG_IPIPE_AT91_TC);
00048 
00049     return readl((void __iomem *)(addr + reg_offset));
00050 }
00051 
00052 static inline void at91_tc_write(unsigned int reg_offset, unsigned long value)
00053 {
00054     unsigned long addr =
00055         (AT91_VA_BASE_TCB0 + 0x40 * CONFIG_IPIPE_AT91_TC);
00056 
00057     writel(value, (void __iomem *)(addr + reg_offset));
00058 }
00059 
00060 extern notrace unsigned long long __ipipe_get_tsc(void);
00061 extern notrace void __ipipe_set_tsc(unsigned long long value);
00062 
00063 static inline void rtai_at91_update_tsc(void)
00064 {
00065     __ipipe_set_tsc(__ipipe_get_tsc()+rt_times.periodic_tick);
00066 };
00067 
00068 extern unsigned int rt_periodic;
00069 
00070 static inline RTIME rtai_rdtsc(void)
00071 {
00072     if(!rt_periodic)
00073         /*
00074          * one-shot mode : use ipipe native get tsc
00075          */
00076         return __ipipe_mach_get_tsc();
00077     else
00078         /*
00079          * periodic mode : use specific get tsc
00080          * tsc has been updated since last shot by rtai_at91_update_tsc
00081          */
00082         return __ipipe_get_tsc()+at91_tc_read(AT91_TC_CV);
00083 }
00084 
00085 static inline void rt_set_timer_delay(unsigned long delay)
00086 {
00087     if (delay) {
00088         /*
00089          * one-shot mode : reprogramm timer
00090          */
00091         __ipipe_mach_set_dec(delay);
00092     } else {
00093         /*
00094          * periodic mode: at91's TC reload itself 
00095          * so nothing to do
00096          */
00097     }
00098 }
00099 #endif /* !_ASM_ARCH_RTAI_TIMER_H_ */

Generated on Tue Feb 2 17:46:04 2010 for RTAI API by  doxygen 1.4.7