xref: /aosp_15_r20/external/coreboot/src/drivers/i2c/nau8825/chip.h (revision b9411a12aaaa7e1e6a6fb7c5e057f44ee179a49c)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #ifndef __DRIVERS_I2C_NAU8825_CHIP_H__
4 #define __DRIVERS_I2C_NAU8825_CHIP_H__
5 
6 #include <acpi/acpi_device.h>
7 
8 #define NAU8825_MAX_BUTTONS 8
9 
10 /*
11  * Nuvoton NAU8825 audio codec devicetree bindings
12  * linux/Documentation/devicetree/bindings/sound/nau8825.txt
13  */
14 struct drivers_i2c_nau8825_config {
15 	/* Interrupt configuration */
16 	struct acpi_irq irq;
17 	struct acpi_gpio irq_gpio;
18 
19 	/* I2C Bus Frequency in Hertz (default 400kHz) */
20 	unsigned int bus_speed;
21 
22 	/* Enable jack detection via JKDET pin */
23 	unsigned int jkdet_enable;
24 
25 	/* Enable JKDET pin pull if set, otherwise high impedance state */
26 	unsigned int jkdet_pull_enable;
27 
28 	/* Pull-up JKDET pin if set, otherwise pull down */
29 	unsigned int jkdet_pull_up;
30 
31 	/* JKDET pin polarity, 0 => active high, 1 => active low */
32 	unsigned int jkdet_polarity;
33 
34 	/*
35 	 * VREF Impedance selection
36 	 *  0 - Open
37 	 *  1 - 25 kOhm
38 	 *  2 - 125 kOhm
39 	 *  3 - 2.5 kOhm
40 	 */
41 	unsigned int vref_impedance;
42 
43 	/* Button impedance measurement hysteresis */
44 	unsigned int sar_hysteresis;
45 
46 	/*
47 	 * Reference voltage for button impedance measurement and micbias
48 	 *  0 - VDDA
49 	 *  1 - VDDA
50 	 *  2 - VDDA * 1.1
51 	 *  3 - VDDA * 1.2
52 	 *  4 - VDDA * 1.3
53 	 *  5 - VDDA * 1.4
54 	 *  6 - VDDA * 1.53
55 	 *  7 - VDDA * 1.53
56 	 */
57 	unsigned int micbias_voltage;
58 	unsigned int sar_voltage;
59 
60 	/*
61 	 * SAR compare time
62 	 *  0 - 500 ns
63 	 *  1 - 1 us
64 	 *  2 - 2 us
65 	 *  3 - 4 us
66 	 */
67 	unsigned int sar_compare_time;
68 
69 	/*
70 	 * SAR sampling time
71 	 *  0 - 2 us
72 	 *  1 - 4 us
73 	 *  2 - 8 us
74 	 *  3 - 16 us
75 	 */
76 	unsigned int sar_sampling_time;
77 
78 	/*
79 	 * Button short key press debounce time
80 	 *  0 - 30 ms
81 	 *  1 - 50 ms
82 	 *  2 - 100 ms
83 	 *  3 - 30 ms
84 	 */
85 	unsigned int short_key_debounce;
86 
87 	/* Debounce time 2^(n+2) ms (0-7) for jack insert */
88 	unsigned int jack_insert_debounce;
89 
90 	/* Debounce time 2^(n+2) ms (0-7) for jack eject */
91 	unsigned int jack_eject_debounce;
92 
93 	/* Number of buttons supported, up to 8 */
94 	unsigned int sar_threshold_num;
95 
96 	/*
97 	 * Impedance threshold for each button, up to 8
98 	 *  SAR = 255 * micbias_voltage / sar_voltage * R / (2000 + R)
99 	 *  R is Button impedance
100 	 */
101 	uint64_t sar_threshold[NAU8825_MAX_BUTTONS];
102 
103 	/* Make the drive strength of ADCOUT IO PIN strong if set.
104 	 * Otherwise, the drive keeps normal strength.
105 	 */
106 	bool adcout_ds;
107 };
108 
109 #endif /* __DRIVERS_I2C_NAU8825_CHIP_H__ */
110