Merge tag 'for-linus-20190706' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / sound / soc / fsl / phycore-ac97.c
blobfe7ba6db7c96430df7064d5f9d559faa2ce8089c
1 // SPDX-License-Identifier: GPL-2.0+
2 //
3 // phycore-ac97.c -- SoC audio for imx_phycore in AC97 mode
4 //
5 // Copyright 2009 Sascha Hauer, Pengutronix <s.hauer@pengutronix.de>
7 #include <linux/module.h>
8 #include <linux/moduleparam.h>
9 #include <linux/device.h>
10 #include <linux/i2c.h>
11 #include <sound/core.h>
12 #include <sound/pcm.h>
13 #include <sound/soc.h>
14 #include <asm/mach-types.h>
16 #include "imx-audmux.h"
18 static struct snd_soc_card imx_phycore;
20 static const struct snd_soc_ops imx_phycore_hifi_ops = {
23 static struct snd_soc_dai_link imx_phycore_dai_ac97[] = {
25 .name = "HiFi",
26 .stream_name = "HiFi",
27 .codec_dai_name = "wm9712-hifi",
28 .codec_name = "wm9712-codec",
29 .cpu_dai_name = "imx-ssi.0",
30 .platform_name = "imx-ssi.0",
31 .ops = &imx_phycore_hifi_ops,
35 static struct snd_soc_card imx_phycore = {
36 .name = "PhyCORE-ac97-audio",
37 .owner = THIS_MODULE,
38 .dai_link = imx_phycore_dai_ac97,
39 .num_links = ARRAY_SIZE(imx_phycore_dai_ac97),
42 static struct platform_device *imx_phycore_snd_ac97_device;
43 static struct platform_device *imx_phycore_snd_device;
45 static int __init imx_phycore_init(void)
47 int ret;
49 if (machine_is_pca100()) {
50 imx_audmux_v1_configure_port(MX27_AUDMUX_HPCR1_SSI0,
51 IMX_AUDMUX_V1_PCR_SYN | /* 4wire mode */
52 IMX_AUDMUX_V1_PCR_TFCSEL(3) |
53 IMX_AUDMUX_V1_PCR_TCLKDIR | /* clock is output */
54 IMX_AUDMUX_V1_PCR_RXDSEL(3));
55 imx_audmux_v1_configure_port(3,
56 IMX_AUDMUX_V1_PCR_SYN | /* 4wire mode */
57 IMX_AUDMUX_V1_PCR_TFCSEL(0) |
58 IMX_AUDMUX_V1_PCR_TFSDIR |
59 IMX_AUDMUX_V1_PCR_RXDSEL(0));
60 } else if (machine_is_pcm043()) {
61 imx_audmux_v2_configure_port(3,
62 IMX_AUDMUX_V2_PTCR_SYN | /* 4wire mode */
63 IMX_AUDMUX_V2_PTCR_TFSEL(0) |
64 IMX_AUDMUX_V2_PTCR_TFSDIR,
65 IMX_AUDMUX_V2_PDCR_RXDSEL(0));
66 imx_audmux_v2_configure_port(0,
67 IMX_AUDMUX_V2_PTCR_SYN | /* 4wire mode */
68 IMX_AUDMUX_V2_PTCR_TCSEL(3) |
69 IMX_AUDMUX_V2_PTCR_TCLKDIR, /* clock is output */
70 IMX_AUDMUX_V2_PDCR_RXDSEL(3));
71 } else {
72 /* return happy. We might run on a totally different machine */
73 return 0;
76 imx_phycore_snd_ac97_device = platform_device_alloc("soc-audio", -1);
77 if (!imx_phycore_snd_ac97_device)
78 return -ENOMEM;
80 platform_set_drvdata(imx_phycore_snd_ac97_device, &imx_phycore);
81 ret = platform_device_add(imx_phycore_snd_ac97_device);
82 if (ret)
83 goto fail1;
85 imx_phycore_snd_device = platform_device_alloc("wm9712-codec", -1);
86 if (!imx_phycore_snd_device) {
87 ret = -ENOMEM;
88 goto fail2;
90 ret = platform_device_add(imx_phycore_snd_device);
92 if (ret) {
93 printk(KERN_ERR "ASoC: Platform device allocation failed\n");
94 goto fail3;
97 return 0;
99 fail3:
100 platform_device_put(imx_phycore_snd_device);
101 fail2:
102 platform_device_del(imx_phycore_snd_ac97_device);
103 fail1:
104 platform_device_put(imx_phycore_snd_ac97_device);
105 return ret;
108 static void __exit imx_phycore_exit(void)
110 platform_device_unregister(imx_phycore_snd_device);
111 platform_device_unregister(imx_phycore_snd_ac97_device);
114 late_initcall(imx_phycore_init);
115 module_exit(imx_phycore_exit);
117 MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de>");
118 MODULE_DESCRIPTION("PhyCORE ALSA SoC driver");
119 MODULE_LICENSE("GPL");