From patchwork Wed Jun 18 12:02:49 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksij Rempel X-Patchwork-Id: 897861 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A4DA22E54C7 for ; Wed, 18 Jun 2025 12:03:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750248199; cv=none; b=IstsOOXpQiwdvsSkuksdMfWnjedgYFXPZsk72LkPz13Jd9XdYvpvzjFIAFLlKCC48YS1y2Q471bW4+hY41SAJii/XvSFstQzVCXN/P8emkbT+NNPY0k+yHeQRffPbn4hSQyks8VemNZEb8tXpb3uL2Wwt7iIgdsRgnH7kxUhCdg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750248199; c=relaxed/simple; bh=kieKHX7Icyd+a5LVpQeQdQRXdlK7iTqy7fQZ7IwgIS8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=aytN6DvOt8u7909rTdrhLkaVCUERQ6E0eFmvOAHiFbZdqSsw/1L8vcV8HShKUph0W9VLuMV5+WuplZkxd+M52fjDPoMlNmUHN7gg20iK3gs+V8k8GpWLa1cDrGcB3SBBnWZ6saQC6WfqmQVAqjxwxdRoFiK7WYtJ7Sx8W4NFz/M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1uRrVJ-0007EU-Fn; Wed, 18 Jun 2025 14:02:57 +0200 Received: from dude04.red.stw.pengutronix.de ([2a0a:edc0:0:1101:1d::ac]) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uRrVI-0048CJ-1M; Wed, 18 Jun 2025 14:02:56 +0200 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1uRrVI-00DBLt-13; Wed, 18 Jun 2025 14:02:56 +0200 From: Oleksij Rempel To: Sebastian Reichel , Srinivas Kandagatla , Benson Leung , Tzung-Bi Shih , Daniel Lezcano Cc: Oleksij Rempel , Sebastian Reichel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, Liam Girdwood , Mark Brown , "Rafael J. Wysocki" , Zhang Rui , Lukasz Luba , linux-pm@vger.kernel.org, =?utf-8?q?S=C3=B8ren_Andersen?= , Guenter Roeck , Matti Vaittinen , Ahmad Fatoum , Andrew Morton , chrome-platform@lists.linux.dev Subject: [PATCH v11 1/7] power: Extend power_on_reason.h for upcoming PSCRR framework Date: Wed, 18 Jun 2025 14:02:49 +0200 Message-Id: <20250618120255.3141862-2-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250618120255.3141862-1-o.rempel@pengutronix.de> References: <20250618120255.3141862-1-o.rempel@pengutronix.de> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-pm@vger.kernel.org Prepare for the introduction of the Power State Change Reason Recorder (PSCRR) framework by expanding the power_on_reason.h header. This extension includes new power-on reasons: - POWER_ON_REASON_OVER_CURRENT for over-current conditions. - POWER_ON_REASON_REGULATOR_FAILURE for regulator failures. - POWER_ON_REASON_OVER_TEMPERATURE for over temperature situations. - POWER_ON_REASON_EC_PANIC for EC panics Signed-off-by: Oleksij Rempel Reviewed-by: Sebastian Reichel --- changes v10: - add Reviewed-by: Sebastian Reichel ... changes v6: - add POWER_ON_REASON_EC_PANIC - s/POWER_ON_REASON_OVERTEMPERATURE/POWER_ON_REASON_OVER_TEMPERATURE --- include/linux/power/power_on_reason.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/linux/power/power_on_reason.h b/include/linux/power/power_on_reason.h index 95a1ec0c403c..bf9501792696 100644 --- a/include/linux/power/power_on_reason.h +++ b/include/linux/power/power_on_reason.h @@ -15,5 +15,9 @@ #define POWER_ON_REASON_XTAL_FAIL "crystal oscillator failure" #define POWER_ON_REASON_BROWN_OUT "brown-out reset" #define POWER_ON_REASON_UNKNOWN "unknown reason" +#define POWER_ON_REASON_OVER_CURRENT "over current" +#define POWER_ON_REASON_REGULATOR_FAILURE "regulator failure" +#define POWER_ON_REASON_OVER_TEMPERATURE "over temperature" +#define POWER_ON_REASON_EC_PANIC "EC panic" #endif /* POWER_ON_REASON_H */ From patchwork Wed Jun 18 12:02:53 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksij Rempel X-Patchwork-Id: 897863 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D914D2DE21F for ; Wed, 18 Jun 2025 12:03:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750248195; cv=none; b=X7v+ZEykN3byXcpy0FuDaTGcX+2pFDiOzu6F3mAH+94t/hPqR67BI8iN6IC4uj5X2gsXkxRtvVEM8ZeiAzb5zLG6azxMSp8/Dfdw1o2A66hVh0l9DT6oHfL9KOw+v06PUDwBZAe0gZJ5+/SD1jDnuOL8aTMhHQ85RYzEo6byVqc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750248195; c=relaxed/simple; bh=XGojHH9F0Yv1Zaj14e+r4bcattMMcYs/2iz2DruAfIQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=p9fqN5YUJJe3FchProdNBisdOwgeluL7pDfFOhUjpOOu35ezwUQvGZN5UZbpy0HJNWl0kW1mTnrsD6tGl/utGyWy+LPc0aq6cPZOGSxzaOuNOOMNOFDCEqDIJAJcnr8hM4l/2zico0PpxJHG9NSBpP1jXK4LmfngLmENP+8+J0Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1uRrVJ-0007EY-Fn; Wed, 18 Jun 2025 14:02:57 +0200 Received: from dude04.red.stw.pengutronix.de ([2a0a:edc0:0:1101:1d::ac]) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uRrVI-0048CO-1g; Wed, 18 Jun 2025 14:02:56 +0200 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1uRrVI-00DBMX-1J; Wed, 18 Jun 2025 14:02:56 +0200 From: Oleksij Rempel To: Sebastian Reichel , Srinivas Kandagatla , Benson Leung , Tzung-Bi Shih , Daniel Lezcano Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, Liam Girdwood , Mark Brown , "Rafael J. Wysocki" , Zhang Rui , Lukasz Luba , linux-pm@vger.kernel.org, =?utf-8?q?S=C3=B8ren_Andersen?= , Guenter Roeck , Matti Vaittinen , Ahmad Fatoum , Andrew Morton , chrome-platform@lists.linux.dev Subject: [PATCH v11 5/7] nvmem: add support for device and sysfs-based cell lookups Date: Wed, 18 Jun 2025 14:02:53 +0200 Message-Id: <20250618120255.3141862-6-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250618120255.3141862-1-o.rempel@pengutronix.de> References: <20250618120255.3141862-1-o.rempel@pengutronix.de> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-pm@vger.kernel.org Introduce new API functions to allow looking up NVMEM devices and cells by name, enhancing flexibility in cases where devicetree-based lookup is not available. Key changes: - Added `nvmem_device_get_by_name()`: Enables retrieving an NVMEM device by its name for systems where direct device reference is needed. - Added `nvmem_cell_get_by_sysfs_name()`: Allows retrieving an NVMEM cell based on its sysfs-style name (e.g., "cell@offset,bits"), making it possible to identify cells dynamically. - Introduced `nvmem_find_cell_entry_by_sysfs_name()`: A helper function that constructs sysfs-like names and searches for matching cell entries. Signed-off-by: Oleksij Rempel --- changes v5: - fix build we NVMEM=n --- drivers/nvmem/core.c | 105 +++++++++++++++++++++++++++++++++ include/linux/nvmem-consumer.h | 18 ++++++ 2 files changed, 123 insertions(+) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 59c295a11d86..d310fd8ca9c0 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -1177,6 +1177,23 @@ struct nvmem_device *of_nvmem_device_get(struct device_node *np, const char *id) EXPORT_SYMBOL_GPL(of_nvmem_device_get); #endif +/** + * nvmem_device_get_by_name - Look up an NVMEM device by its device name + * @name: String matching device name in the provider + * + * Return: A valid pointer to struct nvmem_device on success, + * or ERR_PTR(...) on failure. The caller must later call nvmem_device_put() to + * release the reference. + */ +struct nvmem_device *nvmem_device_get_by_name(const char *name) +{ + if (!name) + return ERR_PTR(-EINVAL); + + return __nvmem_device_get((void *)name, device_match_name); +} +EXPORT_SYMBOL_GPL(nvmem_device_get_by_name); + /** * nvmem_device_get() - Get nvmem device from a given id * @@ -1490,6 +1507,94 @@ struct nvmem_cell *of_nvmem_cell_get(struct device_node *np, const char *id) EXPORT_SYMBOL_GPL(of_nvmem_cell_get); #endif +/** + * nvmem_find_cell_entry_by_sysfs_name - Find an NVMEM cell entry by its sysfs + * name. + * @nvmem: The nvmem_device pointer where the cell is located. + * @sysfs_name: The full sysfs cell name, e.g. "mycell@0x100,8". + * + * This function constructs the sysfs-like name for each cell and compares it + * to @sysfs_name. If a match is found, the matching nvmem_cell_entry pointer + * is returned. This is analogous to nvmem_find_cell_entry_by_name(), except + * it matches on the sysfs naming convention used in the device's attributes. + * + * Return: Pointer to the matching nvmem_cell_entry on success, or NULL if no + * match is found. + */ +static struct nvmem_cell_entry * +nvmem_find_cell_entry_by_sysfs_name(struct nvmem_device *nvmem, + const char *sysfs_name) +{ + struct nvmem_cell_entry *entry; + char tmp[NVMEM_CELL_NAME_MAX]; + + mutex_lock(&nvmem_mutex); + list_for_each_entry(entry, &nvmem->cells, node) { + int len = snprintf(tmp, NVMEM_CELL_NAME_MAX, "%s@%x,%u", + entry->name, entry->offset, + entry->bit_offset); + + if (len >= NVMEM_CELL_NAME_MAX) { + pr_warn("nvmem: cell name too long (max %zu bytes): %s\n", + NVMEM_CELL_NAME_MAX, sysfs_name); + continue; + } + + if (len < 0) { + pr_warn("nvmem: error formatting cell name\n"); + continue; + } + + if (!strcmp(tmp, sysfs_name)) { + mutex_unlock(&nvmem_mutex); + return entry; + } + } + + mutex_unlock(&nvmem_mutex); + return NULL; +} + +/** + * nvmem_cell_get_by_sysfs_name - Retrieve an NVMEM cell using a sysfs-style + * name. + * @nvmem: Pointer to the `struct nvmem_device` containing the cell. + * @sysfs_name: The sysfs-style cell name, formatted as + * "@,". + * + * This function enables dynamic lookup of NVMEM cells via sysfs-style + * identifiers. It is useful when devicetree-based lookup is unavailable or when + * cells are managed dynamically. + * + * Example Usage: + * nvmem_cell_get_by_sysfs_name(nvmem, "mycell@0x100,8"); + * + * Return: Pointer to `struct nvmem_cell` on success. On error, an ERR_PTR() is + * returned with the appropriate error code. + */ +struct nvmem_cell *nvmem_cell_get_by_sysfs_name(struct nvmem_device *nvmem, + const char *sysfs_name) +{ + struct nvmem_cell_entry *entry; + struct nvmem_cell *cell; + + entry = nvmem_find_cell_entry_by_sysfs_name(nvmem, sysfs_name); + if (!entry) + return ERR_PTR(-ENOENT); + + if (!try_module_get(nvmem->owner)) + return ERR_PTR(-EINVAL); + + kref_get(&nvmem->refcnt); + + cell = nvmem_create_cell(entry, entry->name, 0); + if (IS_ERR(cell)) + __nvmem_device_put(nvmem); + + return cell; +} +EXPORT_SYMBOL_GPL(nvmem_cell_get_by_sysfs_name); + /** * nvmem_cell_get() - Get nvmem cell of device form a given cell name * diff --git a/include/linux/nvmem-consumer.h b/include/linux/nvmem-consumer.h index bcb0e17e415d..2b5e06f457b0 100644 --- a/include/linux/nvmem-consumer.h +++ b/include/linux/nvmem-consumer.h @@ -20,6 +20,10 @@ struct nvmem_cell; struct nvmem_device; struct nvmem_cell_info; +#define NVMEM_CELL_NAME_MAX \ + (sizeof("very_long_cell_name_with_some_extra_chars_12345678@0x12345678,128")) + + /** * struct nvmem_cell_lookup - cell lookup entry * @@ -52,6 +56,8 @@ enum { /* Cell based interface */ struct nvmem_cell *nvmem_cell_get(struct device *dev, const char *id); struct nvmem_cell *devm_nvmem_cell_get(struct device *dev, const char *id); +struct nvmem_cell *nvmem_cell_get_by_sysfs_name(struct nvmem_device *nvmem, + const char *cell_name); void nvmem_cell_put(struct nvmem_cell *cell); void devm_nvmem_cell_put(struct device *dev, struct nvmem_cell *cell); void *nvmem_cell_read(struct nvmem_cell *cell, size_t *len); @@ -70,6 +76,7 @@ int nvmem_cell_read_variable_le_u64(struct device *dev, const char *cell_id, struct nvmem_device *nvmem_device_get(struct device *dev, const char *name); struct nvmem_device *devm_nvmem_device_get(struct device *dev, const char *name); +struct nvmem_device *nvmem_device_get_by_name(const char *name); void nvmem_device_put(struct nvmem_device *nvmem); void devm_nvmem_device_put(struct device *dev, struct nvmem_device *nvmem); int nvmem_device_read(struct nvmem_device *nvmem, unsigned int offset, @@ -109,6 +116,12 @@ static inline struct nvmem_cell *devm_nvmem_cell_get(struct device *dev, return ERR_PTR(-EOPNOTSUPP); } +static inline struct nvmem_cell * +nvmem_cell_get_by_sysfs_name(struct nvmem_device *nvmem, const char *cell_name) +{ + return ERR_PTR(-EOPNOTSUPP); +} + static inline void devm_nvmem_cell_put(struct device *dev, struct nvmem_cell *cell) { @@ -185,6 +198,11 @@ static inline struct nvmem_device *devm_nvmem_device_get(struct device *dev, return ERR_PTR(-EOPNOTSUPP); } +static inline struct nvmem_device *nvmem_device_get_by_name(const char *name) +{ + return ERR_PTR(-EOPNOTSUPP); +} + static inline void nvmem_device_put(struct nvmem_device *nvmem) { } From patchwork Wed Jun 18 12:02:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksij Rempel X-Patchwork-Id: 897862 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CA43F2E3B1D for ; Wed, 18 Jun 2025 12:03:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750248197; cv=none; b=J3AqTmzWNL+sBPJw0oEhomxqu/KQX66lkz1BaeSIgCEmd6NIRJtlBkNcve+YScj/tN6iK9nExztk8ayIdmn6RAy7gQ8L45+UFyw7+++V+Qnt/0h8bCvxwsTYFOeIbBZ2pJZ5PFyn9uqXFO25Ar6hETobxZQ7kf7DF5uL98g89Lo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750248197; c=relaxed/simple; bh=penylcrZjRjoRlt2DxZgzg5QOoQPPyQfH7KISVKYXtg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=X4kgZNYqoxoD1IKO6R3w8TimwcytYfisO8JkF/qjycDpcx2EWlU6hDv0QUeEtiomzxwhMs6yxNfKz2zPUO3deQSQJYHUxKJDY78YsbhtjZpZ9VAQOpAkQyKeHQG4DDEH82B54QDK+ptZlJp0ENh7fjrjtwsPL/CL/LNGAoNg1hg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1uRrVJ-0007Ea-Fn; Wed, 18 Jun 2025 14:02:57 +0200 Received: from dude04.red.stw.pengutronix.de ([2a0a:edc0:0:1101:1d::ac]) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uRrVI-0048CR-1r; Wed, 18 Jun 2025 14:02:56 +0200 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1uRrVI-00DBMr-1Q; Wed, 18 Jun 2025 14:02:56 +0200 From: Oleksij Rempel To: Sebastian Reichel , Srinivas Kandagatla , Benson Leung , Tzung-Bi Shih , Daniel Lezcano Cc: Oleksij Rempel , Matti Vaittinen , kernel@pengutronix.de, linux-kernel@vger.kernel.org, Liam Girdwood , Mark Brown , "Rafael J. Wysocki" , Zhang Rui , Lukasz Luba , linux-pm@vger.kernel.org, =?utf-8?q?S=C3=B8ren_Andersen?= , Guenter Roeck , Ahmad Fatoum , Andrew Morton , chrome-platform@lists.linux.dev Subject: [PATCH v11 7/7] Documentation: Add sysfs documentation for PSCRR reboot reason tracking Date: Wed, 18 Jun 2025 14:02:55 +0200 Message-Id: <20250618120255.3141862-8-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250618120255.3141862-1-o.rempel@pengutronix.de> References: <20250618120255.3141862-1-o.rempel@pengutronix.de> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-pm@vger.kernel.org Add documentation for the Power State Change Reason Recorder (PSCRR) sysfs interface, which allows tracking of system shutdown and reboot reasons. The documentation provides details on available sysfs entries under `/sys/kernel/pscrr/`, explaining their functionality, example usage, and how they interact with different backend storage options (e.g., NVMEM). Signed-off-by: Oleksij Rempel Reviewed-by: Matti Vaittinen --- changes v8: - Simplify and clarify example sysfs value comments - Add note that not all values are meaningful on every system changes v7: - document expected values --- .../ABI/testing/sysfs-kernel-reboot-pscrr | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-kernel-reboot-pscrr diff --git a/Documentation/ABI/testing/sysfs-kernel-reboot-pscrr b/Documentation/ABI/testing/sysfs-kernel-reboot-pscrr new file mode 100644 index 000000000000..96369422ed6e --- /dev/null +++ b/Documentation/ABI/testing/sysfs-kernel-reboot-pscrr @@ -0,0 +1,74 @@ +What: /sys/kernel/pscrr/reason +Date: April 2025 +KernelVersion: 6.16 +Contact: Oleksij Rempel +Description: + This file provides access to the current power state + change reason. If supported, the reason may be stored + persistently in an NVMEM cell or another backend. + + Reading this file returns an integer representing the + current shutdown or reboot cause. + + Writing an integer value to this file sets the reason + to be stored for system analysis on next reboot. + + Example usage: + Read: + $ cat /sys/kernel/pscrr/reason + 1 # (Example: Under-voltage shutdown) + + Write: + $ echo 4 > /sys/kernel/pscrr/reason + # Sets the reason to 4 (Example: Over-temperature shutdown) + + Note: + Not all systems support all reason values. Hardware or + configuration may limit which reasons are applicable. + + Values are defined in: + - include/linux/reboot.h (enum psc_reason) + + Supported Values: + (from include/linux/reboot.h) + + +-------+---------------------------+--------------------------+ + | Value | Symbol | Description | + +-------+---------------------------+--------------------------+ + | 0 | PSCR_UNKNOWN | Unknown or unspecified | + | | | power state change reason| + +-------+---------------------------+--------------------------+ + | 1 | PSCR_UNDER_VOLTAGE | Supply voltage dropped | + | | | below safe threshold | + +-------+---------------------------+--------------------------+ + | 2 | PSCR_OVER_CURRENT | Excessive current draw or| + | | | potential short circuit | + +-------+---------------------------+--------------------------+ + | 3 | PSCR_REGULATOR_FAILURE | Voltage regulator failure| + | | | preventing stable supply | + +-------+---------------------------+--------------------------+ + | 4 | PSCR_OVER_TEMPERATURE | Unsafe system temperature| + | | | detected by sensors | + +-------+---------------------------+--------------------------+ + | 5 | PSCR_EC_PANIC | Reboot triggered by EC | + | | | (Embedded Controller) | + +-------+---------------------------+--------------------------+ + +What: /sys/kernel/pscrr/reason_boot +Date: April 2025 +KernelVersion: 6.16 +Contact: Oleksij Rempel +Description: + This file provides the last recorded power state change + reason from before the current boot. If a supported backend + is configured (e.g., NVMEM), the value is retained across + reboots. + + Example usage: + Read: + $ cat /sys/kernel/pscrr/reason_boot + 4 # (Example: Over-temperature shutdown) + + Supported values: + Same as /sys/kernel/pscrr/reason (see above). +