• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * Azoteq IQS620A/621/622/624/625 Multi-Function Sensors
4  *
5  * Copyright (C) 2019 Jeff LaBundy <jeff@labundy.com>
6  */
7 
8 #ifndef __LINUX_MFD_IQS62X_H
9 #define __LINUX_MFD_IQS62X_H
10 
11 #define IQS620_PROD_NUM				0x41
12 #define IQS621_PROD_NUM				0x46
13 #define IQS622_PROD_NUM				0x42
14 #define IQS624_PROD_NUM				0x43
15 #define IQS625_PROD_NUM				0x4E
16 
17 #define IQS621_ALS_FLAGS			0x16
18 #define IQS622_ALS_FLAGS			0x14
19 
20 #define IQS624_HALL_UI				0x70
21 #define IQS624_HALL_UI_WHL_EVENT		BIT(4)
22 #define IQS624_HALL_UI_INT_EVENT		BIT(3)
23 #define IQS624_HALL_UI_AUTO_CAL			BIT(2)
24 
25 #define IQS624_INTERVAL_DIV			0x7D
26 
27 #define IQS620_GLBL_EVENT_MASK			0xD7
28 #define IQS620_GLBL_EVENT_MASK_PMU		BIT(6)
29 
30 #define IQS62X_NUM_KEYS				16
31 #define IQS62X_NUM_EVENTS			(IQS62X_NUM_KEYS + 5)
32 
33 #define IQS62X_EVENT_SIZE			10
34 
35 enum iqs62x_ui_sel {
36 	IQS62X_UI_PROX,
37 	IQS62X_UI_SAR1,
38 };
39 
40 enum iqs62x_event_reg {
41 	IQS62X_EVENT_NONE,
42 	IQS62X_EVENT_SYS,
43 	IQS62X_EVENT_PROX,
44 	IQS62X_EVENT_HYST,
45 	IQS62X_EVENT_HALL,
46 	IQS62X_EVENT_ALS,
47 	IQS62X_EVENT_IR,
48 	IQS62X_EVENT_WHEEL,
49 	IQS62X_EVENT_INTER,
50 	IQS62X_EVENT_UI_LO,
51 	IQS62X_EVENT_UI_HI,
52 };
53 
54 enum iqs62x_event_flag {
55 	/* keys */
56 	IQS62X_EVENT_PROX_CH0_T,
57 	IQS62X_EVENT_PROX_CH0_P,
58 	IQS62X_EVENT_PROX_CH1_T,
59 	IQS62X_EVENT_PROX_CH1_P,
60 	IQS62X_EVENT_PROX_CH2_T,
61 	IQS62X_EVENT_PROX_CH2_P,
62 	IQS62X_EVENT_HYST_POS_T,
63 	IQS62X_EVENT_HYST_POS_P,
64 	IQS62X_EVENT_HYST_NEG_T,
65 	IQS62X_EVENT_HYST_NEG_P,
66 	IQS62X_EVENT_SAR1_ACT,
67 	IQS62X_EVENT_SAR1_QRD,
68 	IQS62X_EVENT_SAR1_MOVE,
69 	IQS62X_EVENT_SAR1_HALT,
70 	IQS62X_EVENT_WHEEL_UP,
71 	IQS62X_EVENT_WHEEL_DN,
72 
73 	/* switches */
74 	IQS62X_EVENT_HALL_N_T,
75 	IQS62X_EVENT_HALL_N_P,
76 	IQS62X_EVENT_HALL_S_T,
77 	IQS62X_EVENT_HALL_S_P,
78 
79 	/* everything else */
80 	IQS62X_EVENT_SYS_RESET,
81 };
82 
83 struct iqs62x_event_data {
84 	u16 ui_data;
85 	u8 als_flags;
86 	u8 ir_flags;
87 	u8 interval;
88 };
89 
90 struct iqs62x_event_desc {
91 	enum iqs62x_event_reg reg;
92 	u8 mask;
93 	u8 val;
94 };
95 
96 struct iqs62x_dev_desc {
97 	const char *dev_name;
98 	const struct mfd_cell *sub_devs;
99 	int num_sub_devs;
100 
101 	u8 prod_num;
102 	u8 sw_num;
103 	const u8 *cal_regs;
104 	int num_cal_regs;
105 
106 	u8 prox_mask;
107 	u8 sar_mask;
108 	u8 hall_mask;
109 	u8 hyst_mask;
110 	u8 temp_mask;
111 	u8 als_mask;
112 	u8 ir_mask;
113 
114 	u8 prox_settings;
115 	u8 als_flags;
116 	u8 hall_flags;
117 	u8 hyst_shift;
118 
119 	u8 interval;
120 	u8 interval_div;
121 
122 	u8 clk_div;
123 	const char *fw_name;
124 	const enum iqs62x_event_reg (*event_regs)[IQS62X_EVENT_SIZE];
125 };
126 
127 struct iqs62x_core {
128 	const struct iqs62x_dev_desc *dev_desc;
129 	struct i2c_client *client;
130 	struct regmap *regmap;
131 	struct blocking_notifier_head nh;
132 	struct list_head fw_blk_head;
133 	struct completion fw_done;
134 	enum iqs62x_ui_sel ui_sel;
135 };
136 
137 extern const struct iqs62x_event_desc iqs62x_events[IQS62X_NUM_EVENTS];
138 
139 #endif /* __LINUX_MFD_IQS62X_H */
140