2 * atlas_btns.c - Atlas Wallmount Touchscreen ACPI Extras
4 * Copyright (C) 2006 Jaya Kumar
5 * Based on Toshiba ACPI by John Belmonte and ASUS ACPI
6 * This work was sponsored by CIS(M) Sdn Bhd.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include <linux/kernel.h>
25 #include <linux/module.h>
26 #include <linux/init.h>
27 #include <linux/input.h>
28 #include <linux/types.h>
29 #include <asm/uaccess.h>
30 #include <acpi/acpi_drivers.h>
32 #define ACPI_ATLAS_NAME "Atlas ACPI"
33 #define ACPI_ATLAS_CLASS "Atlas"
34 #define ACPI_ATLAS_BUTTON_HID "ASIM0000"
36 static struct input_dev *input_dev;
38 /* button handling code */
39 static acpi_status acpi_atlas_button_setup(acpi_handle region_handle,
40 u32 function, void *handler_context, void **return_context)
43 (function != ACPI_REGION_DEACTIVATE) ? handler_context : NULL;
48 static acpi_status acpi_atlas_button_handler(u32 function,
49 acpi_physical_address address,
50 u32 bit_width, acpi_integer *value,
51 void *handler_context, void *region_context)
56 if (function == ACPI_WRITE) {
57 keycode = KEY_F1 + (address & 0x0F);
58 input_report_key(input_dev, keycode, !(address & 0x10));
59 input_sync(input_dev);
62 printk(KERN_WARNING "atlas: shrugged on unexpected function"
63 ":function=%x,address=%lx,value=%x\n",
64 function, (unsigned long)address, (u32)*value);
71 static int atlas_acpi_button_add(struct acpi_device *device)
76 input_dev = input_allocate_device();
78 printk(KERN_ERR "atlas: unable to allocate input device\n");
82 input_dev->name = "Atlas ACPI button driver";
83 input_dev->phys = "ASIM0000/atlas/input0";
84 input_dev->id.bustype = BUS_HOST;
85 input_dev->evbit[LONG(EV_KEY)] = BIT(EV_KEY);
87 set_bit(KEY_F1, input_dev->keybit);
88 set_bit(KEY_F2, input_dev->keybit);
89 set_bit(KEY_F3, input_dev->keybit);
90 set_bit(KEY_F4, input_dev->keybit);
91 set_bit(KEY_F5, input_dev->keybit);
92 set_bit(KEY_F6, input_dev->keybit);
93 set_bit(KEY_F7, input_dev->keybit);
94 set_bit(KEY_F8, input_dev->keybit);
95 set_bit(KEY_F9, input_dev->keybit);
97 err = input_register_device(input_dev);
99 printk(KERN_ERR "atlas: couldn't register input device\n");
100 input_free_device(input_dev);
104 /* hookup button handler */
105 status = acpi_install_address_space_handler(device->handle,
106 0x81, &acpi_atlas_button_handler,
107 &acpi_atlas_button_setup, device);
108 if (ACPI_FAILURE(status)) {
109 printk(KERN_ERR "Atlas: Error installing addr spc handler\n");
110 input_unregister_device(input_dev);
117 static int atlas_acpi_button_remove(struct acpi_device *device, int type)
121 status = acpi_remove_address_space_handler(device->handle,
122 0x81, &acpi_atlas_button_handler);
123 if (ACPI_FAILURE(status)) {
124 printk(KERN_ERR "Atlas: Error removing addr spc handler\n");
128 input_unregister_device(input_dev);
133 static struct acpi_driver atlas_acpi_driver = {
134 .name = ACPI_ATLAS_NAME,
135 .class = ACPI_ATLAS_CLASS,
136 .ids = ACPI_ATLAS_BUTTON_HID,
138 .add = atlas_acpi_button_add,
139 .remove = atlas_acpi_button_remove,
143 static int __init atlas_acpi_init(void)
150 result = acpi_bus_register_driver(&atlas_acpi_driver);
152 printk(KERN_ERR "Atlas ACPI: Unable to register driver\n");
159 static void __exit atlas_acpi_exit(void)
161 acpi_bus_unregister_driver(&atlas_acpi_driver);
164 module_init(atlas_acpi_init);
165 module_exit(atlas_acpi_exit);
167 MODULE_AUTHOR("Jaya Kumar");
168 MODULE_LICENSE("GPL");
169 MODULE_DESCRIPTION("Atlas button driver");