tpsmapi version 0.45 IBM ThinkPad hardware functions driver Author: Shem Multinymous Project: http://sourceforge.net/projects/tpctl Wiki: h…
tpsmapi version 0.45 IBM ThinkPad hardware functions driver Author: Shem Multinymous Project: http://sourceforge.net/projects/tpctl Wiki: h…
tp_smapi version 0.45 IBM ThinkPad hardware functions driver
Author: Shem Multinymous Project: http://sourceforge.net/projects/tpctl Wiki: http://thinkwiki.org/wiki/tp_smapi List: [email protected] (http://mailman.linux-thinkpad.org/mailman/listinfo/linux-thinkpad)
ThinkPad laptops include a proprietary interface called SMAPI BIOS (System Management Application Program Interface) which provides some hardware control functionality that is not accessible by other means.
This driver exposes some features of the SMAPI BIOS through a sysfs interface. It is suitable for newer models, on which SMAPI is invoked through IO port writes. Older models use a different SMAPI interface; for those, try the "thinkpad" module from the "tpctl" package.
WARNING: This driver uses undocumented features and direct hardware access. It thus cannot be guaranteed to work, and may cause arbitrary damage (especially on models it wasn't tested on).
For testing, you can simply compile and load the driver within the current working directory:
To compile and install into the kernel's module path:
If you use the HDAPS driver, use these instead to replace the hdaps module with one patched for compatibility with tp_smapi:
or
With some recent ThinkPad models, the "thinkpad_ec" will refuse to load due to reserved ports. You can force loading by passing the "force_io=1" parameter to the "thinkpad_ec" module using /etc/modules.conf (or your distribution's equivalent). To test this prior to installation, use:
To prepare a stand-alone patch against the current kernel tree (including
the hdaps replacement and Kconfig entries), assuming you have its sourcecode
under /lib/modules/uname -r/source:
To work against a kernel (other than the current one) that's properly installed under /lib/modules/*, add an appropriate KVER= parameter
To work against another kernel, you'll need to set KSRC and KBUILD too:
To delete all autogenerated files:
Append "DEBUG=1" to "make load" to load tp_smapi with debug=1.
The original kernel tree is never modified by any these commands. The /lib/modules directory is modified only by "make install".
thinkpad_ec module: force_io=1 lets thinkpad_ec load on some recent ThinkPad models (e.g., T400 and T500) whose BIOS's ACPI DSDT reserves the ports we need. tp_smapi module: debug=1 enables verbose dmesg output.
Control of battery charging thresholds (in percents of current full charge capacity):
(This is useful since Li-Ion batteries wear out much faster at very
high or low charge levels. The driver will also keeps the thresholds
across suspend-to-disk with AC disconnected; this isn't done
automatically by the hardware.)Inhibiting battery charging for 17 minutes (overrides thresholds):
(This can be used to control which battery is charged when using an
Ultrabay battery.)Forcing battery discharging even if AC power available:
(When AC is connected, forced discharging will automatically stop
when battery is fully depleted -- this is useful for calibration.
Also, this attribute can be used to control which battery is discharged
when both a system battery and an Ultrabay battery are connected.)Misc read-only battery status attributes (see note about HDAPS below):
/sys/devices/platform/smapi/BAT0/installed # 0 or 1 /sys/devices/platform/smapi/BAT0/state # idle/charging/discharging /sys/devices/platform/smapi/BAT0/cycle_count # integer counter /sys/devices/platform/smapi/BAT0/current_now # instantaneous current /sys/devices/platform/smapi/BAT0/current_avg # last minute average /sys/devices/platform/smapi/BAT0/power_now # instantaneous power /sys/devices/platform/smapi/BAT0/power_avg # last minute average /sys/devices/platform/smapi/BAT0/last_full_capacity # in mWh /sys/devices/platform/smapi/BAT0/remaining_percent # remaining percent of energy (set by calibration) /sys/devices/platform/smapi/BAT0/remaining_percent_error # error range of remaing_percent (not reset by calibration) /sys/devices/platform/smapi/BAT0/remaining_running_time # in minutes, by last minute average power /sys/devices/platform/smapi/BAT0/remaining_running_time_now # in minutes, by instantenous power /sys/devices/platform/smapi/BAT0/remaining_charging_time # in minutes /sys/devices/platform/smapi/BAT0/remaining_capacity # in mWh /sys/devices/platform/smapi/BAT0/design_capacity # in mWh /sys/devices/platform/smapi/BAT0/voltage # in mV /sys/devices/platform/smapi/BAT0/design_voltage # in mV /sys/devices/platform/smapi/BAT0/charging_max_current # max charging current /sys/devices/platform/smapi/BAT0/charging_max_voltage # max charging voltage /sys/devices/platform/smapi/BAT0/group{0,1,2,3}_voltage # see below /sys/devices/platform/smapi/BAT0/manufacturer # string /sys/devices/platform/smapi/BAT0/model # string /sys/devices/platform/smapi/BAT0/barcoding # string /sys/devices/platform/smapi/BAT0/chemistry # string /sys/devices/platform/smapi/BAT0/serial # integer /sys/devices/platform/smapi/BAT0/manufacture_date # YYYY-MM-DD /sys/devices/platform/smapi/BAT0/first_use_date # YYYY-MM-DD /sys/devices/platform/smapi/BAT0/temperature # in milli-Celsius /sys/devices/platform/smapi/BAT0/dump # see below /sys/devices/platform/smapi/ac_connected # 0 or 1
The BAT0/group{0,1,2,3}_voltage attribute refers to the separate cell groups in each battery. For example, on the ThinkPad 600, X3x, T4x and R5x models, the battery contains 3 cell groups in series, where each group consisting of 2 or 3 cells connected in parallel. The voltage of each group is given by these attributes, and their sum (roughly) equals the "voltage" attribute. (The effective performance of the battery is determined by the weakest group, i.e., the one those voltage changes most rapidly during dis/charging.)
The "BAT0/dump" attribute gives a a hex dump of the raw status data, which contains additional data now in the above (if you can figure it out). Some unused values are autodetected and replaced by "--":
In all of the above, replace BAT0 with BAT1 to address the 2nd battery (e.g. in the UltraBay).
Raw SMAPI calls:
/sys/devices/platform/smapi/smapi_request This performs raw SMAPI calls. It uses a bad interface that cannot handle multiple simultaneous access. Don't touch it, it's for development only. If you did touch it, you would so something like
and notice that in the output "211a 34b b2 0 0 0 'OK'", the "4b" in the 2nd value, converted to decimal is 75: the current charge stop threshold.
Works (at least partially) on the following ThinkPad model:
Does not work on:
Not all functions are available on all models; for detailed status, see: http://thinkwiki.org/wiki/tp_smapi
Please report success/failure by e-mail or on the Wiki. If you get a "not implemented" or "not supported" message, your laptop probably just can't do that (at least not via the SMAPI BIOS). For negative reports, follow the bug reporting guidelines below. If you send me the necessary technical data (i.e., SMAPI function interfaces), I will support additional models.
The extended battery status function conflicts with the "hdaps" kernel module (they use the same IO ports).
You can use HDAPS=1 (see Installation) to get a patched version of hdaps which is compatible with tp_smapi.
Otherwise:
If you load "hdaps" first, tp_smapi will disable these functions (and log a message in the kernel log). If you load "tp_smapi" first, "hdaps" will refuse to load. To switch between the two, "rmmod" both and then load one you need.
Some of the battery status is also visible through ACPI (/proc/acpi/battery/).
The charging control files (_charge_thresh, inhibit_charge_minutes and force_discrage) don't have this problem.
The modified hdaps driver has several improvements on the one in mainline (beyond resolving the conflict with thinkpad_ec and tp_smapi):
Fixes reliability and improves support for recent ThinkPad models (especially *60 and newer). Unlike the mainline driver, the modified hdaps correctly follows the Embedded Controller communication protocol.
Extends the "invert" parameter to cover all possible axis orientations. The possible values are as follows. Let X,Y denote the hardware readouts. Let R denote the laptop's roll (tilt left/right). Let P denote the laptop's pitch (tilt forward/backward). invert=0: R= X P= Y (same as mainline) invert=1: R=-X P=-Y (same as mainline) invert=2: R=-X P= Y (new) invert=3: R= X P=-Y (new) invert=4: R= Y P= X (new) invert=5: R=-Y P=-X (new) invert=6: R=-Y P= X (new) invert=7: R= Y P=-X (new) It's probably easiest to just try all 8 possibilities and see which yields correct results (e.g., in the hdaps-gl visualisation).
Adds a whitelist which automatically sets the correct axis orientation for some models. If the value for your model is wrong or missing, you can override it using the "invert" parameter. Please also update the tables at http://www.thinkwiki.org/wiki/tp_smapi and http://www.thinkwiki.org/wiki/List_of_DMI_IDs and submit a patch for the whitelist in hdaps.c.
Provides new attributes: /sys/devices/platform/hdaps/sampling_rate: This determines the frequency at which the host queries the embedded controller for accelerometer data (and informs the hdaps input devices). Default=50. /sys/devices/platform/hdaps/oversampling_ratio: When set to X, the embedded controller is told to do physical accelerometer measurements at a rate that is X times higher than the rate at which the driver reads those measurements (i.e., X*sampling_rate). This makes the readouts from the embedded controller more fresh, and is also useful for the running average filter (see next). Default=5 /sys/devices/platform/hdaps/running_avg_filter_order: When set to X, reported readouts will be the average of the last X physical accelerometer measurements. Current firmware allows 1. Please include:
README This fil
No open issues yet, or sync has not completed.