1d2912cb1SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */ 2dfeabdedSJohn Hsu /* 3dfeabdedSJohn Hsu * NAU88L24 ALSA SoC audio driver 4dfeabdedSJohn Hsu * 5dfeabdedSJohn Hsu * Copyright 2016 Nuvoton Technology Corp. 6dfeabdedSJohn Hsu * Author: John Hsu <KCHSU0@nuvoton.com> 7dfeabdedSJohn Hsu */ 8dfeabdedSJohn Hsu 9dfeabdedSJohn Hsu #ifndef __NAU8824_H__ 10dfeabdedSJohn Hsu #define __NAU8824_H__ 11dfeabdedSJohn Hsu 12dfeabdedSJohn Hsu #define NAU8824_REG_RESET 0x00 13dfeabdedSJohn Hsu #define NAU8824_REG_ENA_CTRL 0x01 14dfeabdedSJohn Hsu #define NAU8824_REG_CLK_GATING_ENA 0x02 15dfeabdedSJohn Hsu #define NAU8824_REG_CLK_DIVIDER 0x03 16dfeabdedSJohn Hsu #define NAU8824_REG_FLL1 0x04 17dfeabdedSJohn Hsu #define NAU8824_REG_FLL2 0x05 18dfeabdedSJohn Hsu #define NAU8824_REG_FLL3 0x06 19dfeabdedSJohn Hsu #define NAU8824_REG_FLL4 0x07 20dfeabdedSJohn Hsu #define NAU8824_REG_FLL5 0x08 21dfeabdedSJohn Hsu #define NAU8824_REG_FLL6 0x09 22dfeabdedSJohn Hsu #define NAU8824_REG_FLL_VCO_RSV 0x0A 23dfeabdedSJohn Hsu #define NAU8824_REG_JACK_DET_CTRL 0x0D 24dfeabdedSJohn Hsu #define NAU8824_REG_INTERRUPT_SETTING_1 0x0F 25dfeabdedSJohn Hsu #define NAU8824_REG_IRQ 0x10 26dfeabdedSJohn Hsu #define NAU8824_REG_CLEAR_INT_REG 0x11 27dfeabdedSJohn Hsu #define NAU8824_REG_INTERRUPT_SETTING 0x12 28dfeabdedSJohn Hsu #define NAU8824_REG_SAR_ADC 0x13 29dfeabdedSJohn Hsu #define NAU8824_REG_VDET_COEFFICIENT 0x14 30dfeabdedSJohn Hsu #define NAU8824_REG_VDET_THRESHOLD_1 0x15 31dfeabdedSJohn Hsu #define NAU8824_REG_VDET_THRESHOLD_2 0x16 32dfeabdedSJohn Hsu #define NAU8824_REG_VDET_THRESHOLD_3 0x17 33dfeabdedSJohn Hsu #define NAU8824_REG_VDET_THRESHOLD_4 0x18 34dfeabdedSJohn Hsu #define NAU8824_REG_GPIO_SEL 0x1A 35dfeabdedSJohn Hsu #define NAU8824_REG_PORT0_I2S_PCM_CTRL_1 0x1C 36dfeabdedSJohn Hsu #define NAU8824_REG_PORT0_I2S_PCM_CTRL_2 0x1D 37dfeabdedSJohn Hsu #define NAU8824_REG_PORT0_LEFT_TIME_SLOT 0x1E 38dfeabdedSJohn Hsu #define NAU8824_REG_PORT0_RIGHT_TIME_SLOT 0x1F 39dfeabdedSJohn Hsu #define NAU8824_REG_TDM_CTRL 0x20 40dfeabdedSJohn Hsu #define NAU8824_REG_ADC_HPF_FILTER 0x23 41dfeabdedSJohn Hsu #define NAU8824_REG_ADC_FILTER_CTRL 0x24 42dfeabdedSJohn Hsu #define NAU8824_REG_DAC_FILTER_CTRL_1 0x25 43dfeabdedSJohn Hsu #define NAU8824_REG_DAC_FILTER_CTRL_2 0x26 44dfeabdedSJohn Hsu #define NAU8824_REG_NOTCH_FILTER_1 0x27 45dfeabdedSJohn Hsu #define NAU8824_REG_NOTCH_FILTER_2 0x28 46dfeabdedSJohn Hsu #define NAU8824_REG_EQ1_LOW 0x29 47dfeabdedSJohn Hsu #define NAU8824_REG_EQ2_EQ3 0x2A 48dfeabdedSJohn Hsu #define NAU8824_REG_EQ4_EQ5 0x2B 49dfeabdedSJohn Hsu #define NAU8824_REG_ADC_CH0_DGAIN_CTRL 0x2D 50dfeabdedSJohn Hsu #define NAU8824_REG_ADC_CH1_DGAIN_CTRL 0x2E 51dfeabdedSJohn Hsu #define NAU8824_REG_ADC_CH2_DGAIN_CTRL 0x2F 52dfeabdedSJohn Hsu #define NAU8824_REG_ADC_CH3_DGAIN_CTRL 0x30 53dfeabdedSJohn Hsu #define NAU8824_REG_DAC_MUTE_CTRL 0x31 54dfeabdedSJohn Hsu #define NAU8824_REG_DAC_CH0_DGAIN_CTRL 0x32 55dfeabdedSJohn Hsu #define NAU8824_REG_DAC_CH1_DGAIN_CTRL 0x33 56dfeabdedSJohn Hsu #define NAU8824_REG_ADC_TO_DAC_ST 0x34 57dfeabdedSJohn Hsu #define NAU8824_REG_DRC_KNEE_IP12_ADC_CH01 0x38 58dfeabdedSJohn Hsu #define NAU8824_REG_DRC_KNEE_IP34_ADC_CH01 0x39 59dfeabdedSJohn Hsu #define NAU8824_REG_DRC_SLOPE_ADC_CH01 0x3A 60dfeabdedSJohn Hsu #define NAU8824_REG_DRC_ATKDCY_ADC_CH01 0x3B 61dfeabdedSJohn Hsu #define NAU8824_REG_DRC_KNEE_IP12_ADC_CH23 0x3C 62dfeabdedSJohn Hsu #define NAU8824_REG_DRC_KNEE_IP34_ADC_CH23 0x3D 63dfeabdedSJohn Hsu #define NAU8824_REG_DRC_SLOPE_ADC_CH23 0x3E 64dfeabdedSJohn Hsu #define NAU8824_REG_DRC_ATKDCY_ADC_CH23 0x3F 65dfeabdedSJohn Hsu #define NAU8824_REG_DRC_GAINL_ADC0 0x40 66dfeabdedSJohn Hsu #define NAU8824_REG_DRC_GAINL_ADC1 0x41 67dfeabdedSJohn Hsu #define NAU8824_REG_DRC_GAINL_ADC2 0x42 68dfeabdedSJohn Hsu #define NAU8824_REG_DRC_GAINL_ADC3 0x43 69dfeabdedSJohn Hsu #define NAU8824_REG_DRC_KNEE_IP12_DAC 0x45 70dfeabdedSJohn Hsu #define NAU8824_REG_DRC_KNEE_IP34_DAC 0x46 71dfeabdedSJohn Hsu #define NAU8824_REG_DRC_SLOPE_DAC 0x47 72dfeabdedSJohn Hsu #define NAU8824_REG_DRC_ATKDCY_DAC 0x48 73dfeabdedSJohn Hsu #define NAU8824_REG_DRC_GAIN_DAC_CH0 0x49 74dfeabdedSJohn Hsu #define NAU8824_REG_DRC_GAIN_DAC_CH1 0x4A 75dfeabdedSJohn Hsu #define NAU8824_REG_MODE 0x4C 76dfeabdedSJohn Hsu #define NAU8824_REG_MODE1 0x4D 77dfeabdedSJohn Hsu #define NAU8824_REG_MODE2 0x4E 78dfeabdedSJohn Hsu #define NAU8824_REG_CLASSG 0x50 79dfeabdedSJohn Hsu #define NAU8824_REG_OTP_EFUSE 0x51 80dfeabdedSJohn Hsu #define NAU8824_REG_OTPDOUT_1 0x53 81dfeabdedSJohn Hsu #define NAU8824_REG_OTPDOUT_2 0x54 82dfeabdedSJohn Hsu #define NAU8824_REG_MISC_CTRL 0x55 83dfeabdedSJohn Hsu #define NAU8824_REG_I2C_TIMEOUT 0x56 84dfeabdedSJohn Hsu #define NAU8824_REG_TEST_MODE 0x57 85dfeabdedSJohn Hsu #define NAU8824_REG_I2C_DEVICE_ID 0x58 86dfeabdedSJohn Hsu #define NAU8824_REG_SAR_ADC_DATA_OUT 0x59 87dfeabdedSJohn Hsu #define NAU8824_REG_BIAS_ADJ 0x66 88dfeabdedSJohn Hsu #define NAU8824_REG_PGA_GAIN 0x67 89dfeabdedSJohn Hsu #define NAU8824_REG_TRIM_SETTINGS 0x68 90dfeabdedSJohn Hsu #define NAU8824_REG_ANALOG_CONTROL_1 0x69 91dfeabdedSJohn Hsu #define NAU8824_REG_ANALOG_CONTROL_2 0x6A 92dfeabdedSJohn Hsu #define NAU8824_REG_ENABLE_LO 0x6B 93dfeabdedSJohn Hsu #define NAU8824_REG_GAIN_LO 0x6C 94dfeabdedSJohn Hsu #define NAU8824_REG_CLASSD_GAIN_1 0x6D 95dfeabdedSJohn Hsu #define NAU8824_REG_CLASSD_GAIN_2 0x6E 96dfeabdedSJohn Hsu #define NAU8824_REG_ANALOG_ADC_1 0x71 97dfeabdedSJohn Hsu #define NAU8824_REG_ANALOG_ADC_2 0x72 98dfeabdedSJohn Hsu #define NAU8824_REG_RDAC 0x73 99dfeabdedSJohn Hsu #define NAU8824_REG_MIC_BIAS 0x74 100dfeabdedSJohn Hsu #define NAU8824_REG_HS_VOLUME_CONTROL 0x75 101dfeabdedSJohn Hsu #define NAU8824_REG_BOOST 0x76 102dfeabdedSJohn Hsu #define NAU8824_REG_FEPGA 0x77 103dfeabdedSJohn Hsu #define NAU8824_REG_FEPGA_II 0x78 104dfeabdedSJohn Hsu #define NAU8824_REG_FEPGA_SE 0x79 105dfeabdedSJohn Hsu #define NAU8824_REG_FEPGA_ATTENUATION 0x7A 106dfeabdedSJohn Hsu #define NAU8824_REG_ATT_PORT0 0x7B 107dfeabdedSJohn Hsu #define NAU8824_REG_ATT_PORT1 0x7C 108dfeabdedSJohn Hsu #define NAU8824_REG_POWER_UP_CONTROL 0x7F 109dfeabdedSJohn Hsu #define NAU8824_REG_CHARGE_PUMP_CONTROL 0x80 110dfeabdedSJohn Hsu #define NAU8824_REG_CHARGE_PUMP_INPUT 0x81 111dfeabdedSJohn Hsu #define NAU8824_REG_MAX NAU8824_REG_CHARGE_PUMP_INPUT 112dfeabdedSJohn Hsu /* 16-bit control register address, and 16-bits control register data */ 113dfeabdedSJohn Hsu #define NAU8824_REG_ADDR_LEN 16 114dfeabdedSJohn Hsu #define NAU8824_REG_DATA_LEN 16 115dfeabdedSJohn Hsu 116dfeabdedSJohn Hsu 117dfeabdedSJohn Hsu /* ENA_CTRL (0x1) */ 118dfeabdedSJohn Hsu #define NAU8824_DMIC_LCH_EDGE_CH23 (0x1 << 12) 119dfeabdedSJohn Hsu #define NAU8824_DMIC_LCH_EDGE_CH01 (0x1 << 11) 120dfeabdedSJohn Hsu #define NAU8824_JD_SLEEP_MODE (0x1 << 10) 121dfeabdedSJohn Hsu #define NAU8824_ADC_CH3_DMIC_SFT 9 122dfeabdedSJohn Hsu #define NAU8824_ADC_CH3_DMIC_EN (0x1 << NAU8824_ADC_CH3_DMIC_SFT) 123dfeabdedSJohn Hsu #define NAU8824_ADC_CH2_DMIC_SFT 8 124dfeabdedSJohn Hsu #define NAU8824_ADC_CH2_DMIC_EN (0x1 << NAU8824_ADC_CH2_DMIC_SFT) 125dfeabdedSJohn Hsu #define NAU8824_ADC_CH1_DMIC_SFT 7 126dfeabdedSJohn Hsu #define NAU8824_ADC_CH1_DMIC_EN (0x1 << NAU8824_ADC_CH1_DMIC_SFT) 127dfeabdedSJohn Hsu #define NAU8824_ADC_CH0_DMIC_SFT 6 128dfeabdedSJohn Hsu #define NAU8824_ADC_CH0_DMIC_EN (0x1 << NAU8824_ADC_CH0_DMIC_SFT) 129dfeabdedSJohn Hsu #define NAU8824_DAC_CH1_EN (0x1 << 5) 130dfeabdedSJohn Hsu #define NAU8824_DAC_CH0_EN (0x1 << 4) 131dfeabdedSJohn Hsu #define NAU8824_ADC_CH3_EN (0x1 << 3) 132dfeabdedSJohn Hsu #define NAU8824_ADC_CH2_EN (0x1 << 2) 133dfeabdedSJohn Hsu #define NAU8824_ADC_CH1_EN (0x1 << 1) 134dfeabdedSJohn Hsu #define NAU8824_ADC_CH0_EN 0x1 135dfeabdedSJohn Hsu 136dfeabdedSJohn Hsu /* CLK_GATING_ENA (0x02) */ 137dfeabdedSJohn Hsu #define NAU8824_CLK_ADC_CH23_EN (0x1 << 15) 138dfeabdedSJohn Hsu #define NAU8824_CLK_ADC_CH01_EN (0x1 << 14) 139dfeabdedSJohn Hsu #define NAU8824_CLK_DAC_CH1_EN (0x1 << 13) 140dfeabdedSJohn Hsu #define NAU8824_CLK_DAC_CH0_EN (0x1 << 12) 141dfeabdedSJohn Hsu #define NAU8824_CLK_I2S_EN (0x1 << 7) 142dfeabdedSJohn Hsu #define NAU8824_CLK_GAIN_EN (0x1 << 5) 143dfeabdedSJohn Hsu #define NAU8824_CLK_SAR_EN (0x1 << 3) 144dfeabdedSJohn Hsu #define NAU8824_CLK_DMIC_CH23_EN (0x1 << 1) 145dfeabdedSJohn Hsu 146dfeabdedSJohn Hsu /* CLK_DIVIDER (0x3) */ 147dfeabdedSJohn Hsu #define NAU8824_CLK_SRC_SFT 15 148dfeabdedSJohn Hsu #define NAU8824_CLK_SRC_MASK (1 << NAU8824_CLK_SRC_SFT) 149dfeabdedSJohn Hsu #define NAU8824_CLK_SRC_VCO (1 << NAU8824_CLK_SRC_SFT) 150dfeabdedSJohn Hsu #define NAU8824_CLK_SRC_MCLK (0 << NAU8824_CLK_SRC_SFT) 151dfeabdedSJohn Hsu #define NAU8824_CLK_MCLK_SRC_MASK (0xf << 0) 152dfeabdedSJohn Hsu #define NAU8824_CLK_DMIC_SRC_SFT 10 153dfeabdedSJohn Hsu #define NAU8824_CLK_DMIC_SRC_MASK (0x7 << NAU8824_CLK_DMIC_SRC_SFT) 154dfeabdedSJohn Hsu #define NAU8824_CLK_ADC_SRC_SFT 6 155dfeabdedSJohn Hsu #define NAU8824_CLK_ADC_SRC_MASK (0x3 << NAU8824_CLK_ADC_SRC_SFT) 156dfeabdedSJohn Hsu #define NAU8824_CLK_DAC_SRC_SFT 4 157dfeabdedSJohn Hsu #define NAU8824_CLK_DAC_SRC_MASK (0x3 << NAU8824_CLK_DAC_SRC_SFT) 158dfeabdedSJohn Hsu 159dfeabdedSJohn Hsu /* FLL1 (0x04) */ 160dfeabdedSJohn Hsu #define NAU8824_FLL_RATIO_MASK (0x7f << 0) 161dfeabdedSJohn Hsu 162dfeabdedSJohn Hsu /* FLL3 (0x06) */ 163dfeabdedSJohn Hsu #define NAU8824_FLL_INTEGER_MASK (0x3ff << 0) 164dfeabdedSJohn Hsu #define NAU8824_FLL_CLK_SRC_SFT 10 165dfeabdedSJohn Hsu #define NAU8824_FLL_CLK_SRC_MASK (0x3 << NAU8824_FLL_CLK_SRC_SFT) 166dfeabdedSJohn Hsu #define NAU8824_FLL_CLK_SRC_MCLK (0 << NAU8824_FLL_CLK_SRC_SFT) 167dfeabdedSJohn Hsu #define NAU8824_FLL_CLK_SRC_BLK (0x2 << NAU8824_FLL_CLK_SRC_SFT) 168dfeabdedSJohn Hsu #define NAU8824_FLL_CLK_SRC_FS (0x3 << NAU8824_FLL_CLK_SRC_SFT) 169dfeabdedSJohn Hsu 170dfeabdedSJohn Hsu /* FLL4 (0x07) */ 171dfeabdedSJohn Hsu #define NAU8824_FLL_REF_DIV_SFT 10 172dfeabdedSJohn Hsu #define NAU8824_FLL_REF_DIV_MASK (0x3 << NAU8824_FLL_REF_DIV_SFT) 173dfeabdedSJohn Hsu 174dfeabdedSJohn Hsu /* FLL5 (0x08) */ 175dfeabdedSJohn Hsu #define NAU8824_FLL_PDB_DAC_EN (0x1 << 15) 176dfeabdedSJohn Hsu #define NAU8824_FLL_LOOP_FTR_EN (0x1 << 14) 177dfeabdedSJohn Hsu #define NAU8824_FLL_CLK_SW_MASK (0x1 << 13) 178dfeabdedSJohn Hsu #define NAU8824_FLL_CLK_SW_N2 (0x1 << 13) 179dfeabdedSJohn Hsu #define NAU8824_FLL_CLK_SW_REF (0x0 << 13) 180dfeabdedSJohn Hsu #define NAU8824_FLL_FTR_SW_MASK (0x1 << 12) 181dfeabdedSJohn Hsu #define NAU8824_FLL_FTR_SW_ACCU (0x1 << 12) 182dfeabdedSJohn Hsu #define NAU8824_FLL_FTR_SW_FILTER (0x0 << 12) 183dfeabdedSJohn Hsu 184dfeabdedSJohn Hsu /* FLL6 (0x9) */ 185dfeabdedSJohn Hsu #define NAU8824_DCO_EN (0x1 << 15) 186dfeabdedSJohn Hsu #define NAU8824_SDM_EN (0x1 << 14) 187dfeabdedSJohn Hsu 188dfeabdedSJohn Hsu /* IRQ (0x10) */ 189dfeabdedSJohn Hsu #define NAU8824_SHORT_CIRCUIT_IRQ (0x1 << 7) 190dfeabdedSJohn Hsu #define NAU8824_IMPEDANCE_MEAS_IRQ (0x1 << 6) 191dfeabdedSJohn Hsu #define NAU8824_KEY_RELEASE_IRQ (0x1 << 5) 192dfeabdedSJohn Hsu #define NAU8824_KEY_LONG_PRESS_IRQ (0x1 << 4) 193dfeabdedSJohn Hsu #define NAU8824_KEY_SHORT_PRESS_IRQ (0x1 << 3) 194dfeabdedSJohn Hsu #define NAU8824_JACK_EJECTION_DETECTED (0x1 << 1) 195dfeabdedSJohn Hsu #define NAU8824_JACK_INSERTION_DETECTED 0x1 196dfeabdedSJohn Hsu 197dfeabdedSJohn Hsu /* JACK_DET_CTRL (0x0D) */ 198dfeabdedSJohn Hsu #define NAU8824_JACK_EJECT_DT_SFT 2 199dfeabdedSJohn Hsu #define NAU8824_JACK_EJECT_DT_MASK (0x3 << NAU8824_JACK_EJECT_DT_SFT) 200d316597cSHans de Goede #define NAU8824_JACK_LOGIC (0x1 << 1) 201dfeabdedSJohn Hsu 202dfeabdedSJohn Hsu 203dfeabdedSJohn Hsu /* INTERRUPT_SETTING_1 (0x0F) */ 204dfeabdedSJohn Hsu #define NAU8824_IRQ_EJECT_EN (0x1 << 9) 205dfeabdedSJohn Hsu #define NAU8824_IRQ_INSERT_EN (0x1 << 8) 206dfeabdedSJohn Hsu 207dfeabdedSJohn Hsu /* INTERRUPT_SETTING (0x12) */ 208dfeabdedSJohn Hsu #define NAU8824_IRQ_KEY_RELEASE_DIS (0x1 << 5) 209dfeabdedSJohn Hsu #define NAU8824_IRQ_KEY_SHORT_PRESS_DIS (0x1 << 3) 210dfeabdedSJohn Hsu #define NAU8824_IRQ_EJECT_DIS (0x1 << 1) 211dfeabdedSJohn Hsu #define NAU8824_IRQ_INSERT_DIS 0x1 212dfeabdedSJohn Hsu 213dfeabdedSJohn Hsu /* SAR_ADC (0x13) */ 214dfeabdedSJohn Hsu #define NAU8824_SAR_ADC_EN_SFT 12 215dfeabdedSJohn Hsu #define NAU8824_SAR_TRACKING_GAIN_SFT 8 216dfeabdedSJohn Hsu #define NAU8824_SAR_TRACKING_GAIN_MASK (0x7 << NAU8824_SAR_TRACKING_GAIN_SFT) 217dfeabdedSJohn Hsu #define NAU8824_SAR_COMPARE_TIME_SFT 2 218dfeabdedSJohn Hsu #define NAU8824_SAR_COMPARE_TIME_MASK (3 << 2) 219dfeabdedSJohn Hsu #define NAU8824_SAR_SAMPLING_TIME_SFT 0 220dfeabdedSJohn Hsu #define NAU8824_SAR_SAMPLING_TIME_MASK (3 << 0) 221dfeabdedSJohn Hsu 222dfeabdedSJohn Hsu /* VDET_COEFFICIENT (0x14) */ 223dfeabdedSJohn Hsu #define NAU8824_SHORTKEY_DEBOUNCE_SFT 12 224dfeabdedSJohn Hsu #define NAU8824_SHORTKEY_DEBOUNCE_MASK (0x3 << NAU8824_SHORTKEY_DEBOUNCE_SFT) 225dfeabdedSJohn Hsu #define NAU8824_LEVELS_NR_SFT 8 226dfeabdedSJohn Hsu #define NAU8824_LEVELS_NR_MASK (0x7 << 8) 227dfeabdedSJohn Hsu #define NAU8824_HYSTERESIS_SFT 0 228dfeabdedSJohn Hsu #define NAU8824_HYSTERESIS_MASK 0xf 229dfeabdedSJohn Hsu 230dfeabdedSJohn Hsu /* PORT0_I2S_PCM_CTRL_1 (0x1C) */ 231dfeabdedSJohn Hsu #define NAU8824_I2S_BP_SFT 7 232dfeabdedSJohn Hsu #define NAU8824_I2S_BP_MASK (1 << NAU8824_I2S_BP_SFT) 233dfeabdedSJohn Hsu #define NAU8824_I2S_BP_INV (1 << NAU8824_I2S_BP_SFT) 234dfeabdedSJohn Hsu #define NAU8824_I2S_PCMB_SFT 6 235dfeabdedSJohn Hsu #define NAU8824_I2S_PCMB_EN (1 << NAU8824_I2S_PCMB_SFT) 236dfeabdedSJohn Hsu #define NAU8824_I2S_DL_SFT 2 237dfeabdedSJohn Hsu #define NAU8824_I2S_DL_MASK (0x3 << NAU8824_I2S_DL_SFT) 238dfeabdedSJohn Hsu #define NAU8824_I2S_DL_16 (0 << NAU8824_I2S_DL_SFT) 239dfeabdedSJohn Hsu #define NAU8824_I2S_DL_20 (1 << NAU8824_I2S_DL_SFT) 240dfeabdedSJohn Hsu #define NAU8824_I2S_DL_24 (2 << NAU8824_I2S_DL_SFT) 241dfeabdedSJohn Hsu #define NAU8824_I2S_DL_32 (3 << NAU8824_I2S_DL_SFT) 242dfeabdedSJohn Hsu #define NAU8824_I2S_DF_MASK 0x3 243dfeabdedSJohn Hsu #define NAU8824_I2S_DF_RIGTH 0 244dfeabdedSJohn Hsu #define NAU8824_I2S_DF_LEFT 1 245dfeabdedSJohn Hsu #define NAU8824_I2S_DF_I2S 2 246dfeabdedSJohn Hsu #define NAU8824_I2S_DF_PCM_AB 3 247dfeabdedSJohn Hsu 248dfeabdedSJohn Hsu 249dfeabdedSJohn Hsu /* PORT0_I2S_PCM_CTRL_2 (0x1D) */ 250dfeabdedSJohn Hsu #define NAU8824_I2S_LRC_DIV_SFT 12 251dfeabdedSJohn Hsu #define NAU8824_I2S_LRC_DIV_MASK (0x3 << NAU8824_I2S_LRC_DIV_SFT) 252dfeabdedSJohn Hsu #define NAU8824_I2S_MS_SFT 3 253dfeabdedSJohn Hsu #define NAU8824_I2S_MS_MASK (1 << NAU8824_I2S_MS_SFT) 254dfeabdedSJohn Hsu #define NAU8824_I2S_MS_MASTER (1 << NAU8824_I2S_MS_SFT) 255dfeabdedSJohn Hsu #define NAU8824_I2S_MS_SLAVE (0 << NAU8824_I2S_MS_SFT) 256dfeabdedSJohn Hsu #define NAU8824_I2S_BLK_DIV_MASK 0x7 257dfeabdedSJohn Hsu 258fa101430SJohn Hsu /* PORT0_LEFT_TIME_SLOT (0x1E) */ 259fa101430SJohn Hsu #define NAU8824_TSLOT_L_MASK 0x3ff 260fa101430SJohn Hsu 261fa101430SJohn Hsu /* TDM_CTRL (0x20) */ 262fa101430SJohn Hsu #define NAU8824_TDM_MODE (0x1 << 15) 263fa101430SJohn Hsu #define NAU8824_TDM_OFFSET_EN (0x1 << 14) 264fa101430SJohn Hsu #define NAU8824_TDM_DACL_RX_SFT 6 265fa101430SJohn Hsu #define NAU8824_TDM_DACL_RX_MASK (0x3 << NAU8824_TDM_DACL_RX_SFT) 266fa101430SJohn Hsu #define NAU8824_TDM_DACR_RX_SFT 4 267fa101430SJohn Hsu #define NAU8824_TDM_DACR_RX_MASK (0x3 << NAU8824_TDM_DACR_RX_SFT) 268fa101430SJohn Hsu #define NAU8824_TDM_TX_MASK 0xf 269fa101430SJohn Hsu 270dfeabdedSJohn Hsu /* ADC_FILTER_CTRL (0x24) */ 271dfeabdedSJohn Hsu #define NAU8824_ADC_SYNC_DOWN_MASK 0x3 272dfeabdedSJohn Hsu #define NAU8824_ADC_SYNC_DOWN_32 0 273dfeabdedSJohn Hsu #define NAU8824_ADC_SYNC_DOWN_64 1 274dfeabdedSJohn Hsu #define NAU8824_ADC_SYNC_DOWN_128 2 275dfeabdedSJohn Hsu #define NAU8824_ADC_SYNC_DOWN_256 3 276dfeabdedSJohn Hsu 277dfeabdedSJohn Hsu /* DAC_FILTER_CTRL_1 (0x25) */ 278dfeabdedSJohn Hsu #define NAU8824_DAC_CICCLP_OFF (0x1 << 7) 279dfeabdedSJohn Hsu #define NAU8824_DAC_OVERSAMPLE_MASK 0x7 280dfeabdedSJohn Hsu #define NAU8824_DAC_OVERSAMPLE_64 0 281dfeabdedSJohn Hsu #define NAU8824_DAC_OVERSAMPLE_256 1 282dfeabdedSJohn Hsu #define NAU8824_DAC_OVERSAMPLE_128 2 283dfeabdedSJohn Hsu #define NAU8824_DAC_OVERSAMPLE_32 4 284dfeabdedSJohn Hsu 285dfeabdedSJohn Hsu /* DAC_MUTE_CTRL (0x31) */ 286dfeabdedSJohn Hsu #define NAU8824_DAC_CH01_MIX 0x3 287dfeabdedSJohn Hsu #define NAU8824_DAC_ZC_EN (0x1 << 11) 288dfeabdedSJohn Hsu 289dfeabdedSJohn Hsu /* DAC_CH0_DGAIN_CTRL (0x32) */ 290dfeabdedSJohn Hsu #define NAU8824_DAC_CH0_SEL_SFT 9 291dfeabdedSJohn Hsu #define NAU8824_DAC_CH0_SEL_MASK (0x1 << NAU8824_DAC_CH0_SEL_SFT) 292dfeabdedSJohn Hsu #define NAU8824_DAC_CH0_SEL_I2S0 (0x0 << NAU8824_DAC_CH0_SEL_SFT) 293dfeabdedSJohn Hsu #define NAU8824_DAC_CH0_SEL_I2S1 (0x1 << NAU8824_DAC_CH0_SEL_SFT) 294dfeabdedSJohn Hsu #define NAU8824_DAC_CH0_VOL_MASK 0x1ff 295dfeabdedSJohn Hsu 296dfeabdedSJohn Hsu /* DAC_CH1_DGAIN_CTRL (0x33) */ 297dfeabdedSJohn Hsu #define NAU8824_DAC_CH1_SEL_SFT 9 298dfeabdedSJohn Hsu #define NAU8824_DAC_CH1_SEL_MASK (0x1 << NAU8824_DAC_CH1_SEL_SFT) 299dfeabdedSJohn Hsu #define NAU8824_DAC_CH1_SEL_I2S0 (0x0 << NAU8824_DAC_CH1_SEL_SFT) 300dfeabdedSJohn Hsu #define NAU8824_DAC_CH1_SEL_I2S1 (0x1 << NAU8824_DAC_CH1_SEL_SFT) 301dfeabdedSJohn Hsu #define NAU8824_DAC_CH1_VOL_MASK 0x1ff 302dfeabdedSJohn Hsu 303dfeabdedSJohn Hsu /* CLASSG (0x50) */ 304dfeabdedSJohn Hsu #define NAU8824_CLASSG_TIMER_SFT 8 305dfeabdedSJohn Hsu #define NAU8824_CLASSG_TIMER_MASK (0x3f << NAU8824_CLASSG_TIMER_SFT) 306dfeabdedSJohn Hsu #define NAU8824_CLASSG_LDAC_EN_SFT 2 307dfeabdedSJohn Hsu #define NAU8824_CLASSG_RDAC_EN_SFT 1 308dfeabdedSJohn Hsu #define NAU8824_CLASSG_EN_SFT 0 309dfeabdedSJohn Hsu 310dfeabdedSJohn Hsu /* SAR_ADC_DATA_OUT (0x59) */ 311dfeabdedSJohn Hsu #define NAU8824_SAR_ADC_DATA_MASK 0xff 312dfeabdedSJohn Hsu 313dfeabdedSJohn Hsu /* BIAS_ADJ (0x66) */ 314dfeabdedSJohn Hsu #define NAU8824_VMID (1 << 6) 315dfeabdedSJohn Hsu #define NAU8824_VMID_SEL_SFT 4 316dfeabdedSJohn Hsu #define NAU8824_VMID_SEL_MASK (3 << NAU8824_VMID_SEL_SFT) 317dfeabdedSJohn Hsu #define NAU8824_DMIC2_EN_SFT 3 318dfeabdedSJohn Hsu #define NAU8824_DMIC1_EN_SFT 2 319dfeabdedSJohn Hsu 320dfeabdedSJohn Hsu /* TRIM_SETTINGS (0x68) */ 321dfeabdedSJohn Hsu #define NAU8824_DRV_CURR_INC (1 << 15) 322dfeabdedSJohn Hsu 323dfeabdedSJohn Hsu /* ANALOG_CONTROL_1 (0x69) */ 324dfeabdedSJohn Hsu #define NAU8824_DMIC_CLK_DRV_STRG (1 << 3) 325dfeabdedSJohn Hsu #define NAU8824_DMIC_CLK_SLEW_FAST (0x7) 326dfeabdedSJohn Hsu 327dfeabdedSJohn Hsu /* ANALOG_CONTROL_2 (0x6A) */ 328dfeabdedSJohn Hsu #define NAU8824_CLASSD_CLAMP_DIS_SFT 3 329dfeabdedSJohn Hsu #define NAU8824_CLASSD_CLAMP_DIS (0x1 << NAU8824_CLASSD_CLAMP_DIS_SFT) 330dfeabdedSJohn Hsu 331dfeabdedSJohn Hsu /* ENABLE_LO (0x6B) */ 332dfeabdedSJohn Hsu #define NAU8824_TEST_DAC_SFT 14 333dfeabdedSJohn Hsu #define NAU8824_TEST_DAC_EN (0x3 << NAU8824_TEST_DAC_SFT) 334dfeabdedSJohn Hsu #define NAU8824_DACL_HPR_EN_SFT 3 335dfeabdedSJohn Hsu #define NAU8824_DACL_HPR_EN (0x1 << NAU8824_DACL_HPR_EN_SFT) 336dfeabdedSJohn Hsu #define NAU8824_DACR_HPR_EN_SFT 2 337dfeabdedSJohn Hsu #define NAU8824_DACR_HPR_EN (0x1 << NAU8824_DACR_HPR_EN_SFT) 338dfeabdedSJohn Hsu #define NAU8824_DACR_HPL_EN_SFT 1 339dfeabdedSJohn Hsu #define NAU8824_DACR_HPL_EN (0x1 << NAU8824_DACR_HPL_EN_SFT) 340dfeabdedSJohn Hsu #define NAU8824_DACL_HPL_EN_SFT 0 341dfeabdedSJohn Hsu #define NAU8824_DACL_HPL_EN 0x1 342dfeabdedSJohn Hsu 343dfeabdedSJohn Hsu /* CLASSD_GAIN_1 (0x6D) */ 344dfeabdedSJohn Hsu #define NAU8824_CLASSD_GAIN_1R_SFT 8 345dfeabdedSJohn Hsu #define NAU8824_CLASSD_GAIN_1R_MASK (0x1f << NAU8824_CLASSD_GAIN_1R_SFT) 346dfeabdedSJohn Hsu #define NAU8824_CLASSD_EN_SFT 7 347dfeabdedSJohn Hsu #define NAU8824_CLASSD_EN (0x1 << NAU8824_CLASSD_EN_SFT) 348dfeabdedSJohn Hsu #define NAU8824_CLASSD_GAIN_1L_MASK 0x1f 349dfeabdedSJohn Hsu 350dfeabdedSJohn Hsu /* CLASSD_GAIN_2 (0x6E) */ 351dfeabdedSJohn Hsu #define NAU8824_CLASSD_GAIN_2R_SFT 8 352dfeabdedSJohn Hsu #define NAU8824_CLASSD_GAIN_2R_MASK (0x1f << NAU8824_CLASSD_GAIN_1R_SFT) 353dfeabdedSJohn Hsu #define NAU8824_CLASSD_EN_SFT 7 354dfeabdedSJohn Hsu #define NAU8824_CLASSD_EN (0x1 << NAU8824_CLASSD_EN_SFT) 355dfeabdedSJohn Hsu #define NAU8824_CLASSD_GAIN_2L_MASK 0x1f 356dfeabdedSJohn Hsu 357dfeabdedSJohn Hsu /* ANALOG_ADC_2 (0x72) */ 358dfeabdedSJohn Hsu #define NAU8824_ADCR_EN_SFT 7 359dfeabdedSJohn Hsu #define NAU8824_ADCL_EN_SFT 6 360dfeabdedSJohn Hsu 361dfeabdedSJohn Hsu /* RDAC (0x73) */ 362dfeabdedSJohn Hsu #define NAU8824_DACR_EN_SFT 13 363dfeabdedSJohn Hsu #define NAU8824_DACL_EN_SFT 12 364dfeabdedSJohn Hsu #define NAU8824_DACR_CLK_SFT 9 365dfeabdedSJohn Hsu #define NAU8824_DACL_CLK_SFT 8 366dfeabdedSJohn Hsu #define NAU8824_RDAC_CLK_DELAY_SFT 4 367dfeabdedSJohn Hsu #define NAU8824_RDAC_CLK_DELAY_MASK (0x7 << NAU8824_RDAC_CLK_DELAY_SFT) 368dfeabdedSJohn Hsu #define NAU8824_RDAC_VREF_SFT 2 369dfeabdedSJohn Hsu #define NAU8824_RDAC_VREF_MASK (0x3 << NAU8824_RDAC_VREF_SFT) 370dfeabdedSJohn Hsu 371dfeabdedSJohn Hsu /* MIC_BIAS (0x74) */ 372dfeabdedSJohn Hsu #define NAU8824_MICBIAS_JKSLV (1 << 14) 373dfeabdedSJohn Hsu #define NAU8824_MICBIAS_JKR2 (1 << 12) 374dfeabdedSJohn Hsu #define NAU8824_MICBIAS_POWERUP_SFT 8 375dfeabdedSJohn Hsu #define NAU8824_MICBIAS_VOLTAGE_SFT 0 376dfeabdedSJohn Hsu #define NAU8824_MICBIAS_VOLTAGE_MASK 0x7 377dfeabdedSJohn Hsu 378dfeabdedSJohn Hsu /* BOOST (0x76) */ 379dfeabdedSJohn Hsu #define NAU8824_PRECHARGE_DIS (0x1 << 13) 380dfeabdedSJohn Hsu #define NAU8824_GLOBAL_BIAS_EN (0x1 << 12) 381dfeabdedSJohn Hsu #define NAU8824_HP_BOOST_DIS_SFT 9 382dfeabdedSJohn Hsu #define NAU8824_HP_BOOST_DIS (0x1 << NAU8824_HP_BOOST_DIS_SFT) 383dfeabdedSJohn Hsu #define NAU8824_HP_BOOST_G_DIS_SFT 8 384dfeabdedSJohn Hsu #define NAU8824_HP_BOOST_G_DIS (0x1 << NAU8824_HP_BOOST_G_DIS_SFT) 385dfeabdedSJohn Hsu #define NAU8824_SHORT_SHUTDOWN_DIG_EN (1 << 7) 386dfeabdedSJohn Hsu #define NAU8824_SHORT_SHUTDOWN_EN (1 << 6) 387dfeabdedSJohn Hsu 388dfeabdedSJohn Hsu /* FEPGA (0x77) */ 389dfeabdedSJohn Hsu #define NAU8824_FEPGA_MODER_SHORT_SFT 7 390dfeabdedSJohn Hsu #define NAU8824_FEPGA_MODER_SHORT_EN (0x1 << NAU8824_FEPGA_MODER_SHORT_SFT) 391dfeabdedSJohn Hsu #define NAU8824_FEPGA_MODER_MIC2_SFT 5 392dfeabdedSJohn Hsu #define NAU8824_FEPGA_MODER_MIC2_EN (0x1 << NAU8824_FEPGA_MODER_MIC2_SFT) 393dfeabdedSJohn Hsu #define NAU8824_FEPGA_MODER_HSMIC_SFT 4 394dfeabdedSJohn Hsu #define NAU8824_FEPGA_MODER_HSMIC_EN (0x1 << NAU8824_FEPGA_MODER_HSMIC_SFT) 395dfeabdedSJohn Hsu #define NAU8824_FEPGA_MODEL_SHORT_SFT 3 396dfeabdedSJohn Hsu #define NAU8824_FEPGA_MODEL_SHORT_EN (0x1 << NAU8824_FEPGA_MODEL_SHORT_SFT) 397dfeabdedSJohn Hsu #define NAU8824_FEPGA_MODEL_MIC1_SFT 1 398dfeabdedSJohn Hsu #define NAU8824_FEPGA_MODEL_MIC1_EN (0x1 << NAU8824_FEPGA_MODEL_MIC1_SFT) 399dfeabdedSJohn Hsu #define NAU8824_FEPGA_MODEL_HSMIC_SFT 0 400dfeabdedSJohn Hsu #define NAU8824_FEPGA_MODEL_HSMIC_EN (0x1 << NAU8824_FEPGA_MODEL_HSMIC_SFT) 401dfeabdedSJohn Hsu 402dfeabdedSJohn Hsu /* FEPGA_II (0x78) */ 403dfeabdedSJohn Hsu #define NAU8824_FEPGA_GAINR_SFT 5 404dfeabdedSJohn Hsu #define NAU8824_FEPGA_GAINR_MASK (0x1f << NAU8824_FEPGA_GAINR_SFT) 405dfeabdedSJohn Hsu #define NAU8824_FEPGA_GAINL_SFT 0 406dfeabdedSJohn Hsu #define NAU8824_FEPGA_GAINL_MASK 0x1f 407dfeabdedSJohn Hsu 408dfeabdedSJohn Hsu /* CHARGE_PUMP_CONTROL (0x80) */ 409dfeabdedSJohn Hsu #define NAU8824_JAMNODCLOW (0x1 << 15) 410dfeabdedSJohn Hsu #define NAU8824_SPKR_PULL_DOWN (0x1 << 13) 411dfeabdedSJohn Hsu #define NAU8824_SPKL_PULL_DOWN (0x1 << 12) 412dfeabdedSJohn Hsu #define NAU8824_POWER_DOWN_DACR (0x1 << 9) 413dfeabdedSJohn Hsu #define NAU8824_POWER_DOWN_DACL (0x1 << 8) 414dfeabdedSJohn Hsu #define NAU8824_CHARGE_PUMP_EN_SFT 5 415dfeabdedSJohn Hsu #define NAU8824_CHARGE_PUMP_EN (0x1 << NAU8824_CHARGE_PUMP_EN_SFT) 416dfeabdedSJohn Hsu 417dfeabdedSJohn Hsu 418dfeabdedSJohn Hsu #define NAU8824_CODEC_DAI "nau8824-hifi" 419dfeabdedSJohn Hsu 420dfeabdedSJohn Hsu /* System Clock Source */ 421dfeabdedSJohn Hsu enum { 422dfeabdedSJohn Hsu NAU8824_CLK_DIS, 423dfeabdedSJohn Hsu NAU8824_CLK_MCLK, 424dfeabdedSJohn Hsu NAU8824_CLK_INTERNAL, 425dfeabdedSJohn Hsu NAU8824_CLK_FLL_MCLK, 426dfeabdedSJohn Hsu NAU8824_CLK_FLL_BLK, 427dfeabdedSJohn Hsu NAU8824_CLK_FLL_FS, 428dfeabdedSJohn Hsu }; 429dfeabdedSJohn Hsu 430dfeabdedSJohn Hsu struct nau8824 { 431dfeabdedSJohn Hsu struct device *dev; 432dfeabdedSJohn Hsu struct regmap *regmap; 433dfeabdedSJohn Hsu struct snd_soc_dapm_context *dapm; 434dfeabdedSJohn Hsu struct snd_soc_jack *jack; 435dfeabdedSJohn Hsu struct work_struct jdet_work; 436dfeabdedSJohn Hsu struct semaphore jd_sem; 437*1d3724c9SMaxim Kochetkov struct clk *mclk; 438dfeabdedSJohn Hsu int fs; 439dfeabdedSJohn Hsu int irq; 4407042bde2SSJLIN0 int resume_lock; 441dfeabdedSJohn Hsu int micbias_voltage; 442dfeabdedSJohn Hsu int vref_impedance; 443dfeabdedSJohn Hsu int jkdet_polarity; 444dfeabdedSJohn Hsu int sar_threshold_num; 445dfeabdedSJohn Hsu int sar_threshold[8]; 446dfeabdedSJohn Hsu int sar_hysteresis; 447dfeabdedSJohn Hsu int sar_voltage; 448dfeabdedSJohn Hsu int sar_compare_time; 449dfeabdedSJohn Hsu int sar_sampling_time; 450dfeabdedSJohn Hsu int key_debounce; 451dfeabdedSJohn Hsu int jack_eject_debounce; 452dfeabdedSJohn Hsu }; 453dfeabdedSJohn Hsu 454dfeabdedSJohn Hsu struct nau8824_fll { 455dfeabdedSJohn Hsu int mclk_src; 456dfeabdedSJohn Hsu int ratio; 457dfeabdedSJohn Hsu int fll_frac; 458dfeabdedSJohn Hsu int fll_int; 459dfeabdedSJohn Hsu int clk_ref_div; 460dfeabdedSJohn Hsu }; 461dfeabdedSJohn Hsu 462dfeabdedSJohn Hsu struct nau8824_fll_attr { 463dfeabdedSJohn Hsu unsigned int param; 464dfeabdedSJohn Hsu unsigned int val; 465dfeabdedSJohn Hsu }; 466dfeabdedSJohn Hsu 467dfeabdedSJohn Hsu struct nau8824_osr_attr { 468dfeabdedSJohn Hsu unsigned int osr; 469dfeabdedSJohn Hsu unsigned int clk_src; 470dfeabdedSJohn Hsu }; 471dfeabdedSJohn Hsu 472dfeabdedSJohn Hsu 47312a72f91SKuninori Morimoto int nau8824_enable_jack_detect(struct snd_soc_component *component, 474dfeabdedSJohn Hsu struct snd_soc_jack *jack); 475efee0fcaSHans de Goede const char *nau8824_components(void); 476dfeabdedSJohn Hsu 477dfeabdedSJohn Hsu #endif /* _NAU8824_H */ 478dfeabdedSJohn Hsu 479