Try to attach hpet(4) also via a specific HPET table. Fixes PR kern/43702.
This commit is contained in:
parent
8d08b790cc
commit
6e72689aa7
|
@ -1,4 +1,4 @@
|
|||
.\" $NetBSD: hpet.4,v 1.2 2011/03/13 04:58:55 jruoho Exp $
|
||||
.\" $NetBSD: hpet.4,v 1.3 2011/06/14 13:59:24 jruoho Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 2010 Jukka Ruohonen <jruohonen@iki.fi>
|
||||
.\" All rights reserved.
|
||||
|
@ -24,14 +24,15 @@
|
|||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd March 13, 2011
|
||||
.Dd June 14, 2011
|
||||
.Dt HPET 4 x86
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm hpet
|
||||
.Nd High Precision Event Timer
|
||||
.Sh SYNOPSIS
|
||||
.Cd "hpet* at acpi?"
|
||||
.Cd "hpet* at acpihpetbus?"
|
||||
.Cd "hpet* at acpinodebus?"
|
||||
.Cd "hpet* at amdpcib?"
|
||||
.Cd "hpet* at ichlpcib?"
|
||||
.Sh DESCRIPTION
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: GENERIC,v 1.319 2011/05/28 16:58:51 ryo Exp $
|
||||
# $NetBSD: GENERIC,v 1.320 2011/06/14 13:59:23 jruoho Exp $
|
||||
#
|
||||
# GENERIC machine description file
|
||||
#
|
||||
|
@ -22,7 +22,7 @@ include "arch/amd64/conf/std.amd64"
|
|||
|
||||
options INCLUDE_CONFIG_FILE # embed config file in kernel binary
|
||||
|
||||
#ident "GENERIC-$Revision: 1.319 $"
|
||||
#ident "GENERIC-$Revision: 1.320 $"
|
||||
|
||||
maxusers 64 # estimated number of users
|
||||
|
||||
|
@ -301,7 +301,8 @@ attimer* at acpi? # AT Timer
|
|||
fujbp* at acpi? # Fujitsu Brightness & Pointer
|
||||
fujhk* at acpi? # Fujitsu Hotkeys
|
||||
hpqlb* at acpi? # HP Quick Launch Buttons
|
||||
hpet* at acpi? # High Precision Event Timer
|
||||
hpet* at acpihpetbus? # High Precision Event Timer (table)
|
||||
hpet* at acpinodebus? # High Precision Event Timer (device)
|
||||
joy* at acpi? # Joystick/Game port
|
||||
#lpt* at acpi? # Parallel port
|
||||
mpu* at acpi? # Roland MPU-401 MIDI UART
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: ALL,v 1.307 2011/05/28 13:01:49 ryo Exp $
|
||||
# $NetBSD: ALL,v 1.308 2011/06/14 13:59:23 jruoho Exp $
|
||||
# From NetBSD: GENERIC,v 1.787 2006/10/01 18:37:54 bouyer Exp
|
||||
#
|
||||
# ALL machine description file
|
||||
|
@ -17,7 +17,7 @@ include "arch/i386/conf/std.i386"
|
|||
|
||||
options INCLUDE_CONFIG_FILE # embed config file in kernel binary
|
||||
|
||||
#ident "ALL-$Revision: 1.307 $"
|
||||
#ident "ALL-$Revision: 1.308 $"
|
||||
|
||||
maxusers 64 # estimated number of users
|
||||
|
||||
|
@ -377,7 +377,8 @@ fdc* at acpi? # Floppy disk controller
|
|||
fujbp* at acpi? # Fujitsu Brightness & Pointer
|
||||
fujhk* at acpi? # Fujitsu Hotkeys
|
||||
hpqlb* at acpi? # HP Quick Launch Buttons
|
||||
hpet* at acpi? # High Precision Event Timer
|
||||
hpet* at acpihpetbus? # High Precision Event Timer (table)
|
||||
hpet* at acpinodebus? # High Precision Event Timer (device)
|
||||
joy* at acpi? # Joystick/Game port
|
||||
lpt* at acpi? # Parallel port
|
||||
mpu* at acpi? # Roland MPU-401 MIDI UART
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: GENERIC,v 1.1032 2011/05/28 13:01:49 ryo Exp $
|
||||
# $NetBSD: GENERIC,v 1.1033 2011/06/14 13:59:23 jruoho Exp $
|
||||
#
|
||||
# GENERIC machine description file
|
||||
#
|
||||
|
@ -22,7 +22,7 @@ include "arch/i386/conf/std.i386"
|
|||
|
||||
options INCLUDE_CONFIG_FILE # embed config file in kernel binary
|
||||
|
||||
#ident "GENERIC-$Revision: 1.1032 $"
|
||||
#ident "GENERIC-$Revision: 1.1033 $"
|
||||
|
||||
maxusers 64 # estimated number of users
|
||||
|
||||
|
@ -366,7 +366,8 @@ attimer* at acpi? # AT Timer
|
|||
fujbp* at acpi? # Fujitsu Brightness & Pointer
|
||||
fujhk* at acpi? # Fujitsu Hotkeys
|
||||
hpqlb* at acpi? # HP Quick Launch Buttons
|
||||
hpet* at acpi? # High Precision Event Timer
|
||||
hpet* at acpihpetbus? # High Precision Event Timer (table)
|
||||
hpet* at acpinodebus? # High Precision Event Timer (device)
|
||||
joy* at acpi? # Joystick/Game port
|
||||
#lpt* at acpi? # Parallel port
|
||||
mpu* at acpi? # Roland MPU-401 MIDI UART
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: acpi.c,v 1.244 2011/06/13 09:37:23 jruoho Exp $ */
|
||||
/* $NetBSD: acpi.c,v 1.245 2011/06/14 13:59:23 jruoho Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2003, 2007 The NetBSD Foundation, Inc.
|
||||
|
@ -100,7 +100,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: acpi.c,v 1.244 2011/06/13 09:37:23 jruoho Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: acpi.c,v 1.245 2011/06/14 13:59:23 jruoho Exp $");
|
||||
|
||||
#include "opt_acpi.h"
|
||||
#include "opt_pcifixup.h"
|
||||
|
@ -554,6 +554,9 @@ acpi_childdet(device_t self, device_t child)
|
|||
if (sc->sc_apmbus == child)
|
||||
sc->sc_apmbus = NULL;
|
||||
|
||||
if (sc->sc_hpet == child)
|
||||
sc->sc_hpet = NULL;
|
||||
|
||||
if (sc->sc_wdrt == child)
|
||||
sc->sc_wdrt = NULL;
|
||||
|
||||
|
@ -752,6 +755,16 @@ static int
|
|||
acpi_rescan(device_t self, const char *ifattr, const int *locators)
|
||||
{
|
||||
struct acpi_softc *sc = device_private(self);
|
||||
struct acpi_attach_args aa;
|
||||
|
||||
/*
|
||||
* Try to attach hpet(4) first via a specific table.
|
||||
*/
|
||||
aa.aa_memt = sc->sc_memt;
|
||||
|
||||
if (ifattr_match(ifattr, "acpihpetbus") && sc->sc_hpet == NULL)
|
||||
sc->sc_hpet = config_found_ia(sc->sc_dev,
|
||||
"acpihpetbus", &aa, NULL);
|
||||
|
||||
/*
|
||||
* A two-pass scan for acpinodebus.
|
||||
|
@ -761,6 +774,9 @@ acpi_rescan(device_t self, const char *ifattr, const int *locators)
|
|||
acpi_rescan_nodes(sc);
|
||||
}
|
||||
|
||||
/*
|
||||
* Attach APM emulation and acpiwdrt(4).
|
||||
*/
|
||||
if (ifattr_match(ifattr, "acpiapmbus") && sc->sc_apmbus == NULL)
|
||||
sc->sc_apmbus = config_found_ia(sc->sc_dev,
|
||||
"acpiapmbus", NULL, NULL);
|
||||
|
@ -810,6 +826,7 @@ acpi_rescan_early(struct acpi_softc *sc)
|
|||
static void
|
||||
acpi_rescan_nodes(struct acpi_softc *sc)
|
||||
{
|
||||
const char * const hpet_ids[] = { "PNP0103", NULL };
|
||||
struct acpi_attach_args aa;
|
||||
struct acpi_devnode *ad;
|
||||
ACPI_DEVICE_INFO *di;
|
||||
|
@ -855,6 +872,9 @@ acpi_rescan_nodes(struct acpi_softc *sc)
|
|||
if (acpi_match_hid(di, acpi_ignored_ids) != 0)
|
||||
continue;
|
||||
|
||||
if (acpi_match_hid(di, hpet_ids) != 0 && sc->sc_hpet != NULL)
|
||||
continue;
|
||||
|
||||
aa.aa_node = ad;
|
||||
aa.aa_iot = sc->sc_iot;
|
||||
aa.aa_memt = sc->sc_memt;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: acpivar.h,v 1.69 2011/02/20 06:45:32 jruoho Exp $ */
|
||||
/* $NetBSD: acpivar.h,v 1.70 2011/06/14 13:59:23 jruoho Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 2001 Wasabi Systems, Inc.
|
||||
|
@ -149,8 +149,8 @@ struct acpi_devnode {
|
|||
struct acpi_softc {
|
||||
device_t sc_dev; /* base device info */
|
||||
device_t sc_apmbus; /* APM pseudo-bus */
|
||||
|
||||
device_t sc_wdrt; /* WDRT watchdog */
|
||||
device_t sc_hpet; /* hpet(4) pseudo-bus */
|
||||
device_t sc_wdrt; /* acpiwdrt(4) pseudo-bus */
|
||||
|
||||
struct acpi_devnode *sc_root; /* root of the device tree */
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: files.acpi,v 1.89 2011/06/12 07:25:43 jruoho Exp $
|
||||
# $NetBSD: files.acpi,v 1.90 2011/06/14 13:59:23 jruoho Exp $
|
||||
|
||||
include "dev/acpi/acpica/files.acpica"
|
||||
|
||||
|
@ -10,9 +10,10 @@ defparam opt_acpi.h ACPI_BLACKLIST_YEAR = 2000
|
|||
define acpiapmbus { }
|
||||
define acpinodebus { }
|
||||
define acpiecdtbus { }
|
||||
define acpihpetbus { }
|
||||
define acpiwdrtbus { }
|
||||
|
||||
device acpi: acpica, acpiapmbus, acpinodebus, acpiecdtbus, acpiwdrtbus, sysmon_power, sysmon_taskq
|
||||
device acpi: acpica, acpiapmbus, acpinodebus, acpiecdtbus, acpihpetbus, acpiwdrtbus, sysmon_power, sysmon_taskq
|
||||
attach acpi at acpibus
|
||||
file dev/acpi/acpi.c acpi
|
||||
file dev/acpi/acpi_debug.c acpi
|
||||
|
@ -130,8 +131,9 @@ attach ym at acpinodebus with ym_acpi
|
|||
file dev/acpi/ym_acpi.c ym_acpi
|
||||
|
||||
# High Precision Event Timer
|
||||
attach hpet at acpinodebus with hpet_acpi
|
||||
file dev/acpi/hpet_acpi.c hpet_acpi
|
||||
attach hpet at acpinodebus with hpet_acpi_dev
|
||||
attach hpet at acpihpetbus with hpet_acpi_tab
|
||||
file dev/acpi/hpet_acpi.c hpet_acpi_dev|hpet_acpi_tab
|
||||
|
||||
# ASUS hotkey device
|
||||
device asus: sysmon_envsys, sysmon_power
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $NetBSD: hpet_acpi.c,v 1.5 2010/03/05 14:00:17 jruoho Exp $ */
|
||||
/* $NetBSD: hpet_acpi.c,v 1.6 2011/06/14 13:59:23 jruoho Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006 Nicolas Joly
|
||||
* Copyright (c) 2006, 2011 Nicolas Joly
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -27,41 +27,91 @@
|
|||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: hpet_acpi.c,v 1.5 2010/03/05 14:00:17 jruoho Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: hpet_acpi.c,v 1.6 2011/06/14 13:59:23 jruoho Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/device.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/timetc.h>
|
||||
|
||||
#include <dev/acpi/acpivar.h>
|
||||
|
||||
#include <dev/ic/hpetvar.h>
|
||||
|
||||
static int hpet_acpi_match(device_t, cfdata_t, void *);
|
||||
static void hpet_acpi_attach(device_t, device_t, void *);
|
||||
#define _COMPONENT ACPI_RESOURCE_COMPONENT
|
||||
ACPI_MODULE_NAME ("acpi_hpet")
|
||||
|
||||
#define HPET_MEM_WIDTH 0x3ff /* Expected memory region size. */
|
||||
|
||||
CFATTACH_DECL_NEW(hpet_acpi, sizeof(struct hpet_softc), hpet_acpi_match,
|
||||
hpet_acpi_attach, NULL, NULL);
|
||||
|
||||
/*
|
||||
* Supported device IDs
|
||||
*/
|
||||
static int hpet_acpi_dev_match(device_t, cfdata_t, void *);
|
||||
static void hpet_acpi_dev_attach(device_t, device_t, void *);
|
||||
static int hpet_acpi_tab_match(device_t, cfdata_t, void *);
|
||||
static void hpet_acpi_tab_attach(device_t, device_t, void *);
|
||||
|
||||
static const char * const hpet_acpi_ids[] = {
|
||||
"PNP0103",
|
||||
NULL
|
||||
NULL
|
||||
};
|
||||
|
||||
/*
|
||||
* hpet_acpi_match: autoconf(9) match routine
|
||||
*/
|
||||
CFATTACH_DECL_NEW(hpet_acpi_tab, sizeof(struct hpet_softc),
|
||||
hpet_acpi_tab_match, hpet_acpi_tab_attach, NULL, NULL);
|
||||
|
||||
CFATTACH_DECL_NEW(hpet_acpi_dev, sizeof(struct hpet_softc),
|
||||
hpet_acpi_dev_match, hpet_acpi_dev_attach, NULL, NULL);
|
||||
|
||||
static int
|
||||
hpet_acpi_match(device_t parent, cfdata_t match, void *aux)
|
||||
hpet_acpi_tab_match(device_t parent, cfdata_t match, void *aux)
|
||||
{
|
||||
ACPI_TABLE_HPET *hpet;
|
||||
ACPI_STATUS rv;
|
||||
|
||||
rv = AcpiGetTable(ACPI_SIG_HPET, 1, (ACPI_TABLE_HEADER **)&hpet);
|
||||
|
||||
if (ACPI_FAILURE(rv))
|
||||
return 0;
|
||||
|
||||
if (hpet->Address.Address == 0)
|
||||
return 0;
|
||||
|
||||
if (hpet->Address.SpaceId != ACPI_ADR_SPACE_SYSTEM_MEMORY)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
hpet_acpi_tab_attach(device_t parent, device_t self, void *aux)
|
||||
{
|
||||
struct hpet_softc *sc = device_private(self);
|
||||
struct acpi_attach_args *aa = aux;
|
||||
ACPI_TABLE_HPET *hpet;
|
||||
ACPI_STATUS rv;
|
||||
|
||||
rv = AcpiGetTable(ACPI_SIG_HPET, 1, (ACPI_TABLE_HEADER **)&hpet);
|
||||
|
||||
if (ACPI_FAILURE(rv))
|
||||
return;
|
||||
|
||||
sc->sc_memt = aa->aa_memt;
|
||||
|
||||
if (hpet->Address.Address == 0xfed0000000000000UL) /* A quirk. */
|
||||
hpet->Address.Address >>= 32;
|
||||
|
||||
if (bus_space_map(sc->sc_memt, hpet->Address.Address,
|
||||
HPET_MEM_WIDTH, 0, &sc->sc_memh) != 0) {
|
||||
aprint_error(": failed to map mem space\n");
|
||||
return;
|
||||
}
|
||||
|
||||
aprint_naive("\n");
|
||||
aprint_normal(": mem 0x%"PRIx64"-0x%"PRIx64"\n",
|
||||
hpet->Address.Address, hpet->Address.Address + HPET_MEM_WIDTH);
|
||||
|
||||
hpet_attach_subr(self);
|
||||
}
|
||||
|
||||
static int
|
||||
hpet_acpi_dev_match(device_t parent, cfdata_t match, void *aux)
|
||||
{
|
||||
struct acpi_attach_args *aa = aux;
|
||||
|
||||
|
@ -72,7 +122,7 @@ hpet_acpi_match(device_t parent, cfdata_t match, void *aux)
|
|||
}
|
||||
|
||||
static void
|
||||
hpet_acpi_attach(device_t parent, device_t self, void *aux)
|
||||
hpet_acpi_dev_attach(device_t parent, device_t self, void *aux)
|
||||
{
|
||||
struct hpet_softc *sc = device_private(self);
|
||||
struct acpi_attach_args *aa = aux;
|
||||
|
@ -80,29 +130,34 @@ hpet_acpi_attach(device_t parent, device_t self, void *aux)
|
|||
struct acpi_mem *mem;
|
||||
ACPI_STATUS rv;
|
||||
|
||||
/* parse resources */
|
||||
rv = acpi_resource_parse(self, aa->aa_node->ad_handle, "_CRS",
|
||||
&res, &acpi_resource_parse_ops_default);
|
||||
|
||||
if (ACPI_FAILURE(rv))
|
||||
return;
|
||||
|
||||
/* find our mem registers */
|
||||
mem = acpi_res_mem(&res, 0);
|
||||
|
||||
if (mem == NULL) {
|
||||
aprint_error_dev(self,
|
||||
"unable to find mem register resource\n");
|
||||
aprint_error(": failed to find mem resource\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (mem->ar_length < HPET_MEM_WIDTH) {
|
||||
aprint_error(": invalid memory region size\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
sc->sc_memt = aa->aa_memt;
|
||||
if (bus_space_map(sc->sc_memt, mem->ar_base, mem->ar_length,
|
||||
0, &sc->sc_memh)) {
|
||||
aprint_error_dev(self, "can't map mem space\n");
|
||||
|
||||
if (bus_space_map(sc->sc_memt, mem->ar_base,
|
||||
mem->ar_length, 0, &sc->sc_memh) != 0) {
|
||||
aprint_error(": failed to map mem space\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
hpet_attach_subr(self);
|
||||
|
||||
out:
|
||||
out:
|
||||
acpi_resource_cleanup(&res);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue