From 618eb94e7e7e43a034077aca378802890bc9ff84 Mon Sep 17 00:00:00 2001 From: zxystd <1051244836@qq.com> Date: Mon, 26 Feb 2024 18:34:34 +0800 Subject: [PATCH] AirportItlwm: add power state handler for IOPCIEDeviceWrapper driver, this fix the sleep/wake issue on Sonoma(#937). --- AirportItlwm/IOPCIEDeviceWrapper.cpp | 16 ++++++++++++++++ AirportItlwm/IOPCIEDeviceWrapper.hpp | 3 +++ 2 files changed, 19 insertions(+) diff --git a/AirportItlwm/IOPCIEDeviceWrapper.cpp b/AirportItlwm/IOPCIEDeviceWrapper.cpp index b1b39fa2..ad515a61 100644 --- a/AirportItlwm/IOPCIEDeviceWrapper.cpp +++ b/AirportItlwm/IOPCIEDeviceWrapper.cpp @@ -23,6 +23,12 @@ OSDefineMetaClassAndStructors(IOPCIEDeviceWrapper, IOService); #define PCI_MSIX_FLAGS_ENABLE 0x8000 /* MSI-X enable */ #define PCI_MSI_FLAGS_ENABLE 0x0001 /* MSI feature enabled */ +static IOPMPowerState powerStateArray[2] = +{ + {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {1, kIOPMDeviceUsable, kIOPMPowerOn, kIOPMPowerOn, 0, 0, 0, 0, 0, 0, 0, 0} +}; + static void pciMsiSetEnable(IOPCIDevice *device, UInt8 msiCap, int enable) { UInt16 control; @@ -105,6 +111,9 @@ start(IOService *provider) IOLog("%s::super start succeed\n", getName()); UInt8 builtIn = 0; setProperty("built-in", OSData::withBytes(&builtIn, sizeof(builtIn))); + PMinit(); + registerPowerDriver(this, powerStateArray, 2); + provider->joinPMtree(this); registerService(); return true; } @@ -113,5 +122,12 @@ void IOPCIEDeviceWrapper:: stop(IOService *provider) { XYLog("%s\n", __PRETTY_FUNCTION__); + PMstop(); super::stop(provider); } + +IOReturn IOPCIEDeviceWrapper:: +setPowerState(unsigned long powerStateOrdinal, IOService *whatDevice) +{ + return IOPMAckImplied; +} diff --git a/AirportItlwm/IOPCIEDeviceWrapper.hpp b/AirportItlwm/IOPCIEDeviceWrapper.hpp index b658ef23..2061bb3c 100644 --- a/AirportItlwm/IOPCIEDeviceWrapper.hpp +++ b/AirportItlwm/IOPCIEDeviceWrapper.hpp @@ -24,6 +24,9 @@ class IOPCIEDeviceWrapper : public IOService { virtual bool start(IOService *provider) override; virtual void stop(IOService *provider) override; virtual IOWorkLoop* getWorkLoop() const override; + virtual IOReturn setPowerState( + unsigned long powerStateOrdinal, + IOService * whatDevice ) override; public: ItlHalService *fHalService;