2008-01-12 01:15:26 +08:00
|
|
|
/**
|
2010-03-18 04:15:21 +08:00
|
|
|
* Freescale MPC8610HPCD ALSA SoC Machine driver
|
2008-01-12 01:15:26 +08:00
|
|
|
*
|
|
|
|
* Author: Timur Tabi <timur@freescale.com>
|
|
|
|
*
|
2010-03-18 04:15:21 +08:00
|
|
|
* Copyright 2007-2010 Freescale Semiconductor, Inc.
|
|
|
|
*
|
|
|
|
* 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.
|
2008-01-12 01:15:26 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/interrupt.h>
|
2015-09-20 12:29:53 +08:00
|
|
|
#include <linux/fsl/guts.h>
|
2013-09-18 03:28:33 +08:00
|
|
|
#include <linux/of_address.h>
|
2008-01-12 01:15:26 +08:00
|
|
|
#include <linux/of_device.h>
|
2010-08-20 04:26:58 +08:00
|
|
|
#include <linux/slab.h>
|
2008-01-12 01:15:26 +08:00
|
|
|
#include <sound/soc.h>
|
|
|
|
|
|
|
|
#include "fsl_dma.h"
|
|
|
|
#include "fsl_ssi.h"
|
2012-03-16 16:56:40 +08:00
|
|
|
#include "fsl_utils.h"
|
2008-01-12 01:15:26 +08:00
|
|
|
|
2010-03-18 04:15:21 +08:00
|
|
|
/* There's only one global utilities register */
|
|
|
|
static phys_addr_t guts_phys;
|
|
|
|
|
2008-01-12 01:15:26 +08:00
|
|
|
/**
|
2010-03-18 04:15:21 +08:00
|
|
|
* mpc8610_hpcd_data: machine-specific ASoC device data
|
2008-01-12 01:15:26 +08:00
|
|
|
*
|
|
|
|
* This structure contains data for a single sound platform device on an
|
|
|
|
* MPC8610 HPCD. Some of the data is taken from the device tree.
|
|
|
|
*/
|
|
|
|
struct mpc8610_hpcd_data {
|
2010-03-18 04:15:21 +08:00
|
|
|
struct snd_soc_dai_link dai[2];
|
|
|
|
struct snd_soc_card card;
|
2008-01-12 01:15:26 +08:00
|
|
|
unsigned int dai_format;
|
|
|
|
unsigned int codec_clk_direction;
|
|
|
|
unsigned int cpu_clk_direction;
|
|
|
|
unsigned int clk_frequency;
|
2010-03-18 04:15:21 +08:00
|
|
|
unsigned int ssi_id; /* 0 = SSI1, 1 = SSI2, etc */
|
|
|
|
unsigned int dma_id[2]; /* 0 = DMA1, 1 = DMA2, etc */
|
2008-01-12 01:15:26 +08:00
|
|
|
unsigned int dma_channel_id[2]; /* 0 = ch 0, 1 = ch 1, etc*/
|
2010-03-18 04:15:21 +08:00
|
|
|
char codec_dai_name[DAI_NAME_SIZE];
|
|
|
|
char platform_name[2][DAI_NAME_SIZE]; /* One for each DMA channel */
|
2008-01-12 01:15:26 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2010-03-18 04:15:21 +08:00
|
|
|
* mpc8610_hpcd_machine_probe: initialize the board
|
2008-01-12 01:15:26 +08:00
|
|
|
*
|
2010-03-18 04:15:21 +08:00
|
|
|
* This function is used to initialize the board-specific hardware.
|
2008-01-12 01:15:26 +08:00
|
|
|
*
|
|
|
|
* Here we program the DMACR and PMUXCR registers.
|
|
|
|
*/
|
2011-01-26 22:17:20 +08:00
|
|
|
static int mpc8610_hpcd_machine_probe(struct snd_soc_card *card)
|
2008-01-12 01:15:26 +08:00
|
|
|
{
|
|
|
|
struct mpc8610_hpcd_data *machine_data =
|
2010-03-18 04:15:21 +08:00
|
|
|
container_of(card, struct mpc8610_hpcd_data, card);
|
2012-03-20 00:06:39 +08:00
|
|
|
struct ccsr_guts __iomem *guts;
|
2008-01-12 01:15:26 +08:00
|
|
|
|
2012-03-20 00:06:39 +08:00
|
|
|
guts = ioremap(guts_phys, sizeof(struct ccsr_guts));
|
2010-03-18 04:15:21 +08:00
|
|
|
if (!guts) {
|
|
|
|
dev_err(card->dev, "could not map global utilities\n");
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
2008-01-12 01:15:26 +08:00
|
|
|
|
2010-03-18 04:15:21 +08:00
|
|
|
/* Program the signal routing between the SSI and the DMA */
|
|
|
|
guts_set_dmacr(guts, machine_data->dma_id[0],
|
|
|
|
machine_data->dma_channel_id[0],
|
|
|
|
CCSR_GUTS_DMACR_DEV_SSI);
|
|
|
|
guts_set_dmacr(guts, machine_data->dma_id[1],
|
|
|
|
machine_data->dma_channel_id[1],
|
|
|
|
CCSR_GUTS_DMACR_DEV_SSI);
|
|
|
|
|
|
|
|
guts_set_pmuxcr_dma(guts, machine_data->dma_id[0],
|
|
|
|
machine_data->dma_channel_id[0], 0);
|
|
|
|
guts_set_pmuxcr_dma(guts, machine_data->dma_id[1],
|
|
|
|
machine_data->dma_channel_id[1], 0);
|
2008-01-12 01:15:26 +08:00
|
|
|
|
|
|
|
switch (machine_data->ssi_id) {
|
|
|
|
case 0:
|
2010-03-18 04:15:21 +08:00
|
|
|
clrsetbits_be32(&guts->pmuxcr,
|
2008-01-12 01:15:26 +08:00
|
|
|
CCSR_GUTS_PMUXCR_SSI1_MASK, CCSR_GUTS_PMUXCR_SSI1_SSI);
|
|
|
|
break;
|
|
|
|
case 1:
|
2010-03-18 04:15:21 +08:00
|
|
|
clrsetbits_be32(&guts->pmuxcr,
|
2008-01-12 01:15:26 +08:00
|
|
|
CCSR_GUTS_PMUXCR_SSI2_MASK, CCSR_GUTS_PMUXCR_SSI2_SSI);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-03-18 04:15:21 +08:00
|
|
|
iounmap(guts);
|
|
|
|
|
2008-01-12 01:15:26 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* mpc8610_hpcd_startup: program the board with various hardware parameters
|
|
|
|
*
|
|
|
|
* This function takes board-specific information, like clock frequencies
|
|
|
|
* and serial data formats, and passes that information to the codec and
|
|
|
|
* transport drivers.
|
|
|
|
*/
|
|
|
|
static int mpc8610_hpcd_startup(struct snd_pcm_substream *substream)
|
|
|
|
{
|
|
|
|
struct snd_soc_pcm_runtime *rtd = substream->private_data;
|
|
|
|
struct mpc8610_hpcd_data *machine_data =
|
2010-03-18 04:15:21 +08:00
|
|
|
container_of(rtd->card, struct mpc8610_hpcd_data, card);
|
|
|
|
struct device *dev = rtd->card->dev;
|
2008-01-12 01:15:26 +08:00
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
/* Tell the codec driver what the serial protocol is. */
|
2010-03-18 04:15:21 +08:00
|
|
|
ret = snd_soc_dai_set_fmt(rtd->codec_dai, machine_data->dai_format);
|
2008-07-08 20:19:18 +08:00
|
|
|
if (ret < 0) {
|
2010-03-18 04:15:21 +08:00
|
|
|
dev_err(dev, "could not set codec driver audio format\n");
|
2008-07-08 20:19:18 +08:00
|
|
|
return ret;
|
2008-01-12 01:15:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Tell the codec driver what the MCLK frequency is, and whether it's
|
|
|
|
* a slave or master.
|
|
|
|
*/
|
2010-03-18 04:15:21 +08:00
|
|
|
ret = snd_soc_dai_set_sysclk(rtd->codec_dai, 0,
|
|
|
|
machine_data->clk_frequency,
|
|
|
|
machine_data->codec_clk_direction);
|
2008-07-08 20:19:18 +08:00
|
|
|
if (ret < 0) {
|
2010-03-18 04:15:21 +08:00
|
|
|
dev_err(dev, "could not set codec driver clock params\n");
|
2008-07-08 20:19:18 +08:00
|
|
|
return ret;
|
2008-01-12 01:15:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* mpc8610_hpcd_machine_remove: Remove the sound device
|
|
|
|
*
|
|
|
|
* This function is called to remove the sound device for one SSI. We
|
|
|
|
* de-program the DMACR and PMUXCR register.
|
|
|
|
*/
|
2011-01-26 22:17:20 +08:00
|
|
|
static int mpc8610_hpcd_machine_remove(struct snd_soc_card *card)
|
2008-01-12 01:15:26 +08:00
|
|
|
{
|
|
|
|
struct mpc8610_hpcd_data *machine_data =
|
2010-03-18 04:15:21 +08:00
|
|
|
container_of(card, struct mpc8610_hpcd_data, card);
|
2012-03-20 00:06:39 +08:00
|
|
|
struct ccsr_guts __iomem *guts;
|
2010-03-18 04:15:21 +08:00
|
|
|
|
2012-03-20 00:06:39 +08:00
|
|
|
guts = ioremap(guts_phys, sizeof(struct ccsr_guts));
|
2010-03-18 04:15:21 +08:00
|
|
|
if (!guts) {
|
|
|
|
dev_err(card->dev, "could not map global utilities\n");
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
2008-01-12 01:15:26 +08:00
|
|
|
|
|
|
|
/* Restore the signal routing */
|
|
|
|
|
2010-03-18 04:15:21 +08:00
|
|
|
guts_set_dmacr(guts, machine_data->dma_id[0],
|
|
|
|
machine_data->dma_channel_id[0], 0);
|
|
|
|
guts_set_dmacr(guts, machine_data->dma_id[1],
|
|
|
|
machine_data->dma_channel_id[1], 0);
|
2008-01-12 01:15:26 +08:00
|
|
|
|
|
|
|
switch (machine_data->ssi_id) {
|
|
|
|
case 0:
|
2010-03-18 04:15:21 +08:00
|
|
|
clrsetbits_be32(&guts->pmuxcr,
|
2008-01-12 01:15:26 +08:00
|
|
|
CCSR_GUTS_PMUXCR_SSI1_MASK, CCSR_GUTS_PMUXCR_SSI1_LA);
|
|
|
|
break;
|
|
|
|
case 1:
|
2010-03-18 04:15:21 +08:00
|
|
|
clrsetbits_be32(&guts->pmuxcr,
|
2008-06-14 03:02:31 +08:00
|
|
|
CCSR_GUTS_PMUXCR_SSI2_MASK, CCSR_GUTS_PMUXCR_SSI2_LA);
|
2008-01-12 01:15:26 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-03-18 04:15:21 +08:00
|
|
|
iounmap(guts);
|
|
|
|
|
2008-01-12 01:15:26 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-03-18 04:15:21 +08:00
|
|
|
* mpc8610_hpcd_ops: ASoC machine driver operations
|
2008-01-12 01:15:26 +08:00
|
|
|
*/
|
2017-03-14 03:12:22 +08:00
|
|
|
static const struct snd_soc_ops mpc8610_hpcd_ops = {
|
2008-01-12 01:15:26 +08:00
|
|
|
.startup = mpc8610_hpcd_startup,
|
|
|
|
};
|
|
|
|
|
2010-03-18 04:15:21 +08:00
|
|
|
/**
|
|
|
|
* mpc8610_hpcd_probe: platform probe function for the machine driver
|
|
|
|
*
|
|
|
|
* Although this is a machine driver, the SSI node is the "master" node with
|
|
|
|
* respect to audio hardware connections. Therefore, we create a new ASoC
|
|
|
|
* device for each new SSI node that has a codec attached.
|
|
|
|
*/
|
|
|
|
static int mpc8610_hpcd_probe(struct platform_device *pdev)
|
|
|
|
{
|
|
|
|
struct device *dev = pdev->dev.parent;
|
2010-08-20 04:26:58 +08:00
|
|
|
/* ssi_pdev is the platform device for the SSI node that probed us */
|
2015-12-23 21:03:39 +08:00
|
|
|
struct platform_device *ssi_pdev = to_platform_device(dev);
|
2010-08-20 04:26:58 +08:00
|
|
|
struct device_node *np = ssi_pdev->dev.of_node;
|
2010-03-18 04:15:21 +08:00
|
|
|
struct device_node *codec_np = NULL;
|
2008-01-12 01:15:26 +08:00
|
|
|
struct mpc8610_hpcd_data *machine_data;
|
|
|
|
int ret = -ENODEV;
|
2010-03-18 04:15:21 +08:00
|
|
|
const char *sprop;
|
|
|
|
const u32 *iprop;
|
|
|
|
|
2012-02-24 22:09:37 +08:00
|
|
|
/* Find the codec node for this SSI. */
|
|
|
|
codec_np = of_parse_phandle(np, "codec-handle", 0);
|
2010-03-18 04:15:21 +08:00
|
|
|
if (!codec_np) {
|
|
|
|
dev_err(dev, "invalid codec node\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
2008-01-12 01:15:26 +08:00
|
|
|
|
|
|
|
machine_data = kzalloc(sizeof(struct mpc8610_hpcd_data), GFP_KERNEL);
|
2011-08-20 15:02:01 +08:00
|
|
|
if (!machine_data) {
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto error_alloc;
|
|
|
|
}
|
2008-01-12 01:15:26 +08:00
|
|
|
|
2010-08-20 04:26:58 +08:00
|
|
|
machine_data->dai[0].cpu_dai_name = dev_name(&ssi_pdev->dev);
|
2010-03-18 04:15:21 +08:00
|
|
|
machine_data->dai[0].ops = &mpc8610_hpcd_ops;
|
2008-01-12 01:15:26 +08:00
|
|
|
|
2012-03-16 16:56:41 +08:00
|
|
|
/* ASoC core can match codec with device node */
|
|
|
|
machine_data->dai[0].codec_of_node = codec_np;
|
2008-01-12 01:15:26 +08:00
|
|
|
|
2010-03-18 04:15:21 +08:00
|
|
|
/* The DAI name from the codec (snd_soc_dai_driver.name) */
|
|
|
|
machine_data->dai[0].codec_dai_name = "cs4270-hifi";
|
2008-01-12 01:15:26 +08:00
|
|
|
|
2010-03-18 04:15:21 +08:00
|
|
|
/* We register two DAIs per SSI, one for playback and the other for
|
|
|
|
* capture. Currently, we only support codecs that have one DAI for
|
|
|
|
* both playback and capture.
|
|
|
|
*/
|
|
|
|
memcpy(&machine_data->dai[1], &machine_data->dai[0],
|
|
|
|
sizeof(struct snd_soc_dai_link));
|
2008-01-12 01:15:26 +08:00
|
|
|
|
|
|
|
/* Get the device ID */
|
|
|
|
iprop = of_get_property(np, "cell-index", NULL);
|
|
|
|
if (!iprop) {
|
2010-03-18 04:15:21 +08:00
|
|
|
dev_err(&pdev->dev, "cell-index property not found\n");
|
2008-01-12 01:15:26 +08:00
|
|
|
ret = -EINVAL;
|
|
|
|
goto error;
|
|
|
|
}
|
2011-06-09 04:02:55 +08:00
|
|
|
machine_data->ssi_id = be32_to_cpup(iprop);
|
2008-01-12 01:15:26 +08:00
|
|
|
|
|
|
|
/* Get the serial format and clock direction. */
|
|
|
|
sprop = of_get_property(np, "fsl,mode", NULL);
|
|
|
|
if (!sprop) {
|
2010-03-18 04:15:21 +08:00
|
|
|
dev_err(&pdev->dev, "fsl,mode property not found\n");
|
2008-01-12 01:15:26 +08:00
|
|
|
ret = -EINVAL;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strcasecmp(sprop, "i2s-slave") == 0) {
|
2011-11-23 04:38:59 +08:00
|
|
|
machine_data->dai_format =
|
|
|
|
SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBM_CFM;
|
2008-01-12 01:15:26 +08:00
|
|
|
machine_data->codec_clk_direction = SND_SOC_CLOCK_OUT;
|
|
|
|
machine_data->cpu_clk_direction = SND_SOC_CLOCK_IN;
|
|
|
|
|
2010-03-18 04:15:21 +08:00
|
|
|
/* In i2s-slave mode, the codec has its own clock source, so we
|
2008-01-12 01:15:26 +08:00
|
|
|
* need to get the frequency from the device tree and pass it to
|
|
|
|
* the codec driver.
|
|
|
|
*/
|
|
|
|
iprop = of_get_property(codec_np, "clock-frequency", NULL);
|
|
|
|
if (!iprop || !*iprop) {
|
2010-03-18 04:15:21 +08:00
|
|
|
dev_err(&pdev->dev, "codec bus-frequency "
|
|
|
|
"property is missing or invalid\n");
|
2008-01-12 01:15:26 +08:00
|
|
|
ret = -EINVAL;
|
|
|
|
goto error;
|
|
|
|
}
|
2011-06-09 04:02:55 +08:00
|
|
|
machine_data->clk_frequency = be32_to_cpup(iprop);
|
2008-01-12 01:15:26 +08:00
|
|
|
} else if (strcasecmp(sprop, "i2s-master") == 0) {
|
2011-11-23 04:38:59 +08:00
|
|
|
machine_data->dai_format =
|
|
|
|
SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS;
|
2008-01-12 01:15:26 +08:00
|
|
|
machine_data->codec_clk_direction = SND_SOC_CLOCK_IN;
|
|
|
|
machine_data->cpu_clk_direction = SND_SOC_CLOCK_OUT;
|
|
|
|
} else if (strcasecmp(sprop, "lj-slave") == 0) {
|
2011-11-23 04:38:59 +08:00
|
|
|
machine_data->dai_format =
|
|
|
|
SND_SOC_DAIFMT_LEFT_J | SND_SOC_DAIFMT_CBM_CFM;
|
2008-01-12 01:15:26 +08:00
|
|
|
machine_data->codec_clk_direction = SND_SOC_CLOCK_OUT;
|
|
|
|
machine_data->cpu_clk_direction = SND_SOC_CLOCK_IN;
|
|
|
|
} else if (strcasecmp(sprop, "lj-master") == 0) {
|
2011-11-23 04:38:59 +08:00
|
|
|
machine_data->dai_format =
|
|
|
|
SND_SOC_DAIFMT_LEFT_J | SND_SOC_DAIFMT_CBS_CFS;
|
2008-01-12 01:15:26 +08:00
|
|
|
machine_data->codec_clk_direction = SND_SOC_CLOCK_IN;
|
|
|
|
machine_data->cpu_clk_direction = SND_SOC_CLOCK_OUT;
|
2008-02-23 01:41:41 +08:00
|
|
|
} else if (strcasecmp(sprop, "rj-slave") == 0) {
|
2011-11-23 04:38:59 +08:00
|
|
|
machine_data->dai_format =
|
|
|
|
SND_SOC_DAIFMT_RIGHT_J | SND_SOC_DAIFMT_CBM_CFM;
|
2008-01-12 01:15:26 +08:00
|
|
|
machine_data->codec_clk_direction = SND_SOC_CLOCK_OUT;
|
|
|
|
machine_data->cpu_clk_direction = SND_SOC_CLOCK_IN;
|
|
|
|
} else if (strcasecmp(sprop, "rj-master") == 0) {
|
2011-11-23 04:38:59 +08:00
|
|
|
machine_data->dai_format =
|
|
|
|
SND_SOC_DAIFMT_RIGHT_J | SND_SOC_DAIFMT_CBS_CFS;
|
2008-01-12 01:15:26 +08:00
|
|
|
machine_data->codec_clk_direction = SND_SOC_CLOCK_IN;
|
|
|
|
machine_data->cpu_clk_direction = SND_SOC_CLOCK_OUT;
|
|
|
|
} else if (strcasecmp(sprop, "ac97-slave") == 0) {
|
2011-11-23 04:38:59 +08:00
|
|
|
machine_data->dai_format =
|
|
|
|
SND_SOC_DAIFMT_AC97 | SND_SOC_DAIFMT_CBM_CFM;
|
2008-01-12 01:15:26 +08:00
|
|
|
machine_data->codec_clk_direction = SND_SOC_CLOCK_OUT;
|
|
|
|
machine_data->cpu_clk_direction = SND_SOC_CLOCK_IN;
|
|
|
|
} else if (strcasecmp(sprop, "ac97-master") == 0) {
|
2011-11-23 04:38:59 +08:00
|
|
|
machine_data->dai_format =
|
|
|
|
SND_SOC_DAIFMT_AC97 | SND_SOC_DAIFMT_CBS_CFS;
|
2008-01-12 01:15:26 +08:00
|
|
|
machine_data->codec_clk_direction = SND_SOC_CLOCK_IN;
|
|
|
|
machine_data->cpu_clk_direction = SND_SOC_CLOCK_OUT;
|
|
|
|
} else {
|
2010-03-18 04:15:21 +08:00
|
|
|
dev_err(&pdev->dev,
|
|
|
|
"unrecognized fsl,mode property '%s'\n", sprop);
|
2008-01-12 01:15:26 +08:00
|
|
|
ret = -EINVAL;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!machine_data->clk_frequency) {
|
2010-03-18 04:15:21 +08:00
|
|
|
dev_err(&pdev->dev, "unknown clock frequency\n");
|
2008-01-12 01:15:26 +08:00
|
|
|
ret = -EINVAL;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
2010-03-18 04:15:21 +08:00
|
|
|
/* Find the playback DMA channel to use. */
|
|
|
|
machine_data->dai[0].platform_name = machine_data->platform_name[0];
|
2012-03-16 16:56:40 +08:00
|
|
|
ret = fsl_asoc_get_dma_channel(np, "fsl,playback-dma",
|
|
|
|
&machine_data->dai[0],
|
|
|
|
&machine_data->dma_channel_id[0],
|
|
|
|
&machine_data->dma_id[0]);
|
2008-01-12 01:15:26 +08:00
|
|
|
if (ret) {
|
2010-03-18 04:15:21 +08:00
|
|
|
dev_err(&pdev->dev, "missing/invalid playback DMA phandle\n");
|
2008-01-12 01:15:26 +08:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
2010-03-18 04:15:21 +08:00
|
|
|
/* Find the capture DMA channel to use. */
|
|
|
|
machine_data->dai[1].platform_name = machine_data->platform_name[1];
|
2012-03-16 16:56:40 +08:00
|
|
|
ret = fsl_asoc_get_dma_channel(np, "fsl,capture-dma",
|
|
|
|
&machine_data->dai[1],
|
|
|
|
&machine_data->dma_channel_id[1],
|
|
|
|
&machine_data->dma_id[1]);
|
2010-03-18 04:15:21 +08:00
|
|
|
if (ret) {
|
|
|
|
dev_err(&pdev->dev, "missing/invalid capture DMA phandle\n");
|
2008-01-12 01:15:26 +08:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
2010-03-18 04:15:21 +08:00
|
|
|
/* Initialize our DAI data structure. */
|
|
|
|
machine_data->dai[0].stream_name = "playback";
|
|
|
|
machine_data->dai[1].stream_name = "capture";
|
|
|
|
machine_data->dai[0].name = machine_data->dai[0].stream_name;
|
|
|
|
machine_data->dai[1].name = machine_data->dai[1].stream_name;
|
2008-01-12 01:15:26 +08:00
|
|
|
|
2010-03-18 04:15:21 +08:00
|
|
|
machine_data->card.probe = mpc8610_hpcd_machine_probe;
|
|
|
|
machine_data->card.remove = mpc8610_hpcd_machine_remove;
|
|
|
|
machine_data->card.name = pdev->name; /* The platform driver name */
|
2012-09-15 05:14:34 +08:00
|
|
|
machine_data->card.owner = THIS_MODULE;
|
|
|
|
machine_data->card.dev = &pdev->dev;
|
2010-03-18 04:15:21 +08:00
|
|
|
machine_data->card.num_links = 2;
|
|
|
|
machine_data->card.dai_link = machine_data->dai;
|
2008-01-12 01:15:26 +08:00
|
|
|
|
2010-03-18 04:15:21 +08:00
|
|
|
/* Register with ASoC */
|
2012-09-15 05:14:34 +08:00
|
|
|
ret = snd_soc_register_card(&machine_data->card);
|
2008-01-12 01:15:26 +08:00
|
|
|
if (ret) {
|
2012-09-15 05:14:34 +08:00
|
|
|
dev_err(&pdev->dev, "could not register card\n");
|
|
|
|
goto error;
|
2008-01-12 01:15:26 +08:00
|
|
|
}
|
|
|
|
|
2010-03-18 04:15:21 +08:00
|
|
|
of_node_put(codec_np);
|
2008-01-12 01:15:26 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
error:
|
|
|
|
kfree(machine_data);
|
2011-08-20 15:02:01 +08:00
|
|
|
error_alloc:
|
|
|
|
of_node_put(codec_np);
|
2008-01-12 01:15:26 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-03-18 04:15:21 +08:00
|
|
|
* mpc8610_hpcd_remove: remove the platform device
|
2008-01-12 01:15:26 +08:00
|
|
|
*
|
2010-03-18 04:15:21 +08:00
|
|
|
* This function is called when the platform device is removed.
|
2008-01-12 01:15:26 +08:00
|
|
|
*/
|
2012-12-07 22:26:16 +08:00
|
|
|
static int mpc8610_hpcd_remove(struct platform_device *pdev)
|
2008-01-12 01:15:26 +08:00
|
|
|
{
|
2012-09-15 05:14:34 +08:00
|
|
|
struct snd_soc_card *card = platform_get_drvdata(pdev);
|
2008-01-12 01:15:26 +08:00
|
|
|
struct mpc8610_hpcd_data *machine_data =
|
2010-03-18 04:15:21 +08:00
|
|
|
container_of(card, struct mpc8610_hpcd_data, card);
|
2008-01-12 01:15:26 +08:00
|
|
|
|
2012-09-15 05:14:34 +08:00
|
|
|
snd_soc_unregister_card(card);
|
2008-01-12 01:15:26 +08:00
|
|
|
kfree(machine_data);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-03-18 04:15:21 +08:00
|
|
|
static struct platform_driver mpc8610_hpcd_driver = {
|
|
|
|
.probe = mpc8610_hpcd_probe,
|
2012-12-07 22:26:16 +08:00
|
|
|
.remove = mpc8610_hpcd_remove,
|
2010-04-14 07:13:02 +08:00
|
|
|
.driver = {
|
2012-03-09 00:59:46 +08:00
|
|
|
/* The name must match 'compatible' property in the device tree,
|
2010-03-18 04:15:21 +08:00
|
|
|
* in lowercase letters.
|
|
|
|
*/
|
|
|
|
.name = "snd-soc-mpc8610hpcd",
|
2010-04-14 07:13:02 +08:00
|
|
|
},
|
2008-01-12 01:15:26 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2010-03-18 04:15:21 +08:00
|
|
|
* mpc8610_hpcd_init: machine driver initialization.
|
2008-01-12 01:15:26 +08:00
|
|
|
*
|
|
|
|
* This function is called when this module is loaded.
|
|
|
|
*/
|
|
|
|
static int __init mpc8610_hpcd_init(void)
|
|
|
|
{
|
2010-03-18 04:15:21 +08:00
|
|
|
struct device_node *guts_np;
|
|
|
|
struct resource res;
|
2008-01-12 01:15:26 +08:00
|
|
|
|
2010-03-18 04:15:21 +08:00
|
|
|
pr_info("Freescale MPC8610 HPCD ALSA SoC machine driver\n");
|
2008-01-12 01:15:26 +08:00
|
|
|
|
2010-03-18 04:15:21 +08:00
|
|
|
/* Get the physical address of the global utilities registers */
|
|
|
|
guts_np = of_find_compatible_node(NULL, NULL, "fsl,mpc8610-guts");
|
|
|
|
if (of_address_to_resource(guts_np, 0, &res)) {
|
|
|
|
pr_err("mpc8610-hpcd: missing/invalid global utilities node\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
guts_phys = res.start;
|
2008-01-12 01:15:26 +08:00
|
|
|
|
2010-03-18 04:15:21 +08:00
|
|
|
return platform_driver_register(&mpc8610_hpcd_driver);
|
2008-01-12 01:15:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-03-18 04:15:21 +08:00
|
|
|
* mpc8610_hpcd_exit: machine driver exit
|
2008-01-12 01:15:26 +08:00
|
|
|
*
|
|
|
|
* This function is called when this driver is unloaded.
|
|
|
|
*/
|
|
|
|
static void __exit mpc8610_hpcd_exit(void)
|
|
|
|
{
|
2010-03-18 04:15:21 +08:00
|
|
|
platform_driver_unregister(&mpc8610_hpcd_driver);
|
2008-01-12 01:15:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
module_init(mpc8610_hpcd_init);
|
|
|
|
module_exit(mpc8610_hpcd_exit);
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Timur Tabi <timur@freescale.com>");
|
2010-03-18 04:15:21 +08:00
|
|
|
MODULE_DESCRIPTION("Freescale MPC8610 HPCD ALSA SoC machine driver");
|
|
|
|
MODULE_LICENSE("GPL v2");
|