Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp939735rdb; Fri, 1 Dec 2023 02:48:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IE6FmFPEKO3BM+0Dh+1u4ElhA5JcsJkDCKVWMtDlN6/nWhgg7FAcJOgY/Vi99Wwa0P65LE2 X-Received: by 2002:a17:90b:3ec3:b0:285:949c:5e95 with SMTP id rm3-20020a17090b3ec300b00285949c5e95mr24589541pjb.18.1701427728678; Fri, 01 Dec 2023 02:48:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701427728; cv=none; d=google.com; s=arc-20160816; b=dLz3RNouSctqeXE9w0V5HXBMxSuBzhPfWuAqvS9FXJQVHqO0SCM0Is9owJN+RnH2+3 Gi42sETA/kiRgD9R2VflTF6iekgZspx8754rXCT4hG2NecvmwZMkrbgWuRoawSkTUpHn kYR1ME4k/RXm4O8iAn1eHCq+oxLAZSBLDUuMlY5cAUEm4VzCybWv5bJmr/MoAl993+fz gnXiHchkFT4QLYNekXg8RLLLfYY9rn4BaCYuHwsFVMSj87u6GfbuDHMCCy3TPavY35a0 qo1xlZmnW9YbmfZlM67YefH02x6xuZzWPbFvORqR1NO+W34xpoav0Wub7S0pDuf3RNH5 NjdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=JfOY5xhgLy6NdRwnuyHpwr2Ni+6CMaMR2i2vqyUC4mE=; fh=L0O6eQBSkhYHSHh9NxoYRmJHCbVZzu1+iu4y+dZosWM=; b=vTplSAxCW2+tvE5UGlqBdvOu/N4NeBRgHE4vwYfBdvZG0PYcKH6EZc6yXo7O1C6C2O bq2Erznv5sr75yJLZvD4ZmfSTXToH2bBs+7c/YSD6AiaDQdItzghw3A6LzUIMz9v8xGP iRsig1BLcphp0HN/v3s2IkXfPhoAArBgErOMs6EqYJrsd9GbJqqlbN6p+BzCVnwN9p0/ xk1M+ig7s/EM4pxm6BgnnPdiqD6AYUFI/mhIBoPqR66KGMsYuRROWZxvOxCmZepvyB63 82GL/9jTRM7gFj0IHT3sz2vydopNWsFrqDAS65AYubv08rIODq2BBFGM6HrkKaAOYWR/ FIXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Vag/pdaI"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id g7-20020a17090a300700b002803c4a0684si3112178pjb.189.2023.12.01.02.48.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 02:48:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Vag/pdaI"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 4439F852134C; Fri, 1 Dec 2023 02:48:40 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378399AbjLAKsV (ORCPT + 99 others); Fri, 1 Dec 2023 05:48:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378395AbjLAKsU (ORCPT ); Fri, 1 Dec 2023 05:48:20 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6B8CD40 for ; Fri, 1 Dec 2023 02:48:26 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1E38BC433C9; Fri, 1 Dec 2023 10:48:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701427706; bh=bYTnVPbpbtB9dCl6tLzUGkhooFvdgeD9g8sXerKrUws=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Vag/pdaIry/wEOswBHKkPevJLTu5viOPQ+B8P35F9eUC/wIdR4uMvH3mo4N4rwTqE FBMwaDrS6mPTp7O6oJp9hvSjhf26wlvskqxQ3IqGs8c9APx8+YMxjphhjTei/mPOHo aS3usPHg4YrBT2T6ahOnzL1RcMdh79yQT8Lxi3Bl2OeMACyCdmkLDPlmjSnY9Ms8Pm KsudgtU0FmabCtQX1UTogPJP0PoRNkjnMFnsIco6wPio+KOSnS4gjxYHahzobnaMie QwswwPu4W8hsVj6j2O686b5H63A2ac63OgJbCOr+zrFEHEP1N/2K0IZjaOniUCiFQT yq/+zVHP+p/4Q== Date: Fri, 1 Dec 2023 10:48:20 +0000 From: Lee Jones To: Andreas Kemnade Cc: robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, bcousson@baylibre.com, tony@atomide.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org Subject: Re: [PATCH v2 2/6] twl-core: add power off implementation for twl603x Message-ID: <20231201104820.GC3259151@google.com> References: <20231127221907.177442-1-andreas@kemnade.info> <20231127221907.177442-3-andreas@kemnade.info> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20231127221907.177442-3-andreas@kemnade.info> X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Fri, 01 Dec 2023 02:48:40 -0800 (PST) On Mon, 27 Nov 2023, Andreas Kemnade wrote: > If the system-power-controller property is there, enable power off. > Implementation is based on a Linux v3.0 vendor kernel. > > Signed-off-by: Andreas Kemnade > --- > drivers/mfd/twl-core.c | 34 ++++++++++++++++++++++++++++++++++ > include/linux/mfd/twl.h | 1 + > 2 files changed, 35 insertions(+) > > diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c > index 6e384a79e3418..54482d5d8888b 100644 > --- a/drivers/mfd/twl-core.c > +++ b/drivers/mfd/twl-core.c > @@ -687,6 +687,31 @@ static void twl_remove(struct i2c_client *client) > twl_priv->ready = false; > } > > +static void twl6030_power_off(void) > +{ > +#define APP_DEVOFF (1<<0) > +#define CON_DEVOFF (1<<1) > +#define MOD_DEVOFF (1<<2) Please place these at the top somewhere. You should also have spaces around the '<<'s. These look like they should be BIT()s though. > + > + int err; > + u8 val; > + > + err = twl_i2c_read_u8(TWL_MODULE_PM_MASTER, &val, > + TWL6030_PHOENIX_DEV_ON); You can use 100-chars if you like. > + if (err) { > + pr_err("I2C error %d reading PHOENIX_DEV_ON\n", err); It would save an awful lot of lines and space if we could place these warnings/errors inside twl_i2c_read_u8(). > + return; > + } > + > + val |= APP_DEVOFF | CON_DEVOFF | MOD_DEVOFF; > + > + err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, val, > + TWL6030_PHOENIX_DEV_ON); > + if (err) > + pr_err("TWL6030 Unable to power off\n"); > +} > + > + > static struct of_dev_auxdata twl_auxdata_lookup[] = { > OF_DEV_AUXDATA("ti,twl4030-gpio", 0, "twl4030-gpio", NULL), > { /* sentinel */ }, > @@ -852,6 +877,15 @@ twl_probe(struct i2c_client *client) > goto free; > } > > + if (twl_class_is_6030()) { > + if (of_device_is_system_power_controller(client->dev.of_node)) { Use 'node' instead. > + if (!pm_power_off) > + pm_power_off = twl6030_power_off; > + else > + dev_warn(&client->dev, "Poweroff callback already assigned\n"); > + } > + } > + > status = of_platform_populate(node, NULL, twl_auxdata_lookup, > &client->dev); > > diff --git a/include/linux/mfd/twl.h b/include/linux/mfd/twl.h > index c062d91a67d92..85dc406173dba 100644 > --- a/include/linux/mfd/twl.h > +++ b/include/linux/mfd/twl.h > @@ -461,6 +461,7 @@ static inline int twl6030_mmc_card_detect(struct device *dev, int slot) > > #define TWL4030_PM_MASTER_GLOBAL_TST 0xb6 > > +#define TWL6030_PHOENIX_DEV_ON 0x06 > /*----------------------------------------------------------------------*/ > > /* Power bus message definitions */ > -- > 2.39.2 > -- Lee Jones [李琼斯]