1 /*
2 * wm8727.c
3 *
4 * Created on: 15-Oct-2009
5 * Author: neil.jones@imgtec.com
6 *
7 * Copyright (C) 2009 Imagination Technologies Ltd.
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2 of the License, or (at your
12 * option) any later version.
13 */
14
15 #include <linux/init.h>
16 #include <linux/slab.h>
17 #include <linux/module.h>
18 #include <linux/kernel.h>
19 #include <linux/device.h>
20 #include <sound/core.h>
21 #include <sound/pcm.h>
22 #include <sound/initval.h>
23 #include <sound/soc.h>
24
25 static const struct snd_soc_dapm_widget wm8727_dapm_widgets[] = {
26 SND_SOC_DAPM_OUTPUT("VOUTL"),
27 SND_SOC_DAPM_OUTPUT("VOUTR"),
28 };
29
30 static const struct snd_soc_dapm_route wm8727_dapm_routes[] = {
31 { "VOUTL", NULL, "Playback" },
32 { "VOUTR", NULL, "Playback" },
33 };
34
35 /*
36 * Note this is a simple chip with no configuration interface, sample rate is
37 * determined automatically by examining the Master clock and Bit clock ratios
38 */
39 #define WM8727_RATES (SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |\
40 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |\
41 SNDRV_PCM_RATE_192000)
42
43 static struct snd_soc_dai_driver wm8727_dai = {
44 .name = "wm8727-hifi",
45 .playback = {
46 .stream_name = "Playback",
47 .channels_min = 2,
48 .channels_max = 2,
49 .rates = WM8727_RATES,
50 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE,
51 },
52 };
53
54 static const struct snd_soc_component_driver soc_component_dev_wm8727 = {
55 .dapm_widgets = wm8727_dapm_widgets,
56 .num_dapm_widgets = ARRAY_SIZE(wm8727_dapm_widgets),
57 .dapm_routes = wm8727_dapm_routes,
58 .num_dapm_routes = ARRAY_SIZE(wm8727_dapm_routes),
59 .idle_bias_on = 1,
60 .use_pmdown_time = 1,
61 .endianness = 1,
62 .non_legacy_dai_naming = 1,
63 };
64
wm8727_probe(struct platform_device * pdev)65 static int wm8727_probe(struct platform_device *pdev)
66 {
67 return devm_snd_soc_register_component(&pdev->dev,
68 &soc_component_dev_wm8727, &wm8727_dai, 1);
69 }
70
71 static struct platform_driver wm8727_codec_driver = {
72 .driver = {
73 .name = "wm8727",
74 },
75
76 .probe = wm8727_probe,
77 };
78
79 module_platform_driver(wm8727_codec_driver);
80
81 MODULE_DESCRIPTION("ASoC wm8727 driver");
82 MODULE_AUTHOR("Neil Jones");
83 MODULE_LICENSE("GPL");
84