Difference between revisions of "SMAPI support for Linux"

From ThinkWiki
Jump to: navigation, search
m (Model-specific status: - sort)
(tp_smapi v0.09)
Line 13: Line 13:
 
* Project page: http://tpctl.sourceforge.net/
 
* Project page: http://tpctl.sourceforge.net/
 
* You need to donwnload only the [http://sourceforge.net/project/showfiles.php?group_id=1212&package_id=171579 tp_smapi kernel module].
 
* You need to donwnload only the [http://sourceforge.net/project/showfiles.php?group_id=1212&package_id=171579 tp_smapi kernel module].
 +
 +
====Installation====
  
 
To compile and load the module:
 
To compile and load the module:
  
  # tar xzvf tp_smapi-0.08.tgz
+
  # tar xzvf tp_smapi-0.09.tgz
  # cd tp_smapi-0.08
+
  # cd tp_smapi-0.09
 
  # make load
 
  # make load
  
Line 24: Line 26:
 
  # make install
 
  # make install
 
  # modprobe tp_smapi
 
  # modprobe tp_smapi
 +
 +
====Battery charge control features====
  
 
To set the thresholds for starting and stopping battery charging (in percent of current full charge capacity):
 
To set the thresholds for starting and stopping battery charging (in percent of current full charge capacity):
  
  # echo 40 > /sys/devices/platform/smapi/start_charge_thresh
+
  # echo 40 > /sys/devices/platform/smapi/BAT0/start_charge_thresh
  # echo 70 > /sys/devices/platform/smapi/stop_charge_thresh
+
  # echo 70 > /sys/devices/platform/smapi/BAT0/stop_charge_thresh
  # cat /sys/devices/platform/smapi/*_charge_thresh
+
  # cat /sys/devices/platform/smapi/BAT0/*_charge_thresh
 
  40  
 
  40  
 
  70
 
  70
Line 35: Line 39:
 
To unconditionally inhibit charging for 17 minutes:
 
To unconditionally inhibit charging for 17 minutes:
  
  # echo 17 > /sys/devices/platform/smapi/inhibit_charge_minutes
+
  # echo 17 > /sys/devices/platform/smapi/BAT0/inhibit_charge_minutes
  
 
To cancel charge inhibiting:
 
To cancel charge inhibiting:
  
  # echo 0 > /sys/devices/platform/smapi/inhibit_charge_minutes
+
  # echo 0 > /sys/devices/platform/smapi/BAT0/inhibit_charge_minutes
 +
 
 +
====Battery status features====
 +
 
 +
To view exteded battery status (see below about conflict with <tt>hdaps</tt>):
 +
 
 +
# cat /sys/devices/platform/smapi/BAT0/installed
 +
# cat /sys/devices/platform/smapi/BAT0/cycle_count
 +
# cat /sys/devices/platform/smapi/BAT0/current1
 +
# cat /sys/devices/platform/smapi/BAT0/current2
 +
# cat /sys/devices/platform/smapi/BAT0/last_full_capacity
 +
# cat /sys/devices/platform/smapi/BAT0/remaining_capacity
 +
# cat /sys/devices/platform/smapi/BAT0/design_capacity
 +
# cat /sys/devices/platform/smapi/BAT0/voltage
 +
# cat /sys/devices/platform/smapi/BAT0/design_voltage
 +
# cat /sys/devices/platform/smapi/BAT0/manufacturer
 +
# cat /sys/devices/platform/smapi/BAT0/model
 +
# cat /sys/devices/platform/smapi/BAT0/serial
 +
# cat /sys/devices/platform/smapi/BAT0/barcoding
 +
# cat /sys/devices/platform/smapi/BAT0/chemistry
 +
 
 +
The raw status data, including some fields not in the above (in case
 +
you can figure them out):
 +
 
 +
# cat /sys/devices/platform/smapi/BAT0/dump 
 +
 
 +
In all of the above, replace <tt>BAT0</tt> with <tt>BAT1</tt> to address the 2nd battery.
 +
 
 +
====Optical drive control features====
  
 
To control the speed of the optical drive:
 
To control the speed of the optical drive:
Line 49: Line 81:
 
  2
 
  2
  
 +
====Other features====
 +
 +
Other things that can be controlled through SMAPI, but are not supported in this version of the driver, include forcing battery discharge, PCI bus power saving, CPU power saving control and fan control. See the included README file for more information.
  
Other things that can be controlled through SMAPI, but are not supported in this version of the driver, include forcing battery discharge, PCI bus power saving, CPU power saving control, extended smart battery information and fan control. See the included README file for more information.
+
====Conflict with <tt>hdaps</tt>====
 +
 
 +
The extended battery status function conflicts with the [[HDAPS|hdaps]] kernel module (they use the same IO ports). If you load <tt>hdaps</tt> first, <tt>tp_smapi</tt> will disable its battery status functions (and log a message in the kernel log). If you load <tt>tp_smapi</tt> first, <tt>hdaps</tt> will refuse to load. Use <tt>rmmod</tt> to switch between the two.
 +
 
 +
Some of the battery status is also visible through ACPI ({{path|/proc/acpi/battery/*}}).
 +
 
 +
The charging control files (<tt>*_charge_thresh</tt> and <tt>inhibit_charge_minutes</tt>) don't have this problem.
  
 
====Model-specific status====
 
====Model-specific status====
 +
* ThinkPad {{T43}}
 +
**    all works
 
* ThinkPad {{T43}}, {{T43p}}, {{R52}}
 
* ThinkPad {{T43}}, {{T43p}}, {{R52}}
 
**    all works
 
**    all works
 +
**    unknown: battery status
 
* ThinkPad {{X41}}
 
* ThinkPad {{X41}}
 
**    work:      all battery-related
 
**    work:      all battery-related
 
**    unknown:    cdrom_speed
 
**    unknown:    cdrom_speed
 +
**    unknown: battery status
 
* ThinkPad {{G41}}
 
* ThinkPad {{G41}}
 
**    work:      start_charge_thresh, inhbit_charge_minutes, cdrom_speed
 
**    work:      start_charge_thresh, inhbit_charge_minutes, cdrom_speed
 
**    don't work: stop_charge_thresh (not supported by hardware)
 
**    don't work: stop_charge_thresh (not supported by hardware)
 +
**    unknown: battery status
 
* ThinkPad {{T42p}}, {{T41}}, {{R51}}, {{X40}}
 
* ThinkPad {{T42p}}, {{T41}}, {{R51}}, {{X40}}
 
**    work:      start_charge_thresh, inhbit_charge_minutes
 
**    work:      start_charge_thresh, inhbit_charge_minutes
 
**    don't work: stop_charge_thresh (not supported by hardware)
 
**    don't work: stop_charge_thresh (not supported by hardware)
 
**    unknown:    cdrom_speed
 
**    unknown:    cdrom_speed
 +
**    unknown: battery status
 
* ThinkPad {{T42}}
 
* ThinkPad {{T42}}
 
**    work:      start_charge_thresh, cdrom_speed
 
**    work:      start_charge_thresh, cdrom_speed
 
**    unknown:    inhbit_charge_minutes, stop_charge_thresh
 
**    unknown:    inhbit_charge_minutes, stop_charge_thresh
 +
**    unknown: battery status
 
* ThinkPad {{T41p}}, {{T40}}, {{T40p}}, {{R50p}}, {{R40}}
 
* ThinkPad {{T41p}}, {{T40}}, {{T40p}}, {{R50p}}, {{R40}}
 
**    work:      cdrom_speed
 
**    work:      cdrom_speed
 
**    don't work: all battery-related (not supported by hardware)
 
**    don't work: all battery-related (not supported by hardware)
 +
**    unknown: battery status
 
* ThinkPad {{X32}}, {{X31}}
 
* ThinkPad {{X32}}, {{X31}}
 
**    don't work: all battery-related (not supported by hardware)
 
**    don't work: all battery-related (not supported by hardware)
 
**    unknown:    cdrom_speed
 
**    unknown:    cdrom_speed
 +
**    unknown: battery status
  
 
Please update the above and report your experience on the [[Talk:SMAPI support for Linux|discussion]] page. If the module loads but gives a "<tt>not supported</tt>" or "<tt>not implementeded</tt>" when you try to use some specific file in {{path|/sys/devices/platform/smapi/}}, please report the <tt>dmesg</tt> output and whether the corresponding functionality is available under Windows - maybe your ThinkPad just can't do that.
 
Please update the above and report your experience on the [[Talk:SMAPI support for Linux|discussion]] page. If the module loads but gives a "<tt>not supported</tt>" or "<tt>not implementeded</tt>" when you try to use some specific file in {{path|/sys/devices/platform/smapi/}}, please report the <tt>dmesg</tt> output and whether the corresponding functionality is available under Windows - maybe your ThinkPad just can't do that.

Revision as of 01:59, 13 December 2005

ThinkPad laptops include a proprietary interface called SMAPI BIOS (System Management Application Program Interface) which provides some hardware control functionality that is not exposed by any other interface (e.g., ACPI).

The SMAPI interfaces changes a lot between models, and is poorly documented, so Linux support is not exhaustive for most models. There are currently two SMAPI access mechanisms available: thinkpad and tpctl for older ThinkPads, and tp_smapi for newer ones.

ATTENTION!
These drivers use undocumented features and direct hardware access. They thus cannot be guaranteed to work, and may cause arbitrary damage (especially on models they weren't tested on).

Using the tp_smapi module

The tp_smapi kernel module exposes some features of the SMAPI BIOS found on recent ThinkPads via a sysfs interface. Currently, the implemented functionality is control of battery charging (this is useful for increasing battery lifetime or for using a leftover under-spec power supply that can't handle the combined power draw of running and charging), and control of CD/DVD speed.

Installation

To compile and load the module:

# tar xzvf tp_smapi-0.09.tgz
# cd tp_smapi-0.09
# make load

To install permanently (optional):

# make install
# modprobe tp_smapi

Battery charge control features

To set the thresholds for starting and stopping battery charging (in percent of current full charge capacity):

# echo 40 > /sys/devices/platform/smapi/BAT0/start_charge_thresh
# echo 70 > /sys/devices/platform/smapi/BAT0/stop_charge_thresh
# cat /sys/devices/platform/smapi/BAT0/*_charge_thresh
40 
70

To unconditionally inhibit charging for 17 minutes:

# echo 17 > /sys/devices/platform/smapi/BAT0/inhibit_charge_minutes

To cancel charge inhibiting:

# echo 0 > /sys/devices/platform/smapi/BAT0/inhibit_charge_minutes

Battery status features

To view exteded battery status (see below about conflict with hdaps):

# cat /sys/devices/platform/smapi/BAT0/installed
# cat /sys/devices/platform/smapi/BAT0/cycle_count
# cat /sys/devices/platform/smapi/BAT0/current1 
# cat /sys/devices/platform/smapi/BAT0/current2
# cat /sys/devices/platform/smapi/BAT0/last_full_capacity
# cat /sys/devices/platform/smapi/BAT0/remaining_capacity
# cat /sys/devices/platform/smapi/BAT0/design_capacity
# cat /sys/devices/platform/smapi/BAT0/voltage
# cat /sys/devices/platform/smapi/BAT0/design_voltage
# cat /sys/devices/platform/smapi/BAT0/manufacturer
# cat /sys/devices/platform/smapi/BAT0/model
# cat /sys/devices/platform/smapi/BAT0/serial
# cat /sys/devices/platform/smapi/BAT0/barcoding 
# cat /sys/devices/platform/smapi/BAT0/chemistry

The raw status data, including some fields not in the above (in case you can figure them out):

# cat /sys/devices/platform/smapi/BAT0/dump  

In all of the above, replace BAT0 with BAT1 to address the 2nd battery.

Optical drive control features

To control the speed of the optical drive:

ATTENTION!
Changing the CD speed simultaneously with a read or write to the CD will hang your computer. The hdparm -E or eject -x commands might also work for you, and are safer (but have no effect on some models, such as ThinkPad 43).
Kernel hackers: if you know how to obtain locks that temporarily prevents the ide and ata_piix+libata drivers from touching the drive, or at least how to check whether an ATAPI device is being accessed, please tell the author.
# echo 0 > /sys/devices/platform/smapi/cdrom_speed # slow
# echo 1 > /sys/devices/platform/smapi/cdrom_speed # medium
# echo 2 > /sys/devices/platform/smapi/cdrom_speed # fast
# cat /sys/devices/platform/smapi/cdrom_speed
2

Other features

Other things that can be controlled through SMAPI, but are not supported in this version of the driver, include forcing battery discharge, PCI bus power saving, CPU power saving control and fan control. See the included README file for more information.

Conflict with hdaps

The extended battery status function conflicts with the hdaps kernel module (they use the same IO ports). If you load hdaps first, tp_smapi will disable its battery status functions (and log a message in the kernel log). If you load tp_smapi first, hdaps will refuse to load. Use rmmod to switch between the two.

Some of the battery status is also visible through ACPI (/proc/acpi/battery/*).

The charging control files (*_charge_thresh and inhibit_charge_minutes) don't have this problem.

Model-specific status

  • ThinkPad T43
    • all works
  • ThinkPad T43, T43p, R52
    • all works
    • unknown: battery status
  • ThinkPad X41
    • work: all battery-related
    • unknown: cdrom_speed
    • unknown: battery status
  • ThinkPad G41
    • work: start_charge_thresh, inhbit_charge_minutes, cdrom_speed
    • don't work: stop_charge_thresh (not supported by hardware)
    • unknown: battery status
  • ThinkPad T42p, T41, R51, X40
    • work: start_charge_thresh, inhbit_charge_minutes
    • don't work: stop_charge_thresh (not supported by hardware)
    • unknown: cdrom_speed
    • unknown: battery status
  • ThinkPad T42
    • work: start_charge_thresh, cdrom_speed
    • unknown: inhbit_charge_minutes, stop_charge_thresh
    • unknown: battery status
  • ThinkPad T41p, T40, T40p, R50p, R40
    • work: cdrom_speed
    • don't work: all battery-related (not supported by hardware)
    • unknown: battery status
  • ThinkPad X32, X31
    • don't work: all battery-related (not supported by hardware)
    • unknown: cdrom_speed
    • unknown: battery status

Please update the above and report your experience on the discussion page. If the module loads but gives a "not supported" or "not implementeded" when you try to use some specific file in /sys/devices/platform/smapi/, please report the dmesg output and whether the corresponding functionality is available under Windows - maybe your ThinkPad just can't do that.

Using the thinkpad module

This solution consists of a module, called thinkpad, and a user-space tool caled tpctl. It provides very rich functionality for older ThinkPads, but on newer ThinkPads much of this functionality is exposed and supported through an ACPI interface and the SMAPI access does not work anymore. For Linux kernel 2.6.3 and newer you need tpctl >=4.14 and thinkpad >=5.5. For details, see the README and list of supported models.