* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- * $FreeBSD: src/sys/dev/acpica/acpi_ec.c,v 1.82 2009/06/05 18:44:36 jkim
+ * __FBSDID("$FreeBSD: src/sys/dev/acpica/acpi_ec.c,v 1.76.2.1.6.1 2009/04/15 03:14:26 kensmith Exp $");
*/
#include <sys/cdefs.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/module.h>
-
#include <sys/rman.h>
#include "acpi.h"
-#include "accommon.h"
-
#include <dev/acpica5/acpivar.h>
+#include "acutils.h"
/* Hooks for the ACPI CA debugging infrastructure */
#define _COMPONENT ACPI_EC
ACPI_MODULE_NAME("EC")
+#define rebooting 0
+#define PZERO 0
/*
* EC_COMMAND:
* -----------
#define EC_LOCK_TIMEOUT 1000
/* Default delay in microseconds between each run of the status polling loop. */
-#define EC_POLL_DELAY 5
+#define EC_POLL_DELAY 5000
/* Total time in ms spent waiting for a response from EC. */
-#define EC_TIMEOUT 750
+#define EC_TIMEOUT 7500
#define EVENT_READY(event, status) \
(((event) == EC_EVENT_OUTPUT_BUFFER_FULL && \
EcUnlock(sc);
/* Ignore the value for "no outstanding event". (13.3.5) */
-#if defined(__FreeBSD__)
+#if 0
CTR2(KTR_ACPI, "ec query ok,%s running _Q%02X", Data ? "" : " not", Data);
#endif
if (Data == 0)
EC_STATUS EcStatus;
KASSERT(Context != NULL, ("EcGpeHandler called with NULL"));
-#if defined(__FreeBSD__)
+#if 0
CTR0(KTR_ACPI, "ec gpe handler start");
#endif
-
/*
* Notify EcWaitEvent() that the status register is now fresh. If we
* didn't do this, it wouldn't be possible to distinguish an old IBE
*/
EcStatus = EC_GET_CSR(sc);
if ((EcStatus & EC_EVENT_SCI) && !sc->ec_sci_pend) {
-#if defined(__FreeBSD__)
+#if 0
CTR0(KTR_ACPI, "ec gpe queueing query handler");
#endif
Status = AcpiOsExecute(OSL_GPE_HANDLER, EcGpeQueryHandler, Context);
* If booting, check if we need to run the query handler. If so, we
* we call it directly here since our thread taskq is not active yet.
*/
- if (cold || sc->ec_suspending) {
+ if (cold || rebooting) {
if ((EC_GET_CSR(sc) & EC_EVENT_SCI)) {
-#if defined(__FreeBSD__)
+#if 0
CTR0(KTR_ACPI, "ec running gpe handler directly");
#endif
EcGpeQueryHandler(sc);
status = AE_NO_HARDWARE_RESPONSE;
ec_status = EC_GET_CSR(sc);
if (sc->ec_burstactive && !(ec_status & EC_FLAG_BURST_MODE)) {
-#if defined(__FreeBSD__)
+#if 0
CTR1(KTR_ACPI, "ec burst disabled in waitevent (%s)", msg);
#endif
sc->ec_burstactive = FALSE;
}
if (EVENT_READY(event, ec_status)) {
-#if defined(__FreeBSD__)
+#if 0
CTR2(KTR_ACPI, "ec %s wait ready, status %#x", msg, ec_status);
#endif
status = AE_OK;
ACPI_SERIAL_ASSERT(ec);
Status = AE_NO_HARDWARE_RESPONSE;
- int need_poll = cold || ec_polled_mode || sc->ec_suspending;
+ int need_poll = cold || rebooting || ec_polled_mode || sc->ec_suspending;
/*
* The main CPU should be much faster than the EC. So the status should
* be "not ready" when we start waiting. But if the main CPU is really
if (Status == AE_OK)
break;
}
- tsleep(&sc->ec_gencount, 0, "ecgpe", slp_ival);
+ tsleep(&sc->ec_gencount, PZERO, "ecgpe", slp_ival);
}
/*
ec_polled_mode = TRUE;
}
}
-#if defined(__FreeBSD__)
+#if 0
if (Status != AE_OK)
CTR0(KTR_ACPI, "error: ec wait timed out");
#endif
}
/* Run the command and wait for the chosen event. */
-#if defined(__FreeBSD__)
+#if 0
CTR1(KTR_ACPI, "ec running command %#x", cmd);
#endif
gen_count = sc->ec_gencount;
u_int gen_count;
ACPI_SERIAL_ASSERT(ec);
-#if defined(__FreeBSD__)
+#if 0
CTR1(KTR_ACPI, "ec read from %#x", Address);
#endif
-
/* If we can't start burst mode, continue anyway. */
status = EcCommand(sc, EC_COMMAND_BURST_ENABLE);
if (status == AE_OK) {
- data = EC_GET_DATA(sc);
+ data = EC_GET_DATA(sc);
if (data == EC_BURST_ACK) {
-#if defined(__FreeBSD__)
+#if 0
CTR0(KTR_ACPI, "ec burst enabled");
#endif
sc->ec_burstactive = TRUE;
status = EcCommand(sc, EC_COMMAND_BURST_DISABLE);
if (ACPI_FAILURE(status))
return (status);
-#if defined(__FreeBSD__)
+#if 0
CTR0(KTR_ACPI, "ec disabled burst ok");
#endif
}
u_int gen_count;
ACPI_SERIAL_ASSERT(ec);
-#if defined(__FreeBSD__)
+#if 0
CTR2(KTR_ACPI, "ec write to %#x, data %#x", Address, *Data);
#endif
/* If we can't start burst mode, continue anyway. */
status = EcCommand(sc, EC_COMMAND_BURST_ENABLE);
if (status == AE_OK) {
- data = EC_GET_DATA(sc);
+ data = EC_GET_DATA(sc);
if (data == EC_BURST_ACK) {
-#if defined(__FreeBSD__)
+#if 0
CTR0(KTR_ACPI, "ec burst enabled");
#endif
sc->ec_burstactive = TRUE;
status = EcCommand(sc, EC_COMMAND_BURST_DISABLE);
if (ACPI_FAILURE(status))
return (status);
-#if defined(__FreeBSD__)
+#if 0
CTR0(KTR_ACPI, "ec disabled burst ok");
#endif
}