From patchwork Sat Nov 25 09:29:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Kemnade X-Patchwork-Id: 169684 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce62:0:b0:403:3b70:6f57 with SMTP id o2csp1831171vqx; Sat, 25 Nov 2023 01:31:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IGaIByPOW9CCkV3EIXMw6jQY28DKsW74Zl96/4rJMBK2IN61tLSUAWGCk1IG/2wPPha5ONE X-Received: by 2002:a05:6a20:d48e:b0:187:3b1f:219c with SMTP id im14-20020a056a20d48e00b001873b1f219cmr7443990pzb.10.1700904663099; Sat, 25 Nov 2023 01:31:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700904663; cv=none; d=google.com; s=arc-20160816; b=Z6/jiLHRhxaqrIHZc4aEBS00KqZUU0e8uqfxR1FjcGx3BuL3uz6c1k3MHFrlTujC9J /ueo+ESH32SpQa3pMG0prScwFcsIT83uc2Q4UyAFaCrmYXygkEPm53t9eF+RR5jUThIC OWjxopMNTwd/VucfbakU1oXa3qPWuRrYSD1fxo/L3ZMrI1qnvUkV5W5EZOgVSv2TMo9Z osZJJ4MQUnm1ol2IGa555AM4tIQVNEANegZl0/06/yDYngdZgN/UeCSB1Uk6EFc28roI 5GrmL7C1uRu31/pVG/8LsMbo6MOOK2vN0LcQJQ/sqjQRRwxbKYulwH4sYDgmhKeTC6BM uBvw== 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=xCfnueMZ+tq98mP9ktomnq6TJ0JZJw/jqTstjUqK6pk=; fh=ompBcuc9WZSkOT6I8Jb+H375/5cBcTGkrIOABj6b1VU=; b=R7xx54P1ADBmOqp91zVKD4QCO5iE9XsNZ3KPoCuqH1wdXPa3cvn84FAFIj357YPf/b Zc2xT59xuxCPdQQnHim9B7Il5FgyfqEKP2eNMoODXj2NwK7tJhve2KRW471gV14E98Jy A1l1QxNZJNbstKtO/Ay+lE7gmuIa4MF6sQ0HxBAuO5Yn+1MxW4rWIFiVeZ21A4KdE7fv P+ZasK2hTfz1uTILrmbgje3C5SKGKdkAP987dZ6D1fC2q3lqFSjSQqmP8tlbNhgVjYY5 wV6TST9oUD10RF4usPOBVRzR++lqzd5KIYHl/Zu5Ghcv/fuAqkCbHIx2M72NWFYAh1yr LawQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id w13-20020a170902e88d00b001cf5d073fa7si402181plg.119.2023.11.25.01.31.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Nov 2023 01:31:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (Postfix) with ESMTP id 3177F80B1222; Sat, 25 Nov 2023 01:30:28 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231974AbjKYJaB (ORCPT + 99 others); Sat, 25 Nov 2023 04:30:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231733AbjKYJ3t (ORCPT ); Sat, 25 Nov 2023 04:29:49 -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 CAE5810D7; Sat, 25 Nov 2023 01:29:53 -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 1r6oyu-006fom-LM; Sat, 25 Nov 2023 10:29:44 +0100 Received: from andi by aktux with local (Exim 4.96) (envelope-from ) id 1r6oyu-0004JG-1I; Sat, 25 Nov 2023 10:29:44 +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 2/6] twl-core: add power off implementation for twl603x Date: Sat, 25 Nov 2023 10:29:34 +0100 Message-Id: <20231125092938.16535-3-andreas@kemnade.info> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231125092938.16535-1-andreas@kemnade.info> References: <20231125092938.16535-1-andreas@kemnade.info> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, 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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Sat, 25 Nov 2023 01:30:28 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783527808462467911 X-GMAIL-MSGID: 1783527808462467911 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..3eef285eac535 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; } +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 */