From owner-acpi-jp@jp.freebsd.org  Sat Oct  7 12:20:14 2000
Received: (from daemon@localhost)
	by castle.jp.freebsd.org (8.9.3+3.2W/8.7.3) id MAA91160;
	Sat, 7 Oct 2000 12:20:14 +0900 (JST)
	(envelope-from owner-acpi-jp@jp.FreeBSD.org)
Received: from shidahara1.planet.sci.kobe-u.ac.jp (shidahara1.planet.sci.kobe-u.ac.jp [133.30.50.200])
	by castle.jp.freebsd.org (8.9.3+3.2W/8.7.3) with ESMTP id MAA91155
	for <acpi-jp@jp.freebsd.org>; Sat, 7 Oct 2000 12:20:13 +0900 (JST)
	(envelope-from takawata@shidahara1.planet.sci.kobe-u.ac.jp)
Received: from shidahara1.planet.sci.kobe-u.ac.jp (localhost [127.0.0.1])
	by shidahara1.planet.sci.kobe-u.ac.jp (8.9.3/8.9.3) with ESMTP id MAA55793
	for <acpi-jp@jp.freebsd.org>; Sat, 7 Oct 2000 12:18:32 +0900 (JST)
	(envelope-from takawata@shidahara1.planet.sci.kobe-u.ac.jp)
Message-Id: <200010070318.MAA55793@shidahara1.planet.sci.kobe-u.ac.jp>
To: acpi-jp@jp.freebsd.org
In-reply-to: Your message of "Thu, 05 Oct 2000 04:30:32 MST."
             <200010051130.e95BUWh01596@mass.osd.bsdi.com>
Date: Sat, 07 Oct 2000 12:18:32 +0900
From: Takanori Watanabe <takawata@shidahara1.planet.sci.kobe-u.ac.jp>
Reply-To: acpi-jp@jp.freebsd.org
Precedence: list
X-Distribute: distribute version 2.1 (Alpha) patchlevel 24e+000315
X-Sequence: acpi-jp 809
Subject: [acpi-jp 809] Re: acpica-bsd-20001005 megapatch up
Errors-To: owner-acpi-jp@jp.freebsd.org
Sender: owner-acpi-jp@jp.freebsd.org
X-Originator: takawata@shidahara1.planet.sci.kobe-u.ac.jp

In message <200010051130.e95BUWh01596@mass.osd.bsdi.com>, Mike Smith $B$5$s$$$o$/(B
:

> - EC driver (untested, might work, should be fixable)

I have some fix for this.
In machine ,the polling loop is time out.
And sometimes, it drops query. 
I fixed these problem. With this fix,this laptop supports AC-adapter
 attaching and detaching as I mentioned before. Cool! 

Takanori Watanabe
<a href="http://www.planet.sci.kobe-u.ac.jp/~takawata/key.html">
Public Key</a>
Key fingerprint =  2C 51 E2 78 2C E1 C5 2D  0F F1 20 A3 11 3A 62 2A 

--- dev/acpica/acpi_ec.c	Thu Oct  5 20:01:35 2000
+++ /home/takawata/src/sys/dev/acpica/acpi_ec.c	Sat Oct  7 12:00:26 2000
@@ -371,31 +371,38 @@
 
     /*
      * Check EC_SCI.
-     *
-     * Make sure this is a 'real' EC SCI by checking the EC_SCI bit of the
-     * status register.  Note that this function should only be called when
+     * 
+     * Loop while the EC_SCI bit of the status register is set.
+     * Note that this function should only be called when
      * this bit is set (polling is used to detect IBE/OBF events).
      */
-    EcStatus = EC_GET_CSR(sc);
-    if (EcStatus & EC_EVENT_SCI) {
+    
+    while ( EC_GET_CSR(sc) & EC_EVENT_SCI) {
 	Status = EcQuery(sc, &Data);
-    } else {
-	Status = AE_ERROR;
-    }
 
+	/*
+	 * Signal the semaphore to indicate transaction completion.
+	 */
+	AcpiOsSignalSemaphore(sc->ec_semaphore, 1);
+
+	/*
+	 * Evaluate _Qxx if appropriate.
+	 */
+	if (Status == AE_OK) {
+	    sprintf(qxx, "_Q%02x", Data);
+	    strupr(qxx);
+	    AcpiEvaluateObject(sc->ec_handle, qxx, NULL, NULL);
+	}
+	/*
+	 * Try to get the controller semaphore for getting next query
+	 */
+	if (AcpiOsWaitSemaphore(sc->ec_semaphore, 1, 1000))
+	    return;
+    }
     /*
-     * Signal the semaphore to indicate transaction completion.
+     * Completely finished transaction.
      */
     AcpiOsSignalSemaphore(sc->ec_semaphore, 1);
-
-    /*
-     * Evaluate _Qxx if appropriate.
-     */
-    if (Status == AE_OK) {
-	sprintf(qxx, "_Q%02x", Data);
-	strupr(qxx);
-        AcpiEvaluateObject(sc->ec_handle, qxx, NULL, NULL);
-    }
 }
 
 static ACPI_STATUS
@@ -491,7 +498,7 @@
             !(EcStatus & EC_FLAG_INPUT_BUFFER))
 	    return(AE_OK);
 		
-	AcpiOsSleepUsec(10);
+	AcpiOsSleepUsec(100);
     }
 
     return(AE_ERROR);






