From patchwork Fri Jun 2 06:24:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Nyekjaer X-Patchwork-Id: 102313 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp828172vqr; Thu, 1 Jun 2023 23:27:06 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6U03o/NiaaGDoahJ1GZ5cbaLjDOkBcq5AuMzGIIciQ3Y5yFZBf8UJvtDVUcs9Lxu816GGe X-Received: by 2002:a05:6a00:99e:b0:64d:1585:fff2 with SMTP id u30-20020a056a00099e00b0064d1585fff2mr13729687pfg.29.1685687226370; Thu, 01 Jun 2023 23:27:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685687226; cv=none; d=google.com; s=arc-20160816; b=yLnKUJM4uNKSv/bQvNVrmWOhOlNHpWunVPKLkuA3rHBPLRdg7gRXdBzMQTZvNB2Vaf oW1Qv1u+SXsKsmuW+9j/xIarBlfBmeidRI1lHRn6SjvrbN6MlNdAviA+mVtfQiuEei7Y LR2OcXH2jdCBASCkJ9YikLm2O9B0fIRhsc43tX8nJmRNO/sKROYKkoldsZjigAkhnZhO 22VjK1eDDYt1Hh7CMGKv/5/R4tCzDYwrkS7x4eq+Z4y4Ewq1TeE5RnERFjzuT+GkDms/ nmEmL6MNihzl4KcFjp/BoNjV8fq1xNunQCFE3DDmwaRA1ACVbvwLMBPNesI6iNTqrHPK dEbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6nGHV3Tzd+ueExjxQGldi1rcP9sIpx+z7TiCsn2/rGU=; b=C6PVn/lcEOliSaj5T1Gl1S9gTz8sgsclY9DExvDs3026hS24dV/IwvqbIMSl15UnzJ pT3X9qv1N73BUG/jj7Nt2U0wPINQee70V0zQrm0JVM6GECQnaEL28nnsgu9atHS4QUUC hVtTztkJfLJ1piq17pP5jvNh8Mg8zB8L5GUpl//3chUPzMXKRN21wrjScib9cEYbS7Rd l3GBvvPReajPKZmMcAHb2RfPZDHCgUD9/euue1VDGEvUS/raifgehLM8jC5JazT++rjf etSaoKWl1otN798xHNA+eXJsHYgWUkyq8HQl03s0RhyTkLiOP05FdzQgoX+kbrxkI7jV o0SQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@geanix.com header.s=default2211 header.b=d4QLPBiQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=geanix.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j15-20020a63b60f000000b0053ef469281bsi458901pgf.474.2023.06.01.23.26.54; Thu, 01 Jun 2023 23:27:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@geanix.com header.s=default2211 header.b=d4QLPBiQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=geanix.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233445AbjFBGZJ (ORCPT + 99 others); Fri, 2 Jun 2023 02:25:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233016AbjFBGZI (ORCPT ); Fri, 2 Jun 2023 02:25:08 -0400 Received: from www530.your-server.de (www530.your-server.de [188.40.30.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69E88EB for ; Thu, 1 Jun 2023 23:25:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=geanix.com; s=default2211; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID; bh=6nGHV3Tzd+ueExjxQGldi1rcP9sIpx+z7TiCsn2/rGU=; b=d4QLPBiQIVud1K/5SgqaiQUF2Q 18Re8MstSV22J2FAaZrY+k+k2ArGgVz+BQS65FEHVpTCmS0WCHrYbGC+EgtYAkJQqe2zisp8QzkxR s205XdbCugs+LNgayuocbd75VlgFnW7gpLMAEdZzUuV8k6yGG89qTDJRdputSO7Oaz+WARiSlkdp0 4ny91JSwtuE0+vpZbHq1txJZfELwo8uP4II+LgMPJHBJy4lYG/IafhJxxC/jvF6yYF6TvgPHAU1jL ZCFAJ4MHbRAWTlb641zpCU5EY5vdhlfvbKNx1/8VKuWz2b/VEEWa6IaajoK2zpS2BjQpe3Yaxtsc3 rUEEScyQ==; Received: from sslproxy02.your-server.de ([78.47.166.47]) by www530.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1q4yDg-000Etu-JH; Fri, 02 Jun 2023 08:25:04 +0200 Received: from [185.17.218.86] (helo=zen..) by sslproxy02.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q4yDg-000Nkl-BR; Fri, 02 Jun 2023 08:25:04 +0200 From: Sean Nyekjaer To: krzysztof.kozlowski@linaro.org, conor@kernel.org, lee@kernel.org, linux-kernel@vger.kernel.org Cc: Sean Nyekjaer Subject: [PATCH v3 2/2] mfd: stpmic1: add pmic poweroff via sys-off handler Date: Fri, 2 Jun 2023 08:24:26 +0200 Message-Id: <20230602062426.3947116-2-sean@geanix.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230602062426.3947116-1-sean@geanix.com> References: <20230602062426.3947116-1-sean@geanix.com> MIME-Version: 1.0 X-Authenticated-Sender: sean@geanix.com X-Virus-Scanned: Clear (ClamAV 0.103.8/26925/Thu Jun 1 09:27:46 2023) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767571168700662909?= X-GMAIL-MSGID: =?utf-8?q?1767571168700662909?= Use devm_register_sys_off_handler() that allows to register multiple power-off handlers. This will allow boards using the stpmic1 to power-off. Signed-off-by: Sean Nyekjaer --- Changes since v1: - Removed superfluous function Changes since v2: - Removed the devicetree option to turn the power-off functionality on and off. drivers/mfd/stpmic1.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/mfd/stpmic1.c b/drivers/mfd/stpmic1.c index 4c9b18d9dec8..9c7d1c3b8dfd 100644 --- a/drivers/mfd/stpmic1.c +++ b/drivers/mfd/stpmic1.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -117,6 +118,16 @@ static const struct regmap_irq_chip stpmic1_regmap_irq_chip = { .num_irqs = ARRAY_SIZE(stpmic1_irqs), }; +static int stpmic1_power_off(struct sys_off_data *data) +{ + struct stpmic1 *ddata = data->cb_data; + + regmap_update_bits(ddata->regmap, MAIN_CR, + SOFTWARE_SWITCH_OFF, SOFTWARE_SWITCH_OFF); + + return NOTIFY_DONE; +} + static int stpmic1_probe(struct i2c_client *i2c) { struct stpmic1 *ddata; @@ -159,6 +170,16 @@ static int stpmic1_probe(struct i2c_client *i2c) return ret; } + ret = devm_register_sys_off_handler(ddata->dev, + SYS_OFF_MODE_POWER_OFF, + SYS_OFF_PRIO_DEFAULT, + stpmic1_power_off, + ddata); + if (ret) { + dev_err(ddata->dev, "failed to register sys-off handler: %d\n", ret); + return ret; + } + return devm_of_platform_populate(dev); }