Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp2683579rda; Wed, 25 Oct 2023 09:22:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEf4wqbMyCbExAgd9roGBtGpy29rPrSY6Y4DJZZF7anuC/ujEfjYIj/R0TkJnuQ63S6GRuF X-Received: by 2002:a05:6902:567:b0:d9b:37dd:a3d7 with SMTP id a7-20020a056902056700b00d9b37dda3d7mr15739901ybt.17.1698250955997; Wed, 25 Oct 2023 09:22:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1698250955; cv=pass; d=google.com; s=arc-20160816; b=ct2POve88BsWgODCrzAXvxfuCCta7AKMJ79zL7u7lFKgTCtKKeZgijcU38/z/DSq3d +2tqn+Te3E0UUtH5kZa/CNgaF7GUNdT5ltocCBWdLa6Ul9w14KXZVQcGP8p2qzRizxWC YkZZ//RY5dl7nUFyTOZtR0790c+WMDs+zj6f1fKIk4Rp9W22geFAt2i/JjfPqsgJ1Q2S TVqS4OuuCDRYfJZQsaBsLp12mlWcbnO/JVa6SmyN7PvtMIR4Hjt7xH+PTxAQayfRrjhS kliSKUyt8ZVkFTLLQgY43qLUibmkLf0HTkggf6IOhPuzb0w53/9lEhOGW5zpH8Tju1y9 SoMg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:cc:to:in-reply-to:references :message-id:content-transfer-encoding:subject:date:from :dkim-signature; bh=IhnIsREnNliGjRhfvQxTajFTEWoDQVcts8ho7zL724g=; fh=WGYDx7G3tm+UTbKqpnFEp2KY6hmZjF4Jkz7/+/tC2Mg=; b=HNLfGwq9e3PEEb8xIROSyIgTu1CIQqfW8LN1HPBjZPIkjtXncAn+FfyXYiuOJA7jUf GBjJ1qCDuzEWTv9/A7v3BjPMp/D5ua0jwvsR4NP+Ip6UFOesE4Mb89D0aBCg33x9EIUk qc2yzzwn6cVdmCw/5w2zgeQxcC7N+bFndJo/QuXR2dTdiPayvqV7RVc3MUOmbPJErsRq uq4hVXOeOr7Y2Mq/a4BNefodGSeIYuwsCWdskmlJzG7/JCJI4KE+nCQE9ok3oveppp2+ nlMkZ7KXaMJemR359cIZz/c72AmxEEMwBhB65FMKfcVWVMvuJByMHeZnoASC36j/XxPj P7Cw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@wolfvision.net header.s=selector2 header.b=SGAobYfq; arc=pass (i=1 spf=pass spfdomain=wolfvision.net dkim=pass dkdomain=wolfvision.net dmarc=pass fromdomain=wolfvision.net); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=wolfvision.net Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id k23-20020a25b297000000b00d9a5ec7105csi10617422ybj.610.2023.10.25.09.22.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 09:22:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@wolfvision.net header.s=selector2 header.b=SGAobYfq; arc=pass (i=1 spf=pass spfdomain=wolfvision.net dkim=pass dkdomain=wolfvision.net dmarc=pass fromdomain=wolfvision.net); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=wolfvision.net Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 634B48131C2A; Wed, 25 Oct 2023 09:22:26 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234017AbjJYQWI (ORCPT + 99 others); Wed, 25 Oct 2023 12:22:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229583AbjJYQWF (ORCPT ); Wed, 25 Oct 2023 12:22:05 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2063.outbound.protection.outlook.com [40.107.21.63]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31BE691; Wed, 25 Oct 2023 09:22:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mK8zV6UM7/b0uD/de1z9Q9Ol3fuyQam44pj4vNTsl4OD7bo8tpbNHB2oBeTFrLSnajPLK56hJnpgUQvTYyfHIQxjmWjEMU6LWJGcDtBGnDi2mO5GhwAc4jHFv12fXJ8GRBYBfuotuuiPiSPD9+diqHi/N2X/67lcsuJUuDgc/53jUtFepqlA+MeOuxBmdnXQ5BjmIKtlagK9ptP6RZTqSBdQSMcHNxpM3CaGa8g/4cSd06LTdmIFke+xIvORucLvc7N2zD+pAju6iaHP+fapSHPOcyGdv20rPc6BbSj9Wgplw7gYS2anDUPR3ovFKces/dazk8ccOBGVe0f0OeByEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=IhnIsREnNliGjRhfvQxTajFTEWoDQVcts8ho7zL724g=; b=jAWD+7fF5lzc0GlqhKOcJJA+hTgCwLhNizr36XMjpdsy3aNPpc2J9zJcGVayNqamrKF+F+kWf2SOArIbyUxs9JRhO2Fz+Vug6JatQuJffP8hbS/rfmheJKpu3A62/NJJqvdCX6bz0uX3ONzZATrjoUOgPQzm4/nzYDihalqwjAHhxxXmX4bcMYyITp3ZHhYv/m1IB/gMbiXg9pEayfA6K8uWRIqFxOHAFNcwmSK7E7qvLRxPC1R7fSFj2kj5W30oE77h6RDDHm6Pbx2WuXon3yVbTHrYApY92156lx2pkI9FlU2vysY5QTEHQQsvicqSuY9A6XcuSaTAW61GQJ0P/Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=wolfvision.net; dmarc=pass action=none header.from=wolfvision.net; dkim=pass header.d=wolfvision.net; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wolfvision.net; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IhnIsREnNliGjRhfvQxTajFTEWoDQVcts8ho7zL724g=; b=SGAobYfq1kMFWIOD30ZM3Y3SWc3T+sYwjN1nHboWkZRTQ0CQAz5UDNr5FW1U1Pc/NQK9twAdBezqTFzp4Jo5OjDNtUKDTABg4LY3aPjqdaKnRuYOhJBnC1YWVIxrXgoaITgfzGKC+Dwu7oPen+TWm8GnON8ZK9fjAaD6CQij+c8= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=wolfvision.net; Received: from VE1PR08MB4974.eurprd08.prod.outlook.com (2603:10a6:803:111::15) by VI1PR08MB5376.eurprd08.prod.outlook.com (2603:10a6:803:13e::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.19; Wed, 25 Oct 2023 16:21:59 +0000 Received: from VE1PR08MB4974.eurprd08.prod.outlook.com ([fe80::a309:1d65:f5fb:436b]) by VE1PR08MB4974.eurprd08.prod.outlook.com ([fe80::a309:1d65:f5fb:436b%6]) with mapi id 15.20.6933.019; Wed, 25 Oct 2023 16:21:59 +0000 From: Javier Carrasco Date: Wed, 25 Oct 2023 18:21:54 +0200 Subject: [PATCH 1/2] rtc: pcf85363: add support for high-impedance output Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20231024-topic-pcf85363_hiz_output-v1-1-50908aff0e52@wolfvision.net> References: <20231024-topic-pcf85363_hiz_output-v1-0-50908aff0e52@wolfvision.net> In-Reply-To: <20231024-topic-pcf85363_hiz_output-v1-0-50908aff0e52@wolfvision.net> To: Alessandro Zummo , Alexandre Belloni , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Javier Carrasco X-Mailer: b4 0.12.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1698250918; l=4421; i=javier.carrasco@wolfvision.net; s=20230509; h=from:subject:message-id; bh=FF2xr2kA4qsEIO3Vzgxe9YV6LCFr1AZBTHkk4R/7HSw=; b=NL8dEBmMmFEa4v289RMS3qED08d9Bi/PNAHgRlAgMm560xhjgannG3JAEDYQksbycB7EpeQ8j hlUnaI2kB/ECNODS+DQ7m8sHctxJ4H4LsRTmEYmU7SFc0YocF86r7+Z X-Developer-Key: i=javier.carrasco@wolfvision.net; a=ed25519; pk=tIGJV7M+tCizagNijF0eGMBGcOsPD+0cWGfKjl4h6K8= X-ClientProxiedBy: VI1PR0102CA0040.eurprd01.prod.exchangelabs.com (2603:10a6:803::17) To VE1PR08MB4974.eurprd08.prod.outlook.com (2603:10a6:803:111::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR08MB4974:EE_|VI1PR08MB5376:EE_ X-MS-Office365-Filtering-Correlation-Id: 0639ebf5-d03f-4861-eb3e-08dbd576835c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZNPU7U4Qokf4T1lG2mY4jY88P9ro8Kb0SVymhKYqMnTG0QG5vR406H6Za0eCFFYJSRaVRwGT/SoVDv40l/hanWuvVMFctjgTJocZlFVWj3B+KlaN+RXsJRSg1Pwcsuzj+4R2FE4w1rKob9jQjj+mE3x0MZJwgTCUkZF8Mk7zqSk4q9nrtIXe+2dDRsg0qiXGeHIcFn2loZAeRS6RnbLAo3AL1xIq86NMXdB8CsHuJr+03DRSpjGa7m/XEW9HaLcI98I/VsMOeWfRsOTTIjDHIr717WV+0BoRCFAxzUy2qV9BMjJgQ23FsWBWXJxMLDiIPlgaTmvoek8esbyY2/ULla50MsBOMMbrcy3DRXlTFACBre95oVfe9mVZpfwFx0+y0+mQ3RZ5q2xbOEyaHPD7MwxK8D3d1uP9eGPV6/2ePa6J4OOnCGeohid0BuX53ATcfs+VCpVOMDwRm59kfHHPwgH+DPme1VN9CmN4B5hpfI+SaopOPh2RkMtc4x+Z4GbmMVq8RMk/naGuLFm6FGHKO1rCzBReITGNRcVW95CyLfLagEvvhYyC9bRgzTAHrY/yZqNtphA8LEvV5rIwr+GvsdeuWt5yiEc/vjH68XNztwwc1TgrbPzYs8xIiPsv40U8 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VE1PR08MB4974.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(346002)(39840400004)(396003)(376002)(136003)(366004)(230922051799003)(64100799003)(186009)(1800799009)(451199024)(4326008)(2906002)(8676002)(8936002)(44832011)(83380400001)(6486002)(107886003)(52116002)(5660300002)(41300700001)(6512007)(6506007)(86362001)(316002)(110136005)(26005)(478600001)(6666004)(2616005)(36756003)(38100700002)(66946007)(66556008)(66476007)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?WnVzb0tGb0dVWUdvZFFvcSs3cFcySVlqUE5wYk85SzUzUUd4WmtTbnZxN2hO?= =?utf-8?B?NGdRT3p2ZHJG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JaeTY2MFlGQU5ycUxZVHNuRUt6Nnd5TUFValpuVkJDUDFQ?= =?utf-8?B?LzJSZ0lSWEl4Q0FrWFIvUnpqaDk3b0pyQkl5VmFOYWdhM3RCaVRWZ0ZuOUR5?= =?utf-8?B?d21Sc2ZqeU9aSFhxQ0phL0x3WUhXMi9iVFJObzNsS3R1M2xaWDJQaTRpenBw?= =?utf-8?B?WFdmUHJyN0k2ODVkdWRrbmJydTIvSUdXMXZQMEVDL2hocXYyMEtQa0Zpc3Q4?= =?utf-8?B?aUpGaE0yR2ZHZEFLdldxc3RhRjREaXp1T0JQQ1RKSjlKbng5QXRwTHZWUGpu?= =?utf-8?B?R3V5TzVjdUpzTjlWU0lxODFGaFZvM1VNNnNKcDFGLzBLbnpjNjFya0hpUTVx?= =?utf-8?Q?ZDWIDpBbj2xaJSSgUoDtMgM=3D?= X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: 0639ebf5-d03f-4861-eb3e-08dbd576835c X-MS-Exchange-CrossTenant-AuthSource: VE1PR08MB4974.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Oct 2023 16:21:59.0785 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: e94ec9da-9183-471e-83b3-51baa8eb804f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 5qdMebzrFqtiDZjmdTNRqaaZ86wT+56JpaeffBw2ebfgfIF/3t0LP7JD82dKN10IWGa6Mb7pxkTaLDHngqZs1WYnfpI4QOe1fbeKmpJUc/g= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB5376 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.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 (pete.vger.email [0.0.0.0]); Wed, 25 Oct 2023 09:22:27 -0700 (PDT) The pcf85363 provides a high-impedance (hi-Z) mode for its output. This mode can be used to reduce power consumption in applications where the RTC output is only required as a clock/interrupt source when the system runs in low-power mode (i.e. serving as a clock source for a PMU when the system is down). If the output is not needed, it can also be completely disabled. This implementation adds support for a hi-Z output and also uses simple pm operations (suspend and resume) to switch the output mode from hi-Z in normal operation to the required operation mode in sleep mode (currently either clock or interrupt) if the "sleep" value for the hiz-output was set. In order to make use of the hi-Z output modeling via device tree, check if the new "hiz-output" property is defined and set the hi-Z mode accordingly. Signed-off-by: Javier Carrasco --- drivers/rtc/rtc-pcf85363.c | 62 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/drivers/rtc/rtc-pcf85363.c b/drivers/rtc/rtc-pcf85363.c index 540042b9eec8..82eaf8de8b33 100644 --- a/drivers/rtc/rtc-pcf85363.c +++ b/drivers/rtc/rtc-pcf85363.c @@ -110,9 +110,17 @@ #define NVRAM_SIZE 0x40 +enum pcf85363_hiz_output_t { + PCF85363_HIZ_OFF, + PCF85363_HIZ_ON, + PCF85363_HIZ_SLEEP, +}; + struct pcf85363 { struct rtc_device *rtc; struct regmap *regmap; + + enum pcf85363_hiz_output_t hiz_output; }; struct pcf85x63_config { @@ -403,6 +411,7 @@ static int pcf85363_probe(struct i2c_client *client) }; int ret, i, err; bool wakeup_source; + const char *hiz_output = NULL; if (data) config = data; @@ -433,9 +442,32 @@ static int pcf85363_probe(struct i2c_client *client) pcf85363->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000; pcf85363->rtc->range_max = RTC_TIMESTAMP_END_2099; + if (device_property_present(&client->dev, "hiz-output")) { + ret = device_property_read_string(&client->dev, "hiz-output", + &hiz_output); + if (ret) + return ret; + + if (!strcmp(hiz_output, "enabled")) { + pcf85363->hiz_output = PCF85363_HIZ_ON; + } else if (!strcmp(hiz_output, "sleep")) { + pcf85363->hiz_output = PCF85363_HIZ_SLEEP; + } else if (!strcmp(hiz_output, "disabled")) { + pcf85363->hiz_output = PCF85363_HIZ_OFF; + } else { + dev_warn(&client->dev, "Unknown hiz-output: %s. Assuming disabled", + hiz_output); + pcf85363->hiz_output = PCF85363_HIZ_OFF; + } + } else { + pcf85363->hiz_output = PCF85363_HIZ_OFF; + } wakeup_source = device_property_read_bool(&client->dev, "wakeup-source"); - if (client->irq > 0 || wakeup_source) { + if (pcf85363->hiz_output != PCF85363_HIZ_OFF) { + regmap_update_bits(pcf85363->regmap, CTRL_PIN_IO, + PIN_IO_INTAPM, PIN_IO_INTA_HIZ); + } else if (client->irq > 0 || wakeup_source) { regmap_write(pcf85363->regmap, CTRL_FLAGS, 0); regmap_update_bits(pcf85363->regmap, CTRL_PIN_IO, PIN_IO_INTAPM, PIN_IO_INTA_OUT); @@ -474,6 +506,31 @@ static int pcf85363_probe(struct i2c_client *client) return ret; } +#ifdef CONFIG_PM_SLEEP +static int pcf85363_suspend(struct device *dev) +{ + struct pcf85363 *pcf85363 = dev_get_drvdata(dev); + + if (pcf85363->hiz_output == PCF85363_HIZ_SLEEP) + regmap_update_bits(pcf85363->regmap, CTRL_PIN_IO, PIN_IO_INTAPM, + device_may_wakeup(dev) ? PIN_IO_INTA_OUT : + PIN_IO_INTA_CLK); + + return 0; +} + +static int pcf85363_resume(struct device *dev) +{ + struct pcf85363 *pcf85363 = dev_get_drvdata(dev); + + if (pcf85363->hiz_output == PCF85363_HIZ_SLEEP) + regmap_update_bits(pcf85363->regmap, CTRL_PIN_IO, + PIN_IO_INTAPM, PIN_IO_INTA_HIZ); + + return 0; +} +#endif + static const __maybe_unused struct of_device_id dev_ids[] = { { .compatible = "nxp,pcf85263", .data = &pcf_85263_config }, { .compatible = "nxp,pcf85363", .data = &pcf_85363_config }, @@ -481,9 +538,12 @@ static const __maybe_unused struct of_device_id dev_ids[] = { }; MODULE_DEVICE_TABLE(of, dev_ids); +static SIMPLE_DEV_PM_OPS(pcf85363_pm_ops, pcf85363_suspend, pcf85363_resume); + static struct i2c_driver pcf85363_driver = { .driver = { .name = "pcf85363", + .pm = &pcf85363_pm_ops, .of_match_table = of_match_ptr(dev_ids), }, .probe = pcf85363_probe, -- 2.39.2