Skip to content

Commit 0e63dd2

Browse files
khfengJiri Kosina
authored andcommitted
HID: intel-ish-hid: ipc: Rework EHL OOB wakeup
Since PCI core and ACPI core already handles PCI PME wake and GPE wake when the device has wakeup capability, use device_init_wakeup() to let them do the wakeup setting work. Also add a shutdown callback which uses pci_prepare_to_sleep() to let PCI and ACPI set OOB wakeup for S5. Cc: Jian Hui Lee <[email protected]> Signed-off-by: Kai-Heng Feng <[email protected]> Acked-by: Srinivas Pandruvada <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 42a244b commit 0e63dd2

File tree

1 file changed

+15
-52
lines changed

1 file changed

+15
-52
lines changed

drivers/hid/intel-ish-hid/ipc/pci-ish.c

Lines changed: 15 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -119,50 +119,6 @@ static inline bool ish_should_leave_d0i3(struct pci_dev *pdev)
119119
return !pm_resume_via_firmware() || pdev->device == CHV_DEVICE_ID;
120120
}
121121

122-
static int enable_gpe(struct device *dev)
123-
{
124-
#ifdef CONFIG_ACPI
125-
acpi_status acpi_sts;
126-
struct acpi_device *adev;
127-
struct acpi_device_wakeup *wakeup;
128-
129-
adev = ACPI_COMPANION(dev);
130-
if (!adev) {
131-
dev_err(dev, "get acpi handle failed\n");
132-
return -ENODEV;
133-
}
134-
wakeup = &adev->wakeup;
135-
136-
/*
137-
* Call acpi_disable_gpe(), so that reference count
138-
* gpe_event_info->runtime_count doesn't overflow.
139-
* When gpe_event_info->runtime_count = 0, the call
140-
* to acpi_disable_gpe() simply return.
141-
*/
142-
acpi_disable_gpe(wakeup->gpe_device, wakeup->gpe_number);
143-
144-
acpi_sts = acpi_enable_gpe(wakeup->gpe_device, wakeup->gpe_number);
145-
if (ACPI_FAILURE(acpi_sts)) {
146-
dev_err(dev, "enable ose_gpe failed\n");
147-
return -EIO;
148-
}
149-
150-
return 0;
151-
#else
152-
return -ENODEV;
153-
#endif
154-
}
155-
156-
static void enable_pme_wake(struct pci_dev *pdev)
157-
{
158-
if ((pci_pme_capable(pdev, PCI_D0) ||
159-
pci_pme_capable(pdev, PCI_D3hot) ||
160-
pci_pme_capable(pdev, PCI_D3cold)) && !enable_gpe(&pdev->dev)) {
161-
pci_pme_active(pdev, true);
162-
dev_dbg(&pdev->dev, "ish ipc driver pme wake enabled\n");
163-
}
164-
}
165-
166122
/**
167123
* ish_probe() - PCI driver probe callback
168124
* @pdev: pci device
@@ -233,7 +189,7 @@ static int ish_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
233189

234190
/* Enable PME for EHL */
235191
if (pdev->device == EHL_Ax_DEVICE_ID)
236-
enable_pme_wake(pdev);
192+
device_init_wakeup(dev, true);
237193

238194
ret = ish_init(ishtp);
239195
if (ret)
@@ -256,6 +212,19 @@ static void ish_remove(struct pci_dev *pdev)
256212
ish_device_disable(ishtp_dev);
257213
}
258214

215+
216+
/**
217+
* ish_shutdown() - PCI driver shutdown callback
218+
* @pdev: pci device
219+
*
220+
* This function sets up wakeup for S5
221+
*/
222+
static void ish_shutdown(struct pci_dev *pdev)
223+
{
224+
if (pdev->device == EHL_Ax_DEVICE_ID)
225+
pci_prepare_to_sleep(pdev);
226+
}
227+
259228
static struct device __maybe_unused *ish_resume_device;
260229

261230
/* 50ms to get resume response */
@@ -378,13 +347,6 @@ static int __maybe_unused ish_resume(struct device *device)
378347
struct pci_dev *pdev = to_pci_dev(device);
379348
struct ishtp_device *dev = pci_get_drvdata(pdev);
380349

381-
/* add this to finish power flow for EHL */
382-
if (dev->pdev->device == EHL_Ax_DEVICE_ID) {
383-
pci_set_power_state(pdev, PCI_D0);
384-
enable_pme_wake(pdev);
385-
dev_dbg(dev->devc, "set power state to D0 for ehl\n");
386-
}
387-
388350
ish_resume_device = device;
389351
dev->resume_flag = 1;
390352

@@ -400,6 +362,7 @@ static struct pci_driver ish_driver = {
400362
.id_table = ish_pci_tbl,
401363
.probe = ish_probe,
402364
.remove = ish_remove,
365+
.shutdown = ish_shutdown,
403366
.driver.pm = &ish_pm_ops,
404367
};
405368

0 commit comments

Comments
 (0)