diff options
author | Lars-Peter Clausen <lars@metafoo.de> | 2010-06-19 10:52:51 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2010-06-22 19:10:57 -0400 |
commit | 5898dd9ebd158d9fd3c197fc640d0c104bef39a5 (patch) | |
tree | 6f5c03ef1c7861123ea414cb46ba590d0d692a9b /sound/soc/jz4740 | |
parent | 3b097d64eafac6446d3c5d255830e2bbdd17edd3 (diff) |
ASoC: JZ4740: Add qi_lb60 board driver
This patch adds ASoC support for the qi_lb60 board.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/jz4740')
-rw-r--r-- | sound/soc/jz4740/Kconfig | 9 | ||||
-rw-r--r-- | sound/soc/jz4740/Makefile | 4 | ||||
-rw-r--r-- | sound/soc/jz4740/qi_lb60.c | 166 |
3 files changed, 179 insertions, 0 deletions
diff --git a/sound/soc/jz4740/Kconfig b/sound/soc/jz4740/Kconfig index 27480f204ee0..5351cba66c9e 100644 --- a/sound/soc/jz4740/Kconfig +++ b/sound/soc/jz4740/Kconfig | |||
@@ -12,3 +12,12 @@ config SND_JZ4740_SOC_I2S | |||
12 | help | 12 | help |
13 | Say Y if you want to use I2S protocol and I2S codec on Ingenic JZ4740 | 13 | Say Y if you want to use I2S protocol and I2S codec on Ingenic JZ4740 |
14 | based boards. | 14 | based boards. |
15 | |||
16 | config SND_JZ4740_SOC_QI_LB60 | ||
17 | tristate "SoC Audio support for Qi LB60" | ||
18 | depends on SND_JZ4740_SOC && JZ4740_QI_LB60 | ||
19 | select SND_JZ4740_SOC_I2S | ||
20 | select SND_SOC_JZ4740_CODEC | ||
21 | help | ||
22 | Say Y if you want to add support for ASoC audio on the Qi LB60 board | ||
23 | a.k.a Qi Ben NanoNote. | ||
diff --git a/sound/soc/jz4740/Makefile b/sound/soc/jz4740/Makefile index 1be8d192d23f..be873c1b0c20 100644 --- a/sound/soc/jz4740/Makefile +++ b/sound/soc/jz4740/Makefile | |||
@@ -7,3 +7,7 @@ snd-soc-jz4740-i2s-objs := jz4740-i2s.o | |||
7 | obj-$(CONFIG_SND_JZ4740_SOC) += snd-soc-jz4740.o | 7 | obj-$(CONFIG_SND_JZ4740_SOC) += snd-soc-jz4740.o |
8 | obj-$(CONFIG_SND_JZ4740_SOC_I2S) += snd-soc-jz4740-i2s.o | 8 | obj-$(CONFIG_SND_JZ4740_SOC_I2S) += snd-soc-jz4740-i2s.o |
9 | 9 | ||
10 | # Jz4740 Machine Support | ||
11 | snd-soc-qi-lb60-objs := qi_lb60.o | ||
12 | |||
13 | obj-$(CONFIG_SND_JZ4740_SOC_QI_LB60) += snd-soc-qi-lb60.o | ||
diff --git a/sound/soc/jz4740/qi_lb60.c b/sound/soc/jz4740/qi_lb60.c new file mode 100644 index 000000000000..f15f4918f15f --- /dev/null +++ b/sound/soc/jz4740/qi_lb60.c | |||
@@ -0,0 +1,166 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2009, Lars-Peter Clausen <lars@metafoo.de> | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License version 2 as | ||
6 | * published by the Free Software Foundation. | ||
7 | * | ||
8 | * You should have received a copy of the GNU General Public License along | ||
9 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
10 | * 675 Mass Ave, Cambridge, MA 02139, USA. | ||
11 | * | ||
12 | */ | ||
13 | |||
14 | #include <linux/module.h> | ||
15 | #include <linux/moduleparam.h> | ||
16 | #include <linux/timer.h> | ||
17 | #include <linux/interrupt.h> | ||
18 | #include <linux/platform_device.h> | ||
19 | #include <sound/core.h> | ||
20 | #include <sound/pcm.h> | ||
21 | #include <sound/soc.h> | ||
22 | #include <sound/soc-dapm.h> | ||
23 | #include <linux/gpio.h> | ||
24 | |||
25 | #include "../codecs/jz4740.h" | ||
26 | #include "jz4740-pcm.h" | ||
27 | #include "jz4740-i2s.h" | ||
28 | |||
29 | |||
30 | #define QI_LB60_SND_GPIO JZ_GPIO_PORTB(29) | ||
31 | #define QI_LB60_AMP_GPIO JZ_GPIO_PORTD(4) | ||
32 | |||
33 | static int qi_lb60_spk_event(struct snd_soc_dapm_widget *widget, | ||
34 | struct snd_kcontrol *ctrl, int event) | ||
35 | { | ||
36 | int on = 0; | ||
37 | if (event & SND_SOC_DAPM_POST_PMU) | ||
38 | on = 1; | ||
39 | else if (event & SND_SOC_DAPM_PRE_PMD) | ||
40 | on = 0; | ||
41 | |||
42 | gpio_set_value(QI_LB60_SND_GPIO, on); | ||
43 | gpio_set_value(QI_LB60_AMP_GPIO, on); | ||
44 | |||
45 | return 0; | ||
46 | } | ||
47 | |||
48 | static const struct snd_soc_dapm_widget qi_lb60_widgets[] = { | ||
49 | SND_SOC_DAPM_SPK("Speaker", qi_lb60_spk_event), | ||
50 | SND_SOC_DAPM_MIC("Mic", NULL), | ||
51 | }; | ||
52 | |||
53 | static const struct snd_soc_dapm_route qi_lb60_routes[] = { | ||
54 | {"Mic", NULL, "MIC"}, | ||
55 | {"Speaker", NULL, "LOUT"}, | ||
56 | {"Speaker", NULL, "ROUT"}, | ||
57 | }; | ||
58 | |||
59 | #define QI_LB60_DAIFMT (SND_SOC_DAIFMT_I2S | \ | ||
60 | SND_SOC_DAIFMT_NB_NF | \ | ||
61 | SND_SOC_DAIFMT_CBM_CFM) | ||
62 | |||
63 | static int qi_lb60_codec_init(struct snd_soc_codec *codec) | ||
64 | { | ||
65 | int ret; | ||
66 | struct snd_soc_dai *cpu_dai = codec->socdev->card->dai_link->cpu_dai; | ||
67 | |||
68 | snd_soc_dapm_nc_pin(codec, "LIN"); | ||
69 | snd_soc_dapm_nc_pin(codec, "RIN"); | ||
70 | |||
71 | ret = snd_soc_dai_set_fmt(cpu_dai, QI_LB60_DAIFMT); | ||
72 | if (ret < 0) { | ||
73 | dev_err(codec->dev, "Failed to set cpu dai format: %d\n", ret); | ||
74 | return ret; | ||
75 | } | ||
76 | |||
77 | snd_soc_dapm_new_controls(codec, qi_lb60_widgets, ARRAY_SIZE(qi_lb60_widgets)); | ||
78 | snd_soc_dapm_add_routes(codec, qi_lb60_routes, ARRAY_SIZE(qi_lb60_routes)); | ||
79 | snd_soc_dapm_sync(codec); | ||
80 | |||
81 | return 0; | ||
82 | } | ||
83 | |||
84 | static struct snd_soc_dai_link qi_lb60_dai = { | ||
85 | .name = "jz4740", | ||
86 | .stream_name = "jz4740", | ||
87 | .cpu_dai = &jz4740_i2s_dai, | ||
88 | .codec_dai = &jz4740_codec_dai, | ||
89 | .init = qi_lb60_codec_init, | ||
90 | }; | ||
91 | |||
92 | static struct snd_soc_card qi_lb60 = { | ||
93 | .name = "QI LB60", | ||
94 | .dai_link = &qi_lb60_dai, | ||
95 | .num_links = 1, | ||
96 | .platform = &jz4740_soc_platform, | ||
97 | }; | ||
98 | |||
99 | static struct snd_soc_device qi_lb60_snd_devdata = { | ||
100 | .card = &qi_lb60, | ||
101 | .codec_dev = &soc_codec_dev_jz4740_codec, | ||
102 | }; | ||
103 | |||
104 | static struct platform_device *qi_lb60_snd_device; | ||
105 | |||
106 | static int __init qi_lb60_init(void) | ||
107 | { | ||
108 | int ret; | ||
109 | |||
110 | qi_lb60_snd_device = platform_device_alloc("soc-audio", -1); | ||
111 | |||
112 | if (!qi_lb60_snd_device) | ||
113 | return -ENOMEM; | ||
114 | |||
115 | ret = gpio_request(QI_LB60_SND_GPIO, "SND"); | ||
116 | if (ret) { | ||
117 | pr_err("qi_lb60 snd: Failed to request SND GPIO(%d): %d\n", | ||
118 | QI_LB60_SND_GPIO, ret); | ||
119 | goto err_device_put; | ||
120 | } | ||
121 | |||
122 | ret = gpio_request(QI_LB60_AMP_GPIO, "AMP"); | ||
123 | if (ret) { | ||
124 | pr_err("qi_lb60 snd: Failed to request AMP GPIO(%d): %d\n", | ||
125 | QI_LB60_AMP_GPIO, ret); | ||
126 | goto err_gpio_free_snd; | ||
127 | } | ||
128 | |||
129 | gpio_direction_output(QI_LB60_SND_GPIO, 0); | ||
130 | gpio_direction_output(QI_LB60_AMP_GPIO, 0); | ||
131 | |||
132 | platform_set_drvdata(qi_lb60_snd_device, &qi_lb60_snd_devdata); | ||
133 | qi_lb60_snd_devdata.dev = &qi_lb60_snd_device->dev; | ||
134 | |||
135 | ret = platform_device_add(qi_lb60_snd_device); | ||
136 | if (ret) { | ||
137 | pr_err("qi_lb60 snd: Failed to add snd soc device: %d\n", ret); | ||
138 | goto err_unset_pdata; | ||
139 | } | ||
140 | |||
141 | return 0; | ||
142 | |||
143 | err_unset_pdata: | ||
144 | platform_set_drvdata(qi_lb60_snd_device, NULL); | ||
145 | /*err_gpio_free_amp:*/ | ||
146 | gpio_free(QI_LB60_AMP_GPIO); | ||
147 | err_gpio_free_snd: | ||
148 | gpio_free(QI_LB60_SND_GPIO); | ||
149 | err_device_put: | ||
150 | platform_device_put(qi_lb60_snd_device); | ||
151 | |||
152 | return ret; | ||
153 | } | ||
154 | module_init(qi_lb60_init); | ||
155 | |||
156 | static void __exit qi_lb60_exit(void) | ||
157 | { | ||
158 | gpio_free(QI_LB60_AMP_GPIO); | ||
159 | gpio_free(QI_LB60_SND_GPIO); | ||
160 | platform_device_unregister(qi_lb60_snd_device); | ||
161 | } | ||
162 | module_exit(qi_lb60_exit); | ||
163 | |||
164 | MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>"); | ||
165 | MODULE_DESCRIPTION("ALSA SoC QI LB60 Audio support"); | ||
166 | MODULE_LICENSE("GPL v2"); | ||