blob: bb25a75f92a22749c47685e9373b7763c28af0e4 [file] [log] [blame]
Neil Jones89933de2009-11-02 15:14:17 +00001/*
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>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090016#include <linux/slab.h>
Neil Jones89933de2009-11-02 15:14:17 +000017#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/ac97_codec.h>
23#include <sound/initval.h>
24#include <sound/soc.h>
25
Mark Brown72a061f2013-08-18 18:35:54 +010026static const struct snd_soc_dapm_widget wm8727_dapm_widgets[] = {
27SND_SOC_DAPM_OUTPUT("VOUTL"),
28SND_SOC_DAPM_OUTPUT("VOUTR"),
29};
30
31static const struct snd_soc_dapm_route wm8727_dapm_routes[] = {
32 { "VOUTL", NULL, "Playback" },
33 { "VOUTR", NULL, "Playback" },
34};
35
Neil Jones89933de2009-11-02 15:14:17 +000036/*
37 * Note this is a simple chip with no configuration interface, sample rate is
38 * determined automatically by examining the Master clock and Bit clock ratios
39 */
40#define WM8727_RATES (SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |\
41 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |\
42 SNDRV_PCM_RATE_192000)
43
44
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000045static struct snd_soc_dai_driver wm8727_dai = {
46 .name = "wm8727-hifi",
Neil Jones89933de2009-11-02 15:14:17 +000047 .playback = {
48 .stream_name = "Playback",
49 .channels_min = 2,
50 .channels_max = 2,
51 .rates = WM8727_RATES,
52 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE,
53 },
54};
Neil Jones89933de2009-11-02 15:14:17 +000055
Mark Brown72a061f2013-08-18 18:35:54 +010056static struct snd_soc_codec_driver soc_codec_dev_wm8727 = {
57 .dapm_widgets = wm8727_dapm_widgets,
58 .num_dapm_widgets = ARRAY_SIZE(wm8727_dapm_widgets),
59 .dapm_routes = wm8727_dapm_routes,
60 .num_dapm_routes = ARRAY_SIZE(wm8727_dapm_routes),
61};
Mark Browncce2e9d2009-12-08 21:50:01 +000062
Bill Pemberton7a79e942012-12-07 09:26:37 -050063static int wm8727_probe(struct platform_device *pdev)
Neil Jones89933de2009-11-02 15:14:17 +000064{
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000065 return snd_soc_register_codec(&pdev->dev,
66 &soc_codec_dev_wm8727, &wm8727_dai, 1);
Neil Jones89933de2009-11-02 15:14:17 +000067}
68
Bill Pemberton7a79e942012-12-07 09:26:37 -050069static int wm8727_remove(struct platform_device *pdev)
Neil Jones89933de2009-11-02 15:14:17 +000070{
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000071 snd_soc_unregister_codec(&pdev->dev);
Neil Jones89933de2009-11-02 15:14:17 +000072 return 0;
73}
74
Mark Brown529697c2009-11-03 22:13:30 +000075static struct platform_driver wm8727_codec_driver = {
Neil Jones89933de2009-11-02 15:14:17 +000076 .driver = {
Mark Brown091edcc2011-12-02 22:08:49 +000077 .name = "wm8727",
Neil Jones89933de2009-11-02 15:14:17 +000078 },
79
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000080 .probe = wm8727_probe,
Bill Pemberton7a79e942012-12-07 09:26:37 -050081 .remove = wm8727_remove,
Neil Jones89933de2009-11-02 15:14:17 +000082};
83
Mark Brown5bbcc3c2011-11-23 22:52:08 +000084module_platform_driver(wm8727_codec_driver);
Neil Jones89933de2009-11-02 15:14:17 +000085
86MODULE_DESCRIPTION("ASoC wm8727 driver");
87MODULE_AUTHOR("Neil Jones");
88MODULE_LICENSE("GPL");