2010-02-10 17:42:33 +07:00
|
|
|
/*
|
|
|
|
* phycore-ac97.c -- SoC audio for imx_phycore in AC97 mode
|
|
|
|
*
|
|
|
|
* Copyright 2009 Sascha Hauer, Pengutronix <s.hauer@pengutronix.de>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation; either version 2 of the License, or (at your
|
|
|
|
* option) any later version.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/moduleparam.h>
|
|
|
|
#include <linux/device.h>
|
|
|
|
#include <linux/i2c.h>
|
|
|
|
#include <sound/core.h>
|
|
|
|
#include <sound/pcm.h>
|
|
|
|
#include <sound/soc.h>
|
|
|
|
#include <asm/mach-types.h>
|
2012-03-05 21:30:53 +07:00
|
|
|
|
|
|
|
#include "imx-audmux.h"
|
2010-02-10 17:42:33 +07:00
|
|
|
|
|
|
|
static struct snd_soc_card imx_phycore;
|
|
|
|
|
2017-03-14 02:12:22 +07:00
|
|
|
static const struct snd_soc_ops imx_phycore_hifi_ops = {
|
2010-02-10 17:42:33 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct snd_soc_dai_link imx_phycore_dai_ac97[] = {
|
|
|
|
{
|
|
|
|
.name = "HiFi",
|
|
|
|
.stream_name = "HiFi",
|
2010-03-18 03:15:21 +07:00
|
|
|
.codec_dai_name = "wm9712-hifi",
|
|
|
|
.codec_name = "wm9712-codec",
|
2010-10-01 03:46:14 +07:00
|
|
|
.cpu_dai_name = "imx-ssi.0",
|
2013-04-25 10:18:49 +07:00
|
|
|
.platform_name = "imx-ssi.0",
|
2010-02-10 17:42:33 +07:00
|
|
|
.ops = &imx_phycore_hifi_ops,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct snd_soc_card imx_phycore = {
|
2010-11-04 23:05:44 +07:00
|
|
|
.name = "PhyCORE-ac97-audio",
|
2011-12-23 13:47:08 +07:00
|
|
|
.owner = THIS_MODULE,
|
2010-02-10 17:42:33 +07:00
|
|
|
.dai_link = imx_phycore_dai_ac97,
|
|
|
|
.num_links = ARRAY_SIZE(imx_phycore_dai_ac97),
|
|
|
|
};
|
|
|
|
|
2010-11-25 14:14:03 +07:00
|
|
|
static struct platform_device *imx_phycore_snd_ac97_device;
|
2010-02-10 17:42:33 +07:00
|
|
|
static struct platform_device *imx_phycore_snd_device;
|
|
|
|
|
|
|
|
static int __init imx_phycore_init(void)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
2012-03-05 21:30:50 +07:00
|
|
|
if (machine_is_pca100()) {
|
2012-03-05 21:30:54 +07:00
|
|
|
imx_audmux_v1_configure_port(MX27_AUDMUX_HPCR1_SSI0,
|
|
|
|
IMX_AUDMUX_V1_PCR_SYN | /* 4wire mode */
|
|
|
|
IMX_AUDMUX_V1_PCR_TFCSEL(3) |
|
|
|
|
IMX_AUDMUX_V1_PCR_TCLKDIR | /* clock is output */
|
|
|
|
IMX_AUDMUX_V1_PCR_RXDSEL(3));
|
|
|
|
imx_audmux_v1_configure_port(3,
|
|
|
|
IMX_AUDMUX_V1_PCR_SYN | /* 4wire mode */
|
|
|
|
IMX_AUDMUX_V1_PCR_TFCSEL(0) |
|
|
|
|
IMX_AUDMUX_V1_PCR_TFSDIR |
|
|
|
|
IMX_AUDMUX_V1_PCR_RXDSEL(0));
|
2012-03-05 21:30:50 +07:00
|
|
|
} else if (machine_is_pcm043()) {
|
2012-03-05 21:30:54 +07:00
|
|
|
imx_audmux_v2_configure_port(3,
|
|
|
|
IMX_AUDMUX_V2_PTCR_SYN | /* 4wire mode */
|
|
|
|
IMX_AUDMUX_V2_PTCR_TFSEL(0) |
|
|
|
|
IMX_AUDMUX_V2_PTCR_TFSDIR,
|
|
|
|
IMX_AUDMUX_V2_PDCR_RXDSEL(0));
|
|
|
|
imx_audmux_v2_configure_port(0,
|
|
|
|
IMX_AUDMUX_V2_PTCR_SYN | /* 4wire mode */
|
|
|
|
IMX_AUDMUX_V2_PTCR_TCSEL(3) |
|
|
|
|
IMX_AUDMUX_V2_PTCR_TCLKDIR, /* clock is output */
|
|
|
|
IMX_AUDMUX_V2_PDCR_RXDSEL(3));
|
2012-03-05 21:30:50 +07:00
|
|
|
} else {
|
2010-02-10 17:42:33 +07:00
|
|
|
/* return happy. We might run on a totally different machine */
|
|
|
|
return 0;
|
2012-03-05 21:30:50 +07:00
|
|
|
}
|
2010-02-10 17:42:33 +07:00
|
|
|
|
2010-11-25 14:14:03 +07:00
|
|
|
imx_phycore_snd_ac97_device = platform_device_alloc("soc-audio", -1);
|
|
|
|
if (!imx_phycore_snd_ac97_device)
|
2010-02-10 17:42:33 +07:00
|
|
|
return -ENOMEM;
|
|
|
|
|
2010-11-25 14:14:03 +07:00
|
|
|
platform_set_drvdata(imx_phycore_snd_ac97_device, &imx_phycore);
|
|
|
|
ret = platform_device_add(imx_phycore_snd_ac97_device);
|
|
|
|
if (ret)
|
|
|
|
goto fail1;
|
2010-02-10 17:42:33 +07:00
|
|
|
|
2010-03-18 03:15:21 +07:00
|
|
|
imx_phycore_snd_device = platform_device_alloc("wm9712-codec", -1);
|
2010-11-25 14:14:03 +07:00
|
|
|
if (!imx_phycore_snd_device) {
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto fail2;
|
|
|
|
}
|
2010-02-10 17:42:33 +07:00
|
|
|
ret = platform_device_add(imx_phycore_snd_device);
|
|
|
|
|
|
|
|
if (ret) {
|
|
|
|
printk(KERN_ERR "ASoC: Platform device allocation failed\n");
|
2010-11-25 14:14:03 +07:00
|
|
|
goto fail3;
|
2010-02-10 17:42:33 +07:00
|
|
|
}
|
|
|
|
|
2010-11-25 14:14:03 +07:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
fail3:
|
|
|
|
platform_device_put(imx_phycore_snd_device);
|
|
|
|
fail2:
|
|
|
|
platform_device_del(imx_phycore_snd_ac97_device);
|
|
|
|
fail1:
|
|
|
|
platform_device_put(imx_phycore_snd_ac97_device);
|
2010-02-10 17:42:33 +07:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit imx_phycore_exit(void)
|
|
|
|
{
|
|
|
|
platform_device_unregister(imx_phycore_snd_device);
|
2010-11-25 14:14:03 +07:00
|
|
|
platform_device_unregister(imx_phycore_snd_ac97_device);
|
2010-02-10 17:42:33 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
late_initcall(imx_phycore_init);
|
|
|
|
module_exit(imx_phycore_exit);
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de>");
|
|
|
|
MODULE_DESCRIPTION("PhyCORE ALSA SoC driver");
|
|
|
|
MODULE_LICENSE("GPL");
|