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>, Marek Vasut <marex@denx.de>,
linux-rtc@vger.kernel.org, devicetree@vger.kernel.org,
Manuel Traut <manuel.traut@mt.com>
Subject: [PATCH v1 3/7] rtc-rv8803: add register definitions for rv8901 tamper detection
Date: Fri, 10 Jan 2025 07:13:57 +0100 [thread overview]
Message-ID: <20250110061401.358371-4-markus.burri@mt.com> (raw)
In-Reply-To: <20250110061401.358371-1-markus.burri@mt.com>
Add register definition and string mapping for rv8901 tamper detection.
Signed-off-by: Markus Burri <markus.burri@mt.com>
---
drivers/rtc/rtc-rv8803.c | 122 +++++++++++++++++++++++++++++++++++++++
1 file changed, 122 insertions(+)
diff --git a/drivers/rtc/rtc-rv8803.c b/drivers/rtc/rtc-rv8803.c
index 50fbae9..a4f2f53 100644
--- a/drivers/rtc/rtc-rv8803.c
+++ b/drivers/rtc/rtc-rv8803.c
@@ -58,6 +58,53 @@
#define RX8900_FLAG_SWOFF BIT(2)
#define RX8900_FLAG_VDETOFF BIT(3)
+#define RX8901_EVIN_EN 0x20
+#define RX8901_EVIN1_CFG 0x21
+#define RX8901_EVIN2_CFG 0x23
+#define RX8901_EVIN3_CFG 0x25
+#define RX8901_EVENTx_CFG_POL GENMASK(1, 0)
+#define RX8901_EVENTx_CFG_PUPD GENMASK(4, 2)
+
+#define RX8901_EVIN1_FLT 0x22
+#define RX8901_EVIN2_FLT 0x24
+#define RX8901_EVIN3_FLT 0x26
+
+#define RX8901_BUF1_CFG1 0x27
+#define RX8901_BUF2_CFG1 0x2A
+#define RX8901_BUF3_CFG1 0x2D
+
+#define RX8901_BUF1_STAT 0x28
+#define RX8901_BUF2_STAT 0x2B
+#define RX8901_BUF3_STAT 0x2E
+#define RX8901_BUFx_STAT_PTR GENMASK(5, 0)
+#define RX8901_BUFx_STAT_EMPTF BIT(6)
+#define RX8901_BUFx_STAT_FULLF BIT(7)
+
+#define RX8901_BUF1_CFG2 0x29
+#define RX8901_BUF2_CFG2 0x2C
+#define RX8901_BUF3_CFG2 0x2F
+
+#define RX8901_WRCMD_CFG 0x41
+#define RX8901_WRCMD_TRG 0x42
+
+#define RX8901_EVNT_INTE 0x43
+#define RX8901_CAP_EN 0x44
+
+#define RX8901_BUF_INTF 0x46
+#define RX8901_BUF_INTF_BUF1F BIT(5)
+
+#define RX8901_EVNT_INTF 0x47
+#define RX8901_EVNT_INTF_VBATLEVF BIT(3)
+#define RX8901_EVNT_INTF_EVIN1F BIT(5)
+
+#define RX8901_BUF_OVWF 0x4F
+
+#define NO_OF_EVIN 3
+
+#define EVIN_FILTER_FACTOR 125
+#define EVIN_FILTER_MAX 40
+#define EV_READ_MAX_LINE_SIZE 96
+
enum rv8803_type {
rv_8803,
rx_8803,
@@ -66,6 +113,81 @@ enum rv8803_type {
rx_8901,
};
+enum evin_pull_resistor {
+ no = 0b000,
+ pull_up_500k = 0b001,
+ pull_up_1M = 0b010,
+ pull_up_10M = 0b011,
+ pull_down_500k = 0b100,
+};
+
+enum evin_trigger {
+ falling_edge = 0b00,
+ rising_edge = 0b01,
+ both_edges = 0b10,
+};
+
+enum evin_buffer_mode {
+ inhibit = 0,
+ overwrite = 1,
+};
+
+struct cfg_val_txt {
+ char *txt;
+ u8 val;
+ bool hide;
+};
+
+const struct cfg_val_txt pull_resistor_txt[] = {
+ { "no", no },
+ { "PU/500k", pull_up_500k },
+ { "PU/1M", pull_up_1M },
+ { "PU/10M", pull_up_10M },
+ { "PD/500k", pull_down_500k },
+ { "no", 0b101, 1 },
+ { "no", 0b110, 1 },
+ { "no", 0b111, 1 },
+ { NULL }
+};
+
+const struct cfg_val_txt trigger_txt[] = {
+ { "falling", falling_edge },
+ { "rising", rising_edge },
+ { "both", both_edges },
+ { "both", 0b11, 1 },
+ { NULL }
+};
+
+const struct cfg_val_txt buffer_mode_txt[] = {
+ { "inhibit", inhibit },
+ { "overwrite", overwrite },
+ { NULL }
+};
+
+const struct cfg_val_txt trg_status_txt[] = {
+ { "EVIN1", BIT(5) },
+ { "EVIN2", BIT(6) },
+ { "EVIN3", BIT(7) },
+ { "CMD", BIT(4) },
+ { "VBATL", BIT(3) },
+ { "VTMPL", BIT(2) },
+ { "VDDL", BIT(1) },
+ { "OSCSTP", BIT(0) },
+ { NULL }
+};
+
+static const u8 evin_cfg_reg[] = {
+ RX8901_EVIN1_CFG,
+ RX8901_EVIN2_CFG,
+ RX8901_EVIN3_CFG
+};
+
+static const u8 evin_flt_reg[] = {
+ RX8901_EVIN1_FLT,
+ RX8901_EVIN2_FLT,
+ RX8901_EVIN3_FLT
+};
+
struct rv8803_data {
struct i2c_client *client;
struct rtc_device *rtc;
--
2.39.5
next prev parent reply other threads:[~2025-01-10 6:14 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-10 6:13 [PATCH v1 0/7] rtc-rv8803: Implement timestamp trigger over event pins Markus Burri
2025-01-10 6:13 ` [PATCH v1 1/7] dt-bindings: rtc: add new type for epson,rx8901 Markus Burri
2025-01-11 10:20 ` Krzysztof Kozlowski
2025-01-11 10:26 ` Krzysztof Kozlowski
2025-01-10 6:13 ` [PATCH v1 2/7] rtc-rv8803: add new type for rv8901 Markus Burri
2025-01-10 6:13 ` Markus Burri [this message]
2025-01-11 10:21 ` [PATCH v1 3/7] rtc-rv8803: add register definitions for rv8901 tamper detection Krzysztof Kozlowski
2025-01-12 4:52 ` kernel test robot
2025-01-10 6:13 ` [PATCH v1 4/7] rtc-rv8803: add tamper function to sysfs for rv8901 Markus Burri
2025-01-11 10:24 ` Krzysztof Kozlowski
2025-01-10 6:13 ` [PATCH v1 5/7] rtc-rv8803: extend sysfs to trigger internal ts-event Markus Burri
2025-01-11 10:24 ` Krzysztof Kozlowski
2025-01-10 6:14 ` [PATCH v1 6/7] rtc-rv8803: make tamper function configurable via sysfs Markus Burri
2025-01-11 10:28 ` Krzysztof Kozlowski
2025-01-10 6:14 ` [PATCH v1 7/7] rtc-rv8803: extend sysfs to read ts-event and buffer status 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=20250110061401.358371-4-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=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