pcrtc.c revision 178169
1/*-
2 * Copyright (c) 1990 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * William Jolitz and Don Ahn.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 *    notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 *    notice, this list of conditions and the following disclaimer in the
15 *    documentation and/or other materials provided with the distribution.
16 * 4. Neither the name of the University nor the names of its contributors
17 *    may be used to endorse or promote products derived from this software
18 *    without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 *
32 *	from: @(#)clock.c	7.2 (Berkeley) 5/12/91
33 */
34
35#include <sys/cdefs.h>
36__FBSDID("$FreeBSD: head/sys/pc98/cbus/pcrtc.c 178169 2008-04-13 06:18:34Z nyan $");
37
38/*
39 * Routines to handle clock hardware.
40 */
41
42/*
43 * inittodr, settodr and support routines written
44 * by Christoph Robitschko <chmr@edvz.tu-graz.ac.at>
45 *
46 * reintroduced and updated by Chris Stenton <chris@gnome.co.uk> 8/10/94
47 */
48
49/*
50 * modified for PC98 by Kakefuda
51 */
52
53#include "opt_apic.h"
54#include "opt_clock.h"
55#include "opt_isa.h"
56#include "opt_mca.h"
57
58#include <sys/param.h>
59#include <sys/systm.h>
60#include <sys/bus.h>
61#include <sys/clock.h>
62#include <sys/lock.h>
63#include <sys/kdb.h>
64#include <sys/mutex.h>
65#include <sys/proc.h>
66#include <sys/time.h>
67#include <sys/timetc.h>
68#include <sys/kernel.h>
69#include <sys/limits.h>
70#include <sys/module.h>
71#include <sys/sysctl.h>
72#include <sys/power.h>
73
74#include <machine/clock.h>
75#include <machine/cpu.h>
76#include <machine/cputypes.h>
77#include <machine/frame.h>
78#include <machine/intr_machdep.h>
79#include <machine/md_var.h>
80#include <machine/psl.h>
81#ifdef DEV_APIC
82#include <machine/apicvar.h>
83#endif
84#include <machine/specialreg.h>
85#include <machine/ppireg.h>
86#include <machine/timerreg.h>
87
88#include <i386/isa/icu.h>
89#include <pc98/cbus/cbus.h>
90#include <pc98/pc98/pc98_machdep.h>
91#ifdef DEV_ISA
92#include <isa/isavar.h>
93#endif
94
95#define	TIMER_DIV(x) ((i8254_freq + (x) / 2) / (x))
96
97int	clkintr_pending;
98int	statclock_disable;
99#ifndef TIMER_FREQ
100#define TIMER_FREQ   2457600
101#endif
102u_int	i8254_freq = TIMER_FREQ;
103TUNABLE_INT("hw.i8254.freq", &i8254_freq);
104int	i8254_max_count;
105static int i8254_real_max_count;
106
107static	struct mtx clock_lock;
108static	struct intsrc *i8254_intsrc;
109static	u_int32_t i8254_lastcount;
110static	u_int32_t i8254_offset;
111static	int	(*i8254_pending)(struct intsrc *);
112static	int	i8254_ticked;
113static	int	using_lapic_timer;
114
115/* Values for timerX_state: */
116#define	RELEASED	0
117#define	RELEASE_PENDING	1
118#define	ACQUIRED	2
119#define	ACQUIRE_PENDING	3
120
121static	u_char	timer1_state;
122
123static	unsigned i8254_get_timecount(struct timecounter *tc);
124static	unsigned i8254_simple_get_timecount(struct timecounter *tc);
125static	void	set_i8254_freq(u_int freq, int intr_freq);
126
127static struct timecounter i8254_timecounter = {
128	i8254_get_timecount,	/* get_timecount */
129	0,			/* no poll_pps */
130	~0u,			/* counter_mask */
131	0,			/* frequency */
132	"i8254",		/* name */
133	0			/* quality */
134};
135
136static int
137clkintr(struct trapframe *frame)
138{
139
140	if (timecounter->tc_get_timecount == i8254_get_timecount) {
141		mtx_lock_spin(&clock_lock);
142		if (i8254_ticked)
143			i8254_ticked = 0;
144		else {
145			i8254_offset += i8254_max_count;
146			i8254_lastcount = 0;
147		}
148		clkintr_pending = 0;
149		mtx_unlock_spin(&clock_lock);
150	}
151	KASSERT(!using_lapic_timer, ("clk interrupt enabled with lapic timer"));
152	hardclock(TRAPF_USERMODE(frame), TRAPF_PC(frame));
153	return (FILTER_HANDLED);
154}
155
156int
157timer_spkr_acquire(void)
158{
159	int mode;
160
161	mode = TIMER_SEL1 | TIMER_SQWAVE | TIMER_16BIT;
162
163	if (timer1_state != RELEASED)
164		return (-1);
165	timer1_state = ACQUIRED;
166
167	/*
168	 * This access to the timer registers is as atomic as possible
169	 * because it is a single instruction.  We could do better if we
170	 * knew the rate.  Use of splclock() limits glitches to 10-100us,
171	 * and this is probably good enough for timer2, so we aren't as
172	 * careful with it as with timer0.
173	 */
174	outb(TIMER_MODE, TIMER_SEL1 | (mode & 0x3f));
175	ppi_spkr_on();		/* enable counter1 output to speaker */
176
177	return (0);
178}
179
180int
181timer_spkr_release(void)
182{
183
184	if (timer1_state != ACQUIRED)
185		return (-1);
186	timer1_state = RELEASED;
187	outb(TIMER_MODE, TIMER_SEL1 | TIMER_SQWAVE | TIMER_16BIT);
188	ppi_spkr_off();		/* disable counter1 output to speaker */
189	return (0);
190}
191
192void
193timer_spkr_setfreq(int freq)
194{
195
196	freq = i8254_freq / freq;
197	mtx_lock_spin(&clock_lock);
198	outb(TIMER_CNTR1, (freq) & 0xff);
199	outb(TIMER_CNTR1, (freq) >> 8);
200	mtx_unlock_spin(&clock_lock);
201}
202
203
204static int
205getit(void)
206{
207	int high, low;
208
209	mtx_lock_spin(&clock_lock);
210
211	/* Select timer0 and latch counter value. */
212	outb(TIMER_MODE, TIMER_SEL0 | TIMER_LATCH);
213
214	low = inb(TIMER_CNTR0);
215	high = inb(TIMER_CNTR0);
216
217	mtx_unlock_spin(&clock_lock);
218	return ((high << 8) | low);
219}
220
221/*
222 * Wait "n" microseconds.
223 * Relies on timer 1 counting down from (i8254_freq / hz)
224 * Note: timer had better have been programmed before this is first used!
225 */
226void
227DELAY(int n)
228{
229	int delta, prev_tick, tick, ticks_left;
230
231#ifdef DELAYDEBUG
232	int getit_calls = 1;
233	int n1;
234	static int state = 0;
235
236	if (state == 0) {
237		state = 1;
238		for (n1 = 1; n1 <= 10000000; n1 *= 10)
239			DELAY(n1);
240		state = 2;
241	}
242	if (state == 1)
243		printf("DELAY(%d)...", n);
244#endif
245	/*
246	 * Read the counter first, so that the rest of the setup overhead is
247	 * counted.  Guess the initial overhead is 20 usec (on most systems it
248	 * takes about 1.5 usec for each of the i/o's in getit().  The loop
249	 * takes about 6 usec on a 486/33 and 13 usec on a 386/20.  The
250	 * multiplications and divisions to scale the count take a while).
251	 *
252	 * However, if ddb is active then use a fake counter since reading
253	 * the i8254 counter involves acquiring a lock.  ddb must not do
254	 * locking for many reasons, but it calls here for at least atkbd
255	 * input.
256	 */
257#ifdef KDB
258	if (kdb_active)
259		prev_tick = 1;
260	else
261#endif
262		prev_tick = getit();
263	n -= 0;			/* XXX actually guess no initial overhead */
264	/*
265	 * Calculate (n * (i8254_freq / 1e6)) without using floating point
266	 * and without any avoidable overflows.
267	 */
268	if (n <= 0)
269		ticks_left = 0;
270	else if (n < 256)
271		/*
272		 * Use fixed point to avoid a slow division by 1000000.
273		 * 39099 = 1193182 * 2^15 / 10^6 rounded to nearest.
274		 * 2^15 is the first power of 2 that gives exact results
275		 * for n between 0 and 256.
276		 */
277		ticks_left = ((u_int)n * 39099 + (1 << 15) - 1) >> 15;
278	else
279		/*
280		 * Don't bother using fixed point, although gcc-2.7.2
281		 * generates particularly poor code for the long long
282		 * division, since even the slow way will complete long
283		 * before the delay is up (unless we're interrupted).
284		 */
285		ticks_left = ((u_int)n * (long long)i8254_freq + 999999)
286			     / 1000000;
287
288	while (ticks_left > 0) {
289#ifdef KDB
290		if (kdb_active) {
291			outb(0x5f, 0);
292			tick = prev_tick - 1;
293			if (tick <= 0)
294				tick = i8254_max_count;
295		} else
296#endif
297			tick = getit();
298#ifdef DELAYDEBUG
299		++getit_calls;
300#endif
301		delta = prev_tick - tick;
302		prev_tick = tick;
303		if (delta < 0) {
304			delta += i8254_max_count;
305			/*
306			 * Guard against i8254_max_count being wrong.
307			 * This shouldn't happen in normal operation,
308			 * but it may happen if set_i8254_freq() is
309			 * traced.
310			 */
311			if (delta < 0)
312				delta = 0;
313		}
314		ticks_left -= delta;
315	}
316#ifdef DELAYDEBUG
317	if (state == 1)
318		printf(" %d calls to getit() at %d usec each\n",
319		       getit_calls, (n + 5) / getit_calls);
320#endif
321}
322
323static void
324set_i8254_freq(u_int freq, int intr_freq)
325{
326	int new_i8254_real_max_count;
327
328	i8254_timecounter.tc_frequency = freq;
329	mtx_lock_spin(&clock_lock);
330	i8254_freq = freq;
331	if (using_lapic_timer)
332		new_i8254_real_max_count = 0x10000;
333	else
334		new_i8254_real_max_count = TIMER_DIV(intr_freq);
335	if (new_i8254_real_max_count != i8254_real_max_count) {
336		i8254_real_max_count = new_i8254_real_max_count;
337		if (i8254_real_max_count == 0x10000)
338			i8254_max_count = 0xffff;
339		else
340			i8254_max_count = i8254_real_max_count;
341		outb(TIMER_MODE, TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT);
342		outb(TIMER_CNTR0, i8254_real_max_count & 0xff);
343		outb(TIMER_CNTR0, i8254_real_max_count >> 8);
344	}
345	mtx_unlock_spin(&clock_lock);
346}
347
348static void
349i8254_restore(void)
350{
351
352	mtx_lock_spin(&clock_lock);
353	outb(TIMER_MODE, TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT);
354	outb(TIMER_CNTR0, i8254_real_max_count & 0xff);
355	outb(TIMER_CNTR0, i8254_real_max_count >> 8);
356	mtx_unlock_spin(&clock_lock);
357}
358
359
360/*
361 * Restore all the timers non-atomically (XXX: should be atomically).
362 *
363 * This function is called from pmtimer_resume() to restore all the timers.
364 * This should not be necessary, but there are broken laptops that do not
365 * restore all the timers on resume.
366 */
367void
368timer_restore(void)
369{
370
371	i8254_restore();		/* restore i8254_freq and hz */
372}
373
374/* This is separate from startrtclock() so that it can be called early. */
375void
376i8254_init(void)
377{
378
379	mtx_init(&clock_lock, "clk", NULL, MTX_SPIN | MTX_NOPROFILE);
380
381	if (pc98_machine_type & M_8M)
382		i8254_freq = 1996800L; /* 1.9968 MHz */
383	else
384		i8254_freq = 2457600L; /* 2.4576 MHz */
385
386	set_i8254_freq(i8254_freq, hz);
387}
388
389void
390startrtclock()
391{
392
393	set_i8254_freq(i8254_freq, hz);
394	tc_init(&i8254_timecounter);
395
396	init_TSC();
397}
398
399/*
400 * Start both clocks running.
401 */
402void
403cpu_initclocks()
404{
405
406#ifdef DEV_APIC
407	using_lapic_timer = lapic_setup_clock();
408#endif
409	/*
410	 * If we aren't using the local APIC timer to drive the kernel
411	 * clocks, setup the interrupt handler for the 8254 timer 0 so
412	 * that it can drive hardclock().  Otherwise, change the 8254
413	 * timecounter to user a simpler algorithm.
414	 */
415	if (!using_lapic_timer) {
416		intr_add_handler("clk", 0, (driver_filter_t *)clkintr, NULL,
417		    NULL, INTR_TYPE_CLK, NULL);
418		i8254_intsrc = intr_lookup_source(0);
419		if (i8254_intsrc != NULL)
420			i8254_pending =
421			    i8254_intsrc->is_pic->pic_source_pending;
422	} else {
423		i8254_timecounter.tc_get_timecount =
424		    i8254_simple_get_timecount;
425		i8254_timecounter.tc_counter_mask = 0xffff;
426		set_i8254_freq(i8254_freq, hz);
427	}
428
429	init_TSC_tc();
430}
431
432void
433cpu_startprofclock(void)
434{
435}
436
437void
438cpu_stopprofclock(void)
439{
440}
441
442static int
443sysctl_machdep_i8254_freq(SYSCTL_HANDLER_ARGS)
444{
445	int error;
446	u_int freq;
447
448	/*
449	 * Use `i8254' instead of `timer' in external names because `timer'
450	 * is is too generic.  Should use it everywhere.
451	 */
452	freq = i8254_freq;
453	error = sysctl_handle_int(oidp, &freq, 0, req);
454	if (error == 0 && req->newptr != NULL)
455		set_i8254_freq(freq, hz);
456	return (error);
457}
458
459SYSCTL_PROC(_machdep, OID_AUTO, i8254_freq, CTLTYPE_INT | CTLFLAG_RW,
460    0, sizeof(u_int), sysctl_machdep_i8254_freq, "IU", "");
461
462static unsigned
463i8254_simple_get_timecount(struct timecounter *tc)
464{
465
466	return (i8254_max_count - getit());
467}
468
469static unsigned
470i8254_get_timecount(struct timecounter *tc)
471{
472	u_int count;
473	u_int high, low;
474	u_int eflags;
475
476	eflags = read_eflags();
477	mtx_lock_spin(&clock_lock);
478
479	/* Select timer0 and latch counter value. */
480	outb(TIMER_MODE, TIMER_SEL0 | TIMER_LATCH);
481
482	low = inb(TIMER_CNTR0);
483	high = inb(TIMER_CNTR0);
484	count = i8254_max_count - ((high << 8) | low);
485	if (count < i8254_lastcount ||
486	    (!i8254_ticked && (clkintr_pending ||
487	    ((count < 20 || (!(eflags & PSL_I) &&
488	    count < i8254_max_count / 2u)) &&
489	    i8254_pending != NULL && i8254_pending(i8254_intsrc))))) {
490		i8254_ticked = 1;
491		i8254_offset += i8254_max_count;
492	}
493	i8254_lastcount = count;
494	count += i8254_offset;
495	mtx_unlock_spin(&clock_lock);
496	return (count);
497}
498
499#ifdef DEV_ISA
500/*
501 * Attach to the ISA PnP descriptors for the timer
502 */
503static struct isa_pnp_id attimer_ids[] = {
504	{ 0x0001d041 /* PNP0100 */, "AT timer" },
505	{ 0 }
506};
507
508static int
509attimer_probe(device_t dev)
510{
511	int result;
512
513	result = ISA_PNP_PROBE(device_get_parent(dev), dev, attimer_ids);
514	if (result <= 0)
515		device_quiet(dev);
516	return(result);
517}
518
519static int
520attimer_attach(device_t dev)
521{
522	return(0);
523}
524
525static device_method_t attimer_methods[] = {
526	/* Device interface */
527	DEVMETHOD(device_probe,		attimer_probe),
528	DEVMETHOD(device_attach,	attimer_attach),
529	DEVMETHOD(device_detach,	bus_generic_detach),
530	DEVMETHOD(device_shutdown,	bus_generic_shutdown),
531	DEVMETHOD(device_suspend,	bus_generic_suspend),
532	DEVMETHOD(device_resume,	bus_generic_resume),
533	{ 0, 0 }
534};
535
536static driver_t attimer_driver = {
537	"attimer",
538	attimer_methods,
539	1,		/* no softc */
540};
541
542static devclass_t attimer_devclass;
543
544DRIVER_MODULE(attimer, isa, attimer_driver, attimer_devclass, 0, 0);
545
546#endif /* DEV_ISA */
547
548#ifdef DEV_ISA
549
550/**********************************************************************
551 * RTC driver for subr_rtc
552 */
553
554#include "clock_if.h"
555
556#include <sys/rman.h>
557
558static void rtc_serialcombit(int);
559static void rtc_serialcom(int);
560static int rtc_inb(void);
561static void rtc_outb(int);
562
563static void
564rtc_serialcombit(int i)
565{
566	outb(IO_RTC, ((i&0x01)<<5)|0x07);
567	DELAY(1);
568	outb(IO_RTC, ((i&0x01)<<5)|0x17);
569	DELAY(1);
570	outb(IO_RTC, ((i&0x01)<<5)|0x07);
571	DELAY(1);
572}
573
574static void
575rtc_serialcom(int i)
576{
577	rtc_serialcombit(i&0x01);
578	rtc_serialcombit((i&0x02)>>1);
579	rtc_serialcombit((i&0x04)>>2);
580	rtc_serialcombit((i&0x08)>>3);
581	outb(IO_RTC, 0x07);
582	DELAY(1);
583	outb(IO_RTC, 0x0f);
584	DELAY(1);
585	outb(IO_RTC, 0x07);
586 	DELAY(1);
587}
588
589static void
590rtc_outb(int val)
591{
592	int s;
593	int sa = 0;
594
595	for (s=0;s<8;s++) {
596	    sa = ((val >> s) & 0x01) ? 0x27 : 0x07;
597	    outb(IO_RTC, sa);		/* set DI & CLK 0 */
598	    DELAY(1);
599	    outb(IO_RTC, sa | 0x10);	/* CLK 1 */
600	    DELAY(1);
601	}
602	outb(IO_RTC, sa & 0xef);	/* CLK 0 */
603}
604
605static int
606rtc_inb(void)
607{
608	int s;
609	int sa = 0;
610
611	for (s=0;s<8;s++) {
612	    sa |= ((inb(0x33) & 0x01) << s);
613	    outb(IO_RTC, 0x17);	/* CLK 1 */
614	    DELAY(1);
615	    outb(IO_RTC, 0x07);	/* CLK 0 */
616	    DELAY(2);
617	}
618	return sa;
619}
620
621struct pcrtc_softc {
622	int port_rid1, port_rid2;
623	struct resource *port_res1, *port_res2;
624};
625
626/*
627 * Attach to the ISA PnP descriptors for the timer and realtime clock.
628 */
629static struct isa_pnp_id pcrtc_ids[] = {
630	{ 0x000bd041 /* PNP0B00 */, "AT realtime clock" },
631	{ 0 }
632};
633
634static int
635pcrtc_probe(device_t dev)
636{
637	int result;
638
639	device_set_desc(dev, "PC Real Time Clock");
640	result = ISA_PNP_PROBE(device_get_parent(dev), dev, pcrtc_ids);
641	/* ENXIO if wrong PnP-ID, ENOENT ifno PnP-ID, zero if good PnP-iD */
642	if (result != ENOENT)
643		return(result);
644	/* All PC's have an RTC, and we're hosed without it, so... */
645	return (BUS_PROBE_LOW_PRIORITY);
646}
647
648static int
649pcrtc_attach(device_t dev)
650{
651	struct pcrtc_softc *sc;
652
653	/*
654	 * Not that we need them or anything, but grab our resources
655	 * so they show up, correctly attributed, in the big picture.
656	 */
657	sc = device_get_softc(dev);
658	sc->port_rid1 = 0;
659	bus_set_resource(dev, SYS_RES_IOPORT, sc->port_rid1, IO_RTC, 1);
660	if (!(sc->port_res1 = bus_alloc_resource(dev, SYS_RES_IOPORT,
661	    &sc->port_rid1, IO_RTC, IO_RTC, 1, RF_ACTIVE)))
662		device_printf(dev, "Warning: Couldn't map I/O.\n");
663	sc->port_rid2 = 1;
664	bus_set_resource(dev, SYS_RES_IOPORT, sc->port_rid2, 0x33, 1);
665	if (!(sc->port_res2 = bus_alloc_resource(dev, SYS_RES_IOPORT,
666	    &sc->port_rid2, 0x33, 0x33, 1, RF_ACTIVE)))
667		device_printf(dev, "Warning: Couldn't map I/O.\n");
668
669	clock_register(dev, 1000000);
670	return(0);
671}
672
673static int
674pcrtc_settime(device_t dev __unused, struct timespec *ts)
675{
676	struct clocktime ct;
677
678	clock_ts_to_ct(ts, &ct);
679
680	rtc_serialcom(0x01);	/* Register shift command. */
681
682	rtc_outb(bin2bcd(ct.sec)); 		/* Write back Seconds */
683	rtc_outb(bin2bcd(ct.min)); 		/* Write back Minutes */
684	rtc_outb(bin2bcd(ct.hour)); 		/* Write back Hours   */
685
686	rtc_outb(bin2bcd(ct.day));		/* Write back Day     */
687	rtc_outb((ct.mon << 4) | ct.dow);	/* Write back Month and DOW */
688	rtc_outb(bin2bcd(ct.year % 100));	/* Write back Year    */
689
690	rtc_serialcom(0x02);	/* Time set & Counter hold command. */
691	rtc_serialcom(0x00);	/* Register hold command. */
692
693	return (0);
694}
695
696static int
697pcrtc_gettime(device_t dev, struct timespec *ts)
698{
699	struct clocktime ct;
700	int i;
701
702	rtc_serialcom(0x03);	/* Time Read */
703	rtc_serialcom(0x01);	/* Register shift command. */
704	DELAY(20);
705
706	ct.nsec = 0;
707	ct.sec = bcd2bin(rtc_inb() & 0xff);		/* sec */
708	ct.min = bcd2bin(rtc_inb() & 0xff);		/* min */
709	ct.hour = bcd2bin(rtc_inb() & 0xff);		/* hour */
710	ct.day = bcd2bin(rtc_inb() & 0xff);		/* date */
711	i = rtc_inb();
712	ct.dow = i & 0x0f;				/* dow */
713	ct.mon = (i >> 4) & 0x0f;			/* month */
714	ct.year = bcd2bin(rtc_inb() & 0xff) + 1900;	/* year */
715	if (ct.year < 1995)
716		ct.year += 100;
717
718	/* Set dow = -1 because some clocks don't set it correctly. */
719	ct.dow = -1;
720
721	return (clock_ct_to_ts(&ct, ts));
722}
723
724static device_method_t pcrtc_methods[] = {
725	/* Device interface */
726	DEVMETHOD(device_probe,		pcrtc_probe),
727	DEVMETHOD(device_attach,	pcrtc_attach),
728	DEVMETHOD(device_detach,	bus_generic_detach),
729	DEVMETHOD(device_shutdown,	bus_generic_shutdown),
730	DEVMETHOD(device_suspend,	bus_generic_suspend),
731		/* XXX stop statclock? */
732	DEVMETHOD(device_resume,	bus_generic_resume),
733		/* XXX restart statclock? */
734
735	/* clock interface */
736	DEVMETHOD(clock_gettime,	pcrtc_gettime),
737	DEVMETHOD(clock_settime,	pcrtc_settime),
738
739	{ 0, 0 }
740};
741
742static driver_t pcrtc_driver = {
743	"pcrtc",
744	pcrtc_methods,
745	sizeof(struct pcrtc_softc),
746};
747
748static devclass_t pcrtc_devclass;
749
750DRIVER_MODULE(pcrtc, isa, pcrtc_driver, pcrtc_devclass, 0, 0);
751
752#endif /* DEV_ISA */
753