Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp107091rdb; Sat, 17 Feb 2024 00:21:04 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU9T+gHvztq0BOvQ1SKIe5pEOHU3Uk+VKXW49iR5S9tJfRd2a+6D8fj91TDt5A8KoHKP7y1tKSU+UwZYun7AgeUNRslXwfpYwjCHZ8uNw== X-Google-Smtp-Source: AGHT+IHVXMPBUgABXraOewxzCFkpXp+hhr7bUVhOY1krClErjYQdTm0epxDRNtb9NQsyQHNiKaas X-Received: by 2002:a17:902:aa0b:b0:1d9:5371:bc with SMTP id be11-20020a170902aa0b00b001d9537100bcmr7031983plb.37.1708158064585; Sat, 17 Feb 2024 00:21:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708158064; cv=pass; d=google.com; s=arc-20160816; b=BdpY5jK8Mj+RewJ6+ldCU4o2EIQ3MFI4wd8Bn6Gd7S38+O54/OfraiLTRQuj794uG2 r/a31NbPXgoHzT0zCy5gO+NpF/ZwgG0QeSXtx5wfa8pZeS1SPP6qyHxHCMaZhvharDS1 wKpdgW59U5Q+AS2AnCpzSURDOpCsBYZzett4Azgl5LzhnDm3BcnOmWzIjlZafubn/AQO eZnGOmGlCEB5vHxzz7gJGkPTO/oLMgQsHI+YBgifoopengP3E2xj4TAq1sFy0H8zeoq2 6UIVUsXFP8XKk2wYq43xBCUWXtonQ/b4biCo3U0rI6TfuSy9jnuldyeMPJD5+vltlbzC w6fA== 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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69745-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id b2-20020a170903228200b001d6f89cfec9si1159139plh.348.2024.02.17.00.21.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Feb 2024 00:21:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-69745-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69745-linux.lists.archive=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 46B07282E07 for ; Sat, 17 Feb 2024 08:21:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9ED341D539; Sat, 17 Feb 2024 08:20:48 +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 Content-Transfer-Encoding: 8bit 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 */ -- 2.39.2