Commit Graph

585 Commits

Author SHA1 Message Date
cube 926915cf40 - Split device_t and softc for pcppi(4) and attimer(4)
- Change the attimer <-> pcppi communication using device_t so that
  pcppi(4) doesn't have to know about the contents of struct attimer_softc.

XXX pcppi's childdet function is completely wrong.  This has to be
XXX revisited later.
2008-03-04 16:35:18 +00:00
dyoung e4f3892584 Use pmf_device_register1() instead of shutdownhook_establish() to
register com_cleanup() as the shutdown hook.

Add a generic suspend routine.  Suspend and resume com@isa.

Protect against dereferencing a NULL softc in comioctl().

Destroy both a mutex and a callout in com_detach().

Cosmetic: use aprint_*_dev().  Use PMF_FN_ARGS, PMF_FN_PROTO.
2008-02-29 07:02:04 +00:00
dyoung 61ad1dd43b Use PMF_FN_ARGS, PMF_FN_PROTO. 2008-02-29 06:35:40 +00:00
dyoung 36f58dc899 Use aprint_*_dev(), device_t and accessors. Constify a bit. 2008-02-18 06:19:50 +00:00
jmcneill 95fc3f2649 Add hw.acpi.supported_states sysctl node:
$ sysctl hw.acpi.supported_states
  hw.acpi.supported_states = S0 S3 S4 S5
2008-02-13 15:27:55 +00:00
xtraeme 74a0270856 aiboost_getcomp: use Package.Count to allocate and iterate over
the elements rather than Integer.Value, which sometimes doesn't
match and gives unexpected results on the error path.

This fixes the kmem_poison_check on DEBUG kernels (finally). Patch
by Fukumoto Atsushi. Thanks!
2008-02-01 23:12:30 +00:00
xtraeme d187549ef6 Pass the same size to kmem_alloc(9) and kmem_free(9), this fixes
the kmem_poison_check panic on DEBUG kernels.
2008-01-29 19:35:05 +00:00
jmcneill b7cf8d358c The Thinkpad T61/x61 family powers off the USB power resource on resume
from S3 sleep. Until we get proper ACPI power resource support, simply
call \\_SB.PCI0.LPC.EC.PUBS._ON() on resume if the method exists.

Fixes kern/37279 by Steven M Bellovin.
2008-01-28 20:31:55 +00:00
joerg 3615cf7715 Now that __HAVE_TIMECOUNTER and __HAVE_GENERIC_TODR are invariants,
remove the conditionals and the code associated with the undef case.
2008-01-20 18:09:03 +00:00
jmcneill 8761d09319 Don't be so aggressive in polling the EC when cold, port-i386/37790. 2008-01-18 01:03:24 +00:00
jmcneill 91a074d893 If we are in polling mode, do not try to spin forever in the state machine
waiting for a read or write to complete. Workaround an issue on my VAIO,
but we really need to figure out why it is failing in the first place.
2008-01-18 00:33:54 +00:00
dyoung 636e434283 Support pcppi(4) detachment.
Use device_t, device_private().  Get rid of a struct device * cast.
2008-01-10 07:58:39 +00:00
xtraeme 53fd152fd5 Remove useless returns at the end of void functions. 2008-01-09 14:52:52 +00:00
tnn 303f9ebb5b Make the ACPI_MADT_DEBUG code compile again. 2008-01-07 06:04:07 +00:00
christos d1b79165fa clamp min/max values properly. 2008-01-06 19:42:03 +00:00
ad 0664a0459b Start detangling lock.h from intr.h. This is likely to cause short term
breakage, but the mess of dependencies has been regularly breaking the
build recently anyhow.
2008-01-04 21:17:40 +00:00
dyoung 09fd56f9ec Detach attimer at acpi, attimer at isa. 2008-01-03 01:21:44 +00:00
dyoung 95bf02050e Use device_t, device_private(). 2008-01-02 20:47:28 +00:00
jmcneill 13f097963d Always enable the Fn key quirk if a device node for the Sony Programmable
Interrupt Controller (SNY6001) is not present.
2007-12-23 18:03:02 +00:00
jmcneill 9f7f6d9be0 Move Sony Notebook Controller (sony(4)) driver from MD to MI directory,
as it can be used on amd64 as well.
2007-12-23 17:29:26 +00:00
jmcneill 8fce0f055c Move display switching out of the kernel; deliver this (and other) events
to sysmon so a powerd script can handle them.
2007-12-22 18:38:13 +00:00
jmcneill 6fffc8ef3c Add experimental display switching support. 2007-12-22 13:06:30 +00:00
jmcneill bf34549b28 Only toggle bluetooth when the wireless button is pressed, simplifies
things and it seems I forgot that my laptop has a separate wifi switch.
2007-12-22 03:19:29 +00:00
jmcneill 4ec3c2b1cd Add support for the WLAN / Bluetooth switch. 2007-12-21 22:14:03 +00:00
xtraeme 6d771ab8b4 Register a pmf(9) power handler... ok jmcneill@. 2007-12-21 21:52:10 +00:00
jmcneill aa518c7bc8 Hook Thinkpad temperature sensors into envsys:
$ envstat -d thinkpad0
TMP0:     46.000 degC
TMP1:     39.000 degC
TMP2:     32.000 degC
TMP3:        N/A
TMP4:     50.000 degC
TMP5:        N/A
TMP6:     29.000 degC
TMP7:        N/A
2007-12-21 21:24:45 +00:00
jmcneill f5210660c0 Add acpiec_bus_{read,write} and acpiec_get_handle, for use in other
device drivers.
2007-12-21 21:22:54 +00:00
jmcneill c48902ebaf Handle notifications in a separate thread, and ensure that the BIOS doesn't
try to play trick with us when we are trying to manage the brightness
keys.
2007-12-21 18:43:39 +00:00
jmcneill ef8922785d Convert AcpiOsSleep from using tsleep to cv_timedwait_sig 2007-12-21 18:42:38 +00:00
jmcneill eedb1a1f01 Typo in previous. 2007-12-21 16:38:59 +00:00
jmcneill ea50d249d2 Handle key repeat, and only match if MHKV returns an HKEY version we have
a chance of supporting.
2007-12-21 16:38:02 +00:00
jmcneill 5b0f734d51 Add Thinkpad ACPI driver, for controlling hotkeys and display brightness. 2007-12-21 15:15:19 +00:00
joerg bc8d3e534e It seems like ACPICA can't deal with GPEs being handled before the GPE
handler is called, so clear the GPE bit in the callout as well.
This fixes the EC issues on T42 models.
2007-12-19 20:48:56 +00:00
jmcneill dd0320ef8b Fix comment before AcpiOsGetTimer, no functional change. 2007-12-17 15:02:31 +00:00
jmcneill f13c9086d0 acpi_pci_link_route_interrupt: if we're going to return a valid IRQ, we
need to fill in irq, pol, and trig arguments.
2007-12-16 23:11:08 +00:00
jmcneill a73b778622 Now that ACPI-CA doesn't parse the X/RSDT for us, we need to map it
ourselves.

Before:
  acpi0: X/RSDT: OemId <      ,        ,00000000>, AslId <    ,00000000>
After:
  acpi0: X/RSDT: OemId <LENOVO,TP-7L   ,00001260>, AslId < LTP,00000000>

ACPI can now access the X/RSDT using 'acpi_map_rsdt' and 'acpi_unmap_rsdt'.
2007-12-16 21:10:34 +00:00
joerg 36cdfbe0db Don't retry to post a command if the EC doesn't answer for a second.
It seems to create more issues than it fixes. Try to defend against
lost/late GPEs by using a callout to kick the state machine regulary.
Add some notes about the purpose and working of the driver.
2007-12-15 09:30:59 +00:00
jmcneill d72049ddbd Restore acpi_quirk functionality, lost in the latest ACPI-CA update. 2007-12-15 02:19:55 +00:00
perry 9b2b412c19 __FUNCTION__ -> __func__ 2007-12-15 00:39:14 +00:00
jmcneill e692a6c76a Introduce pmf_system_bus_resume. In the ACPI S3 resume path, use this to
separate powering up devices from restoring their state. This is required
on some machines where AcpiLeaveSleepState can fail due to an attempt to
access a powered off device.
2007-12-14 01:29:29 +00:00
xtraeme fcad73742f Check return value of pmf_device_register(), pointed out by joerg.
Looks like the pmf(9) manpage declared it as void and not bool...
2007-12-13 15:36:29 +00:00
jmcneill 645fe8c342 Try not to pass garbage to pci_make_tag; workaround for odd ACPI DSDTs.
Fixes kern/37527.
2007-12-12 23:33:22 +00:00
jmcneill faa68cee64 Rename acpiec_gpe_state_maschine -> acpiec_gpe_state_machine 2007-12-12 12:57:48 +00:00
jmcneill c44d13d630 No longer required after jmcneill-pm merge. 2007-12-11 23:07:30 +00:00
xtraeme 0cd3ab0981 Register to the pmf(9) framework and fix an error path. 2007-12-10 23:25:59 +00:00
reinoud 3a44e8ad9d Add missing \n and remove surplus . 2007-12-10 22:56:29 +00:00
jmcneill 4c1d81b2b5 Merge jmcneill-pm branch. 2007-12-09 20:27:42 +00:00
jmcneill 0273402379 kern/37501: cosmetic error in acpi_tz probe messages 2007-12-08 23:01:30 +00:00
ad 6874e511b7 lockmgr -> mutex 2007-12-05 07:58:29 +00:00
ad 598ab03ad0 Match the docs: MUTEX_DRIVER/SPIN are now only for porting code written
for Solaris.
2007-12-05 07:06:50 +00:00
jmcneill 61d5fb95a4 No need to waste more than one line of output at attach time. 2007-12-02 06:26:40 +00:00
jmcneill 4fbe23fdd0 aprintify 2007-12-01 04:50:50 +00:00
xtraeme 31962fc6e5 Extend the envsys2 API (one more time, sorry) as defined in:
http://mail-index.netbsd.org/tech-kern/2007/11/09/0001.html

sysmon_envsys_create() and sysmon_envsys_destroy() were added to
create/destroy sysmon_envsys objects (and its TAILQ/LIST for sensors/events).

sysmon_envsys_sensor_attach() and sysmon_envsys_sensor_detach() were
added to attach/detach sensors to a specified sysmon_envsys device.

The events framework is now per device and configurable via the
ENVSYS_SETDICTIONARY ioctl or /etc/envsys.conf and envstat(8).

Update all users and documentation to reflect these changes.
2007-11-16 08:00:11 +00:00
joerg bedc8f14a0 When assigning an IRQ for classic PIC routing to an ACPI link dev,
make sure to update the PCI Interrupt Register of all PCI devices using
it. This fixes interrupt with ACPI and w/o IOAPIC, when the BIOS didn't
route all interrupts correctly.

Reported by sborill@ and by Mathias De Belder in PR 37001, fix tested
by sborill@.
2007-11-07 15:29:15 +00:00
xtraeme f4046a2e1c Missed a struct device -> device_t, found by joerg. 2007-11-05 23:57:32 +00:00
joerg 08de5799c0 Use the fallback to ACPI SCI as PCI interrupt only as a last resort
if no other entry could be used.
2007-11-05 10:30:44 +00:00
xtraeme 7cd6e1759b - Allocate the envsys_data_t structures dynamically, removing the
max limit.
- Use kmem(9) to allocate the memory.
2007-11-04 13:59:49 +00:00
xtraeme 64a549146f Follow plunky's changes:
- Use CFATTACH_DECL_NEW and remove struct device from the softc.
- Use aprint_*_dev().
- Use aiboost_refresh_sensors() for sme_gtredata.
2007-11-03 23:33:50 +00:00
xtraeme 4e10a84855 - Rename ENVSYS_BATTERY_STATE units to ENVSYS_BATTERY_CAPACITY and
introduce ENVSYS_BATTERY_CHARGE, which is the same than an Indicator and
  it's used to know if the battery is currently charging or discharging.

- Require two sensors at least for SME_CLASS_BATTERY to make the low-power
  condition work: a ENVSYS_BATTERY_CAPACITY plus ENVSYS_BATTERY_CHARGE.

- Simplify sme_event_check_lowpower() and make it check the required
  sensors in the SME_CLASS_ACADAPTER and SME_CLASS_BATTERY classes.
  If the acadapter is not ready, trust the state returned by the battery
  device.

Based on suggestion from joerg@.
2007-11-03 23:05:21 +00:00
plunky 812fa1c5a1 do not embed acpi device names in the sensor names
fake it in the compat code for the old envsys API
2007-11-02 19:21:29 +00:00
plunky 60822ed9d3 When no estimate of battery minutes_left can be made, apm should
return a value of 0.
2007-10-27 19:51:29 +00:00
joerg 65eda08509 Pass correct argument to callback, botched up in the last commit. 2007-10-24 07:05:35 +00:00
ad a2a3828545 machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h 2007-10-19 11:59:34 +00:00
joerg 649a2156ea Convert to device_t/softc split. Use aprint API. 2007-10-18 23:54:54 +00:00
joerg 04e2d29955 Use callout_setfunc/callout_schedule. 2007-10-18 00:10:52 +00:00
joerg 8302c6904b Separate softc and device_t. Convert to aprint API and make the driver
less verbose by default.
2007-10-17 23:30:58 +00:00
xtraeme 112f996fbc Use a mutex(9) rather than a rwlock(9), it's cheaper. 2007-10-13 00:56:16 +00:00
xtraeme 7ade6d03ad Fix the problems described in:
http://mail-index.netbsd.org/current-users/2007/07/16/0012.html

- Introduce sme_class into the sysmon_envsys struct to specify a
  class; currently there are two classes: SME_CLASS_ACADAPTER and
  SME_CLASS_BATTERY.

- Add a new envsys event: PENVSYS_EVENT_LOW_POWER that is reached when
  all SME_CLASS_BATTERY devices are in CRITICAL/LOW state and there's not
  any SME_CLASS_ACADAPTER connected.

- Add the 'low-power' event into the sensor_battery script that will
  shutdown the system gracefully via 'shutdown -p'. If powerd(8) is
  not running, cpu_reboot(9) with RB_POWERDOWN is used.

- Make acpiacad(4) a SME_CLASS_ACADAPTER device and acpibat(4) a
  SME_CLASS_BATTERY device.

Update the documentation accordingly to these changes.
2007-10-10 23:25:39 +00:00
xtraeme 6a0ca41c22 Set the monitor value only once in the acpitz_init_envsys(),
not multiple times in the callout handler.
2007-10-07 23:14:53 +00:00
xtraeme 8b2678bd7e Use a two clause license for all the code I contributed.
The envsys code will be changed later.
2007-10-06 07:21:02 +00:00
jmcneill 02ef36ec48 Sort IO resources before attempting to attach; resolves issues on ACPI
firmware that reports 0x64,0x60 instead of 0x60,0x64. Patch tested by
Greg A. Woods.
2007-10-05 18:31:46 +00:00
njoly 69b70bfe60 Add ACPI address32 resource type support (DWord Address Space
Descriptor), for fixed size io and mem.

Fix hpet@acpi attachement on Dell Poweredge 860.
Tested by Wouter Schoot, thanks.

While here:
- Update some indentation
- Correct function check
- Add missing break
- Update wrong debug message

Reviewed by cube.
2007-09-28 15:16:16 +00:00
ad 9c412e0cbf x86 changes for pcc and LKMs.
- Replace most inline assembly with proper functions. As a side effect
  this reduces the size of amd64 GENERIC by about 120kB, and i386 by a
  smaller amount. Nearly all of the inlines did something slow, or something
  that does not need to be fast.
- Make curcpu() and curlwp functions proper, unless __GNUC__ && _KERNEL.
  In that case make them inlines. Makes curlwp LKM and preemption safe.
- Make bus_space and bus_dma more LKM friendly.
- Share a few more files between the ports.
- Other minor changes.
2007-09-26 19:48:34 +00:00
xtraeme debeab5278 - Use a ENVSYS_BATTERY_STATE sensor rather than ENVSYS_GSTRING.
- Use ENVSYS_FMONSTCHANGED on the ENVSYS_BATTERY_STATE sensor to monitor
  state changes.
2007-09-04 16:56:30 +00:00
xtraeme cba98bab30 Add a new sensor of type ENVSYS_GSTRING. This is useful to print
the current battery charge state.

$ envstat -dacpibat0 -s"acpibat0 charge state"
  acpibat0 charge state:     NORMAL
$

It will show WARNING, CRITICAL, LOW or NORMAL depending on the
state it is.
2007-09-02 19:38:32 +00:00
xtraeme 1a5f765979 Use a rwlock(9) to protect access while refreshing data in
aiboost_get_value().
2007-08-30 18:29:11 +00:00
xtraeme 9d55226ba9 Set ENVSYS_FMONNOTSUPP in the last two missing sensors, forgot in previous. 2007-08-26 20:52:15 +00:00
xtraeme a8995b3790 Only assing the monitoring flags once in acpibat_init_envsys() before
registering the driver.
2007-08-26 20:47:42 +00:00
tnn ca5c2e9bf5 apm emulation needs envsys. From Jukka Salmi on the current-users list. 2007-08-23 10:04:07 +00:00
cube 8b3327fe73 Print ACPI device name in a way that Jared McNeill and I find prettier.
I like it better because I get to see the name of the device as it appears
in the DSDT, which sometimes makes sense and that way it's easier to locate
the relevant code when debugging.

E.g.:

PIC (PNP0000) [AT Interrupt Controller] at acpipcib0 not configured
DMAD (PNP0200) [AT DMA Controller] at acpipcib0 not configured
attimer0 at acpipcib0 (TMR, PNP0100): AT Timer
RTC0 (PNP0B00) [AT Real-Time Clock] at acpipcib0 not configured
pckbc0 at acpipcib0 (PS2K, PNP0303): kbd port
acpibat0 at acpi0 (BAT0, PNP0C0A-0): ACPI Battery (Control Method)
2007-08-08 08:52:31 +00:00
cube 5f5f6cdbad Fix a few minor envsys2 bugs/oddities in acpi_bat(4).
- mark (DIS)CHARGERATE as invalid when (DIS)CHARGING so that envstat
   doesn't print some weird stats where the system appears to be doing
   both
 - handle the case when it's doing neither by marking *RATE as invalid
   and setting CHARGING to OFF (because we're not charging, even though
   we're not discharging)
 - fix print_stats to print correct values in those cases, and a real
   percentage (i.e., computed against LFCCAPACITY)
2007-08-08 08:36:41 +00:00
xtraeme 415820dd5e Fix up some comments. 2007-07-29 15:44:24 +00:00
xtraeme 912541575c Disable monitoring in the ACPIBAT_TECHNOLOGY sensor, which is just
informative.
2007-07-16 17:54:46 +00:00
xtraeme 5415c24ed1 aiboost_refresh_sensors: if value returned is 0, invalidate the sensor too. 2007-07-16 16:44:26 +00:00
xtraeme a003094a5a If the method returned invalid data mark the sensor as invalid and
return, but if next time data is ok mark the sensor again as valid.
2007-07-12 18:50:40 +00:00
ad 88ab7da936 Merge some of the less invasive changes from the vmlocking branch:
- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
2007-07-09 20:51:58 +00:00
xtraeme 5310357612 Adapt to the recent changes to the acpiacad(4) and acpibat(4) drivers. 2007-07-05 13:53:21 +00:00
xtraeme 65811978f4 Final round, after more comments from yamt and cube:
For indicators, if sensor is valid but it should report that it is
in disabled state (OFF), just set value_cur to 0 without changing its
state.
2007-07-05 13:47:46 +00:00
xtraeme 615572e484 acpibat_print_stat(): in the 'charging' indicator sensor, check its state
to select the correct string rather than using value_cur.
2007-07-05 12:14:18 +00:00
xtraeme 194be74536 Use only one Indicator sensor when the battery is connected/disconnected
and another one only for charging/discharging.
2007-07-05 12:08:45 +00:00
xtraeme 61142f7829 Use only one sensor to report if the AC Adapter is connected or not,
rather than using two: one when is connected and another one is
disconnected.
2007-07-05 12:07:40 +00:00
xtraeme 937ef5eeb2 Rather than using two AcpiInstallNotifyHandler() with ACPI_DEVICE_NOTIFY
and ACPI_SYSTEM_NOTIFY, use ACPI_ALL_NOTIFY and remove a redundant
call.
2007-07-03 07:44:05 +00:00
xtraeme ecb89ffa1a aiboost_refresh_sensors: initialize j before using it, to make this
build with AIBOOST_DEBUG.
2007-07-02 10:27:12 +00:00
xtraeme d0f8b29da6 aiboost_refresh_sensors:
- use the edata pointer rather than using the softc's edata array.
- if aiboost_get_value() couldn't get a proper value, invalidate the sensor.
2007-07-02 10:06:58 +00:00
xtraeme 20ba8844f6 aiboost_refresh_sensors: when refreshing a fan sensor, use the sum
of aitemp->num + aivolt->num sensors as index.

Closes PR kern/36589.
2007-07-01 20:45:10 +00:00
xtraeme da3f163bd2 Imported envsys 2, a brief description of the new features:
(Part 2: drivers)

* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
  and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
  sysmon_power(9) and powerd(8), that means there is no 32 bytes event
  size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.

Tested by:

blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 07:37:12 +00:00
jmcneill f4e11163b6 Sony firmware strikes again!
The Sony VAIO VGN-N250E (and probably others) sends BatteryInformationChanged
on AC adapter state change. Handle that here.
2007-06-27 19:44:50 +00:00
jmcneill 7d42ba2288 Don't be quite so aggressive in EcWaitEvent; makes acpiec work on the
Sony VAIO VGN-N250E, and possibly others.
2007-06-26 22:36:16 +00:00
jmcneill c0ea19f984 Don't complain if we can't evaluate _ALn. 2007-06-23 20:01:31 +00:00
xtraeme 59000b719e Missing __KERNEL_RCSID(). 2007-05-08 17:17:14 +00:00