xref: /aosp_15_r20/external/coreboot/src/drivers/i2c/sx9324/chip.h (revision b9411a12aaaa7e1e6a6fb7c5e057f44ee179a49c)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #ifndef __DRIVERS_I2C_SX9324_CHIP_H__
4 #define __DRIVERS_I2C_SX9324_CHIP_H__
5 
6 #include <acpi/acpi_device.h>
7 #include <device/i2c_simple.h>
8 
9 #define REGISTER(NAME) uint8_t NAME
10 
11 struct drivers_i2c_sx9324_config {
12 	/* Device Description */
13 	const char *desc;
14 
15 	/* ACPI _UID */
16 	unsigned int uid;
17 
18 	/* Bus speed in Hz, default is I2C_SPEED_FAST */
19 	enum i2c_speed speed;
20 
21 	/* Use GPIO-based interrupt instead of IO-APIC */
22 	struct acpi_gpio irq_gpio;
23 
24 	/* IO-APIC interrupt */
25 	struct acpi_irq irq;
26 
27 	/*
28 	semtech,ph0-pin:
29 	  description: |
30 	    Array of 3 entries. Index represent the id of the CS pin.
31 	    Value indicates how each CS pin is used during phase 0.
32 	    Each of the 3 pins have the following value -
33 	    0 : unused (high impedance)
34 	    1 : measured input
35 	    2 : dynamic shield
36 	    3 : grounded.
37 	    For instance, CS0 measured, CS1 shield and CS2 ground is [1, 2, 3]
38 	  items:
39 	    enum: [ 0, 1, 2, 3 ]
40 	  minItems: 3
41 	  maxItems: 3
42 	*/
43 	uint64_t ph0_pin[3];
44 
45 	/*
46 	semtech,ph1-pin:
47 	  Same as ph0-pin for phase 1.
48 	*/
49 	uint64_t ph1_pin[3];
50 
51 	/*
52 	semtech,ph2-pin:
53 	  Same as ph0-pin for phase 2.
54 	*/
55 	uint64_t ph2_pin[3];
56 
57 	/*
58 	semtech,ph3-pin:
59 	  Same as ph0-pin for phase 3.
60 	*/
61 	uint64_t ph3_pin[3];
62 
63 	/*
64 	semtech,ph01-resolution:
65 	  enum: [8, 16, 32, 64, 128, 256, 512, 1024]
66 	  description:
67 	    Capacitance measurement resolution. For phase 0 and 1.
68 	    Higher the number, higher the resolution.
69 	  default: 128
70 	*/
71 	uint64_t ph01_resolution;
72 
73 	/*
74 	semtech,ph23-resolution:
75 	  Same as ph01-resolution for phase 2 and 3.
76 	*/
77 	uint64_t ph23_resolution;
78 
79 	/*
80 	semtech,startup-sensor:
81 	  enum: [0, 1, 2, 3]
82 	  default: 0
83 	  description: |
84 	    Phase used for start-up proximity detection.
85 	    It is used when we enable a phase to remove static offset and measure
86 	    only capacitance changes introduced by the user.
87 	*/
88 	uint64_t startup_sensor;
89 
90 	/*
91 	semtech,ph01-proxraw-strength:
92 	  minimum: 0
93 	  maximum: 7
94 	  default: 1
95 	  description:
96 	    PROXRAW filter strength for phase 0 and 1. A value of 0 represents off,
97 	    and other values represent 1-1/2^N.
98 	*/
99 	uint64_t ph01_proxraw_strength;
100 
101 	/*
102 	semtech,ph23-proxraw-strength:
103 	  Same as proxraw-strength01, for phase 2 and 3.
104 	*/
105 	uint64_t ph23_proxraw_strength;
106 
107 	/*
108 	semtech,avg-pos-strength:
109 	  enum: [0, 16, 64, 128, 256, 512, 1024, 4294967295]
110 	  default: 16
111 	  description: |
112 	    Average positive filter strength. A value of 0 represents off and
113 	    UINT_MAX (4294967295) represents infinite. Other values
114 	    represent 1-1/N.
115 	*/
116 	uint64_t avg_pos_strength;
117 
118 	/*
119 	semtech,cs-idle-sleep:
120 	  description:
121 	    State of CS pins during sleep mode and idle time.
122 	  enum:
123 	    - hi-z
124 	    - gnd
125 	    - vdd
126 	*/
127 	const char *cs_idle_sleep;
128 
129 	/*
130 	semtech,int-comp-resistor:
131 	  description:
132 	    Internal resistor setting for compensation.
133 	  enum:
134 	    - lowest
135 	    - low
136 	    - high
137 	    - highest
138 	*/
139 	const char *int_comp_resistor;
140 
141 	/*
142 	semtech,input-precharge-resistor-ohms:
143 	  default: 4000
144 	  multipleOf: 2000
145 	  minimum: 0
146 	  maximum: 30000
147 	  description:
148 	    Pre-charge input resistance in Ohm.
149 	*/
150 	uint64_t input_precharge_resistor_ohms;
151 
152 	/*
153 	semtech,input-analog-gain:
154 	  minimum: 0
155 	  maximum: 3
156 	  description: |
157 	    Defines the input antenna analog gain
158 	    0: x1.247
159 	    1: x1 (default)
160 	    2: x0.768
161 	    3: x0.552
162 	*/
163 	uint64_t input_analog_gain;
164 
165 #if CONFIG(DRIVERS_I2C_SX9324_SUPPORT_LEGACY_LINUX_DRIVER)
166 #include "registers.h"
167 #endif
168 };
169 
170 #undef REGISTER
171 
172 #endif /* __DRIVERS_I2C_SX9324_CHIP_H__ */
173