mirror of
https://github.com/linux-thinkpad/tp_smapi.git
synced 2024-09-11 07:05:28 +03:00
import of tp-smapi version 0.38
This commit is contained in:
parent
6cb5f3e763
commit
ae8bc8a13c
9
CHANGES
9
CHANGES
@ -1,5 +1,14 @@
|
||||
Change history for tp_smapi:
|
||||
|
||||
0.38 2008-09-26
|
||||
---------------------
|
||||
- Fixed compilation on kernel 2.6.27-rc7
|
||||
- tp_smapi: Added a new battery attribute
|
||||
/sys/devices/platform/smapi/BAT?/remaining_percent_error
|
||||
This is the error margin for the remaing_percent attribute.
|
||||
Unfortunately, it doesn't seem to be reset by battery calibration.
|
||||
- hdaps: Removed the fake_data_mode attribute.
|
||||
|
||||
0.37 2008-03-28
|
||||
---------------------
|
||||
- Fix compilation on kernel 2.6.25
|
||||
|
19
README
19
README
@ -1,4 +1,4 @@
|
||||
tp_smapi version 0.37
|
||||
tp_smapi version 0.38
|
||||
IBM ThinkPad hardware functions driver
|
||||
|
||||
Author: Shem Multinymous <multinymous@gmail.com>
|
||||
@ -102,8 +102,10 @@ Forcing battery discharging even if AC power available:
|
||||
# echo 0 > /sys/devices/platform/smapi/BAT0/force_discharge # stop discharge
|
||||
# cat /sys/devices/platform/smapi/BAT0/force_discharge
|
||||
|
||||
(This can be used to control which battery is discharged when using an
|
||||
Ultrabay battery.)
|
||||
(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):
|
||||
|
||||
@ -115,7 +117,8 @@ Misc read-only battery status attributes (see note about HDAPS below):
|
||||
/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
|
||||
/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
|
||||
@ -259,10 +262,6 @@ The modified hdaps driver has several improvements on the one in mainline
|
||||
embedded controller, so no CPU resources are used. Higher values make the
|
||||
readouts smoother, since it averages out both sensor noise (good) and abrupt
|
||||
changes (bad). Default=2.
|
||||
/sys/devices/platform/hdaps/fake_data_mode:
|
||||
If set to 1, enables a test mode where the physical accelerometer readouts
|
||||
are replaced with an incrementing counter. This is useful for checking the
|
||||
regularity of the sampling interval and driver<->userspace communication.
|
||||
|
||||
- Provides a second input device, which publishes the raw accelerometer
|
||||
measurements (without the fuzzing needed for joystick emulation). This input
|
||||
@ -330,7 +329,7 @@ For hints about what may be possible via the SMAPI BIOS and how, see:
|
||||
* Exported symbols in PWRMGRIF.DLL or TPPWRW32.DLL (e.g., use "objdump -x").
|
||||
* drivers/char/mwave/smapi.c in the Linux kernel tree.*
|
||||
* The "thinkpad" SMAPI module (http://tpctl.sourceforge.net).
|
||||
* The SMAPI_* constants in tp_smapi.c (some of these are presently unused).
|
||||
* The SMAPI_* constants in tp_smapi.c.
|
||||
|
||||
Note that in the above Technical Reference and in the "thinkpad" module,
|
||||
SMAPI is invoked through a function call to some physical address. However,
|
||||
@ -347,5 +346,5 @@ In addition, the embedded controller on ThinkPad laptops has a non-standard
|
||||
interface at IO ports 0x1600-0x161F (mapped to LCP channel 3 of the H8S chip).
|
||||
The interface provides various system management services (currently known:
|
||||
battery information and accelerometer readouts). For more information see the
|
||||
thinkpad_ec modul and the H8S hardware documentation:
|
||||
thinkpad_ec module and the H8S hardware documentation:
|
||||
http://documentation.renesas.com/eng/products/mpumcu/rej09b0300_2140bhm.pdf
|
||||
|
49
hdaps.c
49
hdaps.c
@ -95,7 +95,6 @@ static int sampling_rate = 50; /* Sampling rate */
|
||||
static int oversampling_ratio = 5; /* Ratio between our sampling rate and
|
||||
* EC accelerometer sampling rate */
|
||||
static int running_avg_filter_order = 2; /* EC running average filter order */
|
||||
static int fake_data_mode; /* Enable EC fake data mode? */
|
||||
|
||||
/* Latest state readout: */
|
||||
static int pos_x, pos_y; /* position */
|
||||
@ -238,28 +237,6 @@ static int hdaps_set_power(int on)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* hdaps_set_fake_data_mode - enable or disable EC test mode
|
||||
* EC test mode fakes accelerometer data using an incrementing counter.
|
||||
* Returns zero on success and negative error code on failure. Can sleep.
|
||||
*/
|
||||
static int hdaps_set_fake_data_mode(int on)
|
||||
{
|
||||
struct thinkpad_ec_row args =
|
||||
{ .mask = 0x0007, .val = {0x17, 0x83, on?0x01:0x00} };
|
||||
struct thinkpad_ec_row data = { .mask = 0x8000 };
|
||||
int ret = thinkpad_ec_read_row(&args, &data);
|
||||
if (ret)
|
||||
return ret;
|
||||
if (data.val[0xF] != 0x00) {
|
||||
printk(KERN_WARNING "failed setting hdaps fake data to %d\n",
|
||||
on);
|
||||
return -EIO;
|
||||
}
|
||||
printk(KERN_DEBUG "hdaps: fake_data_mode set to %d\n", on);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* hdaps_set_ec_config - set accelerometer parameters.
|
||||
* @ec_rate: embedded controller sampling rate
|
||||
@ -399,9 +376,6 @@ static int hdaps_device_init(void)
|
||||
running_avg_filter_order))
|
||||
{ FAILED_INIT("hdaps_set_ec_config failed"); goto bad; }
|
||||
|
||||
if (hdaps_set_fake_data_mode(fake_data_mode))
|
||||
{ FAILED_INIT("hdaps_set_fake_data_mode failed"); goto bad; }
|
||||
|
||||
thinkpad_ec_invalidate();
|
||||
udelay(200);
|
||||
|
||||
@ -678,26 +652,6 @@ static ssize_t hdaps_running_avg_filter_order_store(
|
||||
return count;
|
||||
}
|
||||
|
||||
static ssize_t hdaps_fake_data_mode_store(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
int on, ret;
|
||||
if (sscanf(buf, "%d", &on) != 1 || on < 0 || on > 1)
|
||||
return -EINVAL;
|
||||
ret = hdaps_set_fake_data_mode(on);
|
||||
if (ret)
|
||||
return ret;
|
||||
fake_data_mode = on;
|
||||
return count;
|
||||
}
|
||||
|
||||
static ssize_t hdaps_fake_data_mode_show(
|
||||
struct device *dev, struct device_attribute *attr, char *buf)
|
||||
{
|
||||
return sprintf(buf, "%d\n", fake_data_mode);
|
||||
}
|
||||
|
||||
static int hdaps_mousedev_open(struct input_dev *dev)
|
||||
{
|
||||
if (!try_module_get(THIS_MODULE))
|
||||
@ -737,8 +691,6 @@ static DEVICE_ATTR(oversampling_ratio, 0644,
|
||||
static DEVICE_ATTR(running_avg_filter_order, 0644,
|
||||
hdaps_running_avg_filter_order_show,
|
||||
hdaps_running_avg_filter_order_store);
|
||||
static DEVICE_ATTR(fake_data_mode, 0644,
|
||||
hdaps_fake_data_mode_show, hdaps_fake_data_mode_store);
|
||||
|
||||
static struct attribute *hdaps_attributes[] = {
|
||||
&dev_attr_position.attr,
|
||||
@ -750,7 +702,6 @@ static struct attribute *hdaps_attributes[] = {
|
||||
&dev_attr_sampling_rate.attr,
|
||||
&dev_attr_oversampling_ratio.attr,
|
||||
&dev_attr_running_avg_filter_order.attr,
|
||||
&dev_attr_fake_data_mode.attr,
|
||||
NULL,
|
||||
};
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
* known: battery information and accelerometer readouts). This driver
|
||||
* provides access and mutual exclusion for the EC interface.
|
||||
*
|
||||
* The LPC protocol and terminology is documented here:
|
||||
* The LPC protocol and terminology are documented here:
|
||||
* "H8S/2104B Group Hardware Manual",
|
||||
* http://documentation.renesas.com/eng/products/mpumcu/rej09b0300_2140bhm.pdf
|
||||
*
|
||||
@ -36,10 +36,10 @@
|
||||
#include <linux/delay.h>
|
||||
#include <linux/thinkpad_ec.h>
|
||||
#include <linux/jiffies.h>
|
||||
#include <asm/semaphore.h>
|
||||
#include <linux/semaphore.h>
|
||||
#include <asm/io.h>
|
||||
|
||||
#define TP_VERSION "0.37"
|
||||
#define TP_VERSION "0.38"
|
||||
|
||||
MODULE_AUTHOR("Shem Multinymous");
|
||||
MODULE_DESCRIPTION("ThinkPad embedded controller hardware access");
|
||||
|
20
tp_smapi.c
20
tp_smapi.c
@ -4,15 +4,17 @@
|
||||
* This driver exposes some features of the System Management Application
|
||||
* Program Interface (SMAPI) BIOS found on ThinkPad laptops. It works on
|
||||
* models in which the SMAPI BIOS runs in SMM and is invoked by writing
|
||||
* to the APM control port 0xB2. Older models use a different interface;
|
||||
* for those, try the out-of-tree "thinkpad" module from "tpctl".
|
||||
* to the APM control port 0xB2.
|
||||
* It also exposes battery status information, obtained from the ThinkPad
|
||||
* embedded controller (via the thinkpad_ec module).
|
||||
* Ancient ThinkPad models use a different interface, supported by the
|
||||
* "thinkpad" module from "tpctl".
|
||||
*
|
||||
* Many of the battery status values obtained from the EC simply mirror
|
||||
* values provided by the battery's Smart Battery System (SBS) interface, so
|
||||
* their meaning is defined by the Smart Battery Data Specification.
|
||||
* References to this SBS spec are given in the code where relevant.
|
||||
* their meaning is defined by the Smart Battery Data Specification (see
|
||||
* http://sbs-forum.org/specs/sbdat110.pdf). References to this SBS spec
|
||||
* are given in the code where relevant.
|
||||
*
|
||||
* Copyright (C) 2006 Shem Multinymous <multinymous@gmail.com>.
|
||||
* SMAPI access code based on the mwave driver by Mike Sullivan.
|
||||
@ -45,7 +47,7 @@
|
||||
#include <asm/uaccess.h>
|
||||
#include <asm/io.h>
|
||||
|
||||
#define TP_VERSION "0.37"
|
||||
#define TP_VERSION "0.38"
|
||||
#define TP_DESC "ThinkPad SMAPI Support"
|
||||
#define TP_DIR "smapi"
|
||||
|
||||
@ -1040,6 +1042,13 @@ static ssize_t show_battery_remaining_percent(
|
||||
return show_tp_ec_bat_u16(1, 12, 1, NULL, attr, buf);
|
||||
}
|
||||
|
||||
static ssize_t show_battery_remaining_percent_error(
|
||||
struct device *dev, struct device_attribute *attr, char *buf)
|
||||
{
|
||||
/* units: percent. SBS spec v1.1 p25: MaxError() */
|
||||
return show_tp_ec_bat_u16(9, 4, 1, NULL, attr, buf);
|
||||
}
|
||||
|
||||
static ssize_t show_battery_remaining_charging_time(
|
||||
struct device *dev, struct device_attribute *attr, char *buf)
|
||||
{
|
||||
@ -1326,6 +1335,7 @@ static struct attribute_group tp_root_attribute_group = {
|
||||
_ATTR_R(_BAT, power_now) \
|
||||
_ATTR_R(_BAT, power_avg) \
|
||||
_ATTR_R(_BAT, remaining_percent) \
|
||||
_ATTR_R(_BAT, remaining_percent_error) \
|
||||
_ATTR_R(_BAT, remaining_charging_time) \
|
||||
_ATTR_R(_BAT, remaining_running_time) \
|
||||
_ATTR_R(_BAT, remaining_running_time_now) \
|
||||
|
Loading…
Reference in New Issue
Block a user