2 * platform_gpio_keys.c: gpio_keys platform data initialization file
4 * (C) Copyright 2013 Intel Corporation
5 * Author: Sathyanarayanan Kuppuswamy <sathyanarayanan.kuppuswamy@intel.com>
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; version 2
13 #include <linux/input.h>
14 #include <linux/init.h>
15 #include <linux/kernel.h>
16 #include <linux/gpio.h>
17 #include <linux/gpio_keys.h>
18 #include <linux/platform_device.h>
19 #include <asm/intel-mid.h>
21 #define DEVICE_NAME "gpio-keys"
24 * we will search these buttons in SFI GPIO table (by name)
25 * and register them dynamically. Please add all possible
26 * buttons here, we will shrink them if no GPIO found.
28 static struct gpio_keys_button gpio_button[] = {
29 {KEY_POWER, -1, 1, "power_btn", EV_KEY, 0, 3000},
30 {KEY_PROG1, -1, 1, "prog_btn1", EV_KEY, 0, 20},
31 {KEY_PROG2, -1, 1, "prog_btn2", EV_KEY, 0, 20},
32 {SW_LID, -1, 1, "lid_switch", EV_SW, 0, 20},
33 {KEY_VOLUMEUP, -1, 1, "vol_up", EV_KEY, 0, 20},
34 {KEY_VOLUMEDOWN, -1, 1, "vol_down", EV_KEY, 0, 20},
35 {KEY_CAMERA, -1, 1, "camera_full", EV_KEY, 0, 20},
36 {KEY_CAMERA_FOCUS, -1, 1, "camera_half", EV_KEY, 0, 20},
37 {SW_KEYPAD_SLIDE, -1, 1, "MagSw1", EV_SW, 0, 20},
38 {SW_KEYPAD_SLIDE, -1, 1, "MagSw2", EV_SW, 0, 20},
41 static struct gpio_keys_platform_data gpio_keys = {
42 .buttons = gpio_button,
44 .nbuttons = -1, /* will fill it after search */
47 static struct platform_device pb_device = {
51 .platform_data = &gpio_keys,
56 * Shrink the non-existent buttons, register the gpio button
57 * device if there is some
59 static int __init pb_keys_init(void)
61 struct gpio_keys_button *gb = gpio_button;
64 num = sizeof(gpio_button) / sizeof(struct gpio_keys_button);
65 for (i = 0; i < num; i++) {
66 gb[i].gpio = get_gpio_by_name(gb[i].desc);
67 pr_debug("info[%2d]: name = %s, gpio = %d\n", i, gb[i].desc,
78 gpio_keys.nbuttons = good;
79 return platform_device_register(&pb_device);
83 late_initcall(pb_keys_init);