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=-13.0 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,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 63580C433E1 for ; Sun, 19 Jul 2020 14:52:42 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3117421775 for ; Sun, 19 Jul 2020 14:52:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="rjx9NNUb"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="AZK9wg1D" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3117421775 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=THlmf8FTITR7yN+VzZeppMJUWptywDTfmW2HiLdOFfY=; b=rjx9NNUbvysnfWMTD0SFoRPq2 P2t09Wx0Sqr9zumugxVyyijTmy4W4L+cZ8JptnquiS4LIMpW/vOFRKnLcJeko/jrgSCvtMIqEDTSa pFzYHJA2w5JR6cGauWARm0+/LxSeSy+MgZHz82tiPY37aH4/l/yxKRl7wMiPXGiuM2ewJInwgww13 G3zuJtiSBtjrxN3kmzPdPC4xWGTU11zuaNs6xtKI7TECbt5NzikLON/PuXW0RMcckYWGSx1p6JHL1 2O68PAbkm51Ctk4EZjHLzsf+eJyltC3tJ4tyXvwfvDw8VbO9EMNVT6Vvx6x2cM4dZ0ZPlc8nEp3ql iqg2bJgZw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jxAeM-0004Qw-AY; Sun, 19 Jul 2020 14:50:47 +0000 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jxAeK-0004QP-0r for linux-arm-kernel@lists.infradead.org; Sun, 19 Jul 2020 14:50:45 +0000 Received: by mail-wr1-x442.google.com with SMTP id o11so15429521wrv.9 for ; Sun, 19 Jul 2020 07:50:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Kjfuse7dtGFuujC8xKQQtWkMq6uG/2iBu5hcp0AydUM=; b=AZK9wg1DXgX28pBbajcPDYLcnk43Qj2AOevWnTVuCv3yXTq/YELz1G0Ul7+v0eCTvi MB8sd7FdbuqGAmqXoixLVNffTzI1ihdrw0vfzSnsjg7D9YE3AikleRFunF4FC2sWR812 LnTu6JOitsoEo8RC226fRp1XmpzbZUSt5bZ/Twu8kr1Obc4g31r8afDCKhtLhx9qtVSE mCaeN/WLr2jN5zHwxkEjDR2wN/di4pYhQVImsgculyOyCowVaAEqltifGl9/mHLUZEeB KzzouGzgZl0OMEriHNc8zH1igfzHQOtCrYQXuLBOWkauFYI7txqSpkjWQo9IxKl7FEHE apHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Kjfuse7dtGFuujC8xKQQtWkMq6uG/2iBu5hcp0AydUM=; b=rwpj34eDmOe/ZIzulVYTV59aZV7/cYts0NVhUaXQJS39u5nUL/Ct1rxJeoJ0q22/4n eAXK472oO9CE7nJqKT/lr+4rOdD4xX/UX4PEfUQPCZW1jZhWAF+Vx9X3kC3yF9Q3oPAw eHM7a0CUwSpMmMgyGUu7DtSw/3M0wBmhI6+EzH/e128HTFENBg2yhiDOiQYvvbO7S0UB H260lfrHpnj/r1+oj11FCzxcpisDSlOWwEb/Awb6RVqegLtQ1g5mlUQtnsGxb73tVDmN JSgK4yyfk2SLonGpqsrq3/ksF1Y5779da/admqe4EJHWHO6ziuFnzLX/cSpMoJaxqc5C +uzg== X-Gm-Message-State: AOAM533YYkX7UJfxk+Lg9nrkWDg2RBOnrxjwdNg6pKYklf6Ya/X1w/1X hceprFgVvMnTfCkNUpQD0gU= X-Google-Smtp-Source: ABdhPJwslrlNgQRc5S4GUrNpBrqbecXCN9mawT9Cuuc1xNWEODhN9GtBzhV866bI9hjUba3kyC3HCg== X-Received: by 2002:adf:ee51:: with SMTP id w17mr2439713wro.239.1595170243004; Sun, 19 Jul 2020 07:50:43 -0700 (PDT) Received: from localhost.localdomain (arl-84-90-179-3.netvisao.pt. [84.90.179.3]) by smtp.gmail.com with ESMTPSA id d13sm26422755wrq.89.2020.07.19.07.50.41 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 Jul 2020 07:50:42 -0700 (PDT) From: miguelborgesdefreitas@gmail.com To: a.zummo@towertech.it Subject: [PATCH 1/2] rtc: pcf8523: Make DSM for battery switch-over configurable from DT Date: Sun, 19 Jul 2020 15:50:27 +0100 Message-Id: <20200719145028.3370-2-miguelborgesdefreitas@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200719145028.3370-1-miguelborgesdefreitas@gmail.com> References: <20200719145028.3370-1-miguelborgesdefreitas@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200719_105044_118404_70106383 X-CRM114-Status: GOOD ( 14.50 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, alexandre.belloni@bootlin.com, miguelborgesdefreitas@gmail.com, festevam@gmail.com, s.hauer@pengutronix.de, linux@armlinux.org.uk, linux-kernel@vger.kernel.org, robh+dt@kernel.org, linux-imx@nxp.com, kernel@pengutronix.de, shawnguo@kernel.org, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Miguel Borges de Freitas Signed-off-by: Miguel Borges de Freitas --- Documentation/devicetree/bindings/rtc/nxp,pcf8523.txt | 7 ++++++- Documentation/devicetree/bindings/rtc/rtc.yaml | 7 +++++++ drivers/rtc/rtc-pcf8523.c | 13 ++++++++++--- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/Documentation/devicetree/bindings/rtc/nxp,pcf8523.txt b/Documentation/devicetree/bindings/rtc/nxp,pcf8523.txt index 0b1080c..f715a8f 100644 --- a/Documentation/devicetree/bindings/rtc/nxp,pcf8523.txt +++ b/Documentation/devicetree/bindings/rtc/nxp,pcf8523.txt @@ -4,10 +4,14 @@ Required properties: - compatible: Should contain "nxp,pcf8523". - reg: I2C address for chip. -Optional property: +Optional properties: - quartz-load-femtofarads: The capacitive load of the quartz(x-tal), expressed in femto Farad (fF). Valid values are 7000 and 12500. Default value (if no value is specified) is 12500fF. +- pm-enable-dsm: battery switch-over function is enabled in direct + switching mode. The power failure condition happens when VDD < VBAT, + without requiring VDD to drop below Vth(sw)bat. + Default value (if not provided) is the standard mode. Example: @@ -15,4 +19,5 @@ pcf8523: rtc@68 { compatible = "nxp,pcf8523"; reg = <0x68>; quartz-load-femtofarads = <7000>; + pm-enable-dsm; }; diff --git a/Documentation/devicetree/bindings/rtc/rtc.yaml b/Documentation/devicetree/bindings/rtc/rtc.yaml index ee237b2..a0048f4 100644 --- a/Documentation/devicetree/bindings/rtc/rtc.yaml +++ b/Documentation/devicetree/bindings/rtc/rtc.yaml @@ -47,4 +47,11 @@ properties: description: Enables wake up of host system on alarm. + pm-enable-dsm: + $ref: /schemas/types.yaml#/definitions/flag + description: + Enables the battery switch-over function in direct switching + mode. Should be set in systems where VDD is higher than VBAT + at all times. + ... diff --git a/drivers/rtc/rtc-pcf8523.c b/drivers/rtc/rtc-pcf8523.c index 47e0f41..0c08f91 100644 --- a/drivers/rtc/rtc-pcf8523.c +++ b/drivers/rtc/rtc-pcf8523.c @@ -122,7 +122,7 @@ static int pcf8523_load_capacitance(struct i2c_client *client) return err; } -static int pcf8523_set_pm(struct i2c_client *client, u8 pm) +static int pcf8523_set_pm(struct i2c_client *client) { u8 value; int err; @@ -131,7 +131,10 @@ static int pcf8523_set_pm(struct i2c_client *client, u8 pm) if (err < 0) return err; - value = (value & ~REG_CONTROL3_PM_MASK) | pm; + if (of_property_read_bool(client->dev.of_node, "pm-enable-dsm")) + value = (value & ~REG_CONTROL3_PM_MASK) | REG_CONTROL3_PM_DSM; + else + value = (value & ~REG_CONTROL3_PM_MASK) | 0; err = pcf8523_write(client, REG_CONTROL3, value); if (err < 0) @@ -173,6 +176,10 @@ static int pcf8523_start_rtc(struct i2c_client *client) if (err < 0) return err; + err = pcf8523_set_pm(client); + if (err < 0) + return err; + return 0; } @@ -352,7 +359,7 @@ static int pcf8523_probe(struct i2c_client *client, dev_warn(&client->dev, "failed to set xtal load capacitance: %d", err); - err = pcf8523_set_pm(client, 0); + err = pcf8523_set_pm(client); if (err < 0) return err; -- 1.8.3.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel