Lines Matching +full:rst +full:- +full:syscon
1 // SPDX-License-Identifier: GPL-2.0
5 // Copyright (c) 2016-2018 Socionext Inc.
10 #include <linux/mfd/syscon.h>
25 struct device *dev = &chip->pdev->dev;
27 if (pll_id < 0 || chip->num_plls <= pll_id) {
32 return chip->plls[pll_id].enable;
36 * find_volume - find volume supported HW port by HW port number
51 for (i = 0; i < chip->num_aios; i++) {
52 struct uniphier_aio_sub *sub = &chip->aios[i].sub[0];
54 if (!sub->swm)
57 if (sub->swm->oport.hw == oport_hw)
68 spec->swm.dir != PORT_DIR_OUTPUT) {
73 spec->swm.dir != PORT_DIR_INPUT) {
77 if (spec->name && strcmp(spec->name, name) == 0)
80 if (spec->gname && strcmp(spec->gname, name) == 0)
87 * find_spec - find HW specification info by name
96 * in each drivers (see: aio-i2s.c).
105 const struct uniphier_aio_chip_spec *chip_spec = aio->chip->chip_spec;
108 for (i = 0; i < chip_spec->num_specs; i++) {
109 const struct uniphier_aio_spec *spec = &chip_spec->specs[i];
119 * find_divider - find clock divider by frequency
135 if (!is_valid_pll(aio->chip, pll_id))
136 return -EINVAL;
138 pll = &aio->chip->plls[pll_id];
140 if (pll->freq * mul[i] / div[i] == freq)
143 return -ENOTSUPP;
150 struct device *dev = &aio->chip->pdev->dev;
156 return -ENOTSUPP;
191 return -EINVAL;
195 for (pll_id = 0; pll_id < aio->chip->num_plls; pll_id++) {
198 aio->plldiv = div_id;
202 if (pll_id == aio->chip->num_plls) {
205 return -EINVAL;
210 aio->pll_out = pll_id;
212 aio->pll_in = pll_id;
224 if (!is_valid_pll(aio->chip, pll_id))
225 return -EINVAL;
227 ret = aio_chip_set_pll(aio->chip, pll_id, freq_out);
237 struct device *dev = &aio->chip->pdev->dev;
243 aio->fmt = fmt & SND_SOC_DAIFMT_FORMAT_MASK;
248 return -EINVAL;
258 struct uniphier_aio_sub *sub = &aio->sub[substream->stream];
260 sub->substream = substream;
261 sub->pass_through = 0;
262 sub->use_mmap = true;
271 struct uniphier_aio_sub *sub = &aio->sub[substream->stream];
273 sub->substream = NULL;
281 struct uniphier_aio_sub *sub = &aio->sub[substream->stream];
282 struct device *dev = &aio->chip->pdev->dev;
298 return -EINVAL;
305 sub->params = *params;
306 sub->setting = 1;
309 aio_port_set_volume(sub, sub->vol);
319 struct uniphier_aio_sub *sub = &aio->sub[substream->stream];
321 sub->setting = 0;
330 struct uniphier_aio_sub *sub = &aio->sub[substream->stream];
333 ret = aio_port_set_param(sub, sub->pass_through, &sub->params);
336 ret = aio_src_set_param(sub, &sub->params);
341 ret = aio_if_set_param(sub, sub->pass_through);
345 if (sub->swm->type == PORT_TYPE_CONV) {
363 for (i = 0; i < ARRAY_SIZE(aio->sub); i++) {
364 struct uniphier_aio_sub *sub = &aio->sub[i];
367 spec = find_spec(aio, dai->name, i);
371 sub->swm = &spec->swm;
372 sub->spec = spec;
374 sub->vol = AUD_VOL_INIT;
377 aio_iecout_set_enable(aio->chip, true);
378 aio_chip_init(aio->chip);
379 aio->chip->active = 1;
388 aio->chip->active = 0;
532 aio->chip->num_wup_aios--;
533 if (!aio->chip->num_wup_aios) {
534 reset_control_assert(aio->chip->rst);
535 clk_disable_unprepare(aio->chip->clk);
556 if (!aio->chip->active)
559 if (!aio->chip->num_wup_aios) {
560 ret = clk_prepare_enable(aio->chip->clk);
564 ret = reset_control_deassert(aio->chip->rst);
569 aio_iecout_set_enable(aio->chip, true);
570 aio_chip_init(aio->chip);
572 for (i = 0; i < ARRAY_SIZE(aio->sub); i++) {
573 struct uniphier_aio_sub *sub = &aio->sub[i];
575 if (!sub->spec || !sub->substream)
582 if (!sub->setting)
588 aio->chip->num_wup_aios++;
593 if (!aio->chip->num_wup_aios)
594 reset_control_assert(aio->chip->rst);
596 if (!aio->chip->num_wup_aios)
597 clk_disable_unprepare(aio->chip->clk);
615 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
616 uinfo->count = 1;
617 uinfo->value.integer.min = 0;
618 uinfo->value.integer.max = AUD_VOL_MAX;
629 int oport_hw = kcontrol->private_value;
635 ucontrol->value.integer.value[0] = sub->vol;
646 int oport_hw = kcontrol->private_value;
652 if (sub->vol == ucontrol->value.integer.value[0])
654 sub->vol = ucontrol->value.integer.value[0];
656 aio_port_set_volume(sub, sub->vol);
719 .name = "uniphier-aio",
729 struct device *dev = &pdev->dev;
734 return -ENOMEM;
736 chip->chip_spec = of_device_get_match_data(dev);
737 if (!chip->chip_spec)
738 return -EINVAL;
740 chip->regmap_sg = syscon_regmap_lookup_by_phandle(dev->of_node,
741 "socionext,syscon");
742 if (IS_ERR(chip->regmap_sg)) {
743 if (PTR_ERR(chip->regmap_sg) == -EPROBE_DEFER)
744 return -EPROBE_DEFER;
745 chip->regmap_sg = NULL;
748 chip->clk = devm_clk_get(dev, "aio");
749 if (IS_ERR(chip->clk))
750 return PTR_ERR(chip->clk);
752 chip->rst = devm_reset_control_get_shared(dev, "aio");
753 if (IS_ERR(chip->rst))
754 return PTR_ERR(chip->rst);
756 chip->num_aios = chip->chip_spec->num_dais;
757 chip->num_wup_aios = chip->num_aios;
758 chip->aios = devm_kcalloc(dev,
759 chip->num_aios, sizeof(struct uniphier_aio),
761 if (!chip->aios)
762 return -ENOMEM;
764 chip->num_plls = chip->chip_spec->num_plls;
765 chip->plls = devm_kmemdup_array(dev, chip->chip_spec->plls, chip->num_plls,
766 sizeof(*chip->chip_spec->plls), GFP_KERNEL);
767 if (!chip->plls)
768 return -ENOMEM;
770 for (i = 0; i < chip->num_aios; i++) {
771 struct uniphier_aio *aio = &chip->aios[i];
773 aio->chip = chip;
774 aio->fmt = SND_SOC_DAIFMT_I2S;
776 for (j = 0; j < ARRAY_SIZE(aio->sub); j++) {
777 struct uniphier_aio_sub *sub = &aio->sub[j];
779 sub->aio = aio;
780 spin_lock_init(&sub->lock);
784 chip->pdev = pdev;
787 ret = clk_prepare_enable(chip->clk);
791 ret = reset_control_deassert(chip->rst);
796 chip->chip_spec->dais,
797 chip->chip_spec->num_dais);
812 reset_control_assert(chip->rst);
815 clk_disable_unprepare(chip->clk);
825 reset_control_assert(chip->rst);
826 clk_disable_unprepare(chip->clk);