[PATCH v1 3/7] rtc-rv8803: add register definitions for rv8901 tamper detection

Markus Burri posted 7 patches 1 year ago
There is a newer version of this series
[PATCH v1 3/7] rtc-rv8803: add register definitions for rv8901 tamper detection
Posted by Markus Burri 1 year ago
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
Re: [PATCH v1 3/7] rtc-rv8803: add register definitions for rv8901 tamper detection
Posted by kernel test robot 1 year ago
Hi Markus,

kernel test robot noticed the following build warnings:

[auto build test WARNING on abelloni/rtc-next]
[also build test WARNING on robh/for-next linus/master v6.13-rc6 next-20250110]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Markus-Burri/dt-bindings-rtc-add-new-type-for-epson-rx8901/20250110-141934
base:   https://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux.git rtc-next
patch link:    https://lore.kernel.org/r/20250110061401.358371-4-markus.burri%40mt.com
patch subject: [PATCH v1 3/7] rtc-rv8803: add register definitions for rv8901 tamper detection
config: m68k-randconfig-r122-20250111 (https://download.01.org/0day-ci/archive/20250112/202501121203.Kw9SnPYP-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 14.2.0
reproduce: (https://download.01.org/0day-ci/archive/20250112/202501121203.Kw9SnPYP-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202501121203.Kw9SnPYP-lkp@intel.com/

sparse warnings: (new ones prefixed by >>)
>> drivers/rtc/rtc-rv8803.c:141:26: sparse: sparse: symbol 'pull_resistor_txt' was not declared. Should it be static?
>> drivers/rtc/rtc-rv8803.c:153:26: sparse: sparse: symbol 'trigger_txt' was not declared. Should it be static?
>> drivers/rtc/rtc-rv8803.c:161:26: sparse: sparse: symbol 'buffer_mode_txt' was not declared. Should it be static?
>> drivers/rtc/rtc-rv8803.c:167:26: sparse: sparse: symbol 'trg_status_txt' was not declared. Should it be static?

vim +/pull_resistor_txt +141 drivers/rtc/rtc-rv8803.c

   140	
 > 141	const struct cfg_val_txt pull_resistor_txt[] = {
   142		{ "no", no },
   143		{ "PU/500k", pull_up_500k },
   144		{ "PU/1M", pull_up_1M },
   145		{ "PU/10M", pull_up_10M },
   146		{ "PD/500k", pull_down_500k },
   147		{ "no", 0b101, 1 },
   148		{ "no", 0b110, 1 },
   149		{ "no", 0b111, 1 },
   150		{ NULL }
   151	};
   152	
 > 153	const struct cfg_val_txt trigger_txt[] = {
   154		{ "falling", falling_edge },
   155		{ "rising", rising_edge },
   156		{ "both", both_edges },
   157		{ "both", 0b11, 1 },
   158		{ NULL }
   159	};
   160	
 > 161	const struct cfg_val_txt buffer_mode_txt[] = {
   162		{ "inhibit", inhibit },
   163		{ "overwrite", overwrite },
   164		{ NULL }
   165	};
   166	
 > 167	const struct cfg_val_txt trg_status_txt[] = {
   168		{ "EVIN1", BIT(5) },
   169		{ "EVIN2", BIT(6) },
   170		{ "EVIN3", BIT(7) },
   171		{ "CMD", BIT(4) },
   172		{ "VBATL", BIT(3) },
   173		{ "VTMPL", BIT(2) },
   174		{ "VDDL", BIT(1) },
   175		{ "OSCSTP", BIT(0) },
   176		{ NULL }
   177	};
   178	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Re: [PATCH v1 3/7] rtc-rv8803: add register definitions for rv8901 tamper detection
Posted by Krzysztof Kozlowski 1 year ago
On Fri, Jan 10, 2025 at 07:13:57AM +0100, Markus Burri wrote:
> 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(+)
> 

There are no users of this. Don't add dead code. Probably you wanted to
add it for some usage, so add defines/structs WITH the users.

> 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[] = {

Why all these are not static? Where is the header exporting these?


Best regards,
Krzysztof