aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/extcon/extcon-adc-jack.c34
-rw-r--r--include/linux/extcon/extcon-adc-jack.h2
2 files changed, 36 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
diff --git a/include/linux/extcon/extcon-adc-jack.h b/include/linux/extcon/extcon-adc-jack.h
index 53c60806bcfb..ac85f2061351 100644
--- a/include/linux/extcon/extcon-adc-jack.h
+++ b/include/linux/extcon/extcon-adc-jack.h
@@ -53,6 +53,7 @@ struct adc_jack_cond {
53 * milli-seconds after the interrupt occurs. You may 53 * milli-seconds after the interrupt occurs. You may
54 * describe such delays with @handling_delay_ms, which 54 * describe such delays with @handling_delay_ms, which
55 * is rounded-off by jiffies. 55 * is rounded-off by jiffies.
56 * @wakeup_source: flag to wake up the system for extcon events.
56 */ 57 */
57struct adc_jack_pdata { 58struct adc_jack_pdata {
58 const char *name; 59 const char *name;
@@ -65,6 +66,7 @@ struct adc_jack_pdata {
65 66
66 unsigned long irq_flags; 67 unsigned long irq_flags;
67 unsigned long handling_delay_ms; /* in ms */ 68 unsigned long handling_delay_ms; /* in ms */
69 bool wakeup_source;
68}; 70};
69 71
70#endif /* _EXTCON_ADC_JACK_H */ 72#endif /* _EXTCON_ADC_JACK_H */