Lines Matching +full:gpio +full:- +full:mux +full:- +full:clock

2  * uda1380.c - Philips UDA1380 ALSA SoC audio driver
8 * Copyright (c) 2007-2009 Philipp Zabel <philipp.zabel@gmail.com>
22 #include <linux/gpio.h>
66 u16 *cache = codec->reg_cache; in uda1380_read_reg_cache()
70 return -1; in uda1380_read_reg_cache()
80 u16 *cache = codec->reg_cache; in uda1380_write_reg_cache()
85 set_bit(reg - 0x10, &uda1380_cache_dirty); in uda1380_write_reg_cache()
111 if (!codec->active && (reg >= UDA1380_MVOL)) in uda1380_write()
114 if (codec->hw_write(codec->control_data, data, 3) == 3) { in uda1380_write()
116 i2c_master_send(codec->control_data, data, 1); in uda1380_write()
117 i2c_master_recv(codec->control_data, data, 2); in uda1380_write()
122 return -EIO; in uda1380_write()
125 clear_bit(reg - 0x10, &uda1380_cache_dirty); in uda1380_write()
128 return -EIO; in uda1380_write()
135 u16 *cache = codec->reg_cache; in uda1380_sync_cache()
142 if (codec->hw_write(codec->control_data, data, 3) != 3) in uda1380_sync_cache()
143 dev_err(codec->dev, "%s: write to reg 0x%x failed\n", in uda1380_sync_cache()
150 struct uda1380_platform_data *pdata = codec->dev->platform_data; in uda1380_reset()
152 if (gpio_is_valid(pdata->gpio_reset)) { in uda1380_reset()
153 gpio_set_value(pdata->gpio_reset, 1); in uda1380_reset()
155 gpio_set_value(pdata->gpio_reset, 0); in uda1380_reset()
163 if (codec->hw_write(codec->control_data, data, 3) != 3) { in uda1380_reset()
164 dev_err(codec->dev, "%s: failed\n", __func__); in uda1380_reset()
165 return -EIO; in uda1380_reset()
175 struct snd_soc_codec *uda1380_codec = uda1380->codec; in uda1380_flush_work()
178 for_each_set_bit(bit, &uda1380_cache_dirty, UDA1380_CACHEREGNUM - 0x10) { in uda1380_flush_work()
218 "3rd-order",
219 "5th-order"
234 "single-speed",
235 "double-speed (no mixing)",
236 "quad-speed (no mixing)"
261 * from -48 dB in 1.5 dB steps (mute instead of -49.5 dB)
263 static DECLARE_TLV_DB_SCALE(amix_tlv, -4950, 150, 1);
266 * from -78 dB in 1 dB steps (3 dB steps, really. LSB are ignored),
267 * from -66 dB in 0.5 dB steps (2 dB steps, really) and
268 * from -52 dB in 0.25 dB steps
272 0, 15, TLV_DB_SCALE_ITEM(-8200, 100, 1),
273 16, 43, TLV_DB_SCALE_ITEM(-6600, 50, 0),
274 44, 252, TLV_DB_SCALE_ITEM(-5200, 25, 0),
278 * from -72 dB in 1.5 dB steps (6 dB steps really),
279 * from -66 dB in 0.75 dB steps (3 dB steps really),
280 * from -60 dB in 0.5 dB steps (2 dB steps really) and
281 * from -46 dB in 0.25 dB steps
285 0, 7, TLV_DB_SCALE_ITEM(-7800, 150, 1),
286 8, 15, TLV_DB_SCALE_ITEM(-6600, 75, 0),
287 16, 43, TLV_DB_SCALE_ITEM(-6000, 50, 0),
288 44, 228, TLV_DB_SCALE_ITEM(-4600, 25, 0),
298 /* from -63 to 24 dB in 0.5 dB steps (-128...48) */
299 static DECLARE_TLV_DB_SCALE(dec_tlv, -6400, 50, 1);
313 SOC_DOUBLE_TLV("Tone Control - Treble", UDA1380_MODE, 4, 12, 3, 0, tr_tlv), /* TRL, TRR */
314 SOC_DOUBLE_TLV("Tone Control - Bass", UDA1380_MODE, 0, 8, 15, 0, bb_tlv), /* BBL, BBR */
317 SOC_ENUM("ADC Playback De-emphasis", uda1380_deemp_enum[0]), /* DE2 */
319 SOC_ENUM("PCM Playback De-emphasis", uda1380_deemp_enum[1]), /* DE1 */
326 SOC_DOUBLE_S8_TLV("ADC Capture Volume", UDA1380_DEC, -128, 48, dec_tlv), /* ML_DEC, MR_DEC */
335 /* -5.5, -8, -11.5, -14 dBFS */
339 /* Input mux */
343 /* Output mux */
347 /* Capture mux */
353 SND_SOC_DAPM_MUX("Input Mux", SND_SOC_NOPM, 0, 0,
355 SND_SOC_DAPM_MUX("Output Mux", SND_SOC_NOPM, 0, 0,
357 SND_SOC_DAPM_MUX("Capture Mux", SND_SOC_NOPM, 0, 0,
378 /* output mux */
379 {"HeadPhone Driver", NULL, "Output Mux"},
380 {"VOUTR", NULL, "Output Mux"},
381 {"VOUTL", NULL, "Output Mux"},
387 {"Output Mux", "DAC", "DAC"},
388 {"Output Mux", "Analog Mixer", "Analog Mixer"},
396 /* input mux */
397 {"Left ADC", NULL, "Input Mux"},
398 {"Input Mux", "Mic", "Mic LNA"},
399 {"Input Mux", "Mic + Line R", "Mic LNA"},
400 {"Input Mux", "Line L", "Left PGA"},
401 {"Input Mux", "Line", "Left PGA"},
416 struct snd_soc_codec *codec = codec_dai->codec; in uda1380_set_dai_fmt_both()
434 /* DATAI is slave only, so in single-link mode, this has to be slave */ in uda1380_set_dai_fmt_both()
436 return -EINVAL; in uda1380_set_dai_fmt_both()
446 struct snd_soc_codec *codec = codec_dai->codec; in uda1380_set_dai_fmt_playback()
466 return -EINVAL; in uda1380_set_dai_fmt_playback()
476 struct snd_soc_codec *codec = codec_dai->codec; in uda1380_set_dai_fmt_capture()
505 struct snd_soc_pcm_runtime *rtd = substream->private_data; in uda1380_trigger()
506 struct snd_soc_codec *codec = rtd->codec; in uda1380_trigger()
515 schedule_work(&uda1380->work); in uda1380_trigger()
521 schedule_work(&uda1380->work); in uda1380_trigger()
531 struct snd_soc_pcm_runtime *rtd = substream->private_data; in uda1380_pcm_hw_params()
532 struct snd_soc_codec *codec = rtd->codec; in uda1380_pcm_hw_params()
535 /* set WSPLL power and divider if running from this clock */ in uda1380_pcm_hw_params()
557 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in uda1380_pcm_hw_params()
569 struct snd_soc_pcm_runtime *rtd = substream->private_data; in uda1380_pcm_shutdown()
570 struct snd_soc_codec *codec = rtd->codec; in uda1380_pcm_shutdown()
573 /* shut down WSPLL power if running from this clock */ in uda1380_pcm_shutdown()
579 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in uda1380_pcm_shutdown()
592 struct uda1380_platform_data *pdata = codec->dev->platform_data; in uda1380_set_bias_level()
594 if (codec->dapm.bias_level == level) in uda1380_set_bias_level()
604 if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) { in uda1380_set_bias_level()
605 if (gpio_is_valid(pdata->gpio_power)) { in uda1380_set_bias_level()
606 gpio_set_value(pdata->gpio_power, 1); in uda1380_set_bias_level()
616 if (!gpio_is_valid(pdata->gpio_power)) in uda1380_set_bias_level()
619 gpio_set_value(pdata->gpio_power, 0); in uda1380_set_bias_level()
625 set_bit(reg - 0x10, &uda1380_cache_dirty); in uda1380_set_bias_level()
627 codec->dapm.bias_level = level; in uda1380_set_bias_level()
658 .name = "uda1380-hifi",
673 { /* playback only - dual interface */
674 .name = "uda1380-hifi-playback",
684 { /* capture only - dual interface*/
685 .name = "uda1380-hifi-capture",
711 struct uda1380_platform_data *pdata =codec->dev->platform_data; in uda1380_probe()
715 uda1380->codec = codec; in uda1380_probe()
717 codec->hw_write = (hw_write_t)i2c_master_send; in uda1380_probe()
718 codec->control_data = uda1380->control_data; in uda1380_probe()
721 return -EINVAL; in uda1380_probe()
723 if (gpio_is_valid(pdata->gpio_reset)) { in uda1380_probe()
724 ret = gpio_request_one(pdata->gpio_reset, GPIOF_OUT_INIT_LOW, in uda1380_probe()
730 if (gpio_is_valid(pdata->gpio_power)) { in uda1380_probe()
731 ret = gpio_request_one(pdata->gpio_power, GPIOF_OUT_INIT_LOW, in uda1380_probe()
741 INIT_WORK(&uda1380->work, uda1380_flush_work); in uda1380_probe()
745 /* set clock input */ in uda1380_probe()
746 switch (pdata->dac_clk) { in uda1380_probe()
759 if (gpio_is_valid(pdata->gpio_reset)) in uda1380_probe()
760 gpio_free(pdata->gpio_reset); in uda1380_probe()
768 struct uda1380_platform_data *pdata =codec->dev->platform_data; in uda1380_remove()
772 gpio_free(pdata->gpio_reset); in uda1380_remove()
773 gpio_free(pdata->gpio_power); in uda1380_remove()
806 uda1380 = devm_kzalloc(&i2c->dev, sizeof(struct uda1380_priv), in uda1380_i2c_probe()
809 return -ENOMEM; in uda1380_i2c_probe()
812 uda1380->control_data = i2c; in uda1380_i2c_probe()
814 ret = snd_soc_register_codec(&i2c->dev, in uda1380_i2c_probe()
821 snd_soc_unregister_codec(&i2c->dev); in uda1380_i2c_remove()
833 .name = "uda1380-codec",