Lines Matching +full:adc +full:- +full:clk
1 // SPDX-License-Identifier: GPL-2.0-only
3 * uda1380.c - Philips UDA1380 ALSA SoC audio driver
5 * Copyright (c) 2007-2009 Philipp Zabel <philipp.zabel@gmail.com>
65 u16 *cache = uda1380->reg_cache; in uda1380_read_reg_cache()
70 return -1; in uda1380_read_reg_cache()
81 u16 *cache = uda1380->reg_cache; in uda1380_write_reg_cache()
86 set_bit(reg - 0x10, &uda1380_cache_dirty); in uda1380_write_reg_cache()
116 if (i2c_master_send(uda1380->i2c, data, 3) == 3) { in uda1380_write()
118 i2c_master_send(uda1380->i2c, data, 1); in uda1380_write()
119 i2c_master_recv(uda1380->i2c, data, 2); in uda1380_write()
124 return -EIO; in uda1380_write()
127 clear_bit(reg - 0x10, &uda1380_cache_dirty); in uda1380_write()
130 return -EIO; in uda1380_write()
138 u16 *cache = uda1380->reg_cache; in uda1380_sync_cache()
145 if (i2c_master_send(uda1380->i2c, data, 3) != 3) in uda1380_sync_cache()
146 dev_err(component->dev, "%s: write to reg 0x%x failed\n", in uda1380_sync_cache()
153 struct uda1380_platform_data *pdata = component->dev->platform_data; in uda1380_reset()
156 if (gpio_is_valid(pdata->gpio_reset)) { in uda1380_reset()
157 gpio_set_value(pdata->gpio_reset, 1); in uda1380_reset()
159 gpio_set_value(pdata->gpio_reset, 0); in uda1380_reset()
167 if (i2c_master_send(uda1380->i2c, data, 3) != 3) { in uda1380_reset()
168 dev_err(component->dev, "%s: failed\n", __func__); in uda1380_reset()
169 return -EIO; in uda1380_reset()
179 struct snd_soc_component *uda1380_component = uda1380->component; in uda1380_flush_work()
182 for_each_set_bit(bit, &uda1380_cache_dirty, UDA1380_CACHEREGNUM - 0x10) { in uda1380_flush_work()
218 "ADC",
222 "3rd-order",
223 "5th-order"
238 "single-speed",
239 "double-speed (no mixing)",
240 "quad-speed (no mixing)"
267 * from -48 dB in 1.5 dB steps (mute instead of -49.5 dB)
269 static DECLARE_TLV_DB_SCALE(amix_tlv, -4950, 150, 1);
272 * from -78 dB in 1 dB steps (3 dB steps, really. LSB are ignored),
273 * from -66 dB in 0.5 dB steps (2 dB steps, really) and
274 * from -52 dB in 0.25 dB steps
277 0, 15, TLV_DB_SCALE_ITEM(-8200, 100, 1),
278 16, 43, TLV_DB_SCALE_ITEM(-6600, 50, 0),
279 44, 252, TLV_DB_SCALE_ITEM(-5200, 25, 0)
283 * from -72 dB in 1.5 dB steps (6 dB steps really),
284 * from -66 dB in 0.75 dB steps (3 dB steps really),
285 * from -60 dB in 0.5 dB steps (2 dB steps really) and
286 * from -46 dB in 0.25 dB steps
289 0, 7, TLV_DB_SCALE_ITEM(-7800, 150, 1),
290 8, 15, TLV_DB_SCALE_ITEM(-6600, 75, 0),
291 16, 43, TLV_DB_SCALE_ITEM(-6000, 50, 0),
292 44, 228, TLV_DB_SCALE_ITEM(-4600, 25, 0)
302 /* from -63 to 24 dB in 0.5 dB steps (-128...48) */
303 static DECLARE_TLV_DB_SCALE(dec_tlv, -6400, 50, 1);
314 SOC_SINGLE_TLV("ADC Playback Volume", UDA1380_MIXVOL, 8, 228, 1, vc_tlv), /* VC2 */
317 SOC_DOUBLE_TLV("Tone Control - Treble", UDA1380_MODE, 4, 12, 3, 0, tr_tlv), /* TRL, TRR */
318 SOC_DOUBLE_TLV("Tone Control - Bass", UDA1380_MODE, 0, 8, 15, 0, bb_tlv), /* BBL, BBR */
320 SOC_SINGLE("ADC Playback Switch", UDA1380_DEEMP, 11, 1, 1), /* MT2 from decimation filter */
321 SOC_ENUM("ADC Playback De-emphasis", uda1380_deemp_enum[0]), /* DE2 */
323 SOC_ENUM("PCM Playback De-emphasis", uda1380_deemp_enum[1]), /* DE1 */
330 SOC_DOUBLE_S8_TLV("ADC Capture Volume", UDA1380_DEC, -128, 48, dec_tlv), /* ML_DEC, MR_DEC */
331 /**/ SOC_SINGLE("ADC Capture Switch", UDA1380_PGA, 15, 1, 1), /* MT_ADC */
333 SOC_SINGLE("ADC Polarity inverting Switch", UDA1380_ADC, 12, 1, 0), /* ADCPOL_INV */
339 /* -5.5, -8, -11.5, -14 dBFS */
366 SND_SOC_DAPM_ADC("Left ADC", "Left Capture", UDA1380_PM, 2, 0),
367 SND_SOC_DAPM_ADC("Right ADC", "Right Capture", UDA1380_PM, 0, 0),
401 {"Left ADC", NULL, "Input Mux"},
408 {"Right ADC", "Mic + Line R", "Right PGA"},
409 {"Right ADC", "Line", "Right PGA"},
420 struct snd_soc_component *component = codec_dai->component; in uda1380_set_dai_fmt_both()
440 return -EINVAL; in uda1380_set_dai_fmt_both()
450 struct snd_soc_component *component = codec_dai->component; in uda1380_set_dai_fmt_playback()
470 return -EINVAL; in uda1380_set_dai_fmt_playback()
480 struct snd_soc_component *component = codec_dai->component; in uda1380_set_dai_fmt_capture()
509 struct snd_soc_component *component = dai->component; in uda1380_trigger()
518 schedule_work(&uda1380->work); in uda1380_trigger()
524 schedule_work(&uda1380->work); in uda1380_trigger()
534 struct snd_soc_component *component = dai->component; in uda1380_pcm_hw_params()
535 u16 clk = uda1380_read_reg_cache(component, UDA1380_CLK); in uda1380_pcm_hw_params() local
538 if (clk & R00_DAC_CLK) { in uda1380_pcm_hw_params()
541 clk &= ~0x3; /* clear SEL_LOOP_DIV */ in uda1380_pcm_hw_params()
544 clk |= 0x0; in uda1380_pcm_hw_params()
547 clk |= 0x1; in uda1380_pcm_hw_params()
550 clk |= 0x2; in uda1380_pcm_hw_params()
553 clk |= 0x3; in uda1380_pcm_hw_params()
559 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in uda1380_pcm_hw_params()
560 clk |= R00_EN_DAC | R00_EN_INT; in uda1380_pcm_hw_params()
562 clk |= R00_EN_ADC | R00_EN_DEC; in uda1380_pcm_hw_params()
564 uda1380_write(component, UDA1380_CLK, clk); in uda1380_pcm_hw_params()
571 struct snd_soc_component *component = dai->component; in uda1380_pcm_shutdown()
572 u16 clk = uda1380_read_reg_cache(component, UDA1380_CLK); in uda1380_pcm_shutdown() local
575 if (clk & R00_DAC_CLK) { in uda1380_pcm_shutdown()
580 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in uda1380_pcm_shutdown()
581 clk &= ~(R00_EN_DAC | R00_EN_INT); in uda1380_pcm_shutdown()
583 clk &= ~(R00_EN_ADC | R00_EN_DEC); in uda1380_pcm_shutdown()
585 uda1380_write(component, UDA1380_CLK, clk); in uda1380_pcm_shutdown()
593 struct uda1380_platform_data *pdata = component->dev->platform_data; in uda1380_set_bias_level()
598 /* ADC, DAC on */ in uda1380_set_bias_level()
603 if (gpio_is_valid(pdata->gpio_power)) { in uda1380_set_bias_level()
604 gpio_set_value(pdata->gpio_power, 1); in uda1380_set_bias_level()
614 if (!gpio_is_valid(pdata->gpio_power)) in uda1380_set_bias_level()
617 gpio_set_value(pdata->gpio_power, 0); in uda1380_set_bias_level()
623 set_bit(reg - 0x10, &uda1380_cache_dirty); in uda1380_set_bias_level()
655 .name = "uda1380-hifi",
670 { /* playback only - dual interface */
671 .name = "uda1380-hifi-playback",
681 { /* capture only - dual interface*/
682 .name = "uda1380-hifi-capture",
696 struct uda1380_platform_data *pdata =component->dev->platform_data; in uda1380_probe()
700 uda1380->component = component; in uda1380_probe()
702 if (!gpio_is_valid(pdata->gpio_power)) { in uda1380_probe()
708 INIT_WORK(&uda1380->work, uda1380_flush_work); in uda1380_probe()
711 switch (pdata->dac_clk) { in uda1380_probe()
743 struct uda1380_platform_data *pdata = i2c->dev.platform_data; in uda1380_i2c_probe()
748 return -EINVAL; in uda1380_i2c_probe()
750 uda1380 = devm_kzalloc(&i2c->dev, sizeof(struct uda1380_priv), in uda1380_i2c_probe()
753 return -ENOMEM; in uda1380_i2c_probe()
755 if (gpio_is_valid(pdata->gpio_reset)) { in uda1380_i2c_probe()
756 ret = devm_gpio_request_one(&i2c->dev, pdata->gpio_reset, in uda1380_i2c_probe()
762 if (gpio_is_valid(pdata->gpio_power)) { in uda1380_i2c_probe()
763 ret = devm_gpio_request_one(&i2c->dev, pdata->gpio_power, in uda1380_i2c_probe()
769 uda1380->reg_cache = devm_kmemdup(&i2c->dev, in uda1380_i2c_probe()
773 if (!uda1380->reg_cache) in uda1380_i2c_probe()
774 return -ENOMEM; in uda1380_i2c_probe()
777 uda1380->i2c = i2c; in uda1380_i2c_probe()
779 ret = devm_snd_soc_register_component(&i2c->dev, in uda1380_i2c_probe()
798 .name = "uda1380-codec",