From patchwork Thu Jul 27 15:26:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Bara X-Patchwork-Id: 707412 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2B294C001E0 for ; Thu, 27 Jul 2023 15:26:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233391AbjG0P0y (ORCPT ); Thu, 27 Jul 2023 11:26:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234595AbjG0P0u (ORCPT ); Thu, 27 Jul 2023 11:26:50 -0400 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B22631FF5; Thu, 27 Jul 2023 08:26:48 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-31765792c7cso1180620f8f.0; Thu, 27 Jul 2023 08:26:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690471607; x=1691076407; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=R87BTfopelhJFglN5IN6As+cGJH4HVKKMNIB+DJTWpo=; b=NZgk4HfJyy0U4LwtA03w7bjkCYbSBrHp5nQVOMa0tqIsIfnFDBSpzQAK9pPan32YCP 758WhVpcdhjbgLsuvtBOrQD+80wwe7F0GznGNKVr4kDJK8BYdLOFfXtxdB7XNrAR4+5C 9I4Uww/xYkLM7KkG92p0N5cuCmq730dfnY12q61mNO87ICkJfUjDf9/zbpfIFVbcMhRh 8Xb1CjUYih4bJAkOfFvj0pM65gx26WCjJIb7uZ9U2wVhehioTdTH7R8SjQr0cAY3zqtm 0ldygbdhKV4ZwI8DESfq2nYUf1YNEMfFJCS9c59FaVqcZwk89vBqaVLLo/+V+vCdB8NL P4Kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690471607; x=1691076407; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=R87BTfopelhJFglN5IN6As+cGJH4HVKKMNIB+DJTWpo=; b=GO8FeAjfRtSZhlGl1/Im5gvcABrzZqHdfxMe1ano+mmD8xw/tjUW8X3NFOCbIRWUje pDAMZbPXF+oqC13RrSN+Tas3OLbVG1wQaIMH/nW5WTMoEpYQVIRyV22f3Lm7MoFn/n9E X72pWBZVjiXX7qq4N/4jmt1TjTZDGG1lgkmG7ruuknrjuOuvmRcUtUncU06kougsfhvq E7IsYHKZo4QDB0rXrxC3vKZa/hpoUbcMBO/5B/5J4TvgpTdKL7ggUqcV2W+SaE0ySWMl ehii1ivr7MG0svZFtq9g9rRYJmC+4gFnYF/Zscv3j6pjUMO/TmBhvG0G5Nzd6540H4Rj nyvg== X-Gm-Message-State: ABy/qLZq46i9LrEMZT+7q+DIMBomhmCnUqNgAvLNkZpfOonelgi51TCW kq0FHiPVYuMc3fdXGC9OH7yA0N/ixD+Ij0IV X-Google-Smtp-Source: APBJJlGWncJjmVx3/BMhSoTbn13HjjrbEC9bf/p8ktEEBuc6Uxfm2DMRhqlYdSmkIsOlbWsCdcadaA== X-Received: by 2002:a5d:6744:0:b0:314:15a8:7879 with SMTP id l4-20020a5d6744000000b0031415a87879mr2219378wrw.34.1690471606869; Thu, 27 Jul 2023 08:26:46 -0700 (PDT) Received: from [127.0.1.1] ([91.230.2.244]) by smtp.gmail.com with ESMTPSA id b17-20020adfde11000000b003143765e207sm2350622wrm.49.2023.07.27.08.26.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jul 2023 08:26:46 -0700 (PDT) From: Benjamin Bara Date: Thu, 27 Jul 2023 17:26:36 +0200 Subject: [PATCH 1/6] kernel/reboot: distinguish between cold and warm MIME-Version: 1.0 Message-Id: <20230727-pca9450-reboot-v1-1-c8edb27bf404@skidata.com> References: <20230727-pca9450-reboot-v1-0-c8edb27bf404@skidata.com> In-Reply-To: <20230727-pca9450-reboot-v1-0-c8edb27bf404@skidata.com> To: Lee Jones , Thierry Reding , Jonathan Hunter , Tony Lindgren , Liam Girdwood , Mark Brown , Dmitry Osipenko , Robin Gong , Jerome Neanne Cc: linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org, linux-omap@vger.kernel.org, Benjamin Bara X-Mailer: b4 0.12.3 Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org From: Benjamin Bara As a couple of PMICs support warm and cold resets (e.g. tps65219 or pca9450) and the 'reboot_mode' kernel parameter allows to specify the reboot mode, distinguish between cold and warm reboot handlers. This is done by maintaining two different restart handler lists. When the mode is unspecified, the cold restart handlers are preferred (independent of their actual priority). Signed-off-by: Benjamin Bara --- include/linux/reboot.h | 22 ++++++++++++ kernel/reboot.c | 92 ++++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 108 insertions(+), 6 deletions(-) diff --git a/include/linux/reboot.h b/include/linux/reboot.h index 2b6bb593be5b..05199aedb696 100644 --- a/include/linux/reboot.h +++ b/include/linux/reboot.h @@ -119,6 +119,20 @@ enum sys_off_mode { * Handlers restart system. Handlers are disallowed to sleep. */ SYS_OFF_MODE_RESTART, + + /** + * @SYS_OFF_MODE_RESTART_COLD: + * + * Handlers cold restart system. Handlers are disallowed to sleep. + */ + SYS_OFF_MODE_RESTART_COLD, + + /** + * @SYS_OFF_MODE_RESTART_WARM: + * + * Handlers warm restart system. Handlers are disallowed to sleep. + */ + SYS_OFF_MODE_RESTART_WARM, }; /** @@ -157,6 +171,14 @@ int devm_register_restart_handler(struct device *dev, int (*callback)(struct sys_off_data *data), void *cb_data); +int devm_register_cold_restart_handler(struct device *dev, + int (*callback)(struct sys_off_data *data), + void *cb_data); + +int devm_register_warm_restart_handler(struct device *dev, + int (*callback)(struct sys_off_data *data), + void *cb_data); + int register_platform_power_off(void (*power_off)(void)); void unregister_platform_power_off(void (*power_off)(void)); diff --git a/kernel/reboot.c b/kernel/reboot.c index 3bba88c7ffc6..d0d3faf70a79 100644 --- a/kernel/reboot.c +++ b/kernel/reboot.c @@ -146,9 +146,15 @@ EXPORT_SYMBOL(devm_register_reboot_notifier); /* * Notifier list for kernel code which wants to be called - * to restart the system. + * to cold restart the system. */ -static ATOMIC_NOTIFIER_HEAD(restart_handler_list); +static ATOMIC_NOTIFIER_HEAD(cold_restart_handler_list); + +/* + * Notifier list for kernel code which wants to be called + * to warm restart the system. + */ +static ATOMIC_NOTIFIER_HEAD(warm_restart_handler_list); /** * register_restart_handler - Register function to be called to reset @@ -190,7 +196,11 @@ static ATOMIC_NOTIFIER_HEAD(restart_handler_list); */ int register_restart_handler(struct notifier_block *nb) { - return atomic_notifier_chain_register(&restart_handler_list, nb); + /* + * Store all non-devm-based handlers in the warm list to ensure that the + * "specified" handler are preferred over the "unspecified" ones. + */ + return atomic_notifier_chain_register(&warm_restart_handler_list, nb); } EXPORT_SYMBOL(register_restart_handler); @@ -205,7 +215,14 @@ EXPORT_SYMBOL(register_restart_handler); */ int unregister_restart_handler(struct notifier_block *nb) { - return atomic_notifier_chain_unregister(&restart_handler_list, nb); + int ret; + + ret = atomic_notifier_chain_unregister(&warm_restart_handler_list, nb); + if (ret == -ENOENT) + ret = atomic_notifier_chain_unregister(&cold_restart_handler_list, + nb); + + return ret; } EXPORT_SYMBOL(unregister_restart_handler); @@ -222,7 +239,18 @@ EXPORT_SYMBOL(unregister_restart_handler); */ void do_kernel_restart(char *cmd) { - atomic_notifier_call_chain(&restart_handler_list, reboot_mode, cmd); + /* + * REBOOT_GPIO can be either cold or warm -> let handler decide. + * Prefer cold reboot if mode not specified. + */ + if (reboot_mode == REBOOT_UNDEFINED || reboot_mode == REBOOT_GPIO || + reboot_mode == REBOOT_HARD || reboot_mode == REBOOT_COLD) + atomic_notifier_call_chain(&cold_restart_handler_list, + reboot_mode, cmd); + if (reboot_mode == REBOOT_UNDEFINED || reboot_mode == REBOOT_GPIO || + reboot_mode == REBOOT_SOFT || reboot_mode == REBOOT_WARM) + atomic_notifier_call_chain(&warm_restart_handler_list, + reboot_mode, cmd); } void migrate_to_reboot_cpu(void) @@ -414,7 +442,15 @@ register_sys_off_handler(enum sys_off_mode mode, break; case SYS_OFF_MODE_RESTART: - handler->list = &restart_handler_list; + handler->list = &warm_restart_handler_list; + break; + + case SYS_OFF_MODE_RESTART_COLD: + handler->list = &cold_restart_handler_list; + break; + + case SYS_OFF_MODE_RESTART_WARM: + handler->list = &warm_restart_handler_list; break; default: @@ -560,6 +596,50 @@ int devm_register_restart_handler(struct device *dev, } EXPORT_SYMBOL_GPL(devm_register_restart_handler); +/** + * devm_register_cold_restart_handler - Register cold restart handler + * @dev: Device that registers callback + * @callback: Callback function + * @cb_data: Callback's argument + * + * Registers resource-managed sys-off handler with a default priority + * and using cold restart mode. + * + * Returns zero on success, or error code on failure. + */ +int devm_register_cold_restart_handler(struct device *dev, + int (*callback)(struct sys_off_data *data), + void *cb_data) +{ + return devm_register_sys_off_handler(dev, + SYS_OFF_MODE_RESTART_COLD, + SYS_OFF_PRIO_DEFAULT, + callback, cb_data); +} +EXPORT_SYMBOL_GPL(devm_register_cold_restart_handler); + +/** + * devm_register_warm_restart_handler - Register warm restart handler + * @dev: Device that registers callback + * @callback: Callback function + * @cb_data: Callback's argument + * + * Registers resource-managed sys-off handler with a default priority + * and using warm restart mode. + * + * Returns zero on success, or error code on failure. + */ +int devm_register_warm_restart_handler(struct device *dev, + int (*callback)(struct sys_off_data *data), + void *cb_data) +{ + return devm_register_sys_off_handler(dev, + SYS_OFF_MODE_RESTART_WARM, + SYS_OFF_PRIO_DEFAULT, + callback, cb_data); +} +EXPORT_SYMBOL_GPL(devm_register_warm_restart_handler); + static struct sys_off_handler *platform_power_off_handler; static int platform_power_off_notify(struct sys_off_data *data) From patchwork Thu Jul 27 15:26:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Bara X-Patchwork-Id: 708216 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 44905C41513 for ; Thu, 27 Jul 2023 15:26:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234599AbjG0P0w (ORCPT ); Thu, 27 Jul 2023 11:26:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234588AbjG0P0u (ORCPT ); Thu, 27 Jul 2023 11:26:50 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A97231FF2; Thu, 27 Jul 2023 08:26:49 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-3fbc656873eso12229525e9.1; Thu, 27 Jul 2023 08:26:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690471608; x=1691076408; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=z5lUd6tLllXoqVN95rU12GI/kHjXVOUk+BNB7Y22cto=; b=FjsdD+F62OVFGK0evuFmUjv+fYHflFxnl7eTSOLR+NXfZROQ34Eou4GPvtFmLGiJwb Ks70ALf537BmtGdLK4EB7Ufr6+Zu+b7jPbyo7IxuK8/NfIgkhA0/5j32Px3PuRN2Wh6q Hmb8OtMzEH6euQFvszszXZ4erEJb5h/YmVrCJz1Z6DFjIxsFOHZOIWEmHAuybBNDPEPX hX4cF2DoQ8xxqWjap1trw7ZrA5q0tocGUEiXVaT1VPUh1dZa2FQscPW0BTp3oPSbD9Dz cvcBp+Qy0PZuq61ANQpoT6/cMDmAzmzNLo/SZp73vZqmOgM00VaYyqjdUIdN6c7IqeML R10w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690471608; x=1691076408; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=z5lUd6tLllXoqVN95rU12GI/kHjXVOUk+BNB7Y22cto=; b=KjqA72P0/eF2AFM0NWZ+0x4rxBsLi14R3qrEqlh56mZhvVhx/qf5RYfHl+cs+wFclu 4d9ILcW6UAZJNWUssCn5vltQjuifni5LP2gegeQskW1sQry54WabNMFprfit315i99Cz nmilhEKICo+I+oFHu2oG9bRTeO9ImBHULrsGpkQOQ6SQ/60Xwo+gYAc+nK2GEBJOIYbM zTLpbWbomb3W407Cpy54awtjfmJSUBx5NbdB5sTEYupjuD6j2tHyMO9bAEBS5HZChOzQ yi0DCzUxndCupjCRPrqI/DyfPHqylB1PWVLr+0QXbbgFxPO5qHahf/NNyzLS+MoeITon 7Byw== X-Gm-Message-State: ABy/qLbyOgrJNo8Rc0UYK/keKcb0J85IBe+MvmJ04pLO8iMA+TIL8CRA wTb6bld8hUOnViABjH+7D2I= X-Google-Smtp-Source: APBJJlFjGqSrbh0oMoihKOPYd1QdUFuycfFOnzva1CI7AXyNbgeXj1ldzIMEDsOHkjausLac9x92sQ== X-Received: by 2002:a05:600c:ac1:b0:3fb:a100:2581 with SMTP id c1-20020a05600c0ac100b003fba1002581mr2186582wmr.14.1690471607767; Thu, 27 Jul 2023 08:26:47 -0700 (PDT) Received: from [127.0.1.1] ([91.230.2.244]) by smtp.gmail.com with ESMTPSA id b17-20020adfde11000000b003143765e207sm2350622wrm.49.2023.07.27.08.26.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jul 2023 08:26:47 -0700 (PDT) From: Benjamin Bara Date: Thu, 27 Jul 2023 17:26:37 +0200 Subject: [PATCH 2/6] mfd: rk8xx: Specify restart mode MIME-Version: 1.0 Message-Id: <20230727-pca9450-reboot-v1-2-c8edb27bf404@skidata.com> References: <20230727-pca9450-reboot-v1-0-c8edb27bf404@skidata.com> In-Reply-To: <20230727-pca9450-reboot-v1-0-c8edb27bf404@skidata.com> To: Lee Jones , Thierry Reding , Jonathan Hunter , Tony Lindgren , Liam Girdwood , Mark Brown , Dmitry Osipenko , Robin Gong , Jerome Neanne Cc: linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org, linux-omap@vger.kernel.org, Benjamin Bara X-Mailer: b4 0.12.3 Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org From: Benjamin Bara Specify the implemented restart handler as a cold one. Signed-off-by: Benjamin Bara --- drivers/mfd/rk8xx-core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/mfd/rk8xx-core.c b/drivers/mfd/rk8xx-core.c index e8fc9e2ab1d0..15e8e6a9943a 100644 --- a/drivers/mfd/rk8xx-core.c +++ b/drivers/mfd/rk8xx-core.c @@ -697,7 +697,8 @@ int rk8xx_probe(struct device *dev, int variant, unsigned int irq, struct regmap case RK809_ID: case RK817_ID: ret = devm_register_sys_off_handler(dev, - SYS_OFF_MODE_RESTART, SYS_OFF_PRIO_HIGH, + SYS_OFF_MODE_RESTART_COLD, + SYS_OFF_PRIO_HIGH, &rk808_restart, rk808); if (ret) dev_warn(dev, "failed to register rst handler, %d\n", ret); From patchwork Thu Jul 27 15:26:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Bara X-Patchwork-Id: 707413 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 70EF3C04A94 for ; Thu, 27 Jul 2023 15:26:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234618AbjG0P0y (ORCPT ); Thu, 27 Jul 2023 11:26:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233532AbjG0P0v (ORCPT ); Thu, 27 Jul 2023 11:26:51 -0400 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C9A02D54; Thu, 27 Jul 2023 08:26:50 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-31771bb4869so1150236f8f.0; Thu, 27 Jul 2023 08:26:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690471608; x=1691076408; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=HkMGDumQlalY89C6gPCAt+EinCF2NpTD+G/geonEwe8=; b=QJLPzqFhw7qbdOMo67W0DveidbMWfA8UYMf6LvQNtcDD1N7p0GXZhxZIqEcIQVeAbw l8z9ApmYfdLNVwUvry+24uZ5rpIXD6UxJr38/t3gjgIumUE3m/GQUpnoefKjDs7POAt+ vLfkOX+x9b+g9nOMWlSQPHZbCsjfLByQ2kcks5dvPMIKnAgC1Dbhfivlz4ZngMWYk+Cs KajNfOMfYSb8UsQ+OHgjY7pluzshN2tfqOhIqWI5ohBJ+MNxS6ExFVf5Jb3k7KMWD9x9 a4Kse1naYHheuCtvrdhkTZp8Z6+vusdVGKMIsWIYkHBb6r1ip1OL7OL8lqp+whvvorZ0 SC7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690471608; x=1691076408; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HkMGDumQlalY89C6gPCAt+EinCF2NpTD+G/geonEwe8=; b=bpPhQef2cdN5QRmmiUN5CUUrNYOVInj33YrQGt4qoe8WHIyH1xwq1KTGN+KqcZoAM6 MO65Dt48fzZdJ6GDzZsNyZjFEYAOQPujaWzE4yOjJPiMJeEyfUvvD2rPblHAvf6UyvDu Zoztx+QfVnOrW5/Unwj35QgnkKEV+leNuRjDfxMAGO2Bxz8P4dXlCevjlDoSWQIwgQ3S akX+1kc1oxG+e6nZdtEJj8PKj29tDBNAMZYUK1IM8IPnGv8X/+7GLEfCOkiOKMGxd70B qfIUKT/ZL8Bj+kudMbSfwRrH7mhqhOb8pFalDAlybCLgjRMdt8LXaZTR/oFFpJjD3XMS PAjA== X-Gm-Message-State: ABy/qLan1JwPctDSWOdZbWRHYLOOikvzBXDZOW0cbrb6IECnZd6wxx5J J1accy5nUuIva9160i3RmsI= X-Google-Smtp-Source: APBJJlGn3MF6wD2StoFElm1XD+QHKQk5L//InWCg2kgAY070ed7EkqIEA74JK0+10I1+yQoWXJ803A== X-Received: by 2002:adf:f8ce:0:b0:317:6f08:8371 with SMTP id f14-20020adff8ce000000b003176f088371mr1994540wrq.48.1690471608531; Thu, 27 Jul 2023 08:26:48 -0700 (PDT) Received: from [127.0.1.1] ([91.230.2.244]) by smtp.gmail.com with ESMTPSA id b17-20020adfde11000000b003143765e207sm2350622wrm.49.2023.07.27.08.26.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jul 2023 08:26:48 -0700 (PDT) From: Benjamin Bara Date: Thu, 27 Jul 2023 17:26:38 +0200 Subject: [PATCH 3/6] soc/tegra: pmc: Specify restart mode MIME-Version: 1.0 Message-Id: <20230727-pca9450-reboot-v1-3-c8edb27bf404@skidata.com> References: <20230727-pca9450-reboot-v1-0-c8edb27bf404@skidata.com> In-Reply-To: <20230727-pca9450-reboot-v1-0-c8edb27bf404@skidata.com> To: Lee Jones , Thierry Reding , Jonathan Hunter , Tony Lindgren , Liam Girdwood , Mark Brown , Dmitry Osipenko , Robin Gong , Jerome Neanne Cc: linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org, linux-omap@vger.kernel.org, Benjamin Bara X-Mailer: b4 0.12.3 Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org From: Benjamin Bara Specify the implemented restart handler as a warm one. Signed-off-by: Benjamin Bara Acked-by: Thierry Reding --- drivers/soc/tegra/pmc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c index 162f52456f65..4f42febb9b0f 100644 --- a/drivers/soc/tegra/pmc.c +++ b/drivers/soc/tegra/pmc.c @@ -2962,7 +2962,7 @@ static int tegra_pmc_probe(struct platform_device *pdev) } err = devm_register_sys_off_handler(&pdev->dev, - SYS_OFF_MODE_RESTART, + SYS_OFF_MODE_RESTART_WARM, SYS_OFF_PRIO_LOW, tegra_pmc_restart_handler, NULL); if (err) { From patchwork Thu Jul 27 15:26:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Bara X-Patchwork-Id: 708215 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4050BC41513 for ; Thu, 27 Jul 2023 15:26:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234627AbjG0P04 (ORCPT ); Thu, 27 Jul 2023 11:26:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234601AbjG0P0x (ORCPT ); Thu, 27 Jul 2023 11:26:53 -0400 Received: from mail-lj1-x229.google.com (mail-lj1-x229.google.com [IPv6:2a00:1450:4864:20::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CAD61FEC; Thu, 27 Jul 2023 08:26:51 -0700 (PDT) Received: by mail-lj1-x229.google.com with SMTP id 38308e7fff4ca-2b9352ff1aeso16516681fa.1; Thu, 27 Jul 2023 08:26:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690471609; x=1691076409; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=HdSNTdHfu3gmfnNmRZ2hSNcbvNs2kLgKcLc95quFvnE=; b=Ot63R368iSKukEqX+qAC4oDZKw7GhuAcTMUwho6PAJxiZPK18ngo6jwMnRNjiuzviz gkNNylRKqi6X9L757EsPpYKtFQbb+RisWEfUA7RsDkNumkHgzLUMmqFLAHr3lKvhDSwK 8PV4j7sGqydTylHtyOuW4gSPtQA2vrTCKNIKIYvCxERNkgGIj0YZBYvAtZgmqR49kRpu zFs6RIg1CIIzvsIpWz9XGwByufeeGFj0TxgY/irWUd3jqAt2Oq3Y1V58/Oe2h2e/Jhgw v2Lr2YfuiySrvgVuQlpMUK9oe7nguXRcd27XtW6kfzZBJwE5OgkWmCXgcpt+DJrRVsha AlDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690471609; x=1691076409; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HdSNTdHfu3gmfnNmRZ2hSNcbvNs2kLgKcLc95quFvnE=; b=eZafKpHztt883cNJSapLYwJPKb4jb6YuijerDHWUQKEep+zHi1LF60auiLjiDF6x6i OPG5Gz6seYUVKeR/3VE0dXH1VNY2whJlOiCmEqM20BK7KS4hBYZysmNAtfK7tj4fAM7e GOfDKZ54AJqN48YY32jSZt+RJvdSu5BIScB1PxURneNvcrpiPh/lRtAECwy3eND1i+Jo L741sUPUFesQm2RKbv1DBMY0Lqhnl1nDAhVbuKax6YZbTLzsx2lRcGVW0OYbK2C0oWt3 huHyGB4cg54COmZEUYoX/W9rKzpi33x6VFrc+dwsydJrlrqNnqZRqv92xC2y8sv15AyK +lKw== X-Gm-Message-State: ABy/qLb0QAiQeJTCOiiglxXyBKsVuIbn/AISvwa5yXICWy5qCD7BzrAh JQPI7OqYKJsl5d+bjgDrGJjZATqU1bi9xaKX X-Google-Smtp-Source: APBJJlECjtY232aDHswklrgmAPFnRUY97te2qhkbwXkITkFGmWaf+ews7rGxaiPlP3xdW7gRsnxVOg== X-Received: by 2002:a05:6512:3c86:b0:4f8:7568:e94b with SMTP id h6-20020a0565123c8600b004f87568e94bmr2351473lfv.56.1690471609243; Thu, 27 Jul 2023 08:26:49 -0700 (PDT) Received: from [127.0.1.1] ([91.230.2.244]) by smtp.gmail.com with ESMTPSA id b17-20020adfde11000000b003143765e207sm2350622wrm.49.2023.07.27.08.26.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jul 2023 08:26:49 -0700 (PDT) From: Benjamin Bara Date: Thu, 27 Jul 2023 17:26:39 +0200 Subject: [PATCH 4/6] mfd: tps65219: Specify restart mode MIME-Version: 1.0 Message-Id: <20230727-pca9450-reboot-v1-4-c8edb27bf404@skidata.com> References: <20230727-pca9450-reboot-v1-0-c8edb27bf404@skidata.com> In-Reply-To: <20230727-pca9450-reboot-v1-0-c8edb27bf404@skidata.com> To: Lee Jones , Thierry Reding , Jonathan Hunter , Tony Lindgren , Liam Girdwood , Mark Brown , Dmitry Osipenko , Robin Gong , Jerome Neanne Cc: linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org, linux-omap@vger.kernel.org, Benjamin Bara X-Mailer: b4 0.12.3 Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org From: Benjamin Bara As the tps65219 supports both, a cold and a warm reset, register a cold and a warm restart handler. Signed-off-by: Benjamin Bara --- drivers/mfd/tps65219.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/mfd/tps65219.c b/drivers/mfd/tps65219.c index 0e0c42e4fdfc..85752b93256e 100644 --- a/drivers/mfd/tps65219.c +++ b/drivers/mfd/tps65219.c @@ -278,12 +278,21 @@ static int tps65219_probe(struct i2c_client *client) } } - ret = devm_register_restart_handler(tps->dev, - tps65219_restart_handler, - tps); + ret = devm_register_cold_restart_handler(tps->dev, + tps65219_restart_handler, + tps); if (ret) { - dev_err(tps->dev, "cannot register restart handler, %d\n", ret); + dev_err(tps->dev, "cannot register cold restart handler, %d\n", ret); + return ret; + } + + ret = devm_register_warm_restart_handler(tps->dev, + tps65219_restart_handler, + tps); + + if (ret) { + dev_err(tps->dev, "cannot register warm restart handler, %d\n", ret); return ret; } From patchwork Thu Jul 27 15:26:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Bara X-Patchwork-Id: 708214 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6E880C04A6A for ; Thu, 27 Jul 2023 15:27:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234600AbjG0P05 (ORCPT ); Thu, 27 Jul 2023 11:26:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234609AbjG0P0y (ORCPT ); Thu, 27 Jul 2023 11:26:54 -0400 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4793E1FF2; Thu, 27 Jul 2023 08:26:52 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-31751d7d96eso1093581f8f.1; Thu, 27 Jul 2023 08:26:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690471610; x=1691076410; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=aHqP+YZKi6UJxxMncRrogAGn87C6jhHE2PztBFcHNPw=; b=e7V1bqT9LFG14ArBckFFf5U7nVwFOFhfQI65sytOs6iyWfx/rrSLXqxcBI0kdkJGrY BA8wiuyrjV4RRx2Aw2P7Z2wSPDA6HLK9Zxy2hwRbNQmRKvP/HuFOVUFDZlzH24MS4lv6 GPa2VT1dQKdlr9GcArGDQ2ScCqO8tBvSEnXWBXKeHAFxtO2XYsdFgR/X/HhMr1QjOE5l LAwKVfMBohvzhbha/2jbs5i8Vqbq7KF4D64mfM/15jaLedERLibA1pV8cwovVeCnPHFg jSgvcCUTBXXJmRN363H3veG2acSaToTiJ4OvCSEksuc8PPcP6gshrtwtQYUVewZ5MlA4 /tVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690471610; x=1691076410; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aHqP+YZKi6UJxxMncRrogAGn87C6jhHE2PztBFcHNPw=; b=Egi+qDOHwjPOfFA/0Q9zzJz8HClKTlQq7x1Na0usEijxh1XkbcxTpMByVDdYxGLON7 UIx8j+NOPe4HZ+LdlCSuOcFkKJ7eDXOI9gMnIc4C6orM6+wHEQ5BUuFvnnYA8+aouZpJ qPsahDiOvrIktsDq+JkzwT2BCJuM8lpNaxVtUjXgHsQfj7/YI7yrAuUH+eZNWlS/9VjJ cdCspm8ZOjbLhSYFiGhqA6PDrzOYsktO8w5T2A1LxOZJL0EiVGEPGhduXeOkAvPEwRT3 L32IHKIPzNPQuVfjgJ51+ryq9CrZmKvYl5dj8wgEzCRgbYvRCptd2Sw0PoIQ9RbckGGq BvJw== X-Gm-Message-State: ABy/qLZS1CetxGRe4b4gShr8rvAyKk0AsrXiXQ7vHpiDp1FMtc72E75G ULxf3knC+Z5eoVn/okGLmaQ= X-Google-Smtp-Source: APBJJlFj3FWI2f83wCFSfx20cQToMSQfK77tg5WSRKxqR64WlE46swV6tDTyvqOj7Fu01gkMWRLe+A== X-Received: by 2002:adf:ef05:0:b0:317:6cca:a68a with SMTP id e5-20020adfef05000000b003176ccaa68amr1949427wro.41.1690471610225; Thu, 27 Jul 2023 08:26:50 -0700 (PDT) Received: from [127.0.1.1] ([91.230.2.244]) by smtp.gmail.com with ESMTPSA id b17-20020adfde11000000b003143765e207sm2350622wrm.49.2023.07.27.08.26.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jul 2023 08:26:49 -0700 (PDT) From: Benjamin Bara Date: Thu, 27 Jul 2023 17:26:40 +0200 Subject: [PATCH 5/6] kernel/reboot: remove generic restart mode MIME-Version: 1.0 Message-Id: <20230727-pca9450-reboot-v1-5-c8edb27bf404@skidata.com> References: <20230727-pca9450-reboot-v1-0-c8edb27bf404@skidata.com> In-Reply-To: <20230727-pca9450-reboot-v1-0-c8edb27bf404@skidata.com> To: Lee Jones , Thierry Reding , Jonathan Hunter , Tony Lindgren , Liam Girdwood , Mark Brown , Dmitry Osipenko , Robin Gong , Jerome Neanne Cc: linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org, linux-omap@vger.kernel.org, Benjamin Bara X-Mailer: b4 0.12.3 Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org From: Benjamin Bara Remove the "unspecified" restart mode, as it is not in use anymore. New handler registrations should use the specified "cold" or "warm" instead. Signed-off-by: Benjamin Bara --- include/linux/reboot.h | 11 ----------- kernel/reboot.c | 26 -------------------------- 2 files changed, 37 deletions(-) diff --git a/include/linux/reboot.h b/include/linux/reboot.h index 05199aedb696..ad1a7b4026c0 100644 --- a/include/linux/reboot.h +++ b/include/linux/reboot.h @@ -113,13 +113,6 @@ enum sys_off_mode { */ SYS_OFF_MODE_RESTART_PREPARE, - /** - * @SYS_OFF_MODE_RESTART: - * - * Handlers restart system. Handlers are disallowed to sleep. - */ - SYS_OFF_MODE_RESTART, - /** * @SYS_OFF_MODE_RESTART_COLD: * @@ -167,10 +160,6 @@ int devm_register_power_off_handler(struct device *dev, int (*callback)(struct sys_off_data *data), void *cb_data); -int devm_register_restart_handler(struct device *dev, - int (*callback)(struct sys_off_data *data), - void *cb_data); - int devm_register_cold_restart_handler(struct device *dev, int (*callback)(struct sys_off_data *data), void *cb_data); diff --git a/kernel/reboot.c b/kernel/reboot.c index d0d3faf70a79..072489e48636 100644 --- a/kernel/reboot.c +++ b/kernel/reboot.c @@ -441,10 +441,6 @@ register_sys_off_handler(enum sys_off_mode mode, handler->blocking = true; break; - case SYS_OFF_MODE_RESTART: - handler->list = &warm_restart_handler_list; - break; - case SYS_OFF_MODE_RESTART_COLD: handler->list = &cold_restart_handler_list; break; @@ -574,28 +570,6 @@ int devm_register_power_off_handler(struct device *dev, } EXPORT_SYMBOL_GPL(devm_register_power_off_handler); -/** - * devm_register_restart_handler - Register restart handler - * @dev: Device that registers callback - * @callback: Callback function - * @cb_data: Callback's argument - * - * Registers resource-managed sys-off handler with a default priority - * and using restart mode. - * - * Returns zero on success, or error code on failure. - */ -int devm_register_restart_handler(struct device *dev, - int (*callback)(struct sys_off_data *data), - void *cb_data) -{ - return devm_register_sys_off_handler(dev, - SYS_OFF_MODE_RESTART, - SYS_OFF_PRIO_DEFAULT, - callback, cb_data); -} -EXPORT_SYMBOL_GPL(devm_register_restart_handler); - /** * devm_register_cold_restart_handler - Register cold restart handler * @dev: Device that registers callback From patchwork Thu Jul 27 15:26:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Bara X-Patchwork-Id: 707411 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB368C05052 for ; Thu, 27 Jul 2023 15:27:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232982AbjG0P07 (ORCPT ); Thu, 27 Jul 2023 11:26:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234614AbjG0P0y (ORCPT ); Thu, 27 Jul 2023 11:26:54 -0400 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A46422D54; Thu, 27 Jul 2023 08:26:52 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-3174aac120aso1135803f8f.2; Thu, 27 Jul 2023 08:26:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690471611; x=1691076411; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=qaf1CkazPa/KyrRWgauOWJb0xhcTY+lZFF1+FP/RQeg=; b=pES+br6PSABHemdK2hVq8M/cGE/LbSDF9CzsX6b/tw22P+HPQN5JDqFlEAJg1/Ko21 4l3xTwhx1RpvV0FDlZF2XvaFtlAYeMU7nRTIr/+L1BYYBFaVDqgix7aWOakaSmIpBs57 V8RX4xQ54mO2syAYOHY0JSsNAx39PgCv1UPklwkPMSEzB0DDdFIexEG++xX2uCkj79my KfjXxnfz5eSzNS48bUfU44hZGlvueZcipQKU/96SBWpTeznggJISFzzo9NtkcX+Zrulv 9+q0yiO2GxW7MewOB14kqMvPIhW1/tnJ8mPS2ejOW+jDJ/WVVIUopKdkeZl8vo5bUc9m bidw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690471611; x=1691076411; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qaf1CkazPa/KyrRWgauOWJb0xhcTY+lZFF1+FP/RQeg=; b=VImuB800c2+5fGnNsdkd0+VxHEGFkZKOmckXTq90lJXTniMxGJTO/XPH0mu46nL8xL 5HmKvS4MEtfnw6fsJ2quGTPVz3bja6NBzuqYLXLmW65m/WcPKe8MvrTiRmRE6HNKK8ZT doZHT9WL9UlArd8hirzgyVUC1ogc+83sM+fJ6VZLeayT9Qvukbrw/NRuhe0n0uUjryhP FktkVdqaMQ7MRUlk2bYpNZimD06/jbgguGMeAUX5FeIs4VvWtzG0g/J8FwBPPSd1bLuq 9d14sk3dTb2E+dVSZWD7kKesDfUr+P/uQsskrwb1pi4YD1fU+65BomNYZuUY7NLKSczE IwSA== X-Gm-Message-State: ABy/qLbIfasaZpN9uMHgDIaQBB/Izseu5/qm3PZAtLd3PUkRulIBYP3h J4o7s3ghwsqrgWVBBlASyyw= X-Google-Smtp-Source: APBJJlHpj9mV3MVcTKuPvVTXJhI7/bT5b21nBa++UYoWXRN6A54XNn2ORsf8QM6bqXVp2qwKa/oldw== X-Received: by 2002:adf:f091:0:b0:317:650e:9030 with SMTP id n17-20020adff091000000b00317650e9030mr1982626wro.57.1690471610905; Thu, 27 Jul 2023 08:26:50 -0700 (PDT) Received: from [127.0.1.1] ([91.230.2.244]) by smtp.gmail.com with ESMTPSA id b17-20020adfde11000000b003143765e207sm2350622wrm.49.2023.07.27.08.26.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jul 2023 08:26:50 -0700 (PDT) From: Benjamin Bara Date: Thu, 27 Jul 2023 17:26:41 +0200 Subject: [PATCH 6/6] regulator: pca9450: register restart handlers MIME-Version: 1.0 Message-Id: <20230727-pca9450-reboot-v1-6-c8edb27bf404@skidata.com> References: <20230727-pca9450-reboot-v1-0-c8edb27bf404@skidata.com> In-Reply-To: <20230727-pca9450-reboot-v1-0-c8edb27bf404@skidata.com> To: Lee Jones , Thierry Reding , Jonathan Hunter , Tony Lindgren , Liam Girdwood , Mark Brown , Dmitry Osipenko , Robin Gong , Jerome Neanne Cc: linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org, linux-omap@vger.kernel.org, Benjamin Bara X-Mailer: b4 0.12.3 Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org From: Benjamin Bara The PCA9450 supports both, a warm and a cold reset. Implement both and register the respective handlers. Signed-off-by: Benjamin Bara Acked-by: Mark Brown --- drivers/regulator/pca9450-regulator.c | 59 +++++++++++++++++++++++++++++++++++ include/linux/regulator/pca9450.h | 7 +++++ 2 files changed, 66 insertions(+) diff --git a/drivers/regulator/pca9450-regulator.c b/drivers/regulator/pca9450-regulator.c index 2ab365d2749f..86903d677bf6 100644 --- a/drivers/regulator/pca9450-regulator.c +++ b/drivers/regulator/pca9450-regulator.c @@ -38,6 +38,11 @@ struct pca9450 { int irq; }; +static inline struct pca9450 *dev_to_pca9450(struct device *dev) +{ + return dev_get_drvdata(dev); +} + static const struct regmap_range pca9450_status_range = { .range_min = PCA9450_REG_INT1, .range_max = PCA9450_REG_PWRON_STAT, @@ -219,6 +224,42 @@ static int pca9450_set_dvs_levels(struct device_node *np, return ret; } +static int pca9450_cold_reset(struct pca9450 *pca9450) +{ + int ret; + + ret = regmap_write(pca9450->regmap, PCA9450_REG_SWRST, + SWRST_RESET_COLD_LDO12); + if (ret) + return ret; + + /* t_RESTART is 250 ms. */ + mdelay(500); + return -ETIME; +} + +static int pca9450_warm_reset(struct pca9450 *pca9450) +{ + int ret; + + ret = regmap_write(pca9450->regmap, PCA9450_REG_SWRST, + SWRST_RESET_WARM); + if (ret) + return ret; + + /* t_RESET is 20 ms. */ + mdelay(50); + return -ETIME; +} + +static int pca9450_restart_handler(struct sys_off_data *data) +{ + int (*handler)(struct pca9450 *) = data->cb_data; + struct pca9450 *pca9450 = dev_to_pca9450(data->dev); + + return handler(pca9450); +} + static const struct pca9450_regulator_desc pca9450a_regulators[] = { { .desc = { @@ -845,6 +886,24 @@ static int pca9450_i2c_probe(struct i2c_client *i2c) return PTR_ERR(pca9450->sd_vsel_gpio); } + ret = devm_register_cold_restart_handler(pca9450->dev, + pca9450_restart_handler, + pca9450_cold_reset); + if (ret) { + dev_err(&i2c->dev, "register cold restart handler failed: %d\n", + ret); + return ret; + } + + ret = devm_register_warm_restart_handler(pca9450->dev, + pca9450_restart_handler, + pca9450_warm_reset); + if (ret) { + dev_err(&i2c->dev, "register warm restart handler failed: %d\n", + ret); + return ret; + } + dev_info(&i2c->dev, "%s probed.\n", type == PCA9450_TYPE_PCA9450A ? "pca9450a" : "pca9450bc"); diff --git a/include/linux/regulator/pca9450.h b/include/linux/regulator/pca9450.h index 505c908dbb81..a72fd4942d5f 100644 --- a/include/linux/regulator/pca9450.h +++ b/include/linux/regulator/pca9450.h @@ -93,6 +93,13 @@ enum { PCA9450_MAX_REGISTER = 0x2F, }; +/* PCA9450 SW_RST bits */ +#define SWRST_NOACTION 0x00 +#define SWRST_RESET_REGS 0x05 +#define SWRST_RESET_COLD_LDO12 0x14 +#define SWRST_RESET_WARM 0x35 +#define SWRST_RESET_COLD 0x64 + /* PCA9450 BUCK ENMODE bits */ #define BUCK_ENMODE_OFF 0x00 #define BUCK_ENMODE_ONREQ 0x01