blob: ae403c29688f51605af5c2f29a72fe70e9ac00e0 [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 Guo3c77c292012-03-05 22:30:53 +080021
22#include "imx-audmux.h"
Mark Brown22313ea2010-02-10 10:42:33 +000023
Mark Brown22313ea2010-02-10 10:42:33 +000024static struct snd_soc_card imx_phycore;
25
26static struct snd_soc_ops imx_phycore_hifi_ops = {
27};
28
29static struct snd_soc_dai_link imx_phycore_dai_ac97[] = {
30 {
31 .name = "HiFi",
32 .stream_name = "HiFi",
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000033 .codec_dai_name = "wm9712-hifi",
34 .codec_name = "wm9712-codec",
Mark Brown205d2312010-09-30 13:46:14 -070035 .cpu_dai_name = "imx-ssi.0",
Shawn Guo2bf9d4b2013-04-25 11:18:49 +080036 .platform_name = "imx-ssi.0",
Mark Brown22313ea2010-02-10 10:42:33 +000037 .ops = &imx_phycore_hifi_ops,
38 },
39};
40
41static struct snd_soc_card imx_phycore = {
Sascha Hauer6424dca2010-11-04 17:05:44 +010042 .name = "PhyCORE-ac97-audio",
Axel Lin6aff8cc2011-12-23 14:47:08 +080043 .owner = THIS_MODULE,
Mark Brown22313ea2010-02-10 10:42:33 +000044 .dai_link = imx_phycore_dai_ac97,
45 .num_links = ARRAY_SIZE(imx_phycore_dai_ac97),
46};
47
Axel Lin09de9532010-11-25 15:14:03 +080048static struct platform_device *imx_phycore_snd_ac97_device;
Mark Brown22313ea2010-02-10 10:42:33 +000049static struct platform_device *imx_phycore_snd_device;
50
51static int __init imx_phycore_init(void)
52{
53 int ret;
54
Shawn Guo17ec38a2012-03-05 22:30:50 +080055 if (machine_is_pca100()) {
Shawn Guoaf4872f2012-03-05 22:30:54 +080056 imx_audmux_v1_configure_port(MX27_AUDMUX_HPCR1_SSI0,
57 IMX_AUDMUX_V1_PCR_SYN | /* 4wire mode */
58 IMX_AUDMUX_V1_PCR_TFCSEL(3) |
59 IMX_AUDMUX_V1_PCR_TCLKDIR | /* clock is output */
60 IMX_AUDMUX_V1_PCR_RXDSEL(3));
61 imx_audmux_v1_configure_port(3,
62 IMX_AUDMUX_V1_PCR_SYN | /* 4wire mode */
63 IMX_AUDMUX_V1_PCR_TFCSEL(0) |
64 IMX_AUDMUX_V1_PCR_TFSDIR |
65 IMX_AUDMUX_V1_PCR_RXDSEL(0));
Shawn Guo17ec38a2012-03-05 22:30:50 +080066 } else if (machine_is_pcm043()) {
Shawn Guoaf4872f2012-03-05 22:30:54 +080067 imx_audmux_v2_configure_port(3,
68 IMX_AUDMUX_V2_PTCR_SYN | /* 4wire mode */
69 IMX_AUDMUX_V2_PTCR_TFSEL(0) |
70 IMX_AUDMUX_V2_PTCR_TFSDIR,
71 IMX_AUDMUX_V2_PDCR_RXDSEL(0));
72 imx_audmux_v2_configure_port(0,
73 IMX_AUDMUX_V2_PTCR_SYN | /* 4wire mode */
74 IMX_AUDMUX_V2_PTCR_TCSEL(3) |
75 IMX_AUDMUX_V2_PTCR_TCLKDIR, /* clock is output */
76 IMX_AUDMUX_V2_PDCR_RXDSEL(3));
Shawn Guo17ec38a2012-03-05 22:30:50 +080077 } else {
Mark Brown22313ea2010-02-10 10:42:33 +000078 /* return happy. We might run on a totally different machine */
79 return 0;
Shawn Guo17ec38a2012-03-05 22:30:50 +080080 }
Mark Brown22313ea2010-02-10 10:42:33 +000081
Axel Lin09de9532010-11-25 15:14:03 +080082 imx_phycore_snd_ac97_device = platform_device_alloc("soc-audio", -1);
83 if (!imx_phycore_snd_ac97_device)
Mark Brown22313ea2010-02-10 10:42:33 +000084 return -ENOMEM;
85
Axel Lin09de9532010-11-25 15:14:03 +080086 platform_set_drvdata(imx_phycore_snd_ac97_device, &imx_phycore);
87 ret = platform_device_add(imx_phycore_snd_ac97_device);
88 if (ret)
89 goto fail1;
Mark Brown22313ea2010-02-10 10:42:33 +000090
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000091 imx_phycore_snd_device = platform_device_alloc("wm9712-codec", -1);
Axel Lin09de9532010-11-25 15:14:03 +080092 if (!imx_phycore_snd_device) {
93 ret = -ENOMEM;
94 goto fail2;
95 }
Mark Brown22313ea2010-02-10 10:42:33 +000096 ret = platform_device_add(imx_phycore_snd_device);
97
98 if (ret) {
99 printk(KERN_ERR "ASoC: Platform device allocation failed\n");
Axel Lin09de9532010-11-25 15:14:03 +0800100 goto fail3;
Mark Brown22313ea2010-02-10 10:42:33 +0000101 }
102
Axel Lin09de9532010-11-25 15:14:03 +0800103 return 0;
104
105fail3:
106 platform_device_put(imx_phycore_snd_device);
107fail2:
108 platform_device_del(imx_phycore_snd_ac97_device);
109fail1:
110 platform_device_put(imx_phycore_snd_ac97_device);
Mark Brown22313ea2010-02-10 10:42:33 +0000111 return ret;
112}
113
114static void __exit imx_phycore_exit(void)
115{
116 platform_device_unregister(imx_phycore_snd_device);
Axel Lin09de9532010-11-25 15:14:03 +0800117 platform_device_unregister(imx_phycore_snd_ac97_device);
Mark Brown22313ea2010-02-10 10:42:33 +0000118}
119
120late_initcall(imx_phycore_init);
121module_exit(imx_phycore_exit);
122
123MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de>");
124MODULE_DESCRIPTION("PhyCORE ALSA SoC driver");
125MODULE_LICENSE("GPL");