1c942fddfSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */ 272ed5a8cSapatard@mandriva.com /* 372ed5a8cSapatard@mandriva.com * cs42l51.h 472ed5a8cSapatard@mandriva.com * 572ed5a8cSapatard@mandriva.com * ASoC Driver for Cirrus Logic CS42L51 codecs 672ed5a8cSapatard@mandriva.com * 772ed5a8cSapatard@mandriva.com * Copyright (c) 2010 Arnaud Patard <apatard@mandriva.com> 872ed5a8cSapatard@mandriva.com */ 972ed5a8cSapatard@mandriva.com #ifndef _CS42L51_H 1072ed5a8cSapatard@mandriva.com #define _CS42L51_H 1172ed5a8cSapatard@mandriva.com 12a1253ef6SBrian Austin struct device; 13a1253ef6SBrian Austin 14a1253ef6SBrian Austin extern const struct regmap_config cs42l51_regmap; 15a1253ef6SBrian Austin int cs42l51_probe(struct device *dev, struct regmap *regmap); 16*73d4c313SUwe Kleine-König void cs42l51_remove(struct device *dev); 1775a71482SOlivier Moysan int __maybe_unused cs42l51_suspend(struct device *dev); 1875a71482SOlivier Moysan int __maybe_unused cs42l51_resume(struct device *dev); 19a1253ef6SBrian Austin 2072ed5a8cSapatard@mandriva.com #define CS42L51_CHIP_ID 0x1B 2172ed5a8cSapatard@mandriva.com #define CS42L51_CHIP_REV_A 0x00 2272ed5a8cSapatard@mandriva.com #define CS42L51_CHIP_REV_B 0x01 231025c05fSAxel Lin #define CS42L51_CHIP_REV_MASK 0x07 2472ed5a8cSapatard@mandriva.com 2572ed5a8cSapatard@mandriva.com #define CS42L51_CHIP_REV_ID 0x01 2672ed5a8cSapatard@mandriva.com #define CS42L51_MK_CHIP_REV(a, b) ((a)<<3|(b)) 2772ed5a8cSapatard@mandriva.com 2872ed5a8cSapatard@mandriva.com #define CS42L51_POWER_CTL1 0x02 2972ed5a8cSapatard@mandriva.com #define CS42L51_POWER_CTL1_PDN_DACB (1<<6) 3072ed5a8cSapatard@mandriva.com #define CS42L51_POWER_CTL1_PDN_DACA (1<<5) 3172ed5a8cSapatard@mandriva.com #define CS42L51_POWER_CTL1_PDN_PGAB (1<<4) 3272ed5a8cSapatard@mandriva.com #define CS42L51_POWER_CTL1_PDN_PGAA (1<<3) 3372ed5a8cSapatard@mandriva.com #define CS42L51_POWER_CTL1_PDN_ADCB (1<<2) 3472ed5a8cSapatard@mandriva.com #define CS42L51_POWER_CTL1_PDN_ADCA (1<<1) 3572ed5a8cSapatard@mandriva.com #define CS42L51_POWER_CTL1_PDN (1<<0) 3672ed5a8cSapatard@mandriva.com 3772ed5a8cSapatard@mandriva.com #define CS42L51_MIC_POWER_CTL 0x03 3872ed5a8cSapatard@mandriva.com #define CS42L51_MIC_POWER_CTL_AUTO (1<<7) 3972ed5a8cSapatard@mandriva.com #define CS42L51_MIC_POWER_CTL_SPEED(x) (((x)&3)<<5) 4072ed5a8cSapatard@mandriva.com #define CS42L51_QSM_MODE 3 4172ed5a8cSapatard@mandriva.com #define CS42L51_HSM_MODE 2 4272ed5a8cSapatard@mandriva.com #define CS42L51_SSM_MODE 1 4372ed5a8cSapatard@mandriva.com #define CS42L51_DSM_MODE 0 4472ed5a8cSapatard@mandriva.com #define CS42L51_MIC_POWER_CTL_3ST_SP (1<<4) 4572ed5a8cSapatard@mandriva.com #define CS42L51_MIC_POWER_CTL_PDN_MICB (1<<3) 4672ed5a8cSapatard@mandriva.com #define CS42L51_MIC_POWER_CTL_PDN_MICA (1<<2) 4772ed5a8cSapatard@mandriva.com #define CS42L51_MIC_POWER_CTL_PDN_BIAS (1<<1) 4872ed5a8cSapatard@mandriva.com #define CS42L51_MIC_POWER_CTL_MCLK_DIV2 (1<<0) 4972ed5a8cSapatard@mandriva.com 5072ed5a8cSapatard@mandriva.com #define CS42L51_INTF_CTL 0x04 5172ed5a8cSapatard@mandriva.com #define CS42L51_INTF_CTL_LOOPBACK (1<<7) 5272ed5a8cSapatard@mandriva.com #define CS42L51_INTF_CTL_MASTER (1<<6) 5372ed5a8cSapatard@mandriva.com #define CS42L51_INTF_CTL_DAC_FORMAT(x) (((x)&7)<<3) 5472ed5a8cSapatard@mandriva.com #define CS42L51_DAC_DIF_LJ24 0x00 5572ed5a8cSapatard@mandriva.com #define CS42L51_DAC_DIF_I2S 0x01 5672ed5a8cSapatard@mandriva.com #define CS42L51_DAC_DIF_RJ24 0x02 5772ed5a8cSapatard@mandriva.com #define CS42L51_DAC_DIF_RJ20 0x03 5872ed5a8cSapatard@mandriva.com #define CS42L51_DAC_DIF_RJ18 0x04 5972ed5a8cSapatard@mandriva.com #define CS42L51_DAC_DIF_RJ16 0x05 6072ed5a8cSapatard@mandriva.com #define CS42L51_INTF_CTL_ADC_I2S (1<<2) 6172ed5a8cSapatard@mandriva.com #define CS42L51_INTF_CTL_DIGMIX (1<<1) 6272ed5a8cSapatard@mandriva.com #define CS42L51_INTF_CTL_MICMIX (1<<0) 6372ed5a8cSapatard@mandriva.com 6472ed5a8cSapatard@mandriva.com #define CS42L51_MIC_CTL 0x05 6572ed5a8cSapatard@mandriva.com #define CS42L51_MIC_CTL_ADC_SNGVOL (1<<7) 6672ed5a8cSapatard@mandriva.com #define CS42L51_MIC_CTL_ADCD_DBOOST (1<<6) 6772ed5a8cSapatard@mandriva.com #define CS42L51_MIC_CTL_ADCA_DBOOST (1<<5) 6872ed5a8cSapatard@mandriva.com #define CS42L51_MIC_CTL_MICBIAS_SEL (1<<4) 6972ed5a8cSapatard@mandriva.com #define CS42L51_MIC_CTL_MICBIAS_LVL(x) (((x)&3)<<2) 7072ed5a8cSapatard@mandriva.com #define CS42L51_MIC_CTL_MICB_BOOST (1<<1) 7172ed5a8cSapatard@mandriva.com #define CS42L51_MIC_CTL_MICA_BOOST (1<<0) 7272ed5a8cSapatard@mandriva.com 7372ed5a8cSapatard@mandriva.com #define CS42L51_ADC_CTL 0x06 7472ed5a8cSapatard@mandriva.com #define CS42L51_ADC_CTL_ADCB_HPFEN (1<<7) 7572ed5a8cSapatard@mandriva.com #define CS42L51_ADC_CTL_ADCB_HPFRZ (1<<6) 7672ed5a8cSapatard@mandriva.com #define CS42L51_ADC_CTL_ADCA_HPFEN (1<<5) 7772ed5a8cSapatard@mandriva.com #define CS42L51_ADC_CTL_ADCA_HPFRZ (1<<4) 7872ed5a8cSapatard@mandriva.com #define CS42L51_ADC_CTL_SOFTB (1<<3) 7972ed5a8cSapatard@mandriva.com #define CS42L51_ADC_CTL_ZCROSSB (1<<2) 8072ed5a8cSapatard@mandriva.com #define CS42L51_ADC_CTL_SOFTA (1<<1) 8172ed5a8cSapatard@mandriva.com #define CS42L51_ADC_CTL_ZCROSSA (1<<0) 8272ed5a8cSapatard@mandriva.com 8372ed5a8cSapatard@mandriva.com #define CS42L51_ADC_INPUT 0x07 8472ed5a8cSapatard@mandriva.com #define CS42L51_ADC_INPUT_AINB_MUX(x) (((x)&3)<<6) 8572ed5a8cSapatard@mandriva.com #define CS42L51_ADC_INPUT_AINA_MUX(x) (((x)&3)<<4) 8672ed5a8cSapatard@mandriva.com #define CS42L51_ADC_INPUT_INV_ADCB (1<<3) 8772ed5a8cSapatard@mandriva.com #define CS42L51_ADC_INPUT_INV_ADCA (1<<2) 8872ed5a8cSapatard@mandriva.com #define CS42L51_ADC_INPUT_ADCB_MUTE (1<<1) 8972ed5a8cSapatard@mandriva.com #define CS42L51_ADC_INPUT_ADCA_MUTE (1<<0) 9072ed5a8cSapatard@mandriva.com 9172ed5a8cSapatard@mandriva.com #define CS42L51_DAC_OUT_CTL 0x08 9272ed5a8cSapatard@mandriva.com #define CS42L51_DAC_OUT_CTL_HP_GAIN(x) (((x)&7)<<5) 9372ed5a8cSapatard@mandriva.com #define CS42L51_DAC_OUT_CTL_DAC_SNGVOL (1<<4) 9472ed5a8cSapatard@mandriva.com #define CS42L51_DAC_OUT_CTL_INV_PCMB (1<<3) 9572ed5a8cSapatard@mandriva.com #define CS42L51_DAC_OUT_CTL_INV_PCMA (1<<2) 9672ed5a8cSapatard@mandriva.com #define CS42L51_DAC_OUT_CTL_DACB_MUTE (1<<1) 9772ed5a8cSapatard@mandriva.com #define CS42L51_DAC_OUT_CTL_DACA_MUTE (1<<0) 9872ed5a8cSapatard@mandriva.com 9972ed5a8cSapatard@mandriva.com #define CS42L51_DAC_CTL 0x09 10072ed5a8cSapatard@mandriva.com #define CS42L51_DAC_CTL_DATA_SEL(x) (((x)&3)<<6) 10172ed5a8cSapatard@mandriva.com #define CS42L51_DAC_CTL_FREEZE (1<<5) 10272ed5a8cSapatard@mandriva.com #define CS42L51_DAC_CTL_DEEMPH (1<<3) 10372ed5a8cSapatard@mandriva.com #define CS42L51_DAC_CTL_AMUTE (1<<2) 10472ed5a8cSapatard@mandriva.com #define CS42L51_DAC_CTL_DACSZ(x) (((x)&3)<<0) 10572ed5a8cSapatard@mandriva.com 10672ed5a8cSapatard@mandriva.com #define CS42L51_ALC_PGA_CTL 0x0A 10772ed5a8cSapatard@mandriva.com #define CS42L51_ALC_PGB_CTL 0x0B 10872ed5a8cSapatard@mandriva.com #define CS42L51_ALC_PGX_ALCX_SRDIS (1<<7) 10972ed5a8cSapatard@mandriva.com #define CS42L51_ALC_PGX_ALCX_ZCDIS (1<<6) 11072ed5a8cSapatard@mandriva.com #define CS42L51_ALC_PGX_PGX_VOL(x) (((x)&0x1f)<<0) 11172ed5a8cSapatard@mandriva.com 11272ed5a8cSapatard@mandriva.com #define CS42L51_ADCA_ATT 0x0C 11372ed5a8cSapatard@mandriva.com #define CS42L51_ADCB_ATT 0x0D 11472ed5a8cSapatard@mandriva.com 11572ed5a8cSapatard@mandriva.com #define CS42L51_ADCA_VOL 0x0E 11672ed5a8cSapatard@mandriva.com #define CS42L51_ADCB_VOL 0x0F 11772ed5a8cSapatard@mandriva.com #define CS42L51_PCMA_VOL 0x10 11872ed5a8cSapatard@mandriva.com #define CS42L51_PCMB_VOL 0x11 11972ed5a8cSapatard@mandriva.com #define CS42L51_MIX_MUTE_ADCMIX (1<<7) 12072ed5a8cSapatard@mandriva.com #define CS42L51_MIX_VOLUME(x) (((x)&0x7f)<<0) 12172ed5a8cSapatard@mandriva.com 12272ed5a8cSapatard@mandriva.com #define CS42L51_BEEP_FREQ 0x12 12372ed5a8cSapatard@mandriva.com #define CS42L51_BEEP_VOL 0x13 12472ed5a8cSapatard@mandriva.com #define CS42L51_BEEP_CONF 0x14 12572ed5a8cSapatard@mandriva.com 12672ed5a8cSapatard@mandriva.com #define CS42L51_TONE_CTL 0x15 12772ed5a8cSapatard@mandriva.com #define CS42L51_TONE_CTL_TREB(x) (((x)&0xf)<<4) 12872ed5a8cSapatard@mandriva.com #define CS42L51_TONE_CTL_BASS(x) (((x)&0xf)<<0) 12972ed5a8cSapatard@mandriva.com 13072ed5a8cSapatard@mandriva.com #define CS42L51_AOUTA_VOL 0x16 13172ed5a8cSapatard@mandriva.com #define CS42L51_AOUTB_VOL 0x17 13272ed5a8cSapatard@mandriva.com #define CS42L51_PCM_MIXER 0x18 13372ed5a8cSapatard@mandriva.com #define CS42L51_LIMIT_THRES_DIS 0x19 13472ed5a8cSapatard@mandriva.com #define CS42L51_LIMIT_REL 0x1A 13572ed5a8cSapatard@mandriva.com #define CS42L51_LIMIT_ATT 0x1B 13672ed5a8cSapatard@mandriva.com #define CS42L51_ALC_EN 0x1C 13772ed5a8cSapatard@mandriva.com #define CS42L51_ALC_REL 0x1D 13872ed5a8cSapatard@mandriva.com #define CS42L51_ALC_THRES 0x1E 13972ed5a8cSapatard@mandriva.com #define CS42L51_NOISE_CONF 0x1F 14072ed5a8cSapatard@mandriva.com 14172ed5a8cSapatard@mandriva.com #define CS42L51_STATUS 0x20 14272ed5a8cSapatard@mandriva.com #define CS42L51_STATUS_SP_CLKERR (1<<6) 14372ed5a8cSapatard@mandriva.com #define CS42L51_STATUS_SPEA_OVFL (1<<5) 14472ed5a8cSapatard@mandriva.com #define CS42L51_STATUS_SPEB_OVFL (1<<4) 14572ed5a8cSapatard@mandriva.com #define CS42L51_STATUS_PCMA_OVFL (1<<3) 14672ed5a8cSapatard@mandriva.com #define CS42L51_STATUS_PCMB_OVFL (1<<2) 14772ed5a8cSapatard@mandriva.com #define CS42L51_STATUS_ADCA_OVFL (1<<1) 14872ed5a8cSapatard@mandriva.com #define CS42L51_STATUS_ADCB_OVFL (1<<0) 14972ed5a8cSapatard@mandriva.com 15072ed5a8cSapatard@mandriva.com #define CS42L51_CHARGE_FREQ 0x21 15172ed5a8cSapatard@mandriva.com 15272ed5a8cSapatard@mandriva.com #define CS42L51_FIRSTREG 0x01 15372ed5a8cSapatard@mandriva.com /* 15472ed5a8cSapatard@mandriva.com * Hack: with register 0x21, it makes 33 registers. Looks like someone in the 15572ed5a8cSapatard@mandriva.com * i2c layer doesn't like i2c smbus block read of 33 regs. Workaround by using 15672ed5a8cSapatard@mandriva.com * 32 regs 15772ed5a8cSapatard@mandriva.com */ 15872ed5a8cSapatard@mandriva.com #define CS42L51_LASTREG 0x20 15972ed5a8cSapatard@mandriva.com #define CS42L51_NUMREGS (CS42L51_LASTREG - CS42L51_FIRSTREG + 1) 16072ed5a8cSapatard@mandriva.com 16172ed5a8cSapatard@mandriva.com #endif 162