/* * max98090.h -- MAX98090 ALSA SoC Audio driver * * Copyright 2011-2012 Maxim Integrated Products * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ #ifndef _MAX98090_H #define _MAX98090_H #include /* One can override the Linux version here with an explicit version number */ #define M98090_LINUX_VERSION LINUX_VERSION_CODE /* * MAX98090 Register Definitions */ #define M98090_REG_SOFTWARE_RESET 0x00 #define M98090_REG_DEVICE_STATUS 0x01 #define M98090_REG_JACK_STATUS 0x02 #define M98090_REG_INTERRUPT_S 0x03 #define M98090_REG_QUICK_SYSTEM_CLOCK 0x04 #define M98090_REG_QUICK_SAMPLE_RATE 0x05 #define M98090_REG_DAI_INTERFACE 0x06 #define M98090_REG_DAC_PATH 0x07 #define M98090_REG_MIC_DIRECT_TO_ADC 0x08 #define M98090_REG_LINE_TO_ADC 0x09 #define M98090_REG_ANALOG_MIC_LOOP 0x0A #define M98090_REG_ANALOG_LINE_LOOP 0x0B #define M98090_REG_RESERVED 0x0C #define M98090_REG_LINE_INPUT_CONFIG 0x0D #define M98090_REG_LINE_INPUT_LEVEL 0x0E #define M98090_REG_INPUT_MODE 0x0F #define M98090_REG_MIC1_INPUT_LEVEL 0x10 #define M98090_REG_MIC2_INPUT_LEVEL 0x11 #define M98090_REG_MIC_BIAS_VOLTAGE 0x12 #define M98090_REG_DIGITAL_MIC_ENABLE 0x13 #define M98090_REG_DIGITAL_MIC_CONFIG 0x14 #define M98090_REG_LEFT_ADC_MIXER 0x15 #define M98090_REG_RIGHT_ADC_MIXER 0x16 #define M98090_REG_LEFT_ADC_LEVEL 0x17 #define M98090_REG_RIGHT_ADC_LEVEL 0x18 #define M98090_REG_ADC_BIQUAD_LEVEL 0x19 #define M98090_REG_ADC_SIDETONE 0x1A #define M98090_REG_SYSTEM_CLOCK 0x1B #define M98090_REG_CLOCK_MODE 0x1C #define M98090_REG_CLOCK_RATIO_NI_MSB 0x1D #define M98090_REG_CLOCK_RATIO_NI_LSB 0x1E #define M98090_REG_CLOCK_RATIO_MI_MSB 0x1F #define M98090_REG_CLOCK_RATIO_MI_LSB 0x20 #define M98090_REG_MASTER_MODE 0x21 #define M98090_REG_INTERFACE_FORMAT 0x22 #define M98090_REG_TDM_CONTROL 0x23 #define M98090_REG_TDM_FORMAT 0x24 #define M98090_REG_IO_CONFIGURATION 0x25 #define M98090_REG_FILTER_CONFIG 0x26 #define M98090_REG_DAI_PLAYBACK_LEVEL 0x27 #define M98090_REG_DAI_PLAYBACK_LEVEL_EQ 0x28 #define M98090_REG_LEFT_HP_MIXER 0x29 #define M98090_REG_RIGHT_HP_MIXER 0x2A #define M98090_REG_HP_CONTROL 0x2B #define M98090_REG_LEFT_HP_VOLUME 0x2C #define M98090_REG_RIGHT_HP_VOLUME 0x2D #define M98090_REG_LEFT_SPK_MIXER 0x2E #define M98090_REG_RIGHT_SPK_MIXER 0x2F #define M98090_REG_SPK_CONTROL 0x30 #define M98090_REG_LEFT_SPK_VOLUME 0x31 #define M98090_REG_RIGHT_SPK_VOLUME 0x32 #define M98090_REG_DRC_TIMING 0x33 #define M98090_REG_DRC_COMPRESSOR 0x34 #define M98090_REG_DRC_EXPANDER 0x35 #define M98090_REG_DRC_GAIN 0x36 #define M98090_REG_RCV_LOUTL_MIXER 0x37 #define M98090_REG_RCV_LOUTL_CONTROL 0x38 #define M98090_REG_RCV_LOUTL_VOLUME 0x39 #define M98090_REG_LOUTR_MIXER 0x3A #define M98090_REG_LOUTR_CONTROL 0x3B #define M98090_REG_LOUTR_VOLUME 0x3C #define M98090_REG_JACK_DETECT 0x3D #define M98090_REG_INPUT_ENABLE 0x3E #define M98090_REG_OUTPUT_ENABLE 0x3F #define M98090_REG_LEVEL_CONTROL 0x40 #define M98090_REG_DSP_FILTER_ENABLE 0x41 #define M98090_REG_BIAS_CONTROL 0x42 #define M98090_REG_DAC_CONTROL 0x43 #define M98090_REG_ADC_CONTROL 0x44 #define M98090_REG_DEVICE_SHUTDOWN 0x45 #define M98090_REG_EQUALIZER_BASE 0x46 #define M98090_REG_RECORD_BIQUAD_BASE 0xAF #define M98090_REG_DMIC3_VOLUME 0xBE #define M98090_REG_DMIC4_VOLUME 0xBF #define M98090_REG_DMIC34_BQ_PREATTEN 0xC0 #define M98090_REG_RECORD_TDM_SLOT 0xC1 #define M98090_REG_SAMPLE_RATE 0xC2 #define M98090_REG_DMIC34_BIQUAD_BASE 0xC3 #define M98090_REG_REVISION_ID 0xFF #define M98090_REG_CNT (0xFF+1) #define MAX98090_MAX_REGISTER 0xFF /* MAX98090 Register Bit Fields */ /* * M98090_REG_SOFTWARE_RESET */ #define M98090_SWRESET_MASK (1<<7) #define M98090_SWRESET_SHIFT 7 #define M98090_SWRESET_WIDTH 1 /* * M98090_REG_DEVICE_STATUS */ #define M98090_CLD_MASK (1<<7) #define M98090_CLD_SHIFT 7 #define M98090_CLD_WIDTH 1 #define M98090_SLD_MASK (1<<6) #define M98090_SLD_SHIFT 6 #define M98090_SLD_WIDTH 1 #define M98090_ULK_MASK (1<<5) #define M98090_ULK_SHIFT 5 #define M98090_ULK_WIDTH 1 #define M98090_JDET_MASK (1<<2) #define M98090_JDET_SHIFT 2 #define M98090_JDET_WIDTH 1 #define M98090_DRCACT_MASK (1<<1) #define M98090_DRCACT_SHIFT 1 #define M98090_DRCACT_WIDTH 1 #define M98090_DRCCLP_MASK (1<<0) #define M98090_DRCCLP_SHIFT 0 #define M98090_DRCCLP_WIDTH 1 /* * M98090_REG_JACK_STATUS */ #define M98090_LSNS_MASK (1<<2) #define M98090_LSNS_SHIFT 2 #define M98090_LSNS_WIDTH 1 #define M98090_JKSNS_MASK (1<<1) #define M98090_JKSNS_SHIFT 1 #define M98090_JKSNS_WIDTH 1 /* * M98090_REG_INTERRUPT_S */ #define M98090_ICLD_MASK (1<<7) #define M98090_ICLD_SHIFT 7 #define M98090_ICLD_WIDTH 1 #define M98090_ISLD_MASK (1<<6) #define M98090_ISLD_SHIFT 6 #define M98090_ISLD_WIDTH 1 #define M98090_IULK_MASK (1<<5) #define M98090_IULK_SHIFT 5 #define M98090_IULK_WIDTH 1 #define M98090_IJDET_MASK (1<<2) #define M98090_IJDET_SHIFT 2 #define M98090_IJDET_WIDTH 1 #define M98090_IDRCACT_MASK (1<<1) #define M98090_IDRCACT_SHIFT 1 #define M98090_IDRCACT_WIDTH 1 #define M98090_IDRCCLP_MASK (1<<0) #define M98090_IDRCCLP_SHIFT 0 #define M98090_IDRCCLP_WIDTH 1 /* * M98090_REG_QUICK_SYSTEM_CLOCK */ #define M98090_26M_MASK (1<<7) #define M98090_26M_SHIFT 7 #define M98090_26M_WIDTH 1 #define M98090_19P2M_MASK (1<<6) #define M98090_19P2M_SHIFT 6 #define M98090_19P2M_WIDTH 1 #define M98090_13M_MASK (1<<5) #define M98090_13M_SHIFT 5 #define M98090_13M_WIDTH 1 #define M98090_12P288M_MASK (1<<4) #define M98090_12P288M_SHIFT 4 #define M98090_12P288M_WIDTH 1 #define M98090_12M_MASK (1<<3) #define M98090_12M_SHIFT 3 #define M98090_12M_WIDTH 1 #define M98090_11P2896M_MASK (1<<2) #define M98090_11P2896M_SHIFT 2 #define M98090_11P2896M_WIDTH 1 #define M98090_256FS_MASK (1<<0) #define M98090_256FS_SHIFT 0 #define M98090_256FS_WIDTH 1 #define M98090_CLK_ALL_SHIFT 0 #define M98090_CLK_ALL_WIDTH 8 #define M98090_CLK_ALL_NUM (1<> 8) & 0xff) #define M98090_BYTE0(w) (w & 0xff) /* Silicon revision number */ #define M98090_REVA 0x40 #define M98091_REVA 0x50 enum max98090_type { MAX98090, MAX98091, }; struct max98090_cdata { unsigned int rate; unsigned int fmt; }; struct max98090_priv { struct regmap *regmap; struct snd_soc_codec *codec; enum max98090_type devtype; struct max98090_pdata *pdata; struct clk *mclk; unsigned int sysclk; unsigned int bclk; unsigned int lrclk; struct max98090_cdata dai[1]; int irq; int jack_state; struct delayed_work jack_work; struct delayed_work pll_det_enable_work; struct work_struct pll_det_disable_work; struct work_struct pll_work; struct snd_soc_jack *jack; unsigned int dai_fmt; int tdm_slots; int tdm_width; u8 lin_state; unsigned int pa1en; unsigned int pa2en; unsigned int extmic_mux; unsigned int sidetone; bool master; }; int max98090_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack); #endif