aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/keyboard/gpio_keys.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/input/keyboard/gpio_keys.c')
-rw-r--r--drivers/input/keyboard/gpio_keys.c126
1 files changed, 124 insertions, 2 deletions
diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index bf75ef5..6feb939 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -47,10 +47,20 @@ struct gpio_keys_drvdata {
unsigned int n_buttons;
int (*enable)(struct device *dev);
void (*disable)(struct device *dev);
+#ifdef CONFIG_SENSORS_HALL
+ int gpio_flip_cover;
+ bool flip_cover;
+ struct delayed_work flip_cover_dwork;
+#endif
struct gpio_button_data data[0];
/* WARNING: this area can be expanded. Do NOT add any member! */
};
+#ifdef CONFIG_SENSORS_HALL
+int flip_cover_open;
+extern ts_powered_on;
+#endif
+
/*
* SYSFS interface for enabling/disabling keys and switches:
*
@@ -376,12 +386,36 @@ out:
return count;
}
+#ifdef CONFIG_SENSORS_HALL
+static ssize_t hall_detect_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct gpio_keys_drvdata *ddata = dev_get_drvdata(dev);
+
+ if (ddata->flip_cover){
+ printk("%s: OPEN",__func__);
+ sprintf(buf, "OPEN");
+ }else{
+ printk("%s: CLOSE",__func__);
+ sprintf(buf, "CLOSE");
+ }
+
+ return strlen(buf);
+}
+#endif
+
static DEVICE_ATTR(sec_key_pressed, 0664, key_pressed_show, NULL);
static DEVICE_ATTR(wakeup_keys, 0664, NULL, wakeup_enable);
+#ifdef CONFIG_SENSORS_HALL
+static DEVICE_ATTR(hall_detect, 0664, hall_detect_show, NULL);
+#endif
static struct attribute *sec_key_attrs[] = {
&dev_attr_sec_key_pressed.attr,
&dev_attr_wakeup_keys.attr,
+#ifdef CONFIG_SENSORS_HALL
+ &dev_attr_hall_detect.attr,
+#endif
NULL,
};
@@ -531,9 +565,16 @@ static void gpio_keys_report_event(struct gpio_button_data *bdata)
}
}
#endif
+#ifdef CONFIG_SENSORS_HALL
+ if(!flip_cover_open && button->code == KEY_POWER){
+ printk(KERN_DEBUG" cover closed...ignoring PWR button");
+ }else{
+#endif
input_event(input, type, button->code, !!state);
input_sync(input);
-
+#ifdef CONFIG_SENSORS_HALL
+ }
+#endif
if (button->code == KEY_POWER)
printk(KERN_DEBUG"[keys]PWR %d\n", !!state);
}
@@ -652,11 +693,85 @@ fail2:
return error;
}
+#ifdef CONFIG_SENSORS_HALL
+static void flip_cover_work(struct work_struct *work)
+{
+ struct gpio_keys_drvdata *ddata =
+ container_of(work, struct gpio_keys_drvdata,
+ flip_cover_dwork.work);
+
+ ddata->flip_cover = gpio_get_value(ddata->gpio_flip_cover);
+
+ printk(KERN_DEBUG "[keys] %s : %d\n",
+ __func__, ddata->flip_cover);
+
+ /* input_report_switch(ddata->input, SW_FLIP, ddata->flip_cover);
+ input_sync(ddata->input);*/
+
+ flip_cover_open = ddata->flip_cover;
+
+ if(!ts_powered_on && !ddata->flip_cover){
+ printk("[keys] screen already off\n");
+ }else if(ts_powered_on && ddata->flip_cover){
+ printk("[keys] screen already on\n");
+ }else{
+ input_report_key(ddata->input, KEY_POWER, 1);
+ input_sync(ddata->input);
+ input_report_key(ddata->input, KEY_POWER, 0);
+ input_sync(ddata->input);
+ }
+}
+
+static irqreturn_t flip_cover_detect(int irq, void *dev_id)
+{
+ struct gpio_keys_drvdata *ddata = dev_id;
+
+ cancel_delayed_work_sync(&ddata->flip_cover_dwork);
+ schedule_delayed_work(&ddata->flip_cover_dwork, HZ / 20);
+ return IRQ_HANDLED;
+}
+#endif
+
static int gpio_keys_open(struct input_dev *input)
{
struct gpio_keys_drvdata *ddata = input_get_drvdata(input);
+
+#ifdef CONFIG_SENSORS_HALL
+ int ret = 0;
+ int irq = gpio_to_irq(ddata->gpio_flip_cover);
+
+ INIT_DELAYED_WORK(&ddata->flip_cover_dwork, flip_cover_work);
+
+ ret = request_threaded_irq(
+ irq, NULL,
+ flip_cover_detect,
+ IRQF_DISABLED | IRQF_TRIGGER_RISING |
+ IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
+ "flip_cover", ddata);
+
+ if (ret) {
+ printk(KERN_ERR
+ "keys: failed to request flip cover irq %d gpio %d\n",
+ irq, ddata->gpio_flip_cover);
+ goto hall_sensor_error;
+ }
+
+ ret = enable_irq_wake(irq);
+ if (ret < 0) {
+ printk(KERN_ERR
+ "keys: Failed to Enable Wakeup Source(%d) \n",
+ ret);
+ goto hall_sensor_error;
+ }
+
+ /* update the current status */
+ schedule_delayed_work(&ddata->flip_cover_dwork, HZ / 2);
- return ddata->enable ? ddata->enable(input->dev.parent) : 0;
+hall_sensor_error:
+
+#endif
+
+ return ddata->enable ? ddata->enable(input->dev.parent) : 0;
}
static void gpio_keys_close(struct input_dev *input)
@@ -690,6 +805,9 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev)
ddata->n_buttons = pdata->nbuttons;
ddata->enable = pdata->enable;
ddata->disable = pdata->disable;
+#ifdef CONFIG_SENSORS_HALL
+ ddata->gpio_flip_cover = pdata->gpio_flip_cover;
+#endif
mutex_init(&ddata->disable_lock);
platform_set_drvdata(pdev, ddata);
@@ -698,6 +816,10 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev)
input->name = pdata->name ? : pdev->name;
input->phys = "gpio-keys/input0";
input->dev.parent = &pdev->dev;
+/*#ifdef CONFIG_SENSORS_HALL
+ input->evbit[0] |= BIT_MASK(EV_SW);
+ input_set_capability(input, EV_SW, SW_FLIP);
+#endif*/
input->open = gpio_keys_open;
input->close = gpio_keys_close;