ASoC: Add support for MikroElektronika PROTO codec
Subsystems (5)
cover ASoC: Add support for MikroElektronika PROTO codec
This patchset is based on Florian's initial PROTO driver:
https://lkml.org/lkml/2013/5/22/342
My changes made the driver more generic, so that we could connect other I2S CPU DAIs, by using device-tree.
Tested with sama5d2 I2S driver.
Codrin Ciubotariu (2):
ASoC: Add driver for PROTO Audio CODEC (with a WM8731)
ASoC: mikroe-proto: dt-bindings: add DT bindings for PROTO board
.../bindings/sound/mikroe,mikroe-proto.txt | 23 +++ .../devicetree/bindings/vendor-prefixes.txt | 1 + sound/soc/atmel/Kconfig | 7 + sound/soc/atmel/Makefile | 2 + sound/soc/atmel/mikroe-proto.c | 189 ++++++++++++++++++ 5 files changed, 222 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/mikroe,mikroe-proto.txt create mode 100644 sound/soc/atmel/mikroe-proto.c
Signature · 1 line
2.17.1
PATCH 1/2 ASoC: Add driver for PROTO Audio CODEC (with a WM8731)
Add support for the MikroElektronika PROTO audio codec board.
URL to the audio chip:
http://www.mikroe.com/add-on-boards/audio-voice/audio-codec-proto/
--- sound/soc/atmel/Kconfig | 7 ++ sound/soc/atmel/Makefile | 2 + sound/soc/atmel/mikroe-proto.c | 189 +++++++++++++++++++++++++++++++++ 3 files changed, 198 insertions(+) create mode 100644 sound/soc/atmel/mikroe-proto.c
sound/soc/atmel/Kconfig +7 -0
@@ -97,4 +97,11 @@ config SND_ATMEL_SOC_I2S help Say Y or M if you want to add support for Atmel ASoc driver for boards using I2S. + +config SND_SOC_MIKROE_PROTO + tristate "Support for Mikroe-PROTO board" + depends on OF + select SND_SOC_WM8731 + help + Say Y or M if you want to add support for Audio Codec Board PROTO (WM8731). endif
sound/soc/atmel/Makefile +2 -0
@@ -17,6 +17,7 @@ snd-soc-sam9x5-wm8731-objs := sam9x5_wm8731.o snd-atmel-soc-classd-objs := atmel-classd.o snd-atmel-soc-pdmic-objs := atmel-pdmic.o snd-atmel-soc-tse850-pcm5142-objs := tse850-pcm5142.o +snd-soc-mikroe-proto-objs := mikroe-proto.o obj-$(CONFIG_SND_AT91_SOC_SAM9G20_WM8731) += snd-soc-sam9g20-wm8731.o obj-$(CONFIG_SND_ATMEL_SOC_WM8904) += snd-atmel-soc-wm8904.o
@@ -24,3 +25,4 @@ obj-$(CONFIG_SND_AT91_SOC_SAM9X5_WM8731) += snd-soc-sam9x5-wm8731.o obj-$(CONFIG_SND_ATMEL_SOC_CLASSD) += snd-atmel-soc-classd.o obj-$(CONFIG_SND_ATMEL_SOC_PDMIC) += snd-atmel-soc-pdmic.o obj-$(CONFIG_SND_ATMEL_SOC_TSE850_PCM5142) += snd-atmel-soc-tse850-pcm5142.o +obj-$(CONFIG_SND_SOC_MIKROE_PROTO) += snd-soc-mikroe-proto.o
sound/soc/atmel/mikroe-proto.c new file +189 -0
189 lines not on this page · raw message
Signature · 1 line
2.17.1
Mark Brown
maintainerRe: [PATCH 1/2] ASoC: Add driver for PROTO Audio CODEC (with a WM8731)
Quoted 7 lines · Codrin Ciubotariu
sound/soc/atmel/mikroe-proto.c new file +7
-0+static const unsigned int wm8731_rates_12288000[] = { +8000 ,32000 ,48000 ,96000 , +}; + +static struct snd_pcm_hw_constraint_list wm8731_constraints_12288000 = { + .list = wm8731_rates_12288000, + .count =ARRAY_SIZE (wm8731_rates_12288000),
sound/soc/atmel/mikroe-proto.c line 40
Quoted 10 lines
sound/soc/atmel/mikroe-proto.c new file +10
-0+}; + +static int snd_proto_startup (struct snd_pcm_substream *substream) +{ +/* Setup constraints, because there is a 12.288 MHz XTAL on the board */ +snd_pcm_hw_constraint_list (substream->runtime,0 , +SNDRV_PCM_HW_PARAM_RATE , + &wm8731_constraints_12288000); +return 0 ; +}
This bit is better added to the CODEC driver since it'll apply to any system where there's this clock rate (someone else could come in and add other rates, no need to do that yourself though it'd be nice of course).
That also has the nice bonus that with that I think you'd be able to use
the graph card rather than a custom driver?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180829/7bf525a1/attachment.sig>
Re: [PATCH 1/2] ASoC: Add driver for PROTO Audio CODEC (with a WM8731)
Quoted 15 lines · Mark Brown
Quoted 13 lines · Codrin Ciubotariu
sound/soc/atmel/mikroe-proto.c new file +13
-0+static const unsigned int wm8731_rates_12288000[] = { +8000 ,32000 ,48000 ,96000 , +}; + +static struct snd_pcm_hw_constraint_list wm8731_constraints_12288000 = { + .list = wm8731_rates_12288000, + .count =ARRAY_SIZE (wm8731_rates_12288000), +}; + +static int snd_proto_startup (struct snd_pcm_substream *substream) +{ +/* Setup constraints, because there is a 12.288 MHz XTAL on the board */ + snd_pcm_hw_constraint_list(substream->runtime, 0,
Quoted 8 lines
sound/soc/atmel/mikroe-proto.c line 40
Quoted 4 lines
sound/soc/atmel/mikroe-proto.c new file +4
-0+SNDRV_PCM_HW_PARAM_RATE , + &wm8731_constraints_12288000); +return 0 ; +}This bit is better added to the CODEC driver since it'll apply to any system where there's this clock rate (someone else could come in and add other rates, no need to do that yourself though it'd be nice of course).
I could do it.
Quoted 3 lines
That also has the nice bonus that with that I think you'd be able to use the graph card rather than a custom driver?
The main reason for adding a custom driver and not using graph/simple card is the snd_soc_dai_set_sysclk(codec_dai, WM8731_SYSCLK_XTAL,
XTAL_RATE, SND_SOC_CLOCK_IN) call. This
enables the oscillator found in the wm8731 codec. Since WM8731_SYSCLK_XTAL is not 0, we can't use system-clock-frequency DT property to set it.
Best regards,
Codrin
Mark Brown
maintainerRe: [PATCH 1/2] ASoC: Add driver for PROTO Audio CODEC (with a WM8731)
Quoted 10 lines · Codrin Ciubotariu
Quoted 2 lines · Mark Brown
That also has the nice bonus that with that I think you'd be able to use the graph card rather than a custom driver?
The main reason for adding a custom driver and not using graph/simple card is the
snd_soc_dai_set_sysclk(codec_dai, WM8731_SYSCLK_XTAL, XTAL_RATE, SND_SOC_CLOCK_IN)call. This enables the oscillator found in the wm8731 codec. SinceWM8731_SYSCLK_XTALis not 0, we can't use system-clock-frequency DT property to set it.
Right, that'd be more substantial surgery on the driver to change the DT
binding so that it's got a clock provider in it; it'd be nice to do but
it's a bit much to make it a blocker so the machine driver is OK.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180829/2d517a19/attachment.sig>
Re: [PATCH 1/2] ASoC: Add driver for PROTO Audio CODEC (with a WM8731)
In reply to Codrin CiubotariuQuoted 27 lines · Codrin Ciubotariu
Quoted 17 lines · Mark Brown
Quoted 15 lines · Codrin Ciubotariu
sound/soc/atmel/mikroe-proto.c new file +5
-0+static const unsigned int wm8731_rates_12288000[] = { + 8000, 32000, 48000, 96000, +}; + +static struct snd_pcm_hw_constraint_list wm8731_constraints_12288000= {
+ .list =wm8731_rates_12288000,
+ .count =ARRAY_SIZE(wm8731_rates_12288000),sound/soc/atmel/mikroe-proto.c new file +5
-0+}; + +static int snd_proto_startup (struct snd_pcm_substream *substream) +{ + /* Setup constraints, because there is a 12.288 MHz XTAL on theboard */
+ snd_pcm_hw_constraint_list(substream->runtime, 0,Quoted 8 lines
Quoted 4 lines
+
SNDRV_PCM_HW_PARAM_RATE, +&wm8731_constraints_12288000); + return 0;
+}This bit is better added to the CODEC driver since it'll apply to any system where there's this clock rate (someone else could come in and add other rates, no need to do that yourself though it'd be nice of course).
Quoted 1 line
I could do it.
It looks like these constraints are already in the wm8731 driver. I will wait for more comments and then I will send a v2 without this part.
Thanks and best regards,
Codrin
kbuild test robot
build botRe: [PATCH 1/2] ASoC: Add driver for PROTO Audio CODEC (with a WM8731)
In reply to Codrin CiubotariuThank you for the patch! Yet something to improve:
Hi Codrin,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on at91/at91-next]
[also build test ERROR on v4.19-rc1 next-20180829]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Codrin-Ciubotariu/ASoC-Add-driver-for-PROTO-Audio-CODEC-with-a-WM8731/20180830-060610 base: https://git.kernel.org/pub/scm/linux/kernel/git/nferre/linux-at91.git at91-next config: i386-allmodconfig (attached as .config) compiler: gcc-7 (Debian 7.3.0-16) 7.3.0 reproduce: # save the attached .config to linux build tree make ARCH=i386
All errors (new ones prefixed by >>):
sound/soc/atmel/mikroe-proto.c: In function 'snd_proto_init':
>> sound/soc/atmel/mikroe-proto.c:49:35: error: 'struct snd_soc_pcm_runtime' has no member named 'codec'
struct snd_soc_codec *codec = rtd->codec;
^~
>> sound/soc/atmel/mikroe-proto.c:56:16: error: dereferencing pointer to incomplete type 'struct snd_soc_codec'
dev_err(codec->dev, "Failed to set WM8731 SYSCLK: %d\n", ret);
^~vim +49 sound/soc/atmel/mikroe-proto.c
46
47 static int snd_proto_init(struct snd_soc_pcm_runtime *rtd)
48 {
> 49 struct snd_soc_codec *codec = rtd->codec;
50 struct snd_soc_dai *codec_dai = rtd->codec_dai;
51
52 /* Set proto sysclk */
53 int ret = snd_soc_dai_set_sysclk(codec_dai, WM8731_SYSCLK_XTAL,
54 XTAL_RATE, SND_SOC_CLOCK_IN);
55 if (ret < 0) {
> 56 dev_err(codec->dev, "Failed to set WM8731 SYSCLK: %d\n", ret);
57 return ret;
58 }
59
60 return 0;
61 }
62 ---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .config.gz
Type: application/gzip
Size: 64126 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180830/71379246/attachment-0001.gz>
kbuild test robot
build botRe: [PATCH 1/2] ASoC: Add driver for PROTO Audio CODEC (with a WM8731)
In reply to Codrin CiubotariuThank you for the patch! Perhaps something to improve:
Hi Codrin,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on at91/at91-next]
[also build test WARNING on v4.19-rc1 next-20180830]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Codrin-Ciubotariu/ASoC-Add-driver-for-PROTO-Audio-CODEC-with-a-WM8731/20180830-060610 base: https://git.kernel.org/pub/scm/linux/kernel/git/nferre/linux-at91.git at91-next
coccinelle warnings: (new ones prefixed by >>)
>> sound/soc/atmel/mikroe-proto.c:178:3-8: No need to set .owner here. The core will do it.
Please review and possibly fold the followup patch.
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
kbuild test robot
build bot[PATCH] ASoC: fix platform_no_drv_owner.cocci warnings
In reply to Codrin Ciubotariusound/soc/atmel/mikroe-proto.c:178:3-8: No need to set .owner here. The core will do it.
From: kbuild test robot <[email protected]>
sound/soc/atmel/mikroe-proto.c:178:3-8: No need to set .owner here. The core will do it.
Remove .owner field if calls are used which set it automatically
Generated by: scripts/coccinelle/api/platform_no_drv_owner.cocci
---
url: https://github.com/0day-ci/linux/commits/Codrin-Ciubotariu/ASoC-Add-driver-for-PROTO-Audio-CODEC-with-a-WM8731/20180830-060610 base: https://git.kernel.org/pub/scm/linux/kernel/git/nferre/linux-at91.git at91-next
mikroe-proto.c | 1 - 1 file changed, 1 deletion(-)
sound/soc/atmel/mikroe-proto.c +0 -1
@@ -175,7 +175,6 @@ MODULE_DEVICE_TABLE(of, snd_proto_of_matstatic struct platform_driver snd_proto_driver = { .driver = { .name ="snd-mikroe-proto" , - .owner =THIS_MODULE , .of_match_table = snd_proto_of_match, }, .probe = snd_proto_probe,
PATCH 2/2 ASoC: mikroe-proto: dt-bindings: add DT bindings for PROTO board
In reply to Codrin CiubotariuDT binding documentation for this new ASoC driver.
--- .../bindings/sound/mikroe,mikroe-proto.txt | 23 +++++++++++++++++++ .../devicetree/bindings/vendor-prefixes.txt | 1 + 2 files changed, 24 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/mikroe,mikroe-proto.txt
Documentation/devicetree/bindings/sound/mikroe,mikroe-proto.txt new file +23 -0
@@ -0,0 +1,23 @@ +Mikroe-PROTO audio board + +Required properties: + - compatible: "mikroe,mikroe-proto" + - dai-format: Must be "i2s". + - i2s-controller: The phandle of the I2S controller. + - audio-codec: The phandle of the WM8731 audio codec. +Optional properties: + - model: The user-visible name of this sound complex. + - bitclock-master: Indicates dai-link bit clock master; for details see simple-card.txt (1). + - frame-master: Indicates dai-link frame master; for details see simple-card.txt (1). + +(1) : There must be the same master for both bit and frame clocks. + +Example: + sound { + compatible = "mikroe,mikroe-proto"; + model = "wm8731 @ sama5d2_xplained"; + i2s-controller = <&i2s0>; + audio-codec = <&wm8731>; + dai-format = "i2s"; + }; +};
Documentation/devicetree/bindings/vendor-prefixes.txt +1 -0
@@ -210,6 +210,7 @@ micron Micron Technology Inc. minix MINIX Technology Ltd. miramems MiraMEMS Sensing Technology Co., Ltd. mitsubishi Mitsubishi Electric Corporation +mikroe MikroElektronika d.o.o. mosaixtech Mosaix Technologies, Inc. motorola Motorola, Inc. moxa Moxa Inc.
Signature · 1 line
2.17.1