Skip to content

Commit d3ca28f

Browse files
Pillar1989RobertCNelson
authored andcommitted
add: wilink8-bt
1 parent 0c0b8fb commit d3ca28f

File tree

5 files changed

+191
-3
lines changed

5 files changed

+191
-3
lines changed

sound/soc/codecs/Kconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ config SND_SOC_ALL_CODECS
7777
select SND_SOC_MC13783 if MFD_MC13XXX
7878
select SND_SOC_ML26124 if I2C
7979
select SND_SOC_HDMI_CODEC
80+
select SND_SOC_WILINK8_BT
8081
select SND_SOC_PCM1681 if I2C
8182
select SND_SOC_PCM1792A if SPI_MASTER
8283
select SND_SOC_PCM3008
@@ -436,6 +437,8 @@ config SND_SOC_DMIC
436437

437438
config SND_SOC_HDMI_CODEC
438439
tristate "HDMI stub CODEC"
440+
config SND_SOC_WILINK8_BT
441+
tristate "WILINK8 bluetooth audio"
439442

440443
config SND_SOC_ES8328
441444
tristate "Everest Semi ES8328 CODEC"

sound/soc/codecs/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ snd-soc-max9850-objs := max9850.o
7070
snd-soc-mc13783-objs := mc13783.o
7171
snd-soc-ml26124-objs := ml26124.o
7272
snd-soc-hdmi-codec-objs := hdmi.o
73+
snd-soc-wilink8-bt-objs := wilink8-bt.o
7374
snd-soc-pcm1681-objs := pcm1681.o
7475
snd-soc-pcm1792a-codec-objs := pcm1792a.o
7576
snd-soc-pcm3008-objs := pcm3008.o
@@ -255,6 +256,7 @@ obj-$(CONFIG_SND_SOC_MAX9850) += snd-soc-max9850.o
255256
obj-$(CONFIG_SND_SOC_MC13783) += snd-soc-mc13783.o
256257
obj-$(CONFIG_SND_SOC_ML26124) += snd-soc-ml26124.o
257258
obj-$(CONFIG_SND_SOC_HDMI_CODEC) += snd-soc-hdmi-codec.o
259+
obj-$(CONFIG_SND_SOC_WILINK8_BT) += snd-soc-wilink8-bt.o
258260
obj-$(CONFIG_SND_SOC_PCM1681) += snd-soc-pcm1681.o
259261
obj-$(CONFIG_SND_SOC_PCM1792A) += snd-soc-pcm1792a-codec.o
260262
obj-$(CONFIG_SND_SOC_PCM3008) += snd-soc-pcm3008.o

sound/soc/codecs/wilink8-bt.c

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/*
2+
* ALSA SoC PCM5102a driver
3+
*
4+
* Author: Josh Elliott, <[email protected]>
5+
* Copyright: Copyright: (C) 2014 Texas Instruments
6+
*
7+
* Based on sound/soc/codecs/spdif_transmitter.c by Steve Chen
8+
*
9+
* This program is free software; you can redistribute it and/or modify
10+
* it under the terms of the GNU General Public License version 2 as
11+
* published by the Free Software Foundation.
12+
*/
13+
14+
#include <linux/module.h>
15+
#include <linux/moduleparam.h>
16+
#include <linux/slab.h>
17+
#include <sound/soc.h>
18+
#include <sound/pcm.h>
19+
#include <sound/initval.h>
20+
#include <linux/of.h>
21+
22+
#define DRV_NAME "wilink8_bt"
23+
24+
#define RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000)
25+
#define FORMATS SNDRV_PCM_FMTBIT_S16_LE
26+
27+
28+
static struct snd_soc_codec_driver soc_codec_wilink8_bt = {
29+
};
30+
31+
static struct snd_soc_dai_driver wilink8_bt_dai = {
32+
.name = "wilink8_bt-hifi",
33+
.playback = {
34+
.stream_name = "Playback",
35+
.channels_min = 1,
36+
.channels_max = 2,
37+
.rates = RATES,
38+
.formats = FORMATS,
39+
},
40+
.capture = {
41+
.stream_name = "Capture",
42+
.channels_min = 1,
43+
.channels_max = 2,
44+
.rates = RATES,
45+
.formats = FORMATS,
46+
},
47+
};
48+
49+
static int wilink8_bt_probe(struct platform_device *pdev)
50+
{
51+
return snd_soc_register_codec(&pdev->dev, &soc_codec_wilink8_bt,
52+
&wilink8_bt_dai, 1);
53+
}
54+
55+
static int wilink8_bt_remove(struct platform_device *pdev)
56+
{
57+
snd_soc_unregister_codec(&pdev->dev);
58+
return 0;
59+
}
60+
61+
#ifdef CONFIG_OF
62+
static const struct of_device_id wilink8_bt_dt_ids[] = {
63+
{ .compatible = "ti,wilink8_bt", },
64+
{ }
65+
};
66+
MODULE_DEVICE_TABLE(of, wilink8_bt_dt_ids);
67+
#endif
68+
69+
static struct platform_driver wilink8_bt_driver = {
70+
.probe = wilink8_bt_probe,
71+
.remove = wilink8_bt_remove,
72+
.driver = {
73+
.name = DRV_NAME,
74+
.owner = THIS_MODULE,
75+
.of_match_table = of_match_ptr(wilink8_bt_dt_ids),
76+
},
77+
};
78+
79+
module_platform_driver(wilink8_bt_driver);
80+
81+
MODULE_AUTHOR("Baozhu <[email protected]>");
82+
MODULE_DESCRIPTION("WILINK8_BT dummy codec driver");
83+
MODULE_LICENSE("GPL");
84+
MODULE_ALIAS("platform:" DRV_NAME);

sound/soc/davinci/Kconfig

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,13 @@ config SND_AM33XX_SOC_EVM
4545
boards using McASP and TLV320AIC3X codec. For example AM335X-EVM,
4646
AM335X-EVMSK, and BeagelBone with AudioCape boards have this
4747
setup.
48-
48+
config SND_AM33XX_SOC_WILINK8_BT
49+
tristate "SoC Audio support for WILINK8 PCM on Beaglebone Green Wrieless"
50+
depends on SND_DAVINCI_SOC_GENERIC_EVM && SOC_AM33XX
51+
select SND_SOC_WILINK8_BT
52+
help
53+
Say Y or M if you want to add support for SoC audio on AM33XX
54+
evm board using McASP and WILINK8_BT.
4955
config SND_DAVINCI_SOC_EVM
5056
tristate "SoC Audio support for DaVinci DM6446, DM355 or DM365 EVM"
5157
depends on SND_EDMA_SOC && I2C

sound/soc/davinci/davinci-evm.c

Lines changed: 95 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,16 @@ struct snd_soc_card_drvdata_davinci {
3232

3333
static int evm_startup(struct snd_pcm_substream *substream)
3434
{
35+
int ret = 0;
3536
struct snd_soc_pcm_runtime *rtd = substream->private_data;
3637
struct snd_soc_card *soc_card = rtd->card;
3738
struct snd_soc_card_drvdata_davinci *drvdata =
3839
snd_soc_card_get_drvdata(soc_card);
3940

4041
if (drvdata->mclk)
41-
return clk_prepare_enable(drvdata->mclk);
42+
ret = clk_prepare_enable(drvdata->mclk);
4243

43-
return 0;
44+
return ret;
4445
}
4546

4647
static void evm_shutdown(struct snd_pcm_substream *substream)
@@ -77,6 +78,81 @@ static int evm_hw_params(struct snd_pcm_substream *substream,
7778

7879
return 0;
7980
}
81+
static int wilink8_bt_hw_params(struct snd_pcm_substream *substream,
82+
struct snd_pcm_hw_params *params)
83+
{
84+
struct snd_soc_pcm_runtime *rtd = substream->private_data;
85+
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
86+
struct snd_soc_codec *codec = rtd->codec;
87+
struct snd_soc_card *soc_card = rtd->card;
88+
struct platform_device *pdev = to_platform_device(soc_card->dev);
89+
unsigned sysclk = ((struct snd_soc_card_drvdata_davinci *)
90+
snd_soc_card_get_drvdata(soc_card))->sysclk;
91+
int ret = 0;
92+
int rate = params_rate(params);
93+
94+
if (rate == 16000) {
95+
/*
96+
* Works with tdm-slots set to 5 in the DT:
97+
* 5 slots each with a word-length of 20 gives us 100
98+
* bits/frame.
99+
*/
100+
/* MCLK divider 24/3=8MHz */
101+
ret = snd_soc_dai_set_clkdiv(cpu_dai, 0, 3);
102+
/* BCLK divider 8/5=1.6MHz */
103+
ret = snd_soc_dai_set_clkdiv(cpu_dai, 1, 5);
104+
/* BCLK/FS ratio 1.6/100=16kHz FS */
105+
ret = snd_soc_dai_set_clkdiv(cpu_dai, 2, 100);
106+
107+
/*
108+
* Works with tdm-slots set to 2 in the DT:
109+
* 2 slots each with a word-length of 30 gives us 60
110+
* bits/frame.
111+
*
112+
* ret = snd_soc_dai_set_clkdiv(cpu_dai, 0, 3);
113+
* ret = snd_soc_dai_set_clkdiv(cpu_dai, 1, 5);
114+
* ret = snd_soc_dai_set_clkdiv(cpu_dai, 2, 100);
115+
*/
116+
}
117+
else if (rate == 8000) {
118+
/*
119+
* Works with tdm-slots set to 5 in the DT:
120+
* 5 slots each with a word-length of 20 gives us 100
121+
* bits/frame.
122+
*/
123+
/* MCLK divider 24/3=8MHz */
124+
ret = snd_soc_dai_set_clkdiv(cpu_dai, 0, 3);
125+
/* BCLK divider 8/10=800kHz */
126+
ret = snd_soc_dai_set_clkdiv(cpu_dai, 1, 10);
127+
/* BCLK/FS ratio 800/100=8kHz FS */
128+
ret = snd_soc_dai_set_clkdiv(cpu_dai, 2, 100);
129+
}
130+
else if (rate == 48000) {
131+
/*
132+
* Works with tdm-slots set to 5 in the DT:
133+
* 5 slots each with a word-length of 20 gives us 100
134+
* bits/frame.
135+
*/
136+
/* MCLK divider 24/1=24MHz */
137+
ret = snd_soc_dai_set_clkdiv(cpu_dai, 0, 1);
138+
/* BCLK divider 24/5=4.8MHz */
139+
ret = snd_soc_dai_set_clkdiv(cpu_dai, 1, 5);
140+
/* BCLK/FS ratio 4.8/100=48kHz FS */
141+
ret = snd_soc_dai_set_clkdiv(cpu_dai, 2, 100);
142+
} else {
143+
dev_err(&pdev->dev, "Unsupported rate\n");
144+
}
145+
146+
if (ret < 0) {
147+
dev_err(&pdev->dev, "can't set CPU DAI clock divider %d\n",
148+
ret);
149+
return ret;
150+
}
151+
152+
ret = snd_soc_dai_set_sysclk(cpu_dai, 0, sysclk, SND_SOC_CLOCK_OUT);
153+
154+
return ret;
155+
}
80156

81157
/* If changing sample format the tda998x configuration (REG_CTS_N) needs
82158
to be changed. */
@@ -104,6 +180,11 @@ static struct snd_soc_ops evm_tda998x_ops = {
104180
.startup = evm_tda998x_startup,
105181
.shutdown = evm_shutdown,
106182
};
183+
static struct snd_soc_ops wilink8_bt_ops = {
184+
.startup = evm_startup,
185+
.shutdown = evm_shutdown,
186+
.hw_params = wilink8_bt_hw_params,
187+
};
107188

108189
/* davinci-evm machine dapm widgets */
109190
static const struct snd_soc_dapm_widget aic3x_dapm_widgets[] = {
@@ -407,6 +488,14 @@ static struct snd_soc_dai_link evm_dai_tda998x_hdmi = {
407488
.dai_fmt = (SND_SOC_DAIFMT_CBS_CFS | SND_SOC_DAIFMT_I2S |
408489
SND_SOC_DAIFMT_IB_NF),
409490
};
491+
static struct snd_soc_dai_link evm_dai_wilink8_bt = {
492+
.name = "WILINK8_BT",
493+
.stream_name = "WILINK8",
494+
.codec_dai_name = "wilink8_bt-hifi",
495+
.ops = &wilink8_bt_ops,
496+
.dai_fmt = (SND_SOC_DAIFMT_CBS_CFS | SND_SOC_DAIFMT_NB_IF |
497+
SND_SOC_DAIFMT_DSP_A),
498+
};
410499

411500
static const struct of_device_id davinci_evm_dt_ids[] = {
412501
{
@@ -417,6 +506,10 @@ static const struct of_device_id davinci_evm_dt_ids[] = {
417506
.compatible = "ti,beaglebone-black-audio",
418507
.data = &evm_dai_tda998x_hdmi,
419508
},
509+
{
510+
.compatible = "ti,wilink8-bt-audio",
511+
.data = &evm_dai_wilink8_bt,
512+
},
420513
{ /* sentinel */ }
421514
};
422515
MODULE_DEVICE_TABLE(of, davinci_evm_dt_ids);

0 commit comments

Comments
 (0)