-
Notifications
You must be signed in to change notification settings - Fork 0
/
axp-powerkey.c
106 lines (97 loc) · 3.22 KB
/
axp-powerkey.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/*
* drivers/power/axp/axp-powerkey.c
* (C) Copyright 2010-2016
* Allwinner Technology Co., Ltd. <www.allwinnertech.com>
* Pannan <[email protected]>
*
* axp powerkey APIs
*
* 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.
*
*/
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/types.h>
#include <linux/device.h>
#include <linux/workqueue.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/power_supply.h>
#include <linux/delay.h>
#include <linux/kthread.h>
#include <linux/slab.h>
#include <linux/debugfs.h>
#include <linux/seq_file.h>
#include <linux/input.h>
#include <linux/of.h>
#include "axp-core.h"
#include "axp-powerkey.h"
static irqreturn_t axp_key_up_handler(int irq, void *data)
{
struct axp_powerkey_info *info = (struct axp_powerkey_info *)data;
AXP_DEBUG(AXP_INT, info->chip->pmu_num, "power key up\n");
input_report_key(info->idev, KEY_POWER, 0);
input_sync(info->idev);
return IRQ_HANDLED;
}
static irqreturn_t axp_key_down_handler(int irq, void *data)
{
struct axp_powerkey_info *info = (struct axp_powerkey_info *)data;
AXP_DEBUG(AXP_INT, info->chip->pmu_num, "power key down\n");
input_report_key(info->idev, KEY_POWER, 1);
input_sync(info->idev);
return IRQ_HANDLED;
}
static irqreturn_t axp_presslong_handler(int irq, void *data)
{
struct axp_powerkey_info *info = (struct axp_powerkey_info *)data;
AXP_DEBUG(AXP_INT, info->chip->pmu_num, "power key long\n");
input_report_key(info->idev, KEY_POWER, 1);
input_sync(info->idev);
ssleep(2);
input_report_key(info->idev, KEY_POWER, 0);
input_sync(info->idev);
return IRQ_HANDLED;
}
static irqreturn_t axp_pressshort_handler(int irq, void *data)
{
struct axp_powerkey_info *info = (struct axp_powerkey_info *)data;
AXP_DEBUG(AXP_INT, info->chip->pmu_num, "power key short\n");
input_report_key(info->idev, KEY_POWER, 1);
input_sync(info->idev);
msleep(100);
input_report_key(info->idev, KEY_POWER, 0);
input_sync(info->idev);
return IRQ_HANDLED;
}
struct axp_interrupts axp_powerkey_irq[4] = {
{"PEK_DBR", axp_key_up_handler},
{"PEK_DBF", axp_key_down_handler},
{"PEK_LONG", axp_presslong_handler},
{"PEK_SHORT", axp_pressshort_handler},
};
int axp_powerkey_dt_parse(struct device_node *node,
struct axp_config_info *axp_config)
{
if (!of_device_is_available(node)) {
pr_err("%s: failed\n", __func__);
return -1;
}
printk("[axp]parsing node name:%s in line:%d in:%s \n",node->name,__LINE__,__func__);
AXP_OF_PROP_READ(pmu_powkey_off_time, 6000);
AXP_OF_PROP_READ(pmu_powkey_off_func, 0);
AXP_OF_PROP_READ(pmu_powkey_off_en, 1);
AXP_OF_PROP_READ(pmu_powkey_off_delay_time, 0);
AXP_OF_PROP_READ(pmu_powkey_long_time, 1500);
AXP_OF_PROP_READ(pmu_powkey_on_time, 1000);
AXP_OF_PROP_READ(pmu_pwrok_time, 64);
AXP_OF_PROP_READ(pmu_pwrnoe_time, 2000);
return 0;
}
EXPORT_SYMBOL_GPL(axp_powerkey_dt_parse);
MODULE_DESCRIPTION("ALLWINNERTECH axp powerkey");
MODULE_AUTHOR("pannan");
MODULE_LICENSE("GPL");