rt5645.c (53f9b3baa937e0cbdd75ea11b3c824462e4359b2) | rt5645.c (bd1204cb51f15d202f95222e873a94ed5d07b784) |
---|---|
1/* 2 * rt5645.c -- RT5645 ALSA SoC audio codec driver 3 * 4 * Copyright 2013 Realtek Semiconductor Corp. 5 * Author: Bard Liao <bardliao@realtek.com> 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License version 2 as --- 4 unchanged lines hidden (view full) --- 13#include <linux/moduleparam.h> 14#include <linux/init.h> 15#include <linux/delay.h> 16#include <linux/pm.h> 17#include <linux/i2c.h> 18#include <linux/platform_device.h> 19#include <linux/spi/spi.h> 20#include <linux/gpio.h> | 1/* 2 * rt5645.c -- RT5645 ALSA SoC audio codec driver 3 * 4 * Copyright 2013 Realtek Semiconductor Corp. 5 * Author: Bard Liao <bardliao@realtek.com> 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License version 2 as --- 4 unchanged lines hidden (view full) --- 13#include <linux/moduleparam.h> 14#include <linux/init.h> 15#include <linux/delay.h> 16#include <linux/pm.h> 17#include <linux/i2c.h> 18#include <linux/platform_device.h> 19#include <linux/spi/spi.h> 20#include <linux/gpio.h> |
21#include <linux/acpi.h> | |
22#include <sound/core.h> 23#include <sound/pcm.h> 24#include <sound/pcm_params.h> 25#include <sound/jack.h> 26#include <sound/soc.h> 27#include <sound/soc-dapm.h> 28#include <sound/initval.h> 29#include <sound/tlv.h> --- 1236 unchanged lines hidden (view full) --- 1266 RT5645_HP_SG_MASK | RT5645_HP_L_SMT_MASK | 1267 RT5645_HP_R_SMT_MASK, RT5645_HP_SG_DIS | 1268 RT5645_HP_L_SMT_DIS | RT5645_HP_R_SMT_DIS); 1269 /* headphone amp power down */ 1270 snd_soc_write(codec, RT5645_DEPOP_M1, 0x0000); 1271 snd_soc_update_bits(codec, RT5645_PWR_ANLG1, 1272 RT5645_PWR_HP_L | RT5645_PWR_HP_R | 1273 RT5645_PWR_HA, 0); | 21#include <sound/core.h> 22#include <sound/pcm.h> 23#include <sound/pcm_params.h> 24#include <sound/jack.h> 25#include <sound/soc.h> 26#include <sound/soc-dapm.h> 27#include <sound/initval.h> 28#include <sound/tlv.h> --- 1236 unchanged lines hidden (view full) --- 1265 RT5645_HP_SG_MASK | RT5645_HP_L_SMT_MASK | 1266 RT5645_HP_R_SMT_MASK, RT5645_HP_SG_DIS | 1267 RT5645_HP_L_SMT_DIS | RT5645_HP_R_SMT_DIS); 1268 /* headphone amp power down */ 1269 snd_soc_write(codec, RT5645_DEPOP_M1, 0x0000); 1270 snd_soc_update_bits(codec, RT5645_PWR_ANLG1, 1271 RT5645_PWR_HP_L | RT5645_PWR_HP_R | 1272 RT5645_PWR_HA, 0); |
1273 snd_soc_update_bits(codec, RT5645_DEPOP_M2, 1274 RT5645_DEPOP_MASK, 0); |
|
1274 } 1275 } 1276} 1277 1278static int rt5645_hp_event(struct snd_soc_dapm_widget *w, 1279 struct snd_kcontrol *kcontrol, int event) 1280{ 1281 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); --- 252 unchanged lines hidden (view full) --- 1534 SND_SOC_DAPM_MUX("Mono ADC R1 Mux", SND_SOC_NOPM, 0, 0, 1535 &rt5645_mono_adc_r1_mux), 1536 SND_SOC_DAPM_MUX("Mono ADC R2 Mux", SND_SOC_NOPM, 0, 0, 1537 &rt5645_mono_adc_r2_mux), 1538 /* ADC Mixer */ 1539 1540 SND_SOC_DAPM_SUPPLY_S("adc stereo1 filter", 1, RT5645_PWR_DIG2, 1541 RT5645_PWR_ADC_S1F_BIT, 0, NULL, 0), | 1275 } 1276 } 1277} 1278 1279static int rt5645_hp_event(struct snd_soc_dapm_widget *w, 1280 struct snd_kcontrol *kcontrol, int event) 1281{ 1282 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); --- 252 unchanged lines hidden (view full) --- 1535 SND_SOC_DAPM_MUX("Mono ADC R1 Mux", SND_SOC_NOPM, 0, 0, 1536 &rt5645_mono_adc_r1_mux), 1537 SND_SOC_DAPM_MUX("Mono ADC R2 Mux", SND_SOC_NOPM, 0, 0, 1538 &rt5645_mono_adc_r2_mux), 1539 /* ADC Mixer */ 1540 1541 SND_SOC_DAPM_SUPPLY_S("adc stereo1 filter", 1, RT5645_PWR_DIG2, 1542 RT5645_PWR_ADC_S1F_BIT, 0, NULL, 0), |
1542 SND_SOC_DAPM_SUPPLY_S("adc stereo2 filter", 1, RT5645_PWR_DIG2, 1543 RT5645_PWR_ADC_S2F_BIT, 0, NULL, 0), | |
1544 SND_SOC_DAPM_MIXER_E("Sto1 ADC MIXL", SND_SOC_NOPM, 0, 0, 1545 rt5645_sto1_adc_l_mix, ARRAY_SIZE(rt5645_sto1_adc_l_mix), 1546 NULL, 0), 1547 SND_SOC_DAPM_MIXER_E("Sto1 ADC MIXR", SND_SOC_NOPM, 0, 0, 1548 rt5645_sto1_adc_r_mix, ARRAY_SIZE(rt5645_sto1_adc_r_mix), 1549 NULL, 0), 1550 SND_SOC_DAPM_SUPPLY_S("adc mono left filter", 1, RT5645_PWR_DIG2, 1551 RT5645_PWR_ADC_MF_L_BIT, 0, NULL, 0), --- 173 unchanged lines hidden (view full) --- 1725 SND_SOC_DAPM_MUX("A DAC2 L Mux", SND_SOC_NOPM, 1726 0, 0, &rt5650_a_dac2_l_mux), 1727 SND_SOC_DAPM_MUX("A DAC2 R Mux", SND_SOC_NOPM, 1728 0, 0, &rt5650_a_dac2_r_mux), 1729}; 1730 1731static const struct snd_soc_dapm_route rt5645_dapm_routes[] = { 1732 { "adc stereo1 filter", NULL, "ADC STO1 ASRC", is_using_asrc }, | 1543 SND_SOC_DAPM_MIXER_E("Sto1 ADC MIXL", SND_SOC_NOPM, 0, 0, 1544 rt5645_sto1_adc_l_mix, ARRAY_SIZE(rt5645_sto1_adc_l_mix), 1545 NULL, 0), 1546 SND_SOC_DAPM_MIXER_E("Sto1 ADC MIXR", SND_SOC_NOPM, 0, 0, 1547 rt5645_sto1_adc_r_mix, ARRAY_SIZE(rt5645_sto1_adc_r_mix), 1548 NULL, 0), 1549 SND_SOC_DAPM_SUPPLY_S("adc mono left filter", 1, RT5645_PWR_DIG2, 1550 RT5645_PWR_ADC_MF_L_BIT, 0, NULL, 0), --- 173 unchanged lines hidden (view full) --- 1724 SND_SOC_DAPM_MUX("A DAC2 L Mux", SND_SOC_NOPM, 1725 0, 0, &rt5650_a_dac2_l_mux), 1726 SND_SOC_DAPM_MUX("A DAC2 R Mux", SND_SOC_NOPM, 1727 0, 0, &rt5650_a_dac2_r_mux), 1728}; 1729 1730static const struct snd_soc_dapm_route rt5645_dapm_routes[] = { 1731 { "adc stereo1 filter", NULL, "ADC STO1 ASRC", is_using_asrc }, |
1733 { "adc stereo2 filter", NULL, "ADC STO2 ASRC", is_using_asrc }, | |
1734 { "adc mono left filter", NULL, "ADC MONO L ASRC", is_using_asrc }, 1735 { "adc mono right filter", NULL, "ADC MONO R ASRC", is_using_asrc }, 1736 { "dac mono left filter", NULL, "DAC MONO L ASRC", is_using_asrc }, 1737 { "dac mono right filter", NULL, "DAC MONO R ASRC", is_using_asrc }, 1738 { "dac stereo1 filter", NULL, "DAC STO ASRC", is_using_asrc }, 1739 1740 { "I2S1", NULL, "I2S1 ASRC" }, 1741 { "I2S2", NULL, "I2S2 ASRC" }, --- 306 unchanged lines hidden (view full) --- 2048 { "DAC R2", NULL, "Mono DAC MIXR" }, 2049}; 2050 2051static int rt5645_hw_params(struct snd_pcm_substream *substream, 2052 struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) 2053{ 2054 struct snd_soc_codec *codec = dai->codec; 2055 struct rt5645_priv *rt5645 = snd_soc_codec_get_drvdata(codec); | 1732 { "adc mono left filter", NULL, "ADC MONO L ASRC", is_using_asrc }, 1733 { "adc mono right filter", NULL, "ADC MONO R ASRC", is_using_asrc }, 1734 { "dac mono left filter", NULL, "DAC MONO L ASRC", is_using_asrc }, 1735 { "dac mono right filter", NULL, "DAC MONO R ASRC", is_using_asrc }, 1736 { "dac stereo1 filter", NULL, "DAC STO ASRC", is_using_asrc }, 1737 1738 { "I2S1", NULL, "I2S1 ASRC" }, 1739 { "I2S2", NULL, "I2S2 ASRC" }, --- 306 unchanged lines hidden (view full) --- 2046 { "DAC R2", NULL, "Mono DAC MIXR" }, 2047}; 2048 2049static int rt5645_hw_params(struct snd_pcm_substream *substream, 2050 struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) 2051{ 2052 struct snd_soc_codec *codec = dai->codec; 2053 struct rt5645_priv *rt5645 = snd_soc_codec_get_drvdata(codec); |
2056 unsigned int val_len = 0, val_clk, mask_clk; | 2054 unsigned int val_len = 0, val_clk, mask_clk, dl_sft; |
2057 int pre_div, bclk_ms, frame_size; 2058 2059 rt5645->lrck[dai->id] = params_rate(params); 2060 pre_div = rl6231_get_clk_info(rt5645->sysclk, rt5645->lrck[dai->id]); 2061 if (pre_div < 0) { 2062 dev_err(codec->dev, "Unsupported clock setting\n"); 2063 return -EINVAL; 2064 } 2065 frame_size = snd_soc_params_to_frame_size(params); 2066 if (frame_size < 0) { 2067 dev_err(codec->dev, "Unsupported frame size: %d\n", frame_size); 2068 return -EINVAL; 2069 } | 2055 int pre_div, bclk_ms, frame_size; 2056 2057 rt5645->lrck[dai->id] = params_rate(params); 2058 pre_div = rl6231_get_clk_info(rt5645->sysclk, rt5645->lrck[dai->id]); 2059 if (pre_div < 0) { 2060 dev_err(codec->dev, "Unsupported clock setting\n"); 2061 return -EINVAL; 2062 } 2063 frame_size = snd_soc_params_to_frame_size(params); 2064 if (frame_size < 0) { 2065 dev_err(codec->dev, "Unsupported frame size: %d\n", frame_size); 2066 return -EINVAL; 2067 } |
2068 2069 switch (rt5645->codec_type) { 2070 case CODEC_TYPE_RT5650: 2071 dl_sft = 4; 2072 break; 2073 default: 2074 dl_sft = 2; 2075 break; 2076 } 2077 |
|
2070 bclk_ms = frame_size > 32; 2071 rt5645->bclk[dai->id] = rt5645->lrck[dai->id] * (32 << bclk_ms); 2072 2073 dev_dbg(dai->dev, "bclk is %dHz and lrck is %dHz\n", 2074 rt5645->bclk[dai->id], rt5645->lrck[dai->id]); 2075 dev_dbg(dai->dev, "bclk_ms is %d and pre_div is %d for iis %d\n", 2076 bclk_ms, pre_div, dai->id); 2077 2078 switch (params_width(params)) { 2079 case 16: 2080 break; 2081 case 20: | 2078 bclk_ms = frame_size > 32; 2079 rt5645->bclk[dai->id] = rt5645->lrck[dai->id] * (32 << bclk_ms); 2080 2081 dev_dbg(dai->dev, "bclk is %dHz and lrck is %dHz\n", 2082 rt5645->bclk[dai->id], rt5645->lrck[dai->id]); 2083 dev_dbg(dai->dev, "bclk_ms is %d and pre_div is %d for iis %d\n", 2084 bclk_ms, pre_div, dai->id); 2085 2086 switch (params_width(params)) { 2087 case 16: 2088 break; 2089 case 20: |
2082 val_len |= RT5645_I2S_DL_20; | 2090 val_len = 0x1; |
2083 break; 2084 case 24: | 2091 break; 2092 case 24: |
2085 val_len |= RT5645_I2S_DL_24; | 2093 val_len = 0x2; |
2086 break; 2087 case 8: | 2094 break; 2095 case 8: |
2088 val_len |= RT5645_I2S_DL_8; | 2096 val_len = 0x3; |
2089 break; 2090 default: 2091 return -EINVAL; 2092 } 2093 2094 switch (dai->id) { 2095 case RT5645_AIF1: 2096 mask_clk = RT5645_I2S_BCLK_MS1_MASK | RT5645_I2S_PD1_MASK; 2097 val_clk = bclk_ms << RT5645_I2S_BCLK_MS1_SFT | 2098 pre_div << RT5645_I2S_PD1_SFT; 2099 snd_soc_update_bits(codec, RT5645_I2S1_SDP, | 2097 break; 2098 default: 2099 return -EINVAL; 2100 } 2101 2102 switch (dai->id) { 2103 case RT5645_AIF1: 2104 mask_clk = RT5645_I2S_BCLK_MS1_MASK | RT5645_I2S_PD1_MASK; 2105 val_clk = bclk_ms << RT5645_I2S_BCLK_MS1_SFT | 2106 pre_div << RT5645_I2S_PD1_SFT; 2107 snd_soc_update_bits(codec, RT5645_I2S1_SDP, |
2100 RT5645_I2S_DL_MASK, val_len); | 2108 (0x3 << dl_sft), (val_len << dl_sft)); |
2101 snd_soc_update_bits(codec, RT5645_ADDA_CLK1, mask_clk, val_clk); 2102 break; 2103 case RT5645_AIF2: 2104 mask_clk = RT5645_I2S_BCLK_MS2_MASK | RT5645_I2S_PD2_MASK; 2105 val_clk = bclk_ms << RT5645_I2S_BCLK_MS2_SFT | 2106 pre_div << RT5645_I2S_PD2_SFT; 2107 snd_soc_update_bits(codec, RT5645_I2S2_SDP, | 2109 snd_soc_update_bits(codec, RT5645_ADDA_CLK1, mask_clk, val_clk); 2110 break; 2111 case RT5645_AIF2: 2112 mask_clk = RT5645_I2S_BCLK_MS2_MASK | RT5645_I2S_PD2_MASK; 2113 val_clk = bclk_ms << RT5645_I2S_BCLK_MS2_SFT | 2114 pre_div << RT5645_I2S_PD2_SFT; 2115 snd_soc_update_bits(codec, RT5645_I2S2_SDP, |
2108 RT5645_I2S_DL_MASK, val_len); | 2116 (0x3 << dl_sft), (val_len << dl_sft)); |
2109 snd_soc_update_bits(codec, RT5645_ADDA_CLK1, mask_clk, val_clk); 2110 break; 2111 default: 2112 dev_err(codec->dev, "Invalid dai->id: %d\n", dai->id); 2113 return -EINVAL; 2114 } 2115 2116 return 0; 2117} 2118 2119static int rt5645_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) 2120{ 2121 struct snd_soc_codec *codec = dai->codec; 2122 struct rt5645_priv *rt5645 = snd_soc_codec_get_drvdata(codec); | 2117 snd_soc_update_bits(codec, RT5645_ADDA_CLK1, mask_clk, val_clk); 2118 break; 2119 default: 2120 dev_err(codec->dev, "Invalid dai->id: %d\n", dai->id); 2121 return -EINVAL; 2122 } 2123 2124 return 0; 2125} 2126 2127static int rt5645_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) 2128{ 2129 struct snd_soc_codec *codec = dai->codec; 2130 struct rt5645_priv *rt5645 = snd_soc_codec_get_drvdata(codec); |
2123 unsigned int reg_val = 0; | 2131 unsigned int reg_val = 0, pol_sft; |
2124 | 2132 |
2133 switch (rt5645->codec_type) { 2134 case CODEC_TYPE_RT5650: 2135 pol_sft = 8; 2136 break; 2137 default: 2138 pol_sft = 7; 2139 break; 2140 } 2141 |
|
2125 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { 2126 case SND_SOC_DAIFMT_CBM_CFM: 2127 rt5645->master[dai->id] = 1; 2128 break; 2129 case SND_SOC_DAIFMT_CBS_CFS: 2130 reg_val |= RT5645_I2S_MS_S; 2131 rt5645->master[dai->id] = 0; 2132 break; 2133 default: 2134 return -EINVAL; 2135 } 2136 2137 switch (fmt & SND_SOC_DAIFMT_INV_MASK) { 2138 case SND_SOC_DAIFMT_NB_NF: 2139 break; 2140 case SND_SOC_DAIFMT_IB_NF: | 2142 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { 2143 case SND_SOC_DAIFMT_CBM_CFM: 2144 rt5645->master[dai->id] = 1; 2145 break; 2146 case SND_SOC_DAIFMT_CBS_CFS: 2147 reg_val |= RT5645_I2S_MS_S; 2148 rt5645->master[dai->id] = 0; 2149 break; 2150 default: 2151 return -EINVAL; 2152 } 2153 2154 switch (fmt & SND_SOC_DAIFMT_INV_MASK) { 2155 case SND_SOC_DAIFMT_NB_NF: 2156 break; 2157 case SND_SOC_DAIFMT_IB_NF: |
2141 reg_val |= RT5645_I2S_BP_INV; | 2158 reg_val |= (1 << pol_sft); |
2142 break; 2143 default: 2144 return -EINVAL; 2145 } 2146 2147 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { 2148 case SND_SOC_DAIFMT_I2S: 2149 break; --- 7 unchanged lines hidden (view full) --- 2157 reg_val |= RT5645_I2S_DF_PCM_B; 2158 break; 2159 default: 2160 return -EINVAL; 2161 } 2162 switch (dai->id) { 2163 case RT5645_AIF1: 2164 snd_soc_update_bits(codec, RT5645_I2S1_SDP, | 2159 break; 2160 default: 2161 return -EINVAL; 2162 } 2163 2164 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { 2165 case SND_SOC_DAIFMT_I2S: 2166 break; --- 7 unchanged lines hidden (view full) --- 2174 reg_val |= RT5645_I2S_DF_PCM_B; 2175 break; 2176 default: 2177 return -EINVAL; 2178 } 2179 switch (dai->id) { 2180 case RT5645_AIF1: 2181 snd_soc_update_bits(codec, RT5645_I2S1_SDP, |
2165 RT5645_I2S_MS_MASK | RT5645_I2S_BP_MASK | | 2182 RT5645_I2S_MS_MASK | (1 << pol_sft) | |
2166 RT5645_I2S_DF_MASK, reg_val); 2167 break; 2168 case RT5645_AIF2: 2169 snd_soc_update_bits(codec, RT5645_I2S2_SDP, | 2183 RT5645_I2S_DF_MASK, reg_val); 2184 break; 2185 case RT5645_AIF2: 2186 snd_soc_update_bits(codec, RT5645_I2S2_SDP, |
2170 RT5645_I2S_MS_MASK | RT5645_I2S_BP_MASK | | 2187 RT5645_I2S_MS_MASK | (1 << pol_sft) | |
2171 RT5645_I2S_DF_MASK, reg_val); 2172 break; 2173 default: 2174 dev_err(codec->dev, "Invalid dai->id: %d\n", dai->id); 2175 return -EINVAL; 2176 } 2177 return 0; 2178} --- 102 unchanged lines hidden (view full) --- 2281 2282 return 0; 2283} 2284 2285static int rt5645_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, 2286 unsigned int rx_mask, int slots, int slot_width) 2287{ 2288 struct snd_soc_codec *codec = dai->codec; | 2188 RT5645_I2S_DF_MASK, reg_val); 2189 break; 2190 default: 2191 dev_err(codec->dev, "Invalid dai->id: %d\n", dai->id); 2192 return -EINVAL; 2193 } 2194 return 0; 2195} --- 102 unchanged lines hidden (view full) --- 2298 2299 return 0; 2300} 2301 2302static int rt5645_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, 2303 unsigned int rx_mask, int slots, int slot_width) 2304{ 2305 struct snd_soc_codec *codec = dai->codec; |
2289 unsigned int val = 0; | 2306 struct rt5645_priv *rt5645 = snd_soc_codec_get_drvdata(codec); 2307 unsigned int i_slot_sft, o_slot_sft, i_width_sht, o_width_sht, en_sft; 2308 unsigned int mask, val = 0; |
2290 | 2309 |
2310 switch (rt5645->codec_type) { 2311 case CODEC_TYPE_RT5650: 2312 en_sft = 15; 2313 i_slot_sft = 10; 2314 o_slot_sft = 8; 2315 i_width_sht = 6; 2316 o_width_sht = 4; 2317 mask = 0x8ff0; 2318 break; 2319 default: 2320 en_sft = 14; 2321 i_slot_sft = o_slot_sft = 12; 2322 i_width_sht = o_width_sht = 10; 2323 mask = 0x7c00; 2324 break; 2325 } |
|
2291 if (rx_mask || tx_mask) { | 2326 if (rx_mask || tx_mask) { |
2292 val |= (1 << 14); 2293 snd_soc_update_bits(codec, RT5645_BASS_BACK, 2294 RT5645_G_BB_BST_MASK, RT5645_G_BB_BST_25DB); | 2327 val |= (1 << en_sft); 2328 if (rt5645->codec_type == CODEC_TYPE_RT5645) 2329 snd_soc_update_bits(codec, RT5645_BASS_BACK, 2330 RT5645_G_BB_BST_MASK, RT5645_G_BB_BST_25DB); |
2295 } 2296 2297 switch (slots) { 2298 case 4: | 2331 } 2332 2333 switch (slots) { 2334 case 4: |
2299 val |= (1 << 12); | 2335 val |= (1 << i_slot_sft) | (1 << o_slot_sft); |
2300 break; 2301 case 6: | 2336 break; 2337 case 6: |
2302 val |= (2 << 12); | 2338 val |= (2 << i_slot_sft) | (2 << o_slot_sft); |
2303 break; 2304 case 8: | 2339 break; 2340 case 8: |
2305 val |= (3 << 12); | 2341 val |= (3 << i_slot_sft) | (3 << o_slot_sft); |
2306 break; 2307 case 2: 2308 default: 2309 break; 2310 } 2311 2312 switch (slot_width) { 2313 case 20: | 2342 break; 2343 case 2: 2344 default: 2345 break; 2346 } 2347 2348 switch (slot_width) { 2349 case 20: |
2314 val |= (1 << 10); | 2350 val |= (1 << i_width_sht) | (1 << o_width_sht); |
2315 break; 2316 case 24: | 2351 break; 2352 case 24: |
2317 val |= (2 << 10); | 2353 val |= (2 << i_width_sht) | (2 << o_width_sht); |
2318 break; 2319 case 32: | 2354 break; 2355 case 32: |
2320 val |= (3 << 10); | 2356 val |= (3 << i_width_sht) | (3 << o_width_sht); |
2321 break; 2322 case 16: 2323 default: 2324 break; 2325 } 2326 | 2357 break; 2358 case 16: 2359 default: 2360 break; 2361 } 2362 |
2327 snd_soc_update_bits(codec, RT5645_TDM_CTRL_1, 0x7c00, val); | 2363 snd_soc_update_bits(codec, RT5645_TDM_CTRL_1, mask, val); |
2328 2329 return 0; 2330} 2331 2332static int rt5645_set_bias_level(struct snd_soc_codec *codec, 2333 enum snd_soc_bias_level level) 2334{ 2335 switch (level) { --- 21 unchanged lines hidden (view full) --- 2357 RT5645_PWR_BG | RT5645_PWR_VREF2); 2358 snd_soc_update_bits(codec, RT5645_PWR_ANLG1, 2359 RT5645_PWR_FV1 | RT5645_PWR_FV2, 2360 RT5645_PWR_FV1 | RT5645_PWR_FV2); 2361 break; 2362 2363 case SND_SOC_BIAS_OFF: 2364 snd_soc_write(codec, RT5645_DEPOP_M2, 0x1100); | 2364 2365 return 0; 2366} 2367 2368static int rt5645_set_bias_level(struct snd_soc_codec *codec, 2369 enum snd_soc_bias_level level) 2370{ 2371 switch (level) { --- 21 unchanged lines hidden (view full) --- 2393 RT5645_PWR_BG | RT5645_PWR_VREF2); 2394 snd_soc_update_bits(codec, RT5645_PWR_ANLG1, 2395 RT5645_PWR_FV1 | RT5645_PWR_FV2, 2396 RT5645_PWR_FV1 | RT5645_PWR_FV2); 2397 break; 2398 2399 case SND_SOC_BIAS_OFF: 2400 snd_soc_write(codec, RT5645_DEPOP_M2, 0x1100); |
2365 snd_soc_write(codec, RT5645_GEN_CTRL1, 0x0128); | 2401 snd_soc_update_bits(codec, RT5645_GEN_CTRL1, 2402 RT5645_DIG_GATE_CTRL, 0); |
2366 snd_soc_update_bits(codec, RT5645_PWR_ANLG1, 2367 RT5645_PWR_VREF1 | RT5645_PWR_MB | 2368 RT5645_PWR_BG | RT5645_PWR_VREF2 | 2369 RT5645_PWR_FV1 | RT5645_PWR_FV2, 0x0); 2370 break; 2371 2372 default: 2373 break; --- 104 unchanged lines hidden (view full) --- 2478 rt5650_specific_dapm_widgets, 2479 ARRAY_SIZE(rt5650_specific_dapm_widgets)); 2480 snd_soc_dapm_add_routes(&codec->dapm, 2481 rt5650_specific_dapm_routes, 2482 ARRAY_SIZE(rt5650_specific_dapm_routes)); 2483 break; 2484 } 2485 | 2403 snd_soc_update_bits(codec, RT5645_PWR_ANLG1, 2404 RT5645_PWR_VREF1 | RT5645_PWR_MB | 2405 RT5645_PWR_BG | RT5645_PWR_VREF2 | 2406 RT5645_PWR_FV1 | RT5645_PWR_FV2, 0x0); 2407 break; 2408 2409 default: 2410 break; --- 104 unchanged lines hidden (view full) --- 2515 rt5650_specific_dapm_widgets, 2516 ARRAY_SIZE(rt5650_specific_dapm_widgets)); 2517 snd_soc_dapm_add_routes(&codec->dapm, 2518 rt5650_specific_dapm_routes, 2519 ARRAY_SIZE(rt5650_specific_dapm_routes)); 2520 break; 2521 } 2522 |
2486 rt5645_set_bias_level(codec, SND_SOC_BIAS_OFF); | 2523 snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_OFF); |
2487 2488 snd_soc_update_bits(codec, RT5645_CHARGE_PUMP, 0x0300, 0x0200); 2489 2490 /* for JD function */ 2491 if (rt5645->pdata.en_jd_func) { 2492 snd_soc_dapm_force_enable_pin(&codec->dapm, "JD Power"); 2493 snd_soc_dapm_force_enable_pin(&codec->dapm, "LDO2"); 2494 snd_soc_dapm_sync(&codec->dapm); --- 99 unchanged lines hidden (view full) --- 2594 .num_dapm_widgets = ARRAY_SIZE(rt5645_dapm_widgets), 2595 .dapm_routes = rt5645_dapm_routes, 2596 .num_dapm_routes = ARRAY_SIZE(rt5645_dapm_routes), 2597}; 2598 2599static const struct regmap_config rt5645_regmap = { 2600 .reg_bits = 8, 2601 .val_bits = 16, | 2524 2525 snd_soc_update_bits(codec, RT5645_CHARGE_PUMP, 0x0300, 0x0200); 2526 2527 /* for JD function */ 2528 if (rt5645->pdata.en_jd_func) { 2529 snd_soc_dapm_force_enable_pin(&codec->dapm, "JD Power"); 2530 snd_soc_dapm_force_enable_pin(&codec->dapm, "LDO2"); 2531 snd_soc_dapm_sync(&codec->dapm); --- 99 unchanged lines hidden (view full) --- 2631 .num_dapm_widgets = ARRAY_SIZE(rt5645_dapm_widgets), 2632 .dapm_routes = rt5645_dapm_routes, 2633 .num_dapm_routes = ARRAY_SIZE(rt5645_dapm_routes), 2634}; 2635 2636static const struct regmap_config rt5645_regmap = { 2637 .reg_bits = 8, 2638 .val_bits = 16, |
2602 | 2639 .use_single_rw = true, |
2603 .max_register = RT5645_VENDOR_ID2 + 1 + (ARRAY_SIZE(rt5645_ranges) * 2604 RT5645_PR_SPACING), 2605 .volatile_reg = rt5645_volatile_register, 2606 .readable_reg = rt5645_readable_register, 2607 2608 .cache_type = REGCACHE_RBTREE, 2609 .reg_defaults = rt5645_reg, 2610 .num_reg_defaults = ARRAY_SIZE(rt5645_reg), 2611 .ranges = rt5645_ranges, 2612 .num_ranges = ARRAY_SIZE(rt5645_ranges), 2613}; 2614 2615static const struct i2c_device_id rt5645_i2c_id[] = { 2616 { "rt5645", 0 }, 2617 { "rt5650", 0 }, 2618 { } 2619}; 2620MODULE_DEVICE_TABLE(i2c, rt5645_i2c_id); 2621 | 2640 .max_register = RT5645_VENDOR_ID2 + 1 + (ARRAY_SIZE(rt5645_ranges) * 2641 RT5645_PR_SPACING), 2642 .volatile_reg = rt5645_volatile_register, 2643 .readable_reg = rt5645_readable_register, 2644 2645 .cache_type = REGCACHE_RBTREE, 2646 .reg_defaults = rt5645_reg, 2647 .num_reg_defaults = ARRAY_SIZE(rt5645_reg), 2648 .ranges = rt5645_ranges, 2649 .num_ranges = ARRAY_SIZE(rt5645_ranges), 2650}; 2651 2652static const struct i2c_device_id rt5645_i2c_id[] = { 2653 { "rt5645", 0 }, 2654 { "rt5650", 0 }, 2655 { } 2656}; 2657MODULE_DEVICE_TABLE(i2c, rt5645_i2c_id); 2658 |
2622#ifdef CONFIG_ACPI 2623static struct acpi_device_id rt5645_acpi_match[] = { 2624 { "10EC5645", 0 }, 2625 { "10EC5650", 0 }, 2626 {}, 2627}; 2628MODULE_DEVICE_TABLE(acpi, rt5645_acpi_match); 2629#endif 2630 | |
2631static int rt5645_i2c_probe(struct i2c_client *i2c, 2632 const struct i2c_device_id *id) 2633{ 2634 struct rt5645_platform_data *pdata = dev_get_platdata(&i2c->dev); 2635 struct rt5645_priv *rt5645; 2636 int ret; 2637 unsigned int val; 2638 --- 98 unchanged lines hidden (view full) --- 2737 RT5645_DMIC_2_DP_MASK, RT5645_DMIC_2_DP_GPIO10); 2738 regmap_update_bits(rt5645->regmap, RT5645_GPIO_CTRL1, 2739 RT5645_GP10_PIN_MASK, 2740 RT5645_GP10_PIN_DMIC2_SDA); 2741 break; 2742 2743 case RT5645_DMIC_DATA_GPIO12: 2744 regmap_update_bits(rt5645->regmap, RT5645_DMIC_CTRL1, | 2659static int rt5645_i2c_probe(struct i2c_client *i2c, 2660 const struct i2c_device_id *id) 2661{ 2662 struct rt5645_platform_data *pdata = dev_get_platdata(&i2c->dev); 2663 struct rt5645_priv *rt5645; 2664 int ret; 2665 unsigned int val; 2666 --- 98 unchanged lines hidden (view full) --- 2765 RT5645_DMIC_2_DP_MASK, RT5645_DMIC_2_DP_GPIO10); 2766 regmap_update_bits(rt5645->regmap, RT5645_GPIO_CTRL1, 2767 RT5645_GP10_PIN_MASK, 2768 RT5645_GP10_PIN_DMIC2_SDA); 2769 break; 2770 2771 case RT5645_DMIC_DATA_GPIO12: 2772 regmap_update_bits(rt5645->regmap, RT5645_DMIC_CTRL1, |
2745 RT5645_DMIC_2_DP_MASK, RT5645_DMIC_2_DP_GPIO12); | 2773 RT5645_DMIC_1_DP_MASK, RT5645_DMIC_2_DP_GPIO12); |
2746 regmap_update_bits(rt5645->regmap, RT5645_GPIO_CTRL1, 2747 RT5645_GP12_PIN_MASK, 2748 RT5645_GP12_PIN_DMIC2_SDA); 2749 break; 2750 2751 default: 2752 break; 2753 } --- 85 unchanged lines hidden (view full) --- 2839 2840 return 0; 2841} 2842 2843static struct i2c_driver rt5645_i2c_driver = { 2844 .driver = { 2845 .name = "rt5645", 2846 .owner = THIS_MODULE, | 2774 regmap_update_bits(rt5645->regmap, RT5645_GPIO_CTRL1, 2775 RT5645_GP12_PIN_MASK, 2776 RT5645_GP12_PIN_DMIC2_SDA); 2777 break; 2778 2779 default: 2780 break; 2781 } --- 85 unchanged lines hidden (view full) --- 2867 2868 return 0; 2869} 2870 2871static struct i2c_driver rt5645_i2c_driver = { 2872 .driver = { 2873 .name = "rt5645", 2874 .owner = THIS_MODULE, |
2847 .acpi_match_table = ACPI_PTR(rt5645_acpi_match), | |
2848 }, 2849 .probe = rt5645_i2c_probe, 2850 .remove = rt5645_i2c_remove, 2851 .id_table = rt5645_i2c_id, 2852}; 2853module_i2c_driver(rt5645_i2c_driver); 2854 2855MODULE_DESCRIPTION("ASoC RT5645 driver"); 2856MODULE_AUTHOR("Bard Liao <bardliao@realtek.com>"); 2857MODULE_LICENSE("GPL v2"); | 2875 }, 2876 .probe = rt5645_i2c_probe, 2877 .remove = rt5645_i2c_remove, 2878 .id_table = rt5645_i2c_id, 2879}; 2880module_i2c_driver(rt5645_i2c_driver); 2881 2882MODULE_DESCRIPTION("ASoC RT5645 driver"); 2883MODULE_AUTHOR("Bard Liao <bardliao@realtek.com>"); 2884MODULE_LICENSE("GPL v2"); |