@@ -217,7 +217,7 @@ static void hpet_reserve_platform_timers(unsigned int id) { }
217
217
/*
218
218
* Common hpet info
219
219
*/
220
- static unsigned long hpet_period ;
220
+ static unsigned long hpet_freq ;
221
221
222
222
static void hpet_legacy_set_mode (enum clock_event_mode mode ,
223
223
struct clock_event_device * evt );
@@ -232,7 +232,6 @@ static struct clock_event_device hpet_clockevent = {
232
232
.features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT ,
233
233
.set_mode = hpet_legacy_set_mode ,
234
234
.set_next_event = hpet_legacy_next_event ,
235
- .shift = 32 ,
236
235
.irq = 0 ,
237
236
.rating = 50 ,
238
237
};
@@ -289,29 +288,13 @@ static void hpet_legacy_clockevent_register(void)
289
288
/* Start HPET legacy interrupts */
290
289
hpet_enable_legacy_int ();
291
290
292
- /*
293
- * The mult factor is defined as (include/linux/clockchips.h)
294
- * mult/2^shift = cyc/ns (in contrast to ns/cyc in clocksource.h)
295
- * hpet_period is in units of femtoseconds (per cycle), so
296
- * mult/2^shift = cyc/ns = 10^6/hpet_period
297
- * mult = (10^6 * 2^shift)/hpet_period
298
- * mult = (FSEC_PER_NSEC << hpet_clockevent.shift)/hpet_period
299
- */
300
- hpet_clockevent .mult = div_sc ((unsigned long ) FSEC_PER_NSEC ,
301
- hpet_period , hpet_clockevent .shift );
302
- /* Calculate the min / max delta */
303
- hpet_clockevent .max_delta_ns = clockevent_delta2ns (0x7FFFFFFF ,
304
- & hpet_clockevent );
305
- /* Setup minimum reprogramming delta. */
306
- hpet_clockevent .min_delta_ns = clockevent_delta2ns (HPET_MIN_PROG_DELTA ,
307
- & hpet_clockevent );
308
-
309
291
/*
310
292
* Start hpet with the boot cpu mask and make it
311
293
* global after the IO_APIC has been initialized.
312
294
*/
313
295
hpet_clockevent .cpumask = cpumask_of (smp_processor_id ());
314
- clockevents_register_device (& hpet_clockevent );
296
+ clockevents_config_and_register (& hpet_clockevent , hpet_freq ,
297
+ HPET_MIN_PROG_DELTA , 0x7FFFFFFF );
315
298
global_clock_event = & hpet_clockevent ;
316
299
printk (KERN_DEBUG "hpet clockevent registered\n" );
317
300
}
@@ -549,7 +532,6 @@ static int hpet_setup_irq(struct hpet_dev *dev)
549
532
static void init_one_hpet_msi_clockevent (struct hpet_dev * hdev , int cpu )
550
533
{
551
534
struct clock_event_device * evt = & hdev -> evt ;
552
- uint64_t hpet_freq ;
553
535
554
536
WARN_ON (cpu != smp_processor_id ());
555
537
if (!(hdev -> flags & HPET_DEV_VALID ))
@@ -571,24 +553,10 @@ static void init_one_hpet_msi_clockevent(struct hpet_dev *hdev, int cpu)
571
553
572
554
evt -> set_mode = hpet_msi_set_mode ;
573
555
evt -> set_next_event = hpet_msi_next_event ;
574
- evt -> shift = 32 ;
575
-
576
- /*
577
- * The period is a femto seconds value. We need to calculate the
578
- * scaled math multiplication factor for nanosecond to hpet tick
579
- * conversion.
580
- */
581
- hpet_freq = FSEC_PER_SEC ;
582
- do_div (hpet_freq , hpet_period );
583
- evt -> mult = div_sc ((unsigned long ) hpet_freq ,
584
- NSEC_PER_SEC , evt -> shift );
585
- /* Calculate the max delta */
586
- evt -> max_delta_ns = clockevent_delta2ns (0x7FFFFFFF , evt );
587
- /* 5 usec minimum reprogramming delta. */
588
- evt -> min_delta_ns = 5000 ;
589
-
590
556
evt -> cpumask = cpumask_of (hdev -> cpu );
591
- clockevents_register_device (evt );
557
+
558
+ clockevents_config_and_register (evt , hpet_freq , HPET_MIN_PROG_DELTA ,
559
+ 0x7FFFFFFF );
592
560
}
593
561
594
562
#ifdef CONFIG_HPET
@@ -792,7 +760,6 @@ static struct clocksource clocksource_hpet = {
792
760
static int hpet_clocksource_register (void )
793
761
{
794
762
u64 start , now ;
795
- u64 hpet_freq ;
796
763
cycle_t t1 ;
797
764
798
765
/* Start the counter */
@@ -819,24 +786,7 @@ static int hpet_clocksource_register(void)
819
786
return - ENODEV ;
820
787
}
821
788
822
- /*
823
- * The definition of mult is (include/linux/clocksource.h)
824
- * mult/2^shift = ns/cyc and hpet_period is in units of fsec/cyc
825
- * so we first need to convert hpet_period to ns/cyc units:
826
- * mult/2^shift = ns/cyc = hpet_period/10^6
827
- * mult = (hpet_period * 2^shift)/10^6
828
- * mult = (hpet_period << shift)/FSEC_PER_NSEC
829
- */
830
-
831
- /* Need to convert hpet_period (fsec/cyc) to cyc/sec:
832
- *
833
- * cyc/sec = FSEC_PER_SEC/hpet_period(fsec/cyc)
834
- * cyc/sec = (FSEC_PER_NSEC * NSEC_PER_SEC)/hpet_period
835
- */
836
- hpet_freq = FSEC_PER_SEC ;
837
- do_div (hpet_freq , hpet_period );
838
789
clocksource_register_hz (& clocksource_hpet , (u32 )hpet_freq );
839
-
840
790
return 0 ;
841
791
}
842
792
@@ -845,7 +795,9 @@ static int hpet_clocksource_register(void)
845
795
*/
846
796
int __init hpet_enable (void )
847
797
{
798
+ unsigned long hpet_period ;
848
799
unsigned int id ;
800
+ u64 freq ;
849
801
int i ;
850
802
851
803
if (!is_hpet_capable ())
@@ -883,6 +835,14 @@ int __init hpet_enable(void)
883
835
if (hpet_period < HPET_MIN_PERIOD || hpet_period > HPET_MAX_PERIOD )
884
836
goto out_nohpet ;
885
837
838
+ /*
839
+ * The period is a femto seconds value. Convert it to a
840
+ * frequency.
841
+ */
842
+ freq = FSEC_PER_SEC ;
843
+ do_div (freq , hpet_period );
844
+ hpet_freq = freq ;
845
+
886
846
/*
887
847
* Read the HPET ID register to retrieve the IRQ routing
888
848
* information and the number of channels
0 commit comments