1
0
Fork 0
mirror of https://github.com/NixOS/nixos-hardware synced 2024-09-27 16:47:23 +02:00

Support reloading i2c-designware module(s) after resuming

This commit is contained in:
mexisme 2022-12-05 13:26:28 +13:00
parent b1582825dd
commit 97900e1e7e
2 changed files with 46 additions and 0 deletions

View file

@ -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;
}

View 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";
};
}