Compare commits
7
Commits
66f65a1131
...
0ec4085359
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0ec4085359 | ||
|
|
c40dec90bd | ||
|
|
c8b2340d14 | ||
|
|
3ddba7f670 | ||
|
|
ec4d407422 | ||
|
|
301aa7c1bb | ||
|
|
a52494e39b |
No files matched your search
Generated
+4
-4
@@ -711,11 +711,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1794772391,
|
"lastModified": 1794907651,
|
||||||
"narHash": "sha256-7OVYf6YOxg/bLjwKx6YykSYusIppUTzHTmOtDSL99cs=",
|
"narHash": "sha256-nDbA3JBf/AOKeOFhHmGN5WA5Os1pGBl9p67Ou2DE8JI=",
|
||||||
"ref": "main",
|
"ref": "main",
|
||||||
"rev": "0c2ee19394922ebda34570ae2c4bf01e7f33c2e7",
|
"rev": "c3c1162eb81aaadb174e13e9555c6cff8e7abf6e",
|
||||||
"revCount": 35,
|
"revCount": 42,
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "ssh://gitea@git.ppp.pm:1122/alex/ndp.git"
|
"url": "ssh://gitea@git.ppp.pm:1122/alex/ndp.git"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -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,46 +7,77 @@
|
|||||||
let
|
let
|
||||||
inherit (config.boot.kernelPackages) kernel kernelModuleMakeFlags;
|
inherit (config.boot.kernelPackages) kernel kernelModuleMakeFlags;
|
||||||
|
|
||||||
ipu6-isys = pkgs.stdenv.mkDerivation {
|
mkPatchedModules =
|
||||||
|
{
|
||||||
|
pname,
|
||||||
|
srcPaths,
|
||||||
|
dir,
|
||||||
|
patches,
|
||||||
|
postPatch,
|
||||||
|
}:
|
||||||
|
pkgs.stdenv.mkDerivation {
|
||||||
|
inherit pname patches postPatch;
|
||||||
|
inherit (kernel) version;
|
||||||
|
|
||||||
|
__structuredAttrs = true;
|
||||||
|
|
||||||
|
nativeBuildInputs = kernel.moduleBuildDependencies;
|
||||||
|
|
||||||
|
unpackPhase = ''
|
||||||
|
tar -xf ${kernel.src} --strip-components=1 --wildcards \
|
||||||
|
${lib.escapeShellArgs (map (path: "*/${path}") srcPaths)}
|
||||||
|
'';
|
||||||
|
|
||||||
|
makeFlags = kernelModuleMakeFlags ++ [
|
||||||
|
"KERNELRELEASE=${kernel.modDirVersion}"
|
||||||
|
];
|
||||||
|
|
||||||
|
installFlags = [
|
||||||
|
"DEPMOD=true"
|
||||||
|
"INSTALL_MOD_PATH=${placeholder "out"}"
|
||||||
|
];
|
||||||
|
|
||||||
|
buildPhase = ''
|
||||||
|
runHook preBuild
|
||||||
|
make -C ${kernel.dev}/lib/modules/${kernel.modDirVersion}/build \
|
||||||
|
M=$(pwd)/${dir} "''${makeFlags[@]}"
|
||||||
|
runHook postBuild
|
||||||
|
'';
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
runHook preInstall
|
||||||
|
make -C ${kernel.dev}/lib/modules/${kernel.modDirVersion}/build \
|
||||||
|
M=$(pwd)/${dir} modules_install \
|
||||||
|
"''${makeFlags[@]}" "''${installFlags[@]}"
|
||||||
|
runHook postInstall
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
ipu6-isys = mkPatchedModules {
|
||||||
pname = "ipu6-isys";
|
pname = "ipu6-isys";
|
||||||
inherit (kernel) version;
|
srcPaths = [ "drivers/media/pci/intel/ipu6/*" ];
|
||||||
|
dir = "drivers/media/pci/intel/ipu6";
|
||||||
__structuredAttrs = true;
|
|
||||||
|
|
||||||
patches = [ ./ipu6-isys-runtime-pm-null-check.patch ];
|
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 = ''
|
postPatch = ''
|
||||||
sed -i '/+= intel-ipu6\.o/d' drivers/media/pci/intel/ipu6/Makefile
|
sed -i '/+= intel-ipu6\.o/d' drivers/media/pci/intel/ipu6/Makefile
|
||||||
'';
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
makeFlags = kernelModuleMakeFlags ++ [
|
usbio = mkPatchedModules {
|
||||||
"KERNELRELEASE=${kernel.modDirVersion}"
|
pname = "usbio";
|
||||||
|
srcPaths = [
|
||||||
|
"drivers/usb/misc/usbio.c"
|
||||||
|
"drivers/gpio/gpio-usbio.c"
|
||||||
|
"include/linux/usb/usbio.h"
|
||||||
];
|
];
|
||||||
|
dir = "usbio";
|
||||||
installFlags = [
|
patches = [ ./usbio-reset-resume.patch ];
|
||||||
"DEPMOD=true"
|
postPatch = ''
|
||||||
"INSTALL_MOD_PATH=${placeholder "out"}"
|
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/
|
||||||
buildPhase = ''
|
echo 'LINUXINCLUDE := -I$(src)/include $(LINUXINCLUDE)' > usbio/Kbuild
|
||||||
runHook preBuild
|
echo 'obj-m += usbio.o gpio-usbio.o' >> usbio/Kbuild
|
||||||
make -C ${kernel.dev}/lib/modules/${kernel.modDirVersion}/build \
|
|
||||||
M=$(pwd)/drivers/media/pci/intel/ipu6 "''${makeFlags[@]}"
|
|
||||||
runHook postBuild
|
|
||||||
'';
|
|
||||||
|
|
||||||
installPhase = ''
|
|
||||||
runHook preInstall
|
|
||||||
make -C ${kernel.dev}/lib/modules/${kernel.modDirVersion}/build \
|
|
||||||
M=$(pwd)/drivers/media/pci/intel/ipu6 modules_install \
|
|
||||||
"''${makeFlags[@]}" "''${installFlags[@]}"
|
|
||||||
runHook postInstall
|
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
@@ -79,7 +110,10 @@ in
|
|||||||
})
|
})
|
||||||
];
|
];
|
||||||
|
|
||||||
boot.extraModulePackages = [ ipu6-isys ];
|
boot.extraModulePackages = [
|
||||||
|
ipu6-isys
|
||||||
|
usbio
|
||||||
|
];
|
||||||
|
|
||||||
hardware.ipu6 = {
|
hardware.ipu6 = {
|
||||||
enable = true;
|
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
|
||||||
Reference in new issue
Block a user