Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp1750646rdh; Sat, 25 Nov 2023 01:31:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IFVDNaUOr8kU/rGF4/OHTFI5b8MpWf04jqRis4KQkk6abBMcLgZV8DUQrKglBZSskBS1lsA X-Received: by 2002:a05:6a00:450c:b0:6cb:e4af:d94d with SMTP id cw12-20020a056a00450c00b006cbe4afd94dmr6362350pfb.4.1700904665023; Sat, 25 Nov 2023 01:31:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700904665; cv=none; d=google.com; s=arc-20160816; b=WgLZxd+u2aEvOPwIJv9yrlFIO0rZ4KcKynDX0VrbOOEN1Ro+Y8SONwULMT50XTmPmD B7uocKLbYZwe343yFgjoUiKysDcSaFEU0KjQcTy/qgdZnHQlKBLx1ocpT1KA3HgRienB /SmGhuxS+yNubj/FzNa3df4ddfA2zEP96gJZh47qFMdspQrAkO1F7TIX+DHudluT3KJo XCuG3EbcdoCYJZHShcUm51m1RbsqxgGbcjzh1Bk81Zh+eBNKP1x2oYdKwsnJ/8oHxHds 32QWZ74yXIGikh6FhctbqcydIV7sTeCWK2YR8u59r2BwIliaoI+z8LHZVBO55PQ5javl bgkA== 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 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id p20-20020a056a000b5400b006cb686c08f4si5527770pfo.211.2023.11.25.01.31.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Nov 2023 01:31:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 812898083E79; Sat, 25 Nov 2023 01:30:39 -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 Content-Transfer-Encoding: 8bit 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:39 -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..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 */ -- 2.39.2