From: Markus Burri <markus.burri@mt.com>
To: linux-kernel@vger.kernel.org
Cc: Markus Burri <markus.burri@mt.com>,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Manuel Traut <manuel.traut@mt.com>, Marek Vasut <marex@denx.de>,
linux-rtc@vger.kernel.org, devicetree@vger.kernel.org,
Markus Burri <markus.burri@bbv.ch>
Subject: [PATCH v4 4/7] rtc-rv8803: extend sysfs to trigger internal ts-event
Date: Wed, 21 May 2025 11:05:49 +0200 [thread overview]
Message-ID: <20250521090552.3173-5-markus.burri@mt.com> (raw)
In-Reply-To: <20250521090552.3173-1-markus.burri@mt.com>
Extend sysfs to trigger an internal time-stamp event.
The trigger function can be used from an application to trigger an
internal time-stamp event.
Signed-off-by: Markus Burri <markus.burri@mt.com>
Reviewed-by: Manuel Traut <manuel.traut@mt.com>
---
.../ABI/testing/sysfs-class-rtc-tamper | 7 ++++
drivers/rtc/rtc-rv8803.c | 33 +++++++++++++++++++
2 files changed, 40 insertions(+)
diff --git a/Documentation/ABI/testing/sysfs-class-rtc-tamper b/Documentation/ABI/testing/sysfs-class-rtc-tamper
index 3e61ed628c17..83b2fae1fc6e 100644
--- a/Documentation/ABI/testing/sysfs-class-rtc-tamper
+++ b/Documentation/ABI/testing/sysfs-class-rtc-tamper
@@ -18,4 +18,11 @@ Description: (RO) Attribute to read the stored timestamps form buffer FIFO.
- "1234.567 EVIN1=1" for a trigger from EVIN1 changed from low to high
- "1234.567 EVIN1=0 EVIN2=1 for a simultaneous trigger of EVIN1 changed to low and
EVIN2 changed to high.
+ - "1234.567 CMD=0" for a internal trigger
+What: /sys/class/rtc/rtcX/tamper/trigger
+Date: May 2025
+KernelVersion: 6.15
+Contact: Markus Burri <markus.burri@mt.com>
+Description: (WO) Attribute to trigger an internal timestamp event
+ Write a '1' to trigger an internal event and store a timestamp.
diff --git a/drivers/rtc/rtc-rv8803.c b/drivers/rtc/rtc-rv8803.c
index e367d37e6a8f..d0aac250774a 100644
--- a/drivers/rtc/rtc-rv8803.c
+++ b/drivers/rtc/rtc-rv8803.c
@@ -929,12 +929,45 @@ static ssize_t read_show(struct device *dev, struct device_attribute *attr, char
return offset;
}
+static ssize_t trigger_store(struct device *dev, struct device_attribute *attr, const char *buf,
+ size_t count)
+{
+ struct rv8803_data *rv8803 = dev_get_drvdata(dev->parent);
+ struct i2c_client *client = rv8803->client;
+ int ret;
+ unsigned long tmo;
+
+ guard(mutex)(&rv8803->flags_lock);
+
+ /* CMDTRGEN */
+ ret = rv8803_write_reg(client, RX8901_WRCMD_CFG, BIT(0));
+ if (ret < 0)
+ return ret;
+ ret = rv8803_write_reg(client, RX8901_WRCMD_TRG, 0xFF);
+ if (ret < 0)
+ return ret;
+
+ tmo = jiffies + msecs_to_jiffies(100); /* timeout 100ms */
+ do {
+ usleep_range(10, 2000);
+ ret = rv8803_read_reg(client, RX8901_WRCMD_TRG);
+ if (ret < 0)
+ return ret;
+ if (time_after(jiffies, tmo))
+ return -EBUSY;
+ } while (ret);
+
+ return count;
+}
+
static DEVICE_ATTR_WO(enable);
static DEVICE_ATTR_ADMIN_RO(read);
+static DEVICE_ATTR_WO(trigger);
static struct attribute *rv8803_rtc_event_attrs[] = {
&dev_attr_enable.attr,
&dev_attr_read.attr,
+ &dev_attr_trigger.attr,
NULL
};
--
2.39.5
next prev parent reply other threads:[~2025-05-21 9:06 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-21 9:05 [PATCH v4 0/7] rtc-rv8803: Implement timestamp trigger over event pins Markus Burri
2025-05-21 9:05 ` [PATCH v4 1/7] dt-bindings: rtc: add new type for epson,rx8901 Markus Burri
2025-05-27 6:43 ` Krzysztof Kozlowski
2025-05-21 9:05 ` [PATCH v4 2/7] rtc-rv8803: add new type for rv8901 Markus Burri
2025-05-21 9:05 ` [PATCH v4 3/7] rtc-rv8803: add tamper function to sysfs " Markus Burri
2025-05-21 9:05 ` Markus Burri [this message]
2025-05-21 9:05 ` [PATCH v4 5/7] rtc-rv8803: extend sysfs to read status Markus Burri
2025-05-21 9:05 ` [PATCH v4 6/7] dt-bindings: rtc-rv8803: add tamper detection property node Markus Burri
2025-05-27 6:42 ` Krzysztof Kozlowski
2025-05-21 9:05 ` [PATCH v4 7/7] rtc-rv8803: make tamper function configurable via dt Markus Burri
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=20250521090552.3173-5-markus.burri@mt.com \
--to=markus.burri@mt.com \
--cc=alexandre.belloni@bootlin.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rtc@vger.kernel.org \
--cc=manuel.traut@mt.com \
--cc=marex@denx.de \
--cc=markus.burri@bbv.ch \
--cc=robh@kernel.org \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox