xref: /freebsd/sys/dev/acpica/acpi_timer.c (revision 5f96beb9e08be2b08309a6b98967246b64272ade)
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"
4587e5d361SJohn Baldwin #include <dev/acpica/acpivar.h>
46cace7a2aSWarner Losh #include <dev/pci/pcivar.h>
47787fa5b8SMike Smith 
48787fa5b8SMike Smith /*
49787fa5b8SMike Smith  * A timecounter based on the free-running ACPI timer.
50787fa5b8SMike Smith  *
51787fa5b8SMike Smith  * Based on the i386-only mp_clock.c by <phk@FreeBSD.ORG>.
52787fa5b8SMike Smith  */
5315e32d5dSMike Smith 
54be2b1797SNate Lawson /* Hooks for the ACPI CA debugging infrastructure */
553184cf5aSNate Lawson #define _COMPONENT	ACPI_TIMER
5672e5754cSMike Smith ACPI_MODULE_NAME("TIMER")
570ae55423SMike Smith 
58787fa5b8SMike Smith static device_t	acpi_timer_dev;
59787fa5b8SMike Smith struct resource	*acpi_timer_reg;
6015e32d5dSMike Smith 
61787fa5b8SMike Smith static u_int	acpi_timer_frequency = 14318182 / 4;
6215e32d5dSMike Smith 
6315e32d5dSMike Smith static void	acpi_timer_identify(driver_t *driver, device_t parent);
6415e32d5dSMike Smith static int	acpi_timer_probe(device_t dev);
6515e32d5dSMike Smith static int	acpi_timer_attach(device_t dev);
66787fa5b8SMike Smith static unsigned	acpi_timer_get_timecount(struct timecounter *tc);
67feade919SMike Smith static unsigned	acpi_timer_get_timecount_safe(struct timecounter *tc);
68787fa5b8SMike Smith static int	acpi_timer_sysctl_freq(SYSCTL_HANDLER_ARGS);
69787fa5b8SMike Smith static void	acpi_timer_test(void);
7015e32d5dSMike Smith 
71be2b1797SNate Lawson static uint32_t read_counter(void);
72214475d8SMarcel Moolenaar static int	test_counter(void);
73214475d8SMarcel Moolenaar 
7415e32d5dSMike Smith static device_method_t acpi_timer_methods[] = {
7515e32d5dSMike Smith     DEVMETHOD(device_identify,	acpi_timer_identify),
7615e32d5dSMike Smith     DEVMETHOD(device_probe,	acpi_timer_probe),
7715e32d5dSMike Smith     DEVMETHOD(device_attach,	acpi_timer_attach),
7815e32d5dSMike Smith 
7915e32d5dSMike Smith     {0, 0}
8015e32d5dSMike Smith };
8115e32d5dSMike Smith 
8215e32d5dSMike Smith static driver_t acpi_timer_driver = {
8315e32d5dSMike Smith     "acpi_timer",
8415e32d5dSMike Smith     acpi_timer_methods,
85787fa5b8SMike Smith     0,
8615e32d5dSMike Smith };
8715e32d5dSMike Smith 
883273b005SMike Smith static devclass_t acpi_timer_devclass;
8915e32d5dSMike Smith DRIVER_MODULE(acpi_timer, acpi, acpi_timer_driver, acpi_timer_devclass, 0, 0);
9015e32d5dSMike Smith 
91787fa5b8SMike Smith static struct timecounter acpi_timer_timecounter = {
92feade919SMike Smith 	acpi_timer_get_timecount_safe,
93787fa5b8SMike Smith 	0,
94787fa5b8SMike Smith 	0xffffff,
95787fa5b8SMike Smith 	0,
9678a49a45SPoul-Henning Kamp 	"ACPI",
9778a49a45SPoul-Henning Kamp 	1000
98787fa5b8SMike Smith };
99787fa5b8SMike Smith 
100be2b1797SNate Lawson static uint32_t
101214475d8SMarcel Moolenaar read_counter()
102214475d8SMarcel Moolenaar {
103214475d8SMarcel Moolenaar     bus_space_handle_t bsh;
104214475d8SMarcel Moolenaar     bus_space_tag_t bst;
105214475d8SMarcel Moolenaar     u_int32_t tv;
106214475d8SMarcel Moolenaar 
107214475d8SMarcel Moolenaar     bsh = rman_get_bushandle(acpi_timer_reg);
108214475d8SMarcel Moolenaar     bst = rman_get_bustag(acpi_timer_reg);
109214475d8SMarcel Moolenaar     tv = bus_space_read_4(bst, bsh, 0);
110214475d8SMarcel Moolenaar     bus_space_barrier(bst, bsh, 0, 4, BUS_SPACE_BARRIER_READ);
111be2b1797SNate Lawson 
112214475d8SMarcel Moolenaar     return (tv);
113214475d8SMarcel Moolenaar }
114cb877d00SPoul-Henning Kamp 
115cb877d00SPoul-Henning Kamp #define N 2000
116cb877d00SPoul-Henning Kamp static int
117cb877d00SPoul-Henning Kamp test_counter()
118cb877d00SPoul-Henning Kamp {
119be2b1797SNate Lawson     u_int	last, this;
120cb877d00SPoul-Henning Kamp     int		min, max, n, delta;
121cb877d00SPoul-Henning Kamp 
122cb877d00SPoul-Henning Kamp     min = 10000000;
123cb877d00SPoul-Henning Kamp     max = 0;
124214475d8SMarcel Moolenaar     last = read_counter();
125cb877d00SPoul-Henning Kamp     for (n = 0; n < N; n++) {
126214475d8SMarcel Moolenaar 	this = read_counter();
127cb877d00SPoul-Henning Kamp 	delta = (this - last) & 0xffffff;
128cb877d00SPoul-Henning Kamp 	if (delta > max)
129cb877d00SPoul-Henning Kamp 	    max = delta;
130cb877d00SPoul-Henning Kamp 	else if (delta < min)
131cb877d00SPoul-Henning Kamp 	    min = delta;
132cb877d00SPoul-Henning Kamp 	last = this;
133cb877d00SPoul-Henning Kamp     }
134cb877d00SPoul-Henning Kamp     if (max - min > 2)
135cb877d00SPoul-Henning Kamp 	n = 0;
136214475d8SMarcel Moolenaar     else if (min < 0 || max == 0)
137cb877d00SPoul-Henning Kamp 	n = 0;
138cb877d00SPoul-Henning Kamp     else
139cb877d00SPoul-Henning Kamp 	n = 1;
140be2b1797SNate Lawson     if (bootverbose) {
141cb877d00SPoul-Henning Kamp 	printf("ACPI timer looks %s min = %d, max = %d, width = %d\n",
142cb877d00SPoul-Henning Kamp 		n ? "GOOD" : "BAD ",
143214475d8SMarcel Moolenaar 		min, max, max - min);
144be2b1797SNate Lawson     }
145be2b1797SNate Lawson 
146cb877d00SPoul-Henning Kamp     return (n);
147cb877d00SPoul-Henning Kamp }
148be2b1797SNate Lawson #undef N
149787fa5b8SMike Smith 
150787fa5b8SMike Smith /*
151787fa5b8SMike Smith  * Locate the ACPI timer using the FADT, set up and allocate the I/O resources
152787fa5b8SMike Smith  * we will be using.
153787fa5b8SMike Smith  */
15415e32d5dSMike Smith static void
15515e32d5dSMike Smith acpi_timer_identify(driver_t *driver, device_t parent)
15615e32d5dSMike Smith {
15715e32d5dSMike Smith     device_t	dev;
15815e32d5dSMike Smith     char	desc[40];
159214475d8SMarcel Moolenaar     u_long	rlen, rstart;
160214475d8SMarcel Moolenaar     int		i, j, rid, rtype;
16115e32d5dSMike Smith 
162b4a05238SPeter Wemm     ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
1630ae55423SMike Smith 
164be2b1797SNate Lawson     if (acpi_disabled("timer") || AcpiGbl_FADT == NULL)
1650ae55423SMike Smith 	return_VOID;
16615e32d5dSMike Smith 
16715e32d5dSMike Smith     if ((dev = BUS_ADD_CHILD(parent, 0, "acpi_timer", 0)) == NULL) {
16815e32d5dSMike Smith 	device_printf(parent, "could not add acpi_timer0\n");
1690ae55423SMike Smith 	return_VOID;
17015e32d5dSMike Smith     }
171787fa5b8SMike Smith     acpi_timer_dev = dev;
172214475d8SMarcel Moolenaar 
173787fa5b8SMike Smith     rid = 0;
174214475d8SMarcel Moolenaar     rlen = AcpiGbl_FADT->PmTmLen;
175214475d8SMarcel Moolenaar     rtype = (AcpiGbl_FADT->XPmTmrBlk.AddressSpaceId)
176214475d8SMarcel Moolenaar       ? SYS_RES_IOPORT : SYS_RES_MEMORY;
177214475d8SMarcel Moolenaar     rstart = AcpiGbl_FADT->XPmTmrBlk.Address;
178214475d8SMarcel Moolenaar     bus_set_resource(dev, rtype, rid, rstart, rlen);
1795f96beb9SNate Lawson     acpi_timer_reg = bus_alloc_resource_any(dev, rtype, &rid, RF_ACTIVE);
180214475d8SMarcel Moolenaar     if (acpi_timer_reg == NULL) {
181214475d8SMarcel Moolenaar 	device_printf(dev, "couldn't allocate I/O resource (%s 0x%lx)\n",
182be2b1797SNate Lawson 		      rtype == SYS_RES_IOPORT ? "port" : "mem", rstart);
1830ae55423SMike Smith 	return_VOID;
18415e32d5dSMike Smith     }
185d786139cSMaxime Henrion     if (testenv("debug.acpi.timer_test"))
186787fa5b8SMike Smith 	acpi_timer_test();
187787fa5b8SMike Smith 
188787fa5b8SMike Smith     acpi_timer_timecounter.tc_frequency = acpi_timer_frequency;
189cb877d00SPoul-Henning Kamp     j = 0;
190cb877d00SPoul-Henning Kamp     for(i = 0; i < 10; i++)
191cb877d00SPoul-Henning Kamp 	j += test_counter();
192cb877d00SPoul-Henning Kamp     if (j == 10) {
193cb877d00SPoul-Henning Kamp 	acpi_timer_timecounter.tc_name = "ACPI-fast";
194cb877d00SPoul-Henning Kamp 	acpi_timer_timecounter.tc_get_timecount = acpi_timer_get_timecount;
195cb877d00SPoul-Henning Kamp     } else {
196cb877d00SPoul-Henning Kamp 	acpi_timer_timecounter.tc_name = "ACPI-safe";
197cb877d00SPoul-Henning Kamp 	acpi_timer_timecounter.tc_get_timecount = acpi_timer_get_timecount_safe;
198cb877d00SPoul-Henning Kamp     }
199787fa5b8SMike Smith     tc_init(&acpi_timer_timecounter);
20015e32d5dSMike Smith 
201be2b1797SNate Lawson     sprintf(desc, "%d-bit timer at 3.579545MHz",
202be2b1797SNate Lawson 	    AcpiGbl_FADT->TmrValExt ? 32 : 24);
20315e32d5dSMike Smith     device_set_desc_copy(dev, desc);
2040ae55423SMike Smith 
2050ae55423SMike Smith     return_VOID;
20615e32d5dSMike Smith }
20715e32d5dSMike Smith 
20815e32d5dSMike Smith static int
20915e32d5dSMike Smith acpi_timer_probe(device_t dev)
21015e32d5dSMike Smith {
211787fa5b8SMike Smith     if (dev == acpi_timer_dev)
21215e32d5dSMike Smith 	return (0);
213be2b1797SNate Lawson 
21415e32d5dSMike Smith     return (ENXIO);
21515e32d5dSMike Smith }
21615e32d5dSMike Smith 
21715e32d5dSMike Smith static int
21815e32d5dSMike Smith acpi_timer_attach(device_t dev)
21915e32d5dSMike Smith {
220787fa5b8SMike Smith     return (0);
22115e32d5dSMike Smith }
222787fa5b8SMike Smith 
223787fa5b8SMike Smith /*
224feade919SMike Smith  * Fetch current time value from reliable hardware.
225787fa5b8SMike Smith  */
226787fa5b8SMike Smith static unsigned
227787fa5b8SMike Smith acpi_timer_get_timecount(struct timecounter *tc)
228787fa5b8SMike Smith {
229214475d8SMarcel Moolenaar     return (read_counter());
230787fa5b8SMike Smith }
231787fa5b8SMike Smith 
232787fa5b8SMike Smith /*
233feade919SMike Smith  * Fetch current time value from hardware that may not correctly
234feade919SMike Smith  * latch the counter.
235feade919SMike Smith  */
236feade919SMike Smith static unsigned
237feade919SMike Smith acpi_timer_get_timecount_safe(struct timecounter *tc)
238feade919SMike Smith {
239feade919SMike Smith     unsigned u1, u2, u3;
240feade919SMike Smith 
241214475d8SMarcel Moolenaar     u2 = read_counter();
242214475d8SMarcel Moolenaar     u3 = read_counter();
243feade919SMike Smith     do {
244feade919SMike Smith 	u1 = u2;
245feade919SMike Smith 	u2 = u3;
246214475d8SMarcel Moolenaar 	u3 = read_counter();
247be2b1797SNate Lawson     } while (u1 > u2 || u2 > u3 || u3 - u1 > 15);
248be2b1797SNate Lawson 
249feade919SMike Smith     return (u2);
250feade919SMike Smith }
251feade919SMike Smith 
252feade919SMike Smith /*
253787fa5b8SMike Smith  * Timecounter freqency adjustment interface.
254787fa5b8SMike Smith  */
255787fa5b8SMike Smith static int
256787fa5b8SMike Smith acpi_timer_sysctl_freq(SYSCTL_HANDLER_ARGS)
257787fa5b8SMike Smith {
258787fa5b8SMike Smith     int error;
259787fa5b8SMike Smith     u_int freq;
260787fa5b8SMike Smith 
261787fa5b8SMike Smith     if (acpi_timer_timecounter.tc_frequency == 0)
262787fa5b8SMike Smith 	return (EOPNOTSUPP);
263787fa5b8SMike Smith     freq = acpi_timer_frequency;
264787fa5b8SMike Smith     error = sysctl_handle_int(oidp, &freq, sizeof(freq), req);
265787fa5b8SMike Smith     if (error == 0 && req->newptr != NULL) {
266787fa5b8SMike Smith 	acpi_timer_frequency = freq;
267787fa5b8SMike Smith 	acpi_timer_timecounter.tc_frequency = acpi_timer_frequency;
268787fa5b8SMike Smith     }
269be2b1797SNate Lawson 
270787fa5b8SMike Smith     return (error);
271787fa5b8SMike Smith }
272787fa5b8SMike Smith 
273787fa5b8SMike Smith SYSCTL_PROC(_machdep, OID_AUTO, acpi_timer_freq, CTLTYPE_INT | CTLFLAG_RW,
274787fa5b8SMike Smith 	    0, sizeof(u_int), acpi_timer_sysctl_freq, "I", "");
275787fa5b8SMike Smith 
276787fa5b8SMike Smith /*
277787fa5b8SMike Smith  * Test harness for verifying ACPI timer behaviour.
278787fa5b8SMike Smith  * Boot with debug.acpi.timer_test set to invoke this.
279787fa5b8SMike Smith  */
280787fa5b8SMike Smith static void
281787fa5b8SMike Smith acpi_timer_test(void)
282787fa5b8SMike Smith {
283787fa5b8SMike Smith     u_int32_t	u1, u2, u3;
284787fa5b8SMike Smith 
285214475d8SMarcel Moolenaar     u1 = read_counter();
286214475d8SMarcel Moolenaar     u2 = read_counter();
287214475d8SMarcel Moolenaar     u3 = read_counter();
288787fa5b8SMike Smith 
289787fa5b8SMike Smith     device_printf(acpi_timer_dev, "timer test in progress, reboot to quit.\n");
290787fa5b8SMike Smith     for (;;) {
291787fa5b8SMike Smith 	/*
292be2b1797SNate Lawson 	 * The failure case is where u3 > u1, but u2 does not fall between
293be2b1797SNate Lawson 	 * the two, ie. it contains garbage.
294787fa5b8SMike Smith 	 */
295787fa5b8SMike Smith 	if (u3 > u1) {
296be2b1797SNate Lawson 	    if (u2 < u1 || u2 > u3)
297be2b1797SNate Lawson 		device_printf(acpi_timer_dev,
298be2b1797SNate Lawson 			      "timer is not monotonic: 0x%08x,0x%08x,0x%08x\n",
299787fa5b8SMike Smith 			      u1, u2, u3);
300787fa5b8SMike Smith 	}
301787fa5b8SMike Smith 	u1 = u2;
302787fa5b8SMike Smith 	u2 = u3;
303214475d8SMarcel Moolenaar 	u3 = read_counter();
304787fa5b8SMike Smith     }
305787fa5b8SMike Smith }
306787fa5b8SMike Smith 
307d8a9fe36SMike Smith /*
308d8a9fe36SMike Smith  * Chipset workaround driver hung off PCI.
309d8a9fe36SMike Smith  *
310feade919SMike Smith  * Some ACPI timers are known or believed to suffer from implementation
311feade919SMike Smith  * problems which can lead to erroneous values being read from the timer.
312feade919SMike Smith  *
313feade919SMike Smith  * Since we can't trust unknown chipsets, we default to a timer-read
314feade919SMike Smith  * routine which compensates for the most common problem (as detailed
315feade919SMike Smith  * in the excerpt from the Intel PIIX4 datasheet below).
316feade919SMike Smith  *
317feade919SMike Smith  * When we detect a known-functional chipset, we disable the workaround
318feade919SMike Smith  * to improve speed.
319feade919SMike Smith  *
320d8a9fe36SMike Smith  * ] 20. ACPI Timer Errata
321d8a9fe36SMike Smith  * ]
322d8a9fe36SMike Smith  * ]   Problem: The power management timer may return improper result when
323d8a9fe36SMike Smith  * ]   read. Although the timer value settles properly after incrementing,
324d8a9fe36SMike Smith  * ]   while incrementing there is a 3nS window every 69.8nS where the
325d8a9fe36SMike Smith  * ]   timer value is indeterminate (a 4.2% chance that the data will be
326d8a9fe36SMike Smith  * ]   incorrect when read). As a result, the ACPI free running count up
327d8a9fe36SMike Smith  * ]   timer specification is violated due to erroneous reads.  Implication:
328d8a9fe36SMike Smith  * ]   System hangs due to the "inaccuracy" of the timer when used by
329d8a9fe36SMike Smith  * ]   software for time critical events and delays.
330d8a9fe36SMike Smith  * ]
331d8a9fe36SMike Smith  * ] Workaround: Read the register twice and compare.
332d8a9fe36SMike Smith  * ] Status: This will not be fixed in the PIIX4 or PIIX4E, it is fixed
333d8a9fe36SMike Smith  * ] in the PIIX4M.
334d8a9fe36SMike Smith  *
335d8a9fe36SMike Smith  * The counter is in other words not latched to the PCI bus clock when
336d8a9fe36SMike Smith  * read.  Notice the workaround isn't:  We need to read until we have
337d8a9fe36SMike Smith  * three monotonic samples and then use the middle one, otherwise we are
338d8a9fe36SMike Smith  * not protected against the fact that the bits can be wrong in two
339d8a9fe36SMike Smith  * directions.  If we only cared about monosity two reads would be enough.
340d8a9fe36SMike Smith  */
341d8a9fe36SMike Smith 
342cb877d00SPoul-Henning Kamp #if 0
343d8a9fe36SMike Smith static int	acpi_timer_pci_probe(device_t dev);
344d8a9fe36SMike Smith 
345d8a9fe36SMike Smith static device_method_t acpi_timer_pci_methods[] = {
346d8a9fe36SMike Smith     DEVMETHOD(device_probe,	acpi_timer_pci_probe),
347d8a9fe36SMike Smith     {0, 0}
348d8a9fe36SMike Smith };
349d8a9fe36SMike Smith 
350d8a9fe36SMike Smith static driver_t acpi_timer_pci_driver = {
351d8a9fe36SMike Smith     "acpi_timer_pci",
352d8a9fe36SMike Smith     acpi_timer_pci_methods,
353d8a9fe36SMike Smith     0,
354d8a9fe36SMike Smith };
355d8a9fe36SMike Smith 
356d8a9fe36SMike Smith devclass_t acpi_timer_pci_devclass;
357be2b1797SNate Lawson DRIVER_MODULE(acpi_timer_pci, pci, acpi_timer_pci_driver,
358be2b1797SNate Lawson 	      acpi_timer_pci_devclass, 0, 0);
359d8a9fe36SMike Smith 
360d8a9fe36SMike Smith /*
361feade919SMike Smith  * Look at PCI devices going past; if we detect one we know contains
362feade919SMike Smith  * a functional ACPI timer device, enable the faster timecounter read
363feade919SMike Smith  * routine.
364d8a9fe36SMike Smith  */
365d8a9fe36SMike Smith static int
366d8a9fe36SMike Smith acpi_timer_pci_probe(device_t dev)
367d8a9fe36SMike Smith {
368b2c98accSMike Smith     int vendor, device, revid;
369b2c98accSMike Smith 
370b2c98accSMike Smith     vendor = pci_get_vendor(dev);
371b2c98accSMike Smith     device = pci_get_device(dev);
372b2c98accSMike Smith     revid  = pci_get_revid(dev);
373b2c98accSMike Smith 
374be2b1797SNate Lawson     /* Detect the PIIX4M and i440MX, respectively */
375be2b1797SNate Lawson     if ((vendor == 0x8086 && device == 0x7113 && revid >= 0x03)	||
376be2b1797SNate Lawson 	(vendor == 0x8086 && device == 0x719b)) {
377b2c98accSMike Smith 
378feade919SMike Smith 	acpi_timer_timecounter.tc_get_timecount = acpi_timer_get_timecount;
379b2c98accSMike Smith 	acpi_timer_timecounter.tc_name = "ACPI-fast";
380be2b1797SNate Lawson 	if (bootverbose) {
381be2b1797SNate Lawson 	    device_printf(acpi_timer_dev,"functional ACPI timer detected, "
382be2b1797SNate Lawson 			  "enabling fast timecount interface\n");
383be2b1797SNate Lawson 	}
384d8a9fe36SMike Smith     }
385d8a9fe36SMike Smith 
386be2b1797SNate Lawson     /* We never match anything */
387be2b1797SNate Lawson     return (ENXIO);
388d8a9fe36SMike Smith }
389cb877d00SPoul-Henning Kamp #endif
390