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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
|
#include <accdet_hal.h>
#include <mach/mt_boot.h>
#include <cust_eint.h>
#include <cust_gpio_usage.h>
#include <mach/mt_gpio.h>
/* #include "accdet_drv.h" */
static struct platform_driver accdet_driver;
static int debug_enable_drv = 1;
#define ACCDET_DEBUG_DRV(format, args...) do { \
if (debug_enable_drv) \
{\
printk(KERN_DEBUG format, ##args);\
} \
} while (0)
static long accdet_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
return mt_accdet_unlocked_ioctl(cmd, arg);
}
static int accdet_open(struct inode *inode, struct file *file)
{
return 0;
}
static int accdet_release(struct inode *inode, struct file *file)
{
return 0;
}
static struct file_operations accdet_fops = {
.owner = THIS_MODULE,
.unlocked_ioctl = accdet_unlocked_ioctl,
.open = accdet_open,
.release = accdet_release,
};
struct file_operations *accdet_get_fops(void)
{
return &accdet_fops;
}
static int accdet_probe(struct platform_device *dev)
{
return mt_accdet_probe();
}
static int accdet_remove(struct platform_device *dev)
{
mt_accdet_remove();
return 0;
}
static int accdet_suspend(struct device *device) /* wake up */
{
mt_accdet_suspend();
return 0;
}
static int accdet_resume(struct device *device) /* wake up */
{
mt_accdet_resume();
return 0;
}
/**********************************************************************
//add for IPO-H need update headset state when resume
***********************************************************************/
#ifdef CONFIG_PM
static int accdet_pm_restore_noirq(struct device *device)
{
mt_accdet_pm_restore_noirq();
return 0;
}
static struct dev_pm_ops accdet_pm_ops = {
.suspend = accdet_suspend,
.resume = accdet_resume,
.restore_noirq = accdet_pm_restore_noirq,
};
#endif
#if defined(CONFIG_OF)
struct platform_device accdet_device = {
.name ="Accdet_Driver",
.id = -1,
/* .dev ={ */
/* .release = accdet_dumy_release, */
/* } */
};
#endif
static struct platform_driver accdet_driver = {
.probe = accdet_probe,
/* .suspend = accdet_suspend, */
/* .resume = accdet_resume, */
.remove = accdet_remove,
.driver = {
.name = "Accdet_Driver",
#ifdef CONFIG_PM
.pm = &accdet_pm_ops,
#endif
},
};
struct platform_driver accdet_driver_func(void)
{
return accdet_driver;
}
static int accdet_mod_init(void)
{
int ret = 0;
ACCDET_DEBUG_DRV("[Accdet]accdet_mod_init begin!\n");
#if defined(CONFIG_OF)
ret = platform_device_register(&accdet_device);
printk("[%s]: accdet_device, retval=%d \n!", __func__, ret);
if (ret != 0)
{
printk("platform_device_accdet_register error:(%d)\n", ret);
return ret;
}
else
{
printk("platform_device_accdet_register done!\n");
}
#endif
/* ------------------------------------------------------------------ */
/* Accdet PM */
/* ------------------------------------------------------------------ */
ret = platform_driver_register(&accdet_driver);
if (ret) {
ACCDET_DEBUG_DRV("[Accdet]platform_driver_register error:(%d)\n", ret);
return ret;
} else {
ACCDET_DEBUG_DRV("[Accdet]platform_driver_register done!\n");
}
ACCDET_DEBUG_DRV("[Accdet]accdet_mod_init done!\n");
return 0;
}
static void accdet_mod_exit(void)
{
ACCDET_DEBUG_DRV("[Accdet]accdet_mod_exit\n");
platform_driver_unregister(&accdet_driver);
ACCDET_DEBUG_DRV("[Accdet]accdet_mod_exit Done!\n");
}
/*Patch for CR ALPS00804150 & ALPS00804802 PMIC temp not correct issue*/
int accdet_cable_type_state(void)
{
/* ACCDET_DEBUG("[ACCDET] accdet_cable_type_state=%d\n",accdet_get_cable_type()); */
return accdet_get_cable_type();
}
EXPORT_SYMBOL(accdet_cable_type_state);
/*Patch for CR ALPS00804150 & ALPS00804802 PMIC temp not correct issue*/
module_init(accdet_mod_init);
module_exit(accdet_mod_exit);
module_param(debug_enable_drv, int, 0644);
MODULE_DESCRIPTION("MTK MT6588 ACCDET driver");
MODULE_AUTHOR("Anny <Anny.Hu@mediatek.com>");
MODULE_LICENSE("GPL");
|