Skip to content

Commit 6761f9c

Browse files
EvenxfJiri Kosina
authored andcommitted
HID: Intel-thc-hid: Intel-quicki2c: Add power management for touch device
Send POWER_SLEEP command to touch device when system enters into sleep mode or hibernate mode to save more power; and send POWER_ON command to take device back when system exits sleep mode. Signed-off-by: Even Xu <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent a788b20 commit 6761f9c

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,12 @@ static int quicki2c_suspend(struct device *device)
807807
if (!qcdev)
808808
return -ENODEV;
809809

810+
if (!device_may_wakeup(qcdev->dev)) {
811+
ret = quicki2c_set_power(qcdev, HIDI2C_SLEEP);
812+
if (ret)
813+
return ret;
814+
}
815+
810816
/*
811817
* As I2C is THC subsystem, no register auto save/restore support,
812818
* need driver to do that explicitly for every D3 case.
@@ -856,6 +862,9 @@ static int quicki2c_resume(struct device *device)
856862
if (ret)
857863
return ret;
858864

865+
if (!device_may_wakeup(qcdev->dev))
866+
return quicki2c_set_power(qcdev, HIDI2C_ON);
867+
859868
return 0;
860869
}
861870

@@ -913,6 +922,9 @@ static int quicki2c_poweroff(struct device *device)
913922
if (!qcdev)
914923
return -ENODEV;
915924

925+
/* Ignore the return value as platform will be poweroff soon */
926+
quicki2c_set_power(qcdev, HIDI2C_SLEEP);
927+
916928
ret = thc_interrupt_quiesce(qcdev->thc_hw, true);
917929
if (ret)
918930
return ret;
@@ -966,7 +978,7 @@ static int quicki2c_restore(struct device *device)
966978

967979
thc_change_ltr_mode(qcdev->thc_hw, THC_LTR_MODE_ACTIVE);
968980

969-
return 0;
981+
return quicki2c_set_power(qcdev, HIDI2C_ON);
970982
}
971983

972984
static int quicki2c_runtime_suspend(struct device *device)

0 commit comments

Comments
 (0)