xref: /freebsd/sys/dev/acpica/acpi_hpet.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
1f831d6e0SJohn Baldwin /*-
2f831d6e0SJohn Baldwin  * Copyright (c) 2005 Poul-Henning Kamp
3f831d6e0SJohn Baldwin  * All rights reserved.
4f831d6e0SJohn Baldwin  *
5f831d6e0SJohn Baldwin  * Redistribution and use in source and binary forms, with or without
6f831d6e0SJohn Baldwin  * modification, are permitted provided that the following conditions
7f831d6e0SJohn Baldwin  * are met:
8f831d6e0SJohn Baldwin  * 1. Redistributions of source code must retain the above copyright
9f831d6e0SJohn Baldwin  *    notice, this list of conditions and the following disclaimer.
10f831d6e0SJohn Baldwin  * 2. Redistributions in binary form must reproduce the above copyright
11f831d6e0SJohn Baldwin  *    notice, this list of conditions and the following disclaimer in the
12f831d6e0SJohn Baldwin  *    documentation and/or other materials provided with the distribution.
13f831d6e0SJohn Baldwin  *
14f831d6e0SJohn Baldwin  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15f831d6e0SJohn Baldwin  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16f831d6e0SJohn Baldwin  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17f831d6e0SJohn Baldwin  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18f831d6e0SJohn Baldwin  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19f831d6e0SJohn Baldwin  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20f831d6e0SJohn Baldwin  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21f831d6e0SJohn Baldwin  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22f831d6e0SJohn Baldwin  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23f831d6e0SJohn Baldwin  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24f831d6e0SJohn Baldwin  * SUCH DAMAGE.
25f831d6e0SJohn Baldwin  */
26f831d6e0SJohn Baldwin 
27f831d6e0SJohn Baldwin #ifndef __ACPI_HPET_H__
28f831d6e0SJohn Baldwin #define	__ACPI_HPET_H__
29f831d6e0SJohn Baldwin 
30f831d6e0SJohn Baldwin #define HPET_MEM_WIDTH		0x400	/* Expected memory region size */
31*964bf2f9SJohn F. Carr #define HPET_MEM_MIN_WIDTH	0x100	/* Minimum memory region size */
32f831d6e0SJohn Baldwin 
33f831d6e0SJohn Baldwin /* General registers */
34f831d6e0SJohn Baldwin #define HPET_CAPABILITIES	0x0	/* General capabilities and ID */
35f831d6e0SJohn Baldwin #define	HPET_CAP_VENDOR_ID	0xffff0000
36f831d6e0SJohn Baldwin #define	HPET_CAP_LEG_RT		0x00008000
37f831d6e0SJohn Baldwin #define	HPET_CAP_COUNT_SIZE	0x00002000 /* 1 = 64-bit, 0 = 32-bit */
38f831d6e0SJohn Baldwin #define	HPET_CAP_NUM_TIM	0x00001f00
39f831d6e0SJohn Baldwin #define	HPET_CAP_REV_ID		0x000000ff
40f831d6e0SJohn Baldwin #define HPET_PERIOD		0x4	/* Period (1/hz) of timer */
41f831d6e0SJohn Baldwin #define HPET_CONFIG		0x10	/* General configuration register */
42f831d6e0SJohn Baldwin #define	HPET_CNF_LEG_RT		0x00000002
43f831d6e0SJohn Baldwin #define	HPET_CNF_ENABLE		0x00000001
44f831d6e0SJohn Baldwin #define	HPET_ISR		0x20	/* General interrupt status register */
45f831d6e0SJohn Baldwin #define HPET_MAIN_COUNTER	0xf0	/* Main counter register */
46f831d6e0SJohn Baldwin 
47f831d6e0SJohn Baldwin /* Timer registers */
48f831d6e0SJohn Baldwin #define	HPET_TIMER_CAP_CNF(x)	((x) * 0x20 + 0x100)
49f831d6e0SJohn Baldwin #define	HPET_TCAP_INT_ROUTE	0xffffffff00000000
50f831d6e0SJohn Baldwin #define	HPET_TCAP_FSB_INT_DEL	0x00008000
51f831d6e0SJohn Baldwin #define	HPET_TCNF_FSB_EN	0x00004000
52f831d6e0SJohn Baldwin #define	HPET_TCNF_INT_ROUTE	0x00003e00
53f831d6e0SJohn Baldwin #define	HPET_TCNF_32MODE	0x00000100
54f831d6e0SJohn Baldwin #define	HPET_TCNF_VAL_SET	0x00000040
55f831d6e0SJohn Baldwin #define	HPET_TCAP_SIZE		0x00000020 /* 1 = 64-bit, 0 = 32-bit */
56f831d6e0SJohn Baldwin #define	HPET_TCAP_PER_INT	0x00000010 /* Supports periodic interrupts */
57f831d6e0SJohn Baldwin #define	HPET_TCNF_TYPE		0x00000008 /* 1 = periodic, 0 = one-shot */
58f831d6e0SJohn Baldwin #define	HPET_TCNF_INT_ENB	0x00000004
59875b8844SAlexander Motin #define	HPET_TCNF_INT_TYPE	0x00000002 /* 1 = level triggered, 0 = edge */
60f831d6e0SJohn Baldwin #define	HPET_TIMER_COMPARATOR(x) ((x) * 0x20 + 0x108)
61f831d6e0SJohn Baldwin #define	HPET_TIMER_FSB_VAL(x)	((x) * 0x20 + 0x110)
62f831d6e0SJohn Baldwin #define	HPET_TIMER_FSB_ADDR(x)	((x) * 0x20 + 0x114)
63f831d6e0SJohn Baldwin 
6498393876SAlexander Motin #define	HPET_MIN_CYCLES		128	/* Period considered reliable. */
6598393876SAlexander Motin 
6616808549SKonstantin Belousov #ifdef _KERNEL
6716808549SKonstantin Belousov struct timecounter;
6816808549SKonstantin Belousov struct vdso_timehands;
6916808549SKonstantin Belousov struct vdso_timehands32;
7016808549SKonstantin Belousov 
7116808549SKonstantin Belousov uint32_t hpet_vdso_timehands(struct vdso_timehands *vdso_th,
7216808549SKonstantin Belousov     struct timecounter *tc);
7316808549SKonstantin Belousov uint32_t hpet_vdso_timehands32(struct vdso_timehands32 *vdso_th32,
7416808549SKonstantin Belousov     struct timecounter *tc);
7516808549SKonstantin Belousov #endif
7616808549SKonstantin Belousov 
77f831d6e0SJohn Baldwin #endif /* !__ACPI_HPET_H__ */
78