From patchwork Fri Jun 2 06:24:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Nyekjaer X-Patchwork-Id: 102327 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp833045vqr; Thu, 1 Jun 2023 23:41:44 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ43k0VLlNUj4DlEElVl/qrEsHdrBQ3yVTogLggSK9zIo9mVeVzxr+glRJgTB61VzsOZHVdw X-Received: by 2002:a05:622a:1ca:b0:3ef:6577:7f90 with SMTP id t10-20020a05622a01ca00b003ef65777f90mr15355152qtw.26.1685688104171; Thu, 01 Jun 2023 23:41:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685688104; cv=none; d=google.com; s=arc-20160816; b=mSfx+cd8R3zJPvjci/qbPJdEvh8OAKupkP8LvMjyob/TbKXm8Lrd0kiyphbvn2RrRB UgFnSA0EYyqhFZdnP8dr81tGezFreHqhl6/3h3C+cRaF3cQXlZkHNvWrzsnYUtf+UdQG 1zcExMceMV6ILnksjDpNGiflFaadu7T+USX/70deHHXSRPX9PSqi5ZbsS9Dpoes1Hpy7 9J/2pBVN9Br7CvXSWjEG16UuqSVGBpoYcx3jupNW+mFDFxCCEZNbO7hyHXAmJPvRWM6c FZ7HB59fqxjKX6FYHHrSb+AG+dAdzMouQa3qa62Uu1OTWsE61GpuG1ZV5o9xrnqdTEoA raSg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=/Wt3FAz+QMdyWFgCq6hzT7xcxzyac+Un/+XRumxejUc=; b=nUJrhYnL7WUPXsLN0Cy5nnSnu7A/UIwHig95zR9MIWGfg9KJAKxlniRg3DrvdUFJC5 bv23I1whlAsHFMo/RTTXvvCOL5IO+jXTNMW4wks//FkKUZEnFkU8Bt/E0FOYlw2sIqJx +qppxbqm+Q3U04c7JlK5JEQGkFAkCUBcJQu8CuyxT80+h4mv7WYxNVmZDvAYumexEjGe XdxHpmxKUoMe/hHXAJTxzobfcF+opx0Rbkr1muO7F0k3L1R8RoZbb7Qrq9T4wQVlMMXJ KU1C6r6ghTjwCbiYdoUdSRJdsYVHSskYeiuL2F7a//XL18Agwc8kYdTMnMkNOGNYFvz4 xxBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@geanix.com header.s=default2211 header.b=sfkVhOfz; 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 h11-20020a65480b000000b0051b1241624esi529949pgs.65.2023.06.01.23.41.29; Thu, 01 Jun 2023 23:41:44 -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=sfkVhOfz; 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 S233609AbjFBGZK (ORCPT + 99 others); Fri, 2 Jun 2023 02:25:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232000AbjFBGZI (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 5794FE7 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: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:In-Reply-To:References; bh=/Wt3FAz+QMdyWFgCq6hzT7xcxzyac+Un/+XRumxejUc=; b=sfkVhOfzP62qGMqGIMeruVTmIv poJapgW4vvSwGjLaobeJ6o3LPC9nf9BWZmEyLLGcendfpGIQ1gmjVklwUPEAQeOkvAdU2f6ruVPfe 5FpEhwA+qJmkzSlLDE5HakUAtME5RG6QIXttWo39EEFund7GMBldSDbuisaQm71nhgZSZkpaBAWXe YNisiTPwjlzOq0uSpAESP4D3it/I8N9l+Hwudpgb8ZMV3O5mpYEclv2ofLVmeYTOca1qmcvnL2S9L 18RzwU/w+7QmcgmP6sS0tOQFkbcglHbOqjf7KtaCk0FiZslU//RbK8zCE1r93tRyT6fz57CDoe59j xNR0b5lw==; 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-000Ett-EG; 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-6b; 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 1/2] mfd: stpmic1: fixup main control register and bits naming Date: Fri, 2 Jun 2023 08:24:25 +0200 Message-Id: <20230602062426.3947116-1-sean@geanix.com> X-Mailer: git-send-email 2.40.0 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?1767572089381667926?= X-GMAIL-MSGID: =?utf-8?q?1767572089381667926?= Fixup main control register and bits naming so the match the naming from the datasheet. https://www.st.com/resource/en/datasheet/stpmic1.pdf Signed-off-by: Sean Nyekjaer Reviewed-by: Lee Jones --- Changes since v1: - None Changes since v2: - None drivers/mfd/stpmic1.c | 4 ++-- include/linux/mfd/stpmic1.h | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/mfd/stpmic1.c b/drivers/mfd/stpmic1.c index 8db1530d9bac..4c9b18d9dec8 100644 --- a/drivers/mfd/stpmic1.c +++ b/drivers/mfd/stpmic1.c @@ -19,7 +19,7 @@ static const struct regmap_range stpmic1_readable_ranges[] = { regmap_reg_range(TURN_ON_SR, VERSION_SR), - regmap_reg_range(SWOFF_PWRCTRL_CR, LDO6_STDBY_CR), + regmap_reg_range(MAIN_CR, LDO6_STDBY_CR), regmap_reg_range(BST_SW_CR, BST_SW_CR), regmap_reg_range(INT_PENDING_R1, INT_PENDING_R4), regmap_reg_range(INT_CLEAR_R1, INT_CLEAR_R4), @@ -30,7 +30,7 @@ static const struct regmap_range stpmic1_readable_ranges[] = { }; static const struct regmap_range stpmic1_writeable_ranges[] = { - regmap_reg_range(SWOFF_PWRCTRL_CR, LDO6_STDBY_CR), + regmap_reg_range(MAIN_CR, LDO6_STDBY_CR), regmap_reg_range(BST_SW_CR, BST_SW_CR), regmap_reg_range(INT_CLEAR_R1, INT_CLEAR_R4), regmap_reg_range(INT_SET_MASK_R1, INT_SET_MASK_R4), diff --git a/include/linux/mfd/stpmic1.h b/include/linux/mfd/stpmic1.h index fa3f99f7e9a1..dc00bac24f5a 100644 --- a/include/linux/mfd/stpmic1.h +++ b/include/linux/mfd/stpmic1.h @@ -15,7 +15,7 @@ #define RREQ_STATE_SR 0x5 #define VERSION_SR 0x6 -#define SWOFF_PWRCTRL_CR 0x10 +#define MAIN_CR 0x10 #define PADS_PULL_CR 0x11 #define BUCKS_PD_CR 0x12 #define LDO14_PD_CR 0x13 @@ -148,14 +148,14 @@ #define LDO_BYPASS_MASK BIT(7) /* Main PMIC Control Register - * SWOFF_PWRCTRL_CR + * MAIN_CR * Address : 0x10 */ -#define ICC_EVENT_ENABLED BIT(4) +#define OCP_OFF_DBG BIT(4) #define PWRCTRL_POLARITY_HIGH BIT(3) -#define PWRCTRL_PIN_VALID BIT(2) -#define RESTART_REQUEST_ENABLED BIT(1) -#define SOFTWARE_SWITCH_OFF_ENABLED BIT(0) +#define PWRCTRL_ENABLE BIT(2) +#define RESTART_REQUEST_ENABLE BIT(1) +#define SOFTWARE_SWITCH_OFF BIT(0) /* Main PMIC PADS Control Register * PADS_PULL_CR 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); }