aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/extcon
diff options
context:
space:
mode:
authorVenkat Reddy Talla <vreddytalla@nvidia.com>2016-06-30 04:54:00 -0400
committerChanwoo Choi <cw00.choi@samsung.com>2016-07-02 01:31:34 -0400
commit1b6cf310103799f371066453f55755088b008be0 (patch)
tree50e987757c5060295487ef8750d4827120e7d126 /drivers/extcon
parent5d5c4c139dd766dff903ba35d72fb3ec90022e91 (diff)
extcon: adc-jack: add suspend/resume support
adding suspend and resume funtionality for extcon-adc-jack driver to configure system wake up for extcon events, also adding support to enable/disable system wakeup through flag wakeup_source based on platform requirement. Signed-off-by: Venkat Reddy Talla <vreddytalla@nvidia.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Diffstat (limited to 'drivers/extcon')
-rw-r--r--drivers/extcon/extcon-adc-jack.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/drivers/extcon/extcon-adc-jack.c b/drivers/extcon/extcon-adc-jack.c
index 7fc0ae1912f8..44e48aa78a84 100644
--- a/drivers/extcon/extcon-adc-jack.c
+++ b/drivers/extcon/extcon-adc-jack.c
@@ -38,6 +38,7 @@
38 * @chan: iio channel being queried. 38 * @chan: iio channel being queried.
39 */ 39 */
40struct adc_jack_data { 40struct adc_jack_data {
41 struct device *dev;
41 struct extcon_dev *edev; 42 struct extcon_dev *edev;
42 43
43 const unsigned int **cable_names; 44 const unsigned int **cable_names;
@@ -49,6 +50,7 @@ struct adc_jack_data {
49 struct delayed_work handler; 50 struct delayed_work handler;
50 51
51 struct iio_channel *chan; 52 struct iio_channel *chan;
53 bool wakeup_source;
52}; 54};
53 55
54static void adc_jack_handler(struct work_struct *work) 56static void adc_jack_handler(struct work_struct *work)
@@ -105,6 +107,7 @@ static int adc_jack_probe(struct platform_device *pdev)
105 return -EINVAL; 107 return -EINVAL;
106 } 108 }
107 109
110 data->dev = &pdev->dev;
108 data->edev = devm_extcon_dev_allocate(&pdev->dev, pdata->cable_names); 111 data->edev = devm_extcon_dev_allocate(&pdev->dev, pdata->cable_names);
109 if (IS_ERR(data->edev)) { 112 if (IS_ERR(data->edev)) {
110 dev_err(&pdev->dev, "failed to allocate extcon device\n"); 113 dev_err(&pdev->dev, "failed to allocate extcon device\n");
@@ -128,6 +131,7 @@ static int adc_jack_probe(struct platform_device *pdev)
128 return PTR_ERR(data->chan); 131 return PTR_ERR(data->chan);
129 132
130 data->handling_delay = msecs_to_jiffies(pdata->handling_delay_ms); 133 data->handling_delay = msecs_to_jiffies(pdata->handling_delay_ms);
134 data->wakeup_source = pdata->wakeup_source;
131 135
132 INIT_DEFERRABLE_WORK(&data->handler, adc_jack_handler); 136 INIT_DEFERRABLE_WORK(&data->handler, adc_jack_handler);
133 137
@@ -151,6 +155,9 @@ static int adc_jack_probe(struct platform_device *pdev)
151 return err; 155 return err;
152 } 156 }
153 157
158 if (data->wakeup_source)
159 device_init_wakeup(&pdev->dev, 1);
160
154 return 0; 161 return 0;
155} 162}
156 163
@@ -165,11 +172,38 @@ static int adc_jack_remove(struct platform_device *pdev)
165 return 0; 172 return 0;
166} 173}
167 174
175#ifdef CONFIG_PM_SLEEP
176static int adc_jack_suspend(struct device *dev)
177{
178 struct adc_jack_data *data = dev_get_drvdata(dev);
179
180 cancel_delayed_work_sync(&data->handler);
181 if (device_may_wakeup(data->dev))
182 enable_irq_wake(data->irq);
183
184 return 0;
185}
186
187static int adc_jack_resume(struct device *dev)
188{
189 struct adc_jack_data *data = dev_get_drvdata(dev);
190
191 if (device_may_wakeup(data->dev))
192 disable_irq_wake(data->irq);
193
194 return 0;
195}
196#endif /* CONFIG_PM_SLEEP */
197
198static SIMPLE_DEV_PM_OPS(adc_jack_pm_ops,
199 adc_jack_suspend, adc_jack_resume);
200
168static struct platform_driver adc_jack_driver = { 201static struct platform_driver adc_jack_driver = {
169 .probe = adc_jack_probe, 202 .probe = adc_jack_probe,
170 .remove = adc_jack_remove, 203 .remove = adc_jack_remove,
171 .driver = { 204 .driver = {
172 .name = "adc-jack", 205 .name = "adc-jack",
206 .pm = &adc_jack_pm_ops,
173 }, 207 },
174}; 208};
175 209