Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 1 | /* |
| 2 | * DA7210 ALSA Soc codec driver |
| 3 | * |
| 4 | * Copyright (c) 2009 Dialog Semiconductor |
| 5 | * Written by David Chen <Dajun.chen@diasemi.com> |
| 6 | * |
| 7 | * Copyright (C) 2009 Renesas Solutions Corp. |
| 8 | * Cleanups by Kuninori Morimoto <morimoto.kuninori@renesas.com> |
| 9 | * |
| 10 | * Tested on SuperH Ecovec24 board with S16/S24 LE in 48KHz using I2S |
| 11 | * |
| 12 | * This program is free software; you can redistribute it and/or modify it |
| 13 | * under the terms of the GNU General Public License as published by the |
| 14 | * Free Software Foundation; either version 2 of the License, or (at your |
| 15 | * option) any later version. |
| 16 | */ |
| 17 | |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 18 | #include <linux/delay.h> |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 19 | #include <linux/i2c.h> |
| 20 | #include <linux/platform_device.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 21 | #include <linux/slab.h> |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 22 | #include <sound/pcm.h> |
| 23 | #include <sound/pcm_params.h> |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 24 | #include <sound/soc.h> |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 25 | #include <sound/initval.h> |
Kuninori Morimoto | a7e7cd5 | 2010-07-21 14:12:16 +0900 | [diff] [blame] | 26 | #include <sound/tlv.h> |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 27 | |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 28 | /* DA7210 register space */ |
Ashish Chavan | de5eaf8 | 2011-10-19 14:24:37 +0530 | [diff] [blame] | 29 | #define DA7210_CONTROL 0x01 |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 30 | #define DA7210_STATUS 0x02 |
| 31 | #define DA7210_STARTUP1 0x03 |
Ashish Chavan | 6950c60 | 2011-10-21 18:16:08 +0530 | [diff] [blame^] | 32 | #define DA7210_STARTUP2 0x04 |
| 33 | #define DA7210_STARTUP3 0x05 |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 34 | #define DA7210_MIC_L 0x07 |
| 35 | #define DA7210_MIC_R 0x08 |
Ashish Chavan | de5eaf8 | 2011-10-19 14:24:37 +0530 | [diff] [blame] | 36 | #define DA7210_AUX1_L 0x09 |
| 37 | #define DA7210_AUX1_R 0x0A |
Ashish Chavan | 5eda194 | 2011-10-19 14:19:06 +0530 | [diff] [blame] | 38 | #define DA7210_AUX2 0x0B |
Ashish Chavan | de5eaf8 | 2011-10-19 14:24:37 +0530 | [diff] [blame] | 39 | #define DA7210_IN_GAIN 0x0C |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 40 | #define DA7210_INMIX_L 0x0D |
| 41 | #define DA7210_INMIX_R 0x0E |
| 42 | #define DA7210_ADC_HPF 0x0F |
| 43 | #define DA7210_ADC 0x10 |
Ashish Chavan | 0ee6e9e | 2011-10-15 14:47:56 +0530 | [diff] [blame] | 44 | #define DA7210_ADC_EQ1_2 0X11 |
| 45 | #define DA7210_ADC_EQ3_4 0x12 |
| 46 | #define DA7210_ADC_EQ5 0x13 |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 47 | #define DA7210_DAC_HPF 0x14 |
| 48 | #define DA7210_DAC_L 0x15 |
| 49 | #define DA7210_DAC_R 0x16 |
| 50 | #define DA7210_DAC_SEL 0x17 |
Ashish Chavan | 5eda194 | 2011-10-19 14:19:06 +0530 | [diff] [blame] | 51 | #define DA7210_SOFTMUTE 0x18 |
Ashish Chavan | 0ee6e9e | 2011-10-15 14:47:56 +0530 | [diff] [blame] | 52 | #define DA7210_DAC_EQ1_2 0x19 |
| 53 | #define DA7210_DAC_EQ3_4 0x1A |
| 54 | #define DA7210_DAC_EQ5 0x1B |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 55 | #define DA7210_OUTMIX_L 0x1C |
| 56 | #define DA7210_OUTMIX_R 0x1D |
| 57 | #define DA7210_HP_L_VOL 0x21 |
| 58 | #define DA7210_HP_R_VOL 0x22 |
| 59 | #define DA7210_HP_CFG 0x23 |
Ashish Chavan | 5eda194 | 2011-10-19 14:19:06 +0530 | [diff] [blame] | 60 | #define DA7210_ZERO_CROSS 0x24 |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 61 | #define DA7210_DAI_SRC_SEL 0x25 |
| 62 | #define DA7210_DAI_CFG1 0x26 |
| 63 | #define DA7210_DAI_CFG3 0x28 |
Kuninori Morimoto | 960b3b4 | 2010-03-11 11:37:44 +0900 | [diff] [blame] | 64 | #define DA7210_PLL_DIV1 0x29 |
| 65 | #define DA7210_PLL_DIV2 0x2A |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 66 | #define DA7210_PLL_DIV3 0x2B |
| 67 | #define DA7210_PLL 0x2C |
Ashish Chavan | de5eaf8 | 2011-10-19 14:24:37 +0530 | [diff] [blame] | 68 | #define DA7210_ALC_MAX 0x83 |
| 69 | #define DA7210_ALC_MIN 0x84 |
| 70 | #define DA7210_ALC_NOIS 0x85 |
| 71 | #define DA7210_ALC_ATT 0x86 |
| 72 | #define DA7210_ALC_REL 0x87 |
| 73 | #define DA7210_ALC_DEL 0x88 |
Kuninori Morimoto | 960b3b4 | 2010-03-11 11:37:44 +0900 | [diff] [blame] | 74 | #define DA7210_A_HID_UNLOCK 0x8A |
| 75 | #define DA7210_A_TEST_UNLOCK 0x8B |
| 76 | #define DA7210_A_PLL1 0x90 |
| 77 | #define DA7210_A_CP_MODE 0xA7 |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 78 | |
| 79 | /* STARTUP1 bit fields */ |
| 80 | #define DA7210_SC_MST_EN (1 << 0) |
| 81 | |
| 82 | /* MIC_L bit fields */ |
| 83 | #define DA7210_MICBIAS_EN (1 << 6) |
| 84 | #define DA7210_MIC_L_EN (1 << 7) |
| 85 | |
| 86 | /* MIC_R bit fields */ |
| 87 | #define DA7210_MIC_R_EN (1 << 7) |
| 88 | |
| 89 | /* INMIX_L bit fields */ |
| 90 | #define DA7210_IN_L_EN (1 << 7) |
| 91 | |
| 92 | /* INMIX_R bit fields */ |
| 93 | #define DA7210_IN_R_EN (1 << 7) |
| 94 | |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 95 | /* ADC bit fields */ |
Ashish Chavan | de5eaf8 | 2011-10-19 14:24:37 +0530 | [diff] [blame] | 96 | #define DA7210_ADC_ALC_EN (1 << 0) |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 97 | #define DA7210_ADC_L_EN (1 << 3) |
| 98 | #define DA7210_ADC_R_EN (1 << 7) |
| 99 | |
Kuninori Morimoto | 3a9d620 | 2010-03-01 10:10:43 +0900 | [diff] [blame] | 100 | /* DAC/ADC HPF fields */ |
| 101 | #define DA7210_VOICE_F0_MASK (0x7 << 4) |
| 102 | #define DA7210_VOICE_F0_25 (1 << 4) |
| 103 | #define DA7210_VOICE_EN (1 << 7) |
Mark Brown | c215143 | 2009-12-16 20:36:37 +0000 | [diff] [blame] | 104 | |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 105 | /* DAC_SEL bit fields */ |
| 106 | #define DA7210_DAC_L_SRC_DAI_L (4 << 0) |
| 107 | #define DA7210_DAC_L_EN (1 << 3) |
| 108 | #define DA7210_DAC_R_SRC_DAI_R (5 << 4) |
| 109 | #define DA7210_DAC_R_EN (1 << 7) |
| 110 | |
| 111 | /* OUTMIX_L bit fields */ |
| 112 | #define DA7210_OUT_L_EN (1 << 7) |
| 113 | |
| 114 | /* OUTMIX_R bit fields */ |
| 115 | #define DA7210_OUT_R_EN (1 << 7) |
| 116 | |
| 117 | /* HP_CFG bit fields */ |
| 118 | #define DA7210_HP_2CAP_MODE (1 << 1) |
| 119 | #define DA7210_HP_SENSE_EN (1 << 2) |
| 120 | #define DA7210_HP_L_EN (1 << 3) |
| 121 | #define DA7210_HP_MODE (1 << 6) |
| 122 | #define DA7210_HP_R_EN (1 << 7) |
| 123 | |
| 124 | /* DAI_SRC_SEL bit fields */ |
| 125 | #define DA7210_DAI_OUT_L_SRC (6 << 0) |
| 126 | #define DA7210_DAI_OUT_R_SRC (7 << 4) |
| 127 | |
| 128 | /* DAI_CFG1 bit fields */ |
| 129 | #define DA7210_DAI_WORD_S16_LE (0 << 0) |
Ashish Chavan | 0f8ea58 | 2011-10-12 20:33:21 +0530 | [diff] [blame] | 130 | #define DA7210_DAI_WORD_S20_3LE (1 << 0) |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 131 | #define DA7210_DAI_WORD_S24_LE (2 << 0) |
Ashish Chavan | 0f8ea58 | 2011-10-12 20:33:21 +0530 | [diff] [blame] | 132 | #define DA7210_DAI_WORD_S32_LE (3 << 0) |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 133 | #define DA7210_DAI_FLEN_64BIT (1 << 2) |
Ashish Chavan | 0f8ea58 | 2011-10-12 20:33:21 +0530 | [diff] [blame] | 134 | #define DA7210_DAI_MODE_SLAVE (0 << 7) |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 135 | #define DA7210_DAI_MODE_MASTER (1 << 7) |
| 136 | |
| 137 | /* DAI_CFG3 bit fields */ |
| 138 | #define DA7210_DAI_FORMAT_I2SMODE (0 << 0) |
Ashish Chavan | 0f8ea58 | 2011-10-12 20:33:21 +0530 | [diff] [blame] | 139 | #define DA7210_DAI_FORMAT_LEFT_J (1 << 0) |
| 140 | #define DA7210_DAI_FORMAT_RIGHT_J (2 << 0) |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 141 | #define DA7210_DAI_OE (1 << 3) |
| 142 | #define DA7210_DAI_EN (1 << 7) |
| 143 | |
| 144 | /*PLL_DIV3 bit fields */ |
| 145 | #define DA7210_MCLK_RANGE_10_20_MHZ (1 << 4) |
| 146 | #define DA7210_PLL_BYP (1 << 6) |
| 147 | |
| 148 | /* PLL bit fields */ |
Kuninori Morimoto | 3a9d620 | 2010-03-01 10:10:43 +0900 | [diff] [blame] | 149 | #define DA7210_PLL_FS_MASK (0xF << 0) |
| 150 | #define DA7210_PLL_FS_8000 (0x1 << 0) |
Kuninori Morimoto | 960b3b4 | 2010-03-11 11:37:44 +0900 | [diff] [blame] | 151 | #define DA7210_PLL_FS_11025 (0x2 << 0) |
Kuninori Morimoto | 3a9d620 | 2010-03-01 10:10:43 +0900 | [diff] [blame] | 152 | #define DA7210_PLL_FS_12000 (0x3 << 0) |
| 153 | #define DA7210_PLL_FS_16000 (0x5 << 0) |
Kuninori Morimoto | 960b3b4 | 2010-03-11 11:37:44 +0900 | [diff] [blame] | 154 | #define DA7210_PLL_FS_22050 (0x6 << 0) |
Kuninori Morimoto | 3a9d620 | 2010-03-01 10:10:43 +0900 | [diff] [blame] | 155 | #define DA7210_PLL_FS_24000 (0x7 << 0) |
| 156 | #define DA7210_PLL_FS_32000 (0x9 << 0) |
Kuninori Morimoto | 960b3b4 | 2010-03-11 11:37:44 +0900 | [diff] [blame] | 157 | #define DA7210_PLL_FS_44100 (0xA << 0) |
Kuninori Morimoto | 3a9d620 | 2010-03-01 10:10:43 +0900 | [diff] [blame] | 158 | #define DA7210_PLL_FS_48000 (0xB << 0) |
Kuninori Morimoto | 960b3b4 | 2010-03-11 11:37:44 +0900 | [diff] [blame] | 159 | #define DA7210_PLL_FS_88200 (0xE << 0) |
Kuninori Morimoto | 3a9d620 | 2010-03-01 10:10:43 +0900 | [diff] [blame] | 160 | #define DA7210_PLL_FS_96000 (0xF << 0) |
Kuninori Morimoto | 960b3b4 | 2010-03-11 11:37:44 +0900 | [diff] [blame] | 161 | #define DA7210_PLL_EN (0x1 << 7) |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 162 | |
Ashish Chavan | 5eda194 | 2011-10-19 14:19:06 +0530 | [diff] [blame] | 163 | /* SOFTMUTE bit fields */ |
| 164 | #define DA7210_RAMP_EN (1 << 6) |
| 165 | |
Ashish Chavan | de5eaf8 | 2011-10-19 14:24:37 +0530 | [diff] [blame] | 166 | /* CONTROL bit fields */ |
| 167 | #define DA7210_NOISE_SUP_EN (1 << 3) |
| 168 | |
| 169 | /* IN_GAIN bit fields */ |
| 170 | #define DA7210_INPGA_L_VOL (0x0F << 0) |
| 171 | #define DA7210_INPGA_R_VOL (0xF0 << 0) |
| 172 | |
| 173 | /* ZERO_CROSS bit fields */ |
| 174 | #define DA7210_AUX1_L_ZC (1 << 0) |
| 175 | #define DA7210_AUX1_R_ZC (1 << 1) |
| 176 | #define DA7210_HP_L_ZC (1 << 6) |
| 177 | #define DA7210_HP_R_ZC (1 << 7) |
| 178 | |
| 179 | /* AUX1_L bit fields */ |
| 180 | #define DA7210_AUX1_L_VOL (0x3F << 0) |
| 181 | |
| 182 | /* AUX1_R bit fields */ |
| 183 | #define DA7210_AUX1_R_VOL (0x3F << 0) |
| 184 | |
| 185 | /* Minimum INPGA and AUX1 volume to enable noise suppression */ |
| 186 | #define DA7210_INPGA_MIN_VOL_NS 0x0A /* 10.5dB */ |
| 187 | #define DA7210_AUX1_MIN_VOL_NS 0x35 /* 6dB */ |
| 188 | |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 189 | #define DA7210_VERSION "0.0.1" |
| 190 | |
Kuninori Morimoto | a7e7cd5 | 2010-07-21 14:12:16 +0900 | [diff] [blame] | 191 | /* |
| 192 | * Playback Volume |
| 193 | * |
| 194 | * max : 0x3F (+15.0 dB) |
| 195 | * (1.5 dB step) |
| 196 | * min : 0x11 (-54.0 dB) |
| 197 | * mute : 0x10 |
| 198 | * reserved : 0x00 - 0x0F |
| 199 | * |
Kuninori Morimoto | a7e7cd5 | 2010-07-21 14:12:16 +0900 | [diff] [blame] | 200 | * Reserved area are considered as "mute". |
Kuninori Morimoto | a7e7cd5 | 2010-07-21 14:12:16 +0900 | [diff] [blame] | 201 | */ |
Ashish Chavan | 7a0e67b | 2011-10-14 16:25:25 +0530 | [diff] [blame] | 202 | static const unsigned int hp_out_tlv[] = { |
| 203 | TLV_DB_RANGE_HEAD(2), |
| 204 | 0x0, 0x10, TLV_DB_SCALE_ITEM(TLV_DB_GAIN_MUTE, 0, 1), |
| 205 | /* -54 dB to +15 dB */ |
| 206 | 0x11, 0x3f, TLV_DB_SCALE_ITEM(-5400, 150, 0), |
| 207 | }; |
Kuninori Morimoto | a7e7cd5 | 2010-07-21 14:12:16 +0900 | [diff] [blame] | 208 | |
Ashish Chavan | 0ee6e9e | 2011-10-15 14:47:56 +0530 | [diff] [blame] | 209 | static const DECLARE_TLV_DB_SCALE(eq_gain_tlv, -1050, 150, 0); |
| 210 | static const DECLARE_TLV_DB_SCALE(adc_eq_master_gain_tlv, -1800, 600, 1); |
| 211 | |
Ashish Chavan | 4ced2b9 | 2011-10-15 14:50:06 +0530 | [diff] [blame] | 212 | /* ADC and DAC high pass filter f0 value */ |
| 213 | static const char const *da7210_hpf_cutoff_txt[] = { |
| 214 | "Fs/8192*pi", "Fs/4096*pi", "Fs/2048*pi", "Fs/1024*pi" |
| 215 | }; |
| 216 | |
| 217 | static const struct soc_enum da7210_dac_hpf_cutoff = |
| 218 | SOC_ENUM_SINGLE(DA7210_DAC_HPF, 0, 4, da7210_hpf_cutoff_txt); |
| 219 | |
| 220 | static const struct soc_enum da7210_adc_hpf_cutoff = |
| 221 | SOC_ENUM_SINGLE(DA7210_ADC_HPF, 0, 4, da7210_hpf_cutoff_txt); |
| 222 | |
| 223 | /* ADC and DAC voice (8kHz) high pass cutoff value */ |
| 224 | static const char const *da7210_vf_cutoff_txt[] = { |
| 225 | "2.5Hz", "25Hz", "50Hz", "100Hz", "150Hz", "200Hz", "300Hz", "400Hz" |
| 226 | }; |
| 227 | |
| 228 | static const struct soc_enum da7210_dac_vf_cutoff = |
| 229 | SOC_ENUM_SINGLE(DA7210_DAC_HPF, 4, 8, da7210_vf_cutoff_txt); |
| 230 | |
| 231 | static const struct soc_enum da7210_adc_vf_cutoff = |
| 232 | SOC_ENUM_SINGLE(DA7210_ADC_HPF, 4, 8, da7210_vf_cutoff_txt); |
| 233 | |
Ashish Chavan | 5eda194 | 2011-10-19 14:19:06 +0530 | [diff] [blame] | 234 | static const char *da7210_hp_mode_txt[] = { |
| 235 | "Class H", "Class G" |
| 236 | }; |
| 237 | |
| 238 | static const struct soc_enum da7210_hp_mode_sel = |
| 239 | SOC_ENUM_SINGLE(DA7210_HP_CFG, 0, 2, da7210_hp_mode_txt); |
| 240 | |
Ashish Chavan | de5eaf8 | 2011-10-19 14:24:37 +0530 | [diff] [blame] | 241 | /* ALC can be enabled only if noise suppression is disabled */ |
| 242 | static int da7210_put_alc_sw(struct snd_kcontrol *kcontrol, |
| 243 | struct snd_ctl_elem_value *ucontrol) |
| 244 | { |
| 245 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); |
| 246 | |
| 247 | if (ucontrol->value.integer.value[0]) { |
| 248 | /* Check if noise suppression is enabled */ |
| 249 | if (snd_soc_read(codec, DA7210_CONTROL) & DA7210_NOISE_SUP_EN) { |
| 250 | dev_dbg(codec->dev, |
| 251 | "Disable noise suppression to enable ALC\n"); |
| 252 | return -EINVAL; |
| 253 | } |
| 254 | } |
| 255 | /* If all conditions are met or we are actually disabling ALC */ |
| 256 | return snd_soc_put_volsw(kcontrol, ucontrol); |
| 257 | } |
| 258 | |
| 259 | /* Noise suppression can be enabled only if following conditions are met |
| 260 | * ALC disabled |
| 261 | * ZC enabled for HP and AUX1 PGA |
| 262 | * INPGA_L_VOL and INPGA_R_VOL >= 10.5 dB |
| 263 | * AUX1_L_VOL and AUX1_R_VOL >= 6 dB |
| 264 | */ |
| 265 | static int da7210_put_noise_sup_sw(struct snd_kcontrol *kcontrol, |
| 266 | struct snd_ctl_elem_value *ucontrol) |
| 267 | { |
| 268 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); |
| 269 | u8 val; |
| 270 | |
| 271 | if (ucontrol->value.integer.value[0]) { |
| 272 | /* Check if ALC is enabled */ |
| 273 | if (snd_soc_read(codec, DA7210_ADC) & DA7210_ADC_ALC_EN) |
| 274 | goto err; |
| 275 | |
| 276 | /* Check ZC for HP and AUX1 PGA */ |
| 277 | if ((snd_soc_read(codec, DA7210_ZERO_CROSS) & |
| 278 | (DA7210_AUX1_L_ZC | DA7210_AUX1_R_ZC | DA7210_HP_L_ZC | |
| 279 | DA7210_HP_R_ZC)) != (DA7210_AUX1_L_ZC | |
| 280 | DA7210_AUX1_R_ZC | DA7210_HP_L_ZC | DA7210_HP_R_ZC)) |
| 281 | goto err; |
| 282 | |
| 283 | /* Check INPGA_L_VOL and INPGA_R_VOL */ |
| 284 | val = snd_soc_read(codec, DA7210_IN_GAIN); |
| 285 | if (((val & DA7210_INPGA_L_VOL) < DA7210_INPGA_MIN_VOL_NS) || |
| 286 | (((val & DA7210_INPGA_R_VOL) >> 4) < |
| 287 | DA7210_INPGA_MIN_VOL_NS)) |
| 288 | goto err; |
| 289 | |
| 290 | /* Check AUX1_L_VOL and AUX1_R_VOL */ |
| 291 | if (((snd_soc_read(codec, DA7210_AUX1_L) & DA7210_AUX1_L_VOL) < |
| 292 | DA7210_AUX1_MIN_VOL_NS) || |
| 293 | ((snd_soc_read(codec, DA7210_AUX1_R) & DA7210_AUX1_R_VOL) < |
| 294 | DA7210_AUX1_MIN_VOL_NS)) |
| 295 | goto err; |
| 296 | } |
| 297 | /* If all conditions are met or we are actually disabling Noise sup */ |
| 298 | return snd_soc_put_volsw(kcontrol, ucontrol); |
| 299 | |
| 300 | err: |
| 301 | return -EINVAL; |
| 302 | } |
| 303 | |
Kuninori Morimoto | a7e7cd5 | 2010-07-21 14:12:16 +0900 | [diff] [blame] | 304 | static const struct snd_kcontrol_new da7210_snd_controls[] = { |
| 305 | |
| 306 | SOC_DOUBLE_R_TLV("HeadPhone Playback Volume", |
| 307 | DA7210_HP_L_VOL, DA7210_HP_R_VOL, |
| 308 | 0, 0x3F, 0, hp_out_tlv), |
Ashish Chavan | 0ee6e9e | 2011-10-15 14:47:56 +0530 | [diff] [blame] | 309 | |
| 310 | /* DAC Equalizer controls */ |
| 311 | SOC_SINGLE("DAC EQ Switch", DA7210_DAC_EQ5, 7, 1, 0), |
| 312 | SOC_SINGLE_TLV("DAC EQ1 Volume", DA7210_DAC_EQ1_2, 0, 0xf, 1, |
| 313 | eq_gain_tlv), |
| 314 | SOC_SINGLE_TLV("DAC EQ2 Volume", DA7210_DAC_EQ1_2, 4, 0xf, 1, |
| 315 | eq_gain_tlv), |
| 316 | SOC_SINGLE_TLV("DAC EQ3 Volume", DA7210_DAC_EQ3_4, 0, 0xf, 1, |
| 317 | eq_gain_tlv), |
| 318 | SOC_SINGLE_TLV("DAC EQ4 Volume", DA7210_DAC_EQ3_4, 4, 0xf, 1, |
| 319 | eq_gain_tlv), |
| 320 | SOC_SINGLE_TLV("DAC EQ5 Volume", DA7210_DAC_EQ5, 0, 0xf, 1, |
| 321 | eq_gain_tlv), |
| 322 | |
| 323 | /* ADC Equalizer controls */ |
| 324 | SOC_SINGLE("ADC EQ Switch", DA7210_ADC_EQ5, 7, 1, 0), |
| 325 | SOC_SINGLE_TLV("ADC EQ Master Volume", DA7210_ADC_EQ5, 4, 0x3, |
| 326 | 1, adc_eq_master_gain_tlv), |
| 327 | SOC_SINGLE_TLV("ADC EQ1 Volume", DA7210_ADC_EQ1_2, 0, 0xf, 1, |
| 328 | eq_gain_tlv), |
| 329 | SOC_SINGLE_TLV("ADC EQ2 Volume", DA7210_ADC_EQ1_2, 4, 0xf, 1, |
| 330 | eq_gain_tlv), |
| 331 | SOC_SINGLE_TLV("ADC EQ3 Volume", DA7210_ADC_EQ3_4, 0, 0xf, 1, |
| 332 | eq_gain_tlv), |
| 333 | SOC_SINGLE_TLV("ADC EQ4 Volume", DA7210_ADC_EQ3_4, 4, 0xf, 1, |
| 334 | eq_gain_tlv), |
| 335 | SOC_SINGLE_TLV("ADC EQ5 Volume", DA7210_ADC_EQ5, 0, 0xf, 1, |
| 336 | eq_gain_tlv), |
Ashish Chavan | 4ced2b9 | 2011-10-15 14:50:06 +0530 | [diff] [blame] | 337 | |
| 338 | SOC_SINGLE("DAC HPF Switch", DA7210_DAC_HPF, 3, 1, 0), |
| 339 | SOC_ENUM("DAC HPF Cutoff", da7210_dac_hpf_cutoff), |
| 340 | SOC_SINGLE("DAC Voice Mode Switch", DA7210_DAC_HPF, 7, 1, 0), |
| 341 | SOC_ENUM("DAC Voice Cutoff", da7210_dac_vf_cutoff), |
| 342 | |
| 343 | SOC_SINGLE("ADC HPF Switch", DA7210_ADC_HPF, 3, 1, 0), |
| 344 | SOC_ENUM("ADC HPF Cutoff", da7210_adc_hpf_cutoff), |
| 345 | SOC_SINGLE("ADC Voice Mode Switch", DA7210_ADC_HPF, 7, 1, 0), |
| 346 | SOC_ENUM("ADC Voice Cutoff", da7210_adc_vf_cutoff), |
Ashish Chavan | 5eda194 | 2011-10-19 14:19:06 +0530 | [diff] [blame] | 347 | |
| 348 | /* Mute controls */ |
| 349 | SOC_DOUBLE_R("Mic Capture Switch", DA7210_MIC_L, DA7210_MIC_R, 3, 1, 0), |
| 350 | SOC_SINGLE("Aux2 Capture Switch", DA7210_AUX2, 2, 1, 0), |
| 351 | SOC_DOUBLE("ADC Capture Switch", DA7210_ADC, 2, 6, 1, 0), |
| 352 | SOC_SINGLE("Digital Soft Mute Switch", DA7210_SOFTMUTE, 7, 1, 0), |
| 353 | SOC_SINGLE("Digital Soft Mute Rate", DA7210_SOFTMUTE, 0, 0x7, 0), |
| 354 | |
| 355 | /* Zero cross controls */ |
| 356 | SOC_DOUBLE("Aux1 ZC Switch", DA7210_ZERO_CROSS, 0, 1, 1, 0), |
| 357 | SOC_DOUBLE("In PGA ZC Switch", DA7210_ZERO_CROSS, 2, 3, 1, 0), |
| 358 | SOC_DOUBLE("Lineout ZC Switch", DA7210_ZERO_CROSS, 4, 5, 1, 0), |
| 359 | SOC_DOUBLE("Headphone ZC Switch", DA7210_ZERO_CROSS, 6, 7, 1, 0), |
| 360 | |
| 361 | SOC_ENUM("Headphone Class", da7210_hp_mode_sel), |
Ashish Chavan | de5eaf8 | 2011-10-19 14:24:37 +0530 | [diff] [blame] | 362 | |
| 363 | /* ALC controls */ |
| 364 | SOC_SINGLE_EXT("ALC Enable Switch", DA7210_ADC, 0, 1, 0, |
| 365 | snd_soc_get_volsw, da7210_put_alc_sw), |
| 366 | SOC_SINGLE("ALC Capture Max Volume", DA7210_ALC_MAX, 0, 0x3F, 0), |
| 367 | SOC_SINGLE("ALC Capture Min Volume", DA7210_ALC_MIN, 0, 0x3F, 0), |
| 368 | SOC_SINGLE("ALC Capture Noise Volume", DA7210_ALC_NOIS, 0, 0x3F, 0), |
| 369 | SOC_SINGLE("ALC Capture Attack Rate", DA7210_ALC_ATT, 0, 0xFF, 0), |
| 370 | SOC_SINGLE("ALC Capture Release Rate", DA7210_ALC_REL, 0, 0xFF, 0), |
| 371 | SOC_SINGLE("ALC Capture Release Delay", DA7210_ALC_DEL, 0, 0xFF, 0), |
| 372 | |
| 373 | SOC_SINGLE_EXT("Noise Suppression Enable Switch", DA7210_CONTROL, 3, 1, |
| 374 | 0, snd_soc_get_volsw, da7210_put_noise_sup_sw), |
Kuninori Morimoto | a7e7cd5 | 2010-07-21 14:12:16 +0900 | [diff] [blame] | 375 | }; |
| 376 | |
Ashish Chavan | 6950c60 | 2011-10-21 18:16:08 +0530 | [diff] [blame^] | 377 | /* |
| 378 | * DAPM Controls |
| 379 | * |
| 380 | * Current DAPM implementation covers almost all codec components e.g. IOs, |
| 381 | * mixers, PGAs,ADC and DAC. |
| 382 | */ |
| 383 | /* In Mixer Left */ |
| 384 | static const struct snd_kcontrol_new da7210_dapm_inmixl_controls[] = { |
| 385 | SOC_DAPM_SINGLE("Mic Left Switch", DA7210_INMIX_L, 0, 1, 0), |
| 386 | SOC_DAPM_SINGLE("Mic Right Switch", DA7210_INMIX_L, 1, 1, 0), |
| 387 | }; |
| 388 | |
| 389 | /* In Mixer Right */ |
| 390 | static const struct snd_kcontrol_new da7210_dapm_inmixr_controls[] = { |
| 391 | SOC_DAPM_SINGLE("Mic Right Switch", DA7210_INMIX_R, 0, 1, 0), |
| 392 | SOC_DAPM_SINGLE("Mic Left Switch", DA7210_INMIX_R, 1, 1, 0), |
| 393 | }; |
| 394 | |
| 395 | /* Out Mixer Left */ |
| 396 | static const struct snd_kcontrol_new da7210_dapm_outmixl_controls[] = { |
| 397 | SOC_DAPM_SINGLE("DAC Left Switch", DA7210_OUTMIX_L, 4, 1, 0), |
| 398 | }; |
| 399 | |
| 400 | /* Out Mixer Right */ |
| 401 | static const struct snd_kcontrol_new da7210_dapm_outmixr_controls[] = { |
| 402 | SOC_DAPM_SINGLE("DAC Right Switch", DA7210_OUTMIX_R, 4, 1, 0), |
| 403 | }; |
| 404 | |
| 405 | /* DAPM widgets */ |
| 406 | static const struct snd_soc_dapm_widget da7210_dapm_widgets[] = { |
| 407 | /* Input Side */ |
| 408 | /* Input Lines */ |
| 409 | SND_SOC_DAPM_INPUT("MICL"), |
| 410 | SND_SOC_DAPM_INPUT("MICR"), |
| 411 | |
| 412 | /* Input PGAs */ |
| 413 | SND_SOC_DAPM_PGA("Mic Left", DA7210_STARTUP3, 0, 1, NULL, 0), |
| 414 | SND_SOC_DAPM_PGA("Mic Right", DA7210_STARTUP3, 1, 1, NULL, 0), |
| 415 | |
| 416 | SND_SOC_DAPM_PGA("INPGA Left", DA7210_INMIX_L, 7, 0, NULL, 0), |
| 417 | SND_SOC_DAPM_PGA("INPGA Right", DA7210_INMIX_R, 7, 0, NULL, 0), |
| 418 | |
| 419 | /* Input Mixers */ |
| 420 | SND_SOC_DAPM_MIXER("In Mixer Left", SND_SOC_NOPM, 0, 0, |
| 421 | &da7210_dapm_inmixl_controls[0], |
| 422 | ARRAY_SIZE(da7210_dapm_inmixl_controls)), |
| 423 | |
| 424 | SND_SOC_DAPM_MIXER("In Mixer Right", SND_SOC_NOPM, 0, 0, |
| 425 | &da7210_dapm_inmixr_controls[0], |
| 426 | ARRAY_SIZE(da7210_dapm_inmixr_controls)), |
| 427 | |
| 428 | /* ADCs */ |
| 429 | SND_SOC_DAPM_ADC("ADC Left", "Capture", DA7210_STARTUP3, 5, 1), |
| 430 | SND_SOC_DAPM_ADC("ADC Right", "Capture", DA7210_STARTUP3, 6, 1), |
| 431 | |
| 432 | /* Output Side */ |
| 433 | /* DACs */ |
| 434 | SND_SOC_DAPM_DAC("DAC Left", "Playback", DA7210_STARTUP2, 5, 1), |
| 435 | SND_SOC_DAPM_DAC("DAC Right", "Playback", DA7210_STARTUP2, 6, 1), |
| 436 | |
| 437 | /* Output Mixers */ |
| 438 | SND_SOC_DAPM_MIXER("Out Mixer Left", SND_SOC_NOPM, 0, 0, |
| 439 | &da7210_dapm_outmixl_controls[0], |
| 440 | ARRAY_SIZE(da7210_dapm_outmixl_controls)), |
| 441 | |
| 442 | SND_SOC_DAPM_MIXER("Out Mixer Right", SND_SOC_NOPM, 0, 0, |
| 443 | &da7210_dapm_outmixr_controls[0], |
| 444 | ARRAY_SIZE(da7210_dapm_outmixr_controls)), |
| 445 | |
| 446 | /* Output PGAs */ |
| 447 | SND_SOC_DAPM_PGA("OUTPGA Left Enable", DA7210_OUTMIX_L, 7, 0, NULL, 0), |
| 448 | SND_SOC_DAPM_PGA("OUTPGA Right Enable", DA7210_OUTMIX_R, 7, 0, NULL, 0), |
| 449 | |
| 450 | SND_SOC_DAPM_PGA("Headphone Left", DA7210_STARTUP2, 3, 1, NULL, 0), |
| 451 | SND_SOC_DAPM_PGA("Headphone Right", DA7210_STARTUP2, 4, 1, NULL, 0), |
| 452 | |
| 453 | /* Output Lines */ |
| 454 | SND_SOC_DAPM_OUTPUT("HPL"), |
| 455 | SND_SOC_DAPM_OUTPUT("HPR"), |
| 456 | }; |
| 457 | |
| 458 | /* DAPM audio route definition */ |
| 459 | static const struct snd_soc_dapm_route da7210_audio_map[] = { |
| 460 | /* Dest Connecting Widget source */ |
| 461 | /* Input path */ |
| 462 | {"Mic Left", NULL, "MICL"}, |
| 463 | {"Mic Right", NULL, "MICR"}, |
| 464 | |
| 465 | {"In Mixer Left", "Mic Left Switch", "Mic Left"}, |
| 466 | {"In Mixer Left", "Mic Right Switch", "Mic Right"}, |
| 467 | |
| 468 | {"In Mixer Right", "Mic Right Switch", "Mic Right"}, |
| 469 | {"In Mixer Right", "Mic Left Switch", "Mic Left"}, |
| 470 | |
| 471 | {"INPGA Left", NULL, "In Mixer Left"}, |
| 472 | {"ADC Left", NULL, "INPGA Left"}, |
| 473 | |
| 474 | {"INPGA Right", NULL, "In Mixer Right"}, |
| 475 | {"ADC Right", NULL, "INPGA Right"}, |
| 476 | |
| 477 | /* Output path */ |
| 478 | {"Out Mixer Left", "DAC Left Switch", "DAC Left"}, |
| 479 | {"Out Mixer Right", "DAC Right Switch", "DAC Right"}, |
| 480 | |
| 481 | {"OUTPGA Left Enable", NULL, "Out Mixer Left"}, |
| 482 | {"OUTPGA Right Enable", NULL, "Out Mixer Right"}, |
| 483 | |
| 484 | {"Headphone Left", NULL, "OUTPGA Left Enable"}, |
| 485 | {"HPL", NULL, "Headphone Left"}, |
| 486 | |
| 487 | {"Headphone Right", NULL, "OUTPGA Right Enable"}, |
| 488 | {"HPR", NULL, "Headphone Right"}, |
| 489 | }; |
| 490 | |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 491 | /* Codec private data */ |
| 492 | struct da7210_priv { |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 493 | enum snd_soc_control_type control_type; |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 494 | }; |
| 495 | |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 496 | /* |
| 497 | * Register cache |
| 498 | */ |
| 499 | static const u8 da7210_reg[] = { |
| 500 | 0x00, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* R0 - R7 */ |
| 501 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, /* R8 - RF */ |
| 502 | 0x00, 0x00, 0x00, 0x00, 0x08, 0x10, 0x10, 0x54, /* R10 - R17 */ |
| 503 | 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* R18 - R1F */ |
| 504 | 0x00, 0x00, 0x00, 0x02, 0x00, 0x76, 0x00, 0x00, /* R20 - R27 */ |
| 505 | 0x04, 0x00, 0x00, 0x30, 0x2A, 0x00, 0x40, 0x00, /* R28 - R2F */ |
| 506 | 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, /* R30 - R37 */ |
| 507 | 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x00, 0x00, /* R38 - R3F */ |
| 508 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* R40 - R4F */ |
| 509 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* R48 - R4F */ |
| 510 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* R50 - R57 */ |
| 511 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* R58 - R5F */ |
| 512 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* R60 - R67 */ |
| 513 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* R68 - R6F */ |
| 514 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* R70 - R77 */ |
| 515 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x54, 0x54, 0x00, /* R78 - R7F */ |
| 516 | 0x00, 0x00, 0x2C, 0x00, 0x00, 0x00, 0x00, 0x00, /* R80 - R87 */ |
| 517 | 0x00, /* R88 */ |
| 518 | }; |
| 519 | |
Axel Lin | 40a4971 | 2011-10-12 07:16:25 +0800 | [diff] [blame] | 520 | static int da7210_volatile_register(struct snd_soc_codec *codec, |
| 521 | unsigned int reg) |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 522 | { |
Axel Lin | 40a4971 | 2011-10-12 07:16:25 +0800 | [diff] [blame] | 523 | switch (reg) { |
| 524 | case DA7210_STATUS: |
| 525 | return 1; |
| 526 | default: |
| 527 | return 0; |
| 528 | } |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 529 | } |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 530 | |
| 531 | /* |
| 532 | * Set PCM DAI word length. |
| 533 | */ |
| 534 | static int da7210_hw_params(struct snd_pcm_substream *substream, |
| 535 | struct snd_pcm_hw_params *params, |
| 536 | struct snd_soc_dai *dai) |
| 537 | { |
| 538 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 539 | struct snd_soc_codec *codec = rtd->codec; |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 540 | u32 dai_cfg1; |
Kuninori Morimoto | 960b3b4 | 2010-03-11 11:37:44 +0900 | [diff] [blame] | 541 | u32 fs, bypass; |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 542 | |
| 543 | /* set DAI source to Left and Right ADC */ |
Axel Lin | 40a4971 | 2011-10-12 07:16:25 +0800 | [diff] [blame] | 544 | snd_soc_write(codec, DA7210_DAI_SRC_SEL, |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 545 | DA7210_DAI_OUT_R_SRC | DA7210_DAI_OUT_L_SRC); |
| 546 | |
| 547 | /* Enable DAI */ |
Axel Lin | 40a4971 | 2011-10-12 07:16:25 +0800 | [diff] [blame] | 548 | snd_soc_write(codec, DA7210_DAI_CFG3, DA7210_DAI_OE | DA7210_DAI_EN); |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 549 | |
Axel Lin | 40a4971 | 2011-10-12 07:16:25 +0800 | [diff] [blame] | 550 | dai_cfg1 = 0xFC & snd_soc_read(codec, DA7210_DAI_CFG1); |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 551 | |
| 552 | switch (params_format(params)) { |
| 553 | case SNDRV_PCM_FORMAT_S16_LE: |
| 554 | dai_cfg1 |= DA7210_DAI_WORD_S16_LE; |
| 555 | break; |
Ashish Chavan | 0f8ea58 | 2011-10-12 20:33:21 +0530 | [diff] [blame] | 556 | case SNDRV_PCM_FORMAT_S20_3LE: |
| 557 | dai_cfg1 |= DA7210_DAI_WORD_S20_3LE; |
| 558 | break; |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 559 | case SNDRV_PCM_FORMAT_S24_LE: |
| 560 | dai_cfg1 |= DA7210_DAI_WORD_S24_LE; |
| 561 | break; |
Ashish Chavan | 0f8ea58 | 2011-10-12 20:33:21 +0530 | [diff] [blame] | 562 | case SNDRV_PCM_FORMAT_S32_LE: |
| 563 | dai_cfg1 |= DA7210_DAI_WORD_S32_LE; |
| 564 | break; |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 565 | default: |
| 566 | return -EINVAL; |
| 567 | } |
| 568 | |
Axel Lin | 40a4971 | 2011-10-12 07:16:25 +0800 | [diff] [blame] | 569 | snd_soc_write(codec, DA7210_DAI_CFG1, dai_cfg1); |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 570 | |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 571 | switch (params_rate(params)) { |
Kuninori Morimoto | 3a9d620 | 2010-03-01 10:10:43 +0900 | [diff] [blame] | 572 | case 8000: |
| 573 | fs = DA7210_PLL_FS_8000; |
Kuninori Morimoto | 960b3b4 | 2010-03-11 11:37:44 +0900 | [diff] [blame] | 574 | bypass = DA7210_PLL_BYP; |
| 575 | break; |
| 576 | case 11025: |
| 577 | fs = DA7210_PLL_FS_11025; |
Kuninori Morimoto | 960b3b4 | 2010-03-11 11:37:44 +0900 | [diff] [blame] | 578 | bypass = 0; |
Kuninori Morimoto | 3a9d620 | 2010-03-01 10:10:43 +0900 | [diff] [blame] | 579 | break; |
| 580 | case 12000: |
| 581 | fs = DA7210_PLL_FS_12000; |
Kuninori Morimoto | 960b3b4 | 2010-03-11 11:37:44 +0900 | [diff] [blame] | 582 | bypass = DA7210_PLL_BYP; |
Kuninori Morimoto | 3a9d620 | 2010-03-01 10:10:43 +0900 | [diff] [blame] | 583 | break; |
| 584 | case 16000: |
| 585 | fs = DA7210_PLL_FS_16000; |
Kuninori Morimoto | 960b3b4 | 2010-03-11 11:37:44 +0900 | [diff] [blame] | 586 | bypass = DA7210_PLL_BYP; |
| 587 | break; |
| 588 | case 22050: |
| 589 | fs = DA7210_PLL_FS_22050; |
Kuninori Morimoto | 960b3b4 | 2010-03-11 11:37:44 +0900 | [diff] [blame] | 590 | bypass = 0; |
Kuninori Morimoto | 3a9d620 | 2010-03-01 10:10:43 +0900 | [diff] [blame] | 591 | break; |
| 592 | case 32000: |
| 593 | fs = DA7210_PLL_FS_32000; |
Kuninori Morimoto | 960b3b4 | 2010-03-11 11:37:44 +0900 | [diff] [blame] | 594 | bypass = DA7210_PLL_BYP; |
| 595 | break; |
| 596 | case 44100: |
| 597 | fs = DA7210_PLL_FS_44100; |
Kuninori Morimoto | 960b3b4 | 2010-03-11 11:37:44 +0900 | [diff] [blame] | 598 | bypass = 0; |
Kuninori Morimoto | 3a9d620 | 2010-03-01 10:10:43 +0900 | [diff] [blame] | 599 | break; |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 600 | case 48000: |
Kuninori Morimoto | 3a9d620 | 2010-03-01 10:10:43 +0900 | [diff] [blame] | 601 | fs = DA7210_PLL_FS_48000; |
Kuninori Morimoto | 960b3b4 | 2010-03-11 11:37:44 +0900 | [diff] [blame] | 602 | bypass = DA7210_PLL_BYP; |
| 603 | break; |
| 604 | case 88200: |
| 605 | fs = DA7210_PLL_FS_88200; |
Kuninori Morimoto | 960b3b4 | 2010-03-11 11:37:44 +0900 | [diff] [blame] | 606 | bypass = 0; |
Kuninori Morimoto | 3a9d620 | 2010-03-01 10:10:43 +0900 | [diff] [blame] | 607 | break; |
| 608 | case 96000: |
| 609 | fs = DA7210_PLL_FS_96000; |
Kuninori Morimoto | 960b3b4 | 2010-03-11 11:37:44 +0900 | [diff] [blame] | 610 | bypass = DA7210_PLL_BYP; |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 611 | break; |
| 612 | default: |
| 613 | return -EINVAL; |
| 614 | } |
| 615 | |
Kuninori Morimoto | 960b3b4 | 2010-03-11 11:37:44 +0900 | [diff] [blame] | 616 | /* Disable active mode */ |
| 617 | snd_soc_update_bits(codec, DA7210_STARTUP1, DA7210_SC_MST_EN, 0); |
| 618 | |
Kuninori Morimoto | 3a9d620 | 2010-03-01 10:10:43 +0900 | [diff] [blame] | 619 | snd_soc_update_bits(codec, DA7210_PLL, DA7210_PLL_FS_MASK, fs); |
Kuninori Morimoto | 960b3b4 | 2010-03-11 11:37:44 +0900 | [diff] [blame] | 620 | snd_soc_update_bits(codec, DA7210_PLL_DIV3, DA7210_PLL_BYP, bypass); |
| 621 | |
| 622 | /* Enable active mode */ |
| 623 | snd_soc_update_bits(codec, DA7210_STARTUP1, |
| 624 | DA7210_SC_MST_EN, DA7210_SC_MST_EN); |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 625 | |
| 626 | return 0; |
| 627 | } |
| 628 | |
| 629 | /* |
| 630 | * Set DAI mode and Format |
| 631 | */ |
| 632 | static int da7210_set_dai_fmt(struct snd_soc_dai *codec_dai, u32 fmt) |
| 633 | { |
| 634 | struct snd_soc_codec *codec = codec_dai->codec; |
| 635 | u32 dai_cfg1; |
| 636 | u32 dai_cfg3; |
| 637 | |
Axel Lin | 40a4971 | 2011-10-12 07:16:25 +0800 | [diff] [blame] | 638 | dai_cfg1 = 0x7f & snd_soc_read(codec, DA7210_DAI_CFG1); |
| 639 | dai_cfg3 = 0xfc & snd_soc_read(codec, DA7210_DAI_CFG3); |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 640 | |
| 641 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { |
| 642 | case SND_SOC_DAIFMT_CBM_CFM: |
| 643 | dai_cfg1 |= DA7210_DAI_MODE_MASTER; |
| 644 | break; |
Ashish Chavan | 0f8ea58 | 2011-10-12 20:33:21 +0530 | [diff] [blame] | 645 | case SND_SOC_DAIFMT_CBS_CFS: |
| 646 | dai_cfg1 |= DA7210_DAI_MODE_SLAVE; |
| 647 | break; |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 648 | default: |
| 649 | return -EINVAL; |
| 650 | } |
| 651 | |
| 652 | /* FIXME |
| 653 | * |
| 654 | * It support I2S only now |
| 655 | */ |
| 656 | switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { |
| 657 | case SND_SOC_DAIFMT_I2S: |
| 658 | dai_cfg3 |= DA7210_DAI_FORMAT_I2SMODE; |
| 659 | break; |
Ashish Chavan | 0f8ea58 | 2011-10-12 20:33:21 +0530 | [diff] [blame] | 660 | case SND_SOC_DAIFMT_LEFT_J: |
| 661 | dai_cfg3 |= DA7210_DAI_FORMAT_LEFT_J; |
| 662 | break; |
| 663 | case SND_SOC_DAIFMT_RIGHT_J: |
| 664 | dai_cfg3 |= DA7210_DAI_FORMAT_RIGHT_J; |
| 665 | break; |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 666 | default: |
| 667 | return -EINVAL; |
| 668 | } |
| 669 | |
| 670 | /* FIXME |
| 671 | * |
| 672 | * It support 64bit data transmission only now |
| 673 | */ |
| 674 | dai_cfg1 |= DA7210_DAI_FLEN_64BIT; |
| 675 | |
Axel Lin | 40a4971 | 2011-10-12 07:16:25 +0800 | [diff] [blame] | 676 | snd_soc_write(codec, DA7210_DAI_CFG1, dai_cfg1); |
| 677 | snd_soc_write(codec, DA7210_DAI_CFG3, dai_cfg3); |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 678 | |
| 679 | return 0; |
| 680 | } |
| 681 | |
Ashish Chavan | 5eda194 | 2011-10-19 14:19:06 +0530 | [diff] [blame] | 682 | static int da7210_mute(struct snd_soc_dai *dai, int mute) |
| 683 | { |
| 684 | struct snd_soc_codec *codec = dai->codec; |
| 685 | u8 mute_reg = snd_soc_read(codec, DA7210_DAC_HPF) & 0xFB; |
| 686 | |
| 687 | if (mute) |
| 688 | snd_soc_write(codec, DA7210_DAC_HPF, mute_reg | 0x4); |
| 689 | else |
| 690 | snd_soc_write(codec, DA7210_DAC_HPF, mute_reg); |
| 691 | return 0; |
| 692 | } |
| 693 | |
Ashish Chavan | 0f8ea58 | 2011-10-12 20:33:21 +0530 | [diff] [blame] | 694 | #define DA7210_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\ |
| 695 | SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE) |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 696 | |
| 697 | /* DAI operations */ |
| 698 | static struct snd_soc_dai_ops da7210_dai_ops = { |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 699 | .hw_params = da7210_hw_params, |
| 700 | .set_fmt = da7210_set_dai_fmt, |
Ashish Chavan | 5eda194 | 2011-10-19 14:19:06 +0530 | [diff] [blame] | 701 | .digital_mute = da7210_mute, |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 702 | }; |
| 703 | |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 704 | static struct snd_soc_dai_driver da7210_dai = { |
| 705 | .name = "da7210-hifi", |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 706 | /* playback capabilities */ |
| 707 | .playback = { |
| 708 | .stream_name = "Playback", |
| 709 | .channels_min = 1, |
| 710 | .channels_max = 2, |
| 711 | .rates = SNDRV_PCM_RATE_8000_96000, |
| 712 | .formats = DA7210_FORMATS, |
| 713 | }, |
| 714 | /* capture capabilities */ |
| 715 | .capture = { |
| 716 | .stream_name = "Capture", |
| 717 | .channels_min = 1, |
| 718 | .channels_max = 2, |
| 719 | .rates = SNDRV_PCM_RATE_8000_96000, |
| 720 | .formats = DA7210_FORMATS, |
| 721 | }, |
| 722 | .ops = &da7210_dai_ops, |
Kuninori Morimoto | 960b3b4 | 2010-03-11 11:37:44 +0900 | [diff] [blame] | 723 | .symmetric_rates = 1, |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 724 | }; |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 725 | |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 726 | static int da7210_probe(struct snd_soc_codec *codec) |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 727 | { |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 728 | struct da7210_priv *da7210 = snd_soc_codec_get_drvdata(codec); |
Axel Lin | 40a4971 | 2011-10-12 07:16:25 +0800 | [diff] [blame] | 729 | int ret; |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 730 | |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 731 | dev_info(codec->dev, "DA7210 Audio Codec %s\n", DA7210_VERSION); |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 732 | |
Axel Lin | 40a4971 | 2011-10-12 07:16:25 +0800 | [diff] [blame] | 733 | ret = snd_soc_codec_set_cache_io(codec, 8, 8, da7210->control_type); |
| 734 | if (ret < 0) { |
| 735 | dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); |
| 736 | return ret; |
| 737 | } |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 738 | |
| 739 | /* FIXME |
| 740 | * |
| 741 | * This driver use fixed value here |
Kuninori Morimoto | 960b3b4 | 2010-03-11 11:37:44 +0900 | [diff] [blame] | 742 | * And below settings expects MCLK = 12.288MHz |
| 743 | * |
| 744 | * When you select different MCLK, please check... |
| 745 | * DA7210_PLL_DIV1 val |
| 746 | * DA7210_PLL_DIV2 val |
| 747 | * DA7210_PLL_DIV3 val |
| 748 | * DA7210_PLL_DIV3 :: DA7210_MCLK_RANGExxx |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 749 | */ |
| 750 | |
| 751 | /* |
Kuninori Morimoto | 960b3b4 | 2010-03-11 11:37:44 +0900 | [diff] [blame] | 752 | * make sure that DA7210 use bypass mode before start up |
| 753 | */ |
Axel Lin | 40a4971 | 2011-10-12 07:16:25 +0800 | [diff] [blame] | 754 | snd_soc_write(codec, DA7210_STARTUP1, 0); |
| 755 | snd_soc_write(codec, DA7210_PLL_DIV3, |
Kuninori Morimoto | 960b3b4 | 2010-03-11 11:37:44 +0900 | [diff] [blame] | 756 | DA7210_MCLK_RANGE_10_20_MHZ | DA7210_PLL_BYP); |
| 757 | |
| 758 | /* |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 759 | * ADC settings |
| 760 | */ |
| 761 | |
| 762 | /* Enable Left & Right MIC PGA and Mic Bias */ |
Axel Lin | 40a4971 | 2011-10-12 07:16:25 +0800 | [diff] [blame] | 763 | snd_soc_write(codec, DA7210_MIC_L, DA7210_MIC_L_EN | DA7210_MICBIAS_EN); |
| 764 | snd_soc_write(codec, DA7210_MIC_R, DA7210_MIC_R_EN); |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 765 | |
| 766 | /* Enable Left and Right input PGA */ |
Axel Lin | 40a4971 | 2011-10-12 07:16:25 +0800 | [diff] [blame] | 767 | snd_soc_write(codec, DA7210_INMIX_L, DA7210_IN_L_EN); |
| 768 | snd_soc_write(codec, DA7210_INMIX_R, DA7210_IN_R_EN); |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 769 | |
| 770 | /* Enable Left and Right ADC */ |
Axel Lin | 40a4971 | 2011-10-12 07:16:25 +0800 | [diff] [blame] | 771 | snd_soc_write(codec, DA7210_ADC, DA7210_ADC_L_EN | DA7210_ADC_R_EN); |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 772 | |
| 773 | /* |
| 774 | * DAC settings |
| 775 | */ |
| 776 | |
| 777 | /* Enable Left and Right DAC */ |
Axel Lin | 40a4971 | 2011-10-12 07:16:25 +0800 | [diff] [blame] | 778 | snd_soc_write(codec, DA7210_DAC_SEL, |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 779 | DA7210_DAC_L_SRC_DAI_L | DA7210_DAC_L_EN | |
| 780 | DA7210_DAC_R_SRC_DAI_R | DA7210_DAC_R_EN); |
| 781 | |
| 782 | /* Enable Left and Right out PGA */ |
Axel Lin | 40a4971 | 2011-10-12 07:16:25 +0800 | [diff] [blame] | 783 | snd_soc_write(codec, DA7210_OUTMIX_L, DA7210_OUT_L_EN); |
| 784 | snd_soc_write(codec, DA7210_OUTMIX_R, DA7210_OUT_R_EN); |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 785 | |
| 786 | /* Enable Left and Right HeadPhone PGA */ |
Axel Lin | 40a4971 | 2011-10-12 07:16:25 +0800 | [diff] [blame] | 787 | snd_soc_write(codec, DA7210_HP_CFG, |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 788 | DA7210_HP_2CAP_MODE | DA7210_HP_SENSE_EN | |
| 789 | DA7210_HP_L_EN | DA7210_HP_MODE | DA7210_HP_R_EN); |
| 790 | |
Ashish Chavan | 5eda194 | 2011-10-19 14:19:06 +0530 | [diff] [blame] | 791 | /* Enable ramp mode for DAC gain update */ |
| 792 | snd_soc_write(codec, DA7210_SOFTMUTE, DA7210_RAMP_EN); |
| 793 | |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 794 | /* Diable PLL and bypass it */ |
Axel Lin | 40a4971 | 2011-10-12 07:16:25 +0800 | [diff] [blame] | 795 | snd_soc_write(codec, DA7210_PLL, DA7210_PLL_FS_48000); |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 796 | |
Kuninori Morimoto | 960b3b4 | 2010-03-11 11:37:44 +0900 | [diff] [blame] | 797 | /* |
| 798 | * If 48kHz sound came, it use bypass mode, |
| 799 | * and when it is 44.1kHz, it use PLL. |
| 800 | * |
| 801 | * This time, this driver sets PLL always ON |
| 802 | * and controls bypass/PLL mode by switching |
| 803 | * DA7210_PLL_DIV3 :: DA7210_PLL_BYP bit. |
| 804 | * see da7210_hw_params |
| 805 | */ |
Axel Lin | 40a4971 | 2011-10-12 07:16:25 +0800 | [diff] [blame] | 806 | snd_soc_write(codec, DA7210_PLL_DIV1, 0xE5); /* MCLK = 12.288MHz */ |
| 807 | snd_soc_write(codec, DA7210_PLL_DIV2, 0x99); |
| 808 | snd_soc_write(codec, DA7210_PLL_DIV3, 0x0A | |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 809 | DA7210_MCLK_RANGE_10_20_MHZ | DA7210_PLL_BYP); |
Kuninori Morimoto | 960b3b4 | 2010-03-11 11:37:44 +0900 | [diff] [blame] | 810 | snd_soc_update_bits(codec, DA7210_PLL, DA7210_PLL_EN, DA7210_PLL_EN); |
| 811 | |
| 812 | /* As suggested by Dialog */ |
Axel Lin | 40a4971 | 2011-10-12 07:16:25 +0800 | [diff] [blame] | 813 | snd_soc_write(codec, DA7210_A_HID_UNLOCK, 0x8B); /* unlock */ |
| 814 | snd_soc_write(codec, DA7210_A_TEST_UNLOCK, 0xB4); |
| 815 | snd_soc_write(codec, DA7210_A_PLL1, 0x01); |
| 816 | snd_soc_write(codec, DA7210_A_CP_MODE, 0x7C); |
| 817 | snd_soc_write(codec, DA7210_A_HID_UNLOCK, 0x00); /* re-lock */ |
| 818 | snd_soc_write(codec, DA7210_A_TEST_UNLOCK, 0x00); |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 819 | |
| 820 | /* Activate all enabled subsystem */ |
Axel Lin | 40a4971 | 2011-10-12 07:16:25 +0800 | [diff] [blame] | 821 | snd_soc_write(codec, DA7210_STARTUP1, DA7210_SC_MST_EN); |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 822 | |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 823 | dev_info(codec->dev, "DA7210 Audio Codec %s\n", DA7210_VERSION); |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 824 | |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 825 | return 0; |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 826 | } |
| 827 | |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 828 | static struct snd_soc_codec_driver soc_codec_dev_da7210 = { |
Kuninori Morimoto | 4c62ed9 | 2010-09-16 13:07:06 +0900 | [diff] [blame] | 829 | .probe = da7210_probe, |
Kuninori Morimoto | 4c62ed9 | 2010-09-16 13:07:06 +0900 | [diff] [blame] | 830 | .reg_cache_size = ARRAY_SIZE(da7210_reg), |
| 831 | .reg_word_size = sizeof(u8), |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 832 | .reg_cache_default = da7210_reg, |
Axel Lin | 40a4971 | 2011-10-12 07:16:25 +0800 | [diff] [blame] | 833 | .volatile_register = da7210_volatile_register, |
Mark Brown | a6f096f | 2011-10-14 20:18:49 +0100 | [diff] [blame] | 834 | |
| 835 | .controls = da7210_snd_controls, |
| 836 | .num_controls = ARRAY_SIZE(da7210_snd_controls), |
Ashish Chavan | 6950c60 | 2011-10-21 18:16:08 +0530 | [diff] [blame^] | 837 | |
| 838 | .dapm_widgets = da7210_dapm_widgets, |
| 839 | .num_dapm_widgets = ARRAY_SIZE(da7210_dapm_widgets), |
| 840 | .dapm_routes = da7210_audio_map, |
| 841 | .num_dapm_routes = ARRAY_SIZE(da7210_audio_map), |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 842 | }; |
| 843 | |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 844 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) |
Mark Brown | 735fe4c | 2010-01-12 14:13:00 +0000 | [diff] [blame] | 845 | static int __devinit da7210_i2c_probe(struct i2c_client *i2c, |
| 846 | const struct i2c_device_id *id) |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 847 | { |
| 848 | struct da7210_priv *da7210; |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 849 | int ret; |
| 850 | |
| 851 | da7210 = kzalloc(sizeof(struct da7210_priv), GFP_KERNEL); |
| 852 | if (!da7210) |
| 853 | return -ENOMEM; |
| 854 | |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 855 | i2c_set_clientdata(i2c, da7210); |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 856 | da7210->control_type = SND_SOC_I2C; |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 857 | |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 858 | ret = snd_soc_register_codec(&i2c->dev, |
| 859 | &soc_codec_dev_da7210, &da7210_dai, 1); |
| 860 | if (ret < 0) |
Axel Lin | 085efd2 | 2010-07-23 05:53:45 +0000 | [diff] [blame] | 861 | kfree(da7210); |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 862 | |
| 863 | return ret; |
| 864 | } |
| 865 | |
Mark Brown | 735fe4c | 2010-01-12 14:13:00 +0000 | [diff] [blame] | 866 | static int __devexit da7210_i2c_remove(struct i2c_client *client) |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 867 | { |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 868 | snd_soc_unregister_codec(&client->dev); |
| 869 | kfree(i2c_get_clientdata(client)); |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 870 | return 0; |
| 871 | } |
| 872 | |
| 873 | static const struct i2c_device_id da7210_i2c_id[] = { |
| 874 | { "da7210", 0 }, |
| 875 | { } |
| 876 | }; |
| 877 | MODULE_DEVICE_TABLE(i2c, da7210_i2c_id); |
| 878 | |
| 879 | /* I2C codec control layer */ |
| 880 | static struct i2c_driver da7210_i2c_driver = { |
| 881 | .driver = { |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 882 | .name = "da7210-codec", |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 883 | .owner = THIS_MODULE, |
| 884 | }, |
Kuninori Morimoto | 4c62ed9 | 2010-09-16 13:07:06 +0900 | [diff] [blame] | 885 | .probe = da7210_i2c_probe, |
| 886 | .remove = __devexit_p(da7210_i2c_remove), |
| 887 | .id_table = da7210_i2c_id, |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 888 | }; |
| 889 | #endif |
| 890 | |
Kuninori Morimoto | 9861545 | 2009-12-14 13:21:56 +0900 | [diff] [blame] | 891 | static int __init da7210_modinit(void) |
| 892 | { |
| 893 | int ret = 0; |
| 894 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) |
| 895 | ret = i2c_add_driver(&da7210_i2c_driver); |
| 896 | #endif |
| 897 | return ret; |
| 898 | } |
| 899 | module_init(da7210_modinit); |
| 900 | |
| 901 | static void __exit da7210_exit(void) |
| 902 | { |
| 903 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) |
| 904 | i2c_del_driver(&da7210_i2c_driver); |
| 905 | #endif |
| 906 | } |
| 907 | module_exit(da7210_exit); |
| 908 | |
| 909 | MODULE_DESCRIPTION("ASoC DA7210 driver"); |
| 910 | MODULE_AUTHOR("David Chen, Kuninori Morimoto"); |
| 911 | MODULE_LICENSE("GPL"); |