LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Giulio Benetti <giulio.benetti@micronovasrl.com>
To: a.zummo@towertech.it
Cc: alexandre.belloni@bootlin.com, robh+dt@kernel.org,
	mark.rutland@arm.com, linux-rtc@vger.kernel.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	Giulio Benetti <giulio.benetti@micronovasrl.com>
Subject: [PATCH 4/4] rtc: ds1307: add frequency-test property to check calibration on m41txx
Date: Tue,  8 May 2018 16:56:11 +0200	[thread overview]
Message-ID: <20180508145611.49072-4-giulio.benetti@micronovasrl.com> (raw)
In-Reply-To: <20180508145611.49072-1-giulio.benetti@micronovasrl.com>

On m41txx you can enable open-drain OUT pin to check if calibration is ok.
Enabling OUT pin with frequency-test bool property, OUT pin will tick
512 times faster than 1s tick base.

Enable FT bit on CONTROL register if calibration is active.

Signed-off-by: Giulio Benetti <giulio.benetti@micronovasrl.com>
---
 Documentation/devicetree/bindings/rtc/rtc-ds1307.txt | 3 +++
 drivers/rtc/rtc-ds1307.c                             | 4 ++++
 2 files changed, 7 insertions(+)

diff --git a/Documentation/devicetree/bindings/rtc/rtc-ds1307.txt b/Documentation/devicetree/bindings/rtc/rtc-ds1307.txt
index d3d70a5495c5..72a5f8cdc306 100644
--- a/Documentation/devicetree/bindings/rtc/rtc-ds1307.txt
+++ b/Documentation/devicetree/bindings/rtc/rtc-ds1307.txt
@@ -36,6 +36,9 @@ Optional properties:
 	Should be given if internal trickle charger diode should be disabled
 - calibration: m41t0, m41t00, m41t11 only
 	Set calibration value to correct external bias, ranging between (-31) and 31.
+- frequency-test: m41t0, m41t00, m41t11 only
+	Enable open-drain OUT pin 512 times faster than 1 second tick.
+	This allows to check calibration value.
 
 Example:
 	rtc1: ds1339@68 {
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index 9cda52589c0f..a727ced157df 100644
--- a/drivers/rtc/rtc-ds1307.c
+++ b/drivers/rtc/rtc-ds1307.c
@@ -1485,6 +1485,10 @@ static int ds1307_probe(struct i2c_client *client,
 			if (calib >= 0)
 				out_byte |= M41TXX_BIT_CALIB_SIGN;
 
+			if (of_property_read_bool(client->dev.of_node,
+					"frequency-test"))
+				out_byte |= M41TXX_BIT_FT;
+
 			regmap_write(ds1307->regmap, M41TXX_REG_CONTROL,
 					out_byte);
 		}
-- 
2.17.0

  parent reply	other threads:[~2018-05-08 14:56 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-08 14:56 [PATCH 1/4] rtc: ds1307: fix data pointer to m41t0 Giulio Benetti
2018-05-08 14:56 ` [PATCH 2/4] rtc: ds1307: support m41t11 variant Giulio Benetti
2018-05-08 14:56 ` [PATCH 3/4] rtc: ds1307: add calibration of_ for mt41txx chips Giulio Benetti
2018-05-08 17:40   ` Rob Herring
2018-05-09 18:33     ` Giulio Benetti
2018-05-08 19:19   ` Alexandre Belloni
2018-05-09 18:31     ` Giulio Benetti
2018-05-08 14:56 ` Giulio Benetti [this message]
2018-05-08 17:44   ` [PATCH 4/4] rtc: ds1307: add frequency-test property to check calibration on m41txx Rob Herring
2018-05-09 18:32     ` Giulio Benetti

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180508145611.49072-4-giulio.benetti@micronovasrl.com \
    --to=giulio.benetti@micronovasrl.com \
    --cc=a.zummo@towertech.it \
    --cc=alexandre.belloni@bootlin.com \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rtc@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=robh+dt@kernel.org \
    --subject='Re: [PATCH 4/4] rtc: ds1307: add frequency-test property to check calibration on m41txx' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).