Lines Matching +full:loop +full:- +full:powered

1 // SPDX-License-Identifier: GPL-2.0
3 // TSE-850 audio - ASoC driver for the Axentia TSE-850 with a PCM5142 codec
10 // IN1 +---o +------------+ o---+ OUT1
14 // +--o +--. |
17 // | .---. |
18 // DAC +----------->|Sum|---+
19 // | '---' |
23 // IN2 +---o--+------------+--o---+ OUT2
26 // The 'loop1' gpio pin controls two relays, which are either in loop
33 // 'loop2' relays are active, short-cutting the TSE-850 from channel 2.
34 // IN1, IN2, OUT1 and OUT2 are TSE-850 connectors and DAC is the PCB name
64 struct snd_soc_card *card = dapm->card; in tse850_get_mux1()
67 ucontrol->value.enumerated.item[0] = tse850->loop1_cache; in tse850_get_mux1()
76 struct snd_soc_card *card = dapm->card; in tse850_put_mux1()
78 struct soc_enum *e = (struct soc_enum *)kctrl->private_value; in tse850_put_mux1()
79 unsigned int val = ucontrol->value.enumerated.item[0]; in tse850_put_mux1()
81 if (val >= e->items) in tse850_put_mux1()
82 return -EINVAL; in tse850_put_mux1()
84 gpiod_set_value_cansleep(tse850->loop1, val); in tse850_put_mux1()
85 tse850->loop1_cache = val; in tse850_put_mux1()
94 struct snd_soc_card *card = dapm->card; in tse850_get_mux2()
97 ucontrol->value.enumerated.item[0] = tse850->loop2_cache; in tse850_get_mux2()
106 struct snd_soc_card *card = dapm->card; in tse850_put_mux2()
108 struct soc_enum *e = (struct soc_enum *)kctrl->private_value; in tse850_put_mux2()
109 unsigned int val = ucontrol->value.enumerated.item[0]; in tse850_put_mux2()
111 if (val >= e->items) in tse850_put_mux2()
112 return -EINVAL; in tse850_put_mux2()
114 gpiod_set_value_cansleep(tse850->loop2, val); in tse850_put_mux2()
115 tse850->loop2_cache = val; in tse850_put_mux2()
124 struct snd_soc_card *card = dapm->card; in tse850_get_mix()
127 ucontrol->value.enumerated.item[0] = tse850->add_cache; in tse850_get_mix()
136 struct snd_soc_card *card = dapm->card; in tse850_put_mix()
138 int connect = !!ucontrol->value.integer.value[0]; in tse850_put_mix()
140 if (tse850->add_cache == connect) in tse850_put_mix()
145 * inside snd_soc_dapm_mixer_update_power in the loop. in tse850_put_mix()
147 gpiod_set_value_cansleep(tse850->add, connect); in tse850_put_mix()
148 tse850->add_cache = connect; in tse850_put_mix()
158 struct snd_soc_card *card = dapm->card; in tse850_get_ana()
162 ret = regulator_get_voltage(tse850->ana); in tse850_get_ana()
168 * -11.5V to "Low" (enum 0) in tse850_get_ana()
169 * 11.5V-12.5V to "12V" (enum 1) in tse850_get_ana()
170 * 12.5V-13.5V to "13V" (enum 2) in tse850_get_ana()
172 * 18.5V-19.5V to "19V" (enum 8) in tse850_get_ana()
173 * 19.5V- to "20V" (enum 9) in tse850_get_ana()
179 ret -= 11000000; in tse850_get_ana()
182 ucontrol->value.enumerated.item[0] = ret; in tse850_get_ana()
191 struct snd_soc_card *card = dapm->card; in tse850_put_ana()
193 struct soc_enum *e = (struct soc_enum *)kctrl->private_value; in tse850_put_ana()
194 unsigned int uV = ucontrol->value.enumerated.item[0]; in tse850_put_ana()
197 if (uV >= e->items) in tse850_put_ana()
198 return -EINVAL; in tse850_put_ana()
214 ret = regulator_set_voltage(tse850->ana, uV, uV); in tse850_put_ana()
221 static const char * const mux_text[] = { "Mixer", "Loop" };
275 * matter in practice since nothing is powered in those sections anyway.
281 { "MUX1", "Loop", "IN1" },
284 { "MUX2", "Loop", "IN2" },
299 DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "pcm512x-hifi")),
303 .name = "TSE-850",
304 .stream_name = "TSE-850-PCM",
312 .name = "TSE-850-ASoC",
325 struct device_node *np = pdev->dev.of_node; in tse850_dt_init()
330 dev_err(&pdev->dev, "only device tree supported\n"); in tse850_dt_init()
331 return -EINVAL; in tse850_dt_init()
334 cpu_np = of_parse_phandle(np, "axentia,cpu-dai", 0); in tse850_dt_init()
336 dev_err(&pdev->dev, "failed to get cpu dai\n"); in tse850_dt_init()
337 return -EINVAL; in tse850_dt_init()
339 dailink->cpus->of_node = cpu_np; in tse850_dt_init()
340 dailink->platforms->of_node = cpu_np; in tse850_dt_init()
343 codec_np = of_parse_phandle(np, "axentia,audio-codec", 0); in tse850_dt_init()
345 dev_err(&pdev->dev, "failed to get codec info\n"); in tse850_dt_init()
346 return -EINVAL; in tse850_dt_init()
348 dailink->codecs->of_node = codec_np; in tse850_dt_init()
357 struct device *dev = card->dev = &pdev->dev; in tse850_probe()
363 return -ENOMEM; in tse850_probe()
373 tse850->add = devm_gpiod_get(dev, "axentia,add", GPIOD_OUT_HIGH); in tse850_probe()
374 if (IS_ERR(tse850->add)) in tse850_probe()
375 return dev_err_probe(dev, PTR_ERR(tse850->add), in tse850_probe()
377 tse850->add_cache = 1; in tse850_probe()
379 tse850->loop1 = devm_gpiod_get(dev, "axentia,loop1", GPIOD_OUT_HIGH); in tse850_probe()
380 if (IS_ERR(tse850->loop1)) in tse850_probe()
381 return dev_err_probe(dev, PTR_ERR(tse850->loop1), in tse850_probe()
383 tse850->loop1_cache = 1; in tse850_probe()
385 tse850->loop2 = devm_gpiod_get(dev, "axentia,loop2", GPIOD_OUT_HIGH); in tse850_probe()
386 if (IS_ERR(tse850->loop2)) in tse850_probe()
387 return dev_err_probe(dev, PTR_ERR(tse850->loop2), in tse850_probe()
389 tse850->loop2_cache = 1; in tse850_probe()
391 tse850->ana = devm_regulator_get(dev, "axentia,ana"); in tse850_probe()
392 if (IS_ERR(tse850->ana)) in tse850_probe()
393 return dev_err_probe(dev, PTR_ERR(tse850->ana), in tse850_probe()
396 ret = regulator_enable(tse850->ana); in tse850_probe()
411 regulator_disable(tse850->ana); in tse850_probe()
421 regulator_disable(tse850->ana); in tse850_remove()
425 { .compatible = "axentia,tse850-pcm5142", },
432 .name = "axentia-tse850-pcm5142",
443 MODULE_DESCRIPTION("ALSA SoC driver for TSE-850 with PCM5142 codec");