From patchwork Sat Feb 17 08:20:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Kemnade X-Patchwork-Id: 202585 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp210137dyc; Sat, 17 Feb 2024 00:21:40 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUGHQbawG5fjB2vMF0u/cdrG33ZBG73JsK96b9Gi/pF744v2v0ky0PTp6Yh1WmcsDIsLEFgh9Ab8RZ1swrwKO3Hp4DbUA== X-Google-Smtp-Source: AGHT+IF+tYYiJ8fo/MaLpDZhAQwyx7KuhXxxJbVMvg1htiO7E3p7HCIMZ4yIHKyEfiPjYN5kvFZR X-Received: by 2002:a05:6e02:1749:b0:364:6ae:b5d1 with SMTP id y9-20020a056e02174900b0036406aeb5d1mr9700517ill.2.1708158100658; Sat, 17 Feb 2024 00:21:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708158100; cv=pass; d=google.com; s=arc-20160816; b=CpVHwvjhtiCgnJn5LDAZD4BBjjO6F7l2f/YlrOKdLGyYAyRcYrvIMDeBDJB7FdQnzY 5u7jCS+5KsRNC69tA4tfHZpNTTiPgwLWqYYtKm8ELeRiuHznxClN/E3wpVssUiN9VdB9 UTBjoEUsHLsSl4wcfbiWHOc9lebkWG9DtfQqEyPtFSLyQEE5KomR+Ylg6dERfvN26EBO Hc5dvMCoCPmjjeP5ORulYRXkGnGIJ3b+4TrPa/+BLYRAcIyog8h5bDbd5s3awZBhZX1w g2JViSs4ycER3BAMbPSiYGuMOcp7xLMEm5TLUstbHBr5UO6CPUjgfSDH6d48fJXhQg4U bGHw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:to:from:dkim-signature; bh=t7Kt1H92S1Uo0WtagmmqZO9iJoXliNnTy7y2hbdMW6c=; fh=ompBcuc9WZSkOT6I8Jb+H375/5cBcTGkrIOABj6b1VU=; b=ze3V0C4/L8tWBnWvyliQ9aHu4e082w4UYMK4T5NEx0E7EjRYAfbW8ICNdcyn4GjvsA Wmz8iqMcMTiRPYZ3+AHBGqfCPAlsFeTv1xtDTFYSHUpjiktR1M0LZIh+S98Fz/fCbcEg jj/1WUyGyzC5/ucnzx12B3pV0CjYEPnKRL65hPnDkfnJg204GFXgwamdJZSi1heaJIIN R+pt2tUlKlDDZ6vRZNz7kweGgyJb6Lk/xcBFil1yRkNHPuJ3zvmjnRfeW/qGjzvRID8k HLLyGMJ34i4OBr059aUmJyVL0hI4rTEjzntdBQJsntRcSUy5rfUV5FZgxeD9HKkNoJZy xn/A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=fail header.i=@kemnade.info header.s=20220719 header.b=ySj3BOqz; arc=pass (i=1 spf=pass spfdomain=kemnade.info dkim=pass dkdomain=kemnade.info); spf=pass (google.com: domain of linux-kernel+bounces-69745-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69745-ouuuleilei=gmail.com@vger.kernel.org" Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id r13-20020a65508d000000b005d8b8c6a98bsi1178579pgp.588.2024.02.17.00.21.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Feb 2024 00:21:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-69745-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=fail header.i=@kemnade.info header.s=20220719 header.b=ySj3BOqz; arc=pass (i=1 spf=pass spfdomain=kemnade.info dkim=pass dkdomain=kemnade.info); spf=pass (google.com: domain of linux-kernel+bounces-69745-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69745-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id BACAFB21466 for ; Sat, 17 Feb 2024 08:21:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 76B911DFF2; Sat, 17 Feb 2024 08:20:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=kemnade.info header.i=@kemnade.info header.b="ySj3BOqz" Received: from mail.andi.de1.cc (mail.andi.de1.cc [178.238.236.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5013B1CD23; Sat, 17 Feb 2024 08:20:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=178.238.236.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708158047; cv=none; b=RhdXvrxkoLsUjTKcSXCkpEJ5dePAEtHFKqQ3hAaSvDrsx9yT0Ppsede5v3QseuqUUB+spYKjzdHA1qNyQE7pQEaUpVzwdo3z6FNqPHQKpf8JJMOT6MWTCs7iOcB1LpCQfXGHXnva+GuZue2fiYBoKwQfOu5AeN0Cy6NRuoHK9yI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708158047; c=relaxed/simple; bh=w91rU8ULQEAl2yC2K+2JFdu1mPXgT91a33YAroU1V7Q=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=H4O3I93V/zcngLpkgy/8dRglG3vAfd3Vn73rWZYTCTW8xvzWEkrs1xdseJ3ChfX4KiYeoCDnRzLRWR3TnxsbkUwqAsFQp6cfo3q/bychXeIwbGAHOhZ/HmF0I4e7l3JXSIa5ALwM4qXo60//qgvE2DPJyC5vWyHX1Z9XtIDIRFE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kemnade.info; spf=pass smtp.mailfrom=kemnade.info; dkim=pass (2048-bit key) header.d=kemnade.info header.i=@kemnade.info header.b=ySj3BOqz; arc=none smtp.client-ip=178.238.236.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kemnade.info Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kemnade.info DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=kemnade.info; s=20220719; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=t7Kt1H92S1Uo0WtagmmqZO9iJoXliNnTy7y2hbdMW6c=; b=ySj3BOqzDv6V6LUOJA80aQGK2K h82bVen1rFf66iJOzOxPHpmbmGTF4GmNe684LXyhkDxtv80O6Fjn13SgI8j5LDKHCvSPUGFf6u+dU Hx0Ws2fUnwAvHSsSBShkYQFU85PO12uPDvuI+Vgb0BVWltQUZ5OZ7AM9v7IwfAIMq1oIg2/hzEqKb rWi4TD+FBenkuVrh3RzAKAF5YPSIu57te1CmEEQ286YBjYDwkpLQjvlXzvw+OPc70ADrQYJ1rDwEw hOdJKltecWjCbkuu0Vu0klh8KBlahvGC1q/2Wj5CKrh4AEV0mlaPD1dnm9UJBdzVvJf2doV5wUMW/ 7/pVuYNw==; Received: from p2003010777002c001a3da2fffebfd33a.dip0.t-ipconnect.de ([2003:107:7700:2c00: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 1rbFw0-009WA5-DZ; Sat, 17 Feb 2024 09:20:32 +0100 Received: from andi by aktux with local (Exim 4.96) (envelope-from ) id 1rbFvz-00Dabj-2w; Sat, 17 Feb 2024 09:20:31 +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 v4 2/5] twl-core: add power off implementation for twl603x Date: Sat, 17 Feb 2024 09:20:04 +0100 Message-Id: <20240217082007.3238948-3-andreas@kemnade.info> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240217082007.3238948-1-andreas@kemnade.info> References: <20240217082007.3238948-1-andreas@kemnade.info> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791133588614587516 X-GMAIL-MSGID: 1791133588614587516 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 | 28 ++++++++++++++++++++++++++++ include/linux/mfd/twl.h | 1 + 2 files changed, 29 insertions(+) diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c index 6e384a79e3418..c130ffef182f1 100644 --- a/drivers/mfd/twl-core.c +++ b/drivers/mfd/twl-core.c @@ -124,6 +124,11 @@ #define TWL6030_BASEADD_RSV 0x0000 #define TWL6030_BASEADD_ZERO 0x0000 +/* Some fields in TWL6030_PHOENIX_DEV_ON */ +#define TWL6030_APP_DEVOFF BIT(0) +#define TWL6030_CON_DEVOFF BIT(1) +#define TWL6030_MOD_DEVOFF BIT(2) + /* Few power values */ #define R_CFG_BOOT 0x05 @@ -687,6 +692,20 @@ static void twl_remove(struct i2c_client *client) twl_priv->ready = false; } +static void twl6030_power_off(void) +{ + int err; + u8 val; + + err = twl_i2c_read_u8(TWL_MODULE_PM_MASTER, &val, TWL6030_PHOENIX_DEV_ON); + if (err) + return; + + val |= TWL6030_APP_DEVOFF | TWL6030_CON_DEVOFF | TWL6030_MOD_DEVOFF; + twl_i2c_write_u8(TWL_MODULE_PM_MASTER, val, TWL6030_PHOENIX_DEV_ON); +} + + static struct of_dev_auxdata twl_auxdata_lookup[] = { OF_DEV_AUXDATA("ti,twl4030-gpio", 0, "twl4030-gpio", NULL), { /* sentinel */ }, @@ -852,6 +871,15 @@ twl_probe(struct i2c_client *client) goto free; } + if (twl_class_is_6030()) { + if (of_device_is_system_power_controller(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 */