1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  * Copyright (C) 2022 ROHM Semiconductors
4  *
5  * ROHM/KIONIX KX022A accelerometer driver
6  */
7 
8 #ifndef _KX022A_H_
9 #define _KX022A_H_
10 
11 #include <linux/bits.h>
12 #include <linux/regmap.h>
13 
14 #define KX022A_REG_WHO		0x0f
15 #define KX022A_ID		0xc8
16 
17 #define KX022A_REG_CNTL2	0x19
18 #define KX022A_MASK_SRST	BIT(7)
19 #define KX022A_REG_CNTL		0x18
20 #define KX022A_MASK_PC1		BIT(7)
21 #define KX022A_MASK_RES		BIT(6)
22 #define KX022A_MASK_DRDY	BIT(5)
23 #define KX022A_MASK_GSEL	GENMASK(4, 3)
24 #define KX022A_GSEL_SHIFT	3
25 #define KX022A_GSEL_2		0x0
26 #define KX022A_GSEL_4		BIT(3)
27 #define KX022A_GSEL_8		BIT(4)
28 #define KX022A_GSEL_16		GENMASK(4, 3)
29 
30 #define KX022A_REG_INS2		0x13
31 #define KX022A_MASK_INS2_DRDY	BIT(4)
32 #define KX122_MASK_INS2_WMI	BIT(5)
33 
34 #define KX022A_REG_XHP_L	0x0
35 #define KX022A_REG_XOUT_L	0x06
36 #define KX022A_REG_YOUT_L	0x08
37 #define KX022A_REG_ZOUT_L	0x0a
38 #define KX022A_REG_COTR		0x0c
39 #define KX022A_REG_TSCP		0x10
40 #define KX022A_REG_INT_REL	0x17
41 
42 #define KX022A_REG_ODCNTL	0x1b
43 
44 #define KX022A_REG_BTS_WUF_TH	0x31
45 #define KX022A_REG_MAN_WAKE	0x2c
46 
47 #define KX022A_REG_BUF_CNTL1	0x3a
48 #define KX022A_MASK_WM_TH	GENMASK(6, 0)
49 #define KX022A_REG_BUF_CNTL2	0x3b
50 #define KX022A_MASK_BUF_EN	BIT(7)
51 #define KX022A_MASK_BRES16	BIT(6)
52 #define KX022A_REG_BUF_STATUS_1	0x3c
53 #define KX022A_REG_BUF_STATUS_2	0x3d
54 #define KX022A_REG_BUF_CLEAR	0x3e
55 #define KX022A_REG_BUF_READ	0x3f
56 #define KX022A_MASK_ODR		GENMASK(3, 0)
57 #define KX022A_ODR_SHIFT	3
58 #define KX022A_FIFO_MAX_WMI_TH	41
59 
60 #define KX022A_REG_INC1		0x1c
61 #define KX022A_REG_INC5		0x20
62 #define KX022A_REG_INC6		0x21
63 #define KX022A_MASK_IEN		BIT(5)
64 #define KX022A_MASK_IPOL	BIT(4)
65 #define KX022A_IPOL_LOW		0
66 #define KX022A_IPOL_HIGH	KX022A_MASK_IPOL1
67 #define KX022A_MASK_ITYP	BIT(3)
68 #define KX022A_ITYP_PULSE	KX022A_MASK_ITYP
69 #define KX022A_ITYP_LEVEL	0
70 
71 #define KX022A_REG_INC4		0x1f
72 #define KX022A_MASK_WMI		BIT(5)
73 
74 #define KX022A_REG_SELF_TEST	0x60
75 #define KX022A_MAX_REGISTER	0x60
76 
77 struct device;
78 
79 int kx022a_probe_internal(struct device *dev);
80 extern const struct regmap_config kx022a_regmap;
81 
82 #endif
83