Support reloading i2c-designware module(s) after resuming
This commit is contained in:
parent
b1582825dd
commit
97900e1e7e
|
@ -10,6 +10,7 @@ in {
|
|||
../../../common/pc/laptop
|
||||
../../../common/pc/laptop/acpi_call.nix
|
||||
../../../common/pc/ssd
|
||||
../sleep-resume/i2c-designware
|
||||
];
|
||||
|
||||
# Force S3 sleep mode. See README.wiki for details.
|
||||
|
@ -26,4 +27,7 @@ in {
|
|||
|
||||
# This will save you money and possibly your life!
|
||||
services.thermald.enable = mkDefault true;
|
||||
|
||||
# Reloads i2c-designware module after suspend
|
||||
services.sleep-resume.i2c-designware.enable = mkDefault true;
|
||||
}
|
||||
|
|
42
dell/xps/sleep-resume/i2c-designware/default.nix
Normal file
42
dell/xps/sleep-resume/i2c-designware/default.nix
Normal file
|
@ -0,0 +1,42 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
let
|
||||
inherit (lib) mkIf mkOption types;
|
||||
|
||||
reloadDesignware = pkgs.writeShellApplication {
|
||||
name = "reload-i2c-designware.sh";
|
||||
runtimeInputs = [ pkgs.kmod ];
|
||||
text = ''
|
||||
# Reload the i2c Designware driver after resuming from sleep.
|
||||
|
||||
# Wait up-to 0.5 second for each module to be unloaded:
|
||||
# (It should never take this long)
|
||||
modprobe -r --wait 500 i2c_designware_platform
|
||||
modprobe -r --wait 500 i2c_designware_core
|
||||
modprobe -r --wait 500 i2c_hid_acpi
|
||||
modprobe -r --wait 500 i2c_hid
|
||||
|
||||
# Should reload the module dependencies automatically:
|
||||
modprobe i2c_designware_platform
|
||||
'';
|
||||
};
|
||||
|
||||
cfg = config.services.sleep-resume.i2c-designware;
|
||||
in {
|
||||
options = {
|
||||
services.sleep-resume.i2c-designware = {
|
||||
enable = mkOption {
|
||||
default = false;
|
||||
type = types.bool;
|
||||
description = "Reload the i2c_designware driver after resuming from sleep.";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
powerManagement.resumeCommands = "${reloadDesignware}/bin/reload-i2c-designware.sh";
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in a new issue