From patchwork Wed Feb 1 14:34:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frieder Schrempf X-Patchwork-Id: 51365 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp317130wrn; Wed, 1 Feb 2023 06:44:04 -0800 (PST) X-Google-Smtp-Source: AK7set8cT/2szMy5pSiaEKWD/VRh/JwxwHpU/3esyJLc8UVZOqO0xZgwR/oQkBYgOzOdcAasJNKO X-Received: by 2002:a17:902:e844:b0:196:15a6:7332 with SMTP id t4-20020a170902e84400b0019615a67332mr2713827plg.31.1675262644334; Wed, 01 Feb 2023 06:44:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675262644; cv=none; d=google.com; s=arc-20160816; b=ymBIKa0Z163dq1mLCND7JWfIZnL5/2VuSuSm3qfm+iJsf0r/bboQnL12jU5r6dNIPs e70bu82dfGJh9zia43XviB77l/L44lXX7eNabbnjAZn0xLnZvtlAzcU77fcUaw7GqMFp 8w399eW5G1R+0dINZ3dNLi5bNbexo5XT4ldsWClvVT9QhyClTeH01OP6CsWXBSHgYTZ3 x5qhDcur0MgkAnBFE3E92Xhz70krzWZTEUqH7j40eXkDbaaTUiujS1oT2c6bCNvg7F4d lJOSJHEnTd9uNh9Yer7b6EQeuRDLj4GoMd748UD1erLP6K/O059N09qaJ1RiZQiBP96I bnbw== 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:cc:to:from :dkim-signature; bh=wvJB0OUDEjfjJl0NbgwhqGyfXYoeQO+CyeH0uszLyk0=; b=Aof7iNTV1u4NSu+z6ZuhZa4osgZFaWFHlUaSD4saoWCJwr+jHLoPmqqKwcZzoF+2Ys n7mJPR/BQThspSAdv2Pz6qGbSFyCSoBAJPSzaPfRPwYqYuvugKwcXUw3UWYzzT9tkuFB lqyVzV45a+A3Hg0ccLXY7izAsD7TwiD4V/yvmt+JmpvllFv0YkF0rpkBJ00Ci5NHve9L qX82O8xvDd8EUR60J1babTBicanvLVTYL32gu7maJVgVztqhbLHXQhMLdlEG/kEZm9fM 3INhcE8Tsf4hzz5rYhdjb7YclpM3E9+ocMYyFYPrk3vIYq18lo/dIffoZeHF28YESBrz SOLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fris.de header.s=dkim header.b=silF0PZR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=fris.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s4-20020a170902ea0400b00189ac5a25e8si6923296plg.160.2023.02.01.06.43.52; Wed, 01 Feb 2023 06:44:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@fris.de header.s=dkim header.b=silF0PZR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=fris.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231963AbjBAOnU (ORCPT + 99 others); Wed, 1 Feb 2023 09:43:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232462AbjBAOnK (ORCPT ); Wed, 1 Feb 2023 09:43:10 -0500 X-Greylist: delayed 491 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Wed, 01 Feb 2023 06:43:05 PST Received: from mail.fris.de (mail.fris.de [116.203.77.234]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C03D2E80B; Wed, 1 Feb 2023 06:43:03 -0800 (PST) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 432F6C033C; Wed, 1 Feb 2023 15:35:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fris.de; s=dkim; t=1675262109; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=wvJB0OUDEjfjJl0NbgwhqGyfXYoeQO+CyeH0uszLyk0=; b=silF0PZRDEQ+cRx3MXl+8ZK4MfXSgw/Xeu5H/4fxJDygDKC88Zw65FY6WVG3pWEQ9DEWc0 Liz7qJ8O4M71oGThvh+zL2SIYCziQcwpNs8/M2KvA0TumO6qOo0g0pGIoyNDxteHsGkHG2 JxyR7kAoeie/HU69iXi7Wvt5qD+zNPrtwdBFTN1M6Y1AAHwsVQkyJJc8WUNoyt5lGWhtI4 eH5KZfnH8tUtL7cFta9BVXp0h6vqDYuoBkzey2F4UrBFonlCOrJwfx17HVJTVX1uAhfemC zFR0NAH3zLARFWNLNg4cVG1cAPOm3hRP+kjVFxtAAYUTB3+Uw6o6xBYgg1fAgw== From: Frieder Schrempf To: Alessandro Zummo , Alexandre Belloni , linux-kernel@vger.kernel.org, linux-rtc@vger.kernel.org Cc: Frieder Schrempf , keliu , Shang XiaoJing , Vincent Whitchurch , Yang Yingliang Subject: [PATCH 5/7] rtc: class: Support setting backup switch mode from devicetree Date: Wed, 1 Feb 2023 15:34:27 +0100 Message-Id: <20230201143431.863784-6-frieder@fris.de> In-Reply-To: <20230201143431.863784-1-frieder@fris.de> References: <20230201143431.863784-1-frieder@fris.de> MIME-Version: 1.0 X-Last-TLS-Session-Version: TLSv1.3 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756640202873826855?= X-GMAIL-MSGID: =?utf-8?q?1756640202873826855?= From: Frieder Schrempf Some RTC devices like the RV3028 have BSM disabled as factory default. This makes the RTC quite useless if it is expected to preserve the time on hardware that has a battery buffered supply for the RTC. Let boards that have a buffered supply for the RTC available force the BSM to the desired value via devicetree by setting the 'backup-switch-mode' property. Signed-off-by: Frieder Schrempf --- drivers/rtc/class.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/rtc/class.c b/drivers/rtc/class.c index e5b7b48cffac..79417d1fbeee 100644 --- a/drivers/rtc/class.c +++ b/drivers/rtc/class.c @@ -391,6 +391,11 @@ int __devm_rtc_register_device(struct module *owner, struct rtc_device *rtc) struct rtc_wkalrm alrm; int err; + struct rtc_param bsm = { + .param = RTC_PARAM_BACKUP_SWITCH_MODE, + .uvalue = RTC_BSM_DISABLED, + }; + if (!rtc->ops) { dev_dbg(&rtc->dev, "no ops set\n"); return -EINVAL; @@ -402,6 +407,15 @@ int __devm_rtc_register_device(struct module *owner, struct rtc_device *rtc) if (rtc->ops->set_offset) set_bit(RTC_FEATURE_CORRECTION, rtc->features); + /* setup backup switching mode */ + if (test_bit(RTC_FEATURE_BACKUP_SWITCH_MODE, rtc->features) && + !device_property_read_u32(rtc->dev.parent, "backup-switch-mode", + (u32 *)&bsm.uvalue)) { + err = rtc->ops->param_set(rtc->dev.parent, &bsm); + if (err && err != -EINVAL) + return err; + } + rtc->owner = owner; rtc_device_get_offset(rtc);