diff options
author | Matthew Bouyack <mbouyack@google.com> | 2021-08-06 15:00:13 -0700 |
---|---|---|
committer | Andrew Evans <andrewevans@google.com> | 2022-03-09 15:04:45 -0800 |
commit | 8419716c20c2d69e99cce41e0cd06015ea1123fb (patch) | |
tree | 35f9e41b0b4bef51bad35621bd0c2e8f3e8b2d23 /ots_pat9126 | |
parent | 1975f2209f933d8c70b9c600203ed21ff9ab31f8 (diff) | |
download | rotary-encoders-8419716c20c2d69e99cce41e0cd06015ea1123fb.tar.gz |
Wake on RSB rotation
Set the RSB IRQ as a wake interrupt and keep the system
awake until the event can be passed to userspace.
Signed-off-by: Matthew Bouyack <mbouyack@google.com>
Bug: 181563147
Change-Id: Ibf9f28bedecdb9abf309b1193beb2931a6d1a11c
Diffstat (limited to 'ots_pat9126')
-rw-r--r-- | ots_pat9126/pat9126.c | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/ots_pat9126/pat9126.c b/ots_pat9126/pat9126.c index d967063..49f6cb2 100644 --- a/ots_pat9126/pat9126.c +++ b/ots_pat9126/pat9126.c @@ -70,6 +70,9 @@ struct rw_reg_info pat9126_reg_info; /* Declaration of suspend and resume functions */ static int pat9126_suspend(struct device *dev); static int pat9126_resume(struct device *dev); +#else +static int pat9126_enable_irq_wake(struct device *dev); +static int pat9126_disable_irq_wake(struct device *dev); #endif static int pat9126_write(struct i2c_client *client, u8 addr, u8 data) @@ -367,14 +370,17 @@ static void pat9126_work_handler(struct work_struct *work) input_sync(ipdev); } enable_irq(data->client->irq); + pm_relax(dev); } static irqreturn_t pat9126_irq(int irq, void *dev_data) { struct pixart_pat9126_data *data = dev_data; + struct device *dev = &data->client->dev; bool result = false; disable_irq_nosync(irq); + pm_stay_awake(dev); if (!work_pending(&data->work)) { result = schedule_delayed_work(&data->polling_work, msecs_to_jiffies(10)); if (result == false) { @@ -812,6 +818,26 @@ static int pat9126_resume(struct device *dev) return 0; } +#else +static int pat9126_enable_irq_wake(struct device *dev) +{ + struct pixart_pat9126_data *data = + (struct pixart_pat9126_data *) dev_get_drvdata(dev); + + enable_irq_wake(data->client->irq); + + return 0; +} + +static int pat9126_disable_irq_wake(struct device *dev) +{ + struct pixart_pat9126_data *data = + (struct pixart_pat9126_data *) dev_get_drvdata(dev); + + disable_irq_wake(data->client->irq); + + return 0; +} #endif static const struct i2c_device_id pat9126_device_id[] = { @@ -820,12 +846,15 @@ static const struct i2c_device_id pat9126_device_id[] = { }; MODULE_DEVICE_TABLE(i2c, pat9126_device_id); -#if defined(PAT9126_PM_OPS) static const struct dev_pm_ops pat9126_pm_ops = { +#if defined(PAT9126_PM_OPS) .suspend = pat9126_suspend, .resume = pat9126_resume -}; +#else + .suspend = pat9126_enable_irq_wake, + .resume = pat9126_disable_irq_wake #endif +}; static const struct of_device_id pixart_pat9126_match_table[] = { { .compatible = "pixart,pat9126",}, @@ -836,9 +865,7 @@ static struct i2c_driver pat9126_i2c_driver = { .driver = { .name = PAT9126_DEV_NAME, .owner = THIS_MODULE, -#if defined(PAT9126_PM_OPS) .pm = &pat9126_pm_ops, -#endif .of_match_table = pixart_pat9126_match_table, }, .probe = pat9126_i2c_probe, |