Untitled

 avatar
unknown
plain_text
9 days ago
3.8 kB
5
Indexable
#!/bin/sh

disable_wakeup() {
   local device="$1"
   # Check current status
   if grep -q "^$device.*enabled" /proc/acpi/wakeup; then
       echo "$device" > /proc/acpi/wakeup
   fi
}

case $1 in
   pre)
       # Optionally unload Thunderbolt module.
       # For when you have devices connected to a dock that may trigger wakeup's.
       # modprobe -r thunderbolt 2>/dev/null

       # Disable pinctrl_amd-related wakeups
       disable_wakeup "GP11"
       disable_wakeup "GP12"
       disable_wakeup "GP23"

       # Disable Thunderbolt wakeups
       disable_wakeup "NHI0"
       disable_wakeup "NHI1"

       # disable USB wakeups
       disable_wakeup "XHC0"
       disable_wakeup "XHC1"
       disable_wakeup "XHC3"
       disable_wakeup "XHC4"

       # Disable some ACPI related wakeups.
       disable_wakeup "SWUS"

       # ***** Descriptions below for the gpe* interrupts are educated guesses ***

       # system control interrupts (SCI) or power management events
       echo disable >/sys/firmware/acpi/interrupts/gpe02

       # touchpad / I2C controller(s)
       echo disable >/sys/firmware/acpi/interrupts/gpe03

       # I2C or SPI controllers, sensors
       echo disable >/sys/firmware/acpi/interrupts/gpe0D

       # USB controllers (e.g., XHCI), PCIe devices, or GPIO interrupts
       echo disable >/sys/firmware/acpi/interrupts/gpe10



       # potentially lid switch, power button, or keyboard events etc.
       # echo disable >/sys/firmware/acpi/interrupts/gpe19

       # Disable touchpad driver
       modprobe -r i2c_hid_acpi

       echo "** Suspend before state:" >/tmp/suspend_stats.txt
       echo "/proc/acpi/wakeup" >>/tmp/suspend_stats.txt
       cat /proc/acpi/wakeup >>/tmp/suspend_stats.txt
       echo "/sys/firmware/acpi/interrupts/gpe_all" >>/tmp/suspend_stats.txt
       cat /sys/firmware/acpi/interrupts/gpe_all >>/tmp/suspend_stats.txt
       echo "/sys/kernel/debug/wakeup_sources" >>/tmp/suspend_stats.txt
       cat /sys/kernel/debug/wakeup_sources >>/tmp/suspend_stats.txt
       echo "GPE states" >>/tmp/suspend_stats.txt
       grep "" /sys/firmware/acpi/interrupts/gpe* >>/tmp/suspend_stats.txt
       echo "** Entering suspend **" >>/tmp/suspend_stats.txt
       echo "" >>/tmp/suspend_stats.txt
       ;;
   post)
       echo "** Exit suspend state:" >>/tmp/suspend_stats.txt
       echo "/proc/acpi/wakeup" >>/tmp/suspend_stats.txt
       cat /proc/acpi/wakeup >>/tmp/suspend_stats.txt
       echo "/sys/firmware/acpi/interrupts/gpe_all" >>/tmp/suspend_stats.txt
       cat /sys/firmware/acpi/interrupts/gpe_all >>/tmp/suspend_stats.txt
       echo "/sys/kernel/debug/wakeup_sources" >>/tmp/suspend_stats.txt
       cat /sys/kernel/debug/wakeup_sources >>/tmp/suspend_stats.txt
       echo "GPE states" >>/tmp/suspend_stats.txt
       grep "" /sys/firmware/acpi/interrupts/gpe* >>/tmp/suspend_stats.txt

       # Re-enable touchpad driver.
       modprobe i2c_hid_acpi

       echo enable >/sys/firmware/acpi/interrupts/gpe03
       echo enable >/sys/firmware/acpi/interrupts/gpe02
       echo enable >/sys/firmware/acpi/interrupts/gpe03
       echo enable >/sys/firmware/acpi/interrupts/gpe0D
       echo enable >/sys/firmware/acpi/interrupts/gpe10

       # Optionally reload Thunderbolt module (uncomment if unloaded above)
       # modprobe thunderbolt 2>/dev/null

       ;;
esac
Editor is loading...
Leave a Comment