Commit 146b468eb0203c9b1aa1de93723ffc82c85d1dc1

Authored by Tom Rini

Merge branch 'master' of git://git.denx.de/u-boot-sparc

Showing 2 changed files Side-by-side Diff

arch/sparc/cpu/leon2/cpu_init.c
... ... @@ -13,6 +13,9 @@
13 13  
14 14 #include <config.h>
15 15  
  16 +#define TIMER_BASE_CLK 1000000
  17 +#define US_PER_TICK (1000000 / CONFIG_SYS_HZ)
  18 +
16 19 DECLARE_GLOBAL_DATA_PTR;
17 20  
18 21 /* reset CPU (jump to 0, without reset) */
... ... @@ -90,7 +93,7 @@
90 93 while (get_timer(start) < ticks) ;
91 94 }
92 95  
93   -/* initiate and setup timer0 interrupt to 1MHz
  96 +/* initiate and setup timer0 interrupt to configured HZ. Base clock is 1MHz.
94 97 * Return irq number for timer int or a negative number for
95 98 * dealing with self
96 99 */
97 100  
98 101  
99 102  
100 103  
101 104  
... ... @@ -98,29 +101,32 @@
98 101 {
99 102 LEON2_regs *leon2 = (LEON2_regs *) LEON2_PREGS;
100 103  
101   - /* 1ms ticks */
  104 + /* SYS_HZ ticks per second */
102 105 leon2->Timer_Counter_1 = 0;
103   - leon2->Timer_Reload_1 = 999; /* (((1000000 / 100) - 1)) */
  106 + leon2->Timer_Reload_1 = (TIMER_BASE_CLK / CONFIG_SYS_HZ) - 1;
104 107 leon2->Timer_Control_1 =
105 108 (LEON2_TIMER_CTRL_EN | LEON2_TIMER_CTRL_RS | LEON2_TIMER_CTRL_LD);
106 109  
107 110 return LEON2_TIMER1_IRQNO;
108 111 }
109 112  
  113 +ulong get_tbclk(void)
  114 +{
  115 + return TIMER_BASE_CLK;
  116 +}
  117 +
110 118 /*
111 119 * This function is intended for SHORT delays only.
112 120 */
113 121 unsigned long cpu_usec2ticks(unsigned long usec)
114 122 {
115   - /* timer set to 1kHz ==> 1 clk tick = 1 msec */
116   - if (usec < 1000)
  123 + if (usec < US_PER_TICK)
117 124 return 1;
118   - return (usec / 1000);
  125 + return usec / US_PER_TICK;
119 126 }
120 127  
121 128 unsigned long cpu_ticks2usec(unsigned long ticks)
122 129 {
123   - /* 1tick = 1usec */
124   - return ticks * 1000;
  130 + return ticks * US_PER_TICK;
125 131 }
arch/sparc/cpu/leon3/cpu_init.c
... ... @@ -14,6 +14,9 @@
14 14  
15 15 #include <config.h>
16 16  
  17 +#define TIMER_BASE_CLK 1000000
  18 +#define US_PER_TICK (1000000 / CONFIG_SYS_HZ)
  19 +
17 20 DECLARE_GLOBAL_DATA_PTR;
18 21  
19 22 /* reset CPU (jump to 0, without reset) */
20 23  
21 24  
... ... @@ -203,15 +206,15 @@
203 206 while (get_timer(start) < ticks) ;
204 207 }
205 208  
206   -/* initiate and setup timer0 interrupt to 1MHz
  209 +/* initiate and setup timer0 interrupt to configured HZ. Base clock is 1MHz.
207 210 * Return irq number for timer int or a negative number for
208 211 * dealing with self
209 212 */
210 213 int timer_interrupt_init_cpu(void)
211 214 {
212   - /* 1ms ticks */
  215 + /* SYS_HZ ticks per second */
213 216 gptimer->e[0].val = 0;
214   - gptimer->e[0].rld = 999; /* (((1000000 / 100) - 1)) */
  217 + gptimer->e[0].rld = (TIMER_BASE_CLK / CONFIG_SYS_HZ) - 1;
215 218 gptimer->e[0].ctrl =
216 219 (LEON3_GPTIMER_EN |
217 220 LEON3_GPTIMER_RL | LEON3_GPTIMER_LD | LEON3_GPTIMER_IRQEN);
218 221  
219 222  
220 223  
... ... @@ -219,20 +222,23 @@
219 222 return gptimer_irq;
220 223 }
221 224  
  225 +ulong get_tbclk(void)
  226 +{
  227 + return TIMER_BASE_CLK;
  228 +}
  229 +
222 230 /*
223 231 * This function is intended for SHORT delays only.
224 232 */
225 233 unsigned long cpu_usec2ticks(unsigned long usec)
226 234 {
227   - /* timer set to 1kHz ==> 1 clk tick = 1 msec */
228   - if (usec < 1000)
  235 + if (usec < US_PER_TICK)
229 236 return 1;
230   - return (usec / 1000);
  237 + return usec / US_PER_TICK;
231 238 }
232 239  
233 240 unsigned long cpu_ticks2usec(unsigned long ticks)
234 241 {
235   - /* 1tick = 1usec */
236   - return ticks * 1000;
  242 + return ticks * US_PER_TICK;
237 243 }