2009-05-26 20:34:12 +08:00
|
|
|
/*
|
|
|
|
* Phytec pcm030 driver for the PSC of the Freescale MPC52xx
|
|
|
|
* configured as AC97 interface
|
|
|
|
*
|
|
|
|
* Copyright 2008 Jon Smirl, Digispeaker
|
|
|
|
* Author: Jon Smirl <jonsmirl@gmail.com>
|
|
|
|
*
|
|
|
|
* This file is licensed under the terms of the GNU General Public License
|
|
|
|
* version 2. This program is licensed "as is" without any warranty of any
|
|
|
|
* kind, whether express or implied.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/device.h>
|
|
|
|
#include <linux/of_device.h>
|
|
|
|
#include <linux/of_platform.h>
|
|
|
|
|
|
|
|
#include <sound/soc.h>
|
|
|
|
|
|
|
|
#include "mpc5200_dma.h"
|
|
|
|
|
2009-08-07 22:33:53 +08:00
|
|
|
#define DRV_NAME "pcm030-audio-fabric"
|
|
|
|
|
2012-09-20 22:36:45 +08:00
|
|
|
struct pcm030_audio_data {
|
|
|
|
struct snd_soc_card *card;
|
|
|
|
struct platform_device *codec_device;
|
|
|
|
};
|
|
|
|
|
2009-05-26 20:34:12 +08:00
|
|
|
static struct snd_soc_dai_link pcm030_fabric_dai[] = {
|
|
|
|
{
|
2012-10-10 22:10:08 +08:00
|
|
|
.name = "AC97.0",
|
2009-05-26 20:34:12 +08:00
|
|
|
.stream_name = "AC97 Analog",
|
2010-03-18 04:15:21 +08:00
|
|
|
.codec_dai_name = "wm9712-hifi",
|
|
|
|
.cpu_dai_name = "mpc5200-psc-ac97.0",
|
|
|
|
.codec_name = "wm9712-codec",
|
2009-05-26 20:34:12 +08:00
|
|
|
},
|
|
|
|
{
|
2012-10-10 22:10:08 +08:00
|
|
|
.name = "AC97.1",
|
2009-05-26 20:34:12 +08:00
|
|
|
.stream_name = "AC97 IEC958",
|
2010-03-18 04:15:21 +08:00
|
|
|
.codec_dai_name = "wm9712-aux",
|
|
|
|
.cpu_dai_name = "mpc5200-psc-ac97.1",
|
2010-10-27 03:07:43 +08:00
|
|
|
.codec_name = "wm9712-codec",
|
2009-05-26 20:34:12 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2012-09-20 22:36:44 +08:00
|
|
|
static struct snd_soc_card pcm030_card = {
|
2011-12-22 21:04:54 +08:00
|
|
|
.name = "pcm030",
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.dai_link = pcm030_fabric_dai,
|
|
|
|
.num_links = ARRAY_SIZE(pcm030_fabric_dai),
|
|
|
|
};
|
|
|
|
|
2013-03-11 02:33:06 +08:00
|
|
|
static int pcm030_fabric_probe(struct platform_device *op)
|
2009-05-26 20:34:12 +08:00
|
|
|
{
|
2012-09-20 22:36:44 +08:00
|
|
|
struct device_node *np = op->dev.of_node;
|
|
|
|
struct device_node *platform_np;
|
|
|
|
struct snd_soc_card *card = &pcm030_card;
|
2012-09-20 22:36:45 +08:00
|
|
|
struct pcm030_audio_data *pdata;
|
2018-09-18 09:28:49 +08:00
|
|
|
struct snd_soc_dai_link *dai_link;
|
2012-09-20 22:36:44 +08:00
|
|
|
int ret;
|
|
|
|
int i;
|
2009-05-26 20:34:12 +08:00
|
|
|
|
2010-02-02 12:34:14 +08:00
|
|
|
if (!of_machine_is_compatible("phytec,pcm030"))
|
2009-05-26 20:34:12 +08:00
|
|
|
return -ENODEV;
|
|
|
|
|
2012-09-20 22:36:45 +08:00
|
|
|
pdata = devm_kzalloc(&op->dev, sizeof(struct pcm030_audio_data),
|
|
|
|
GFP_KERNEL);
|
|
|
|
if (!pdata)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2012-09-20 22:36:44 +08:00
|
|
|
card->dev = &op->dev;
|
2012-09-20 22:36:45 +08:00
|
|
|
|
|
|
|
pdata->card = card;
|
2012-09-20 22:36:44 +08:00
|
|
|
|
|
|
|
platform_np = of_parse_phandle(np, "asoc-platform", 0);
|
|
|
|
if (!platform_np) {
|
|
|
|
dev_err(&op->dev, "ac97 not registered\n");
|
2009-05-26 20:34:12 +08:00
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
2018-09-18 09:28:49 +08:00
|
|
|
for_each_card_prelinks(card, i, dai_link)
|
|
|
|
dai_link->platform_of_node = platform_np;
|
2009-05-26 20:34:12 +08:00
|
|
|
|
2012-09-20 22:36:45 +08:00
|
|
|
ret = request_module("snd-soc-wm9712");
|
|
|
|
if (ret)
|
|
|
|
dev_err(&op->dev, "request_module returned: %d\n", ret);
|
|
|
|
|
|
|
|
pdata->codec_device = platform_device_alloc("wm9712-codec", -1);
|
|
|
|
if (!pdata->codec_device)
|
|
|
|
dev_err(&op->dev, "platform_device_alloc() failed\n");
|
|
|
|
|
|
|
|
ret = platform_device_add(pdata->codec_device);
|
|
|
|
if (ret)
|
|
|
|
dev_err(&op->dev, "platform_device_add() failed: %d\n", ret);
|
|
|
|
|
2012-09-20 22:36:44 +08:00
|
|
|
ret = snd_soc_register_card(card);
|
|
|
|
if (ret)
|
|
|
|
dev_err(&op->dev, "snd_soc_register_card() failed: %d\n", ret);
|
|
|
|
|
2013-11-09 08:41:14 +08:00
|
|
|
platform_set_drvdata(op, pdata);
|
|
|
|
|
2012-09-20 22:36:44 +08:00
|
|
|
return ret;
|
2009-05-26 20:34:12 +08:00
|
|
|
}
|
|
|
|
|
2012-12-07 22:26:16 +08:00
|
|
|
static int pcm030_fabric_remove(struct platform_device *op)
|
2012-09-20 22:36:44 +08:00
|
|
|
{
|
2012-09-20 22:36:45 +08:00
|
|
|
struct pcm030_audio_data *pdata = platform_get_drvdata(op);
|
2012-09-20 22:36:44 +08:00
|
|
|
int ret;
|
|
|
|
|
2012-09-20 22:36:45 +08:00
|
|
|
ret = snd_soc_unregister_card(pdata->card);
|
|
|
|
platform_device_unregister(pdata->codec_device);
|
2012-09-20 22:36:44 +08:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-03-19 00:48:57 +08:00
|
|
|
static const struct of_device_id pcm030_audio_match[] = {
|
2012-09-20 22:36:44 +08:00
|
|
|
{ .compatible = "phytec,pcm030-audio-fabric", },
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(of, pcm030_audio_match);
|
|
|
|
|
|
|
|
static struct platform_driver pcm030_fabric_driver = {
|
|
|
|
.probe = pcm030_fabric_probe,
|
2012-12-07 22:26:16 +08:00
|
|
|
.remove = pcm030_fabric_remove,
|
2012-09-20 22:36:44 +08:00
|
|
|
.driver = {
|
|
|
|
.name = DRV_NAME,
|
|
|
|
.of_match_table = pcm030_audio_match,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
module_platform_driver(pcm030_fabric_driver);
|
2009-05-26 20:34:12 +08:00
|
|
|
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Jon Smirl <jonsmirl@gmail.com>");
|
|
|
|
MODULE_DESCRIPTION(DRV_NAME ": mpc5200 pcm030 fabric driver");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
|