e33173a557c8b10a4475b8d4016f1540f522301c
[openwrt/staging/jogo.git] /
1 From 3150326498ba9388b85e5af2c8fcfeafc46eeaad Mon Sep 17 00:00:00 2001
2 From: GT <dev@3d-lab-av.com>
3 Date: Sat, 6 Apr 2019 21:16:39 +0100
4 Subject: [PATCH 495/806] ASoC: decommissioning driver for 3Dlab Nano soundcard
5
6 ---
7 .../overlays/3dlab-nano-player-overlay.dts | 32 --
8 arch/arm/boot/dts/overlays/Makefile | 1 -
9 arch/arm/boot/dts/overlays/README | 6 -
10 sound/soc/bcm/3dlab-nano-player.c | 370 ------------------
11 sound/soc/bcm/Kconfig | 6 -
12 sound/soc/bcm/Makefile | 6 +-
13 8 files changed, 2 insertions(+), 421 deletions(-)
14 delete mode 100644 arch/arm/boot/dts/overlays/3dlab-nano-player-overlay.dts
15 delete mode 100644 sound/soc/bcm/3dlab-nano-player.c
16
17 --- a/arch/arm/boot/dts/overlays/3dlab-nano-player-overlay.dts
18 +++ /dev/null
19 @@ -1,32 +0,0 @@
20 -// Definitions for 3Dlab Nano Player
21 -/dts-v1/;
22 -/plugin/;
23 -
24 -/ {
25 - compatible = "brcm,bcm2708";
26 -
27 - fragment@0 {
28 - target = <&i2s>;
29 - __overlay__ {
30 - status = "okay";
31 - };
32 - };
33 -
34 - fragment@1 {
35 - target = <&i2c>;
36 - __overlay__ {
37 - #address-cells = <1>;
38 - #size-cells = <0>;
39 - status = "okay";
40 -
41 - nano-player@41 {
42 - compatible = "3dlab,nano-player";
43 - reg = <0x41>;
44 - i2s-controller = <&i2s>;
45 - status = "okay";
46 - };
47 - };
48 - };
49 -};
50 -
51 -// EOF
52 --- a/arch/arm/boot/dts/overlays/Makefile
53 +++ b/arch/arm/boot/dts/overlays/Makefile
54 @@ -1,7 +1,6 @@
55 # Overlays for the Raspberry Pi platform
56
57 dtbo-$(CONFIG_ARCH_BCM2835) += \
58 - 3dlab-nano-player.dtbo \
59 adau1977-adc.dtbo \
60 adau7002-simple.dtbo \
61 ads1015.dtbo \
62 --- a/arch/arm/boot/dts/overlays/README
63 +++ b/arch/arm/boot/dts/overlays/README
64 @@ -205,12 +205,6 @@ Params:
65 and the other i2c baudrate parameters.
66
67
68 -Name: 3dlab-nano-player
69 -Info: Configures the 3Dlab Nano Player
70 -Load: dtoverlay=3dlab-nano-player
71 -Params: <None>
72 -
73 -
74 Name: adau1977-adc
75 Info: Overlay for activation of ADAU1977 ADC codec over I2C for control
76 and I2S for data.
77 --- a/sound/soc/bcm/3dlab-nano-player.c
78 +++ /dev/null
79 @@ -1,370 +0,0 @@
80 -/*
81 - * 3Dlab Nano Player ALSA SoC Audio driver.
82 - *
83 - * Copyright (C) 2018 3Dlab.
84 - *
85 - * Author: GT <dev@3d-lab-av.com>
86 - *
87 - * This program is free software; you can redistribute it and/or
88 - * modify it under the terms of the GNU General Public License
89 - * version 2 as published by the Free Software Foundation.
90 - *
91 - * This program is distributed in the hope that it will be useful, but
92 - * WITHOUT ANY WARRANTY; without even the implied warranty of
93 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
94 - * General Public License for more details.
95 - */
96 -
97 -#include <linux/module.h>
98 -#include <linux/i2c.h>
99 -#include <sound/soc.h>
100 -#include <sound/pcm.h>
101 -#include <sound/pcm_params.h>
102 -#include <sound/control.h>
103 -
104 -#define NANO_ID 0x00
105 -#define NANO_VER 0x01
106 -#define NANO_CFG 0x02
107 -#define NANO_STATUS 0x03
108 -#define NANO_SPI_ADDR 0x04
109 -#define NANO_SPI_DATA 0x05
110 -
111 -#define NANO_ID_VAL 0x3D
112 -#define NANO_CFG_OFF 0x00
113 -#define NANO_CFG_MULT1 0
114 -#define NANO_CFG_MULT2 1
115 -#define NANO_CFG_MULT4 2
116 -#define NANO_CFG_MULT8 3
117 -#define NANO_CFG_MULT16 4
118 -#define NANO_CFG_CLK22 0
119 -#define NANO_CFG_CLK24 BIT(3)
120 -#define NANO_CFG_DSD BIT(4)
121 -#define NANO_CFG_ENA BIT(5)
122 -#define NANO_CFG_BLINK BIT(6)
123 -#define NANO_STATUS_P1 BIT(0)
124 -#define NANO_STATUS_P2 BIT(1)
125 -#define NANO_STATUS_FLG BIT(2)
126 -#define NANO_STATUS_CLK BIT(3)
127 -#define NANO_SPI_READ 0
128 -#define NANO_SPI_WRITE BIT(5)
129 -
130 -#define NANO_DAC_CTRL1 0x00
131 -#define NANO_DAC_CTRL2 0x01
132 -#define NANO_DAC_CTRL3 0x02
133 -#define NANO_DAC_LATT 0x03
134 -#define NANO_DAC_RATT 0x04
135 -
136 -#define NANO_CTRL2_VAL 0x22
137 -
138 -static int nano_player_spi_write(struct regmap *map,
139 - unsigned int reg, unsigned int val)
140 -{
141 - /* indirect register access */
142 - regmap_write(map, NANO_SPI_DATA, val);
143 - regmap_write(map, NANO_SPI_ADDR, reg | NANO_SPI_WRITE);
144 - return 0;
145 -}
146 -
147 -static int nano_player_ctrl_info(struct snd_kcontrol *kcontrol,
148 - struct snd_ctl_elem_info *uinfo)
149 -{
150 - /* describe control element */
151 - if (strstr(kcontrol->id.name, "Volume")) {
152 - uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
153 - uinfo->count = 1;
154 - uinfo->value.integer.min = 0;
155 - uinfo->value.integer.max = 100;
156 - } else {
157 - uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
158 - uinfo->count = 1;
159 - uinfo->value.integer.min = 0;
160 - uinfo->value.integer.max = 1;
161 - }
162 -
163 - return 0;
164 -}
165 -
166 -static int nano_player_ctrl_put(struct snd_kcontrol *kcontrol,
167 - struct snd_ctl_elem_value *ucontrol)
168 -{
169 - /* program control value to hardware */
170 - struct snd_soc_card *card = snd_kcontrol_chip(kcontrol);
171 - struct regmap *regmap = snd_soc_card_get_drvdata(card);
172 -
173 - if (strstr(kcontrol->id.name, "Volume")) {
174 - unsigned int vol = ucontrol->value.integer.value[0];
175 - unsigned int att = 255 - (2 * (100 - vol));
176 -
177 - nano_player_spi_write(regmap, NANO_DAC_LATT, att);
178 - nano_player_spi_write(regmap, NANO_DAC_RATT, att);
179 - kcontrol->private_value = vol;
180 - } else {
181 - unsigned int mute = ucontrol->value.integer.value[0];
182 - unsigned int reg = NANO_CTRL2_VAL | mute;
183 -
184 - nano_player_spi_write(regmap, NANO_DAC_CTRL2, reg);
185 - kcontrol->private_value = mute;
186 - }
187 - return 0;
188 -}
189 -
190 -static int nano_player_ctrl_get(struct snd_kcontrol *kcontrol,
191 - struct snd_ctl_elem_value *ucontrol)
192 -{
193 - /* return last programmed value */
194 - ucontrol->value.integer.value[0] = kcontrol->private_value;
195 - return 0;
196 -}
197 -
198 -#define SOC_NANO_PLAYER_CTRL(xname) \
199 -{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
200 - .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
201 - .info = nano_player_ctrl_info, \
202 - .put = nano_player_ctrl_put, \
203 - .get = nano_player_ctrl_get }
204 -
205 -static const struct snd_kcontrol_new nano_player_controls[] = {
206 - SOC_NANO_PLAYER_CTRL("Master Playback Volume"),
207 - SOC_NANO_PLAYER_CTRL("Master Playback Switch"),
208 -};
209 -
210 -static const unsigned int nano_player_rates[] = {
211 - 44100, 48000, 88200, 96000, 176400, 192000, 352800, 384000,
212 - 705600, 768000 /* only possible with fast clocks */
213 -};
214 -
215 -static struct snd_pcm_hw_constraint_list nano_player_constraint_rates = {
216 - .list = nano_player_rates,
217 - .count = ARRAY_SIZE(nano_player_rates),
218 -};
219 -
220 -static int nano_player_init(struct snd_soc_pcm_runtime *rtd)
221 -{
222 - struct snd_soc_card *card = rtd->card;
223 - struct regmap *regmap = snd_soc_card_get_drvdata(card);
224 - struct snd_soc_pcm_stream *cpu = &rtd->cpu_dai->driver->playback;
225 - struct snd_soc_pcm_stream *codec = &rtd->codec_dai->driver->playback;
226 - unsigned int sample_bits = 32;
227 - unsigned int val;
228 -
229 - /* configure cpu dai */
230 - cpu->formats |= SNDRV_PCM_FMTBIT_DSD_U32_LE;
231 - cpu->rate_max = 768000;
232 -
233 - /* configure dummy codec dai */
234 - codec->rate_min = 44100;
235 - codec->rates = SNDRV_PCM_RATE_KNOT;
236 - codec->formats = SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_DSD_U32_LE;
237 -
238 - /* configure max supported rate */
239 - regmap_read(regmap, NANO_STATUS, &val);
240 - if (val & NANO_STATUS_CLK) {
241 - dev_notice(card->dev, "Board with fast clocks installed\n");
242 - codec->rate_max = 768000;
243 - } else {
244 - dev_notice(card->dev, "Board with normal clocks installed\n");
245 - codec->rate_max = 384000;
246 - }
247 -
248 - /* frame length enforced by hardware */
249 - return snd_soc_dai_set_bclk_ratio(rtd->cpu_dai, sample_bits * 2);
250 -}
251 -
252 -static int nano_player_startup(struct snd_pcm_substream *substream)
253 -{
254 - return snd_pcm_hw_constraint_list(substream->runtime, 0,
255 - SNDRV_PCM_HW_PARAM_RATE,
256 - &nano_player_constraint_rates);
257 -}
258 -
259 -static int nano_player_hw_params(struct snd_pcm_substream *substream,
260 - struct snd_pcm_hw_params *params)
261 -{
262 - struct snd_soc_pcm_runtime *rtd = substream->private_data;
263 - struct snd_soc_card *card = rtd->card;
264 - struct regmap *regmap = snd_soc_card_get_drvdata(card);
265 - unsigned int config = NANO_CFG_ENA;
266 - struct snd_mask *fmt;
267 -
268 - /* configure PCM or DSD */
269 - fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
270 - if (snd_mask_test(fmt, SNDRV_PCM_FORMAT_DSD_U32_LE)) {
271 - /* embed DSD in PCM data */
272 - snd_mask_none(fmt);
273 - snd_mask_set(fmt, SNDRV_PCM_FORMAT_S32_LE);
274 - /* enable DSD mode */
275 - config |= NANO_CFG_DSD;
276 - }
277 -
278 - /* configure clocks */
279 - switch (params_rate(params)) {
280 - case 44100:
281 - config |= NANO_CFG_MULT1 | NANO_CFG_CLK22;
282 - break;
283 - case 88200:
284 - config |= NANO_CFG_MULT2 | NANO_CFG_CLK22;
285 - break;
286 - case 176400:
287 - config |= NANO_CFG_MULT4 | NANO_CFG_CLK22;
288 - break;
289 - case 352800:
290 - config |= NANO_CFG_MULT8 | NANO_CFG_CLK22;
291 - break;
292 - case 705600:
293 - config |= NANO_CFG_MULT16 | NANO_CFG_CLK22;
294 - break;
295 - case 48000:
296 - config |= NANO_CFG_MULT1 | NANO_CFG_CLK24;
297 - break;
298 - case 96000:
299 - config |= NANO_CFG_MULT2 | NANO_CFG_CLK24;
300 - break;
301 - case 192000:
302 - config |= NANO_CFG_MULT4 | NANO_CFG_CLK24;
303 - break;
304 - case 384000:
305 - config |= NANO_CFG_MULT8 | NANO_CFG_CLK24;
306 - break;
307 - case 768000:
308 - config |= NANO_CFG_MULT16 | NANO_CFG_CLK24;
309 - break;
310 - default:
311 - return -EINVAL;
312 - }
313 -
314 - dev_dbg(card->dev, "Send CFG register 0x%02X\n", config);
315 - return regmap_write(regmap, NANO_CFG, config);
316 -}
317 -
318 -static struct snd_soc_ops nano_player_ops = {
319 - .startup = nano_player_startup,
320 - .hw_params = nano_player_hw_params,
321 -};
322 -
323 -static struct snd_soc_dai_link nano_player_link = {
324 - .name = "3Dlab Nano Player",
325 - .stream_name = "3Dlab Nano Player HiFi",
326 - .platform_name = "bcm2708-i2s.0",
327 - .cpu_dai_name = "bcm2708-i2s.0",
328 - .codec_name = "snd-soc-dummy",
329 - .codec_dai_name = "snd-soc-dummy-dai",
330 - .dai_fmt = SND_SOC_DAIFMT_I2S |
331 - SND_SOC_DAIFMT_CONT |
332 - SND_SOC_DAIFMT_NB_NF |
333 - SND_SOC_DAIFMT_CBM_CFM,
334 - .init = nano_player_init,
335 - .ops = &nano_player_ops,
336 -};
337 -
338 -static const struct regmap_config nano_player_regmap = {
339 - .reg_bits = 8,
340 - .val_bits = 8,
341 - .max_register = 128,
342 - .cache_type = REGCACHE_RBTREE,
343 -};
344 -
345 -static int nano_player_card_probe(struct snd_soc_card *card)
346 -{
347 - struct regmap *regmap = snd_soc_card_get_drvdata(card);
348 - unsigned int val;
349 -
350 - /* check hardware integrity */
351 - regmap_read(regmap, NANO_ID, &val);
352 - if (val != NANO_ID_VAL) {
353 - dev_err(card->dev, "Invalid ID register 0x%02X\n", val);
354 - return -ENODEV;
355 - }
356 -
357 - /* report version to the user */
358 - regmap_read(regmap, NANO_VER, &val);
359 - dev_notice(card->dev, "Started 3Dlab Nano Player driver (v%d)\n", val);
360 -
361 - /* enable internal audio bus and blink status LED */
362 - return regmap_write(regmap, NANO_CFG, NANO_CFG_ENA | NANO_CFG_BLINK);
363 -}
364 -
365 -static int nano_player_card_remove(struct snd_soc_card *card)
366 -{
367 - /* disable internal audio bus */
368 - struct regmap *regmap = snd_soc_card_get_drvdata(card);
369 -
370 - return regmap_write(regmap, NANO_CFG, NANO_CFG_OFF);
371 -}
372 -
373 -static struct snd_soc_card nano_player_card = {
374 - .name = "3Dlab_Nano_Player",
375 - .owner = THIS_MODULE,
376 - .dai_link = &nano_player_link,
377 - .num_links = 1,
378 - .controls = nano_player_controls,
379 - .num_controls = ARRAY_SIZE(nano_player_controls),
380 - .probe = nano_player_card_probe,
381 - .remove = nano_player_card_remove,
382 -};
383 -
384 -static int nano_player_i2c_probe(struct i2c_client *i2c,
385 - const struct i2c_device_id *id)
386 -{
387 - struct regmap *regmap;
388 - int ret;
389 -
390 - regmap = devm_regmap_init_i2c(i2c, &nano_player_regmap);
391 - if (IS_ERR(regmap)) {
392 - ret = PTR_ERR(regmap);
393 - dev_err(&i2c->dev, "Failed to init regmap %d\n", ret);
394 - return ret;
395 - }
396 -
397 - if (i2c->dev.of_node) {
398 - struct snd_soc_dai_link *dai = &nano_player_link;
399 - struct device_node *node;
400 -
401 - /* cpu handle configured by device tree */
402 - node = of_parse_phandle(i2c->dev.of_node, "i2s-controller", 0);
403 - if (node) {
404 - dai->platform_name = NULL;
405 - dai->platform_of_node = node;
406 - dai->cpu_dai_name = NULL;
407 - dai->cpu_of_node = node;
408 - }
409 - }
410 -
411 - nano_player_card.dev = &i2c->dev;
412 - snd_soc_card_set_drvdata(&nano_player_card, regmap);
413 - ret = devm_snd_soc_register_card(&i2c->dev, &nano_player_card);
414 -
415 - if (ret && ret != -EPROBE_DEFER)
416 - dev_err(&i2c->dev, "Failed to register card %d\n", ret);
417 -
418 - return ret;
419 -}
420 -
421 -static const struct of_device_id nano_player_of_match[] = {
422 - { .compatible = "3dlab,nano-player", },
423 - { }
424 -};
425 -MODULE_DEVICE_TABLE(of, nano_player_of_match);
426 -
427 -static const struct i2c_device_id nano_player_i2c_id[] = {
428 - { "nano-player", 0 },
429 - { }
430 -};
431 -MODULE_DEVICE_TABLE(i2c, nano_player_i2c_id);
432 -
433 -static struct i2c_driver nano_player_i2c_driver = {
434 - .probe = nano_player_i2c_probe,
435 - .id_table = nano_player_i2c_id,
436 - .driver = {
437 - .name = "nano-player",
438 - .owner = THIS_MODULE,
439 - .of_match_table = nano_player_of_match,
440 - },
441 -};
442 -
443 -module_i2c_driver(nano_player_i2c_driver);
444 -
445 -MODULE_DESCRIPTION("ASoC 3Dlab Nano Player driver");
446 -MODULE_AUTHOR("GT <dev@3d-lab-av.com>");
447 -MODULE_LICENSE("GPL v2");
448 -
449 -/* EOF */
450 --- a/sound/soc/bcm/Kconfig
451 +++ b/sound/soc/bcm/Kconfig
452 @@ -17,12 +17,6 @@ config SND_SOC_CYGNUS
453
454 If you don't know what to do here, say N.
455
456 -config SND_BCM2708_SOC_3DLAB_NANO_PLAYER
457 - tristate "Support for 3Dlab Nano Player"
458 - depends on SND_BCM2708_SOC_I2S || SND_BCM2835_SOC_I2S
459 - help
460 - Say Y or M if you want to add support for 3Dlab Nano Player.
461 -
462 config SND_BCM2708_SOC_GOOGLEVOICEHAT_SOUNDCARD
463 tristate "Support for Google voiceHAT soundcard"
464 depends on SND_BCM2708_SOC_I2S || SND_BCM2835_SOC_I2S
465 --- a/sound/soc/bcm/Makefile
466 +++ b/sound/soc/bcm/Makefile
467 @@ -12,7 +12,6 @@ obj-$(CONFIG_SND_SOC_CYGNUS) += snd-soc-
468 snd-soc-googlevoicehat-codec-objs := googlevoicehat-codec.o
469
470 # BCM2708 Machine Support
471 -snd-soc-3dlab-nano-player-objs := 3dlab-nano-player.o
472 snd-soc-hifiberry-dacplus-objs := hifiberry_dacplus.o
473 snd-soc-hifiberry-dacplusadc-objs := hifiberry_dacplusadc.o
474 snd-soc-justboom-dac-objs := justboom-dac.o
475 @@ -20,7 +19,7 @@ snd-soc-rpi-cirrus-objs := rpi-cirrus.o
476 snd-soc-rpi-proto-objs := rpi-proto.o
477 snd-soc-iqaudio-codec-objs := iqaudio-codec.o
478 snd-soc-iqaudio-dac-objs := iqaudio-dac.o
479 - snd-soc-i-sabre-q2m-objs := i-sabre-q2m.o
480 +snd-soc-i-sabre-q2m-objs := i-sabre-q2m.o
481 snd-soc-audioinjector-pi-soundcard-objs := audioinjector-pi-soundcard.o
482 snd-soc-audioinjector-octo-soundcard-objs := audioinjector-octo-soundcard.o
483 snd-soc-audiosense-pi-objs := audiosense-pi.o
484 @@ -36,7 +35,6 @@ snd-soc-fe-pi-audio-objs := fe-pi-audio.
485 snd-soc-rpi-simple-soundcard-objs := rpi-simple-soundcard.o
486 snd-soc-rpi-wm8804-soundcard-objs := rpi-wm8804-soundcard.o
487
488 -obj-$(CONFIG_SND_BCM2708_SOC_3DLAB_NANO_PLAYER) += snd-soc-3dlab-nano-player.o
489 obj-$(CONFIG_SND_BCM2708_SOC_GOOGLEVOICEHAT_SOUNDCARD) += snd-soc-googlevoicehat-codec.o
490 obj-$(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUS) += snd-soc-hifiberry-dacplus.o
491 obj-$(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUSADC) += snd-soc-hifiberry-dacplusadc.o
492 @@ -45,7 +43,7 @@ obj-$(CONFIG_SND_BCM2708_SOC_RPI_CIRRUS)
493 obj-$(CONFIG_SND_BCM2708_SOC_RPI_PROTO) += snd-soc-rpi-proto.o
494 obj-$(CONFIG_SND_BCM2708_SOC_IQAUDIO_CODEC) += snd-soc-iqaudio-codec.o
495 obj-$(CONFIG_SND_BCM2708_SOC_IQAUDIO_DAC) += snd-soc-iqaudio-dac.o
496 - obj-$(CONFIG_SND_BCM2708_SOC_I_SABRE_Q2M) += snd-soc-i-sabre-q2m.o
497 +obj-$(CONFIG_SND_BCM2708_SOC_I_SABRE_Q2M) += snd-soc-i-sabre-q2m.o
498 obj-$(CONFIG_SND_AUDIOINJECTOR_PI_SOUNDCARD) += snd-soc-audioinjector-pi-soundcard.o
499 obj-$(CONFIG_SND_AUDIOINJECTOR_OCTO_SOUNDCARD) += snd-soc-audioinjector-octo-soundcard.o
500 obj-$(CONFIG_SND_AUDIOSENSE_PI) += snd-soc-audiosense-pi.o