Compare commits
17
Commits
66f65a1131
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c29f8c94e3 | ||
|
|
f537765495 | ||
|
|
a9ffe67b8b | ||
|
|
fab534431c | ||
|
|
ddbeaa7b5b | ||
|
|
3a6a75bffa | ||
|
|
ef499b0581 | ||
|
|
d469f067bd | ||
|
|
cc4b41a4b0 | ||
|
|
ef21a9a785 | ||
|
|
0ec4085359 | ||
|
|
c40dec90bd | ||
|
|
c8b2340d14 | ||
|
|
3ddba7f670 | ||
|
|
ec4d407422 | ||
|
|
301aa7c1bb | ||
|
|
a52494e39b |
No files matched your search
Generated
+12
-68
@@ -60,11 +60,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1794815051,
|
||||
"narHash": "sha256-03xK+GPuyAIbUHvJXsWY2QclronkMUkxxDUegFrbYlU=",
|
||||
"lastModified": 1795167012,
|
||||
"narHash": "sha256-lrLLMUJNddmAMMDobTJVshu7ckzMTmTab4S3XPFgT1E=",
|
||||
"ref": "main",
|
||||
"rev": "640bd1d321ea5078b1f17bf1d6e6afaf734b669f",
|
||||
"revCount": 29,
|
||||
"rev": "7be6c580cb78e8e3267b6d98e421275aacc8140b",
|
||||
"revCount": 30,
|
||||
"type": "git",
|
||||
"url": "ssh://gitea@git.ppp.pm:1122/alex/ct.git"
|
||||
},
|
||||
@@ -81,11 +81,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1794813897,
|
||||
"narHash": "sha256-8pxsTqBZRio6eeloNKqKaDWAK/EH7cp4qPkhG1XL7Xo=",
|
||||
"lastModified": 1795169003,
|
||||
"narHash": "sha256-He4Tde9AYNSIb8D8ZowMAUECQnUM07cSEwqc10D04xc=",
|
||||
"ref": "main",
|
||||
"rev": "223accdfa20322a64c3ce1b934de274f82402258",
|
||||
"revCount": 58,
|
||||
"rev": "c3114be05fda532d8fbb14149a5a662550bc49f2",
|
||||
"revCount": 61,
|
||||
"type": "git",
|
||||
"url": "ssh://gitea@git.ppp.pm:1122/alex/dagbok.git"
|
||||
},
|
||||
@@ -222,24 +222,6 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils_4": {
|
||||
"inputs": {
|
||||
"systems": "systems_6"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1731533236,
|
||||
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"heldtenkeltdotse-site": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
@@ -711,11 +693,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1794772391,
|
||||
"narHash": "sha256-7OVYf6YOxg/bLjwKx6YykSYusIppUTzHTmOtDSL99cs=",
|
||||
"lastModified": 1795359024,
|
||||
"narHash": "sha256-y8QxP87mNSW+Dzb4MnTmibVkrQ9yrz+WJthJaFKr9h0=",
|
||||
"ref": "main",
|
||||
"rev": "0c2ee19394922ebda34570ae2c4bf01e7f33c2e7",
|
||||
"revCount": 35,
|
||||
"rev": "dd0c3762e91759ebd6fb449194690bf4cddb824f",
|
||||
"revCount": 48,
|
||||
"type": "git",
|
||||
"url": "ssh://gitea@git.ppp.pm:1122/alex/ndp.git"
|
||||
},
|
||||
@@ -950,7 +932,6 @@
|
||||
"pppdotpm-site": "pppdotpm-site",
|
||||
"puppy-tracker": "puppy-tracker",
|
||||
"schema": "schema",
|
||||
"solo-referee": "solo-referee",
|
||||
"todo": "todo",
|
||||
"whib-backend": "whib-backend",
|
||||
"whib-frontend": "whib-frontend"
|
||||
@@ -977,28 +958,6 @@
|
||||
"url": "ssh://gitea@git.ppp.pm:1122/alex/schema.git"
|
||||
}
|
||||
},
|
||||
"solo-referee": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils_4",
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1793606847,
|
||||
"narHash": "sha256-S1TQWwx1dm9Y/TWWmaxUGCuBIKmftiXx+uNshj/2K7M=",
|
||||
"ref": "main",
|
||||
"rev": "cf0ebe6df54fd1d3203f531d90718ca54803abb9",
|
||||
"revCount": 81,
|
||||
"type": "git",
|
||||
"url": "ssh://gitea@git.ppp.pm:1122/alex/solo-referee.git"
|
||||
},
|
||||
"original": {
|
||||
"ref": "main",
|
||||
"type": "git",
|
||||
"url": "ssh://gitea@git.ppp.pm:1122/alex/solo-referee.git"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1689347949,
|
||||
@@ -1074,21 +1033,6 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"systems_6": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"todo": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
|
||||
@@ -105,12 +105,6 @@
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
solo-referee = {
|
||||
url = "git+ssh://gitea@git.ppp.pm:1122/alex/solo-referee.git?ref=main";
|
||||
# url = "path:/home/alex/code/solo-referee";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
schema = {
|
||||
url = "git+ssh://gitea@git.ppp.pm:1122/alex/schema.git?ref=main";
|
||||
# url = "path:/home/alex/code/schema";
|
||||
|
||||
@@ -27,7 +27,6 @@ in
|
||||
homepage.enable = true;
|
||||
disk-smart.enable = true;
|
||||
puppy-tracker.enable = true;
|
||||
solo-referee.enable = true;
|
||||
todo.enable = true;
|
||||
schema.enable = true;
|
||||
atuin.enable = true;
|
||||
|
||||
@@ -105,7 +105,6 @@ let
|
||||
snapshot /var/lib/jellyfin "$STATE/jellyfin" --exclude='transcodes/' --exclude='cache/' --exclude='metadata/' --exclude='log/' --exclude='data/subtitles/'
|
||||
snapshot /var/lib/audiobookshelf "$STATE/audiobookshelf" --exclude='metadata/'
|
||||
snapshot /var/lib/puppy-tracker "$STATE/puppy-tracker"
|
||||
snapshot /var/lib/solo-referee "$STATE/solo-referee"
|
||||
snapshot /var/lib/todo "$STATE/todo"
|
||||
snapshot /var/lib/schema "$STATE/schema"
|
||||
snapshot /var/lib/dagbok "$STATE/dagbok"
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
{
|
||||
inputs,
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
let
|
||||
enabled = config.mod.solo-referee.enable;
|
||||
port = 8090;
|
||||
in
|
||||
{
|
||||
options = {
|
||||
mod.solo-referee = {
|
||||
enable = lib.mkEnableOption "Enable solo-referee module";
|
||||
};
|
||||
};
|
||||
|
||||
imports = [
|
||||
inputs.solo-referee.nixosModules.default
|
||||
];
|
||||
|
||||
config = lib.mkIf enabled {
|
||||
mod.homepage.services = [
|
||||
{
|
||||
name = "Solo Referee";
|
||||
port = port;
|
||||
description = "Solo-RPG tool with Claude as GM";
|
||||
# url omitted → homepage links to http://manatee:${port}.
|
||||
}
|
||||
];
|
||||
|
||||
services.solo-referee = {
|
||||
enable = true;
|
||||
inherit port;
|
||||
# Reachable on the LAN / Tailscale at manatee:${port}; no public vhost.
|
||||
address = "0.0.0.0";
|
||||
openFirewall = true;
|
||||
# Anthropic API key kept out of the store; the file holds
|
||||
# `ANTHROPIC_API_KEY=...`. Without it the offline stub GM runs.
|
||||
apiKeyFile = config.age.secrets."solo-referee-api-key".path;
|
||||
};
|
||||
|
||||
age.secrets."solo-referee-api-key".file =
|
||||
../../../../secrets/manatee/solo-referee-api-key.age;
|
||||
};
|
||||
}
|
||||
@@ -632,7 +632,7 @@ Setup prefix for keybindings.
|
||||
)
|
||||
|
||||
:custom
|
||||
(eglot-code-action-indications nil)
|
||||
(refactor-indications nil)
|
||||
|
||||
:hook (
|
||||
(eglot-managed-mode . mp-eglot-eldoc)
|
||||
|
||||
@@ -49,6 +49,7 @@ in
|
||||
server = "http://manatee:4533";
|
||||
user = "navi";
|
||||
passwordCommand = "cat ${config.age.secrets."navidrome-password".path}";
|
||||
anthropicKeyCommand = "cat ${config.age.secrets."ndp-llm-api-key".path}";
|
||||
};
|
||||
};
|
||||
};
|
||||
@@ -84,4 +85,10 @@ in
|
||||
owner = "alex";
|
||||
group = "users";
|
||||
};
|
||||
|
||||
age.secrets."ndp-llm-api-key" = {
|
||||
file = ../../../../secrets/pinwheel/ndp-llm-api-key.age;
|
||||
owner = "alex";
|
||||
group = "users";
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
{ pkgs, ... }:
|
||||
let
|
||||
picard = pkgs.symlinkJoin {
|
||||
name = "picard";
|
||||
paths = [ pkgs.picard ];
|
||||
nativeBuildInputs = [ pkgs.makeWrapper ];
|
||||
postBuild = ''
|
||||
wrapProgram $out/bin/picard --set QT_SCREEN_SCALE_FACTORS 1.5
|
||||
'';
|
||||
};
|
||||
|
||||
plugins = pkgs.linkFarm "picard-plugins" {
|
||||
replaygain2 = pkgs.fetchFromGitHub {
|
||||
owner = "metabrainz";
|
||||
repo = "picard-plugin-replaygain2";
|
||||
tag = "v2.3.1";
|
||||
hash = "sha256-NBn/LgjDRVCHmbI+bU4j29UhrL33ctV9jXj6CfFRBWA=";
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
home-manager.users.alex = { lib, ... }: {
|
||||
home.packages = [
|
||||
picard
|
||||
pkgs.rsgain
|
||||
];
|
||||
|
||||
home.activation.picardReplayGainPlugin = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
|
||||
if ! ${pkgs.picard}/bin/picard-cli plugins info replaygain2 2>/dev/null | grep -qF "${plugins}/replaygain2"; then
|
||||
run ${pkgs.picard}/bin/picard-cli --yes plugins install --no-git --reinstall "${plugins}/replaygain2" \
|
||||
|| warnEcho "Failed to install Picard plugin replaygain2"
|
||||
fi
|
||||
'';
|
||||
};
|
||||
}
|
||||
@@ -7,22 +7,25 @@
|
||||
let
|
||||
inherit (config.boot.kernelPackages) kernel kernelModuleMakeFlags;
|
||||
|
||||
ipu6-isys = pkgs.stdenv.mkDerivation {
|
||||
pname = "ipu6-isys";
|
||||
mkPatchedModules =
|
||||
{
|
||||
pname,
|
||||
srcPaths,
|
||||
dir,
|
||||
patches,
|
||||
postPatch,
|
||||
}:
|
||||
pkgs.stdenv.mkDerivation {
|
||||
inherit pname patches postPatch;
|
||||
inherit (kernel) version;
|
||||
|
||||
__structuredAttrs = true;
|
||||
|
||||
patches = [ ./ipu6-isys-runtime-pm-null-check.patch ];
|
||||
|
||||
nativeBuildInputs = kernel.moduleBuildDependencies;
|
||||
|
||||
unpackPhase = ''
|
||||
tar -xf ${kernel.src} --strip-components=1 --wildcards '*/drivers/media/pci/intel/ipu6/*'
|
||||
'';
|
||||
|
||||
postPatch = ''
|
||||
sed -i '/+= intel-ipu6\.o/d' drivers/media/pci/intel/ipu6/Makefile
|
||||
tar -xf ${kernel.src} --strip-components=1 --wildcards \
|
||||
${lib.escapeShellArgs (map (path: "*/${path}") srcPaths)}
|
||||
'';
|
||||
|
||||
makeFlags = kernelModuleMakeFlags ++ [
|
||||
@@ -37,18 +40,46 @@ let
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
make -C ${kernel.dev}/lib/modules/${kernel.modDirVersion}/build \
|
||||
M=$(pwd)/drivers/media/pci/intel/ipu6 "''${makeFlags[@]}"
|
||||
M=$(pwd)/${dir} "''${makeFlags[@]}"
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
make -C ${kernel.dev}/lib/modules/${kernel.modDirVersion}/build \
|
||||
M=$(pwd)/drivers/media/pci/intel/ipu6 modules_install \
|
||||
M=$(pwd)/${dir} modules_install \
|
||||
"''${makeFlags[@]}" "''${installFlags[@]}"
|
||||
runHook postInstall
|
||||
'';
|
||||
};
|
||||
|
||||
ipu6-isys = mkPatchedModules {
|
||||
pname = "ipu6-isys";
|
||||
srcPaths = [ "drivers/media/pci/intel/ipu6/*" ];
|
||||
dir = "drivers/media/pci/intel/ipu6";
|
||||
patches = [ ./ipu6-isys-runtime-pm-null-check.patch ];
|
||||
postPatch = ''
|
||||
sed -i '/+= intel-ipu6\.o/d' drivers/media/pci/intel/ipu6/Makefile
|
||||
'';
|
||||
};
|
||||
|
||||
usbio = mkPatchedModules {
|
||||
pname = "usbio";
|
||||
srcPaths = [
|
||||
"drivers/usb/misc/usbio.c"
|
||||
"drivers/gpio/gpio-usbio.c"
|
||||
"include/linux/usb/usbio.h"
|
||||
];
|
||||
dir = "usbio";
|
||||
patches = [ ./usbio-reset-resume.patch ];
|
||||
postPatch = ''
|
||||
mkdir -p usbio/include/linux/usb
|
||||
cp drivers/usb/misc/usbio.c drivers/gpio/gpio-usbio.c usbio/
|
||||
cp include/linux/usb/usbio.h usbio/include/linux/usb/
|
||||
echo 'LINUXINCLUDE := -I$(src)/include $(LINUXINCLUDE)' > usbio/Kbuild
|
||||
echo 'obj-m += usbio.o gpio-usbio.o' >> usbio/Kbuild
|
||||
'';
|
||||
};
|
||||
in
|
||||
{
|
||||
nixpkgs.overlays = [
|
||||
@@ -79,7 +110,10 @@ in
|
||||
})
|
||||
];
|
||||
|
||||
boot.extraModulePackages = [ ipu6-isys ];
|
||||
boot.extraModulePackages = [
|
||||
ipu6-isys
|
||||
usbio
|
||||
];
|
||||
|
||||
hardware.ipu6 = {
|
||||
enable = true;
|
||||
|
||||
@@ -0,0 +1,320 @@
|
||||
--- a/drivers/usb/misc/usbio.c
|
||||
+++ b/drivers/usb/misc/usbio.c
|
||||
@@ -83,6 +83,7 @@
|
||||
* @gpios: GPIO bank descriptors
|
||||
* @nr_gpio_banks: Number of I2C busses
|
||||
* @gpios: I2C bank descriptors
|
||||
+ * @reset_count: Number of times the bridge was reset while bound
|
||||
*/
|
||||
struct usbio_device {
|
||||
struct device *dev;
|
||||
@@ -115,6 +116,8 @@
|
||||
|
||||
unsigned int nr_i2c_buses;
|
||||
struct usbio_i2c_bus_desc i2cs[USBIO_MAX_I2CBUSES];
|
||||
+
|
||||
+ unsigned int reset_count;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -428,6 +431,21 @@
|
||||
}
|
||||
EXPORT_SYMBOL_NS_GPL(usbio_get_quirks, "USBIO");
|
||||
|
||||
+unsigned int usbio_get_reset_count(struct auxiliary_device *adev)
|
||||
+{
|
||||
+ struct usbio_client *client = adev_to_client(adev);
|
||||
+ struct usbio_device *usbio;
|
||||
+
|
||||
+ guard(mutex)(&client->mutex);
|
||||
+
|
||||
+ usbio = client->bridge;
|
||||
+ if (!usbio)
|
||||
+ return 0; /* Disconnected */
|
||||
+
|
||||
+ return usbio->reset_count;
|
||||
+}
|
||||
+EXPORT_SYMBOL_NS_GPL(usbio_get_reset_count, "USBIO");
|
||||
+
|
||||
static void usbio_auxdev_release(struct device *dev)
|
||||
{
|
||||
struct auxiliary_device *adev = to_auxiliary_dev(dev);
|
||||
@@ -503,6 +521,47 @@
|
||||
return 0;
|
||||
}
|
||||
|
||||
+static int usbio_init_bridge(struct usbio_device *usbio)
|
||||
+{
|
||||
+ struct usbio_protver protver;
|
||||
+ struct usbio_fwver fwver;
|
||||
+ int ret;
|
||||
+
|
||||
+ guard(mutex)(&usbio->ctrl_mutex);
|
||||
+
|
||||
+ ret = usbio_ctrl_msg(usbio, USBIO_PKTTYPE_CTRL, USBIO_CTRLCMD_HS, NULL, 0, NULL, 0);
|
||||
+ if (ret < 0)
|
||||
+ return ret;
|
||||
+
|
||||
+ ret = usbio_ctrl_msg(usbio, USBIO_PKTTYPE_CTRL, USBIO_CTRLCMD_PROTVER, NULL, 0,
|
||||
+ &protver, sizeof(protver));
|
||||
+ if (ret < 0)
|
||||
+ return ret;
|
||||
+
|
||||
+ ret = usbio_ctrl_msg(usbio, USBIO_PKTTYPE_CTRL, USBIO_CTRLCMD_FWVER, NULL, 0,
|
||||
+ &fwver, sizeof(fwver));
|
||||
+ if (ret < 0)
|
||||
+ return ret;
|
||||
+
|
||||
+ ret = usbio_ctrl_msg(usbio, USBIO_PKTTYPE_CTRL, USBIO_CTRLCMD_ENUMGPIO, NULL, 0,
|
||||
+ usbio->gpios, sizeof(usbio->gpios));
|
||||
+ if (ret < 0 || ret % sizeof(struct usbio_gpio_bank_desc))
|
||||
+ return (ret < 0) ? ret : -EPROTO;
|
||||
+ usbio->nr_gpio_banks = ret / sizeof(struct usbio_gpio_bank_desc);
|
||||
+
|
||||
+ ret = usbio_ctrl_msg(usbio, USBIO_PKTTYPE_CTRL, USBIO_CTRLCMD_ENUMI2C, NULL, 0,
|
||||
+ usbio->i2cs, sizeof(usbio->i2cs));
|
||||
+ if (ret < 0 || ret % sizeof(struct usbio_i2c_bus_desc))
|
||||
+ return (ret < 0) ? ret : -EPROTO;
|
||||
+ usbio->nr_i2c_buses = ret / sizeof(struct usbio_i2c_bus_desc);
|
||||
+
|
||||
+ dev_dbg(usbio->dev, "ProtVer(BCD): %02x FwVer: %d.%d.%d.%d\n",
|
||||
+ protver.ver, fwver.major, fwver.minor,
|
||||
+ le16_to_cpu(fwver.patch), le16_to_cpu(fwver.build));
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
static int usbio_suspend(struct usb_interface *intf, pm_message_t msg)
|
||||
{
|
||||
struct usbio_device *usbio = usb_get_intfdata(intf);
|
||||
@@ -519,6 +578,26 @@
|
||||
return usb_submit_urb(usbio->urb, GFP_KERNEL);
|
||||
}
|
||||
|
||||
+static int usbio_reset_resume(struct usb_interface *intf)
|
||||
+{
|
||||
+ struct usbio_device *usbio = usb_get_intfdata(intf);
|
||||
+ int ret;
|
||||
+
|
||||
+ ret = usb_submit_urb(usbio->urb, GFP_KERNEL);
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+
|
||||
+ ret = usbio_init_bridge(usbio);
|
||||
+ if (ret) {
|
||||
+ usb_kill_urb(usbio->urb);
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ usbio->reset_count++;
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
static void usbio_disconnect(struct usb_interface *intf)
|
||||
{
|
||||
struct usbio_device *usbio = usb_get_intfdata(intf);
|
||||
@@ -550,9 +629,7 @@
|
||||
struct usb_device *udev = interface_to_usbdev(intf);
|
||||
struct usb_endpoint_descriptor *ep_in, *ep_out;
|
||||
struct device *dev = &intf->dev;
|
||||
- struct usbio_protver protver;
|
||||
struct usbio_device *usbio;
|
||||
- struct usbio_fwver fwver;
|
||||
int ret;
|
||||
|
||||
usbio = devm_kzalloc(dev, sizeof(*usbio), GFP_KERNEL);
|
||||
@@ -623,51 +700,16 @@
|
||||
goto err_free_urb;
|
||||
}
|
||||
|
||||
- mutex_lock(&usbio->ctrl_mutex);
|
||||
-
|
||||
- ret = usbio_ctrl_msg(usbio, USBIO_PKTTYPE_CTRL, USBIO_CTRLCMD_HS, NULL, 0, NULL, 0);
|
||||
- if (ret < 0)
|
||||
- goto err_unlock;
|
||||
-
|
||||
- ret = usbio_ctrl_msg(usbio, USBIO_PKTTYPE_CTRL, USBIO_CTRLCMD_PROTVER, NULL, 0,
|
||||
- &protver, sizeof(protver));
|
||||
- if (ret < 0)
|
||||
- goto err_unlock;
|
||||
-
|
||||
- ret = usbio_ctrl_msg(usbio, USBIO_PKTTYPE_CTRL, USBIO_CTRLCMD_FWVER, NULL, 0,
|
||||
- &fwver, sizeof(fwver));
|
||||
- if (ret < 0)
|
||||
- goto err_unlock;
|
||||
-
|
||||
- ret = usbio_ctrl_msg(usbio, USBIO_PKTTYPE_CTRL, USBIO_CTRLCMD_ENUMGPIO, NULL, 0,
|
||||
- usbio->gpios, sizeof(usbio->gpios));
|
||||
- if (ret < 0 || ret % sizeof(struct usbio_gpio_bank_desc)) {
|
||||
- ret = (ret < 0) ? ret : -EPROTO;
|
||||
- goto err_unlock;
|
||||
- }
|
||||
- usbio->nr_gpio_banks = ret / sizeof(struct usbio_gpio_bank_desc);
|
||||
-
|
||||
- ret = usbio_ctrl_msg(usbio, USBIO_PKTTYPE_CTRL, USBIO_CTRLCMD_ENUMI2C, NULL, 0,
|
||||
- usbio->i2cs, sizeof(usbio->i2cs));
|
||||
- if (ret < 0 || ret % sizeof(struct usbio_i2c_bus_desc)) {
|
||||
- ret = (ret < 0) ? ret : -EPROTO;
|
||||
- goto err_unlock;
|
||||
- }
|
||||
- usbio->nr_i2c_buses = ret / sizeof(struct usbio_i2c_bus_desc);
|
||||
-
|
||||
- mutex_unlock(&usbio->ctrl_mutex);
|
||||
-
|
||||
- dev_dbg(dev, "ProtVer(BCD): %02x FwVer: %d.%d.%d.%d\n",
|
||||
- protver.ver, fwver.major, fwver.minor,
|
||||
- le16_to_cpu(fwver.patch), le16_to_cpu(fwver.build));
|
||||
+ ret = usbio_init_bridge(usbio);
|
||||
+ if (ret)
|
||||
+ goto err_kill_urb;
|
||||
|
||||
usbio_enum_gpios(usbio);
|
||||
usbio_enum_i2cs(usbio);
|
||||
|
||||
return 0;
|
||||
|
||||
-err_unlock:
|
||||
- mutex_unlock(&usbio->ctrl_mutex);
|
||||
+err_kill_urb:
|
||||
usb_kill_urb(usbio->urb);
|
||||
err_free_urb:
|
||||
usb_free_urb(usbio->urb);
|
||||
@@ -694,6 +736,7 @@
|
||||
.disconnect = usbio_disconnect,
|
||||
.suspend = usbio_suspend,
|
||||
.resume = usbio_resume,
|
||||
+ .reset_resume = usbio_reset_resume,
|
||||
.id_table = usbio_table,
|
||||
.supports_autosuspend = 1,
|
||||
};
|
||||
--- a/drivers/gpio/gpio-usbio.c
|
||||
+++ b/drivers/gpio/gpio-usbio.c
|
||||
@@ -15,14 +15,16 @@
|
||||
|
||||
struct usbio_gpio_bank {
|
||||
u8 config[USBIO_GPIOSPERBANK];
|
||||
+ u32 value;
|
||||
u32 bitmap;
|
||||
};
|
||||
|
||||
struct usbio_gpio {
|
||||
- struct mutex config_mutex; /* Protects banks[x].config */
|
||||
+ struct mutex config_mutex; /* Protects banks[x].config and banks[x].value */
|
||||
struct usbio_gpio_bank banks[USBIO_MAX_GPIOBANKS];
|
||||
struct gpio_chip gc;
|
||||
struct auxiliary_device *adev;
|
||||
+ unsigned int reset_count;
|
||||
};
|
||||
|
||||
static const struct acpi_device_id usbio_gpio_acpi_hids[] = {
|
||||
@@ -101,6 +103,13 @@
|
||||
|
||||
usbio_gpio_get_bank_and_pin(gc, offset, &bank, &pin);
|
||||
|
||||
+ scoped_guard(mutex, &gpio->config_mutex) {
|
||||
+ if (value)
|
||||
+ bank->value |= BIT(pin);
|
||||
+ else
|
||||
+ bank->value &= ~BIT(pin);
|
||||
+ }
|
||||
+
|
||||
gbuf.bankid = offset / USBIO_GPIOSPERBANK;
|
||||
gbuf.pincount = 1;
|
||||
gbuf.pin = pin;
|
||||
@@ -178,6 +187,66 @@
|
||||
return usbio_gpio_update_config(gc, offset, USBIO_GPIO_PINCFG_MASK, value);
|
||||
}
|
||||
|
||||
+static int usbio_gpio_restore(struct usbio_gpio *gpio)
|
||||
+{
|
||||
+ struct usbio_gpio_init ginit;
|
||||
+ struct usbio_gpio_rw gbuf;
|
||||
+ int ret;
|
||||
+
|
||||
+ guard(mutex)(&gpio->config_mutex);
|
||||
+
|
||||
+ for (unsigned int b = 0; b < USBIO_MAX_GPIOBANKS; b++) {
|
||||
+ struct usbio_gpio_bank *bank = &gpio->banks[b];
|
||||
+
|
||||
+ for (unsigned int pin = 0; pin < USBIO_GPIOSPERBANK; pin++) {
|
||||
+ u8 mode = bank->config[pin] & USBIO_GPIO_PINMOD_MASK;
|
||||
+
|
||||
+ if (mode == USBIO_GPIO_PINMOD_INVAL)
|
||||
+ continue;
|
||||
+
|
||||
+ ginit.bankid = b;
|
||||
+ ginit.config = bank->config[pin];
|
||||
+ ginit.pincount = 1;
|
||||
+ ginit.pin = pin;
|
||||
+
|
||||
+ ret = usbio_control_msg(gpio->adev, USBIO_PKTTYPE_GPIO, USBIO_GPIOCMD_INIT,
|
||||
+ &ginit, sizeof(ginit), NULL, 0);
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+
|
||||
+ if (mode != USBIO_GPIO_PINMOD_OUTPUT)
|
||||
+ continue;
|
||||
+
|
||||
+ gbuf.bankid = b;
|
||||
+ gbuf.pincount = 1;
|
||||
+ gbuf.pin = pin;
|
||||
+ gbuf.value = cpu_to_le32(bank->value & BIT(pin));
|
||||
+
|
||||
+ ret = usbio_control_msg(gpio->adev, USBIO_PKTTYPE_GPIO, USBIO_GPIOCMD_WRITE,
|
||||
+ &gbuf, sizeof(gbuf), NULL, 0);
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int usbio_gpio_resume(struct device *dev)
|
||||
+{
|
||||
+ struct usbio_gpio *gpio = dev_get_drvdata(dev);
|
||||
+ unsigned int reset_count = usbio_get_reset_count(gpio->adev);
|
||||
+
|
||||
+ if (reset_count == gpio->reset_count)
|
||||
+ return 0;
|
||||
+
|
||||
+ gpio->reset_count = reset_count;
|
||||
+
|
||||
+ return usbio_gpio_restore(gpio);
|
||||
+}
|
||||
+
|
||||
+static DEFINE_SIMPLE_DEV_PM_OPS(usbio_gpio_pm_ops, NULL, usbio_gpio_resume);
|
||||
+
|
||||
static int usbio_gpio_probe(struct auxiliary_device *adev,
|
||||
const struct auxiliary_device_id *adev_id)
|
||||
{
|
||||
@@ -199,6 +268,8 @@
|
||||
return ret;
|
||||
|
||||
gpio->adev = adev;
|
||||
+ gpio->reset_count = usbio_get_reset_count(adev);
|
||||
+ dev_set_drvdata(dev, gpio);
|
||||
|
||||
usbio_acpi_bind(gpio->adev, usbio_gpio_acpi_hids);
|
||||
|
||||
@@ -238,7 +309,8 @@
|
||||
static struct auxiliary_driver usbio_gpio_driver = {
|
||||
.name = USBIO_GPIO_CLIENT,
|
||||
.probe = usbio_gpio_probe,
|
||||
- .id_table = usbio_gpio_id_table
|
||||
+ .id_table = usbio_gpio_id_table,
|
||||
+ .driver.pm = pm_sleep_ptr(&usbio_gpio_pm_ops),
|
||||
};
|
||||
module_auxiliary_driver(usbio_gpio_driver);
|
||||
|
||||
--- a/include/linux/usb/usbio.h
|
||||
+++ b/include/linux/usb/usbio.h
|
||||
@@ -172,6 +172,7 @@
|
||||
void usbio_release(struct auxiliary_device *adev);
|
||||
void usbio_get_txrxbuf_len(struct auxiliary_device *adev, u16 *txbuf_len, u16 *rxbuf_len);
|
||||
unsigned long usbio_get_quirks(struct auxiliary_device *adev);
|
||||
+unsigned int usbio_get_reset_count(struct auxiliary_device *adev);
|
||||
void usbio_acpi_bind(struct auxiliary_device *adev, const struct acpi_device_id *hids);
|
||||
|
||||
#endif
|
||||
Binary file not shown.
Binary file not shown.
+1
-1
@@ -28,6 +28,7 @@ in {
|
||||
"pinwheel/work-production-ovpn.age".publicKeys = [ pinwheel alex ];
|
||||
"pinwheel/naviterm-config.age".publicKeys = [ pinwheel alex ];
|
||||
"pinwheel/navidrome-password.age".publicKeys = [ pinwheel alex ];
|
||||
"pinwheel/ndp-llm-api-key.age".publicKeys = [ pinwheel alex ];
|
||||
"pinwheel/atuin-key.age".publicKeys = [ pinwheel alex ];
|
||||
|
||||
"manatee/root.manatee.age".publicKeys = [ manatee alex ];
|
||||
@@ -47,7 +48,6 @@ in {
|
||||
"manatee/romm-db-password.age".publicKeys = [ manatee alex ];
|
||||
"manatee/romm-metadata-api-keys.age".publicKeys = [ manatee alex ];
|
||||
"manatee/puppy-tracker-invite-code.age".publicKeys = [ manatee alex ];
|
||||
"manatee/solo-referee-api-key.age".publicKeys = [ manatee alex ];
|
||||
"manatee/todo-token.age".publicKeys = [ manatee alex ];
|
||||
"manatee/dagbok-token.age".publicKeys = [ manatee pinwheel alex ];
|
||||
"manatee/schema-invite-code.age".publicKeys = [ manatee alex ];
|
||||
|
||||
Reference in new issue
Block a user