1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212
|
README file for
thinkpad device drivers
Last updated: 23 December 2003
Introduction
============
thinkpad.o, smapi.o, superio.o, rtcmosram.o and thinkpadpm.o (or
thinkpad.ko, smapi.ko, superio.ko, rtcmosram.ko and thinkpadpm.ko in
Linux 2.6) are device drivers in the form of loadable kernel modules
that serve as interfaces to the IBM System Management Application
Program Interface (SMAPI) BIOS found in some IBM ThinkPad laptop
computers, and as drivers of certain ThinkPad hardware components.
Access to the drivers is via the ioctl() system call. Each driver
adds an entry under /proc/driver/thinkpad named like itself which
contains some information about the driver.
These drivers were written to be used with the tpctl program.
Please see the README file for that program for more information.
Hardware requirements
=====================
IBM ThinkPad laptop computer. See the SUPPORTED-MODELS file for more
information. If this file wasn't included in the thinkpad package, look
for it in the tpctl package.
Software requirements
=====================
The drivers work with kernel 2.4.19 and later. Drivers other than the
APM-interface driver work with late 2.2 kernels. Kernels 2.3.0 through
2.4.18 and kernels prior to 2.2 are not supported.
Installation
============
If you are using Debian, install the thinkpad-base package, then
install the thinkpad-source package and use make-kpkg to make a
thinkpad-modules-<your.kern.ver> package for your kernel. This
is not the place to explain how to use make-kpkg, but an example
might be helpful. I have just installed kernel-image-2.4.20-686
on my ThinkPad 600X system. Now I:
sudo apt-get install kernel-source-2.4.20
cd /usr/src
tar jxf kernel-source-2.4.20.tar.bz2
cd kernel-source-2.4.20
cp /boot/config-2.4.20-686 .config
make-kpkg clean
make-kpkg --rootcmd=fakeroot modules-image
sudo dpkg -i ../thinkpad-modules-2.4.20-686_4.3-1+10.00.Custom_i386.deb
I am finished.
On distributions that don't set things up for you automatically,
you can install from the source tarball. First make sure that your
kernel source tree is at /lib/modules/`uname -r`/build and make
sure that the file include/linux/modversions.h is in that tree.
(It is generated by the "make dep" command in the kernel build
procedure.) Then do:
tar zxvf thinkpad_<ver.num>.src.tar.gz
cd thinkpad-<ver.num>
If you are running Linux 2.6, do:
ln -s 2.6/drivers drivers
ln -s 2.6/include include
make all
If you are running Linux 2.4, do:
ln -s 2.4/drivers drivers
ln -s 2.4/include include
make all
If you are running Linux 2.2, do:
ln -s 2.2/drivers drivers
ln -s 2.2/include include
make all
Once compilation has finished, to install the files do the following
(as root):
make install
This installs the loadable kernel modules under the directory
/lib/modules/<running-kernel-version>/thinkpad .
You may want to follow this with:
make clean
which deletes all compiled binaries from your source directory.
If you do _not_ use devfs then you must create a device node for the
thinkpad device driver. As root do:
make device
which does the following:
mkdir --mode=755 /dev/thinkpad
mknod --mode=664 /dev/thinkpad/thinkpad c 10 170
If you _do_ use devfs you don't need to make a node; the driver
modules will create nodes under /dev/thinkpad when they are loaded.
It might be useful to create a "thinkpad" group and add to it users
whom you want to allow to adjust settings. Then the device node's
group should be changed to "thinkpad". Without devfs do this as
root:
chown root:thinkpad /dev/thinkpad/thinkpad
With devfs, to make this change permanent, add the following line to
/etc/devfsd.conf and restart devfsd:
REGISTER ^thinkpad/.*$ PERMISSIONS root.thinkpad 0664
To set up automatic module loading, add the following lines to
/etc/modules.conf (or for Debian, to a file /etc/modutils/tpctl,
or for RedHat, to the file /etc/conf.modules):
keep
path[thinkpad]=/lib/modules/`uname -r`/thinkpad
options thinkpad enable_smapi=1 enable_superio=1 enable_rtcmosram=1 enable_thinkpadpm=1
alias char-major-10-170 thinkpad
alias /dev/thinkpad thinkpad
alias /dev/thinkpad/thinkpad thinkpad
alias /dev/thinkpad/smapi smapi
alias /dev/thinkpad/superio superio
alias /dev/thinkpad/rtcmosram rtcmosram
alias /dev/thinkpad/thinkpadpm thinkpadpm
and then run the "depmod -a" command as root. On debian, also run
"update-modules" as root. The "keep" line only needs to be added if it
does not already appear earlier in the file.
The package is now installed. Whew!
Uninstallation
==============
To remove all installed thinkpad device driver files:
make uninstall
Note that this removes /lib/modules/<running.kernel.version>/thinkpad
and all its contents and subdirectories!
Usage -- modules
================
The modules are loaded automatically when they are needed.
thinkpad.o dispatches requests to the other modules. It can be loaded with
the following parameters:
enable_smapi=(0|1) disable|enable use of smapi module
enable_superio=(0|1) disable|enable use of superio module
enable_rtcmosram=(0|1) disable|enable use of rtcmosram module
enable_thinkpadpm=(0|1) disable|enable use of thinkpadpm module
E.g.,
insmod thinkpad enable_superio=0
loads the thinkpad module while preventing it from using the superio module.
tpctl commands that employ the superio module will then return an error
message. The default value of each parameter is 1. These parameters can be
added to the /etc/modules.conf or /etc/conf.modules file as follows so that
they are in effect whenever thinkpad.o loaded by modprobe. E.g.,
options thinkpad enable_smapi=0 enable_superio=0
These parameters were added so that thinkpad.o can be used "safely" on
ThinkPads which lack some of the supported hardware.
The file /proc/driver/thinkpad/<module_name> contains information about each
of the drivers.
Security
========
The user requires write permission on the thinkpad device file (normally
/dev/thinkpad/thinkpad) in order to change settings or to "sedate"
the machine. This means that it is safe to allow an untrusted user to
execute tpctl or ntpctl, so long as he or she doesn't have write
permission on the device file.
References
==========
In writing the code I found the following documentation helpful.
With the advent of kernel 2.4.0 much of their content is out of date.
------------------------------------------------------------------------
IBM. _IBM ThinkPad 560Z Technical Reference_. First ed (October 1998).
_IBM ThinkPad 560 Technical Reference_.
_IBM ThinkPad 600 Technical Reference_.
_IBM ThinkPad 765 Technical Reference_.
_IBM ThinkPad 770 Technical Reference_.
National Semiconductor. _PC87338/PC97338 data sheet_. November, 1998.
Pomerantz, Ori. _Linux kernel module programming guide_. Version 1.1.0
26 April 1999.
Rubini, Alessandro. _Linux device drivers_. Cambridge: O'Reilly, 1998.
Rubini, Alessandro and Jonathan Corbet. _Linux device drivers_. 2nd ed.
Cambridge, O'Reilly, 2001.
http://www.oreilly.com/catalog/linuxdrive2/chapter/book/index.html
------------------------------------------------------------------------
The first of the IBM Technical Reference manuals listed is the most
current and correct that I have found. All are available in the
"support" section of IBM's website www.ibm.com.
I thank Ori Pomerantz for his contribution.
The O'Reilly book, now in its second edition, is superb.
--
Thomas Hood
|