Lines Matching +full:mux +full:- +full:int +full:- +full:port
1 // SPDX-License-Identifier: GPL-2.0+
14 #include "imx-audmux.h"
24 unsigned int clk_frequency;
27 static int imx_sgtl5000_dai_init(struct snd_soc_pcm_runtime *rtd) in imx_sgtl5000_dai_init()
29 struct imx_sgtl5000_data *data = snd_soc_card_get_drvdata(rtd->card); in imx_sgtl5000_dai_init()
30 struct device *dev = rtd->card->dev; in imx_sgtl5000_dai_init()
31 int ret; in imx_sgtl5000_dai_init()
34 data->clk_frequency, SND_SOC_CLOCK_IN); in imx_sgtl5000_dai_init()
51 static int imx_sgtl5000_probe(struct platform_device *pdev) in imx_sgtl5000_probe()
53 struct device_node *np = pdev->dev.of_node; in imx_sgtl5000_probe()
59 int int_port, ext_port; in imx_sgtl5000_probe()
60 int ret; in imx_sgtl5000_probe()
62 ret = of_property_read_u32(np, "mux-int-port", &int_port); in imx_sgtl5000_probe()
64 dev_err(&pdev->dev, "mux-int-port missing or invalid\n"); in imx_sgtl5000_probe()
67 ret = of_property_read_u32(np, "mux-ext-port", &ext_port); in imx_sgtl5000_probe()
69 dev_err(&pdev->dev, "mux-ext-port missing or invalid\n"); in imx_sgtl5000_probe()
74 * The port numbering in the hardware manual starts at 1, while in imx_sgtl5000_probe()
77 int_port--; in imx_sgtl5000_probe()
78 ext_port--; in imx_sgtl5000_probe()
87 dev_err(&pdev->dev, "audmux internal port setup failed\n"); in imx_sgtl5000_probe()
94 dev_err(&pdev->dev, "audmux external port setup failed\n"); in imx_sgtl5000_probe()
98 ssi_np = of_parse_phandle(pdev->dev.of_node, "ssi-controller", 0); in imx_sgtl5000_probe()
99 codec_np = of_parse_phandle(pdev->dev.of_node, "audio-codec", 0); in imx_sgtl5000_probe()
101 dev_err(&pdev->dev, "phandle missing or invalid\n"); in imx_sgtl5000_probe()
102 ret = -EINVAL; in imx_sgtl5000_probe()
108 dev_dbg(&pdev->dev, "failed to find SSI platform device\n"); in imx_sgtl5000_probe()
109 ret = -EPROBE_DEFER; in imx_sgtl5000_probe()
112 put_device(&ssi_pdev->dev); in imx_sgtl5000_probe()
115 dev_dbg(&pdev->dev, "failed to find codec platform device\n"); in imx_sgtl5000_probe()
116 ret = -EPROBE_DEFER; in imx_sgtl5000_probe()
120 data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); in imx_sgtl5000_probe()
122 ret = -ENOMEM; in imx_sgtl5000_probe()
126 comp = devm_kzalloc(&pdev->dev, 3 * sizeof(*comp), GFP_KERNEL); in imx_sgtl5000_probe()
128 ret = -ENOMEM; in imx_sgtl5000_probe()
132 data->codec_clk = clk_get(&codec_dev->dev, NULL); in imx_sgtl5000_probe()
133 if (IS_ERR(data->codec_clk)) { in imx_sgtl5000_probe()
134 ret = PTR_ERR(data->codec_clk); in imx_sgtl5000_probe()
138 data->clk_frequency = clk_get_rate(data->codec_clk); in imx_sgtl5000_probe()
140 data->dai.cpus = &comp[0]; in imx_sgtl5000_probe()
141 data->dai.codecs = &comp[1]; in imx_sgtl5000_probe()
142 data->dai.platforms = &comp[2]; in imx_sgtl5000_probe()
144 data->dai.num_cpus = 1; in imx_sgtl5000_probe()
145 data->dai.num_codecs = 1; in imx_sgtl5000_probe()
146 data->dai.num_platforms = 1; in imx_sgtl5000_probe()
148 data->dai.name = "HiFi"; in imx_sgtl5000_probe()
149 data->dai.stream_name = "HiFi"; in imx_sgtl5000_probe()
150 data->dai.codecs->dai_name = "sgtl5000"; in imx_sgtl5000_probe()
151 data->dai.codecs->of_node = codec_np; in imx_sgtl5000_probe()
152 data->dai.cpus->of_node = ssi_np; in imx_sgtl5000_probe()
153 data->dai.platforms->of_node = ssi_np; in imx_sgtl5000_probe()
154 data->dai.init = &imx_sgtl5000_dai_init; in imx_sgtl5000_probe()
155 data->dai.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | in imx_sgtl5000_probe()
158 data->card.dev = &pdev->dev; in imx_sgtl5000_probe()
159 ret = snd_soc_of_parse_card_name(&data->card, "model"); in imx_sgtl5000_probe()
162 ret = snd_soc_of_parse_audio_routing(&data->card, "audio-routing"); in imx_sgtl5000_probe()
165 data->card.num_links = 1; in imx_sgtl5000_probe()
166 data->card.owner = THIS_MODULE; in imx_sgtl5000_probe()
167 data->card.dai_link = &data->dai; in imx_sgtl5000_probe()
168 data->card.dapm_widgets = imx_sgtl5000_dapm_widgets; in imx_sgtl5000_probe()
169 data->card.num_dapm_widgets = ARRAY_SIZE(imx_sgtl5000_dapm_widgets); in imx_sgtl5000_probe()
171 platform_set_drvdata(pdev, &data->card); in imx_sgtl5000_probe()
172 snd_soc_card_set_drvdata(&data->card, data); in imx_sgtl5000_probe()
174 ret = devm_snd_soc_register_card(&pdev->dev, &data->card); in imx_sgtl5000_probe()
176 dev_err_probe(&pdev->dev, ret, "snd_soc_register_card failed\n"); in imx_sgtl5000_probe()
186 put_device(&codec_dev->dev); in imx_sgtl5000_probe()
188 if (data && !IS_ERR(data->codec_clk)) in imx_sgtl5000_probe()
189 clk_put(data->codec_clk); in imx_sgtl5000_probe()
201 clk_put(data->codec_clk); in imx_sgtl5000_remove()
205 { .compatible = "fsl,imx-audio-sgtl5000", },
212 .name = "imx-sgtl5000",
224 MODULE_ALIAS("platform:imx-sgtl5000");