Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

reset: ACPI reset support

Some of the IO devices like I2C or SPI require reset at runtime to
recover from an error condition without changing the power state of
the system. Added check for ACPI handle and a call to method '__RST'
if supported. Devices using device tree method are unaffected by this.

Signed-off-by: Krishna Yarlagadda <kyarlagadda@nvidia.com>
[p.zabel@pengutronix.de: wrap in #ifdef CONFIG_ACPI due to missing stubs]
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Link: https://lore.kernel.org/r/20220307135626.16673-1-kyarlagadda@nvidia.com

authored by

Krishna Yarlagadda and committed by
Philipp Zabel
82816b4f 77fb4e45

+14 -1
+14 -1
drivers/reset/core.c
··· 12 12 #include <linux/kref.h> 13 13 #include <linux/module.h> 14 14 #include <linux/of.h> 15 + #include <linux/acpi.h> 15 16 #include <linux/reset.h> 16 17 #include <linux/reset-controller.h> 17 18 #include <linux/slab.h> ··· 1101 1100 * 1102 1101 * Convenience wrapper for __reset_control_get() and reset_control_reset(). 1103 1102 * This is useful for the common case of devices with single, dedicated reset 1104 - * lines. 1103 + * lines. _RST firmware method will be called for devices with ACPI. 1105 1104 */ 1106 1105 int __device_reset(struct device *dev, bool optional) 1107 1106 { 1108 1107 struct reset_control *rstc; 1109 1108 int ret; 1109 + 1110 + #ifdef CONFIG_ACPI 1111 + acpi_handle handle = ACPI_HANDLE(dev); 1112 + 1113 + if (handle) { 1114 + if (!acpi_has_method(handle, "_RST")) 1115 + return optional ? 0 : -ENOENT; 1116 + if (ACPI_FAILURE(acpi_evaluate_object(handle, "_RST", NULL, 1117 + NULL))) 1118 + return -EIO; 1119 + } 1120 + #endif 1110 1121 1111 1122 rstc = __reset_control_get(dev, NULL, 0, 0, optional, true); 1112 1123 if (IS_ERR(rstc))