1 /* SPDX-License-Identifier: GPL-2.0-or-later * 1 2 /* 3 * da7219-aad.h - DA7322 ASoC AAD Driver 4 * 5 * Copyright (c) 2015 Dialog Semiconductor Ltd 6 * 7 * Author: Adam Thomson <Adam.Thomson.Opensour 8 */ 9 10 #ifndef __DA7219_AAD_H 11 #define __DA7219_AAD_H 12 13 #include <linux/timer.h> 14 #include <linux/mutex.h> 15 #include <sound/soc.h> 16 #include <sound/jack.h> 17 #include <sound/da7219-aad.h> 18 19 /* 20 * Registers 21 */ 22 23 #define DA7219_ACCDET_STATUS_A 0xC0 24 #define DA7219_ACCDET_STATUS_B 0xC1 25 #define DA7219_ACCDET_IRQ_EVENT_A 0xC2 26 #define DA7219_ACCDET_IRQ_EVENT_B 0xC3 27 #define DA7219_ACCDET_IRQ_MASK_A 0xC4 28 #define DA7219_ACCDET_IRQ_MASK_B 0xC5 29 #define DA7219_ACCDET_CONFIG_1 0xC6 30 #define DA7219_ACCDET_CONFIG_2 0xC7 31 #define DA7219_ACCDET_CONFIG_3 0xC8 32 #define DA7219_ACCDET_CONFIG_4 0xC9 33 #define DA7219_ACCDET_CONFIG_5 0xCA 34 #define DA7219_ACCDET_CONFIG_6 0xCB 35 #define DA7219_ACCDET_CONFIG_7 0xCC 36 #define DA7219_ACCDET_CONFIG_8 0xCD 37 38 39 /* 40 * Bit Fields 41 */ 42 43 /* DA7219_ACCDET_STATUS_A = 0xC0 */ 44 #define DA7219_JACK_INSERTION_STS_SHIFT 0 45 #define DA7219_JACK_INSERTION_STS_MASK (0x1 < 46 #define DA7219_JACK_TYPE_STS_SHIFT 1 47 #define DA7219_JACK_TYPE_STS_MASK (0x1 < 48 #define DA7219_JACK_PIN_ORDER_STS_SHIFT 2 49 #define DA7219_JACK_PIN_ORDER_STS_MASK (0x1 < 50 #define DA7219_MICBIAS_UP_STS_SHIFT 3 51 #define DA7219_MICBIAS_UP_STS_MASK (0x1 < 52 53 /* DA7219_ACCDET_STATUS_B = 0xC1 */ 54 #define DA7219_BUTTON_TYPE_STS_SHIFT 0 55 #define DA7219_BUTTON_TYPE_STS_MASK (0xFF 56 57 /* DA7219_ACCDET_IRQ_EVENT_A = 0xC2 */ 58 #define DA7219_E_JACK_INSERTED_SHIFT 59 #define DA7219_E_JACK_INSERTED_MASK 60 #define DA7219_E_JACK_REMOVED_SHIFT 61 #define DA7219_E_JACK_REMOVED_MASK 62 #define DA7219_E_JACK_DETECT_COMPLETE_SHIFT 63 #define DA7219_E_JACK_DETECT_COMPLETE_MASK 64 65 /* DA7219_ACCDET_IRQ_EVENT_B = 0xC3 */ 66 #define DA7219_E_BUTTON_A_PRESSED_SHIFT 67 #define DA7219_E_BUTTON_A_PRESSED_MASK 68 #define DA7219_E_BUTTON_B_PRESSED_SHIFT 69 #define DA7219_E_BUTTON_B_PRESSED_MASK 70 #define DA7219_E_BUTTON_C_PRESSED_SHIFT 71 #define DA7219_E_BUTTON_C_PRESSED_MASK 72 #define DA7219_E_BUTTON_D_PRESSED_SHIFT 73 #define DA7219_E_BUTTON_D_PRESSED_MASK 74 #define DA7219_E_BUTTON_D_RELEASED_SHIFT 75 #define DA7219_E_BUTTON_D_RELEASED_MASK 76 #define DA7219_E_BUTTON_C_RELEASED_SHIFT 77 #define DA7219_E_BUTTON_C_RELEASED_MASK 78 #define DA7219_E_BUTTON_B_RELEASED_SHIFT 79 #define DA7219_E_BUTTON_B_RELEASED_MASK 80 #define DA7219_E_BUTTON_A_RELEASED_SHIFT 81 #define DA7219_E_BUTTON_A_RELEASED_MASK 82 83 /* DA7219_ACCDET_IRQ_MASK_A = 0xC4 */ 84 #define DA7219_M_JACK_INSERTED_SHIFT 85 #define DA7219_M_JACK_INSERTED_MASK 86 #define DA7219_M_JACK_REMOVED_SHIFT 87 #define DA7219_M_JACK_REMOVED_MASK 88 #define DA7219_M_JACK_DETECT_COMPLETE_SHIFT 89 #define DA7219_M_JACK_DETECT_COMPLETE_MASK 90 91 /* DA7219_ACCDET_IRQ_MASK_B = 0xC5 */ 92 #define DA7219_M_BUTTON_A_PRESSED_SHIFT 93 #define DA7219_M_BUTTON_A_PRESSED_MASK 94 #define DA7219_M_BUTTON_B_PRESSED_SHIFT 95 #define DA7219_M_BUTTON_B_PRESSED_MASK 96 #define DA7219_M_BUTTON_C_PRESSED_SHIFT 97 #define DA7219_M_BUTTON_C_PRESSED_MASK 98 #define DA7219_M_BUTTON_D_PRESSED_SHIFT 99 #define DA7219_M_BUTTON_D_PRESSED_MASK 100 #define DA7219_M_BUTTON_D_RELEASED_SHIFT 101 #define DA7219_M_BUTTON_D_RELEASED_MASK 102 #define DA7219_M_BUTTON_C_RELEASED_SHIFT 103 #define DA7219_M_BUTTON_C_RELEASED_MASK 104 #define DA7219_M_BUTTON_B_RELEASED_SHIFT 105 #define DA7219_M_BUTTON_B_RELEASED_MASK 106 #define DA7219_M_BUTTON_A_RELEASED_SHIFT 107 #define DA7219_M_BUTTON_A_RELEASED_MASK 108 109 /* DA7219_ACCDET_CONFIG_1 = 0xC6 */ 110 #define DA7219_ACCDET_EN_SHIFT 0 111 #define DA7219_ACCDET_EN_MASK (0x1 < 112 #define DA7219_BUTTON_CONFIG_SHIFT 1 113 #define DA7219_BUTTON_CONFIG_MASK (0x7 < 114 #define DA7219_MIC_DET_THRESH_SHIFT 4 115 #define DA7219_MIC_DET_THRESH_MASK (0x3 < 116 #define DA7219_JACK_TYPE_DET_EN_SHIFT 6 117 #define DA7219_JACK_TYPE_DET_EN_MASK (0x1 < 118 #define DA7219_PIN_ORDER_DET_EN_SHIFT 7 119 #define DA7219_PIN_ORDER_DET_EN_MASK (0x1 < 120 121 /* DA7219_ACCDET_CONFIG_2 = 0xC7 */ 122 #define DA7219_ACCDET_PAUSE_SHIFT 0 123 #define DA7219_ACCDET_PAUSE_MASK (0x1 < 124 #define DA7219_JACKDET_DEBOUNCE_SHIFT 1 125 #define DA7219_JACKDET_DEBOUNCE_MASK (0x7 < 126 #define DA7219_JACK_DETECT_RATE_SHIFT 4 127 #define DA7219_JACK_DETECT_RATE_MASK (0x3 < 128 #define DA7219_JACKDET_REM_DEB_SHIFT 6 129 #define DA7219_JACKDET_REM_DEB_MASK (0x3 < 130 131 /* DA7219_ACCDET_CONFIG_3 = 0xC8 */ 132 #define DA7219_A_D_BUTTON_THRESH_SHIFT 0 133 #define DA7219_A_D_BUTTON_THRESH_MASK (0xFF 134 135 /* DA7219_ACCDET_CONFIG_4 = 0xC9 */ 136 #define DA7219_D_B_BUTTON_THRESH_SHIFT 0 137 #define DA7219_D_B_BUTTON_THRESH_MASK (0xFF 138 139 /* DA7219_ACCDET_CONFIG_5 = 0xCA */ 140 #define DA7219_B_C_BUTTON_THRESH_SHIFT 0 141 #define DA7219_B_C_BUTTON_THRESH_MASK (0xFF 142 143 /* DA7219_ACCDET_CONFIG_6 = 0xCB */ 144 #define DA7219_C_MIC_BUTTON_THRESH_SHIFT 145 #define DA7219_C_MIC_BUTTON_THRESH_MASK 146 147 /* DA7219_ACCDET_CONFIG_7 = 0xCC */ 148 #define DA7219_BUTTON_AVERAGE_SHIFT 0 149 #define DA7219_BUTTON_AVERAGE_MASK (0x3 < 150 #define DA7219_ADC_1_BIT_REPEAT_SHIFT 2 151 #define DA7219_ADC_1_BIT_REPEAT_MASK (0x3 < 152 #define DA7219_PIN_ORDER_FORCE_SHIFT 4 153 #define DA7219_PIN_ORDER_FORCE_MASK (0x1 < 154 #define DA7219_JACK_TYPE_FORCE_SHIFT 5 155 #define DA7219_JACK_TYPE_FORCE_MASK (0x1 < 156 157 /* DA7219_ACCDET_CONFIG_8 = 0xCD */ 158 #define DA7219_HPTEST_EN_SHIFT 0 159 #define DA7219_HPTEST_EN_MASK (0x1 < 160 #define DA7219_HPTEST_RES_SEL_SHIFT 1 161 #define DA7219_HPTEST_RES_SEL_MASK (0x3 < 162 #define DA7219_HPTEST_RES_SEL_1KOHMS (0x0 < 163 #define DA7219_HPTEST_COMP_SHIFT 4 164 #define DA7219_HPTEST_COMP_MASK (0x1 < 165 166 167 #define DA7219_AAD_MAX_BUTTONS 4 168 #define DA7219_AAD_REPORT_ALL_MASK (SND_J 169 SND_J 170 SND_J 171 SND_J 172 173 #define DA7219_AAD_MICBIAS_CHK_DELAY 10 174 #define DA7219_AAD_MICBIAS_CHK_RETRIES 5 175 176 #define DA7219_AAD_HPTEST_RAMP_FREQ 177 #define DA7219_AAD_HPTEST_RAMP_FREQ_INT_OSC 178 #define DA7219_AAD_HPTEST_PERIOD 179 #define DA7219_AAD_HPTEST_INT_OSC_PATH_DELAY 180 181 enum da7219_aad_event_regs { 182 DA7219_AAD_IRQ_REG_A = 0, 183 DA7219_AAD_IRQ_REG_B, 184 DA7219_AAD_IRQ_REG_MAX, 185 }; 186 187 /* Private data */ 188 struct da7219_aad_priv { 189 struct snd_soc_component *component; 190 int irq; 191 int gnd_switch_delay; 192 193 u8 micbias_pulse_lvl; 194 u32 micbias_pulse_time; 195 196 u8 btn_cfg; 197 198 struct work_struct btn_det_work; 199 struct work_struct hptest_work; 200 struct delayed_work jack_det_work; 201 struct workqueue_struct *aad_wq; 202 203 struct snd_soc_jack *jack; 204 bool micbias_resume_enable; 205 bool jack_inserted; 206 }; 207 208 /* AAD control */ 209 void da7219_aad_jack_det(struct snd_soc_compon 210 211 /* Suspend/Resume */ 212 void da7219_aad_suspend(struct snd_soc_compone 213 void da7219_aad_resume(struct snd_soc_componen 214 215 /* Init/Exit */ 216 int da7219_aad_init(struct snd_soc_component * 217 void da7219_aad_exit(struct snd_soc_component 218 219 /* I2C Probe */ 220 int da7219_aad_probe(struct i2c_client *i2c); 221 222 #endif /* __DA7219_AAD_H */ 223
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.