24 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
26 #include <linux/kernel.h>
27 #include <linux/module.h>
29 #include <linux/input.h>
30 #include <linux/types.h>
31 #include <asm/uaccess.h>
34 #define ACPI_ATLAS_NAME "Atlas ACPI"
35 #define ACPI_ATLAS_CLASS "Atlas"
37 static unsigned short atlas_keymap[16];
38 static struct input_dev *input_dev;
42 u32 function,
void *handler_context,
void **return_context)
53 void *handler_context,
void *region_context)
58 int code = address & 0x0f;
59 int key_down = !(address & 0x10);
62 input_report_key(input_dev, atlas_keymap[code], key_down);
63 input_sync(input_dev);
67 pr_warn(
"shrugged on unexpected function: function=%x,address=%lx,value=%x\n",
68 function, (
unsigned long)address, (
u32)*value);
75 static int atlas_acpi_button_add(
struct acpi_device *
device)
81 input_dev = input_allocate_device();
83 pr_err(
"unable to allocate input device\n");
87 input_dev->name =
"Atlas ACPI button driver";
88 input_dev->phys =
"ASIM0000/atlas/input0";
90 input_dev->keycode = atlas_keymap;
91 input_dev->keycodesize =
sizeof(
unsigned short);
92 input_dev->keycodemax =
ARRAY_SIZE(atlas_keymap);
96 for (i = 0; i <
ARRAY_SIZE(atlas_keymap); i++) {
104 err = input_register_device(input_dev);
106 pr_err(
"couldn't register input device\n");
107 input_free_device(input_dev);
113 0x81, &acpi_atlas_button_handler,
114 &acpi_atlas_button_setup, device);
116 pr_err(
"error installing addr spc handler\n");
117 input_unregister_device(input_dev);
124 static int atlas_acpi_button_remove(
struct acpi_device *device,
int type)
129 0x81, &acpi_atlas_button_handler);
131 pr_err(
"error removing addr spc handler\n");
133 input_unregister_device(input_dev);
144 static struct acpi_driver atlas_acpi_driver = {
148 .ids = atlas_device_ids,
150 .add = atlas_acpi_button_add,
151 .remove = atlas_acpi_button_remove,