1dfe0f98bSBrian Austin /* 2dfe0f98bSBrian Austin * cs42l52.h -- CS42L52 ALSA SoC audio driver 3dfe0f98bSBrian Austin * 4dfe0f98bSBrian Austin * Copyright 2012 CirrusLogic, Inc. 5dfe0f98bSBrian Austin * 6dfe0f98bSBrian Austin * Author: Georgi Vlaev <joe@nucleusys.com> 7dfe0f98bSBrian Austin * Author: Brian Austin <brian.austin@cirrus.com> 8dfe0f98bSBrian Austin * 9dfe0f98bSBrian Austin * This program is free software; you can redistribute it and/or modify 10dfe0f98bSBrian Austin * it under the terms of the GNU General Public License version 2 as 11dfe0f98bSBrian Austin * published by the Free Software Foundation. 12dfe0f98bSBrian Austin * 13dfe0f98bSBrian Austin */ 14dfe0f98bSBrian Austin 15dfe0f98bSBrian Austin #ifndef __CS42L52_H__ 16dfe0f98bSBrian Austin #define __CS42L52_H__ 17dfe0f98bSBrian Austin 18dfe0f98bSBrian Austin #define CS42L52_NAME "CS42L52" 19dfe0f98bSBrian Austin #define CS42L52_DEFAULT_CLK 12000000 20dfe0f98bSBrian Austin #define CS42L52_MIN_CLK 11000000 21dfe0f98bSBrian Austin #define CS42L52_MAX_CLK 27000000 22dfe0f98bSBrian Austin #define CS42L52_DEFAULT_FORMAT SNDRV_PCM_FMTBIT_S16_LE 23dfe0f98bSBrian Austin #define CS42L52_DEFAULT_MAX_CHANS 2 24dfe0f98bSBrian Austin #define CS42L52_SYSCLK 1 25dfe0f98bSBrian Austin 26dfe0f98bSBrian Austin #define CS42L52_CHIP_SWICTH (1 << 17) 27dfe0f98bSBrian Austin #define CS42L52_ALL_IN_ONE (1 << 16) 28dfe0f98bSBrian Austin #define CS42L52_CHIP_ONE 0x00 29dfe0f98bSBrian Austin #define CS42L52_CHIP_TWO 0x01 30dfe0f98bSBrian Austin #define CS42L52_CHIP_THR 0x02 31dfe0f98bSBrian Austin #define CS42L52_CHIP_MASK 0x0f 32dfe0f98bSBrian Austin 33dfe0f98bSBrian Austin #define CS42L52_FIX_BITS_CTL 0x00 34dfe0f98bSBrian Austin #define CS42L52_CHIP 0x01 35dfe0f98bSBrian Austin #define CS42L52_CHIP_ID 0xE0 36dfe0f98bSBrian Austin #define CS42L52_CHIP_ID_MASK 0xF8 37dfe0f98bSBrian Austin #define CS42L52_CHIP_REV_A0 0x00 38dfe0f98bSBrian Austin #define CS42L52_CHIP_REV_A1 0x01 39dfe0f98bSBrian Austin #define CS42L52_CHIP_REV_B0 0x02 40dfe0f98bSBrian Austin #define CS42L52_CHIP_REV_MASK 0x03 41dfe0f98bSBrian Austin 42dfe0f98bSBrian Austin #define CS42L52_PWRCTL1 0x02 43dfe0f98bSBrian Austin #define CS42L52_PWRCTL1_PDN_ALL 0x9F 44dfe0f98bSBrian Austin #define CS42L52_PWRCTL1_PDN_CHRG 0x80 45dfe0f98bSBrian Austin #define CS42L52_PWRCTL1_PDN_PGAB 0x10 46dfe0f98bSBrian Austin #define CS42L52_PWRCTL1_PDN_PGAA 0x08 47dfe0f98bSBrian Austin #define CS42L52_PWRCTL1_PDN_ADCB 0x04 48dfe0f98bSBrian Austin #define CS42L52_PWRCTL1_PDN_ADCA 0x02 49dfe0f98bSBrian Austin #define CS42L52_PWRCTL1_PDN_CODEC 0x01 50dfe0f98bSBrian Austin 51dfe0f98bSBrian Austin #define CS42L52_PWRCTL2 0x03 52dfe0f98bSBrian Austin #define CS42L52_PWRCTL2_OVRDB (1 << 4) 53dfe0f98bSBrian Austin #define CS42L52_PWRCTL2_OVRDA (1 << 3) 54dfe0f98bSBrian Austin #define CS42L52_PWRCTL2_PDN_MICB (1 << 2) 55dfe0f98bSBrian Austin #define CS42L52_PWRCTL2_PDN_MICB_SHIFT 2 56dfe0f98bSBrian Austin #define CS42L52_PWRCTL2_PDN_MICA (1 << 1) 57dfe0f98bSBrian Austin #define CS42L52_PWRCTL2_PDN_MICA_SHIFT 1 58dfe0f98bSBrian Austin #define CS42L52_PWRCTL2_PDN_MICBIAS (1 << 0) 59dfe0f98bSBrian Austin #define CS42L52_PWRCTL2_PDN_MICBIAS_SHIFT 0 60dfe0f98bSBrian Austin 61dfe0f98bSBrian Austin #define CS42L52_PWRCTL3 0x04 62dfe0f98bSBrian Austin #define CS42L52_PWRCTL3_HPB_PDN_SHIFT 6 63dfe0f98bSBrian Austin #define CS42L52_PWRCTL3_HPB_ON_LOW 0x00 64dfe0f98bSBrian Austin #define CS42L52_PWRCTL3_HPB_ON_HIGH 0x01 65dfe0f98bSBrian Austin #define CS42L52_PWRCTL3_HPB_ALWAYS_ON 0x02 66dfe0f98bSBrian Austin #define CS42L52_PWRCTL3_HPB_ALWAYS_OFF 0x03 67dfe0f98bSBrian Austin #define CS42L52_PWRCTL3_HPA_PDN_SHIFT 4 68dfe0f98bSBrian Austin #define CS42L52_PWRCTL3_HPA_ON_LOW 0x00 69dfe0f98bSBrian Austin #define CS42L52_PWRCTL3_HPA_ON_HIGH 0x01 70dfe0f98bSBrian Austin #define CS42L52_PWRCTL3_HPA_ALWAYS_ON 0x02 71dfe0f98bSBrian Austin #define CS42L52_PWRCTL3_HPA_ALWAYS_OFF 0x03 72dfe0f98bSBrian Austin #define CS42L52_PWRCTL3_SPKB_PDN_SHIFT 2 73dfe0f98bSBrian Austin #define CS42L52_PWRCTL3_SPKB_ON_LOW 0x00 74dfe0f98bSBrian Austin #define CS42L52_PWRCTL3_SPKB_ON_HIGH 0x01 75dfe0f98bSBrian Austin #define CS42L52_PWRCTL3_SPKB_ALWAYS_ON 0x02 76dfe0f98bSBrian Austin #define CS42L52_PWRCTL3_PDN_SPKB (1 << 2) 77dfe0f98bSBrian Austin #define CS42L52_PWRCTL3_PDN_SPKA (1 << 0) 78dfe0f98bSBrian Austin #define CS42L52_PWRCTL3_SPKA_PDN_SHIFT 0 79dfe0f98bSBrian Austin #define CS42L52_PWRCTL3_SPKA_ON_LOW 0x00 80dfe0f98bSBrian Austin #define CS42L52_PWRCTL3_SPKA_ON_HIGH 0x01 81dfe0f98bSBrian Austin #define CS42L52_PWRCTL3_SPKA_ALWAYS_ON 0x02 82dfe0f98bSBrian Austin 83dfe0f98bSBrian Austin #define CS42L52_DEFAULT_OUTPUT_STATE 0x05 84dfe0f98bSBrian Austin #define CS42L52_PWRCTL3_CONF_MASK 0x03 85dfe0f98bSBrian Austin 86dfe0f98bSBrian Austin #define CS42L52_CLK_CTL 0x05 87dfe0f98bSBrian Austin #define CLK_AUTODECT_ENABLE (1 << 7) 88dfe0f98bSBrian Austin #define CLK_SPEED_SHIFT 5 89dfe0f98bSBrian Austin #define CLK_DS_MODE 0x00 90dfe0f98bSBrian Austin #define CLK_SS_MODE 0x01 91dfe0f98bSBrian Austin #define CLK_HS_MODE 0x02 92dfe0f98bSBrian Austin #define CLK_QS_MODE 0x03 93dfe0f98bSBrian Austin #define CLK_32K_SR_SHIFT 4 94dfe0f98bSBrian Austin #define CLK_32K 0x01 95dfe0f98bSBrian Austin #define CLK_NO_32K 0x00 96dfe0f98bSBrian Austin #define CLK_27M_MCLK_SHIFT 3 97dfe0f98bSBrian Austin #define CLK_27M_MCLK 0x01 98dfe0f98bSBrian Austin #define CLK_NO_27M 0x00 99dfe0f98bSBrian Austin #define CLK_RATIO_SHIFT 1 100dfe0f98bSBrian Austin #define CLK_R_128 0x00 101dfe0f98bSBrian Austin #define CLK_R_125 0x01 102dfe0f98bSBrian Austin #define CLK_R_132 0x02 103dfe0f98bSBrian Austin #define CLK_R_136 0x03 104dfe0f98bSBrian Austin 105dfe0f98bSBrian Austin #define CS42L52_IFACE_CTL1 0x06 106dfe0f98bSBrian Austin #define CS42L52_IFACE_CTL1_MASTER (1 << 7) 107dfe0f98bSBrian Austin #define CS42L52_IFACE_CTL1_SLAVE (0 << 7) 108dfe0f98bSBrian Austin #define CS42L52_IFACE_CTL1_INV_SCLK (1 << 6) 109dfe0f98bSBrian Austin #define CS42L52_IFACE_CTL1_ADC_FMT_I2S (1 << 5) 110dfe0f98bSBrian Austin #define CS42L52_IFACE_CTL1_ADC_FMT_LEFT_J (0 << 5) 111dfe0f98bSBrian Austin #define CS42L52_IFACE_CTL1_DSP_MODE_EN (1 << 4) 112dfe0f98bSBrian Austin #define CS42L52_IFACE_CTL1_DAC_FMT_LEFT_J (0 << 2) 113dfe0f98bSBrian Austin #define CS42L52_IFACE_CTL1_DAC_FMT_I2S (1 << 2) 114dfe0f98bSBrian Austin #define CS42L52_IFACE_CTL1_DAC_FMT_RIGHT_J (2 << 2) 115dfe0f98bSBrian Austin #define CS42L52_IFACE_CTL1_WL_32BIT (0x00) 116dfe0f98bSBrian Austin #define CS42L52_IFACE_CTL1_WL_24BIT (0x01) 117dfe0f98bSBrian Austin #define CS42L52_IFACE_CTL1_WL_20BIT (0x02) 118dfe0f98bSBrian Austin #define CS42L52_IFACE_CTL1_WL_16BIT (0x03) 119dfe0f98bSBrian Austin #define CS42L52_IFACE_CTL1_WL_MASK 0xFFFF 120dfe0f98bSBrian Austin 121dfe0f98bSBrian Austin #define CS42L52_IFACE_CTL2 0x07 122dfe0f98bSBrian Austin #define CS42L52_IFACE_CTL2_SC_MC_EQ (1 << 6) 123dfe0f98bSBrian Austin #define CS42L52_IFACE_CTL2_LOOPBACK (1 << 5) 124dfe0f98bSBrian Austin #define CS42L52_IFACE_CTL2_S_MODE_OUTPUT_EN (0 << 4) 125dfe0f98bSBrian Austin #define CS42L52_IFACE_CTL2_S_MODE_OUTPUT_HIZ (1 << 4) 126dfe0f98bSBrian Austin #define CS42L52_IFACE_CTL2_HP_SW_INV (1 << 3) 127dfe0f98bSBrian Austin #define CS42L52_IFACE_CTL2_BIAS_LVL 0x07 128dfe0f98bSBrian Austin 129dfe0f98bSBrian Austin #define CS42L52_ADC_PGA_A 0x08 130dfe0f98bSBrian Austin #define CS42L52_ADC_PGA_B 0x09 131dfe0f98bSBrian Austin #define CS42L52_ADC_SEL_SHIFT 5 132dfe0f98bSBrian Austin #define CS42L52_ADC_SEL_AIN1 0x00 133dfe0f98bSBrian Austin #define CS42L52_ADC_SEL_AIN2 0x01 134dfe0f98bSBrian Austin #define CS42L52_ADC_SEL_AIN3 0x02 135dfe0f98bSBrian Austin #define CS42L52_ADC_SEL_AIN4 0x03 136dfe0f98bSBrian Austin #define CS42L52_ADC_SEL_PGA 0x04 137dfe0f98bSBrian Austin 138dfe0f98bSBrian Austin #define CS42L52_ANALOG_HPF_CTL 0x0A 139dfe0f98bSBrian Austin #define CS42L52_HPF_CTL_ANLGSFTB (1 << 3) 140dfe0f98bSBrian Austin #define CS42L52_HPF_CTL_ANLGSFTA (1 << 0) 141dfe0f98bSBrian Austin 142dfe0f98bSBrian Austin #define CS42L52_ADC_HPF_FREQ 0x0B 143dfe0f98bSBrian Austin #define CS42L52_ADC_MISC_CTL 0x0C 144dfe0f98bSBrian Austin #define CS42L52_ADC_MISC_CTL_SOURCE_DSP (1 << 6) 145dfe0f98bSBrian Austin 146dfe0f98bSBrian Austin #define CS42L52_PB_CTL1 0x0D 147dfe0f98bSBrian Austin #define CS42L52_PB_CTL1_HP_GAIN_SHIFT 5 148dfe0f98bSBrian Austin #define CS42L52_PB_CTL1_HP_GAIN_03959 0x00 149dfe0f98bSBrian Austin #define CS42L52_PB_CTL1_HP_GAIN_04571 0x01 150dfe0f98bSBrian Austin #define CS42L52_PB_CTL1_HP_GAIN_05111 0x02 151dfe0f98bSBrian Austin #define CS42L52_PB_CTL1_HP_GAIN_06047 0x03 152dfe0f98bSBrian Austin #define CS42L52_PB_CTL1_HP_GAIN_07099 0x04 153dfe0f98bSBrian Austin #define CS42L52_PB_CTL1_HP_GAIN_08399 0x05 154dfe0f98bSBrian Austin #define CS42L52_PB_CTL1_HP_GAIN_10000 0x06 155dfe0f98bSBrian Austin #define CS42L52_PB_CTL1_HP_GAIN_11430 0x07 156dfe0f98bSBrian Austin #define CS42L52_PB_CTL1_INV_PCMB (1 << 3) 157dfe0f98bSBrian Austin #define CS42L52_PB_CTL1_INV_PCMA (1 << 2) 158dfe0f98bSBrian Austin #define CS42L52_PB_CTL1_MSTB_MUTE (1 << 1) 159dfe0f98bSBrian Austin #define CS42L52_PB_CTL1_MSTA_MUTE (1 << 0) 16040e2516aSNicolas Schichan #define CS42L52_PB_CTL1_MUTE_MASK 0x03 161dfe0f98bSBrian Austin #define CS42L52_PB_CTL1_MUTE 3 162dfe0f98bSBrian Austin #define CS42L52_PB_CTL1_UNMUTE 0 163dfe0f98bSBrian Austin 164dfe0f98bSBrian Austin #define CS42L52_MISC_CTL 0x0E 165dfe0f98bSBrian Austin #define CS42L52_MISC_CTL_DEEMPH (1 << 2) 166dfe0f98bSBrian Austin #define CS42L52_MISC_CTL_DIGSFT (1 << 1) 167dfe0f98bSBrian Austin #define CS42L52_MISC_CTL_DIGZC (1 << 0) 168dfe0f98bSBrian Austin 169dfe0f98bSBrian Austin #define CS42L52_PB_CTL2 0x0F 170dfe0f98bSBrian Austin #define CS42L52_PB_CTL2_HPB_MUTE (1 << 7) 171dfe0f98bSBrian Austin #define CS42L52_PB_CTL2_HPA_MUTE (1 << 6) 172dfe0f98bSBrian Austin #define CS42L52_PB_CTL2_SPKB_MUTE (1 << 5) 173dfe0f98bSBrian Austin #define CS42L52_PB_CTL2_SPKA_MUTE (1 << 4) 174dfe0f98bSBrian Austin #define CS42L52_PB_CTL2_SPK_SWAP (1 << 2) 175dfe0f98bSBrian Austin #define CS42L52_PB_CTL2_SPK_MONO (1 << 1) 176dfe0f98bSBrian Austin #define CS42L52_PB_CTL2_SPK_MUTE50 (1 << 0) 177dfe0f98bSBrian Austin 178dfe0f98bSBrian Austin #define CS42L52_MICA_CTL 0x10 179dfe0f98bSBrian Austin #define CS42L52_MICB_CTL 0x11 180dfe0f98bSBrian Austin #define CS42L52_MIC_CTL_MIC_SEL_MASK 0xBF 181dfe0f98bSBrian Austin #define CS42L52_MIC_CTL_MIC_SEL_SHIFT 6 182*3d800c6dSBrian Austin #define CS42L52_MIC_CTL_TYPE_MASK 0x20 183dfe0f98bSBrian Austin #define CS42L52_MIC_CTL_TYPE_SHIFT 5 184dfe0f98bSBrian Austin 185dfe0f98bSBrian Austin 186dfe0f98bSBrian Austin #define CS42L52_PGAA_CTL 0x12 187dfe0f98bSBrian Austin #define CS42L52_PGAB_CTL 0x13 188dfe0f98bSBrian Austin #define CS42L52_PGAX_CTL_VOL_12DB 24 189dfe0f98bSBrian Austin #define CS42L52_PGAX_CTL_VOL_6DB 12 /*step size 0.5db*/ 190dfe0f98bSBrian Austin 191dfe0f98bSBrian Austin #define CS42L52_PASSTHRUA_VOL 0x14 192dfe0f98bSBrian Austin #define CS42L52_PASSTHRUB_VOL 0x15 193dfe0f98bSBrian Austin 194dfe0f98bSBrian Austin #define CS42L52_ADCA_VOL 0x16 195dfe0f98bSBrian Austin #define CS42L52_ADCB_VOL 0x17 196dfe0f98bSBrian Austin #define CS42L52_ADCX_VOL_24DB 24 /*step size 1db*/ 197dfe0f98bSBrian Austin #define CS42L52_ADCX_VOL_12DB 12 198dfe0f98bSBrian Austin #define CS42L52_ADCX_VOL_6DB 6 199dfe0f98bSBrian Austin 200dfe0f98bSBrian Austin #define CS42L52_ADCA_MIXER_VOL 0x18 201dfe0f98bSBrian Austin #define CS42L52_ADCB_MIXER_VOL 0x19 202dfe0f98bSBrian Austin #define CS42L52_ADC_MIXER_VOL_12DB 0x18 203dfe0f98bSBrian Austin 204dfe0f98bSBrian Austin #define CS42L52_PCMA_MIXER_VOL 0x1A 205dfe0f98bSBrian Austin #define CS42L52_PCMB_MIXER_VOL 0x1B 206dfe0f98bSBrian Austin 207dfe0f98bSBrian Austin #define CS42L52_BEEP_FREQ 0x1C 208dfe0f98bSBrian Austin #define CS42L52_BEEP_VOL 0x1D 209dfe0f98bSBrian Austin #define CS42L52_BEEP_TONE_CTL 0x1E 210dfe0f98bSBrian Austin #define CS42L52_BEEP_RATE_SHIFT 4 211dfe0f98bSBrian Austin #define CS42L52_BEEP_RATE_MASK 0x0F 212dfe0f98bSBrian Austin 213dfe0f98bSBrian Austin #define CS42L52_TONE_CTL 0x1F 214dfe0f98bSBrian Austin #define CS42L52_BEEP_EN_MASK 0x3F 215dfe0f98bSBrian Austin 216dfe0f98bSBrian Austin #define CS42L52_MASTERA_VOL 0x20 217dfe0f98bSBrian Austin #define CS42L52_MASTERB_VOL 0x21 218dfe0f98bSBrian Austin 219dfe0f98bSBrian Austin #define CS42L52_HPA_VOL 0x22 220dfe0f98bSBrian Austin #define CS42L52_HPB_VOL 0x23 221dfe0f98bSBrian Austin #define CS42L52_DEFAULT_HP_VOL 0xF0 222dfe0f98bSBrian Austin 223dfe0f98bSBrian Austin #define CS42L52_SPKA_VOL 0x24 224dfe0f98bSBrian Austin #define CS42L52_SPKB_VOL 0x25 225dfe0f98bSBrian Austin #define CS42L52_DEFAULT_SPK_VOL 0xF0 226dfe0f98bSBrian Austin 227dfe0f98bSBrian Austin #define CS42L52_ADC_PCM_MIXER 0x26 228dfe0f98bSBrian Austin 229dfe0f98bSBrian Austin #define CS42L52_LIMITER_CTL1 0x27 230dfe0f98bSBrian Austin #define CS42L52_LIMITER_CTL2 0x28 231dfe0f98bSBrian Austin #define CS42L52_LIMITER_AT_RATE 0x29 232dfe0f98bSBrian Austin 233dfe0f98bSBrian Austin #define CS42L52_ALC_CTL 0x2A 234dfe0f98bSBrian Austin #define CS42L52_ALC_CTL_ALCB_ENABLE_SHIFT 7 235dfe0f98bSBrian Austin #define CS42L52_ALC_CTL_ALCA_ENABLE_SHIFT 6 236dfe0f98bSBrian Austin #define CS42L52_ALC_CTL_FASTEST_ATTACK 0 237dfe0f98bSBrian Austin 238dfe0f98bSBrian Austin #define CS42L52_ALC_RATE 0x2B 239dfe0f98bSBrian Austin #define CS42L52_ALC_SLOWEST_RELEASE 0x3F 240dfe0f98bSBrian Austin 241dfe0f98bSBrian Austin #define CS42L52_ALC_THRESHOLD 0x2C 242dfe0f98bSBrian Austin #define CS42L52_ALC_MAX_RATE_SHIFT 5 243dfe0f98bSBrian Austin #define CS42L52_ALC_MIN_RATE_SHIFT 2 244dfe0f98bSBrian Austin #define CS42L52_ALC_RATE_0DB 0 245dfe0f98bSBrian Austin #define CS42L52_ALC_RATE_3DB 1 246dfe0f98bSBrian Austin #define CS42L52_ALC_RATE_6DB 2 247dfe0f98bSBrian Austin 248dfe0f98bSBrian Austin #define CS42L52_NOISE_GATE_CTL 0x2D 249dfe0f98bSBrian Austin #define CS42L52_NG_ENABLE_SHIFT 6 250dfe0f98bSBrian Austin #define CS42L52_NG_THRESHOLD_SHIFT 2 251dfe0f98bSBrian Austin #define CS42L52_NG_MIN_70DB 2 252dfe0f98bSBrian Austin #define CS42L52_NG_DELAY_SHIFT 0 253dfe0f98bSBrian Austin #define CS42L52_NG_DELAY_100MS 1 254dfe0f98bSBrian Austin 255dfe0f98bSBrian Austin #define CS42L52_CLK_STATUS 0x2E 256dfe0f98bSBrian Austin #define CS42L52_BATT_COMPEN 0x2F 257dfe0f98bSBrian Austin 258dfe0f98bSBrian Austin #define CS42L52_BATT_LEVEL 0x30 259dfe0f98bSBrian Austin #define CS42L52_SPK_STATUS 0x31 260dfe0f98bSBrian Austin #define CS42L52_SPK_STATUS_PIN_SHIFT 3 261dfe0f98bSBrian Austin #define CS42L52_SPK_STATUS_PIN_HIGH 1 262dfe0f98bSBrian Austin 263dfe0f98bSBrian Austin #define CS42L52_TEM_CTL 0x32 264dfe0f98bSBrian Austin #define CS42L52_TEM_CTL_SET 0x80 265dfe0f98bSBrian Austin #define CS42L52_THE_FOLDBACK 0x33 266dfe0f98bSBrian Austin #define CS42L52_CHARGE_PUMP 0x34 267dfe0f98bSBrian Austin #define CS42L52_CHARGE_PUMP_MASK 0xF0 268dfe0f98bSBrian Austin #define CS42L52_CHARGE_PUMP_SHIFT 4 269dfe0f98bSBrian Austin #define CS42L52_FIX_BITS1 0x3E 270dfe0f98bSBrian Austin #define CS42L52_FIX_BITS2 0x47 271dfe0f98bSBrian Austin 272dfe0f98bSBrian Austin #define CS42L52_MAX_REGISTER 0x34 273dfe0f98bSBrian Austin 274dfe0f98bSBrian Austin #endif 275