xref: /freebsd/sys/dev/acpica/acpi_timer.c (revision 78a49a45bc3191c19d85c576090fd1a598d78540)
115e32d5dSMike Smith /*-
2787fa5b8SMike Smith  * Copyright (c) 2000, 2001 Michael Smith
315e32d5dSMike Smith  * Copyright (c) 2000 BSDi
415e32d5dSMike Smith  * All rights reserved.
515e32d5dSMike Smith  *
615e32d5dSMike Smith  * Redistribution and use in source and binary forms, with or without
715e32d5dSMike Smith  * modification, are permitted provided that the following conditions
815e32d5dSMike Smith  * are met:
915e32d5dSMike Smith  * 1. Redistributions of source code must retain the above copyright
1015e32d5dSMike Smith  *    notice, this list of conditions and the following disclaimer.
1115e32d5dSMike Smith  * 2. Redistributions in binary form must reproduce the above copyright
1215e32d5dSMike Smith  *    notice, this list of conditions and the following disclaimer in the
1315e32d5dSMike Smith  *    documentation and/or other materials provided with the distribution.
1415e32d5dSMike Smith  *
1515e32d5dSMike Smith  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1615e32d5dSMike Smith  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1715e32d5dSMike Smith  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1815e32d5dSMike Smith  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1915e32d5dSMike Smith  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2015e32d5dSMike Smith  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2115e32d5dSMike Smith  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2215e32d5dSMike Smith  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2315e32d5dSMike Smith  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2415e32d5dSMike Smith  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2515e32d5dSMike Smith  * SUCH DAMAGE.
2615e32d5dSMike Smith  *
2715e32d5dSMike Smith  *	$FreeBSD$
2815e32d5dSMike Smith  */
2915e32d5dSMike Smith #include "opt_acpi.h"
3015e32d5dSMike Smith #include <sys/param.h>
3115e32d5dSMike Smith #include <sys/bus.h>
32787fa5b8SMike Smith #include <sys/kernel.h>
33787fa5b8SMike Smith #include <sys/sysctl.h>
343a65df00SJohn Baldwin #if __FreeBSD_version >= 500000
35787fa5b8SMike Smith #include <sys/timetc.h>
363a65df00SJohn Baldwin #else
373a65df00SJohn Baldwin #include <sys/time.h>
383a65df00SJohn Baldwin #endif
39787fa5b8SMike Smith 
40787fa5b8SMike Smith #include <machine/bus.h>
41787fa5b8SMike Smith #include <machine/resource.h>
42787fa5b8SMike Smith #include <sys/rman.h>
4315e32d5dSMike Smith 
4415e32d5dSMike Smith #include "acpi.h"
4515e32d5dSMike Smith 
4687e5d361SJohn Baldwin #include <dev/acpica/acpivar.h>
47787fa5b8SMike Smith #include <pci/pcivar.h>
48787fa5b8SMike Smith 
49787fa5b8SMike Smith /*
50787fa5b8SMike Smith  * A timecounter based on the free-running ACPI timer.
51787fa5b8SMike Smith  *
52787fa5b8SMike Smith  * Based on the i386-only mp_clock.c by <phk@FreeBSD.ORG>.
53787fa5b8SMike Smith  */
5415e32d5dSMike Smith 
550ae55423SMike Smith /*
560ae55423SMike Smith  * Hooks for the ACPI CA debugging infrastructure
570ae55423SMike Smith  */
582a4ac806SMike Smith #define _COMPONENT	ACPI_SYSTEM
5972e5754cSMike Smith ACPI_MODULE_NAME("TIMER")
600ae55423SMike Smith 
61787fa5b8SMike Smith static device_t	acpi_timer_dev;
62787fa5b8SMike Smith struct resource	*acpi_timer_reg;
6315e32d5dSMike Smith 
64787fa5b8SMike Smith static u_int	acpi_timer_frequency = 14318182/4;
6515e32d5dSMike Smith 
6615e32d5dSMike Smith static void	acpi_timer_identify(driver_t *driver, device_t parent);
6715e32d5dSMike Smith static int	acpi_timer_probe(device_t dev);
6815e32d5dSMike Smith static int	acpi_timer_attach(device_t dev);
69787fa5b8SMike Smith static unsigned	acpi_timer_get_timecount(struct timecounter *tc);
70feade919SMike Smith static unsigned	acpi_timer_get_timecount_safe(struct timecounter *tc);
71787fa5b8SMike Smith static int	acpi_timer_sysctl_freq(SYSCTL_HANDLER_ARGS);
72787fa5b8SMike Smith static void	acpi_timer_test(void);
7315e32d5dSMike Smith 
74214475d8SMarcel Moolenaar static u_int32_t read_counter(void);
75214475d8SMarcel Moolenaar static int test_counter(void);
76214475d8SMarcel Moolenaar 
77787fa5b8SMike Smith /*
78787fa5b8SMike Smith  * Driver hung off ACPI.
79787fa5b8SMike Smith  */
8015e32d5dSMike Smith static device_method_t acpi_timer_methods[] = {
8115e32d5dSMike Smith     DEVMETHOD(device_identify,	acpi_timer_identify),
8215e32d5dSMike Smith     DEVMETHOD(device_probe,	acpi_timer_probe),
8315e32d5dSMike Smith     DEVMETHOD(device_attach,	acpi_timer_attach),
8415e32d5dSMike Smith 
8515e32d5dSMike Smith     {0, 0}
8615e32d5dSMike Smith };
8715e32d5dSMike Smith 
8815e32d5dSMike Smith static driver_t acpi_timer_driver = {
8915e32d5dSMike Smith     "acpi_timer",
9015e32d5dSMike Smith     acpi_timer_methods,
91787fa5b8SMike Smith     0,
9215e32d5dSMike Smith };
9315e32d5dSMike Smith 
943273b005SMike Smith static devclass_t acpi_timer_devclass;
9515e32d5dSMike Smith DRIVER_MODULE(acpi_timer, acpi, acpi_timer_driver, acpi_timer_devclass, 0, 0);
9615e32d5dSMike Smith 
97787fa5b8SMike Smith /*
98787fa5b8SMike Smith  * Timecounter.
99787fa5b8SMike Smith  */
100787fa5b8SMike Smith static struct timecounter acpi_timer_timecounter = {
101feade919SMike Smith 	acpi_timer_get_timecount_safe,
102787fa5b8SMike Smith 	0,
103787fa5b8SMike Smith 	0xffffff,
104787fa5b8SMike Smith 	0,
10578a49a45SPoul-Henning Kamp 	"ACPI",
10678a49a45SPoul-Henning Kamp 	1000
107787fa5b8SMike Smith };
108787fa5b8SMike Smith 
109214475d8SMarcel Moolenaar 
110214475d8SMarcel Moolenaar static u_int32_t
111214475d8SMarcel Moolenaar read_counter()
112214475d8SMarcel Moolenaar {
113214475d8SMarcel Moolenaar 	bus_space_handle_t bsh;
114214475d8SMarcel Moolenaar 	bus_space_tag_t bst;
115214475d8SMarcel Moolenaar 	u_int32_t tv;
116214475d8SMarcel Moolenaar 
117214475d8SMarcel Moolenaar 	bsh = rman_get_bushandle(acpi_timer_reg);
118214475d8SMarcel Moolenaar 	bst = rman_get_bustag(acpi_timer_reg);
119214475d8SMarcel Moolenaar 	tv = bus_space_read_4(bst, bsh, 0);
120214475d8SMarcel Moolenaar 	bus_space_barrier(bst, bsh, 0, 4, BUS_SPACE_BARRIER_READ);
121214475d8SMarcel Moolenaar 	return (tv);
122214475d8SMarcel Moolenaar }
123cb877d00SPoul-Henning Kamp 
124cb877d00SPoul-Henning Kamp #define N 2000
125cb877d00SPoul-Henning Kamp static int
126cb877d00SPoul-Henning Kamp test_counter()
127cb877d00SPoul-Henning Kamp {
128cb877d00SPoul-Henning Kamp 	int min, max, n, delta;
129cb877d00SPoul-Henning Kamp 	unsigned last, this;
130cb877d00SPoul-Henning Kamp 
131cb877d00SPoul-Henning Kamp 	min = 10000000;
132cb877d00SPoul-Henning Kamp 	max = 0;
133214475d8SMarcel Moolenaar 	last = read_counter();
134cb877d00SPoul-Henning Kamp 	for (n = 0; n < N; n++) {
135214475d8SMarcel Moolenaar 		this = read_counter();
136cb877d00SPoul-Henning Kamp 		delta = (this - last) & 0xffffff;
137cb877d00SPoul-Henning Kamp 		if (delta > max)
138cb877d00SPoul-Henning Kamp 			max = delta;
139cb877d00SPoul-Henning Kamp 		else if (delta < min)
140cb877d00SPoul-Henning Kamp 			min = delta;
141cb877d00SPoul-Henning Kamp 		last = this;
142cb877d00SPoul-Henning Kamp 	}
143cb877d00SPoul-Henning Kamp 	if (max - min > 2)
144cb877d00SPoul-Henning Kamp 		n = 0;
145214475d8SMarcel Moolenaar 	else if (min < 0 || max == 0)
146cb877d00SPoul-Henning Kamp 		n = 0;
147cb877d00SPoul-Henning Kamp 	else
148cb877d00SPoul-Henning Kamp 		n = 1;
149116caf7cSPoul-Henning Kamp 	if (bootverbose)
150cb877d00SPoul-Henning Kamp 		printf("ACPI timer looks %s min = %d, max = %d, width = %d\n",
151cb877d00SPoul-Henning Kamp 			n ? "GOOD" : "BAD ",
152214475d8SMarcel Moolenaar 			min, max, max - min);
153cb877d00SPoul-Henning Kamp 	return (n);
154cb877d00SPoul-Henning Kamp }
155787fa5b8SMike Smith 
156787fa5b8SMike Smith /*
157787fa5b8SMike Smith  * Locate the ACPI timer using the FADT, set up and allocate the I/O resources
158787fa5b8SMike Smith  * we will be using.
159787fa5b8SMike Smith  */
16015e32d5dSMike Smith static void
16115e32d5dSMike Smith acpi_timer_identify(driver_t *driver, device_t parent)
16215e32d5dSMike Smith {
16315e32d5dSMike Smith     device_t	dev;
16415e32d5dSMike Smith     char	desc[40];
165214475d8SMarcel Moolenaar     u_long	rlen, rstart;
166214475d8SMarcel Moolenaar     int		i, j, rid, rtype;
16715e32d5dSMike Smith 
168b4a05238SPeter Wemm     ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
1690ae55423SMike Smith 
1700ae55423SMike Smith     if (acpi_disabled("timer"))
1710ae55423SMike Smith 	return_VOID;
1720ae55423SMike Smith 
17391467fc6SMike Smith     if (AcpiGbl_FADT == NULL)
1740ae55423SMike Smith 	return_VOID;
17515e32d5dSMike Smith 
17615e32d5dSMike Smith     if ((dev = BUS_ADD_CHILD(parent, 0, "acpi_timer", 0)) == NULL) {
17715e32d5dSMike Smith 	device_printf(parent, "could not add acpi_timer0\n");
1780ae55423SMike Smith 	return_VOID;
17915e32d5dSMike Smith     }
180787fa5b8SMike Smith     acpi_timer_dev = dev;
181214475d8SMarcel Moolenaar 
182787fa5b8SMike Smith     rid = 0;
183214475d8SMarcel Moolenaar     rlen = AcpiGbl_FADT->PmTmLen;
184214475d8SMarcel Moolenaar     rtype = (AcpiGbl_FADT->XPmTmrBlk.AddressSpaceId)
185214475d8SMarcel Moolenaar       ? SYS_RES_IOPORT : SYS_RES_MEMORY;
186214475d8SMarcel Moolenaar     rstart = AcpiGbl_FADT->XPmTmrBlk.Address;
187214475d8SMarcel Moolenaar     bus_set_resource(dev, rtype, rid, rstart, rlen);
188214475d8SMarcel Moolenaar     acpi_timer_reg = bus_alloc_resource(dev, rtype, &rid, 0, ~0, 1, RF_ACTIVE);
189214475d8SMarcel Moolenaar     if (acpi_timer_reg == NULL) {
190214475d8SMarcel Moolenaar 	device_printf(dev, "couldn't allocate I/O resource (%s 0x%lx)\n",
191214475d8SMarcel Moolenaar 	  (rtype == SYS_RES_IOPORT) ? "port" : "mem", rstart);
1920ae55423SMike Smith 	return_VOID;
19315e32d5dSMike Smith     }
194d786139cSMaxime Henrion     if (testenv("debug.acpi.timer_test"))
195787fa5b8SMike Smith 	acpi_timer_test();
196787fa5b8SMike Smith 
197787fa5b8SMike Smith     acpi_timer_timecounter.tc_frequency = acpi_timer_frequency;
198cb877d00SPoul-Henning Kamp     j = 0;
199cb877d00SPoul-Henning Kamp     for(i = 0; i < 10; i++)
200cb877d00SPoul-Henning Kamp 	j += test_counter();
201cb877d00SPoul-Henning Kamp     if (j == 10) {
202cb877d00SPoul-Henning Kamp 	acpi_timer_timecounter.tc_name = "ACPI-fast";
203cb877d00SPoul-Henning Kamp 	acpi_timer_timecounter.tc_get_timecount = acpi_timer_get_timecount;
204cb877d00SPoul-Henning Kamp     } else {
205cb877d00SPoul-Henning Kamp 	acpi_timer_timecounter.tc_name = "ACPI-safe";
206cb877d00SPoul-Henning Kamp 	acpi_timer_timecounter.tc_get_timecount = acpi_timer_get_timecount_safe;
207cb877d00SPoul-Henning Kamp     }
208787fa5b8SMike Smith     tc_init(&acpi_timer_timecounter);
20915e32d5dSMike Smith 
210214475d8SMarcel Moolenaar     sprintf(desc, "%d-bit timer at 3.579545MHz", (AcpiGbl_FADT->TmrValExt)
211214475d8SMarcel Moolenaar       ? 32 : 24);
21215e32d5dSMike Smith     device_set_desc_copy(dev, desc);
2130ae55423SMike Smith 
2140ae55423SMike Smith     return_VOID;
21515e32d5dSMike Smith }
21615e32d5dSMike Smith 
21715e32d5dSMike Smith static int
21815e32d5dSMike Smith acpi_timer_probe(device_t dev)
21915e32d5dSMike Smith {
220787fa5b8SMike Smith     if (dev == acpi_timer_dev)
22115e32d5dSMike Smith 	return(0);
22215e32d5dSMike Smith     return(ENXIO);
22315e32d5dSMike Smith }
22415e32d5dSMike Smith 
22515e32d5dSMike Smith static int
22615e32d5dSMike Smith acpi_timer_attach(device_t dev)
22715e32d5dSMike Smith {
228787fa5b8SMike Smith     return(0);
22915e32d5dSMike Smith }
230787fa5b8SMike Smith 
231787fa5b8SMike Smith /*
232feade919SMike Smith  * Fetch current time value from reliable hardware.
233787fa5b8SMike Smith  */
234787fa5b8SMike Smith static unsigned
235787fa5b8SMike Smith acpi_timer_get_timecount(struct timecounter *tc)
236787fa5b8SMike Smith {
237214475d8SMarcel Moolenaar     return (read_counter());
238787fa5b8SMike Smith }
239787fa5b8SMike Smith 
240787fa5b8SMike Smith /*
241feade919SMike Smith  * Fetch current time value from hardware that may not correctly
242feade919SMike Smith  * latch the counter.
243feade919SMike Smith  */
244feade919SMike Smith static unsigned
245feade919SMike Smith acpi_timer_get_timecount_safe(struct timecounter *tc)
246feade919SMike Smith {
247feade919SMike Smith     unsigned u1, u2, u3;
248feade919SMike Smith 
249214475d8SMarcel Moolenaar     u2 = read_counter();
250214475d8SMarcel Moolenaar     u3 = read_counter();
251feade919SMike Smith     do {
252feade919SMike Smith 	u1 = u2;
253feade919SMike Smith 	u2 = u3;
254214475d8SMarcel Moolenaar 	u3 = read_counter();
255cb877d00SPoul-Henning Kamp     } while (u1 > u2 || u2 > u3 || (u3 - u1) > 15);
256feade919SMike Smith     return (u2);
257feade919SMike Smith }
258feade919SMike Smith 
259feade919SMike Smith /*
260787fa5b8SMike Smith  * Timecounter freqency adjustment interface.
261787fa5b8SMike Smith  */
262787fa5b8SMike Smith static int
263787fa5b8SMike Smith acpi_timer_sysctl_freq(SYSCTL_HANDLER_ARGS)
264787fa5b8SMike Smith {
265787fa5b8SMike Smith     int error;
266787fa5b8SMike Smith     u_int freq;
267787fa5b8SMike Smith 
268787fa5b8SMike Smith     if (acpi_timer_timecounter.tc_frequency == 0)
269787fa5b8SMike Smith 	return (EOPNOTSUPP);
270787fa5b8SMike Smith     freq = acpi_timer_frequency;
271787fa5b8SMike Smith     error = sysctl_handle_int(oidp, &freq, sizeof(freq), req);
272787fa5b8SMike Smith     if (error == 0 && req->newptr != NULL) {
273787fa5b8SMike Smith 	acpi_timer_frequency = freq;
274787fa5b8SMike Smith 	acpi_timer_timecounter.tc_frequency = acpi_timer_frequency;
275787fa5b8SMike Smith     }
276787fa5b8SMike Smith     return (error);
277787fa5b8SMike Smith }
278787fa5b8SMike Smith 
279787fa5b8SMike Smith SYSCTL_PROC(_machdep, OID_AUTO, acpi_timer_freq, CTLTYPE_INT | CTLFLAG_RW,
280787fa5b8SMike Smith 	    0, sizeof(u_int), acpi_timer_sysctl_freq, "I", "");
281787fa5b8SMike Smith 
282787fa5b8SMike Smith /*
283787fa5b8SMike Smith  * Test harness for verifying ACPI timer behaviour.
284787fa5b8SMike Smith  * Boot with debug.acpi.timer_test set to invoke this.
285787fa5b8SMike Smith  */
286787fa5b8SMike Smith static void
287787fa5b8SMike Smith acpi_timer_test(void)
288787fa5b8SMike Smith {
289787fa5b8SMike Smith     u_int32_t	u1, u2, u3;
290787fa5b8SMike Smith 
291214475d8SMarcel Moolenaar     u1 = read_counter();
292214475d8SMarcel Moolenaar     u2 = read_counter();
293214475d8SMarcel Moolenaar     u3 = read_counter();
294787fa5b8SMike Smith 
295787fa5b8SMike Smith     device_printf(acpi_timer_dev, "timer test in progress, reboot to quit.\n");
296787fa5b8SMike Smith     for (;;) {
297787fa5b8SMike Smith 	/*
298787fa5b8SMike Smith 	 * The failure case is where u3 > u1, but u2 does not fall between the two,
299787fa5b8SMike Smith 	 * ie. it contains garbage.
300787fa5b8SMike Smith 	 */
301787fa5b8SMike Smith 	if (u3 > u1) {
302787fa5b8SMike Smith 	    if ((u2 < u1) || (u2 > u3))
303787fa5b8SMike Smith 		device_printf(acpi_timer_dev, "timer is not monotonic: 0x%08x,0x%08x,0x%08x\n",
304787fa5b8SMike Smith 			      u1, u2, u3);
305787fa5b8SMike Smith 	}
306787fa5b8SMike Smith 	u1 = u2;
307787fa5b8SMike Smith 	u2 = u3;
308214475d8SMarcel Moolenaar 	u3 = read_counter();
309787fa5b8SMike Smith     }
310787fa5b8SMike Smith }
311787fa5b8SMike Smith 
312d8a9fe36SMike Smith /*
313d8a9fe36SMike Smith  * Chipset workaround driver hung off PCI.
314d8a9fe36SMike Smith  *
315feade919SMike Smith  * Some ACPI timers are known or believed to suffer from implementation
316feade919SMike Smith  * problems which can lead to erroneous values being read from the timer.
317feade919SMike Smith  *
318feade919SMike Smith  * Since we can't trust unknown chipsets, we default to a timer-read
319feade919SMike Smith  * routine which compensates for the most common problem (as detailed
320feade919SMike Smith  * in the excerpt from the Intel PIIX4 datasheet below).
321feade919SMike Smith  *
322feade919SMike Smith  * When we detect a known-functional chipset, we disable the workaround
323feade919SMike Smith  * to improve speed.
324feade919SMike Smith  *
325d8a9fe36SMike Smith  * ] 20. ACPI Timer Errata
326d8a9fe36SMike Smith  * ]
327d8a9fe36SMike Smith  * ]   Problem: The power management timer may return improper result when
328d8a9fe36SMike Smith  * ]   read. Although the timer value settles properly after incrementing,
329d8a9fe36SMike Smith  * ]   while incrementing there is a 3nS window every 69.8nS where the
330d8a9fe36SMike Smith  * ]   timer value is indeterminate (a 4.2% chance that the data will be
331d8a9fe36SMike Smith  * ]   incorrect when read). As a result, the ACPI free running count up
332d8a9fe36SMike Smith  * ]   timer specification is violated due to erroneous reads.  Implication:
333d8a9fe36SMike Smith  * ]   System hangs due to the "inaccuracy" of the timer when used by
334d8a9fe36SMike Smith  * ]   software for time critical events and delays.
335d8a9fe36SMike Smith  * ]
336d8a9fe36SMike Smith  * ] Workaround: Read the register twice and compare.
337d8a9fe36SMike Smith  * ] Status: This will not be fixed in the PIIX4 or PIIX4E, it is fixed
338d8a9fe36SMike Smith  * ] in the PIIX4M.
339d8a9fe36SMike Smith  *
340d8a9fe36SMike Smith  * The counter is in other words not latched to the PCI bus clock when
341d8a9fe36SMike Smith  * read.  Notice the workaround isn't:  We need to read until we have
342d8a9fe36SMike Smith  * three monotonic samples and then use the middle one, otherwise we are
343d8a9fe36SMike Smith  * not protected against the fact that the bits can be wrong in two
344d8a9fe36SMike Smith  * directions.  If we only cared about monosity two reads would be enough.
345d8a9fe36SMike Smith  */
346d8a9fe36SMike Smith 
347cb877d00SPoul-Henning Kamp #if 0
348d8a9fe36SMike Smith static int	acpi_timer_pci_probe(device_t dev);
349d8a9fe36SMike Smith 
350d8a9fe36SMike Smith static device_method_t acpi_timer_pci_methods[] = {
351d8a9fe36SMike Smith     DEVMETHOD(device_probe,	acpi_timer_pci_probe),
352d8a9fe36SMike Smith     {0, 0}
353d8a9fe36SMike Smith };
354d8a9fe36SMike Smith 
355d8a9fe36SMike Smith static driver_t acpi_timer_pci_driver = {
356d8a9fe36SMike Smith     "acpi_timer_pci",
357d8a9fe36SMike Smith     acpi_timer_pci_methods,
358d8a9fe36SMike Smith     0,
359d8a9fe36SMike Smith };
360d8a9fe36SMike Smith 
361d8a9fe36SMike Smith devclass_t acpi_timer_pci_devclass;
362d8a9fe36SMike Smith DRIVER_MODULE(acpi_timer_pci, pci, acpi_timer_pci_driver, acpi_timer_pci_devclass, 0, 0);
363d8a9fe36SMike Smith 
364d8a9fe36SMike Smith /*
365feade919SMike Smith  * Look at PCI devices going past; if we detect one we know contains
366feade919SMike Smith  * a functional ACPI timer device, enable the faster timecounter read
367feade919SMike Smith  * routine.
368d8a9fe36SMike Smith  */
369d8a9fe36SMike Smith static int
370d8a9fe36SMike Smith acpi_timer_pci_probe(device_t dev)
371d8a9fe36SMike Smith {
372b2c98accSMike Smith     int vendor, device, revid;
373b2c98accSMike Smith 
374b2c98accSMike Smith     vendor = pci_get_vendor(dev);
375b2c98accSMike Smith     device = pci_get_device(dev);
376b2c98accSMike Smith     revid  = pci_get_revid(dev);
377b2c98accSMike Smith 
378b2c98accSMike Smith     if (((vendor == 0x8086) && (device == 0x7113) && (revid >= 0x03))	|| /* PIIX4M */
379b2c98accSMike Smith 	((vendor == 0x8086) && (device == 0x719b)) 			|| /* i440MX */
380b2c98accSMike Smith 	0) {
381b2c98accSMike Smith 
382feade919SMike Smith 	acpi_timer_timecounter.tc_get_timecount = acpi_timer_get_timecount;
383b2c98accSMike Smith 	acpi_timer_timecounter.tc_name = "ACPI-fast";
384feade919SMike Smith 	if (bootverbose)
385b2c98accSMike Smith 	    device_printf(acpi_timer_dev, "functional ACPI timer detected, enabling fast timecount interface\n");
386d8a9fe36SMike Smith     }
387d8a9fe36SMike Smith 
388d8a9fe36SMike Smith     return(ENXIO);		/* we never match anything */
389d8a9fe36SMike Smith }
390cb877d00SPoul-Henning Kamp #endif
391