Angel Pons | 8a3453f | 2020-04-02 23:48:19 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Martin Roth | cddd600 | 2019-09-23 17:38:27 -0600 | [diff] [blame] | 2 | |
Furquan Shaikh | 76cedd2 | 2020-05-02 10:24:23 -0700 | [diff] [blame] | 3 | #include <acpi/acpi_device.h> |
Duncan Laurie | 7522dc3 | 2016-05-10 20:20:16 -0700 | [diff] [blame] | 4 | |
| 5 | #define NAU8825_MAX_BUTTONS 8 |
| 6 | |
| 7 | /* |
| 8 | * Nuvoton NAU8825 audio codec devicetree bindings |
| 9 | * linux/Documentation/devicetree/bindings/sound/nau8825.txt |
| 10 | */ |
| 11 | struct drivers_i2c_nau8825_config { |
| 12 | /* Interrupt configuration */ |
| 13 | struct acpi_irq irq; |
Seven Lee | b8159df | 2021-03-29 20:00:41 +0800 | [diff] [blame^] | 14 | struct acpi_gpio irq_gpio; |
Duncan Laurie | 7522dc3 | 2016-05-10 20:20:16 -0700 | [diff] [blame] | 15 | |
| 16 | /* I2C Bus Frequency in Hertz (default 400kHz) */ |
Martin Roth | 38ddbfb | 2019-10-23 21:41:00 -0600 | [diff] [blame] | 17 | unsigned int bus_speed; |
Duncan Laurie | 7522dc3 | 2016-05-10 20:20:16 -0700 | [diff] [blame] | 18 | |
| 19 | /* Enable jack detection via JKDET pin */ |
Martin Roth | 38ddbfb | 2019-10-23 21:41:00 -0600 | [diff] [blame] | 20 | unsigned int jkdet_enable; |
Duncan Laurie | 7522dc3 | 2016-05-10 20:20:16 -0700 | [diff] [blame] | 21 | |
| 22 | /* Enable JKDET pin pull if set, otherwise high impedance state */ |
Martin Roth | 38ddbfb | 2019-10-23 21:41:00 -0600 | [diff] [blame] | 23 | unsigned int jkdet_pull_enable; |
Duncan Laurie | 7522dc3 | 2016-05-10 20:20:16 -0700 | [diff] [blame] | 24 | |
| 25 | /* Pull-up JKDET pin if set, otherwise pull down */ |
Martin Roth | 38ddbfb | 2019-10-23 21:41:00 -0600 | [diff] [blame] | 26 | unsigned int jkdet_pull_up; |
Duncan Laurie | 7522dc3 | 2016-05-10 20:20:16 -0700 | [diff] [blame] | 27 | |
| 28 | /* JKDET pin polarity, 0 => active high, 1 => active low */ |
Martin Roth | 38ddbfb | 2019-10-23 21:41:00 -0600 | [diff] [blame] | 29 | unsigned int jkdet_polarity; |
Duncan Laurie | 7522dc3 | 2016-05-10 20:20:16 -0700 | [diff] [blame] | 30 | |
| 31 | /* |
| 32 | * VREF Impedance selection |
| 33 | * 0 - Open |
| 34 | * 1 - 25 kOhm |
| 35 | * 2 - 125 kOhm |
| 36 | * 3 - 2.5 kOhm |
| 37 | */ |
Martin Roth | 38ddbfb | 2019-10-23 21:41:00 -0600 | [diff] [blame] | 38 | unsigned int vref_impedance; |
Duncan Laurie | 7522dc3 | 2016-05-10 20:20:16 -0700 | [diff] [blame] | 39 | |
| 40 | /* Button impedance measurement hysteresis */ |
Martin Roth | 38ddbfb | 2019-10-23 21:41:00 -0600 | [diff] [blame] | 41 | unsigned int sar_hysteresis; |
Duncan Laurie | 7522dc3 | 2016-05-10 20:20:16 -0700 | [diff] [blame] | 42 | |
| 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 Roth | 38ddbfb | 2019-10-23 21:41:00 -0600 | [diff] [blame] | 54 | unsigned int micbias_voltage; |
| 55 | unsigned int sar_voltage; |
Duncan Laurie | 7522dc3 | 2016-05-10 20:20:16 -0700 | [diff] [blame] | 56 | |
| 57 | /* |
| 58 | * SAR compare time |
| 59 | * 0 - 500 ns |
| 60 | * 1 - 1 us |
| 61 | * 2 - 2 us |
| 62 | * 3 - 4 us |
| 63 | */ |
Martin Roth | 38ddbfb | 2019-10-23 21:41:00 -0600 | [diff] [blame] | 64 | unsigned int sar_compare_time; |
Duncan Laurie | 7522dc3 | 2016-05-10 20:20:16 -0700 | [diff] [blame] | 65 | |
| 66 | /* |
| 67 | * SAR sampling time |
| 68 | * 0 - 2 us |
| 69 | * 1 - 4 us |
| 70 | * 2 - 8 us |
| 71 | * 3 - 16 us |
| 72 | */ |
Martin Roth | 38ddbfb | 2019-10-23 21:41:00 -0600 | [diff] [blame] | 73 | unsigned int sar_sampling_time; |
Duncan Laurie | 7522dc3 | 2016-05-10 20:20:16 -0700 | [diff] [blame] | 74 | |
| 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 Roth | 38ddbfb | 2019-10-23 21:41:00 -0600 | [diff] [blame] | 82 | unsigned int short_key_debounce; |
Duncan Laurie | 7522dc3 | 2016-05-10 20:20:16 -0700 | [diff] [blame] | 83 | |
| 84 | /* Debounce time 2^(n+2) ms (0-7) for jack insert */ |
Martin Roth | 38ddbfb | 2019-10-23 21:41:00 -0600 | [diff] [blame] | 85 | unsigned int jack_insert_debounce; |
Duncan Laurie | 7522dc3 | 2016-05-10 20:20:16 -0700 | [diff] [blame] | 86 | |
| 87 | /* Debounce time 2^(n+2) ms (0-7) for jack eject */ |
Martin Roth | 38ddbfb | 2019-10-23 21:41:00 -0600 | [diff] [blame] | 88 | unsigned int jack_eject_debounce; |
Duncan Laurie | 7522dc3 | 2016-05-10 20:20:16 -0700 | [diff] [blame] | 89 | |
| 90 | /* Number of buttons supported, up to 8 */ |
Martin Roth | 38ddbfb | 2019-10-23 21:41:00 -0600 | [diff] [blame] | 91 | unsigned int sar_threshold_num; |
Duncan Laurie | 7522dc3 | 2016-05-10 20:20:16 -0700 | [diff] [blame] | 92 | |
| 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 | }; |