mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-22 06:32:08 +00:00
Input: cros_ec_keyb - mark cros_ec_keyb driver as wake enabled device.
Mark cros_ec_keyb has wake enabled by default. If we see a MKBP event related to keyboard, call pm_wakeup_event() to make sure wakeup triggers are accounted to keyb during suspend resume path. Signed-off-by: Ravi Chandra Sadineni <ravisadineni@chromium.org> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
This commit is contained in:
parent
cbd606ec9f
commit
38ba34a43d
2 changed files with 28 additions and 24 deletions
|
@ -244,24 +244,35 @@ static int cros_ec_keyb_work(struct notifier_block *nb,
|
||||||
|
|
||||||
switch (ckdev->ec->event_data.event_type) {
|
switch (ckdev->ec->event_data.event_type) {
|
||||||
case EC_MKBP_EVENT_KEY_MATRIX:
|
case EC_MKBP_EVENT_KEY_MATRIX:
|
||||||
|
if (device_may_wakeup(ckdev->dev)) {
|
||||||
|
pm_wakeup_event(ckdev->dev, 0);
|
||||||
|
} else {
|
||||||
/*
|
/*
|
||||||
* If EC is not the wake source, discard key state changes
|
* If keyboard is not wake enabled, discard key state
|
||||||
* during suspend.
|
* changes during suspend. Switches will be re-checked
|
||||||
|
* in cros_ec_keyb_resume() to be sure nothing is lost.
|
||||||
*/
|
*/
|
||||||
if (queued_during_suspend)
|
if (queued_during_suspend)
|
||||||
return NOTIFY_OK;
|
return NOTIFY_OK;
|
||||||
|
}
|
||||||
|
|
||||||
if (ckdev->ec->event_size != ckdev->cols) {
|
if (ckdev->ec->event_size != ckdev->cols) {
|
||||||
dev_err(ckdev->dev,
|
dev_err(ckdev->dev,
|
||||||
"Discarded incomplete key matrix event.\n");
|
"Discarded incomplete key matrix event.\n");
|
||||||
return NOTIFY_OK;
|
return NOTIFY_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
cros_ec_keyb_process(ckdev,
|
cros_ec_keyb_process(ckdev,
|
||||||
ckdev->ec->event_data.data.key_matrix,
|
ckdev->ec->event_data.data.key_matrix,
|
||||||
ckdev->ec->event_size);
|
ckdev->ec->event_size);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EC_MKBP_EVENT_SYSRQ:
|
case EC_MKBP_EVENT_SYSRQ:
|
||||||
|
if (device_may_wakeup(ckdev->dev))
|
||||||
|
pm_wakeup_event(ckdev->dev, 0);
|
||||||
|
else if (queued_during_suspend)
|
||||||
|
return NOTIFY_OK;
|
||||||
|
|
||||||
val = get_unaligned_le32(&ckdev->ec->event_data.data.sysrq);
|
val = get_unaligned_le32(&ckdev->ec->event_data.data.sysrq);
|
||||||
dev_dbg(ckdev->dev, "sysrq code from EC: %#x\n", val);
|
dev_dbg(ckdev->dev, "sysrq code from EC: %#x\n", val);
|
||||||
handle_sysrq(val);
|
handle_sysrq(val);
|
||||||
|
@ -269,12 +280,9 @@ static int cros_ec_keyb_work(struct notifier_block *nb,
|
||||||
|
|
||||||
case EC_MKBP_EVENT_BUTTON:
|
case EC_MKBP_EVENT_BUTTON:
|
||||||
case EC_MKBP_EVENT_SWITCH:
|
case EC_MKBP_EVENT_SWITCH:
|
||||||
/*
|
if (device_may_wakeup(ckdev->dev))
|
||||||
* If EC is not the wake source, discard key state
|
pm_wakeup_event(ckdev->dev, 0);
|
||||||
* changes during suspend. Switches will be re-checked in
|
else if (queued_during_suspend)
|
||||||
* cros_ec_keyb_resume() to be sure nothing is lost.
|
|
||||||
*/
|
|
||||||
if (queued_during_suspend)
|
|
||||||
return NOTIFY_OK;
|
return NOTIFY_OK;
|
||||||
|
|
||||||
if (ckdev->ec->event_data.event_type == EC_MKBP_EVENT_BUTTON) {
|
if (ckdev->ec->event_data.event_type == EC_MKBP_EVENT_BUTTON) {
|
||||||
|
@ -639,6 +647,7 @@ static int cros_ec_keyb_probe(struct platform_device *pdev)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
device_init_wakeup(ckdev->dev, true);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -229,7 +229,7 @@ int cros_ec_suspend(struct cros_ec_device *ec_dev)
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(cros_ec_suspend);
|
EXPORT_SYMBOL(cros_ec_suspend);
|
||||||
|
|
||||||
static void cros_ec_drain_events(struct cros_ec_device *ec_dev)
|
static void cros_ec_report_events_during_suspend(struct cros_ec_device *ec_dev)
|
||||||
{
|
{
|
||||||
while (cros_ec_get_next_event(ec_dev, NULL) > 0)
|
while (cros_ec_get_next_event(ec_dev, NULL) > 0)
|
||||||
blocking_notifier_call_chain(&ec_dev->event_notifier,
|
blocking_notifier_call_chain(&ec_dev->event_notifier,
|
||||||
|
@ -253,21 +253,16 @@ int cros_ec_resume(struct cros_ec_device *ec_dev)
|
||||||
dev_dbg(ec_dev->dev, "Error %d sending resume event to ec",
|
dev_dbg(ec_dev->dev, "Error %d sending resume event to ec",
|
||||||
ret);
|
ret);
|
||||||
|
|
||||||
/*
|
|
||||||
* In some cases, we need to distinguish between events that occur
|
|
||||||
* during suspend if the EC is not a wake source. For example,
|
|
||||||
* keypresses during suspend should be discarded if it does not wake
|
|
||||||
* the system.
|
|
||||||
*
|
|
||||||
* If the EC is not a wake source, drain the event queue and mark them
|
|
||||||
* as "queued during suspend".
|
|
||||||
*/
|
|
||||||
if (ec_dev->wake_enabled) {
|
if (ec_dev->wake_enabled) {
|
||||||
disable_irq_wake(ec_dev->irq);
|
disable_irq_wake(ec_dev->irq);
|
||||||
ec_dev->wake_enabled = 0;
|
ec_dev->wake_enabled = 0;
|
||||||
} else {
|
|
||||||
cros_ec_drain_events(ec_dev);
|
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
* Let the mfd devices know about events that occur during
|
||||||
|
* suspend. This way the clients know what to do with them.
|
||||||
|
*/
|
||||||
|
cros_ec_report_events_during_suspend(ec_dev);
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue