blob: 5b160c8724d23867221030dc974a50e47b984ae1 [file] [log] [blame]
Angel Pons8a3453f2020-04-02 23:48:19 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Martin Rothcddd6002019-09-23 17:38:27 -06002
Furquan Shaikh76cedd22020-05-02 10:24:23 -07003#include <acpi/acpi_device.h>
Duncan Laurie7522dc32016-05-10 20:20:16 -07004
5#define NAU8825_MAX_BUTTONS 8
6
7/*
8 * Nuvoton NAU8825 audio codec devicetree bindings
9 * linux/Documentation/devicetree/bindings/sound/nau8825.txt
10 */
11struct drivers_i2c_nau8825_config {
12 /* Interrupt configuration */
13 struct acpi_irq irq;
Seven Leeb8159df2021-03-29 20:00:41 +080014 struct acpi_gpio irq_gpio;
Duncan Laurie7522dc32016-05-10 20:20:16 -070015
16 /* I2C Bus Frequency in Hertz (default 400kHz) */
Martin Roth38ddbfb2019-10-23 21:41:00 -060017 unsigned int bus_speed;
Duncan Laurie7522dc32016-05-10 20:20:16 -070018
19 /* Enable jack detection via JKDET pin */
Martin Roth38ddbfb2019-10-23 21:41:00 -060020 unsigned int jkdet_enable;
Duncan Laurie7522dc32016-05-10 20:20:16 -070021
22 /* Enable JKDET pin pull if set, otherwise high impedance state */
Martin Roth38ddbfb2019-10-23 21:41:00 -060023 unsigned int jkdet_pull_enable;
Duncan Laurie7522dc32016-05-10 20:20:16 -070024
25 /* Pull-up JKDET pin if set, otherwise pull down */
Martin Roth38ddbfb2019-10-23 21:41:00 -060026 unsigned int jkdet_pull_up;
Duncan Laurie7522dc32016-05-10 20:20:16 -070027
28 /* JKDET pin polarity, 0 => active high, 1 => active low */
Martin Roth38ddbfb2019-10-23 21:41:00 -060029 unsigned int jkdet_polarity;
Duncan Laurie7522dc32016-05-10 20:20:16 -070030
31 /*
32 * VREF Impedance selection
33 * 0 - Open
34 * 1 - 25 kOhm
35 * 2 - 125 kOhm
36 * 3 - 2.5 kOhm
37 */
Martin Roth38ddbfb2019-10-23 21:41:00 -060038 unsigned int vref_impedance;
Duncan Laurie7522dc32016-05-10 20:20:16 -070039
40 /* Button impedance measurement hysteresis */
Martin Roth38ddbfb2019-10-23 21:41:00 -060041 unsigned int sar_hysteresis;
Duncan Laurie7522dc32016-05-10 20:20:16 -070042
43 /*
44 * Reference voltage for button impedance measurement and micbias
45 * 0 - VDDA
46 * 1 - VDDA
47 * 2 - VDDA * 1.1
48 * 3 - VDDA * 1.2
49 * 4 - VDDA * 1.3
50 * 5 - VDDA * 1.4
51 * 6 - VDDA * 1.53
52 * 7 - VDDA * 1.53
53 */
Martin Roth38ddbfb2019-10-23 21:41:00 -060054 unsigned int micbias_voltage;
55 unsigned int sar_voltage;
Duncan Laurie7522dc32016-05-10 20:20:16 -070056
57 /*
58 * SAR compare time
59 * 0 - 500 ns
60 * 1 - 1 us
61 * 2 - 2 us
62 * 3 - 4 us
63 */
Martin Roth38ddbfb2019-10-23 21:41:00 -060064 unsigned int sar_compare_time;
Duncan Laurie7522dc32016-05-10 20:20:16 -070065
66 /*
67 * SAR sampling time
68 * 0 - 2 us
69 * 1 - 4 us
70 * 2 - 8 us
71 * 3 - 16 us
72 */
Martin Roth38ddbfb2019-10-23 21:41:00 -060073 unsigned int sar_sampling_time;
Duncan Laurie7522dc32016-05-10 20:20:16 -070074
75 /*
76 * Button short key press debounce time
77 * 0 - 30 ms
78 * 1 - 50 ms
79 * 2 - 100 ms
80 * 3 - 30 ms
81 */
Martin Roth38ddbfb2019-10-23 21:41:00 -060082 unsigned int short_key_debounce;
Duncan Laurie7522dc32016-05-10 20:20:16 -070083
84 /* Debounce time 2^(n+2) ms (0-7) for jack insert */
Martin Roth38ddbfb2019-10-23 21:41:00 -060085 unsigned int jack_insert_debounce;
Duncan Laurie7522dc32016-05-10 20:20:16 -070086
87 /* Debounce time 2^(n+2) ms (0-7) for jack eject */
Martin Roth38ddbfb2019-10-23 21:41:00 -060088 unsigned int jack_eject_debounce;
Duncan Laurie7522dc32016-05-10 20:20:16 -070089
90 /* Number of buttons supported, up to 8 */
Martin Roth38ddbfb2019-10-23 21:41:00 -060091 unsigned int sar_threshold_num;
Duncan Laurie7522dc32016-05-10 20:20:16 -070092
93 /*
94 * Impedance threshold for each button, up to 8
95 * SAR = 255 * micbias_voltage / sar_voltage * R / (2000 + R)
96 * R is Button impedance
97 */
98 uint64_t sar_threshold[NAU8825_MAX_BUTTONS];
99};