diff options
author | Atsushi Nemoto <anemo@mba.ocn.ne.jp> | 2006-10-23 11:21:27 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2006-10-31 15:13:23 -0500 |
commit | 16b7b2ac0148e839da86af8747b6fa4aad43a9b7 (patch) | |
tree | 93912ae2e9c64f71a8cca028677fd918b9edf0fa /arch/mips/sibyte | |
parent | 70e46f48cb5933119712ee27945309a4bfc98282 (diff) |
[MIPS] Fixup migration to GENERIC_TIME
Since we already moved to GENERIC_TIME, we should implement alternatives
of old do_gettimeoffset routines to get sub-jiffies resolution from
gettimeofday(). This patch includes:
* MIPS clocksource support (based on works by Manish Lachwani).
* remove unused gettimeoffset routines and related codes.
* remove unised 64bit do_div64_32().
* simplify mips_hpt_init. (no argument needed, __init tag)
* simplify c0_hpt_timer_init. (no need to write to c0_count)
* remove some hpt_init routines.
* mips_hpt_mask variable to specify bitmask of hpt value.
* convert jmr3927_do_gettimeoffset to jmr3927_hpt_read.
* convert ip27_do_gettimeoffset to ip27_hpt_read.
* convert bcm1480_do_gettimeoffset to bcm1480_hpt_read.
* simplify sb1250 hpt functions. (no need to subtract and shift)
Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/sibyte')
-rw-r--r-- | arch/mips/sibyte/bcm1480/time.c | 33 | ||||
-rw-r--r-- | arch/mips/sibyte/sb1250/time.c | 28 |
2 files changed, 19 insertions, 42 deletions
diff --git a/arch/mips/sibyte/bcm1480/time.c b/arch/mips/sibyte/bcm1480/time.c index bf12af46132e..e136bde5248e 100644 --- a/arch/mips/sibyte/bcm1480/time.c +++ b/arch/mips/sibyte/bcm1480/time.c | |||
@@ -47,6 +47,12 @@ | |||
47 | #define IMR_IP3_VAL K_BCM1480_INT_MAP_I1 | 47 | #define IMR_IP3_VAL K_BCM1480_INT_MAP_I1 |
48 | #define IMR_IP4_VAL K_BCM1480_INT_MAP_I2 | 48 | #define IMR_IP4_VAL K_BCM1480_INT_MAP_I2 |
49 | 49 | ||
50 | #ifdef CONFIG_SIMULATION | ||
51 | #define BCM1480_HPT_VALUE 50000 | ||
52 | #else | ||
53 | #define BCM1480_HPT_VALUE 1000000 | ||
54 | #endif | ||
55 | |||
50 | extern int bcm1480_steal_irq(int irq); | 56 | extern int bcm1480_steal_irq(int irq); |
51 | 57 | ||
52 | void bcm1480_time_init(void) | 58 | void bcm1480_time_init(void) |
@@ -59,11 +65,6 @@ void bcm1480_time_init(void) | |||
59 | BUG(); | 65 | BUG(); |
60 | } | 66 | } |
61 | 67 | ||
62 | if (!cpu) { | ||
63 | /* Use our own gettimeoffset() routine */ | ||
64 | do_gettimeoffset = bcm1480_gettimeoffset; | ||
65 | } | ||
66 | |||
67 | bcm1480_mask_irq(cpu, irq); | 68 | bcm1480_mask_irq(cpu, irq); |
68 | 69 | ||
69 | /* Map the timer interrupt to ip[4] of this cpu */ | 70 | /* Map the timer interrupt to ip[4] of this cpu */ |
@@ -74,11 +75,7 @@ void bcm1480_time_init(void) | |||
74 | /* Disable the timer and set up the count */ | 75 | /* Disable the timer and set up the count */ |
75 | __raw_writeq(0, IOADDR(A_SCD_TIMER_REGISTER(cpu, R_SCD_TIMER_CFG))); | 76 | __raw_writeq(0, IOADDR(A_SCD_TIMER_REGISTER(cpu, R_SCD_TIMER_CFG))); |
76 | __raw_writeq( | 77 | __raw_writeq( |
77 | #ifndef CONFIG_SIMULATION | 78 | BCM1480_HPT_VALUE/HZ |
78 | 1000000/HZ | ||
79 | #else | ||
80 | 50000/HZ | ||
81 | #endif | ||
82 | , IOADDR(A_SCD_TIMER_REGISTER(cpu, R_SCD_TIMER_INIT))); | 79 | , IOADDR(A_SCD_TIMER_REGISTER(cpu, R_SCD_TIMER_INIT))); |
83 | 80 | ||
84 | /* Set the timer running */ | 81 | /* Set the timer running */ |
@@ -122,16 +119,16 @@ void bcm1480_timer_interrupt(void) | |||
122 | } | 119 | } |
123 | } | 120 | } |
124 | 121 | ||
125 | /* | 122 | static unsigned int bcm1480_hpt_read(void) |
126 | * We use our own do_gettimeoffset() instead of the generic one, | ||
127 | * because the generic one does not work for SMP case. | ||
128 | * In addition, since we use general timer 0 for system time, | ||
129 | * we can get accurate intra-jiffy offset without calibration. | ||
130 | */ | ||
131 | unsigned long bcm1480_gettimeoffset(void) | ||
132 | { | 123 | { |
124 | /* We assume this function is called xtime_lock held. */ | ||
133 | unsigned long count = | 125 | unsigned long count = |
134 | __raw_readq(IOADDR(A_SCD_TIMER_REGISTER(0, R_SCD_TIMER_CNT))); | 126 | __raw_readq(IOADDR(A_SCD_TIMER_REGISTER(0, R_SCD_TIMER_CNT))); |
127 | return (jiffies + 1) * (BCM1480_HPT_VALUE / HZ) - count; | ||
128 | } | ||
135 | 129 | ||
136 | return 1000000/HZ - count; | 130 | void __init bcm1480_hpt_setup(void) |
131 | { | ||
132 | mips_hpt_read = bcm1480_hpt_read; | ||
133 | mips_hpt_frequency = BCM1480_HPT_VALUE; | ||
137 | } | 134 | } |
diff --git a/arch/mips/sibyte/sb1250/time.c b/arch/mips/sibyte/sb1250/time.c index 0ccf1796dd78..bcb74f2c1948 100644 --- a/arch/mips/sibyte/sb1250/time.c +++ b/arch/mips/sibyte/sb1250/time.c | |||
@@ -47,15 +47,11 @@ | |||
47 | 47 | ||
48 | #define SB1250_HPT_NUM 3 | 48 | #define SB1250_HPT_NUM 3 |
49 | #define SB1250_HPT_VALUE M_SCD_TIMER_CNT /* max value */ | 49 | #define SB1250_HPT_VALUE M_SCD_TIMER_CNT /* max value */ |
50 | #define SB1250_HPT_SHIFT ((sizeof(unsigned int)*8)-V_SCD_TIMER_WIDTH) | ||
51 | 50 | ||
52 | 51 | ||
53 | extern int sb1250_steal_irq(int irq); | 52 | extern int sb1250_steal_irq(int irq); |
54 | 53 | ||
55 | static unsigned int sb1250_hpt_read(void); | 54 | static unsigned int sb1250_hpt_read(void); |
56 | static void sb1250_hpt_init(unsigned int); | ||
57 | |||
58 | static unsigned int hpt_offset; | ||
59 | 55 | ||
60 | void __init sb1250_hpt_setup(void) | 56 | void __init sb1250_hpt_setup(void) |
61 | { | 57 | { |
@@ -69,13 +65,9 @@ void __init sb1250_hpt_setup(void) | |||
69 | __raw_writeq(M_SCD_TIMER_ENABLE | M_SCD_TIMER_MODE_CONTINUOUS, | 65 | __raw_writeq(M_SCD_TIMER_ENABLE | M_SCD_TIMER_MODE_CONTINUOUS, |
70 | IOADDR(A_SCD_TIMER_REGISTER(SB1250_HPT_NUM, R_SCD_TIMER_CFG))); | 66 | IOADDR(A_SCD_TIMER_REGISTER(SB1250_HPT_NUM, R_SCD_TIMER_CFG))); |
71 | 67 | ||
72 | /* | 68 | mips_hpt_frequency = V_SCD_TIMER_FREQ; |
73 | * we need to fill 32 bits, so just use the upper 23 bits and pretend | ||
74 | * the timer is going 512Mhz instead of 1Mhz | ||
75 | */ | ||
76 | mips_hpt_frequency = V_SCD_TIMER_FREQ << SB1250_HPT_SHIFT; | ||
77 | mips_hpt_init = sb1250_hpt_init; | ||
78 | mips_hpt_read = sb1250_hpt_read; | 69 | mips_hpt_read = sb1250_hpt_read; |
70 | mips_hpt_mask = M_SCD_TIMER_INIT; | ||
79 | } | 71 | } |
80 | } | 72 | } |
81 | 73 | ||
@@ -149,11 +141,7 @@ void sb1250_timer_interrupt(void) | |||
149 | 141 | ||
150 | /* | 142 | /* |
151 | * The HPT is free running from SB1250_HPT_VALUE down to 0 then starts over | 143 | * The HPT is free running from SB1250_HPT_VALUE down to 0 then starts over |
152 | * again. There's no easy way to set to a specific value so store init value | 144 | * again. |
153 | * in hpt_offset and subtract each time. | ||
154 | * | ||
155 | * Note: Timer isn't full 32bits so shift it into the upper part making | ||
156 | * it appear to run at a higher frequency. | ||
157 | */ | 145 | */ |
158 | static unsigned int sb1250_hpt_read(void) | 146 | static unsigned int sb1250_hpt_read(void) |
159 | { | 147 | { |
@@ -161,13 +149,5 @@ static unsigned int sb1250_hpt_read(void) | |||
161 | 149 | ||
162 | count = G_SCD_TIMER_CNT(__raw_readq(IOADDR(A_SCD_TIMER_REGISTER(SB1250_HPT_NUM, R_SCD_TIMER_CNT)))); | 150 | count = G_SCD_TIMER_CNT(__raw_readq(IOADDR(A_SCD_TIMER_REGISTER(SB1250_HPT_NUM, R_SCD_TIMER_CNT)))); |
163 | 151 | ||
164 | count = (SB1250_HPT_VALUE - count) << SB1250_HPT_SHIFT; | 152 | return SB1250_HPT_VALUE - count; |
165 | |||
166 | return count - hpt_offset; | ||
167 | } | ||
168 | |||
169 | static void sb1250_hpt_init(unsigned int count) | ||
170 | { | ||
171 | hpt_offset = count; | ||
172 | return; | ||
173 | } | 153 | } |