1 From 7f29222b1731e8182ba94a331531dec18865a1e4 Mon Sep 17 00:00:00 2001
2 From: John Crispin <blogic@openwrt.org>
3 Date: Sun, 27 Jul 2014 09:31:47 +0100
4 Subject: [PATCH 48/53] asoc: add mt7620 support
6 Signed-off-by: John Crispin <blogic@openwrt.org>
8 arch/mips/ralink/of.c | 2 +
9 sound/soc/Kconfig | 1 +
10 sound/soc/Makefile | 1 +
11 sound/soc/ralink/Kconfig | 15 ++
12 sound/soc/ralink/Makefile | 11 +
13 sound/soc/ralink/mt7620-i2s.c | 436 ++++++++++++++++++++++++++++++++++++++
14 sound/soc/ralink/mt7620-wm8960.c | 233 ++++++++++++++++++++
15 7 files changed, 699 insertions(+)
16 create mode 100644 sound/soc/ralink/Kconfig
17 create mode 100644 sound/soc/ralink/Makefile
18 create mode 100644 sound/soc/ralink/mt7620-i2s.c
19 create mode 100644 sound/soc/ralink/mt7620-wm8960.c
21 diff --git a/arch/mips/ralink/of.c b/arch/mips/ralink/of.c
22 index da85bbf..371baa5 100644
23 --- a/arch/mips/ralink/of.c
24 +++ b/arch/mips/ralink/of.c
26 #include <linux/of_fdt.h>
27 #include <linux/kernel.h>
28 #include <linux/bootmem.h>
29 +#include <linux/module.h>
30 #include <linux/of_platform.h>
31 #include <linux/of_address.h>
36 __iomem void *rt_sysc_membase;
37 +EXPORT_SYMBOL(rt_sysc_membase);
38 __iomem void *rt_memc_membase;
40 __iomem void *plat_of_remap_node(const char *node)
41 diff --git a/sound/soc/Kconfig b/sound/soc/Kconfig
42 index 225bfda..76ce95c 100644
43 --- a/sound/soc/Kconfig
44 +++ b/sound/soc/Kconfig
45 @@ -53,6 +53,7 @@ source "sound/soc/mxs/Kconfig"
46 source "sound/soc/pxa/Kconfig"
47 source "sound/soc/qcom/Kconfig"
48 source "sound/soc/rockchip/Kconfig"
49 +source "sound/soc/ralink/Kconfig"
50 source "sound/soc/samsung/Kconfig"
51 source "sound/soc/sh/Kconfig"
52 source "sound/soc/sirf/Kconfig"
53 diff --git a/sound/soc/Makefile b/sound/soc/Makefile
54 index 134aca1..e9d8e0e 100644
55 --- a/sound/soc/Makefile
56 +++ b/sound/soc/Makefile
57 @@ -35,6 +35,7 @@ obj-$(CONFIG_SND_SOC) += kirkwood/
58 obj-$(CONFIG_SND_SOC) += pxa/
59 obj-$(CONFIG_SND_SOC) += qcom/
60 obj-$(CONFIG_SND_SOC) += rockchip/
61 +obj-$(CONFIG_SND_SOC) += ralink/
62 obj-$(CONFIG_SND_SOC) += samsung/
63 obj-$(CONFIG_SND_SOC) += sh/
64 obj-$(CONFIG_SND_SOC) += sirf/
65 diff --git a/sound/soc/ralink/Kconfig b/sound/soc/ralink/Kconfig
67 index 0000000..d462622
69 +++ b/sound/soc/ralink/Kconfig
71 +config SND_MT7620_SOC_I2S
72 + depends on SOC_MT7620 && SND_SOC
73 + select SND_SOC_GENERIC_DMAENGINE_PCM
74 + tristate "SoC Audio (I2S protocol) for Ralink MT7620 SoC"
76 + Say Y if you want to use I2S protocol and I2S codec on Ingenic MT7620
79 +config SND_MT7620_SOC_WM8960
80 + tristate "SoC Audio support for Ralink WM8960"
81 + select SND_MT7620_SOC_I2S
82 + select SND_SOC_WM8960
84 + Say Y if you want to add support for ASoC audio on the Qi LB60 board
85 + a.k.a Qi Ben NanoNote.
86 diff --git a/sound/soc/ralink/Makefile b/sound/soc/ralink/Makefile
88 index 0000000..3d79980
90 +++ b/sound/soc/ralink/Makefile
93 +# Jz4740 Platform Support
95 +snd-soc-mt7620-i2s-objs := mt7620-i2s.o
97 +obj-$(CONFIG_SND_MT7620_SOC_I2S) += snd-soc-mt7620-i2s.o
99 +# Jz4740 Machine Support
100 +snd-soc-mt7620-wm8960-objs := mt7620-wm8960.o
102 +obj-$(CONFIG_SND_MT7620_SOC_WM8960) += snd-soc-mt7620-wm8960.o
103 diff --git a/sound/soc/ralink/mt7620-i2s.c b/sound/soc/ralink/mt7620-i2s.c
105 index 0000000..2ce9b21
107 +++ b/sound/soc/ralink/mt7620-i2s.c
110 + * Copyright (C) 2010, Lars-Peter Clausen <lars@metafoo.de>
112 + * This program is free software; you can redistribute it and/or modify it
113 + * under the terms of the GNU General Public License as published by the
114 + * Free Software Foundation; either version 2 of the License, or (at your
115 + * option) any later version.
117 + * You should have received a copy of the GNU General Public License along
118 + * with this program; if not, write to the Free Software Foundation, Inc.,
119 + * 675 Mass Ave, Cambridge, MA 02139, USA.
123 +#include <linux/init.h>
124 +#include <linux/io.h>
125 +#include <linux/kernel.h>
126 +#include <linux/module.h>
127 +#include <linux/platform_device.h>
128 +#include <linux/slab.h>
130 +#include <linux/delay.h>
132 +#include <linux/dma-mapping.h>
134 +#include <sound/core.h>
135 +#include <sound/pcm.h>
136 +#include <sound/pcm_params.h>
137 +#include <sound/soc.h>
138 +#include <sound/initval.h>
139 +#include <sound/dmaengine_pcm.h>
141 +#include <ralink_regs.h>
143 +#define I2S_REG_CFG0 0x00
144 +#define I2S_REG_CFG0_EN BIT(31)
145 +#define I2S_REG_CFG0_DMA_EN BIT(30)
146 +#define I2S_REG_CFG0_BYTE_SWAP BIT(28)
147 +#define I2S_REG_CFG0_TX_EN BIT(24)
148 +#define I2S_REG_CFG0_RX_EN BIT(20)
149 +#define I2S_REG_CFG0_SLAVE BIT(16)
150 +#define I2S_REG_CFG0_RX_THRES 12
151 +#define I2S_REG_CFG0_TX_THRES 4
152 +#define I2S_REG_CFG0_DFT_THRES (4 << I2S_REG_CFG0_RX_THRES) | \
153 + (4 << I2S_REG_CFG0_TX_THRES)
155 +#define I2S_REG_INT_STATUS 0x04
156 +#define I2S_REG_INT_EN 0x08
157 +#define I2S_REG_FF_STATUS 0x0c
158 +#define I2S_REG_WREG 0x10
159 +#define I2S_REG_RREG 0x14
160 +#define I2S_REG_CFG1 0x18
162 +#define I2S_REG_DIVCMP 0x20
163 +#define I2S_REG_DIVINT 0x24
164 +#define I2S_REG_CLK_EN BIT(31)
167 + struct resource *mem;
168 + void __iomem *base;
169 + dma_addr_t phys_base;
171 + struct snd_dmaengine_dai_dma_data playback_dma_data;
172 + struct snd_dmaengine_dai_dma_data capture_dma_data;
175 +static inline uint32_t mt7620_i2s_read(const struct mt7620_i2s *i2s,
178 + return readl(i2s->base + reg);
181 +static inline void mt7620_i2s_write(const struct mt7620_i2s *i2s,
182 + unsigned int reg, uint32_t value)
184 + //printk("i2s --> %p = 0x%08X\n", i2s->base + reg, value);
185 + writel(value, i2s->base + reg);
188 +static int mt7620_i2s_startup(struct snd_pcm_substream *substream,
189 + struct snd_soc_dai *dai)
191 + struct mt7620_i2s *i2s = snd_soc_dai_get_drvdata(dai);
197 + cfg = mt7620_i2s_read(i2s, I2S_REG_CFG0);
198 + cfg |= I2S_REG_CFG0_EN;
199 + mt7620_i2s_write(i2s, I2S_REG_CFG0, cfg);
204 +static void mt7620_i2s_shutdown(struct snd_pcm_substream *substream,
205 + struct snd_soc_dai *dai)
207 + struct mt7620_i2s *i2s = snd_soc_dai_get_drvdata(dai);
213 + cfg = mt7620_i2s_read(i2s, I2S_REG_CFG0);
214 + cfg &= ~I2S_REG_CFG0_EN;
215 + mt7620_i2s_write(i2s, I2S_REG_CFG0, cfg);
218 +static int mt7620_i2s_trigger(struct snd_pcm_substream *substream, int cmd,
219 + struct snd_soc_dai *dai)
221 + struct mt7620_i2s *i2s = snd_soc_dai_get_drvdata(dai);
226 + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
227 + mask = I2S_REG_CFG0_TX_EN;
229 + mask = I2S_REG_CFG0_RX_EN;
231 + cfg = mt7620_i2s_read(i2s, I2S_REG_CFG0);
234 + case SNDRV_PCM_TRIGGER_START:
235 + case SNDRV_PCM_TRIGGER_RESUME:
236 + case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
239 + case SNDRV_PCM_TRIGGER_STOP:
240 + case SNDRV_PCM_TRIGGER_SUSPEND:
241 + case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
248 + if (cfg & (I2S_REG_CFG0_TX_EN | I2S_REG_CFG0_RX_EN))
249 + cfg |= I2S_REG_CFG0_DMA_EN;
251 + cfg &= ~I2S_REG_CFG0_DMA_EN;
253 + mt7620_i2s_write(i2s, I2S_REG_CFG0, cfg);
258 +static int mt7620_i2s_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
260 + struct mt7620_i2s *i2s = snd_soc_dai_get_drvdata(dai);
263 + cfg = mt7620_i2s_read(i2s, I2S_REG_CFG0);
265 + switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
266 + case SND_SOC_DAIFMT_CBS_CFS:
267 + cfg |= I2S_REG_CFG0_SLAVE;
269 + case SND_SOC_DAIFMT_CBM_CFM:
270 + cfg &= ~I2S_REG_CFG0_SLAVE;
272 + case SND_SOC_DAIFMT_CBM_CFS:
277 + switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
278 + case SND_SOC_DAIFMT_I2S:
279 + case SND_SOC_DAIFMT_MSB:
280 + cfg &= ~I2S_REG_CFG0_BYTE_SWAP;
282 + case SND_SOC_DAIFMT_LSB:
283 + cfg |= I2S_REG_CFG0_BYTE_SWAP;
289 + switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
290 + case SND_SOC_DAIFMT_NB_NF:
296 + mt7620_i2s_write(i2s, I2S_REG_CFG0, cfg);
301 +static int mt7620_i2s_hw_params(struct snd_pcm_substream *substream,
302 + struct snd_pcm_hw_params *params, struct snd_soc_dai *dai)
308 +unsigned long i2sMaster_inclk_int[11] = {
309 + 78, 56, 52, 39, 28, 26, 19, 14, 13, 9, 6};
310 +unsigned long i2sMaster_inclk_comp[11] = {
311 + 64, 352, 42, 32, 176, 21, 272, 88, 10, 455, 261};
314 +static int mt7620_i2s_set_sysclk(struct snd_soc_dai *dai, int clk_id,
315 + unsigned int freq, int dir)
317 + struct mt7620_i2s *i2s = snd_soc_dai_get_drvdata(dai);
319 + printk("Internal REFCLK with fractional division\n");
321 + mt7620_i2s_write(i2s, I2S_REG_DIVINT, i2sMaster_inclk_int[7]);
322 + mt7620_i2s_write(i2s, I2S_REG_DIVCMP,
323 + i2sMaster_inclk_comp[7] | I2S_REG_CLK_EN);
325 +/* struct mt7620_i2s *i2s = snd_soc_dai_get_drvdata(dai);
326 + struct clk *parent;
330 + case JZ4740_I2S_CLKSRC_EXT:
331 + parent = clk_get(NULL, "ext");
332 + clk_set_parent(i2s->clk_i2s, parent);
334 + case JZ4740_I2S_CLKSRC_PLL:
335 + parent = clk_get(NULL, "pll half");
336 + clk_set_parent(i2s->clk_i2s, parent);
337 + ret = clk_set_rate(i2s->clk_i2s, freq);
348 +static void mt7620_i2c_init_pcm_config(struct mt7620_i2s *i2s)
350 + struct snd_dmaengine_dai_dma_data *dma_data;
353 + dma_data = &i2s->playback_dma_data;
354 + dma_data->maxburst = 16;
355 + dma_data->slave_id = 2; //JZ4740_DMA_TYPE_AIC_TRANSMIT;
356 + dma_data->addr = i2s->phys_base + I2S_REG_WREG;
359 + dma_data = &i2s->capture_dma_data;
360 + dma_data->maxburst = 16;
361 + dma_data->slave_id = 3; //JZ4740_DMA_TYPE_AIC_RECEIVE;
362 + dma_data->addr = i2s->phys_base + I2S_REG_RREG;
365 +static int mt7620_i2s_dai_probe(struct snd_soc_dai *dai)
367 + struct mt7620_i2s *i2s = snd_soc_dai_get_drvdata(dai);
370 + mt7620_i2c_init_pcm_config(i2s);
371 + dai->playback_dma_data = &i2s->playback_dma_data;
372 + dai->capture_dma_data = &i2s->capture_dma_data;
374 + /* set share pins to i2s/gpio mode and i2c mode */
375 + data = rt_sysc_r32(0x60);
376 + data &= 0xFFFFFFE2;
377 + data |= 0x00000018;
378 + rt_sysc_w32(data, 0x60);
380 + printk("Internal REFCLK with fractional division\n");
382 + mt7620_i2s_write(i2s, I2S_REG_CFG0, I2S_REG_CFG0_DFT_THRES);
383 + mt7620_i2s_write(i2s, I2S_REG_CFG1, 0);
384 + mt7620_i2s_write(i2s, I2S_REG_INT_EN, 0);
386 + mt7620_i2s_write(i2s, I2S_REG_DIVINT, i2sMaster_inclk_int[7]);
387 + mt7620_i2s_write(i2s, I2S_REG_DIVCMP,
388 + i2sMaster_inclk_comp[7] | I2S_REG_CLK_EN);
393 +static int mt7620_i2s_dai_remove(struct snd_soc_dai *dai)
398 +static const struct snd_soc_dai_ops mt7620_i2s_dai_ops = {
399 + .startup = mt7620_i2s_startup,
400 + .shutdown = mt7620_i2s_shutdown,
401 + .trigger = mt7620_i2s_trigger,
402 + .hw_params = mt7620_i2s_hw_params,
403 + .set_fmt = mt7620_i2s_set_fmt,
404 + .set_sysclk = mt7620_i2s_set_sysclk,
407 +#define JZ4740_I2S_FMTS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \
408 + SNDRV_PCM_FMTBIT_S24_LE)
410 +static struct snd_soc_dai_driver mt7620_i2s_dai = {
411 + .probe = mt7620_i2s_dai_probe,
412 + .remove = mt7620_i2s_dai_remove,
416 + .rates = SNDRV_PCM_RATE_8000_48000,
417 + .formats = JZ4740_I2S_FMTS,
422 + .rates = SNDRV_PCM_RATE_8000_48000,
423 + .formats = JZ4740_I2S_FMTS,
425 + .symmetric_rates = 1,
426 + .ops = &mt7620_i2s_dai_ops,
429 +static const struct snd_pcm_hardware mt7620_pcm_hardware = {
430 + .info = SNDRV_PCM_INFO_MMAP |
431 + SNDRV_PCM_INFO_MMAP_VALID |
432 + SNDRV_PCM_INFO_INTERLEAVED |
433 + SNDRV_PCM_INFO_BLOCK_TRANSFER,
434 + .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S8,
435 + .period_bytes_min = PAGE_SIZE,
436 + .period_bytes_max = 64 * 1024,
438 + .periods_max = 128,
439 + .buffer_bytes_max = 128 * 1024,
443 +static const struct snd_dmaengine_pcm_config mt7620_dmaengine_pcm_config = {
444 + .prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config,
445 + .pcm_hardware = &mt7620_pcm_hardware,
446 + .prealloc_buffer_size = 256 * PAGE_SIZE,
449 +static const struct snd_soc_component_driver mt7620_i2s_component = {
450 + .name = "mt7620-i2s",
453 +static int mt7620_i2s_dev_probe(struct platform_device *pdev)
455 + struct mt7620_i2s *i2s;
458 + snd_dmaengine_pcm_register(&pdev->dev,
459 + &mt7620_dmaengine_pcm_config,
460 + SND_DMAENGINE_PCM_FLAG_COMPAT);
462 + i2s = kzalloc(sizeof(*i2s), GFP_KERNEL);
466 + i2s->mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
472 + i2s->mem = request_mem_region(i2s->mem->start, resource_size(i2s->mem),
479 + i2s->base = ioremap_nocache(i2s->mem->start, resource_size(i2s->mem));
482 + goto err_release_mem_region;
485 + i2s->phys_base = i2s->mem->start;
487 + platform_set_drvdata(pdev, i2s);
488 + ret = snd_soc_register_component(&pdev->dev, &mt7620_i2s_component,
489 + &mt7620_i2s_dai, 1);
492 + dev_err(&pdev->dev, "loaded\n");
496 + dev_err(&pdev->dev, "Failed to register DAI\n");
497 + iounmap(i2s->base);
499 +err_release_mem_region:
500 + release_mem_region(i2s->mem->start, resource_size(i2s->mem));
507 +static int mt7620_i2s_dev_remove(struct platform_device *pdev)
509 + struct mt7620_i2s *i2s = platform_get_drvdata(pdev);
511 + snd_soc_unregister_component(&pdev->dev);
513 + iounmap(i2s->base);
514 + release_mem_region(i2s->mem->start, resource_size(i2s->mem));
518 + snd_dmaengine_pcm_unregister(&pdev->dev);
523 +static const struct of_device_id mt7620_i2s_match[] = {
524 + { .compatible = "ralink,mt7620a-i2s" },
527 +MODULE_DEVICE_TABLE(of, mt7620_i2s_match);
529 +static struct platform_driver mt7620_i2s_driver = {
530 + .probe = mt7620_i2s_dev_probe,
531 + .remove = mt7620_i2s_dev_remove,
533 + .name = "mt7620-i2s",
534 + .owner = THIS_MODULE,
535 + .of_match_table = mt7620_i2s_match,
539 +module_platform_driver(mt7620_i2s_driver);
541 +MODULE_AUTHOR("Lars-Peter Clausen, <lars@metafoo.de>");
542 +MODULE_DESCRIPTION("Ingenic JZ4740 SoC I2S driver");
543 +MODULE_LICENSE("GPL");
544 +MODULE_ALIAS("platform:mt7620-i2s");
545 diff --git a/sound/soc/ralink/mt7620-wm8960.c b/sound/soc/ralink/mt7620-wm8960.c
547 index 0000000..3389988
549 +++ b/sound/soc/ralink/mt7620-wm8960.c
552 + * Copyright 2013 Freescale Semiconductor, Inc.
554 + * Based on mt7620-sgtl5000.c
555 + * Copyright 2012 Freescale Semiconductor, Inc.
556 + * Copyright 2012 Linaro Ltd.
558 + * The code contained herein is licensed under the GNU General Public
559 + * License. You may obtain a copy of the GNU General Public License
560 + * Version 2 or later at the following locations:
562 + * http://www.opensource.org/licenses/gpl-license.html
563 + * http://www.gnu.org/copyleft/gpl.html
566 +#include <linux/module.h>
567 +#include <linux/of_platform.h>
568 +#include <linux/i2c.h>
569 +#include <linux/slab.h>
570 +#include <sound/soc.h>
571 +#include <sound/pcm_params.h>
572 +#include <sound/soc-dapm.h>
573 +#include <linux/pinctrl/consumer.h>
575 +#include "../codecs/wm8960.h"
577 +#define DAI_NAME_SIZE 32
579 +struct mt7620_wm8960_data {
580 + struct snd_soc_dai_link dai;
581 + struct snd_soc_card card;
582 + char codec_dai_name[DAI_NAME_SIZE];
583 + char platform_name[DAI_NAME_SIZE];
584 + unsigned int clk_frequency;
587 +struct mt7620_priv {
588 + struct platform_device *pdev;
590 +static struct mt7620_priv card_priv;
592 +static const struct snd_soc_dapm_widget mt7620_wm8960_dapm_widgets[] = {
593 + SND_SOC_DAPM_HP("Headphone Jack", NULL),
594 + SND_SOC_DAPM_SPK("Ext Spk", NULL),
595 + SND_SOC_DAPM_MIC("AMIC", NULL),
596 + SND_SOC_DAPM_MIC("DMIC", NULL),
599 +static int sample_rate = 44100;
600 +static snd_pcm_format_t sample_format = SNDRV_PCM_FORMAT_S16_LE;
602 +static int mt7620_hifi_hw_params(struct snd_pcm_substream *substream,
603 + struct snd_pcm_hw_params *params)
605 + sample_rate = params_rate(params);
606 + sample_format = params_format(params);
611 +static struct snd_soc_ops mt7620_hifi_ops = {
612 + .hw_params = mt7620_hifi_hw_params,
615 +static int mt7620_wm8960_set_bias_level(struct snd_soc_card *card,
616 + struct snd_soc_dapm_context *dapm,
617 + enum snd_soc_bias_level level)
619 + struct snd_soc_dai *codec_dai = card->rtd[0].codec_dai;
620 + struct mt7620_priv *priv = &card_priv;
621 + struct mt7620_wm8960_data *data = snd_soc_card_get_drvdata(card);
622 + struct device *dev = &priv->pdev->dev;
625 + if (dapm->dev != codec_dai->dev)
629 + case SND_SOC_BIAS_PREPARE:
630 + if (dapm->bias_level == SND_SOC_BIAS_STANDBY) {
634 + case SND_SOC_BIAS_STANDBY:
635 + if (dapm->bias_level == SND_SOC_BIAS_PREPARE) {
636 + ret = snd_soc_dai_set_sysclk(codec_dai,
637 + WM8960_SYSCLK_MCLK, data->clk_frequency,
641 + "failed to switch away from FLL: %d\n",
655 +static int mt7620_wm8960_late_probe(struct snd_soc_card *card)
657 + struct snd_soc_dai *codec_dai = card->rtd[0].codec_dai;
658 + struct mt7620_priv *priv = &card_priv;
659 + struct mt7620_wm8960_data *data = snd_soc_card_get_drvdata(card);
660 + struct device *dev = &priv->pdev->dev;
663 + ret = snd_soc_dai_set_sysclk(codec_dai, WM8960_SYSCLK_MCLK,
664 + data->clk_frequency, SND_SOC_CLOCK_IN);
666 + dev_err(dev, "failed to set sysclk in %s\n", __func__);
671 +static int mt7620_wm8960_probe(struct platform_device *pdev)
673 + struct device_node *i2s_np, *codec_np;
674 + struct platform_device *i2s_pdev;
675 + struct mt7620_priv *priv = &card_priv;
676 + struct i2c_client *codec_dev;
677 + struct mt7620_wm8960_data *data;
682 + i2s_np = of_parse_phandle(pdev->dev.of_node, "i2s-controller", 0);
683 + codec_np = of_parse_phandle(pdev->dev.of_node, "audio-codec", 0);
684 + if (!i2s_np || !codec_np) {
685 + dev_err(&pdev->dev, "phandle missing or invalid\n");
690 + i2s_pdev = of_find_device_by_node(i2s_np);
692 + dev_err(&pdev->dev, "failed to find SSI platform device\n");
696 + codec_dev = of_find_i2c_device_by_node(codec_np);
697 + if (!codec_dev || !codec_dev->dev.driver) {
698 + dev_err(&pdev->dev, "failed to find codec platform device\n");
703 + data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
709 + data->clk_frequency = 12000000;
710 + data->dai.name = "HiFi";
711 + data->dai.stream_name = "HiFi";
712 + data->dai.codec_dai_name = "wm8960-hifi";
713 + data->dai.codec_of_node = codec_np;
714 + data->dai.cpu_dai_name = dev_name(&i2s_pdev->dev);
715 + data->dai.platform_of_node = i2s_np;
716 + data->dai.ops = &mt7620_hifi_ops;
717 + data->dai.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
718 + SND_SOC_DAIFMT_CBM_CFM;
720 + data->card.dev = &pdev->dev;
721 + ret = snd_soc_of_parse_card_name(&data->card, "model");
724 + ret = snd_soc_of_parse_audio_routing(&data->card, "audio-routing");
727 + data->card.num_links = 1;
728 + data->card.dai_link = &data->dai;
729 + data->card.dapm_widgets = mt7620_wm8960_dapm_widgets;
730 + data->card.num_dapm_widgets = ARRAY_SIZE(mt7620_wm8960_dapm_widgets);
732 + data->card.late_probe = mt7620_wm8960_late_probe;
733 + data->card.set_bias_level = mt7620_wm8960_set_bias_level;
735 + platform_set_drvdata(pdev, &data->card);
736 + snd_soc_card_set_drvdata(&data->card, data);
738 + ret = devm_snd_soc_register_card(&pdev->dev, &data->card);
740 + dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret);
744 + of_node_put(i2s_np);
745 + of_node_put(codec_np);
750 + of_node_put(i2s_np);
752 + of_node_put(codec_np);
757 +static int mt7620_wm8960_remove(struct platform_device *pdev)
762 +static const struct of_device_id mt7620_wm8960_dt_ids[] = {
763 + { .compatible = "mediatek,mt7620-audio-wm8960", },
766 +MODULE_DEVICE_TABLE(of, mt7620_wm8960_dt_ids);
768 +static struct platform_driver mt7620_wm8960_driver = {
770 + .name = "mt7620-wm8960",
771 + .owner = THIS_MODULE,
772 + .pm = &snd_soc_pm_ops,
773 + .of_match_table = mt7620_wm8960_dt_ids,
775 + .probe = mt7620_wm8960_probe,
776 + .remove = mt7620_wm8960_remove,
778 +module_platform_driver(mt7620_wm8960_driver);
780 +MODULE_AUTHOR("Freescale Semiconductor, Inc.");
781 +MODULE_DESCRIPTION("Freescale i.MX WM8962 ASoC machine driver");
782 +MODULE_LICENSE("GPL v2");
783 +MODULE_ALIAS("platform:mt7620-wm8962");