Path: blob/master/arch/mn10300/unit-asb2364/include/unit/timex.h
15159 views
/* timex.h: MN2WS0038 architecture timer specifications1*2* Copyright (C) 2002, 2010 Red Hat, Inc. All Rights Reserved.3* Written by David Howells ([email protected])4*5* This program is free software; you can redistribute it and/or6* modify it under the terms of the GNU General Public License7* as published by the Free Software Foundation; either version8* 2 of the License, or (at your option) any later version.9*/10#ifndef _ASM_UNIT_TIMEX_H11#define _ASM_UNIT_TIMEX_H1213#ifndef __ASSEMBLY__14#include <linux/irq.h>15#endif /* __ASSEMBLY__ */1617#include <asm/timer-regs.h>18#include <unit/clock.h>19#include <asm/param.h>2021/*22* jiffies counter specifications23*/2425#define TMJCBR_MAX 0xffffff /* 24bit */26#define TMJCIRQ TMTIRQ2728#ifndef __ASSEMBLY__2930#define MN10300_SRC_IOBCLK MN10300_IOBCLK3132#ifndef HZ33# error HZ undeclared.34#endif /* !HZ */3536#define MN10300_JCCLK (MN10300_SRC_IOBCLK)37#define MN10300_TSCCLK (MN10300_SRC_IOBCLK)3839#define MN10300_JC_PER_HZ ((MN10300_JCCLK + HZ / 2) / HZ)40#define MN10300_TSC_PER_HZ ((MN10300_TSCCLK + HZ / 2) / HZ)4142/* Check bit width of MTM interval value that sets base register */43#if (MN10300_JC_PER_HZ - 1) > TMJCBR_MAX44# error MTM tick timer interval value is overflow.45#endif4647static inline void stop_jiffies_counter(void)48{49u16 tmp;50TMTMD = 0;51tmp = TMTMD;52}5354static inline void reload_jiffies_counter(u32 cnt)55{56u32 tmp;5758TMTBR = cnt;59tmp = TMTBR;6061TMTMD = TMTMD_TMTLDE;62TMTMD = TMTMD_TMTCNE;63tmp = TMTMD;64}6566#if defined(CONFIG_SMP) && defined(CONFIG_GENERIC_CLOCKEVENTS) && \67!defined(CONFIG_GENERIC_CLOCKEVENTS_BROADCAST)68/*69* If we aren't using broadcasting, each core needs its own event timer.70* Since CPU0 uses the tick timer which is 24-bits, we use timer 4 & 571* cascaded to 32-bits for CPU1 (but only really use 24-bits to match72* CPU0).73*/7475#define TMJC1IRQ TM5IRQ7677static inline void stop_jiffies_counter1(void)78{79u8 tmp;80TM4MD = 0;81TM5MD = 0;82tmp = TM4MD;83tmp = TM5MD;84}8586static inline void reload_jiffies_counter1(u32 cnt)87{88u32 tmp;8990TM45BR = cnt;91tmp = TM45BR;9293TM4MD = TM4MD_INIT_COUNTER;94tmp = TM4MD;9596TM5MD = TM5MD_SRC_TM4CASCADE | TM5MD_INIT_COUNTER;97TM5MD = TM5MD_SRC_TM4CASCADE | TM5MD_COUNT_ENABLE;98tmp = TM5MD;99100TM4MD = TM4MD_COUNT_ENABLE;101tmp = TM4MD;102}103#endif /* CONFIG_SMP&GENERIC_CLOCKEVENTS&!GENERIC_CLOCKEVENTS_BROADCAST */104105#endif /* !__ASSEMBLY__ */106107108/*109* timestamp counter specifications110*/111#define TMTSCBR_MAX 0xffffffff112113#ifndef __ASSEMBLY__114115/* Use 32-bit timestamp counter */116#define TMTSCMD TMSMD117#define TMTSCBR TMSBR118#define TMTSCBC TMSBC119#define TMTSCICR TMSICR120121static inline void startup_timestamp_counter(void)122{123u32 sync;124125/* set up TMS(Timestamp) 32bit timer register to count real time126* - count down from 4Gig-1 to 0 and wrap at IOBCLK rate127*/128129TMTSCBR = TMTSCBR_MAX;130sync = TMTSCBR;131132TMTSCICR = 0;133sync = TMTSCICR;134135TMTSCMD = TMTMD_TMTLDE;136TMTSCMD = TMTMD_TMTCNE;137sync = TMTSCMD;138}139140static inline void shutdown_timestamp_counter(void)141{142TMTSCMD = 0;143}144145/*146* we use a cascaded pair of 16-bit down-counting timers to count I/O147* clock cycles for the purposes of time keeping148*/149typedef unsigned long cycles_t;150151static inline cycles_t read_timestamp_counter(void)152{153return (cycles_t)~TMTSCBC;154}155156#endif /* !__ASSEMBLY__ */157158#endif /* _ASM_UNIT_TIMEX_H */159160161