Lines Matching +full:global +full:- +full:utilities
1 // SPDX-License-Identifier: GPL-2.0
21 /* P1022-specific PMUXCR and DMUXCR bit definitions */
49 unsigned int shift = 16 + (8 * (1 - co) + 2 * (3 - ch)); in guts_set_dmuxcr()
51 clrsetbits_be32(&guts->dmuxcr, 3 << shift, device << shift); in guts_set_dmuxcr()
54 /* There's only one global utilities register */
58 * machine_data: machine-specific ASoC device data
79 * This function is used to initialize the board-specific hardware.
91 dev_err(card->dev, "could not map global utilities\n"); in p1022_ds_machine_probe()
92 return -ENOMEM; in p1022_ds_machine_probe()
96 clrsetbits_be32(&guts->pmuxcr, CCSR_GUTS_PMUXCR_UART0_I2C1_MASK, in p1022_ds_machine_probe()
100 clrsetbits_be32(&guts->pmuxcr, CCSR_GUTS_PMUXCR_SSI_DMA_TDM_MASK, in p1022_ds_machine_probe()
104 guts_set_dmuxcr(guts, mdata->dma_id[0], mdata->dma_channel_id[0], in p1022_ds_machine_probe()
107 guts_set_dmuxcr(guts, mdata->dma_id[1], mdata->dma_channel_id[1], in p1022_ds_machine_probe()
118 * This function takes board-specific information, like clock frequencies
126 container_of(rtd->card, struct machine_data, card); in p1022_ds_startup()
127 struct device *dev = rtd->card->dev; in p1022_ds_startup()
131 ret = snd_soc_dai_set_fmt(snd_soc_rtd_to_codec(rtd, 0), mdata->dai_format); in p1022_ds_startup()
141 ret = snd_soc_dai_set_sysclk(snd_soc_rtd_to_codec(rtd, 0), 0, mdata->clk_frequency, in p1022_ds_startup()
142 mdata->codec_clk_direction); in p1022_ds_startup()
155 * de-program the DMACR and PMUXCR register.
165 dev_err(card->dev, "could not map global utilities\n"); in p1022_ds_machine_remove()
166 return -ENOMEM; in p1022_ds_machine_remove()
170 clrbits32(&guts->pmuxcr, CCSR_GUTS_PMUXCR_UART0_I2C1_MASK); in p1022_ds_machine_remove()
171 clrbits32(&guts->pmuxcr, CCSR_GUTS_PMUXCR_SSI_DMA_TDM_MASK); in p1022_ds_machine_remove()
172 guts_set_dmuxcr(guts, mdata->dma_id[0], mdata->dma_channel_id[0], 0); in p1022_ds_machine_remove()
173 guts_set_dmuxcr(guts, mdata->dma_id[1], mdata->dma_channel_id[1], 0); in p1022_ds_machine_remove()
196 struct device *dev = pdev->dev.parent; in p1022_ds_probe()
199 struct device_node *np = ssi_pdev->dev.of_node; in p1022_ds_probe()
208 codec_np = of_parse_phandle(np, "codec-handle", 0); in p1022_ds_probe()
211 return -EINVAL; in p1022_ds_probe()
216 ret = -ENOMEM; in p1022_ds_probe()
220 comp = devm_kzalloc(&pdev->dev, 6 * sizeof(*comp), GFP_KERNEL); in p1022_ds_probe()
222 ret = -ENOMEM; in p1022_ds_probe()
226 mdata->dai[0].cpus = &comp[0]; in p1022_ds_probe()
227 mdata->dai[0].codecs = &comp[1]; in p1022_ds_probe()
228 mdata->dai[0].platforms = &comp[2]; in p1022_ds_probe()
230 mdata->dai[0].num_cpus = 1; in p1022_ds_probe()
231 mdata->dai[0].num_codecs = 1; in p1022_ds_probe()
232 mdata->dai[0].num_platforms = 1; in p1022_ds_probe()
234 mdata->dai[1].cpus = &comp[3]; in p1022_ds_probe()
235 mdata->dai[1].codecs = &comp[4]; in p1022_ds_probe()
236 mdata->dai[1].platforms = &comp[5]; in p1022_ds_probe()
238 mdata->dai[1].num_cpus = 1; in p1022_ds_probe()
239 mdata->dai[1].num_codecs = 1; in p1022_ds_probe()
240 mdata->dai[1].num_platforms = 1; in p1022_ds_probe()
243 mdata->dai[0].cpus->dai_name = dev_name(&ssi_pdev->dev); in p1022_ds_probe()
244 mdata->dai[0].ops = &p1022_ds_ops; in p1022_ds_probe()
247 mdata->dai[0].codecs->of_node = codec_np; in p1022_ds_probe()
253 memcpy(&mdata->dai[1], &mdata->dai[0], sizeof(struct snd_soc_dai_link)); in p1022_ds_probe()
256 mdata->dai[0].codecs->dai_name = "wm8776-hifi-playback"; in p1022_ds_probe()
257 mdata->dai[1].codecs->dai_name = "wm8776-hifi-capture"; in p1022_ds_probe()
260 iprop = of_get_property(np, "cell-index", NULL); in p1022_ds_probe()
262 dev_err(&pdev->dev, "cell-index property not found\n"); in p1022_ds_probe()
263 ret = -EINVAL; in p1022_ds_probe()
266 mdata->ssi_id = be32_to_cpup(iprop); in p1022_ds_probe()
271 dev_err(&pdev->dev, "fsl,mode property not found\n"); in p1022_ds_probe()
272 ret = -EINVAL; in p1022_ds_probe()
276 if (strcasecmp(sprop, "i2s-slave") == 0) { in p1022_ds_probe()
277 mdata->dai_format = SND_SOC_DAIFMT_NB_NF | in p1022_ds_probe()
279 mdata->codec_clk_direction = SND_SOC_CLOCK_OUT; in p1022_ds_probe()
280 mdata->cpu_clk_direction = SND_SOC_CLOCK_IN; in p1022_ds_probe()
282 /* In i2s-slave mode, the codec has its own clock source, so we in p1022_ds_probe()
286 iprop = of_get_property(codec_np, "clock-frequency", NULL); in p1022_ds_probe()
288 dev_err(&pdev->dev, "codec bus-frequency " in p1022_ds_probe()
290 ret = -EINVAL; in p1022_ds_probe()
293 mdata->clk_frequency = be32_to_cpup(iprop); in p1022_ds_probe()
294 } else if (strcasecmp(sprop, "i2s-master") == 0) { in p1022_ds_probe()
295 mdata->dai_format = SND_SOC_DAIFMT_NB_NF | in p1022_ds_probe()
297 mdata->codec_clk_direction = SND_SOC_CLOCK_IN; in p1022_ds_probe()
298 mdata->cpu_clk_direction = SND_SOC_CLOCK_OUT; in p1022_ds_probe()
299 } else if (strcasecmp(sprop, "lj-slave") == 0) { in p1022_ds_probe()
300 mdata->dai_format = SND_SOC_DAIFMT_NB_NF | in p1022_ds_probe()
302 mdata->codec_clk_direction = SND_SOC_CLOCK_OUT; in p1022_ds_probe()
303 mdata->cpu_clk_direction = SND_SOC_CLOCK_IN; in p1022_ds_probe()
304 } else if (strcasecmp(sprop, "lj-master") == 0) { in p1022_ds_probe()
305 mdata->dai_format = SND_SOC_DAIFMT_NB_NF | in p1022_ds_probe()
307 mdata->codec_clk_direction = SND_SOC_CLOCK_IN; in p1022_ds_probe()
308 mdata->cpu_clk_direction = SND_SOC_CLOCK_OUT; in p1022_ds_probe()
309 } else if (strcasecmp(sprop, "rj-slave") == 0) { in p1022_ds_probe()
310 mdata->dai_format = SND_SOC_DAIFMT_NB_NF | in p1022_ds_probe()
312 mdata->codec_clk_direction = SND_SOC_CLOCK_OUT; in p1022_ds_probe()
313 mdata->cpu_clk_direction = SND_SOC_CLOCK_IN; in p1022_ds_probe()
314 } else if (strcasecmp(sprop, "rj-master") == 0) { in p1022_ds_probe()
315 mdata->dai_format = SND_SOC_DAIFMT_NB_NF | in p1022_ds_probe()
317 mdata->codec_clk_direction = SND_SOC_CLOCK_IN; in p1022_ds_probe()
318 mdata->cpu_clk_direction = SND_SOC_CLOCK_OUT; in p1022_ds_probe()
319 } else if (strcasecmp(sprop, "ac97-slave") == 0) { in p1022_ds_probe()
320 mdata->dai_format = SND_SOC_DAIFMT_NB_NF | in p1022_ds_probe()
322 mdata->codec_clk_direction = SND_SOC_CLOCK_OUT; in p1022_ds_probe()
323 mdata->cpu_clk_direction = SND_SOC_CLOCK_IN; in p1022_ds_probe()
324 } else if (strcasecmp(sprop, "ac97-master") == 0) { in p1022_ds_probe()
325 mdata->dai_format = SND_SOC_DAIFMT_NB_NF | in p1022_ds_probe()
327 mdata->codec_clk_direction = SND_SOC_CLOCK_IN; in p1022_ds_probe()
328 mdata->cpu_clk_direction = SND_SOC_CLOCK_OUT; in p1022_ds_probe()
330 dev_err(&pdev->dev, in p1022_ds_probe()
332 ret = -EINVAL; in p1022_ds_probe()
336 if (!mdata->clk_frequency) { in p1022_ds_probe()
337 dev_err(&pdev->dev, "unknown clock frequency\n"); in p1022_ds_probe()
338 ret = -EINVAL; in p1022_ds_probe()
343 mdata->dai[0].platforms->name = mdata->platform_name[0]; in p1022_ds_probe()
344 ret = fsl_asoc_get_dma_channel(np, "fsl,playback-dma", &mdata->dai[0], in p1022_ds_probe()
345 &mdata->dma_channel_id[0], in p1022_ds_probe()
346 &mdata->dma_id[0]); in p1022_ds_probe()
348 dev_err(&pdev->dev, "missing/invalid playback DMA phandle\n"); in p1022_ds_probe()
353 mdata->dai[1].platforms->name = mdata->platform_name[1]; in p1022_ds_probe()
354 ret = fsl_asoc_get_dma_channel(np, "fsl,capture-dma", &mdata->dai[1], in p1022_ds_probe()
355 &mdata->dma_channel_id[1], in p1022_ds_probe()
356 &mdata->dma_id[1]); in p1022_ds_probe()
358 dev_err(&pdev->dev, "missing/invalid capture DMA phandle\n"); in p1022_ds_probe()
363 mdata->dai[0].stream_name = "playback"; in p1022_ds_probe()
364 mdata->dai[1].stream_name = "capture"; in p1022_ds_probe()
365 mdata->dai[0].name = mdata->dai[0].stream_name; in p1022_ds_probe()
366 mdata->dai[1].name = mdata->dai[1].stream_name; in p1022_ds_probe()
368 mdata->card.probe = p1022_ds_machine_probe; in p1022_ds_probe()
369 mdata->card.remove = p1022_ds_machine_remove; in p1022_ds_probe()
370 mdata->card.name = pdev->name; /* The platform driver name */ in p1022_ds_probe()
371 mdata->card.owner = THIS_MODULE; in p1022_ds_probe()
372 mdata->card.dev = &pdev->dev; in p1022_ds_probe()
373 mdata->card.num_links = 2; in p1022_ds_probe()
374 mdata->card.dai_link = mdata->dai; in p1022_ds_probe()
377 ret = snd_soc_register_card(&mdata->card); in p1022_ds_probe()
379 dev_err(&pdev->dev, "could not register card\n"); in p1022_ds_probe()
417 .name = "snd-soc-p1022ds",
431 /* Get the physical address of the global utilities registers */ in p1022_ds_init()
432 guts_np = of_find_compatible_node(NULL, NULL, "fsl,p1022-guts"); in p1022_ds_init()
434 pr_err("snd-soc-p1022ds: missing/invalid global utils node\n"); in p1022_ds_init()
436 return -EINVAL; in p1022_ds_init()