1 From a75cd9664fb5a0a7e691ccd3643fc8016bb4dc55 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 496/773] ASoC: decommissioning driver for 3Dlab Nano soundcard
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 arch/arm/configs/bcm2709_defconfig | 1 -
11 arch/arm/configs/bcmrpi_defconfig | 1 -
12 sound/soc/bcm/3dlab-nano-player.c | 370 ------------------
13 sound/soc/bcm/Kconfig | 6 -
14 sound/soc/bcm/Makefile | 6 +-
15 8 files changed, 2 insertions(+), 421 deletions(-)
16 delete mode 100644 arch/arm/boot/dts/overlays/3dlab-nano-player-overlay.dts
17 delete mode 100644 sound/soc/bcm/3dlab-nano-player.c
19 --- a/arch/arm/boot/dts/overlays/3dlab-nano-player-overlay.dts
22 -// Definitions for 3Dlab Nano Player
27 - compatible = "brcm,bcm2708";
39 - #address-cells = <1>;
44 - compatible = "3dlab,nano-player";
46 - i2s-controller = <&i2s>;
54 --- a/arch/arm/boot/dts/overlays/Makefile
55 +++ b/arch/arm/boot/dts/overlays/Makefile
57 # Overlays for the Raspberry Pi platform
59 dtbo-$(CONFIG_ARCH_BCM2835) += \
60 - 3dlab-nano-player.dtbo \
62 adau7002-simple.dtbo \
64 --- a/arch/arm/boot/dts/overlays/README
65 +++ b/arch/arm/boot/dts/overlays/README
66 @@ -205,12 +205,6 @@ Params:
67 and the other i2c baudrate parameters.
70 -Name: 3dlab-nano-player
71 -Info: Configures the 3Dlab Nano Player
72 -Load: dtoverlay=3dlab-nano-player
77 Info: Overlay for activation of ADAU1977 ADC codec over I2C for control
79 --- a/arch/arm/configs/bcm2709_defconfig
80 +++ b/arch/arm/configs/bcm2709_defconfig
81 @@ -908,7 +908,6 @@ CONFIG_SND_USB_6FIRE=m
82 CONFIG_SND_USB_HIFACE=m
84 CONFIG_SND_BCM2835_SOC_I2S=m
85 -CONFIG_SND_BCM2708_SOC_3DLAB_NANO_PLAYER=m
86 CONFIG_SND_BCM2708_SOC_GOOGLEVOICEHAT_SOUNDCARD=m
87 CONFIG_SND_BCM2708_SOC_HIFIBERRY_DAC=m
88 CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUS=m
89 --- a/arch/arm/configs/bcmrpi_defconfig
90 +++ b/arch/arm/configs/bcmrpi_defconfig
91 @@ -900,7 +900,6 @@ CONFIG_SND_USB_6FIRE=m
92 CONFIG_SND_USB_HIFACE=m
94 CONFIG_SND_BCM2835_SOC_I2S=m
95 -CONFIG_SND_BCM2708_SOC_3DLAB_NANO_PLAYER=m
96 CONFIG_SND_BCM2708_SOC_GOOGLEVOICEHAT_SOUNDCARD=m
97 CONFIG_SND_BCM2708_SOC_HIFIBERRY_DAC=m
98 CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUS=m
99 --- a/sound/soc/bcm/3dlab-nano-player.c
103 - * 3Dlab Nano Player ALSA SoC Audio driver.
105 - * Copyright (C) 2018 3Dlab.
107 - * Author: GT <dev@3d-lab-av.com>
109 - * This program is free software; you can redistribute it and/or
110 - * modify it under the terms of the GNU General Public License
111 - * version 2 as published by the Free Software Foundation.
113 - * This program is distributed in the hope that it will be useful, but
114 - * WITHOUT ANY WARRANTY; without even the implied warranty of
115 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
116 - * General Public License for more details.
119 -#include <linux/module.h>
120 -#include <linux/i2c.h>
121 -#include <sound/soc.h>
122 -#include <sound/pcm.h>
123 -#include <sound/pcm_params.h>
124 -#include <sound/control.h>
126 -#define NANO_ID 0x00
127 -#define NANO_VER 0x01
128 -#define NANO_CFG 0x02
129 -#define NANO_STATUS 0x03
130 -#define NANO_SPI_ADDR 0x04
131 -#define NANO_SPI_DATA 0x05
133 -#define NANO_ID_VAL 0x3D
134 -#define NANO_CFG_OFF 0x00
135 -#define NANO_CFG_MULT1 0
136 -#define NANO_CFG_MULT2 1
137 -#define NANO_CFG_MULT4 2
138 -#define NANO_CFG_MULT8 3
139 -#define NANO_CFG_MULT16 4
140 -#define NANO_CFG_CLK22 0
141 -#define NANO_CFG_CLK24 BIT(3)
142 -#define NANO_CFG_DSD BIT(4)
143 -#define NANO_CFG_ENA BIT(5)
144 -#define NANO_CFG_BLINK BIT(6)
145 -#define NANO_STATUS_P1 BIT(0)
146 -#define NANO_STATUS_P2 BIT(1)
147 -#define NANO_STATUS_FLG BIT(2)
148 -#define NANO_STATUS_CLK BIT(3)
149 -#define NANO_SPI_READ 0
150 -#define NANO_SPI_WRITE BIT(5)
152 -#define NANO_DAC_CTRL1 0x00
153 -#define NANO_DAC_CTRL2 0x01
154 -#define NANO_DAC_CTRL3 0x02
155 -#define NANO_DAC_LATT 0x03
156 -#define NANO_DAC_RATT 0x04
158 -#define NANO_CTRL2_VAL 0x22
160 -static int nano_player_spi_write(struct regmap *map,
161 - unsigned int reg, unsigned int val)
163 - /* indirect register access */
164 - regmap_write(map, NANO_SPI_DATA, val);
165 - regmap_write(map, NANO_SPI_ADDR, reg | NANO_SPI_WRITE);
169 -static int nano_player_ctrl_info(struct snd_kcontrol *kcontrol,
170 - struct snd_ctl_elem_info *uinfo)
172 - /* describe control element */
173 - if (strstr(kcontrol->id.name, "Volume")) {
174 - uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
176 - uinfo->value.integer.min = 0;
177 - uinfo->value.integer.max = 100;
179 - uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
181 - uinfo->value.integer.min = 0;
182 - uinfo->value.integer.max = 1;
188 -static int nano_player_ctrl_put(struct snd_kcontrol *kcontrol,
189 - struct snd_ctl_elem_value *ucontrol)
191 - /* program control value to hardware */
192 - struct snd_soc_card *card = snd_kcontrol_chip(kcontrol);
193 - struct regmap *regmap = snd_soc_card_get_drvdata(card);
195 - if (strstr(kcontrol->id.name, "Volume")) {
196 - unsigned int vol = ucontrol->value.integer.value[0];
197 - unsigned int att = 255 - (2 * (100 - vol));
199 - nano_player_spi_write(regmap, NANO_DAC_LATT, att);
200 - nano_player_spi_write(regmap, NANO_DAC_RATT, att);
201 - kcontrol->private_value = vol;
203 - unsigned int mute = ucontrol->value.integer.value[0];
204 - unsigned int reg = NANO_CTRL2_VAL | mute;
206 - nano_player_spi_write(regmap, NANO_DAC_CTRL2, reg);
207 - kcontrol->private_value = mute;
212 -static int nano_player_ctrl_get(struct snd_kcontrol *kcontrol,
213 - struct snd_ctl_elem_value *ucontrol)
215 - /* return last programmed value */
216 - ucontrol->value.integer.value[0] = kcontrol->private_value;
220 -#define SOC_NANO_PLAYER_CTRL(xname) \
221 -{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
222 - .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
223 - .info = nano_player_ctrl_info, \
224 - .put = nano_player_ctrl_put, \
225 - .get = nano_player_ctrl_get }
227 -static const struct snd_kcontrol_new nano_player_controls[] = {
228 - SOC_NANO_PLAYER_CTRL("Master Playback Volume"),
229 - SOC_NANO_PLAYER_CTRL("Master Playback Switch"),
232 -static const unsigned int nano_player_rates[] = {
233 - 44100, 48000, 88200, 96000, 176400, 192000, 352800, 384000,
234 - 705600, 768000 /* only possible with fast clocks */
237 -static struct snd_pcm_hw_constraint_list nano_player_constraint_rates = {
238 - .list = nano_player_rates,
239 - .count = ARRAY_SIZE(nano_player_rates),
242 -static int nano_player_init(struct snd_soc_pcm_runtime *rtd)
244 - struct snd_soc_card *card = rtd->card;
245 - struct regmap *regmap = snd_soc_card_get_drvdata(card);
246 - struct snd_soc_pcm_stream *cpu = &rtd->cpu_dai->driver->playback;
247 - struct snd_soc_pcm_stream *codec = &rtd->codec_dai->driver->playback;
248 - unsigned int sample_bits = 32;
251 - /* configure cpu dai */
252 - cpu->formats |= SNDRV_PCM_FMTBIT_DSD_U32_LE;
253 - cpu->rate_max = 768000;
255 - /* configure dummy codec dai */
256 - codec->rate_min = 44100;
257 - codec->rates = SNDRV_PCM_RATE_KNOT;
258 - codec->formats = SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_DSD_U32_LE;
260 - /* configure max supported rate */
261 - regmap_read(regmap, NANO_STATUS, &val);
262 - if (val & NANO_STATUS_CLK) {
263 - dev_notice(card->dev, "Board with fast clocks installed\n");
264 - codec->rate_max = 768000;
266 - dev_notice(card->dev, "Board with normal clocks installed\n");
267 - codec->rate_max = 384000;
270 - /* frame length enforced by hardware */
271 - return snd_soc_dai_set_bclk_ratio(rtd->cpu_dai, sample_bits * 2);
274 -static int nano_player_startup(struct snd_pcm_substream *substream)
276 - return snd_pcm_hw_constraint_list(substream->runtime, 0,
277 - SNDRV_PCM_HW_PARAM_RATE,
278 - &nano_player_constraint_rates);
281 -static int nano_player_hw_params(struct snd_pcm_substream *substream,
282 - struct snd_pcm_hw_params *params)
284 - struct snd_soc_pcm_runtime *rtd = substream->private_data;
285 - struct snd_soc_card *card = rtd->card;
286 - struct regmap *regmap = snd_soc_card_get_drvdata(card);
287 - unsigned int config = NANO_CFG_ENA;
288 - struct snd_mask *fmt;
290 - /* configure PCM or DSD */
291 - fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
292 - if (snd_mask_test(fmt, SNDRV_PCM_FORMAT_DSD_U32_LE)) {
293 - /* embed DSD in PCM data */
294 - snd_mask_none(fmt);
295 - snd_mask_set(fmt, SNDRV_PCM_FORMAT_S32_LE);
296 - /* enable DSD mode */
297 - config |= NANO_CFG_DSD;
300 - /* configure clocks */
301 - switch (params_rate(params)) {
303 - config |= NANO_CFG_MULT1 | NANO_CFG_CLK22;
306 - config |= NANO_CFG_MULT2 | NANO_CFG_CLK22;
309 - config |= NANO_CFG_MULT4 | NANO_CFG_CLK22;
312 - config |= NANO_CFG_MULT8 | NANO_CFG_CLK22;
315 - config |= NANO_CFG_MULT16 | NANO_CFG_CLK22;
318 - config |= NANO_CFG_MULT1 | NANO_CFG_CLK24;
321 - config |= NANO_CFG_MULT2 | NANO_CFG_CLK24;
324 - config |= NANO_CFG_MULT4 | NANO_CFG_CLK24;
327 - config |= NANO_CFG_MULT8 | NANO_CFG_CLK24;
330 - config |= NANO_CFG_MULT16 | NANO_CFG_CLK24;
336 - dev_dbg(card->dev, "Send CFG register 0x%02X\n", config);
337 - return regmap_write(regmap, NANO_CFG, config);
340 -static struct snd_soc_ops nano_player_ops = {
341 - .startup = nano_player_startup,
342 - .hw_params = nano_player_hw_params,
345 -static struct snd_soc_dai_link nano_player_link = {
346 - .name = "3Dlab Nano Player",
347 - .stream_name = "3Dlab Nano Player HiFi",
348 - .platform_name = "bcm2708-i2s.0",
349 - .cpu_dai_name = "bcm2708-i2s.0",
350 - .codec_name = "snd-soc-dummy",
351 - .codec_dai_name = "snd-soc-dummy-dai",
352 - .dai_fmt = SND_SOC_DAIFMT_I2S |
353 - SND_SOC_DAIFMT_CONT |
354 - SND_SOC_DAIFMT_NB_NF |
355 - SND_SOC_DAIFMT_CBM_CFM,
356 - .init = nano_player_init,
357 - .ops = &nano_player_ops,
360 -static const struct regmap_config nano_player_regmap = {
363 - .max_register = 128,
364 - .cache_type = REGCACHE_RBTREE,
367 -static int nano_player_card_probe(struct snd_soc_card *card)
369 - struct regmap *regmap = snd_soc_card_get_drvdata(card);
372 - /* check hardware integrity */
373 - regmap_read(regmap, NANO_ID, &val);
374 - if (val != NANO_ID_VAL) {
375 - dev_err(card->dev, "Invalid ID register 0x%02X\n", val);
379 - /* report version to the user */
380 - regmap_read(regmap, NANO_VER, &val);
381 - dev_notice(card->dev, "Started 3Dlab Nano Player driver (v%d)\n", val);
383 - /* enable internal audio bus and blink status LED */
384 - return regmap_write(regmap, NANO_CFG, NANO_CFG_ENA | NANO_CFG_BLINK);
387 -static int nano_player_card_remove(struct snd_soc_card *card)
389 - /* disable internal audio bus */
390 - struct regmap *regmap = snd_soc_card_get_drvdata(card);
392 - return regmap_write(regmap, NANO_CFG, NANO_CFG_OFF);
395 -static struct snd_soc_card nano_player_card = {
396 - .name = "3Dlab_Nano_Player",
397 - .owner = THIS_MODULE,
398 - .dai_link = &nano_player_link,
400 - .controls = nano_player_controls,
401 - .num_controls = ARRAY_SIZE(nano_player_controls),
402 - .probe = nano_player_card_probe,
403 - .remove = nano_player_card_remove,
406 -static int nano_player_i2c_probe(struct i2c_client *i2c,
407 - const struct i2c_device_id *id)
409 - struct regmap *regmap;
412 - regmap = devm_regmap_init_i2c(i2c, &nano_player_regmap);
413 - if (IS_ERR(regmap)) {
414 - ret = PTR_ERR(regmap);
415 - dev_err(&i2c->dev, "Failed to init regmap %d\n", ret);
419 - if (i2c->dev.of_node) {
420 - struct snd_soc_dai_link *dai = &nano_player_link;
421 - struct device_node *node;
423 - /* cpu handle configured by device tree */
424 - node = of_parse_phandle(i2c->dev.of_node, "i2s-controller", 0);
426 - dai->platform_name = NULL;
427 - dai->platform_of_node = node;
428 - dai->cpu_dai_name = NULL;
429 - dai->cpu_of_node = node;
433 - nano_player_card.dev = &i2c->dev;
434 - snd_soc_card_set_drvdata(&nano_player_card, regmap);
435 - ret = devm_snd_soc_register_card(&i2c->dev, &nano_player_card);
437 - if (ret && ret != -EPROBE_DEFER)
438 - dev_err(&i2c->dev, "Failed to register card %d\n", ret);
443 -static const struct of_device_id nano_player_of_match[] = {
444 - { .compatible = "3dlab,nano-player", },
447 -MODULE_DEVICE_TABLE(of, nano_player_of_match);
449 -static const struct i2c_device_id nano_player_i2c_id[] = {
450 - { "nano-player", 0 },
453 -MODULE_DEVICE_TABLE(i2c, nano_player_i2c_id);
455 -static struct i2c_driver nano_player_i2c_driver = {
456 - .probe = nano_player_i2c_probe,
457 - .id_table = nano_player_i2c_id,
459 - .name = "nano-player",
460 - .owner = THIS_MODULE,
461 - .of_match_table = nano_player_of_match,
465 -module_i2c_driver(nano_player_i2c_driver);
467 -MODULE_DESCRIPTION("ASoC 3Dlab Nano Player driver");
468 -MODULE_AUTHOR("GT <dev@3d-lab-av.com>");
469 -MODULE_LICENSE("GPL v2");
472 --- a/sound/soc/bcm/Kconfig
473 +++ b/sound/soc/bcm/Kconfig
474 @@ -17,12 +17,6 @@ config SND_SOC_CYGNUS
476 If you don't know what to do here, say N.
478 -config SND_BCM2708_SOC_3DLAB_NANO_PLAYER
479 - tristate "Support for 3Dlab Nano Player"
480 - depends on SND_BCM2708_SOC_I2S || SND_BCM2835_SOC_I2S
482 - Say Y or M if you want to add support for 3Dlab Nano Player.
484 config SND_BCM2708_SOC_GOOGLEVOICEHAT_SOUNDCARD
485 tristate "Support for Google voiceHAT soundcard"
486 depends on SND_BCM2708_SOC_I2S || SND_BCM2835_SOC_I2S
487 --- a/sound/soc/bcm/Makefile
488 +++ b/sound/soc/bcm/Makefile
489 @@ -12,7 +12,6 @@ obj-$(CONFIG_SND_SOC_CYGNUS) += snd-soc-
490 snd-soc-googlevoicehat-codec-objs := googlevoicehat-codec.o
492 # BCM2708 Machine Support
493 -snd-soc-3dlab-nano-player-objs := 3dlab-nano-player.o
494 snd-soc-hifiberry-dacplus-objs := hifiberry_dacplus.o
495 snd-soc-hifiberry-dacplusadc-objs := hifiberry_dacplusadc.o
496 snd-soc-justboom-dac-objs := justboom-dac.o
497 @@ -20,7 +19,7 @@ snd-soc-rpi-cirrus-objs := rpi-cirrus.o
498 snd-soc-rpi-proto-objs := rpi-proto.o
499 snd-soc-iqaudio-codec-objs := iqaudio-codec.o
500 snd-soc-iqaudio-dac-objs := iqaudio-dac.o
501 - snd-soc-i-sabre-q2m-objs := i-sabre-q2m.o
502 +snd-soc-i-sabre-q2m-objs := i-sabre-q2m.o
503 snd-soc-audioinjector-pi-soundcard-objs := audioinjector-pi-soundcard.o
504 snd-soc-audioinjector-octo-soundcard-objs := audioinjector-octo-soundcard.o
505 snd-soc-audiosense-pi-objs := audiosense-pi.o
506 @@ -36,7 +35,6 @@ snd-soc-fe-pi-audio-objs := fe-pi-audio.
507 snd-soc-rpi-simple-soundcard-objs := rpi-simple-soundcard.o
508 snd-soc-rpi-wm8804-soundcard-objs := rpi-wm8804-soundcard.o
510 -obj-$(CONFIG_SND_BCM2708_SOC_3DLAB_NANO_PLAYER) += snd-soc-3dlab-nano-player.o
511 obj-$(CONFIG_SND_BCM2708_SOC_GOOGLEVOICEHAT_SOUNDCARD) += snd-soc-googlevoicehat-codec.o
512 obj-$(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUS) += snd-soc-hifiberry-dacplus.o
513 obj-$(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUSADC) += snd-soc-hifiberry-dacplusadc.o
514 @@ -45,7 +43,7 @@ obj-$(CONFIG_SND_BCM2708_SOC_RPI_CIRRUS)
515 obj-$(CONFIG_SND_BCM2708_SOC_RPI_PROTO) += snd-soc-rpi-proto.o
516 obj-$(CONFIG_SND_BCM2708_SOC_IQAUDIO_CODEC) += snd-soc-iqaudio-codec.o
517 obj-$(CONFIG_SND_BCM2708_SOC_IQAUDIO_DAC) += snd-soc-iqaudio-dac.o
518 - obj-$(CONFIG_SND_BCM2708_SOC_I_SABRE_Q2M) += snd-soc-i-sabre-q2m.o
519 +obj-$(CONFIG_SND_BCM2708_SOC_I_SABRE_Q2M) += snd-soc-i-sabre-q2m.o
520 obj-$(CONFIG_SND_AUDIOINJECTOR_PI_SOUNDCARD) += snd-soc-audioinjector-pi-soundcard.o
521 obj-$(CONFIG_SND_AUDIOINJECTOR_OCTO_SOUNDCARD) += snd-soc-audioinjector-octo-soundcard.o
522 obj-$(CONFIG_SND_AUDIOSENSE_PI) += snd-soc-audiosense-pi.o