1 // SPDX-License-Identifier: GPL-2.0+
3 // phycore-ac97.c -- SoC audio for imx_phycore in AC97 mode
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 SND_SOC_DAILINK_DEFS(hifi
,
24 DAILINK_COMP_ARRAY(COMP_CPU("imx-ssi.0")),
25 DAILINK_COMP_ARRAY(COMP_CODEC("wm9712-codec", "wm9712-hifi")),
26 DAILINK_COMP_ARRAY(COMP_PLATFORM("imx-ssi.0")));
28 static struct snd_soc_dai_link imx_phycore_dai_ac97
[] = {
31 .stream_name
= "HiFi",
32 .ops
= &imx_phycore_hifi_ops
,
33 SND_SOC_DAILINK_REG(hifi
),
37 static struct snd_soc_card imx_phycore
= {
38 .name
= "PhyCORE-ac97-audio",
40 .dai_link
= imx_phycore_dai_ac97
,
41 .num_links
= ARRAY_SIZE(imx_phycore_dai_ac97
),
44 static struct platform_device
*imx_phycore_snd_ac97_device
;
45 static struct platform_device
*imx_phycore_snd_device
;
47 static int __init
imx_phycore_init(void)
51 if (machine_is_pca100()) {
52 imx_audmux_v1_configure_port(MX27_AUDMUX_HPCR1_SSI0
,
53 IMX_AUDMUX_V1_PCR_SYN
| /* 4wire mode */
54 IMX_AUDMUX_V1_PCR_TFCSEL(3) |
55 IMX_AUDMUX_V1_PCR_TCLKDIR
| /* clock is output */
56 IMX_AUDMUX_V1_PCR_RXDSEL(3));
57 imx_audmux_v1_configure_port(3,
58 IMX_AUDMUX_V1_PCR_SYN
| /* 4wire mode */
59 IMX_AUDMUX_V1_PCR_TFCSEL(0) |
60 IMX_AUDMUX_V1_PCR_TFSDIR
|
61 IMX_AUDMUX_V1_PCR_RXDSEL(0));
62 } else if (machine_is_pcm043()) {
63 imx_audmux_v2_configure_port(3,
64 IMX_AUDMUX_V2_PTCR_SYN
| /* 4wire mode */
65 IMX_AUDMUX_V2_PTCR_TFSEL(0) |
66 IMX_AUDMUX_V2_PTCR_TFSDIR
,
67 IMX_AUDMUX_V2_PDCR_RXDSEL(0));
68 imx_audmux_v2_configure_port(0,
69 IMX_AUDMUX_V2_PTCR_SYN
| /* 4wire mode */
70 IMX_AUDMUX_V2_PTCR_TCSEL(3) |
71 IMX_AUDMUX_V2_PTCR_TCLKDIR
, /* clock is output */
72 IMX_AUDMUX_V2_PDCR_RXDSEL(3));
74 /* return happy. We might run on a totally different machine */
78 imx_phycore_snd_ac97_device
= platform_device_alloc("soc-audio", -1);
79 if (!imx_phycore_snd_ac97_device
)
82 platform_set_drvdata(imx_phycore_snd_ac97_device
, &imx_phycore
);
83 ret
= platform_device_add(imx_phycore_snd_ac97_device
);
87 imx_phycore_snd_device
= platform_device_alloc("wm9712-codec", -1);
88 if (!imx_phycore_snd_device
) {
92 ret
= platform_device_add(imx_phycore_snd_device
);
95 printk(KERN_ERR
"ASoC: Platform device allocation failed\n");
102 platform_device_put(imx_phycore_snd_device
);
104 platform_device_del(imx_phycore_snd_ac97_device
);
106 platform_device_put(imx_phycore_snd_ac97_device
);
110 static void __exit
imx_phycore_exit(void)
112 platform_device_unregister(imx_phycore_snd_device
);
113 platform_device_unregister(imx_phycore_snd_ac97_device
);
116 late_initcall(imx_phycore_init
);
117 module_exit(imx_phycore_exit
);
119 MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de>");
120 MODULE_DESCRIPTION("PhyCORE ALSA SoC driver");
121 MODULE_LICENSE("GPL");