Commit Graph

863 Commits

Author SHA1 Message Date
jruoho 2731b5ff2f Print a warning if AcpiOsSleep() is called with a value larger than two
seconds. It is known that there are systems in the field that pass bogus AML
values to the Sleep() operation code, possibly requesting delays that could
be measured in days.

Discussed with jmcneill@.

XXX: While the used mstohz(9) is documented to round to one second if the
     passed value is larger than 131072 ms, we may still need to force a
     sensible upper limit if this warning starts to appear.
2010-05-12 17:03:11 +00:00
jruoho 881c3c1e3f When scanning the device "capabilities" (power, wake-up, etc.),
include all device nodes, regardless of the status of the device.

XXX: It is known that some systems implement the _STA method incorrectly.
     If needed in the future, attachment based on the values from this
     method may need revisiting. Same goes for ACPI_ACTIVATE_DEV.
2010-05-12 16:11:05 +00:00
jruoho a24d118616 Initial pass for issues observed by dyoung@ on HP Pavilion N3270. In this
laptop there is a PNP0C0B ("ACPI fan") with the following properties:

        _PSC : Power state for D3 (alone).
        _PR0 : Power resources for D0.
        _PSx : Power state switch for D0 and D3.

Thus, it is impossible to get or set the D3 power state via power resources
alone; there is only a single PowerResource() and it is for D0.

To tackle this:

  1. Evaluate the direct _PSC control method if and only if there is no
     given _PRx. The order is important; it is known that some other
     systems implement the _PSC method (like _STA) incorrectly.

  2. If no _PRx is available (and thus no _ON or _OFF), do not error out.
     Instead, if we have AE_NOT_FOUND, continue to evaluate the power state
     switch method, _PSx, which (on this laptop) should alone suffice for
     the D0 -> D3 transition.
2010-05-12 15:59:52 +00:00
jruoho 7600ada264 Add ASUS CUV4X-D. From Pierre Pronchery in PR #41351. 2010-04-28 17:52:17 +00:00
jruoho 20524a61c1 Include the new prototype for acpi_enter_sleep_state(). 2010-04-27 08:37:07 +00:00
jruoho cd8924253f Make acpi_enter_sleep_state() not to return. No one cared what it returned. 2010-04-27 08:36:06 +00:00
jruoho e7c1114893 Be consistent with the returned exception codes. Check for NULL pointers. 2010-04-27 08:15:07 +00:00
jruoho f04ee53053 Use ACPICA's standard notify values from <actypes.h> and move the
device-specific notify constants to the device-specific files.
2010-04-27 05:57:43 +00:00
jruoho d5124a1812 Clean up <dev/acpi/acpireg.h>. While documenting the control methods is an
admirable goal, it is pretty much mission impossible; the specifications are
nearly thousand pages each and the amount of methods is counted in hundreds.

In addition, use ACPICA's native constants from <actypes.h> when possible.
Also move ACPI_STA_OK from "mpacpi.c" to <dev/acpi/acpireg.h> to simplify
the evaluation of device status.
2010-04-27 05:34:14 +00:00
jruoho f655bf2ab4 Fix typo. Doh. 2010-04-26 13:38:42 +00:00
jruoho 727f1f57e9 Improve and rearrange comments. 2010-04-26 13:30:31 +00:00
jruoho 696f7c4b2e AE_CTRL_TERMINATE -> AE_CTRL_FALSE. 2010-04-26 12:46:48 +00:00
jruoho a0542f149f Move the ACPIVERBOSE blocks to a single place.
Also print non-devices in the EISAID/HID/UID/ADR-block
2010-04-26 04:31:09 +00:00
jruoho ccaec16d65 Return instead of breaking out if the sleep state is not available. 2010-04-25 17:06:23 +00:00
jruoho 902b38408b As noted by jmcneill@, the specifications specifically mention that the _TTS
should be invoked before the system has notified any native mode device
drivers. Thus, do the call before pmf_system_suspend(9).
2010-04-25 17:03:08 +00:00
jruoho 61a52d7657 Evaluate _TTS on sleep state transitions. This is mainly to pro-actively
support some weird BIOS, which may require the evaluation. Ok jmcneill@.
2010-04-25 10:05:22 +00:00
jruoho 0c1ea6e257 Add a note about AcpiEnterSleepStatePrep(). 2010-04-25 09:12:38 +00:00
jruoho 2e3ac7f8ad Embarrassing typos: _PI_ -> _SI_, _PB_ -> _SB_. 2010-04-24 19:51:15 +00:00
jruoho a84baa0293 Do not use __func__ with ACPI_DEBUG_PRINT (it already adds it). 2010-04-24 19:36:14 +00:00
jruoho 80e5813055 Remove retrieving the zone name via something called "REGN".
We really should not add code that aims to satisfy some oddball firmware,
not in the generic drivers that aim to comply with the specifications.
In the long-term this is even worse than quirk tables.
2010-04-24 19:16:10 +00:00
jruoho ac93d6907f Some purely cosmetic editing in the name of readability: clean up the softc
and remove unused variables therein, remove unused constants, use
ACPI_DEBUG_PRINT, add more detailed comments, et cetera.
2010-04-24 19:11:48 +00:00
jruoho 2203417f01 Fix a bug involving acpitz(4) accidentally attaching to the _TZ_ scope.
This in turn was caused by a bug in ACPICA, which reports the types of _SB_
and _TZ_ scopes incorrectly for its own internal reasons (utglobal.c):

  /*
   * Predefined ACPI Names (Built-in to the Interpreter)
   *
   * NOTES:
   * 1) _SB_ is defined to be a device to allow \_SB_._INI to be run
   *    during the initialization sequence.
   * 2) _TZ_ is defined to be a thermal zone in order to allow ASL code to
   *    perform a Notify() operation on it.
   */

Thanks to cegger@ for noticing the bug and testing a fix.
2010-04-24 13:42:18 +00:00
jruoho 83caa2c18b Add utility function acpi_get_node().
This retrieves a struct acpi_devnode from a handle. Since this requires
accessing the global softc, it is better to do it in one place alone. The
same goes for possible locking of the node-queue; it is better not to
publicize such a lock for generic device drivers.
2010-04-24 06:57:10 +00:00
jruoho 1b81a62b62 Now that we are able to remove references to power resources, provide a
detachment routine for acpitz(4). Add comments explaining the relationship
between power resources and active cooling. Also some improvements to code
readability.
2010-04-24 06:31:44 +00:00
jruoho ba4f1cd0dd Forgot that the firmware may change the power state behind our back,
so actively query the state when the sysctl(8) is invoked.
2010-04-23 19:00:58 +00:00
jruoho 16bdc3ff0f Add hw.acpi.power sysctl-node. 2010-04-23 18:51:31 +00:00
jruoho f6ac0eab50 One malloc(9) type is enough for ACPI; use M_ACPI. 2010-04-23 15:52:26 +00:00
jruoho 84377acda5 Simplify acpi_pcidev_find(): directly return a pointer to the device node. 2010-04-23 15:46:59 +00:00
jruoho f7be22cf8e Cosmetics: be pedantic and use AE_CTRL_TERMINATE instead of AE_ABORT_METHOD
as a condition to break out of a loop.
2010-04-23 15:37:01 +00:00
jruoho 7e3b451fbe When setting the power, always mark the state as invalid on failure, even if
going to D0. Also fix a potential NULL pointer dereference in an aprint_().
2010-04-23 15:20:35 +00:00
jruoho bccc1bf1aa Make the ACPIVERBOSE output even prettier by removing cruft. 2010-04-23 07:04:18 +00:00
jruoho bdb6986f24 Some pretty printing for ACPIVERBOSE. 2010-04-22 21:58:08 +00:00
jruoho 6772f0e062 Remove a redundant prototype. A leftover from the previous commit. 2010-04-22 18:53:23 +00:00
jruoho 9ddf2c5165 Merge new code for ACPI power resources.
The old code served us well, but a major overhaul would have been needed for
it to cope with the increased demands of the code -- and the specifications.

ok jmcneill@, pgoyette@
2010-04-22 18:40:09 +00:00
jruoho e0aec4e102 Wrap long lines, add some white space for readability, remove unnecessary
variable assignments, misc KNF. No functional change.
2010-04-22 15:25:46 +00:00
jruoho 1af445da2a Shorten the long lines with two custom macros. 2010-04-22 15:14:24 +00:00
jruoho b3ff23fb49 From Gregoire Sutre: rework the ACPI PCI support. This makes ACPI to
correctly pick PCI segment groups, PCI bus numbers, PCI root bridges,
PCI-to-PCI bridges, and PCI devices, among other things. In short: it is
more robust than the old code or anything in sys/arch/x86/x86/mpacpi.c.

ok cegger@, jmcneill@
2010-04-22 14:50:30 +00:00
jruoho 54e937894d Remove the block where the default address space handlers were manually
installed via AcpiInstallAddressSpaceHandler(). This was already commented
out because ACPICA does this for us when ACPI_NO_ADDRESS_SPACE_INIT is not
specified when calling AcpiEnableSubsystem().
2010-04-20 04:57:04 +00:00
jruoho b9961a4e19 Instruct ACPICA to dynamically allocate the table descriptions in
AcpiInitializeTables() instead of pushing 128 statically allocated
descriptors. This will eliminate also the need to call
AcpiReallocateRootTable().

The rationale for the statically allocated table descriptors is to allow
initialization without virtual/dynamic memory. Later these should be copied
to dynamic memory via AcpiReallocateRootTable(). But since in NetBSD both
functions were called in the very same acpi_probe(), this dance was
completely unnecessary.
2010-04-20 04:53:22 +00:00
jruoho 92024a35be Remove a duplicate variable assignment. 2010-04-18 14:07:16 +00:00
jruoho 0c6bf9beea From Gregoire Sutre:
Modify the main ACPI namespace scan by including a parent-child
  relationship for each node. The result is a bi-directional tree.

ok jmcneill@
2010-04-18 14:05:26 +00:00
jruoho 0b7093053e Regen. 2010-04-18 10:22:33 +00:00
jruoho 2e422aa6a6 Add ATM1200. From ThinkPad X60s. 2010-04-18 10:22:01 +00:00
christos b62024a026 fix dmesg printing. 2010-04-16 01:52:54 +00:00
jruoho 55052eca77 As discussed with jmcneill@, install a global "bus notification handler"
that receives all notifications and deliver notifications to drivers via it.
2010-04-15 07:02:24 +00:00
jruoho d6afaa4439 Arrange some comments. 2010-04-15 04:03:38 +00:00
jruoho 603f4c71f0 Simplify the setting of the GPEs. Add a debug-printf. 2010-04-14 20:08:56 +00:00
jruoho fb53d8ceed No need to spread the ACPICA type system any more than is necessary:
UINT8 -> uint8_t and UINT32 -> uint32_t.
2010-04-14 19:27:28 +00:00
jruoho 06a5faf4f3 Simplify error reporting, remove casts, KNF. 2010-04-14 18:39:56 +00:00
jruoho 8a96e47761 Remove the code that was copy-pasted to acpi_detach() from the attachment
routine. Add a note that the detachment is incomplete.
2010-04-14 17:20:19 +00:00