Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 15 May 2007 12:09:35 +0900
From:      Takanori Watanabe <takawata@init-main.com>
To:        Nate Lawson <nate@root.org>
Cc:        acpi@freebsd.org
Subject:   Re: acpi_hpet not found
Message-ID:  <200705150309.l4F39Z9d021438@sana.init-main.com>
In-Reply-To: Your message of "Mon, 14 May 2007 14:28:00 MST." <4648D460.9040400@root.org>

next in thread | previous in thread | raw e-mail | index | archive | help
In message <4648D460.9040400@root.org>, Nate Lawson wrote:
>Takanori Watanabe wrote:
>> In message <200705142056.05598.h.schmalzbauer@omnisec.de>, Harald Schmalzbau
>er 
>> さんいわく:
>>> Hello,
>>>
>>> on my workstation the HPEtimer is not found, but it's enabled in 32-bit mod
>e 
>>> in BIOS, so I think there is one... It's a 965P (ich8) chipset.
>>>
>>> I can't find anything regarding HPET in tha man pages. Any hints?
>> 
>> Show your acpi tables. It may have to support HPET table.
>
>
>Here's what I got from his post:
>
>/*
>  HPET: Length=56, Revision=1, Checksum=232,
>	OEMID=GBT, OEM Table ID=GBTUACPI, OEM Revision=0x42302e31,
>	Creator ID=GBTU, Creator Revision=0x98
>	HPET Number=0
>	ADDR=0xfed00000:0[0] (Memory)	HW Rev=0x1
>	Comparitors=2
>	Counter Size=1
>	Legacy IRQ routing capable={TRUE}
>	PCI Vendor ID=0x8086
>	Minimal Tick=16
> */
>
>But he has no Device of type PNP0103.  So we need to implement
>table-based HPET probing, not just AML PNP probing.  This is similar to
>how we handle ECDT for the embedded controller.
>
>When we do that, we also need to work around the fact that the address
>bit width is wrong (0).

I have patch for this on RELENG_6.


Index: acpi.c
===================================================================
RCS file: /home/ncvs/src/sys/dev/acpica/acpi.c,v
retrieving revision 1.231
diff -u -r1.231 acpi.c
--- acpi.c	22 Feb 2007 05:59:23 -0000	1.231
+++ acpi.c	27 Mar 2007 17:34:39 -0000
@@ -480,6 +480,7 @@
      * a problem but should be addressed eventually.
      */
     acpi_ec_ecdt_probe(dev);
+    acpi_hpet_table_probe(dev);
 
     /* Bring device objects and regions online. */
     if (ACPI_FAILURE(status = AcpiInitializeObjects(flags))) {
Index: acpi_hpet.c
===================================================================
RCS file: /home/ncvs/src/sys/dev/acpica/acpi_hpet.c,v
retrieving revision 1.5
diff -u -r1.5 acpi_hpet.c
--- acpi_hpet.c	11 Aug 2006 17:12:16 -0000	1.5
+++ acpi_hpet.c	27 Mar 2007 17:33:58 -0000
@@ -40,6 +40,16 @@
 #include <dev/acpica/acpivar.h>
 
 ACPI_SERIAL_DECL(hpet, "ACPI HPET support");
+typedef struct {
+	ACPI_TABLE_HEADER	header;
+	UINT32 			id;
+	ACPI_GENERIC_ADDRESS	address;
+	UINT8			unit;
+	UINT16			clock_tick __packed;
+	UINT8			page_prot;
+}__packed ACPI_TABLE_HPET;
+
+static devclass_t acpi_hpet_devclass;
 
 /* ACPI CA debugging */
 #define _COMPONENT	ACPI_TIMER
@@ -77,17 +87,48 @@
 	sc = tc->tc_priv;
 	return (bus_read_4(sc->mem_res, HPET_OFFSET_VALUE));
 }
+#define DEV_HPET(x)		(acpi_get_magic(x) == (int)&acpi_hpet_devclass)
+void 
+acpi_hpet_table_probe(device_t parent)
+{
+	ACPI_TABLE_HPET *hpet;
+	ACPI_TABLE_HEADER *hdr;
+	ACPI_STATUS	status;
+	device_t	child;
+
+	/*Currently, id and minimam clock tick info. is discarded.*/
+
+	status = AcpiGetFirmwareTable("HPET", 1, ACPI_LOGICAL_ADDRESSING, &hdr);
+	hpet = (ACPI_TABLE_HPET *) hdr;
+	child = BUS_ADD_CHILD(parent, 0, "acpi_hpet", hpet->unit);
+	if (child == NULL) {
+		printf("%s: can't add child\n", __func__);
+		return;
+	}
+	
+	acpi_set_magic(child, (int)&acpi_hpet_devclass);
+	bus_set_resource(child, SYS_RES_MEMORY, 0, hpet->address.Address, HPET_MEM_WIDTH);
+	if(device_probe_and_attach(child) != 0)
+		device_delete_child(parent, child);
+}
 
 static int
 acpi_hpet_probe(device_t dev)
 {
 	ACPI_FUNCTION_TRACE((char *)(uintptr_t) __func__);
-
-	if (acpi_disabled("hpet") ||
-	    ACPI_ID_PROBE(device_get_parent(dev), dev, hpet_ids) == NULL ||
-	    device_get_unit(dev) != 0)
+	/*First of all, hpet hpet should not disabled.*/
+	if(acpi_disabled("hpet"))
+		return ENXIO;
+
+	/*Already knows */
+	if(DEV_HPET(dev)){
+		return 0;
+	}
+	
+	if (ACPI_ID_PROBE(device_get_parent(dev), dev, hpet_ids) == NULL ||
+	    devclass_get_device(acpi_hpet_devclass, device_get_unit(dev)))
 		return (ENXIO);
-
+	
 	device_set_desc(dev, "High Precision Event Timer");
 	return (0);
 }
@@ -198,7 +239,6 @@
 	sizeof(struct acpi_hpet_softc),
 };
 
-static devclass_t acpi_hpet_devclass;
 
 DRIVER_MODULE(acpi_hpet, acpi, acpi_hpet_driver, acpi_hpet_devclass, 0, 0);
 MODULE_DEPEND(acpi_hpet, acpi, 1, 1, 1);
Index: acpivar.h
===================================================================
RCS file: /home/ncvs/src/sys/dev/acpica/acpivar.h,v
retrieving revision 1.103
diff -u -r1.103 acpivar.h
--- acpivar.h	7 Jan 2007 21:53:42 -0000	1.103
+++ acpivar.h	27 Mar 2007 17:32:54 -0000
@@ -407,6 +407,8 @@
 
 /* Embedded controller. */
 void		acpi_ec_ecdt_probe(device_t);
+/* HPET table probe*/
+void		acpi_hpet_table_probe(device_t);
 
 /* AC adapter interface. */
 int		acpi_acad_get_acline(int *);

And the patch above has a minor bug.

Index: dev/acpica/acpi_hpet.c
===================================================================
RCS file: /home/tkato/cvs/kato-stable/sys/dev/acpica/acpi_hpet.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- dev/acpica/acpi_hpet.c	28 Mar 2007 10:37:42 -0000	1.2
+++ dev/acpica/acpi_hpet.c	28 Mar 2007 10:56:01 -0000	1.3
@@ -99,6 +99,9 @@
 	/*Currently, id and minimam clock tick info. is discarded.*/
 
 	status = AcpiGetFirmwareTable("HPET", 1, ACPI_LOGICAL_ADDRESSING, &hdr);
+	if (ACPI_FAILURE(status))
+	  return;
+
 	hpet = (ACPI_TABLE_HPET *) hdr;
 	child = BUS_ADD_CHILD(parent, 0, "acpi_hpet", hpet->unit);
 	if (child == NULL) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200705150309.l4F39Z9d021438>