/*
* ibm_acpi.c - IBM ThinkPad ACPI Extras
*
*
* Copyright (C) 2004 Borislav Deianov
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Changelog:
*
* 2004-08-09 0.1 initial release, support for X series
* 2004-08-14 0.2 support for T series, X20
* bluetooth enable/disable
* hotkey events disabled by default
* removed fan control, currently useless
* 2004-08-17 0.3 support for R40
* lcd off, brightness control
* thinklight on/off
* 2004-09-16 0.4 support for module parameters
* hotkey mask can be prefixed by 0x
* video output switching
* video expansion control
* ultrabay eject support
* removed lcd brightness/on/off control, didn't work
* 2004-10-18 0.5 thinklight support on A21e, G40, R32, T20, T21, X20
* proc file format changed
* video_switch command
* experimental cmos control
* experimental led control
* experimental acpi sounds
* 2004-10-19 0.6 use acpi_bus_register_driver() to claim HKEY device
* 2004-10-23 0.7 fix module loading on A21e, A22p, T20, T21, X20
* fix LED control on A21e
* 2004-11-08 0.8 fix init error case, don't return from a macro
* thanks to Chris Wright <chrisw@osdl.org>
*/
#define IBM_VERSION "0.8"
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/types.h>
#include <linux/proc_fs.h>
#include <asm/uaccess.h>
#include <acpi/acpi_drivers.h>
#include <acpi/acnamesp.h>
#define IBM_NAME "ibm"
#define IBM_DESC "IBM ThinkPad ACPI Extras"
#define IBM_FILE "ibm_acpi"
#define IBM_URL "http://ibm-acpi.sf.net/"
#define IBM_DIR IBM_NAME
#define IBM_LOG IBM_FILE ": "
#define IBM_ERR KERN_ERR IBM_LOG
#define IBM_NOTICE KERN_NOTICE IBM_LOG
#define IBM_INFO KERN_INFO IBM_LOG
#define IBM_DEBUG KERN_DEBUG IBM_LOG
#define IBM_MAX_ACPI_ARGS 3
#define __unused __attribute__ ((unused))
static int experimental;
module_param(experimental, int, 0);
static acpi_handle root_handle = NULL;
#define IBM_HANDLE(object, parent, paths...) \
static acpi_handle object##_handle; \
static acpi_handle *object##_parent = &parent##_handle; \
static char *object##_paths[] = { paths }
IBM_HANDLE(ec, root,
"\\_SB.PCI0.ISA.EC", /* A21e, A22p, T20, T21, X20 */
"\\_SB.PCI0.LPC.EC", /* all others */
);
IBM_HANDLE(vid, root,
"\\_SB.PCI0.VID", /* A21e, G40, X30, X40 */
"\\_SB.PCI0.AGP.VID", /* all others */
);
IBM_HANDLE(cmos, root,
"\\UCMS", /* R50, R50p, R51, T4x, X31, X40 */
"\\CMOS", /* A3x, G40, R32, T23, T30, X22, X24, X30 */
"\\CMS", /* R40, R40e */
); /* A21e, A22p, T20, T21, X20 */
IBM_HANDLE(dock, root,
"\\_SB.GDCK", /* X30, X31, X40 */
"\\_SB.PCI0.DOCK", /* A22p, T20, T21, X20 */
"\\_SB.PCI0.PCI1.DOCK", /* all others */
); /* A21e, G40, R32, R40, R40e */
IBM_HANDLE(bay, root,
"\\_SB.PCI0.IDE0.SCND.MSTR"); /* all except A21e */
IBM_HANDLE(bayej, root,
"\\_SB.PCI0.IDE0.SCND.MSTR._EJ0"); /* all except A2x, A3x */
IBM_HANDLE(lght, root, "\\LGHT"); /* A21e, A22p, T20, T21, X20 */
IBM_HANDLE(hkey, ec, "HKEY"); /* all */
IBM_HANDLE(led, ec, "LED"); /* all except A21e, A22p, T20, T21, X20 */
IBM_HANDLE(sysl, ec, "SYSL"); /* A21e, A22p, T20, T21, X20 */
IBM_HANDLE(bled, ec, "BLED"); /* A22p, T20, T21, X20 */
IBM_HANDLE(beep, ec, "BEEP"); /* all models */
struct ibm_struct {
char *name;
char *hid;
struct acpi_driver *driver;
int (*init) (struct ibm_struct *);
int (*read) (struct ibm_struct *, char *);
int (*write) (struct ibm_struct *, char *)