devicefs support for system timer

From: Pavel Machek (pavel@ucw.cz)
Date: Sun Dec 01 2002 - 16:28:26 EST


Hi!

Here it is; without this, time runs 50x too slow after resume, please
apply

                                                                Pavel

--- clean/arch/i386/kernel/i8259.c 2002-09-30 20:33:40.000000000 +0200
+++ linux-sensors/arch/i386/kernel/i8259.c 2002-12-01 22:26:19.000000000 +0100
@@ -367,6 +367,45 @@
         }
 }
 
+static void setup_timer(void)
+{
+ outb_p(0x34,0x43); /* binary, mode 2, LSB/MSB, ch 0 */
+ udelay(10);
+ outb_p(LATCH & 0xff , 0x40); /* LSB */
+ udelay(10);
+ outb(LATCH >> 8 , 0x40); /* MSB */
+}
+
+static int timer_resume(struct device *dev, u32 level)
+{
+ if (level == RESUME_POWER_ON)
+ setup_timer();
+ return 0;
+}
+
+static struct device_driver timer_driver = {
+ .name = "timer",
+ .bus = &system_bus_type,
+ .resume = timer_resume,
+};
+
+static struct sys_device device_timer = {
+ .name = "timer",
+ .id = 0,
+ .dev = {
+ .name = "timer",
+ .driver = &timer_driver,
+ },
+};
+
+static int __init init_timer_devicefs(void)
+{
+ driver_register(&timer_driver);
+ return sys_device_register(&device_timer);
+}
+
+device_initcall(init_timer_devicefs);
+
 void __init init_IRQ(void)
 {
         int i;
@@ -386,16 +425,15 @@
         }
 
         /* setup after call gates are initialised (usually add in
- * the architecture specific gates */
+ * the architecture specific gates)
+ */
         intr_init_hook();
 
         /*
          * Set the clock to HZ Hz, we already have a valid
          * vector now:
          */
- outb_p(0x34,0x43); /* binary, mode 2, LSB/MSB, ch 0 */
- outb_p(LATCH & 0xff , 0x40); /* LSB */
- outb(LATCH >> 8 , 0x40); /* MSB */
+ setup_timer();
 
         /*
          * External FPU? Set up irq13 if so, for

-- 
Worst form of spam? Adding advertisment signatures ala sourceforge.net.
What goes next? Inserting advertisment *into* email?
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sat Dec 07 2002 - 22:00:11 EST