From patchwork Mon Sep 7 14:27:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bastian Krause X-Patchwork-Id: 1359065 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-rtc-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4BlYfN2Zfsz9sR4 for ; Tue, 8 Sep 2020 02:30:04 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729868AbgIGQ34 (ORCPT ); Mon, 7 Sep 2020 12:29:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729870AbgIGO2h (ORCPT ); Mon, 7 Sep 2020 10:28:37 -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 421EFC061798 for ; Mon, 7 Sep 2020 07:27:45 -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 1kFI7U-0003nx-42; Mon, 07 Sep 2020 16:27:44 +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 4/8] rtc: ds1307: apply DS13XX_TRICKLE_CHARGER_MAGIC only conditionally Date: Mon, 7 Sep 2020 16:27:23 +0200 Message-Id: <20200907142727.26472-5-bst@pengutronix.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200907142727.26472-1-bst@pengutronix.de> References: <20200907142727.26472-1-bst@pengutronix.de> MIME-Version: 1.0 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: linux-rtc@vger.kernel.org Sender: linux-rtc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rtc@vger.kernel.org DS13XX_TRICKLE_CHARGER_MAGIC sets the trickle-charge select (TCS) bits (7..4). The datasheet of Maxim Integrated's DS1339 [1] for instance reads: "To prevent accidental enabling, only a pattern on 1010 enables the trickle charger. All other patterns disable the trickle charger." Since not all RTCs connected to a backup battery or supercap use these bits DS13XX_TRICKLE_CHARGER_MAGIC should not get applied for all charger setups unconditionally. Epson's RX8130 is such an example: Instead of TCS bits "SMPTSEL1", "SMPTSEL0", "CHGEN" and "INIEN" are expected as bit 7..4. DS1339 and DS1340 are currently the only RTCs in the ds1307 driver that apply DS13XX_TRICKLE_CHARGER_MAGIC to their setup register value. So apply DS13XX_TRICKLE_CHARGER_MAGIC in do_trickle_setup_ds1339() which is used by both RTCs. [1] https://datasheets.maximintegrated.com/en/ds/DS1339-DS1339U.pdf [2] https://support.epson.biz/td/api/doc_check.php?dl=app_RX8130CE Signed-off-by: Bastian Krause --- No previous version. --- drivers/rtc/rtc-ds1307.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c index 54c85cdd019d..ff5242d10b21 100644 --- a/drivers/rtc/rtc-ds1307.c +++ b/drivers/rtc/rtc-ds1307.c @@ -507,6 +507,8 @@ static u8 do_trickle_setup_ds1339(struct ds1307 *ds1307, u32 ohms, bool diode) u8 setup = (diode) ? DS1307_TRICKLE_CHARGER_DIODE : DS1307_TRICKLE_CHARGER_NO_DIODE; + setup |= DS13XX_TRICKLE_CHARGER_MAGIC; + switch (ohms) { case 250: setup |= DS1307_TRICKLE_CHARGER_250_OHM; @@ -1758,7 +1760,6 @@ static int ds1307_probe(struct i2c_client *client, trickle_charger_setup = pdata->trickle_charger_setup; if (trickle_charger_setup && chip->trickle_charger_reg) { - trickle_charger_setup |= DS13XX_TRICKLE_CHARGER_MAGIC; dev_dbg(ds1307->dev, "writing trickle charger info 0x%x to 0x%x\n", trickle_charger_setup, chip->trickle_charger_reg);