diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2013-04-12 08:56:52 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2013-04-12 08:56:52 -0400 |
commit | 0680fa6c25d283d218cbb7760083c0d7ffb6d31c (patch) | |
tree | b731746e2a63ab3331ab81dc39f388e7cfceae7c | |
parent | f1cc981b0257f0e0459137e61d13c4fe7652499b (diff) | |
parent | cc289be8c913006a43275dfd8ed4ac56b43140a8 (diff) |
Merge remote-tracking branch 'asoc/topic/ak5386' into asoc-next
-rw-r--r-- | Documentation/devicetree/bindings/sound/ak5386.txt | 19 | ||||
-rw-r--r-- | sound/soc/codecs/Kconfig | 4 | ||||
-rw-r--r-- | sound/soc/codecs/Makefile | 2 | ||||
-rw-r--r-- | sound/soc/codecs/ak5386.c | 152 |
4 files changed, 177 insertions, 0 deletions
diff --git a/Documentation/devicetree/bindings/sound/ak5386.txt b/Documentation/devicetree/bindings/sound/ak5386.txt new file mode 100644 index 000000000000..dc3914fe6ce8 --- /dev/null +++ b/Documentation/devicetree/bindings/sound/ak5386.txt | |||
@@ -0,0 +1,19 @@ | |||
1 | AK5386 Single-ended 24-Bit 192kHz delta-sigma ADC | ||
2 | |||
3 | This device has no control interface. | ||
4 | |||
5 | Required properties: | ||
6 | |||
7 | - compatible : "asahi-kasei,ak5386" | ||
8 | |||
9 | Optional properties: | ||
10 | |||
11 | - reset-gpio : a GPIO spec for the reset/power down pin. | ||
12 | If specified, it will be deasserted at probe time. | ||
13 | |||
14 | Example: | ||
15 | |||
16 | spdif: ak5386@0 { | ||
17 | compatible = "asahi-kasei,ak5386"; | ||
18 | reset-gpio = <&gpio0 23>; | ||
19 | }; | ||
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index 45b72561c615..500f666c3875 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig | |||
@@ -26,6 +26,7 @@ config SND_SOC_ALL_CODECS | |||
26 | select SND_SOC_AK4641 if I2C | 26 | select SND_SOC_AK4641 if I2C |
27 | select SND_SOC_AK4642 if I2C | 27 | select SND_SOC_AK4642 if I2C |
28 | select SND_SOC_AK4671 if I2C | 28 | select SND_SOC_AK4671 if I2C |
29 | select SND_SOC_AK5386 | ||
29 | select SND_SOC_ALC5623 if I2C | 30 | select SND_SOC_ALC5623 if I2C |
30 | select SND_SOC_ALC5632 if I2C | 31 | select SND_SOC_ALC5632 if I2C |
31 | select SND_SOC_CQ0093VC if MFD_DAVINCI_VOICECODEC | 32 | select SND_SOC_CQ0093VC if MFD_DAVINCI_VOICECODEC |
@@ -203,6 +204,9 @@ config SND_SOC_AK4642 | |||
203 | config SND_SOC_AK4671 | 204 | config SND_SOC_AK4671 |
204 | tristate | 205 | tristate |
205 | 206 | ||
207 | config SND_SOC_AK5386 | ||
208 | tristate | ||
209 | |||
206 | config SND_SOC_ALC5623 | 210 | config SND_SOC_ALC5623 |
207 | tristate | 211 | tristate |
208 | config SND_SOC_ALC5632 | 212 | config SND_SOC_ALC5632 |
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index 6a3b3c3b8b41..3a7ec1c39741 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile | |||
@@ -14,6 +14,7 @@ snd-soc-ak4535-objs := ak4535.o | |||
14 | snd-soc-ak4641-objs := ak4641.o | 14 | snd-soc-ak4641-objs := ak4641.o |
15 | snd-soc-ak4642-objs := ak4642.o | 15 | snd-soc-ak4642-objs := ak4642.o |
16 | snd-soc-ak4671-objs := ak4671.o | 16 | snd-soc-ak4671-objs := ak4671.o |
17 | snd-soc-ak5386-objs := ak5386.o | ||
17 | snd-soc-arizona-objs := arizona.o | 18 | snd-soc-arizona-objs := arizona.o |
18 | snd-soc-cq93vc-objs := cq93vc.o | 19 | snd-soc-cq93vc-objs := cq93vc.o |
19 | snd-soc-cs42l51-objs := cs42l51.o | 20 | snd-soc-cs42l51-objs := cs42l51.o |
@@ -137,6 +138,7 @@ obj-$(CONFIG_SND_SOC_AK4535) += snd-soc-ak4535.o | |||
137 | obj-$(CONFIG_SND_SOC_AK4641) += snd-soc-ak4641.o | 138 | obj-$(CONFIG_SND_SOC_AK4641) += snd-soc-ak4641.o |
138 | obj-$(CONFIG_SND_SOC_AK4642) += snd-soc-ak4642.o | 139 | obj-$(CONFIG_SND_SOC_AK4642) += snd-soc-ak4642.o |
139 | obj-$(CONFIG_SND_SOC_AK4671) += snd-soc-ak4671.o | 140 | obj-$(CONFIG_SND_SOC_AK4671) += snd-soc-ak4671.o |
141 | obj-$(CONFIG_SND_SOC_AK5386) += snd-soc-ak5386.o | ||
140 | obj-$(CONFIG_SND_SOC_ALC5623) += snd-soc-alc5623.o | 142 | obj-$(CONFIG_SND_SOC_ALC5623) += snd-soc-alc5623.o |
141 | obj-$(CONFIG_SND_SOC_ALC5632) += snd-soc-alc5632.o | 143 | obj-$(CONFIG_SND_SOC_ALC5632) += snd-soc-alc5632.o |
142 | obj-$(CONFIG_SND_SOC_ARIZONA) += snd-soc-arizona.o | 144 | obj-$(CONFIG_SND_SOC_ARIZONA) += snd-soc-arizona.o |
diff --git a/sound/soc/codecs/ak5386.c b/sound/soc/codecs/ak5386.c new file mode 100644 index 000000000000..1f303983ae02 --- /dev/null +++ b/sound/soc/codecs/ak5386.c | |||
@@ -0,0 +1,152 @@ | |||
1 | /* | ||
2 | * ALSA SoC driver for | ||
3 | * Asahi Kasei AK5386 Single-ended 24-Bit 192kHz delta-sigma ADC | ||
4 | * | ||
5 | * (c) 2013 Daniel Mack <zonque@gmail.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License version 2 as | ||
9 | * published by the Free Software Foundation. | ||
10 | */ | ||
11 | |||
12 | #include <linux/module.h> | ||
13 | #include <linux/slab.h> | ||
14 | #include <linux/of.h> | ||
15 | #include <linux/of_gpio.h> | ||
16 | #include <linux/of_device.h> | ||
17 | #include <sound/soc.h> | ||
18 | #include <sound/pcm.h> | ||
19 | #include <sound/initval.h> | ||
20 | |||
21 | struct ak5386_priv { | ||
22 | int reset_gpio; | ||
23 | }; | ||
24 | |||
25 | static struct snd_soc_codec_driver soc_codec_ak5386; | ||
26 | |||
27 | static int ak5386_set_dai_fmt(struct snd_soc_dai *codec_dai, | ||
28 | unsigned int format) | ||
29 | { | ||
30 | struct snd_soc_codec *codec = codec_dai->codec; | ||
31 | |||
32 | format &= SND_SOC_DAIFMT_FORMAT_MASK; | ||
33 | if (format != SND_SOC_DAIFMT_LEFT_J && | ||
34 | format != SND_SOC_DAIFMT_I2S) { | ||
35 | dev_err(codec->dev, "Invalid DAI format\n"); | ||
36 | return -EINVAL; | ||
37 | } | ||
38 | |||
39 | return 0; | ||
40 | } | ||
41 | |||
42 | static int ak5386_hw_params(struct snd_pcm_substream *substream, | ||
43 | struct snd_pcm_hw_params *params, | ||
44 | struct snd_soc_dai *dai) | ||
45 | { | ||
46 | struct snd_soc_codec *codec = dai->codec; | ||
47 | struct ak5386_priv *priv = snd_soc_codec_get_drvdata(codec); | ||
48 | |||
49 | /* | ||
50 | * From the datasheet: | ||
51 | * | ||
52 | * All external clocks (MCLK, SCLK and LRCK) must be present unless | ||
53 | * PDN pin = āLā. If these clocks are not provided, the AK5386 may | ||
54 | * draw excess current due to its use of internal dynamically | ||
55 | * refreshed logic. If the external clocks are not present, place | ||
56 | * the AK5386 in power-down mode (PDN pin = āLā). | ||
57 | */ | ||
58 | |||
59 | if (gpio_is_valid(priv->reset_gpio)) | ||
60 | gpio_set_value(priv->reset_gpio, 1); | ||
61 | |||
62 | return 0; | ||
63 | } | ||
64 | |||
65 | static int ak5386_hw_free(struct snd_pcm_substream *substream, | ||
66 | struct snd_soc_dai *dai) | ||
67 | { | ||
68 | struct snd_soc_codec *codec = dai->codec; | ||
69 | struct ak5386_priv *priv = snd_soc_codec_get_drvdata(codec); | ||
70 | |||
71 | if (gpio_is_valid(priv->reset_gpio)) | ||
72 | gpio_set_value(priv->reset_gpio, 0); | ||
73 | |||
74 | return 0; | ||
75 | } | ||
76 | |||
77 | static const struct snd_soc_dai_ops ak5386_dai_ops = { | ||
78 | .set_fmt = ak5386_set_dai_fmt, | ||
79 | .hw_params = ak5386_hw_params, | ||
80 | .hw_free = ak5386_hw_free, | ||
81 | }; | ||
82 | |||
83 | static struct snd_soc_dai_driver ak5386_dai = { | ||
84 | .name = "ak5386-hifi", | ||
85 | .capture = { | ||
86 | .stream_name = "Capture", | ||
87 | .channels_min = 1, | ||
88 | .channels_max = 2, | ||
89 | .rates = SNDRV_PCM_RATE_8000_192000, | ||
90 | .formats = SNDRV_PCM_FMTBIT_S8 | | ||
91 | SNDRV_PCM_FMTBIT_S16_LE | | ||
92 | SNDRV_PCM_FMTBIT_S24_LE | | ||
93 | SNDRV_PCM_FMTBIT_S24_3LE, | ||
94 | }, | ||
95 | .ops = &ak5386_dai_ops, | ||
96 | }; | ||
97 | |||
98 | #ifdef CONFIG_OF | ||
99 | static const struct of_device_id ak5386_dt_ids[] = { | ||
100 | { .compatible = "asahi-kasei,ak5386", }, | ||
101 | { } | ||
102 | }; | ||
103 | MODULE_DEVICE_TABLE(of, ak5386_dt_ids); | ||
104 | #endif | ||
105 | |||
106 | static int ak5386_probe(struct platform_device *pdev) | ||
107 | { | ||
108 | struct device *dev = &pdev->dev; | ||
109 | struct ak5386_priv *priv; | ||
110 | |||
111 | priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); | ||
112 | if (!priv) | ||
113 | return -ENOMEM; | ||
114 | |||
115 | priv->reset_gpio = -EINVAL; | ||
116 | dev_set_drvdata(dev, priv); | ||
117 | |||
118 | if (of_match_device(of_match_ptr(ak5386_dt_ids), dev)) | ||
119 | priv->reset_gpio = of_get_named_gpio(dev->of_node, | ||
120 | "reset-gpio", 0); | ||
121 | |||
122 | if (gpio_is_valid(priv->reset_gpio)) | ||
123 | if (devm_gpio_request_one(dev, priv->reset_gpio, | ||
124 | GPIOF_OUT_INIT_LOW, | ||
125 | "AK5386 Reset")) | ||
126 | priv->reset_gpio = -EINVAL; | ||
127 | |||
128 | return snd_soc_register_codec(dev, &soc_codec_ak5386, | ||
129 | &ak5386_dai, 1); | ||
130 | } | ||
131 | |||
132 | static int ak5386_remove(struct platform_device *pdev) | ||
133 | { | ||
134 | snd_soc_unregister_codec(&pdev->dev); | ||
135 | return 0; | ||
136 | } | ||
137 | |||
138 | static struct platform_driver ak5386_driver = { | ||
139 | .probe = ak5386_probe, | ||
140 | .remove = ak5386_remove, | ||
141 | .driver = { | ||
142 | .name = "ak5386", | ||
143 | .owner = THIS_MODULE, | ||
144 | .of_match_table = of_match_ptr(ak5386_dt_ids), | ||
145 | }, | ||
146 | }; | ||
147 | |||
148 | module_platform_driver(ak5386_driver); | ||
149 | |||
150 | MODULE_DESCRIPTION("ASoC driver for AK5386 ADC"); | ||
151 | MODULE_AUTHOR("Daniel Mack <zonque@gmail.com>"); | ||
152 | MODULE_LICENSE("GPL"); | ||