blob: a59692e740b4558468280708228b6165422e7924 [file] [log] [blame]
Mark Brown22313ea2010-02-10 10:42:33 +00001/*
2 * phycore-ac97.c -- SoC audio for imx_phycore in AC97 mode
3 *
4 * Copyright 2009 Sascha Hauer, Pengutronix <s.hauer@pengutronix.de>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 *
11 */
12
13#include <linux/module.h>
14#include <linux/moduleparam.h>
15#include <linux/device.h>
16#include <linux/i2c.h>
17#include <sound/core.h>
18#include <sound/pcm.h>
19#include <sound/soc.h>
Mark Brown22313ea2010-02-10 10:42:33 +000020#include <asm/mach-types.h>
Shawn Guo17ec38a2012-03-05 22:30:50 +080021#include <mach/audmux.h>
Mark Brown22313ea2010-02-10 10:42:33 +000022
Mark Brown22313ea2010-02-10 10:42:33 +000023static struct snd_soc_card imx_phycore;
24
25static struct snd_soc_ops imx_phycore_hifi_ops = {
26};
27
28static struct snd_soc_dai_link imx_phycore_dai_ac97[] = {
29 {
30 .name = "HiFi",
31 .stream_name = "HiFi",
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000032 .codec_dai_name = "wm9712-hifi",
33 .codec_name = "wm9712-codec",
Mark Brown205d2312010-09-30 13:46:14 -070034 .cpu_dai_name = "imx-ssi.0",
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000035 .platform_name = "imx-fiq-pcm-audio.0",
Mark Brown22313ea2010-02-10 10:42:33 +000036 .ops = &imx_phycore_hifi_ops,
37 },
38};
39
40static struct snd_soc_card imx_phycore = {
Sascha Hauer6424dca2010-11-04 17:05:44 +010041 .name = "PhyCORE-ac97-audio",
Axel Lin6aff8cc2011-12-23 14:47:08 +080042 .owner = THIS_MODULE,
Mark Brown22313ea2010-02-10 10:42:33 +000043 .dai_link = imx_phycore_dai_ac97,
44 .num_links = ARRAY_SIZE(imx_phycore_dai_ac97),
45};
46
Axel Lin09de9532010-11-25 15:14:03 +080047static struct platform_device *imx_phycore_snd_ac97_device;
Mark Brown22313ea2010-02-10 10:42:33 +000048static struct platform_device *imx_phycore_snd_device;
49
50static int __init imx_phycore_init(void)
51{
52 int ret;
53
Shawn Guo17ec38a2012-03-05 22:30:50 +080054 if (machine_is_pca100()) {
55 mxc_audmux_v1_configure_port(MX27_AUDMUX_HPCR1_SSI0,
56 MXC_AUDMUX_V1_PCR_SYN | /* 4wire mode */
57 MXC_AUDMUX_V1_PCR_TFCSEL(3) |
58 MXC_AUDMUX_V1_PCR_TCLKDIR | /* clock is output */
59 MXC_AUDMUX_V1_PCR_RXDSEL(3));
60 mxc_audmux_v1_configure_port(3,
61 MXC_AUDMUX_V1_PCR_SYN | /* 4wire mode */
62 MXC_AUDMUX_V1_PCR_TFCSEL(0) |
63 MXC_AUDMUX_V1_PCR_TFSDIR |
64 MXC_AUDMUX_V1_PCR_RXDSEL(0));
65 } else if (machine_is_pcm043()) {
66 mxc_audmux_v2_configure_port(3,
67 MXC_AUDMUX_V2_PTCR_SYN | /* 4wire mode */
68 MXC_AUDMUX_V2_PTCR_TFSEL(0) |
69 MXC_AUDMUX_V2_PTCR_TFSDIR,
70 MXC_AUDMUX_V2_PDCR_RXDSEL(0));
71 mxc_audmux_v2_configure_port(0,
72 MXC_AUDMUX_V2_PTCR_SYN | /* 4wire mode */
73 MXC_AUDMUX_V2_PTCR_TCSEL(3) |
74 MXC_AUDMUX_V2_PTCR_TCLKDIR, /* clock is output */
75 MXC_AUDMUX_V2_PDCR_RXDSEL(3));
76 } else {
Mark Brown22313ea2010-02-10 10:42:33 +000077 /* return happy. We might run on a totally different machine */
78 return 0;
Shawn Guo17ec38a2012-03-05 22:30:50 +080079 }
Mark Brown22313ea2010-02-10 10:42:33 +000080
Axel Lin09de9532010-11-25 15:14:03 +080081 imx_phycore_snd_ac97_device = platform_device_alloc("soc-audio", -1);
82 if (!imx_phycore_snd_ac97_device)
Mark Brown22313ea2010-02-10 10:42:33 +000083 return -ENOMEM;
84
Axel Lin09de9532010-11-25 15:14:03 +080085 platform_set_drvdata(imx_phycore_snd_ac97_device, &imx_phycore);
86 ret = platform_device_add(imx_phycore_snd_ac97_device);
87 if (ret)
88 goto fail1;
Mark Brown22313ea2010-02-10 10:42:33 +000089
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000090 imx_phycore_snd_device = platform_device_alloc("wm9712-codec", -1);
Axel Lin09de9532010-11-25 15:14:03 +080091 if (!imx_phycore_snd_device) {
92 ret = -ENOMEM;
93 goto fail2;
94 }
Mark Brown22313ea2010-02-10 10:42:33 +000095 ret = platform_device_add(imx_phycore_snd_device);
96
97 if (ret) {
98 printk(KERN_ERR "ASoC: Platform device allocation failed\n");
Axel Lin09de9532010-11-25 15:14:03 +080099 goto fail3;
Mark Brown22313ea2010-02-10 10:42:33 +0000100 }
101
Axel Lin09de9532010-11-25 15:14:03 +0800102 return 0;
103
104fail3:
105 platform_device_put(imx_phycore_snd_device);
106fail2:
107 platform_device_del(imx_phycore_snd_ac97_device);
108fail1:
109 platform_device_put(imx_phycore_snd_ac97_device);
Mark Brown22313ea2010-02-10 10:42:33 +0000110 return ret;
111}
112
113static void __exit imx_phycore_exit(void)
114{
115 platform_device_unregister(imx_phycore_snd_device);
Axel Lin09de9532010-11-25 15:14:03 +0800116 platform_device_unregister(imx_phycore_snd_ac97_device);
Mark Brown22313ea2010-02-10 10:42:33 +0000117}
118
119late_initcall(imx_phycore_init);
120module_exit(imx_phycore_exit);
121
122MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de>");
123MODULE_DESCRIPTION("PhyCORE ALSA SoC driver");
124MODULE_LICENSE("GPL");