Commit-ID: 27ef3744f85bbbd00175ce7e9ac46b52089ee83c Gitweb: http://git.kernel.org/tip/27ef3744f85bbbd00175ce7e9ac46b52089ee83c Author: Timur Tabi <timur@xxxxxxxxxxxxx> AuthorDate: Thu, 19 Aug 2010 17:11:40 -0500 Committer: Mark Brown <broonie@xxxxxxxxxxxxxxxxxxxxxxxxxxx> CommitDate: Fri, 20 Aug 2010 12:14:48 +0100 ASoC: add support for the Freescale P1022 DS reference board The Freescale P1022 is a dual-core e500-based SOC with multimedia capabilities, specifically the same SSI audio controller on the MPC8610. The P1022 DS reference board includes a P1022 and a Wolfson Microelectronics WM8776 codec. Signed-off-by: Timur Tabi <timur@xxxxxxxxxxxxx> Acked-by: Liam Girdwood <lrg@xxxxxxxxxxxxxxx> Signed-off-by: Mark Brown <broonie@xxxxxxxxxxxxxxxxxxxxxxxxxxx> --- sound/soc/fsl/Kconfig | 24 ++- sound/soc/fsl/Makefile | 8 +- sound/soc/fsl/{mpc8610_hpcd.c => p1022_ds.c} | 359 +++++++++++++------------- 3 files changed, 205 insertions(+), 186 deletions(-) diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig index 9818687..d754d34 100644 --- a/sound/soc/fsl/Kconfig +++ b/sound/soc/fsl/Kconfig @@ -1,24 +1,36 @@ config SND_MPC52xx_DMA tristate -# ASoC platform support for the Freescale MPC8610 SOC. This compiles drivers -# for the SSI and the Elo DMA controller. You will still need to select -# a platform driver and a codec driver. -config SND_SOC_MPC8610 +# ASoC platform support for the Freescale PowerPC SOCs that have an SSI and +# an Elo DMA controller, such as the MPC8610 and P1022. You will still need to +# select a platform driver and a codec driver. +config SND_SOC_POWERPC_SSI tristate - depends on MPC8610 + depends on FSL_SOC config SND_SOC_MPC8610_HPCD tristate "ALSA SoC support for the Freescale MPC8610 HPCD board" # I2C is necessary for the CS4270 driver depends on MPC8610_HPCD && I2C - select SND_SOC_MPC8610 + select SND_SOC_POWERPC_SSI select SND_SOC_CS4270 select SND_SOC_CS4270_VD33_ERRATA default y if MPC8610_HPCD help Say Y if you want to enable audio on the Freescale MPC8610 HPCD. +config SND_SOC_P1022_DS + tristate "ALSA SoC support for the Freescale P1022 DS board" + # I2C is necessary for the WM8776 driver + depends on P1022_DS && I2C + select SND_SOC_POWERPC_SSI + select SND_SOC_WM8776 + default y if P1022_DS + help + Say Y if you want to enable audio on the Freescale P1022 DS board. + This will also include the Wolfson Microelectronics WM8776 codec + driver. + config SND_SOC_MPC5200_I2S tristate "Freescale MPC5200 PSC in I2S mode driver" depends on PPC_MPC52xx && PPC_BESTCOMM diff --git a/sound/soc/fsl/Makefile b/sound/soc/fsl/Makefile index 7e472a5..b4a38c0 100644 --- a/sound/soc/fsl/Makefile +++ b/sound/soc/fsl/Makefile @@ -2,10 +2,14 @@ snd-soc-mpc8610-hpcd-objs := mpc8610_hpcd.o obj-$(CONFIG_SND_SOC_MPC8610_HPCD) += snd-soc-mpc8610-hpcd.o -# MPC8610 Platform Support +# P1022 DS Machine Support +snd-soc-p1022-ds-objs := p1022_ds.o +obj-$(CONFIG_SND_SOC_P1022_DS) += snd-soc-p1022-ds.o + +# Freescale PowerPC SSI/DMA Platform Support snd-soc-fsl-ssi-objs := fsl_ssi.o snd-soc-fsl-dma-objs := fsl_dma.o -obj-$(CONFIG_SND_SOC_MPC8610) += snd-soc-fsl-ssi.o snd-soc-fsl-dma.o +obj-$(CONFIG_SND_SOC_POWERPC_SSI) += snd-soc-fsl-ssi.o snd-soc-fsl-dma.o # MPC5200 Platform Support obj-$(CONFIG_SND_MPC52xx_DMA) += mpc5200_dma.o diff --git a/sound/soc/fsl/mpc8610_hpcd.c b/sound/soc/fsl/p1022_ds.c similarity index 54% copy from sound/soc/fsl/mpc8610_hpcd.c copy to sound/soc/fsl/p1022_ds.c index 38339c1..f8176e8 100644 --- a/sound/soc/fsl/mpc8610_hpcd.c +++ b/sound/soc/fsl/p1022_ds.c @@ -1,9 +1,9 @@ /** - * Freescale MPC8610HPCD ALSA SoC Machine driver + * Freescale P1022DS ALSA SoC Machine driver * * Author: Timur Tabi <timur@xxxxxxxxxxxxx> * - * Copyright 2007-2010 Freescale Semiconductor, Inc. + * Copyright 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 @@ -13,24 +13,58 @@ #include <linux/module.h> #include <linux/interrupt.h> #include <linux/of_device.h> +#include <linux/slab.h> #include <sound/soc.h> #include <asm/fsl_guts.h> #include "fsl_dma.h" #include "fsl_ssi.h" +/* P1022-specific PMUXCR and DMUXCR bit definitions */ + +#define CCSR_GUTS_PMUXCR_UART0_I2C1_MASK 0x0001c000 +#define CCSR_GUTS_PMUXCR_UART0_I2C1_UART0_SSI 0x00010000 +#define CCSR_GUTS_PMUXCR_UART0_I2C1_SSI 0x00018000 + +#define CCSR_GUTS_PMUXCR_SSI_DMA_TDM_MASK 0x00000c00 +#define CCSR_GUTS_PMUXCR_SSI_DMA_TDM_SSI 0x00000000 + +#define CCSR_GUTS_DMUXCR_PAD 1 /* DMA controller/channel set to pad */ +#define CCSR_GUTS_DMUXCR_SSI 2 /* DMA controller/channel set to SSI */ + +/* + * Set the DMACR register in the GUTS + * + * The DMACR register determines the source of initiated transfers for each + * channel on each DMA controller. Rather than have a bunch of repetitive + * macros for the bit patterns, we just have a function that calculates + * them. + * + * guts: Pointer to GUTS structure + * co: The DMA controller (0 or 1) + * ch: The channel on the DMA controller (0, 1, 2, or 3) + * device: The device to set as the target (CCSR_GUTS_DMUXCR_xxx) + */ +static inline void guts_set_dmuxcr(struct ccsr_guts_85xx __iomem *guts, + unsigned int co, unsigned int ch, unsigned int device) +{ + unsigned int shift = 16 + (8 * (1 - co) + 2 * (3 - ch)); + + clrsetbits_be32(&guts->dmuxcr, 3 << shift, device << shift); +} + /* There's only one global utilities register */ static phys_addr_t guts_phys; #define DAI_NAME_SIZE 32 /** - * mpc8610_hpcd_data: machine-specific ASoC device data + * machine_data: machine-specific ASoC device data * * This structure contains data for a single sound platform device on an - * MPC8610 HPCD. Some of the data is taken from the device tree. + * P1022 DS. Some of the data is taken from the device tree. */ -struct mpc8610_hpcd_data { +struct machine_data { struct snd_soc_dai_link dai[2]; struct snd_soc_card card; unsigned int dai_format; @@ -40,54 +74,44 @@ struct mpc8610_hpcd_data { unsigned int ssi_id; /* 0 = SSI1, 1 = SSI2, etc */ unsigned int dma_id[2]; /* 0 = DMA1, 1 = DMA2, etc */ unsigned int dma_channel_id[2]; /* 0 = ch 0, 1 = ch 1, etc*/ - char codec_dai_name[DAI_NAME_SIZE]; char codec_name[DAI_NAME_SIZE]; char platform_name[2][DAI_NAME_SIZE]; /* One for each DMA channel */ }; /** - * mpc8610_hpcd_machine_probe: initialize the board + * p1022_ds_machine_probe: initialize the board * * This function is used to initialize the board-specific hardware. * * Here we program the DMACR and PMUXCR registers. */ -static int mpc8610_hpcd_machine_probe(struct platform_device *sound_device) +static int p1022_ds_machine_probe(struct platform_device *sound_device) { struct snd_soc_card *card = platform_get_drvdata(sound_device); - struct mpc8610_hpcd_data *machine_data = - container_of(card, struct mpc8610_hpcd_data, card); - struct ccsr_guts_86xx __iomem *guts; + struct machine_data *mdata = + container_of(card, struct machine_data, card); + struct ccsr_guts_85xx __iomem *guts; - guts = ioremap(guts_phys, sizeof(struct ccsr_guts_86xx)); + guts = ioremap(guts_phys, sizeof(struct ccsr_guts_85xx)); if (!guts) { dev_err(card->dev, "could not map global utilities\n"); return -ENOMEM; } - /* 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); - - switch (machine_data->ssi_id) { - case 0: - clrsetbits_be32(&guts->pmuxcr, - CCSR_GUTS_PMUXCR_SSI1_MASK, CCSR_GUTS_PMUXCR_SSI1_SSI); - break; - case 1: - clrsetbits_be32(&guts->pmuxcr, - CCSR_GUTS_PMUXCR_SSI2_MASK, CCSR_GUTS_PMUXCR_SSI2_SSI); - break; - } + /* Enable SSI Tx signal */ + clrsetbits_be32(&guts->pmuxcr, CCSR_GUTS_PMUXCR_UART0_I2C1_MASK, + CCSR_GUTS_PMUXCR_UART0_I2C1_UART0_SSI); + + /* Enable SSI Rx signal */ + clrsetbits_be32(&guts->pmuxcr, CCSR_GUTS_PMUXCR_SSI_DMA_TDM_MASK, + CCSR_GUTS_PMUXCR_SSI_DMA_TDM_SSI); + + /* Enable DMA Channel for SSI */ + guts_set_dmuxcr(guts, mdata->dma_id[0], mdata->dma_channel_id[0], + CCSR_GUTS_DMUXCR_SSI); + + guts_set_dmuxcr(guts, mdata->dma_id[1], mdata->dma_channel_id[1], + CCSR_GUTS_DMUXCR_SSI); iounmap(guts); @@ -95,22 +119,22 @@ static int mpc8610_hpcd_machine_probe(struct platform_device *sound_device) } /** - * mpc8610_hpcd_startup: program the board with various hardware parameters + * p1022_ds_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) +static int p1022_ds_startup(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mpc8610_hpcd_data *machine_data = - container_of(rtd->card, struct mpc8610_hpcd_data, card); + struct machine_data *mdata = + container_of(rtd->card, struct machine_data, card); struct device *dev = rtd->card->dev; int ret = 0; /* Tell the codec driver what the serial protocol is. */ - ret = snd_soc_dai_set_fmt(rtd->codec_dai, machine_data->dai_format); + ret = snd_soc_dai_set_fmt(rtd->codec_dai, mdata->dai_format); if (ret < 0) { dev_err(dev, "could not set codec driver audio format\n"); return ret; @@ -120,9 +144,8 @@ static int mpc8610_hpcd_startup(struct snd_pcm_substream *substream) * Tell the codec driver what the MCLK frequency is, and whether it's * a slave or master. */ - ret = snd_soc_dai_set_sysclk(rtd->codec_dai, 0, - machine_data->clk_frequency, - machine_data->codec_clk_direction); + ret = snd_soc_dai_set_sysclk(rtd->codec_dai, 0, mdata->clk_frequency, + mdata->codec_clk_direction); if (ret < 0) { dev_err(dev, "could not set codec driver clock params\n"); return ret; @@ -132,41 +155,29 @@ static int mpc8610_hpcd_startup(struct snd_pcm_substream *substream) } /** - * mpc8610_hpcd_machine_remove: Remove the sound device + * p1022_ds_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. */ -static int mpc8610_hpcd_machine_remove(struct platform_device *sound_device) +static int p1022_ds_machine_remove(struct platform_device *sound_device) { struct snd_soc_card *card = platform_get_drvdata(sound_device); - struct mpc8610_hpcd_data *machine_data = - container_of(card, struct mpc8610_hpcd_data, card); - struct ccsr_guts_86xx __iomem *guts; + struct machine_data *mdata = + container_of(card, struct machine_data, card); + struct ccsr_guts_85xx __iomem *guts; - guts = ioremap(guts_phys, sizeof(struct ccsr_guts_86xx)); + guts = ioremap(guts_phys, sizeof(struct ccsr_guts_85xx)); if (!guts) { dev_err(card->dev, "could not map global utilities\n"); return -ENOMEM; } /* Restore the signal routing */ - - 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); - - switch (machine_data->ssi_id) { - case 0: - clrsetbits_be32(&guts->pmuxcr, - CCSR_GUTS_PMUXCR_SSI1_MASK, CCSR_GUTS_PMUXCR_SSI1_LA); - break; - case 1: - clrsetbits_be32(&guts->pmuxcr, - CCSR_GUTS_PMUXCR_SSI2_MASK, CCSR_GUTS_PMUXCR_SSI2_LA); - break; - } + clrbits32(&guts->pmuxcr, CCSR_GUTS_PMUXCR_UART0_I2C1_MASK); + clrbits32(&guts->pmuxcr, CCSR_GUTS_PMUXCR_SSI_DMA_TDM_MASK); + guts_set_dmuxcr(guts, mdata->dma_id[0], mdata->dma_channel_id[0], 0); + guts_set_dmuxcr(guts, mdata->dma_id[1], mdata->dma_channel_id[1], 0); iounmap(guts); @@ -174,10 +185,10 @@ static int mpc8610_hpcd_machine_remove(struct platform_device *sound_device) } /** - * mpc8610_hpcd_ops: ASoC machine driver operations + * p1022_ds_ops: ASoC machine driver operations */ -static struct snd_soc_ops mpc8610_hpcd_ops = { - .startup = mpc8610_hpcd_startup, +static struct snd_soc_ops p1022_ds_ops = { + .startup = p1022_ds_startup, }; /** @@ -191,21 +202,13 @@ static struct snd_soc_ops mpc8610_hpcd_ops = { * with the specific string, then NULL is returned. */ static struct device_node *get_node_by_phandle_name(struct device_node *np, - const char *name, - const char *compatible) + const char *name, const char *compatible) { - const phandle *ph; - int len; - - ph = of_get_property(np, name, &len); - if (!ph || (len != sizeof(phandle))) - return NULL; - - np = of_find_node_by_phandle(*ph); + np = of_parse_phandle(np, name, 0); if (!np) return NULL; - if (compatible && !of_device_is_compatible(np, compatible)) { + if (!of_device_is_compatible(np, compatible)) { of_node_put(np); return NULL; } @@ -224,17 +227,18 @@ static int get_parent_cell_index(struct device_node *np) { struct device_node *parent = of_get_parent(np); const u32 *iprop; + int ret = -1; if (!parent) return -1; iprop = of_get_property(parent, "cell-index", NULL); - of_node_put(parent); + if (iprop) + ret = *iprop; - if (!iprop) - return -1; + of_node_put(parent); - return *iprop; + return ret; } /** @@ -314,63 +318,59 @@ static int get_dma_channel(struct device_node *ssi_np, } /** - * mpc8610_hpcd_probe: platform probe function for the machine driver + * p1022_ds_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) +static int p1022_ds_probe(struct platform_device *pdev) { struct device *dev = pdev->dev.parent; - /* of_dev is the OF device for the SSI node that probed us */ - struct of_device *of_dev = container_of(dev, struct of_device, dev); - struct device_node *np = of_dev->dev.of_node; + /* ssi_pdev is the platform device for the SSI node that probed us */ + struct platform_device *ssi_pdev = + container_of(dev, struct platform_device, dev); + struct device_node *np = ssi_pdev->dev.of_node; struct device_node *codec_np = NULL; struct platform_device *sound_device = NULL; - struct mpc8610_hpcd_data *machine_data; + struct machine_data *mdata; int ret = -ENODEV; const char *sprop; const u32 *iprop; - /* We are only interested in SSIs with a codec phandle in them, - * so let's make sure this SSI has one. The MPC8610 HPCD only - * knows about the CS4270 codec, so reject anything else. - */ - codec_np = get_node_by_phandle_name(np, "codec-handle", - "cirrus,cs4270"); + /* Find the codec node for this SSI. */ + codec_np = of_parse_phandle(np, "codec-handle", 0); if (!codec_np) { - dev_err(dev, "invalid codec node\n"); + dev_err(dev, "could not find codec node\n"); return -EINVAL; } - machine_data = kzalloc(sizeof(struct mpc8610_hpcd_data), GFP_KERNEL); - if (!machine_data) + mdata = kzalloc(sizeof(struct machine_data), GFP_KERNEL); + if (!mdata) return -ENOMEM; - machine_data->dai[0].cpu_dai_name = dev_name(&of_dev->dev); - machine_data->dai[0].ops = &mpc8610_hpcd_ops; + mdata->dai[0].cpu_dai_name = dev_name(&ssi_pdev->dev); + mdata->dai[0].ops = &p1022_ds_ops; /* Determine the codec name, it will be used as the codec DAI name */ - ret = codec_node_dev_name(codec_np, machine_data->codec_name, - DAI_NAME_SIZE); + ret = codec_node_dev_name(codec_np, mdata->codec_name, DAI_NAME_SIZE); if (ret) { dev_err(&pdev->dev, "invalid codec node %s\n", codec_np->full_name); ret = -EINVAL; goto error; } - machine_data->dai[0].codec_name = machine_data->codec_name; - - /* The DAI name from the codec (snd_soc_dai_driver.name) */ - machine_data->dai[0].codec_dai_name = "cs4270-hifi"; + mdata->dai[0].codec_name = mdata->codec_name; /* 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. + * capture. We support codecs that have separate DAIs for both playback + * and capture. */ - memcpy(&machine_data->dai[1], &machine_data->dai[0], - sizeof(struct snd_soc_dai_link)); + memcpy(&mdata->dai[1], &mdata->dai[0], sizeof(struct snd_soc_dai_link)); + + /* The DAI names from the codec (snd_soc_dai_driver.name) */ + mdata->dai[0].codec_dai_name = "wm8776-hifi-playback"; + mdata->dai[1].codec_dai_name = "wm8776-hifi-capture"; /* Get the device ID */ iprop = of_get_property(np, "cell-index", NULL); @@ -379,7 +379,7 @@ static int mpc8610_hpcd_probe(struct platform_device *pdev) ret = -EINVAL; goto error; } - machine_data->ssi_id = *iprop; + mdata->ssi_id = *iprop; /* Get the serial format and clock direction. */ sprop = of_get_property(np, "fsl,mode", NULL); @@ -390,9 +390,9 @@ static int mpc8610_hpcd_probe(struct platform_device *pdev) } if (strcasecmp(sprop, "i2s-slave") == 0) { - machine_data->dai_format = SND_SOC_DAIFMT_I2S; - machine_data->codec_clk_direction = SND_SOC_CLOCK_OUT; - machine_data->cpu_clk_direction = SND_SOC_CLOCK_IN; + mdata->dai_format = SND_SOC_DAIFMT_I2S; + mdata->codec_clk_direction = SND_SOC_CLOCK_OUT; + mdata->cpu_clk_direction = SND_SOC_CLOCK_IN; /* In i2s-slave mode, the codec has its own clock source, so we * need to get the frequency from the device tree and pass it to @@ -405,35 +405,35 @@ static int mpc8610_hpcd_probe(struct platform_device *pdev) ret = -EINVAL; goto error; } - machine_data->clk_frequency = *iprop; + mdata->clk_frequency = *iprop; } else if (strcasecmp(sprop, "i2s-master") == 0) { - machine_data->dai_format = SND_SOC_DAIFMT_I2S; - machine_data->codec_clk_direction = SND_SOC_CLOCK_IN; - machine_data->cpu_clk_direction = SND_SOC_CLOCK_OUT; + mdata->dai_format = SND_SOC_DAIFMT_I2S; + mdata->codec_clk_direction = SND_SOC_CLOCK_IN; + mdata->cpu_clk_direction = SND_SOC_CLOCK_OUT; } else if (strcasecmp(sprop, "lj-slave") == 0) { - machine_data->dai_format = SND_SOC_DAIFMT_LEFT_J; - machine_data->codec_clk_direction = SND_SOC_CLOCK_OUT; - machine_data->cpu_clk_direction = SND_SOC_CLOCK_IN; + mdata->dai_format = SND_SOC_DAIFMT_LEFT_J; + mdata->codec_clk_direction = SND_SOC_CLOCK_OUT; + mdata->cpu_clk_direction = SND_SOC_CLOCK_IN; } else if (strcasecmp(sprop, "lj-master") == 0) { - machine_data->dai_format = SND_SOC_DAIFMT_LEFT_J; - machine_data->codec_clk_direction = SND_SOC_CLOCK_IN; - machine_data->cpu_clk_direction = SND_SOC_CLOCK_OUT; + mdata->dai_format = SND_SOC_DAIFMT_LEFT_J; + mdata->codec_clk_direction = SND_SOC_CLOCK_IN; + mdata->cpu_clk_direction = SND_SOC_CLOCK_OUT; } else if (strcasecmp(sprop, "rj-slave") == 0) { - machine_data->dai_format = SND_SOC_DAIFMT_RIGHT_J; - machine_data->codec_clk_direction = SND_SOC_CLOCK_OUT; - machine_data->cpu_clk_direction = SND_SOC_CLOCK_IN; + mdata->dai_format = SND_SOC_DAIFMT_RIGHT_J; + mdata->codec_clk_direction = SND_SOC_CLOCK_OUT; + mdata->cpu_clk_direction = SND_SOC_CLOCK_IN; } else if (strcasecmp(sprop, "rj-master") == 0) { - machine_data->dai_format = SND_SOC_DAIFMT_RIGHT_J; - machine_data->codec_clk_direction = SND_SOC_CLOCK_IN; - machine_data->cpu_clk_direction = SND_SOC_CLOCK_OUT; + mdata->dai_format = SND_SOC_DAIFMT_RIGHT_J; + mdata->codec_clk_direction = SND_SOC_CLOCK_IN; + mdata->cpu_clk_direction = SND_SOC_CLOCK_OUT; } else if (strcasecmp(sprop, "ac97-slave") == 0) { - machine_data->dai_format = SND_SOC_DAIFMT_AC97; - machine_data->codec_clk_direction = SND_SOC_CLOCK_OUT; - machine_data->cpu_clk_direction = SND_SOC_CLOCK_IN; + mdata->dai_format = SND_SOC_DAIFMT_AC97; + mdata->codec_clk_direction = SND_SOC_CLOCK_OUT; + mdata->cpu_clk_direction = SND_SOC_CLOCK_IN; } else if (strcasecmp(sprop, "ac97-master") == 0) { - machine_data->dai_format = SND_SOC_DAIFMT_AC97; - machine_data->codec_clk_direction = SND_SOC_CLOCK_IN; - machine_data->cpu_clk_direction = SND_SOC_CLOCK_OUT; + mdata->dai_format = SND_SOC_DAIFMT_AC97; + mdata->codec_clk_direction = SND_SOC_CLOCK_IN; + mdata->cpu_clk_direction = SND_SOC_CLOCK_OUT; } else { dev_err(&pdev->dev, "unrecognized fsl,mode property '%s'\n", sprop); @@ -441,43 +441,43 @@ static int mpc8610_hpcd_probe(struct platform_device *pdev) goto error; } - if (!machine_data->clk_frequency) { + if (!mdata->clk_frequency) { dev_err(&pdev->dev, "unknown clock frequency\n"); ret = -EINVAL; goto error; } /* Find the playback DMA channel to use. */ - machine_data->dai[0].platform_name = machine_data->platform_name[0]; - ret = get_dma_channel(np, "fsl,playback-dma", &machine_data->dai[0], - &machine_data->dma_channel_id[0], - &machine_data->dma_id[0]); + mdata->dai[0].platform_name = mdata->platform_name[0]; + ret = get_dma_channel(np, "fsl,playback-dma", &mdata->dai[0], + &mdata->dma_channel_id[0], + &mdata->dma_id[0]); if (ret) { dev_err(&pdev->dev, "missing/invalid playback DMA phandle\n"); goto error; } /* Find the capture DMA channel to use. */ - machine_data->dai[1].platform_name = machine_data->platform_name[1]; - ret = get_dma_channel(np, "fsl,capture-dma", &machine_data->dai[1], - &machine_data->dma_channel_id[1], - &machine_data->dma_id[1]); + mdata->dai[1].platform_name = mdata->platform_name[1]; + ret = get_dma_channel(np, "fsl,capture-dma", &mdata->dai[1], + &mdata->dma_channel_id[1], + &mdata->dma_id[1]); if (ret) { dev_err(&pdev->dev, "missing/invalid capture DMA phandle\n"); goto error; } /* 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; + mdata->dai[0].stream_name = "playback"; + mdata->dai[1].stream_name = "capture"; + mdata->dai[0].name = mdata->dai[0].stream_name; + mdata->dai[1].name = mdata->dai[1].stream_name; - 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 */ - machine_data->card.num_links = 2; - machine_data->card.dai_link = machine_data->dai; + mdata->card.probe = p1022_ds_machine_probe; + mdata->card.remove = p1022_ds_machine_remove; + mdata->card.name = pdev->name; /* The platform driver name */ + mdata->card.num_links = 2; + mdata->card.dai_link = mdata->dai; /* Allocate a new audio platform device structure */ sound_device = platform_device_alloc("soc-audio", -1); @@ -488,7 +488,7 @@ static int mpc8610_hpcd_probe(struct platform_device *pdev) } /* Associate the card data with the sound device */ - platform_set_drvdata(sound_device, &machine_data->card); + platform_set_drvdata(sound_device, &mdata->card); /* Register with ASoC */ ret = platform_device_add(sound_device); @@ -507,26 +507,26 @@ error: if (sound_device) platform_device_unregister(sound_device); - kfree(machine_data); + kfree(mdata); return ret; } /** - * mpc8610_hpcd_remove: remove the platform device + * p1022_ds_remove: remove the platform device * * This function is called when the platform device is removed. */ -static int __devexit mpc8610_hpcd_remove(struct platform_device *pdev) +static int __devexit p1022_ds_remove(struct platform_device *pdev) { struct platform_device *sound_device = dev_get_drvdata(&pdev->dev); struct snd_soc_card *card = platform_get_drvdata(sound_device); - struct mpc8610_hpcd_data *machine_data = - container_of(card, struct mpc8610_hpcd_data, card); + struct machine_data *mdata = + container_of(card, struct machine_data, card); platform_device_unregister(sound_device); - kfree(machine_data); + kfree(mdata); sound_device->dev.platform_data = NULL; dev_set_drvdata(&pdev->dev, NULL); @@ -534,54 +534,57 @@ static int __devexit mpc8610_hpcd_remove(struct platform_device *pdev) return 0; } -static struct platform_driver mpc8610_hpcd_driver = { - .probe = mpc8610_hpcd_probe, - .remove = __devexit_p(mpc8610_hpcd_remove), +static struct platform_driver p1022_ds_driver = { + .probe = p1022_ds_probe, + .remove = __devexit_p(p1022_ds_remove), .driver = { /* The name must match the 'model' property in the device tree, - * in lowercase letters. + * in lowercase letters, but only the part after that last + * comma. This is because some model properties have a "fsl," + * prefix. */ - .name = "snd-soc-mpc8610hpcd", + .name = "snd-soc-p1022", .owner = THIS_MODULE, }, }; /** - * mpc8610_hpcd_init: machine driver initialization. + * p1022_ds_init: machine driver initialization. * * This function is called when this module is loaded. */ -static int __init mpc8610_hpcd_init(void) +static int __init p1022_ds_init(void) { struct device_node *guts_np; struct resource res; - pr_info("Freescale MPC8610 HPCD ALSA SoC machine driver\n"); + pr_info("Freescale P1022 DS ALSA SoC machine driver\n"); /* Get the physical address of the global utilities registers */ - guts_np = of_find_compatible_node(NULL, NULL, "fsl,mpc8610-guts"); + guts_np = of_find_compatible_node(NULL, NULL, "fsl,p1022-guts"); if (of_address_to_resource(guts_np, 0, &res)) { - pr_err("mpc8610-hpcd: missing/invalid global utilities node\n"); + pr_err("p1022-ds: missing/invalid global utilities node\n"); return -EINVAL; } guts_phys = res.start; + of_node_put(guts_np); - return platform_driver_register(&mpc8610_hpcd_driver); + return platform_driver_register(&p1022_ds_driver); } /** - * mpc8610_hpcd_exit: machine driver exit + * p1022_ds_exit: machine driver exit * * This function is called when this driver is unloaded. */ -static void __exit mpc8610_hpcd_exit(void) +static void __exit p1022_ds_exit(void) { - platform_driver_unregister(&mpc8610_hpcd_driver); + platform_driver_unregister(&p1022_ds_driver); } -module_init(mpc8610_hpcd_init); -module_exit(mpc8610_hpcd_exit); +module_init(p1022_ds_init); +module_exit(p1022_ds_exit); MODULE_AUTHOR("Timur Tabi <timur@xxxxxxxxxxxxx>"); -MODULE_DESCRIPTION("Freescale MPC8610 HPCD ALSA SoC machine driver"); +MODULE_DESCRIPTION("Freescale P1022 DS ALSA SoC machine driver"); MODULE_LICENSE("GPL v2"); -- To unsubscribe from this list: send the line "unsubscribe linux-tip-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html