Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp709203rwd; Tue, 16 May 2023 06:54:24 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6DeGDuYQvv5YL98gKviRJYHtplIVOZVabyZXX+i+RzooRKLmRbNgso2DC6qc6n7L3DIlKH X-Received: by 2002:a05:6a21:78a7:b0:101:2f83:5fba with SMTP id bf39-20020a056a2178a700b001012f835fbamr17908473pzc.31.1684245264489; Tue, 16 May 2023 06:54:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684245264; cv=none; d=google.com; s=arc-20160816; b=RFeBvotTTO8I2PjED3m/mDkn5h+yNprgv449/T56MxFuYrYSiaj3MQkgTmRlKJrbaF 5eXZjHMHjM1ZZ9j1WGPg58nJm1Pxc24bubCjvVsdTBqvYX6fJ+ne5osjexQL6b7Nddh0 D5vCgybUODsYtO1Rg3rwViIM2D4pNElsF7pll1AIIBo6PJd2/VIBNcB1hxYfYaCTeEV5 cp4N0TUsXlvaPdVYY3M0ssbhRk2iOWlu52RD9avGIhnH5RcJrtfipgqcIrFE9szfwsg0 h6PTQCk51vTxWPkBRWzBkhEPq316wUzlN7J7uQERoz1k8o4XvYiJrLlGcrDrumkm/xCS SizA== 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=4OVpla0e3KhLB8EpKpRBFad9oNXZVOLCvEDNQKceCdM=; b=TkXQHzUnt0IV3H4oPwv0MePNzD1kbZI7iV0DfgwW8OUbXMvXksS/igV2awDF2QTbBc z26nxBQTM+deTy9OS5cPUgz/4uXBV2aKQwcJv3f1MKumYAg1wyPJ3IOeZV7mV3ka0Qlt WcO0x5IPFiXJ3jqfbcLxwxTxzfYP5e64Tk577GklgFDXb3qx2BNZrF+ZgjFp0rFbnRfg FoIuKJza5VGrDtlp3qaehTzzsaAR3XLfGslOBv+HGYRNbod2lX4yYDxBlROYjJ+MxgKc X2XpQASWF+jn6bgNsCflwRMuP5s7DWc4Q0YisGd3sbbdLF3EenVzzlNQGnFK6+cba5Sb iLmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@geanix.com header.s=default2211 header.b=A2eVFsVZ; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w129-20020a626287000000b00643fdad4119si19225103pfb.146.2023.05.16.06.54.02; Tue, 16 May 2023 06:54:24 -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=A2eVFsVZ; 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 S233453AbjEPNiE (ORCPT + 99 others); Tue, 16 May 2023 09:38:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232657AbjEPNiD (ORCPT ); Tue, 16 May 2023 09:38:03 -0400 X-Greylist: delayed 912 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Tue, 16 May 2023 06:38:00 PDT Received: from www530.your-server.de (www530.your-server.de [188.40.30.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0408CA; Tue, 16 May 2023 06:38:00 -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=4OVpla0e3KhLB8EpKpRBFad9oNXZVOLCvEDNQKceCdM=; b=A2eVFsVZ6ivdKi28ZHruVlSUvr Clze0kziSRRWxUPjXgwdYnsXE5o1eqBSuVISLnamRXVKO4z3sA94HdgVWzWI0sR3Fex31thzrq8dh YoCLPCZEOwkjmv+QWeo1zm1cjiYs1OYMLxeJxoGKasUKq2vK6SZVFiwP0Kx0WjetLmywLvL+stiHN OWWoVKXqxXhDFnF/31wvqstuAV6DNPOGpcq9U53a8cuLXk4fIr7M2SGht95/dTpSLcfn+rGwCjK4S brApjDiqxYtcusrs/abErYAQ4wLHx4Dts3dXW4z8nbyvDJylRoALO4EKiti8DN59ZQ5Zox2WCFhgx z+5kMeLw==; Received: from sslproxy03.your-server.de ([88.198.220.132]) by www530.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1pyuda-000AJ6-EB; Tue, 16 May 2023 15:22:46 +0200 Received: from [185.17.218.86] (helo=zen..) by sslproxy03.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pyuda-000NS5-5w; Tue, 16 May 2023 15:22:46 +0200 From: Sean Nyekjaer To: robh+dt@kernel.org, Lee Jones Cc: devicetree@vger.kernel.org, Sean Nyekjaer , linux-kernel@vger.kernel.org Subject: [PATCH v2 2/3] mfd: stpmic1: add pmic poweroff via sys-off handler Date: Tue, 16 May 2023 15:22:23 +0200 Message-Id: <20230516132225.3012541-2-sean@geanix.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230516132225.3012541-1-sean@geanix.com> References: <20230516132225.3012541-1-sean@geanix.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Authenticated-Sender: sean@geanix.com X-Virus-Scanned: Clear (ClamAV 0.103.8/26908/Tue May 16 09:24:20 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 Use devm_register_sys_off_handler() that allows to register multiple power-off handlers. This can be enabled by adding "st,pmic-poweroff" to device-tree. Signed-off-by: Sean Nyekjaer --- Changes since v1: - Removed superfluous function drivers/mfd/stpmic1.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/mfd/stpmic1.c b/drivers/mfd/stpmic1.c index 4c9b18d9dec8..5b82cd37d57a 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,18 @@ static int stpmic1_probe(struct i2c_client *i2c) return ret; } + if (of_property_read_bool(i2c->dev.of_node, "st,pmic-poweroff")) { + 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); } -- 2.40.0