xref: /freebsd/sys/dev/acpica/acpi_timer.c (revision 64278df5e02bfd3061b58440a695339ec48c2785)
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);
9064278df5SNate Lawson MODULE_DEPEND(acpi_timer, acpi, 1, 1, 1);
9115e32d5dSMike Smith 
92787fa5b8SMike Smith static struct timecounter acpi_timer_timecounter = {
93feade919SMike Smith 	acpi_timer_get_timecount_safe,
94787fa5b8SMike Smith 	0,
95787fa5b8SMike Smith 	0xffffff,
96787fa5b8SMike Smith 	0,
9778a49a45SPoul-Henning Kamp 	"ACPI",
9878a49a45SPoul-Henning Kamp 	1000
99787fa5b8SMike Smith };
100787fa5b8SMike Smith 
101be2b1797SNate Lawson static uint32_t
102214475d8SMarcel Moolenaar read_counter()
103214475d8SMarcel Moolenaar {
104214475d8SMarcel Moolenaar     bus_space_handle_t bsh;
105214475d8SMarcel Moolenaar     bus_space_tag_t bst;
106214475d8SMarcel Moolenaar     u_int32_t tv;
107214475d8SMarcel Moolenaar 
108214475d8SMarcel Moolenaar     bsh = rman_get_bushandle(acpi_timer_reg);
109214475d8SMarcel Moolenaar     bst = rman_get_bustag(acpi_timer_reg);
110214475d8SMarcel Moolenaar     tv = bus_space_read_4(bst, bsh, 0);
111214475d8SMarcel Moolenaar     bus_space_barrier(bst, bsh, 0, 4, BUS_SPACE_BARRIER_READ);
112be2b1797SNate Lawson 
113214475d8SMarcel Moolenaar     return (tv);
114214475d8SMarcel Moolenaar }
115cb877d00SPoul-Henning Kamp 
116cb877d00SPoul-Henning Kamp #define N 2000
117cb877d00SPoul-Henning Kamp static int
118cb877d00SPoul-Henning Kamp test_counter()
119cb877d00SPoul-Henning Kamp {
120be2b1797SNate Lawson     u_int	last, this;
121cb877d00SPoul-Henning Kamp     int		min, max, n, delta;
122cb877d00SPoul-Henning Kamp 
123cb877d00SPoul-Henning Kamp     min = 10000000;
124cb877d00SPoul-Henning Kamp     max = 0;
125214475d8SMarcel Moolenaar     last = read_counter();
126cb877d00SPoul-Henning Kamp     for (n = 0; n < N; n++) {
127214475d8SMarcel Moolenaar 	this = read_counter();
128cb877d00SPoul-Henning Kamp 	delta = (this - last) & 0xffffff;
129cb877d00SPoul-Henning Kamp 	if (delta > max)
130cb877d00SPoul-Henning Kamp 	    max = delta;
131cb877d00SPoul-Henning Kamp 	else if (delta < min)
132cb877d00SPoul-Henning Kamp 	    min = delta;
133cb877d00SPoul-Henning Kamp 	last = this;
134cb877d00SPoul-Henning Kamp     }
135cb877d00SPoul-Henning Kamp     if (max - min > 2)
136cb877d00SPoul-Henning Kamp 	n = 0;
137214475d8SMarcel Moolenaar     else if (min < 0 || max == 0)
138cb877d00SPoul-Henning Kamp 	n = 0;
139cb877d00SPoul-Henning Kamp     else
140cb877d00SPoul-Henning Kamp 	n = 1;
141be2b1797SNate Lawson     if (bootverbose) {
142cb877d00SPoul-Henning Kamp 	printf("ACPI timer looks %s min = %d, max = %d, width = %d\n",
143cb877d00SPoul-Henning Kamp 		n ? "GOOD" : "BAD ",
144214475d8SMarcel Moolenaar 		min, max, max - min);
145be2b1797SNate Lawson     }
146be2b1797SNate Lawson 
147cb877d00SPoul-Henning Kamp     return (n);
148cb877d00SPoul-Henning Kamp }
149be2b1797SNate Lawson #undef N
150787fa5b8SMike Smith 
151787fa5b8SMike Smith /*
152787fa5b8SMike Smith  * Locate the ACPI timer using the FADT, set up and allocate the I/O resources
153787fa5b8SMike Smith  * we will be using.
154787fa5b8SMike Smith  */
15515e32d5dSMike Smith static void
15615e32d5dSMike Smith acpi_timer_identify(driver_t *driver, device_t parent)
15715e32d5dSMike Smith {
15815e32d5dSMike Smith     device_t	dev;
15915e32d5dSMike Smith     char	desc[40];
160214475d8SMarcel Moolenaar     u_long	rlen, rstart;
161214475d8SMarcel Moolenaar     int		i, j, rid, rtype;
16215e32d5dSMike Smith 
163b4a05238SPeter Wemm     ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
1640ae55423SMike Smith 
165be2b1797SNate Lawson     if (acpi_disabled("timer") || AcpiGbl_FADT == NULL)
1660ae55423SMike Smith 	return_VOID;
16715e32d5dSMike Smith 
16815e32d5dSMike Smith     if ((dev = BUS_ADD_CHILD(parent, 0, "acpi_timer", 0)) == NULL) {
16915e32d5dSMike Smith 	device_printf(parent, "could not add acpi_timer0\n");
1700ae55423SMike Smith 	return_VOID;
17115e32d5dSMike Smith     }
172787fa5b8SMike Smith     acpi_timer_dev = dev;
173214475d8SMarcel Moolenaar 
174787fa5b8SMike Smith     rid = 0;
175214475d8SMarcel Moolenaar     rlen = AcpiGbl_FADT->PmTmLen;
176214475d8SMarcel Moolenaar     rtype = (AcpiGbl_FADT->XPmTmrBlk.AddressSpaceId)
177214475d8SMarcel Moolenaar       ? SYS_RES_IOPORT : SYS_RES_MEMORY;
178214475d8SMarcel Moolenaar     rstart = AcpiGbl_FADT->XPmTmrBlk.Address;
179214475d8SMarcel Moolenaar     bus_set_resource(dev, rtype, rid, rstart, rlen);
1805f96beb9SNate Lawson     acpi_timer_reg = bus_alloc_resource_any(dev, rtype, &rid, RF_ACTIVE);
181214475d8SMarcel Moolenaar     if (acpi_timer_reg == NULL) {
182214475d8SMarcel Moolenaar 	device_printf(dev, "couldn't allocate I/O resource (%s 0x%lx)\n",
183be2b1797SNate Lawson 		      rtype == SYS_RES_IOPORT ? "port" : "mem", rstart);
1840ae55423SMike Smith 	return_VOID;
18515e32d5dSMike Smith     }
186d786139cSMaxime Henrion     if (testenv("debug.acpi.timer_test"))
187787fa5b8SMike Smith 	acpi_timer_test();
188787fa5b8SMike Smith 
189787fa5b8SMike Smith     acpi_timer_timecounter.tc_frequency = acpi_timer_frequency;
190cb877d00SPoul-Henning Kamp     j = 0;
191cb877d00SPoul-Henning Kamp     for(i = 0; i < 10; i++)
192cb877d00SPoul-Henning Kamp 	j += test_counter();
193cb877d00SPoul-Henning Kamp     if (j == 10) {
194cb877d00SPoul-Henning Kamp 	acpi_timer_timecounter.tc_name = "ACPI-fast";
195cb877d00SPoul-Henning Kamp 	acpi_timer_timecounter.tc_get_timecount = acpi_timer_get_timecount;
196cb877d00SPoul-Henning Kamp     } else {
197cb877d00SPoul-Henning Kamp 	acpi_timer_timecounter.tc_name = "ACPI-safe";
198cb877d00SPoul-Henning Kamp 	acpi_timer_timecounter.tc_get_timecount = acpi_timer_get_timecount_safe;
199cb877d00SPoul-Henning Kamp     }
200787fa5b8SMike Smith     tc_init(&acpi_timer_timecounter);
20115e32d5dSMike Smith 
202be2b1797SNate Lawson     sprintf(desc, "%d-bit timer at 3.579545MHz",
203be2b1797SNate Lawson 	    AcpiGbl_FADT->TmrValExt ? 32 : 24);
20415e32d5dSMike Smith     device_set_desc_copy(dev, desc);
2050ae55423SMike Smith 
2060ae55423SMike Smith     return_VOID;
20715e32d5dSMike Smith }
20815e32d5dSMike Smith 
20915e32d5dSMike Smith static int
21015e32d5dSMike Smith acpi_timer_probe(device_t dev)
21115e32d5dSMike Smith {
212787fa5b8SMike Smith     if (dev == acpi_timer_dev)
21315e32d5dSMike Smith 	return (0);
214be2b1797SNate Lawson 
21515e32d5dSMike Smith     return (ENXIO);
21615e32d5dSMike Smith }
21715e32d5dSMike Smith 
21815e32d5dSMike Smith static int
21915e32d5dSMike Smith acpi_timer_attach(device_t dev)
22015e32d5dSMike Smith {
221787fa5b8SMike Smith     return (0);
22215e32d5dSMike Smith }
223787fa5b8SMike Smith 
224787fa5b8SMike Smith /*
225feade919SMike Smith  * Fetch current time value from reliable hardware.
226787fa5b8SMike Smith  */
227787fa5b8SMike Smith static unsigned
228787fa5b8SMike Smith acpi_timer_get_timecount(struct timecounter *tc)
229787fa5b8SMike Smith {
230214475d8SMarcel Moolenaar     return (read_counter());
231787fa5b8SMike Smith }
232787fa5b8SMike Smith 
233787fa5b8SMike Smith /*
234feade919SMike Smith  * Fetch current time value from hardware that may not correctly
235feade919SMike Smith  * latch the counter.
236feade919SMike Smith  */
237feade919SMike Smith static unsigned
238feade919SMike Smith acpi_timer_get_timecount_safe(struct timecounter *tc)
239feade919SMike Smith {
240feade919SMike Smith     unsigned u1, u2, u3;
241feade919SMike Smith 
242214475d8SMarcel Moolenaar     u2 = read_counter();
243214475d8SMarcel Moolenaar     u3 = read_counter();
244feade919SMike Smith     do {
245feade919SMike Smith 	u1 = u2;
246feade919SMike Smith 	u2 = u3;
247214475d8SMarcel Moolenaar 	u3 = read_counter();
248be2b1797SNate Lawson     } while (u1 > u2 || u2 > u3 || u3 - u1 > 15);
249be2b1797SNate Lawson 
250feade919SMike Smith     return (u2);
251feade919SMike Smith }
252feade919SMike Smith 
253feade919SMike Smith /*
254787fa5b8SMike Smith  * Timecounter freqency adjustment interface.
255787fa5b8SMike Smith  */
256787fa5b8SMike Smith static int
257787fa5b8SMike Smith acpi_timer_sysctl_freq(SYSCTL_HANDLER_ARGS)
258787fa5b8SMike Smith {
259787fa5b8SMike Smith     int error;
260787fa5b8SMike Smith     u_int freq;
261787fa5b8SMike Smith 
262787fa5b8SMike Smith     if (acpi_timer_timecounter.tc_frequency == 0)
263787fa5b8SMike Smith 	return (EOPNOTSUPP);
264787fa5b8SMike Smith     freq = acpi_timer_frequency;
265787fa5b8SMike Smith     error = sysctl_handle_int(oidp, &freq, sizeof(freq), req);
266787fa5b8SMike Smith     if (error == 0 && req->newptr != NULL) {
267787fa5b8SMike Smith 	acpi_timer_frequency = freq;
268787fa5b8SMike Smith 	acpi_timer_timecounter.tc_frequency = acpi_timer_frequency;
269787fa5b8SMike Smith     }
270be2b1797SNate Lawson 
271787fa5b8SMike Smith     return (error);
272787fa5b8SMike Smith }
273787fa5b8SMike Smith 
274787fa5b8SMike Smith SYSCTL_PROC(_machdep, OID_AUTO, acpi_timer_freq, CTLTYPE_INT | CTLFLAG_RW,
275787fa5b8SMike Smith 	    0, sizeof(u_int), acpi_timer_sysctl_freq, "I", "");
276787fa5b8SMike Smith 
277787fa5b8SMike Smith /*
278787fa5b8SMike Smith  * Test harness for verifying ACPI timer behaviour.
279787fa5b8SMike Smith  * Boot with debug.acpi.timer_test set to invoke this.
280787fa5b8SMike Smith  */
281787fa5b8SMike Smith static void
282787fa5b8SMike Smith acpi_timer_test(void)
283787fa5b8SMike Smith {
284787fa5b8SMike Smith     u_int32_t	u1, u2, u3;
285787fa5b8SMike Smith 
286214475d8SMarcel Moolenaar     u1 = read_counter();
287214475d8SMarcel Moolenaar     u2 = read_counter();
288214475d8SMarcel Moolenaar     u3 = read_counter();
289787fa5b8SMike Smith 
290787fa5b8SMike Smith     device_printf(acpi_timer_dev, "timer test in progress, reboot to quit.\n");
291787fa5b8SMike Smith     for (;;) {
292787fa5b8SMike Smith 	/*
293be2b1797SNate Lawson 	 * The failure case is where u3 > u1, but u2 does not fall between
294be2b1797SNate Lawson 	 * the two, ie. it contains garbage.
295787fa5b8SMike Smith 	 */
296787fa5b8SMike Smith 	if (u3 > u1) {
297be2b1797SNate Lawson 	    if (u2 < u1 || u2 > u3)
298be2b1797SNate Lawson 		device_printf(acpi_timer_dev,
299be2b1797SNate Lawson 			      "timer is not monotonic: 0x%08x,0x%08x,0x%08x\n",
300787fa5b8SMike Smith 			      u1, u2, u3);
301787fa5b8SMike Smith 	}
302787fa5b8SMike Smith 	u1 = u2;
303787fa5b8SMike Smith 	u2 = u3;
304214475d8SMarcel Moolenaar 	u3 = read_counter();
305787fa5b8SMike Smith     }
306787fa5b8SMike Smith }
307787fa5b8SMike Smith 
308d8a9fe36SMike Smith /*
309d8a9fe36SMike Smith  * Chipset workaround driver hung off PCI.
310d8a9fe36SMike Smith  *
311feade919SMike Smith  * Some ACPI timers are known or believed to suffer from implementation
312feade919SMike Smith  * problems which can lead to erroneous values being read from the timer.
313feade919SMike Smith  *
314feade919SMike Smith  * Since we can't trust unknown chipsets, we default to a timer-read
315feade919SMike Smith  * routine which compensates for the most common problem (as detailed
316feade919SMike Smith  * in the excerpt from the Intel PIIX4 datasheet below).
317feade919SMike Smith  *
318feade919SMike Smith  * When we detect a known-functional chipset, we disable the workaround
319feade919SMike Smith  * to improve speed.
320feade919SMike Smith  *
321d8a9fe36SMike Smith  * ] 20. ACPI Timer Errata
322d8a9fe36SMike Smith  * ]
323d8a9fe36SMike Smith  * ]   Problem: The power management timer may return improper result when
324d8a9fe36SMike Smith  * ]   read. Although the timer value settles properly after incrementing,
325d8a9fe36SMike Smith  * ]   while incrementing there is a 3nS window every 69.8nS where the
326d8a9fe36SMike Smith  * ]   timer value is indeterminate (a 4.2% chance that the data will be
327d8a9fe36SMike Smith  * ]   incorrect when read). As a result, the ACPI free running count up
328d8a9fe36SMike Smith  * ]   timer specification is violated due to erroneous reads.  Implication:
329d8a9fe36SMike Smith  * ]   System hangs due to the "inaccuracy" of the timer when used by
330d8a9fe36SMike Smith  * ]   software for time critical events and delays.
331d8a9fe36SMike Smith  * ]
332d8a9fe36SMike Smith  * ] Workaround: Read the register twice and compare.
333d8a9fe36SMike Smith  * ] Status: This will not be fixed in the PIIX4 or PIIX4E, it is fixed
334d8a9fe36SMike Smith  * ] in the PIIX4M.
335d8a9fe36SMike Smith  *
336d8a9fe36SMike Smith  * The counter is in other words not latched to the PCI bus clock when
337d8a9fe36SMike Smith  * read.  Notice the workaround isn't:  We need to read until we have
338d8a9fe36SMike Smith  * three monotonic samples and then use the middle one, otherwise we are
339d8a9fe36SMike Smith  * not protected against the fact that the bits can be wrong in two
340d8a9fe36SMike Smith  * directions.  If we only cared about monosity two reads would be enough.
341d8a9fe36SMike Smith  */
342d8a9fe36SMike Smith 
343cb877d00SPoul-Henning Kamp #if 0
344d8a9fe36SMike Smith static int	acpi_timer_pci_probe(device_t dev);
345d8a9fe36SMike Smith 
346d8a9fe36SMike Smith static device_method_t acpi_timer_pci_methods[] = {
347d8a9fe36SMike Smith     DEVMETHOD(device_probe,	acpi_timer_pci_probe),
348d8a9fe36SMike Smith     {0, 0}
349d8a9fe36SMike Smith };
350d8a9fe36SMike Smith 
351d8a9fe36SMike Smith static driver_t acpi_timer_pci_driver = {
352d8a9fe36SMike Smith     "acpi_timer_pci",
353d8a9fe36SMike Smith     acpi_timer_pci_methods,
354d8a9fe36SMike Smith     0,
355d8a9fe36SMike Smith };
356d8a9fe36SMike Smith 
357d8a9fe36SMike Smith devclass_t acpi_timer_pci_devclass;
358be2b1797SNate Lawson DRIVER_MODULE(acpi_timer_pci, pci, acpi_timer_pci_driver,
359be2b1797SNate Lawson 	      acpi_timer_pci_devclass, 0, 0);
360d8a9fe36SMike Smith 
361d8a9fe36SMike Smith /*
362feade919SMike Smith  * Look at PCI devices going past; if we detect one we know contains
363feade919SMike Smith  * a functional ACPI timer device, enable the faster timecounter read
364feade919SMike Smith  * routine.
365d8a9fe36SMike Smith  */
366d8a9fe36SMike Smith static int
367d8a9fe36SMike Smith acpi_timer_pci_probe(device_t dev)
368d8a9fe36SMike Smith {
369b2c98accSMike Smith     int vendor, device, revid;
370b2c98accSMike Smith 
371b2c98accSMike Smith     vendor = pci_get_vendor(dev);
372b2c98accSMike Smith     device = pci_get_device(dev);
373b2c98accSMike Smith     revid  = pci_get_revid(dev);
374b2c98accSMike Smith 
375be2b1797SNate Lawson     /* Detect the PIIX4M and i440MX, respectively */
376be2b1797SNate Lawson     if ((vendor == 0x8086 && device == 0x7113 && revid >= 0x03)	||
377be2b1797SNate Lawson 	(vendor == 0x8086 && device == 0x719b)) {
378b2c98accSMike Smith 
379feade919SMike Smith 	acpi_timer_timecounter.tc_get_timecount = acpi_timer_get_timecount;
380b2c98accSMike Smith 	acpi_timer_timecounter.tc_name = "ACPI-fast";
381be2b1797SNate Lawson 	if (bootverbose) {
382be2b1797SNate Lawson 	    device_printf(acpi_timer_dev,"functional ACPI timer detected, "
383be2b1797SNate Lawson 			  "enabling fast timecount interface\n");
384be2b1797SNate Lawson 	}
385d8a9fe36SMike Smith     }
386d8a9fe36SMike Smith 
387be2b1797SNate Lawson     /* We never match anything */
388be2b1797SNate Lawson     return (ENXIO);
389d8a9fe36SMike Smith }
390cb877d00SPoul-Henning Kamp #endif
391