From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9F3D6C2BBD1 for ; Thu, 17 Sep 2020 18:34:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 63B1A2220F for ; Thu, 17 Sep 2020 18:34:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726576AbgIQSek (ORCPT ); Thu, 17 Sep 2020 14:34:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726381AbgIQSdj (ORCPT ); Thu, 17 Sep 2020 14:33:39 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76C29C06121C for ; Thu, 17 Sep 2020 11:32:56 -0700 (PDT) Received: from dude.hi.pengutronix.de ([2001:67c:670:100:1d::7] helo=dude.pengutronix.de.) by metis.ext.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1kIyiE-0004GR-TQ; Thu, 17 Sep 2020 20:32:54 +0200 From: Bastian Krause To: linux-rtc@vger.kernel.org Cc: devicetree@vger.kernel.org, Alessandro Zummo , Alexandre Belloni , Rob Herring , Arnaud Ebalard , Marek Vasut , kernel@pengutronix.de, Bastian Krause Subject: [PATCH v2 6/8] rtc: ds1307: store previous charge default per chip Date: Thu, 17 Sep 2020 20:32:44 +0200 Message-Id: <20200917183246.19446-7-bst@pengutronix.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200917183246.19446-1-bst@pengutronix.de> References: <20200917183246.19446-1-bst@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::7 X-SA-Exim-Mail-From: bst@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: devicetree@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Some RTC's batteries and supercaps were charged by default until now. In contrast other RTCs allow charging but the driver did not configure them to do so until now. These must not be charged by default to stay backwards compatible. In order to do that, store the charge default per chip. Signed-off-by: Bastian Krause --- No changes since v1. v1 notes: No previous version. --- drivers/rtc/rtc-ds1307.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c index 7983438b677a..270621e1c9cf 100644 --- a/drivers/rtc/rtc-ds1307.c +++ b/drivers/rtc/rtc-ds1307.c @@ -194,6 +194,11 @@ struct chip_desc { * the resistor between Vcc and Vbackup? */ bool requires_trickle_resistor; + /* Some RTC's batteries and supercaps were charged by default, others + * allow charging but were not configured previously to do so. + * Remember this behavior to stay backwards compatible. + */ + bool charge_default; }; static const struct chip_desc chips[last_ds_type]; @@ -986,6 +991,7 @@ static const struct chip_desc chips[last_ds_type] = { .trickle_charger_reg = 0x10, .do_trickle_setup = &do_trickle_setup_ds1339, .requires_trickle_resistor = true, + .charge_default = true, }, [ds_1340] = { .century_reg = DS1307_REG_HOUR, @@ -994,6 +1000,7 @@ static const struct chip_desc chips[last_ds_type] = { .do_trickle_setup = &do_trickle_setup_ds1339, .trickle_charger_reg = 0x08, .requires_trickle_resistor = true, + .charge_default = true, }, [ds_1341] = { .century_reg = DS1307_REG_MONTH, @@ -1302,7 +1309,7 @@ static u8 ds1307_trickle_init(struct ds1307 *ds1307, const struct chip_desc *chip) { u32 ohms; - bool diode = true; + bool diode = chip->charge_default; if (!chip->do_trickle_setup) return 0; -- 2.28.0