Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp3434083rdh; Mon, 27 Nov 2023 14:22:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IHteCJrcZFu0ZT4eF33leyDltKqUOXAsnSAVBG9svcAy8dGH2IXtnPMqCjgHJgIcJ006R9b X-Received: by 2002:a05:6a00:1c92:b0:6cb:bbb3:a598 with SMTP id y18-20020a056a001c9200b006cbbbb3a598mr16213904pfw.4.1701123769403; Mon, 27 Nov 2023 14:22:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701123769; cv=none; d=google.com; s=arc-20160816; b=o6LLqAmXC/WbuKxj3NHc8B9WeS9aNdR0hgYTn1GTz7ZhNqOyjYK1yucvQoyQ4Qe8yk jK6ThJ06fBo8Kyr7QkI7cXsPL81km9ByQ3NJ36nZZq37mBF3mYGPC3YYHLRfcp2Rm3Vu 54W7o37DMvtTRJZYbzegrfVBoB3oq+RQ7ICO6yGNbXOFPQDBGLp4dmBGT3R95rKlWPmT VFycH8aHgA0DIKM9UNYkGIHHoXLwctptjc1hGVkKy+nGxJq9OGKPPTpze6zk5p3ieqvo RKYWFsF/XsxPxImVzs+gkEdoeaAtK2Gn4xOn5VlBeZPH5b+efh3qTCwGb/Df/hoYjuCl Y/rA== 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:to:from; bh=D4A0tC1iUu6aGA2hB2ve2lQldaElqwWpU6PqjR0KL84=; fh=ompBcuc9WZSkOT6I8Jb+H375/5cBcTGkrIOABj6b1VU=; b=zweCCw90DGuJzRRDgM3yJvw1i+CalzItOz4P0na+keltcbLaMnVZ3lv8fX96W5twtj 5Fa4jbbtazH7mOXFrJggjfZg2yC2MUlP4Xxm5BLWZgBeQy5A7t5XXHh6yUvuH8bA+38R dQJzq8fy1THbluaYdxBMlD/akD8tOMjVL6VWoOQlc+gzB7bvto2ApHJ/AHmqqtT0AtlI 96RI+8dTjOblY0L0MkweTIOQlj3UYqBE2rdE4Y7Bk4Ot6m1iFv/S8eCsM5BLz3eFPSDO OJfpLx6APyhxWAoNE+2E7J7QjftijH/4rsmz2+fPP5zksOTRIIcg+O/Etnlnjttg7EsE MrQA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id p67-20020a625b46000000b00690204af234si10237086pfb.378.2023.11.27.14.22.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 14:22:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 1A8668051BBF; Mon, 27 Nov 2023 14:22:46 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234360AbjK0WWc (ORCPT + 99 others); Mon, 27 Nov 2023 17:22:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233800AbjK0WWI (ORCPT ); Mon, 27 Nov 2023 17:22:08 -0500 Received: from mail.andi.de1.cc (mail.andi.de1.cc [IPv6:2a02:c205:3004:2154::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07F834C25; Mon, 27 Nov 2023 14:19:22 -0800 (PST) Received: from p200301077700a9001a3da2fffebfd33a.dip0.t-ipconnect.de ([2003:107:7700:a900:1a3d:a2ff:febf:d33a] helo=aktux) by mail.andi.de1.cc with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r7jwg-006my1-Ra; Mon, 27 Nov 2023 23:19:14 +0100 Received: from andi by aktux with local (Exim 4.96) (envelope-from ) id 1r7jwg-000kAX-1y; Mon, 27 Nov 2023 23:19:14 +0100 From: Andreas Kemnade To: lee@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, bcousson@baylibre.com, tony@atomide.com, andreas@kemnade.info, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org Subject: [PATCH v2 2/6] twl-core: add power off implementation for twl603x Date: Mon, 27 Nov 2023 23:19:03 +0100 Message-Id: <20231127221907.177442-3-andreas@kemnade.info> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231127221907.177442-1-andreas@kemnade.info> References: <20231127221907.177442-1-andreas@kemnade.info> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 27 Nov 2023 14:22:47 -0800 (PST) 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) + + int err; + u8 val; + + err = twl_i2c_read_u8(TWL_MODULE_PM_MASTER, &val, + TWL6030_PHOENIX_DEV_ON); + if (err) { + pr_err("I2C error %d reading PHOENIX_DEV_ON\n", err); + 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)) { + 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