Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1076725ybh; Sun, 19 Jul 2020 07:54:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxU5uL7t6myBe4itKOiJ2oKLMELpDDSrn+kkhAoxejSOfYAOn/15u5TpghQrDHG48AnDfML X-Received: by 2002:a17:906:3e13:: with SMTP id k19mr16638152eji.476.1595170450426; Sun, 19 Jul 2020 07:54:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595170450; cv=none; d=google.com; s=arc-20160816; b=qWFPvcd8Ume2q23Qp/6mOGWEvxk4281cFsgPciej0KkW3+4Ft4tEzpLF5/zng+p2Wv wOinUXA5N18fw5/voTG0cJkpjps3lFBSx7u3Qb+b15YzgPc4+/tsJph8tBUb18oyojKR bd7bsDzm6m3xkVoW8BhvVnjjknah5cJG//br26pAH4aZgOE/EpABcuBBaj1c9Lkcdg2w SZgvIGc/YufRYCQUD/uS5BU3MawAYQ6vWhXQTU9pRNnpn3nFR0IWOHPMfGqPi2QFZMda 74SZvYLNX4ifaKcwxITvj8mWUH5klkmVuDz17pBlsdSYJrf0mYIDNdZCfi2aGxGl5eug L1NA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Kjfuse7dtGFuujC8xKQQtWkMq6uG/2iBu5hcp0AydUM=; b=Vkm1n30a9x2cvkN1l3Pv1KEmbM2cBK8IAzMEL6acrbT+74DzxTSQi4cDB4r6AGAw1T ROQMiWa3aP9BwwStbNZhqw/JUdu/NH1J8CIw8enlWS2VSI+SdMO5yQ+3bQa6pTY8RA8+ laaVEQfezOs99PllH34lxjQOVWOxM0SL3vWAcgdmg3+VdQYW3TCP9NTfZPYWnJVID2Oq fTnm4lLmQFQhuB/yjGcg+XJaiUcMCfwN1XHnxhnLOaMn9gYAW7hoTegAM9c7FCqt8kCS 5EIYg52qJSuhoO07n0z8YJ9jvnlNXVM3y9Pk70vLzObhO89YiQc6Zog1PDUArLDjgrMQ js2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=AZK9wg1D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s1si8674414edx.297.2020.07.19.07.53.47; Sun, 19 Jul 2020 07:54:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=AZK9wg1D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726264AbgGSOup (ORCPT + 99 others); Sun, 19 Jul 2020 10:50:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726024AbgGSOuo (ORCPT ); Sun, 19 Jul 2020 10:50:44 -0400 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 465C8C0619D2; Sun, 19 Jul 2020 07:50:44 -0700 (PDT) Received: by mail-wr1-x442.google.com with SMTP id s10so15378638wrw.12; Sun, 19 Jul 2020 07:50:44 -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=X9OKYMhe8bRLYhTPX0x8yPazt9hNIabrJzpWKPxDje2pLelyeS6dWoG0fsWVdyuCZF Q7ZM4+0VSnkSOglIduCDElMAg4I/bo4IRF/4VjYnONp3ndP1ZiVVMIBc5S4+fWY4Kuej t+ZfSzpVPK9nIymARqAJ4mxkemZjqdfXH5pdIK0jzffsQvJZ0Vpof/39KDfeYEA+BvUg TkSE84bT5jTIrIZcZ7YEbkEKP6/SGHf6P7/7+PQ2+xXwXhFf+d7nzQS6ry0uXoMuVTQ4 nEcgRVMXMXI/Qa5msdwqhalLGTCqiQT2j5eoPRt9a84Byc+T61CLTdtwqeewioPQOA9p 0//w== X-Gm-Message-State: AOAM530ahQT2GkRWNIiEqmtkW2Orz9tpotXL768ELG0BOKGTgB2jt+LK 6GNL+qwcg1FCkqSW+n4+Rmw= 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 Cc: linux@armlinux.org.uk, alexandre.belloni@bootlin.com, robh+dt@kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, miguelborgesdefreitas@gmail.com, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org 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 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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