import of tp-smapi version 0.30

This commit is contained in:
Shem Multinymous 2006-08-17 10:51:02 +02:00 committed by Evgeni Golov
parent 32a12d64c7
commit 48bf5e6066
6 changed files with 63 additions and 24 deletions

23
CHANGES
View File

@ -1,5 +1,28 @@
Change history for tp_smapi:
0.30 2006-09-03
---------------------
Visible changes:
- Makefile: now supports kernels built with separate source and build
directories (thanks to Lenz Grimmer).
To work against against some kernel installed under /lib/modules/
add an appropriate KVER= parameter:
# make patch KVER=2.6.16-rc2
If it's not installed you'll need to set KSRC and KBUILD too:
# make patch KVER=2.6.16-rc2 KSRC=$HOME/2.6.16-rc2 KBUILD=$HOME/2.6.16-rc2
- Changed the format of /sys/devices/platform/smapi/smapi_request
(no more register names).
Internal changes:
- tp_smapi: the 'dump' sysfs attribute now outputs only rows 0x00 through 0x0a,
since 0x0b causes an EC hang on some firmware (e.g., all T42 and old T43).
Thanks to Henrique and Sukant for tracking this down!
- thinkpad_ec: Log a warning if 0x161F returns 0x80.
- thinkpad_ec: Increase TPC_REQUEST_RETRIES
- thinkpad_ec: Report row args upon data read error.
- hdaps: Apply hwmon-hdaps-handle-errors-from-input-register-device.patch
from -mm.
0.29 2006-08-17
---------------------
Visible changes:

View File

@ -2,8 +2,10 @@ ifndef TP_MODULES
# This part runs as a normal, top-level Makefile:
X:=$(shell false)
KVER := $(shell uname -r)
KSRC := /lib/modules/$(KVER)/build
MOD_DIR := /lib/modules/$(KVER)/kernel
KBASE := /lib/modules/$(KVER)
KSRC := $(KBASE)/source
KBUILD := $(KBASE)/build
MOD_DIR := $(KBASE)/kernel
PWD := $(shell pwd)
IDIR := include/linux
TP_DIR := drivers/firmware
@ -33,7 +35,7 @@ default: modules
# Build the modules thinkpad_ec.ko, tp_smapi.ko and (if HDAPS=1) hdaps.ko
modules: $(KSRC) dmi_ec_oem_string.h $(patsubst %.o,%.c,$(TP_MODULES))
$(MAKE) -C $(KSRC) M=$(PWD) modules
$(MAKE) -C $(KSRC) M=$(PWD) O=$(KBUILD) modules
clean:
rm -f tp_smapi.mod.* tp_smapi.o tp_smapi.ko .tp_smapi.*.cmd
@ -74,7 +76,7 @@ ifeq ($(HDAPS),1)
rm -f $(MOD_DIR)/drivers/hwmon/hdaps.ko
rm -f $(MOD_DIR)/extra/hdaps.ko
endif
$(MAKE) -C $(KSRC) M=$(PWD) modules_install
$(MAKE) -C $(KSRC) M=$(PWD) O=$(KBUILD) modules_install
depmod -a

19
README
View File

@ -1,4 +1,4 @@
tp_smapi version 0.29
tp_smapi version 0.30
IBM ThinkPad hardware functions driver
Author: Shem Multinymous <multinymous@gmail.com>
@ -45,8 +45,11 @@ To prepare a stand-alone patch against the current kernel tree (including
a compatibility fixes to hdaps and Kconfig entries):
# make patch
To prepare a stand-alone patch against another kernel, follow this example:
# make patch KSRC=/path/to/linux-2.6.16-rc2 KVER=2.6.16-rc2
To work against a kernel (other than the current one) that's
installed under /lib/modules/, add an appropriate KVER= parameter
# make patch KVER=2.6.16-rc2
To work against an uninstalled kernel, you'll need to set KSRC and KBUILD too:
# make patch KVER=2.6.16-rc2 KSRC=$HOME/2.6.16-rc2 KBUILD=$HOME/2.6.16-rc2
To delete all autogenerated files:
# make clean
@ -156,6 +159,11 @@ 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
# echo '211a 100 0 0' > /sys/devices/platform/smapi/smapi_request
# cat /sys/devices/platform/smapi/smapi_request
and notice that in the output "211a 34b b2 0 0 0 'OK'", the "4b" in the 2nd
parameter, converted to decimal is 75: the current charge stop threshold.
Model-specific status
@ -254,11 +262,6 @@ inhibit_charge_minutes was set and comparing to current time.
Save and and restore inhibit_charge_minutes across suspend-to-disk, as done
for charge thresholds (requires the above time calculations too).
Other things that can be controlled through SMAPI, but are not supported
in this version of the driver, PCI bus power saving, CPU power saving control
and fan control. For below. I don't plain to implement all those features, but
the current framework should be a base for contributions.
More about SMAPI
----------------

View File

@ -754,13 +754,17 @@ static int __init hdaps_init(void)
input_set_abs_params(hdaps_idev, ABS_Y,
-256, 256, HDAPS_INPUT_FUZZ, HDAPS_INPUT_FLAT);
input_register_device(hdaps_idev);
ret = input_register_device(hdaps_idev);
if (ret)
goto out_idev;
mod_timer(&hdaps_timer, jiffies + HZ/sampling_rate);
printk(KERN_INFO "hdaps: driver successfully loaded.\n");
return 0;
out_idev:
input_free_device(hdaps_idev);
out_group:
sysfs_remove_group(&pdev->dev.kobj, &hdaps_attribute_group);
out_device:

View File

@ -36,7 +36,7 @@
#include <linux/jiffies.h>
#include <asm/io.h>
#define TP_VERSION "0.29"
#define TP_VERSION "0.30"
MODULE_AUTHOR("Shem Multinymous");
MODULE_DESCRIPTION("ThinkPad embedded controller hardware access");
@ -61,7 +61,7 @@ MODULE_LICENSE("GPL");
/* Timeouts and retries */
#define TPC_READ_RETRIES 150
#define TPC_READ_NDELAY 500
#define TPC_REQUEST_RETRIES 100
#define TPC_REQUEST_RETRIES 1000
#define TPC_REQUEST_NDELAY 10
#define TPC_PREFETCH_TIMEOUT (HZ/10) /* invalidate prefetch after 0.1sec */
@ -194,7 +194,8 @@ static int thinkpad_ec_request_row(const struct thinkpad_ec_row *args)
/* Read current row data from the controller, assuming it's already
* requested.
*/
static int thinkpad_ec_read_data(struct thinkpad_ec_row *data)
static int thinkpad_ec_read_data(const struct thinkpad_ec_row *args,
struct thinkpad_ec_row *data)
{
int i;
u8 str3 = inb(TPC_STR3_PORT) & H8S_STR3_MASK;
@ -209,7 +210,7 @@ static int thinkpad_ec_read_data(struct thinkpad_ec_row *data)
/* Finally, the EC signals output buffer full: */
if (str3 != (H8S_STR3_OBF3B|H8S_STR3_SWMF)) {
printk(KERN_WARNING
MSG_FMT("bad initial STR3 (0x%02x)", str3));
REQ_FMT("bad initial STR3", str3));
return -EIO;
}
@ -226,7 +227,11 @@ static int thinkpad_ec_read_data(struct thinkpad_ec_row *data)
str3 = inb(TPC_STR3_PORT) & H8S_STR3_MASK;
if (str3 & H8S_STR3_OBF3B)
printk(KERN_WARNING
MSG_FMT("OBF3B=1 after read (0x%02x)", str3));
REQ_FMT("OBF3B=1 after read", str3));
/* If port 0x161F returns 0x80 too often, the EC may lock up: */
if (data->val[0xF] == 0x80)
printk(KERN_WARNING
REQ_FMT("0x161F reports error", data->val[0xF]));
return 0;
}
@ -282,7 +287,7 @@ int thinkpad_ec_read_row(const struct thinkpad_ec_row *args,
read_row:
/* Read the row's data */
for (retries=0; retries<TPC_READ_RETRIES; ++retries) {
ret = thinkpad_ec_read_data(data);
ret = thinkpad_ec_read_data(args, data);
if (!ret)
goto out;
if (ret!=-EBUSY)
@ -319,7 +324,7 @@ int thinkpad_ec_try_read_row(const struct thinkpad_ec_row *args,
if (!thinkpad_ec_is_row_fetched(args)) {
ret = -ENODATA;
} else {
ret = thinkpad_ec_read_data(data);
ret = thinkpad_ec_read_data(args, data);
if (!ret)
prefetch_jiffies = TPC_PREFETCH_NONE; /* eaten up */
}

View File

@ -41,7 +41,7 @@
#include <asm/uaccess.h>
#include <asm/io.h>
#define TP_VERSION "0.29"
#define TP_VERSION "0.30"
#define TP_DESC "ThinkPad SMAPI Support"
#define TP_DIR "smapi"
@ -1093,6 +1093,8 @@ static int show_battery_first_use_date(
* a battery. Some of the enumerated values don't exist (i.e., the EC function
* does not touch a register); we use a kludge to detect and denote these.
*/
#define MIN_DUMP_ARG0 0x00
#define MAX_DUMP_ARG0 0x0a /* 0x0b is useful too but hangs old EC firmware */
static int show_battery_dump(
struct device *dev, struct device_attribute *attr, char *buf)
{
@ -1104,7 +1106,7 @@ static int show_battery_dump(
const u8 junka=0xAA, junkb=0x55; /* junk values for testing changes */
int ret;
for (arg0=0x00; arg0<=0x0b; ++arg0) {
for (arg0=MIN_DUMP_ARG0; arg0<=MAX_DUMP_ARG0; ++arg0) {
if ( (p-buf) > PAGE_SIZE-TP_CONTROLLER_ROW_LEN*5 )
return -ENOMEM; /* don't overflow sysfs buf */
/* Read raw twice with different junk values,
@ -1189,7 +1191,7 @@ static int store_smapi_request(struct device *dev,
u32 outEBX, outECX, outEDX, outEDI, outESI;
const char* msg;
int ret;
if (sscanf(buf, "BX=%x CX=%x DI=%x SI=%x", &inEBX, &inECX, &inEDI, &inESI) != 4) {
if (sscanf(buf, "%x %x %x %x", &inEBX, &inECX, &inEDI, &inESI) != 4) {
smapi_attr_answer[0] = '\0';
return -EINVAL;
}
@ -1197,7 +1199,7 @@ static int store_smapi_request(struct device *dev,
inEBX, inECX, inEDI, inESI,
&outEBX, &outECX, &outEDX, &outEDI, &outESI, &msg);
snprintf(smapi_attr_answer, MAX_SMAPI_ATTR_ANSWER_LEN,
"BX=%x CX=%x DX=%x DI=%x SI=%x ret=%d msg=%s\n",
"%x %x %x %x %x %d '%s'\n",
(unsigned int)outEBX, (unsigned int)outECX, (unsigned int)outEDX,
(unsigned int)outEDI, (unsigned int)outESI, ret, msg);
if (ret)