* [PATCH 0/2] ASoC: Add support for MikroElektronika PROTO codec @ 2018-08-29 14:47 Codrin Ciubotariu 2018-08-29 14:47 ` [PATCH 1/2] ASoC: Add driver for PROTO Audio CODEC (with a WM8731) Codrin Ciubotariu 2018-08-29 14:47 ` [PATCH 2/2] ASoC: mikroe-proto: dt-bindings: add DT bindings for PROTO board Codrin Ciubotariu 0 siblings, 2 replies; 11+ messages in thread From: Codrin Ciubotariu @ 2018-08-29 14:47 UTC (permalink / raw) To: alsa-devel, devicetree, broonie, robh+dt, alexandre.belloni, nicolas.ferre Cc: linux-kernel, linux-arm-kernel, florian.meier, cristian.birsan 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 -- 2.17.1 ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 1/2] ASoC: Add driver for PROTO Audio CODEC (with a WM8731) 2018-08-29 14:47 [PATCH 0/2] ASoC: Add support for MikroElektronika PROTO codec Codrin Ciubotariu @ 2018-08-29 14:47 ` Codrin Ciubotariu 2018-08-29 14:53 ` Mark Brown ` (3 more replies) 2018-08-29 14:47 ` [PATCH 2/2] ASoC: mikroe-proto: dt-bindings: add DT bindings for PROTO board Codrin Ciubotariu 1 sibling, 4 replies; 11+ messages in thread From: Codrin Ciubotariu @ 2018-08-29 14:47 UTC (permalink / raw) To: alsa-devel, devicetree, broonie, robh+dt, alexandre.belloni, nicolas.ferre Cc: linux-kernel, linux-arm-kernel, florian.meier, cristian.birsan 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/ Signed-off-by: Florian Meier <florian.meier@koalo.de> Signed-off-by: Codrin Ciubotariu <codrin.ciubotariu@microchip.com> --- 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 diff --git a/sound/soc/atmel/Kconfig b/sound/soc/atmel/Kconfig index 539ef33e670a..fbf4d3e42c18 100644 --- a/sound/soc/atmel/Kconfig +++ b/sound/soc/atmel/Kconfig @@ -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 diff --git a/sound/soc/atmel/Makefile b/sound/soc/atmel/Makefile index cd87cb4bcff5..9f41bfa0fea3 100644 --- a/sound/soc/atmel/Makefile +++ b/sound/soc/atmel/Makefile @@ -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 diff --git a/sound/soc/atmel/mikroe-proto.c b/sound/soc/atmel/mikroe-proto.c new file mode 100644 index 000000000000..9d9dc1c8ac6b --- /dev/null +++ b/sound/soc/atmel/mikroe-proto.c @@ -0,0 +1,189 @@ +/* + * ASoC driver for PROTO AudioCODEC (with a WM8731) + * + * Author: Florian Meier, <koalo@koalo.de> + * Copyright 2013 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include <linux/module.h> +#include <linux/platform_device.h> + +#include <sound/core.h> +#include <sound/pcm.h> +#include <sound/soc.h> +#include <sound/jack.h> + +#include "../codecs/wm8731.h" + +#define XTAL_RATE 12288000 /* This is fixed on this board */ + +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, + SNDRV_PCM_HW_PARAM_RATE, + &wm8731_constraints_12288000); + return 0; +} + +/* machine stream operations */ +static struct snd_soc_ops snd_proto_ops = { + .startup = snd_proto_startup, +}; + +static int snd_proto_init(struct snd_soc_pcm_runtime *rtd) +{ + struct snd_soc_codec *codec = rtd->codec; + struct snd_soc_dai *codec_dai = rtd->codec_dai; + + /* Set proto sysclk */ + int ret = snd_soc_dai_set_sysclk(codec_dai, WM8731_SYSCLK_XTAL, + XTAL_RATE, SND_SOC_CLOCK_IN); + if (ret < 0) { + dev_err(codec->dev, "Failed to set WM8731 SYSCLK: %d\n", ret); + return ret; + } + + return 0; +} + +static const struct snd_soc_dapm_widget snd_proto_widget[] = { + SND_SOC_DAPM_MIC("Microphone Jack", NULL), + SND_SOC_DAPM_HP("Headphone Jack", NULL), +}; + +static const struct snd_soc_dapm_route snd_proto_route[] = { + /* speaker connected to LHPOUT/RHPOUT */ + {"Headphone Jack", NULL, "LHPOUT"}, + {"Headphone Jack", NULL, "RHPOUT"}, + + /* mic is connected to Mic Jack, with WM8731 Mic Bias */ + {"MICIN", NULL, "Mic Bias"}, + {"Mic Bias", NULL, "Microphone Jack"}, +}; + +/* audio machine driver */ +static struct snd_soc_card snd_proto = { + .name = "snd_mikroe_proto", + .owner = THIS_MODULE, + .dapm_widgets = snd_proto_widget, + .num_dapm_widgets = ARRAY_SIZE(snd_proto_widget), + .dapm_routes = snd_proto_route, + .num_dapm_routes = ARRAY_SIZE(snd_proto_route), +}; + +static int snd_proto_probe(struct platform_device *pdev) +{ + struct snd_soc_dai_link *dai; + struct device_node *np = pdev->dev.of_node; + struct device_node *codec_np, *cpu_np; + struct device_node *bitclkmaster = NULL; + struct device_node *framemaster = NULL; + unsigned int dai_fmt; + int ret = 0; + + if (!np) { + dev_err(&pdev->dev, "No device node supplied\n"); + return -EINVAL; + } + + snd_proto.dev = &pdev->dev; + ret = snd_soc_of_parse_card_name(&snd_proto, "model"); + if (ret) + return ret; + + dai = devm_kzalloc(&pdev->dev, sizeof(*dai), GFP_KERNEL); + if (!dai) + return -ENOMEM; + + snd_proto.dai_link = dai; + snd_proto.num_links = 1; + + dai->name = "WM8731"; + dai->stream_name = "WM8731 HiFi"; + dai->codec_dai_name = "wm8731-hifi"; + dai->init = &snd_proto_init; + dai->ops = &snd_proto_ops; + + codec_np = of_parse_phandle(np, "audio-codec", 0); + if (!codec_np) { + dev_err(&pdev->dev, "audio-codec node missing\n"); + return -EINVAL; + } + dai->codec_of_node = codec_np; + + cpu_np = of_parse_phandle(np, "i2s-controller", 0); + if (!cpu_np) { + dev_err(&pdev->dev, "i2s-controller missing\n"); + return -EINVAL; + } + dai->cpu_of_node = cpu_np; + dai->platform_of_node = cpu_np; + + dai_fmt = snd_soc_of_parse_daifmt(np, NULL, + &bitclkmaster, &framemaster); + if (bitclkmaster != framemaster) { + dev_err(&pdev->dev, "Must be the same bitclock and frame master\n"); + return -EINVAL; + } + if (bitclkmaster) { + dai_fmt &= ~SND_SOC_DAIFMT_MASTER_MASK; + if (codec_np == bitclkmaster) + dai_fmt |= SND_SOC_DAIFMT_CBM_CFM; + else + dai_fmt |= SND_SOC_DAIFMT_CBS_CFS; + } + of_node_put(bitclkmaster); + of_node_put(framemaster); + dai->dai_fmt = dai_fmt; + + of_node_put(codec_np); + of_node_put(cpu_np); + + ret = snd_soc_register_card(&snd_proto); + if (ret && ret != -EPROBE_DEFER) + dev_err(&pdev->dev, + "snd_soc_register_card() failed: %d\n", ret); + + return ret; +} + +static int snd_proto_remove(struct platform_device *pdev) +{ + return snd_soc_unregister_card(&snd_proto); +} + +static const struct of_device_id snd_proto_of_match[] = { + { .compatible = "mikroe,mikroe-proto", }, + {}, +}; +MODULE_DEVICE_TABLE(of, snd_proto_of_match); + +static 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, + .remove = snd_proto_remove, +}; + +module_platform_driver(snd_proto_driver); + +MODULE_AUTHOR("Florian Meier"); +MODULE_DESCRIPTION("ASoC Driver for PROTO board (WM8731)"); +MODULE_LICENSE("GPL"); -- 2.17.1 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] ASoC: Add driver for PROTO Audio CODEC (with a WM8731) 2018-08-29 14:47 ` [PATCH 1/2] ASoC: Add driver for PROTO Audio CODEC (with a WM8731) Codrin Ciubotariu @ 2018-08-29 14:53 ` Mark Brown 2018-08-29 15:20 ` Codrin Ciubotariu 2018-08-29 23:43 ` kbuild test robot ` (2 subsequent siblings) 3 siblings, 1 reply; 11+ messages in thread From: Mark Brown @ 2018-08-29 14:53 UTC (permalink / raw) To: Codrin Ciubotariu Cc: devicetree, alsa-devel, nicolas.ferre, alexandre.belloni, linux-kernel, robh+dt, florian.meier, cristian.birsan, linux-arm-kernel [-- Attachment #1.1: Type: text/plain, Size: 970 bytes --] On Wed, Aug 29, 2018 at 05:47:26PM +0300, Codrin Ciubotariu wrote: > +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, > + 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? [-- Attachment #1.2: signature.asc --] [-- Type: application/pgp-signature, Size: 488 bytes --] [-- Attachment #2: Type: text/plain, Size: 0 bytes --] ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] ASoC: Add driver for PROTO Audio CODEC (with a WM8731) 2018-08-29 14:53 ` Mark Brown @ 2018-08-29 15:20 ` Codrin Ciubotariu 2018-08-29 15:26 ` Mark Brown 2018-08-29 15:33 ` Codrin Ciubotariu 0 siblings, 2 replies; 11+ messages in thread From: Codrin Ciubotariu @ 2018-08-29 15:20 UTC (permalink / raw) To: Mark Brown Cc: devicetree, alsa-devel, nicolas.ferre, alexandre.belloni, linux-kernel, robh+dt, florian.meier, cristian.birsan, linux-arm-kernel On 29.08.2018 17:53, Mark Brown wrote: > On Wed, Aug 29, 2018 at 05:47:26PM +0300, Codrin Ciubotariu wrote: > >> +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, >> + 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. > > 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 ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] ASoC: Add driver for PROTO Audio CODEC (with a WM8731) 2018-08-29 15:20 ` Codrin Ciubotariu @ 2018-08-29 15:26 ` Mark Brown 2018-08-29 15:33 ` Codrin Ciubotariu 1 sibling, 0 replies; 11+ messages in thread From: Mark Brown @ 2018-08-29 15:26 UTC (permalink / raw) To: Codrin Ciubotariu Cc: devicetree, alsa-devel, nicolas.ferre, alexandre.belloni, linux-kernel, robh+dt, florian.meier, cristian.birsan, linux-arm-kernel [-- Attachment #1.1: Type: text/plain, Size: 777 bytes --] On Wed, Aug 29, 2018 at 06:20:59PM +0300, Codrin Ciubotariu wrote: > On 29.08.2018 17:53, Mark Brown wrote: > > 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. 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. [-- Attachment #1.2: signature.asc --] [-- Type: application/pgp-signature, Size: 488 bytes --] [-- Attachment #2: Type: text/plain, Size: 0 bytes --] ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] ASoC: Add driver for PROTO Audio CODEC (with a WM8731) 2018-08-29 15:20 ` Codrin Ciubotariu 2018-08-29 15:26 ` Mark Brown @ 2018-08-29 15:33 ` Codrin Ciubotariu 1 sibling, 0 replies; 11+ messages in thread From: Codrin Ciubotariu @ 2018-08-29 15:33 UTC (permalink / raw) To: Mark Brown Cc: alsa-devel, devicetree, robh+dt, alexandre.belloni, nicolas.ferre, linux-kernel, linux-arm-kernel, florian.meier, cristian.birsan On 29.08.2018 18:20, Codrin Ciubotariu wrote: > On 29.08.2018 17:53, Mark Brown wrote: >> On Wed, Aug 29, 2018 at 05:47:26PM +0300, Codrin Ciubotariu wrote: >> >>> +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, >>> + 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. 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 ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] ASoC: Add driver for PROTO Audio CODEC (with a WM8731) 2018-08-29 14:47 ` [PATCH 1/2] ASoC: Add driver for PROTO Audio CODEC (with a WM8731) Codrin Ciubotariu 2018-08-29 14:53 ` Mark Brown @ 2018-08-29 23:43 ` kbuild test robot 2018-08-30 10:12 ` kbuild test robot 2018-08-30 10:13 ` [PATCH] ASoC: fix platform_no_drv_owner.cocci warnings kbuild test robot 3 siblings, 0 replies; 11+ messages in thread From: kbuild test robot @ 2018-08-29 23:43 UTC (permalink / raw) To: Codrin Ciubotariu Cc: devicetree, alsa-devel, linux-kernel, cristian.birsan, alexandre.belloni, robh+dt, nicolas.ferre, broonie, florian.meier, kbuild-all, linux-arm-kernel [-- Attachment #1: Type: text/plain, Size: 1874 bytes --] 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 [-- Attachment #2: .config.gz --] [-- Type: application/gzip, Size: 64126 bytes --] [-- Attachment #3: Type: text/plain, Size: 0 bytes --] ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] ASoC: Add driver for PROTO Audio CODEC (with a WM8731) 2018-08-29 14:47 ` [PATCH 1/2] ASoC: Add driver for PROTO Audio CODEC (with a WM8731) Codrin Ciubotariu 2018-08-29 14:53 ` Mark Brown 2018-08-29 23:43 ` kbuild test robot @ 2018-08-30 10:12 ` kbuild test robot 2018-08-30 10:13 ` [PATCH] ASoC: fix platform_no_drv_owner.cocci warnings kbuild test robot 3 siblings, 0 replies; 11+ messages in thread From: kbuild test robot @ 2018-08-30 10:12 UTC (permalink / raw) To: Codrin Ciubotariu Cc: kbuild-all, alsa-devel, devicetree, broonie, robh+dt, alexandre.belloni, nicolas.ferre, linux-kernel, linux-arm-kernel, florian.meier, cristian.birsan 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 ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH] ASoC: fix platform_no_drv_owner.cocci warnings 2018-08-29 14:47 ` [PATCH 1/2] ASoC: Add driver for PROTO Audio CODEC (with a WM8731) Codrin Ciubotariu ` (2 preceding siblings ...) 2018-08-30 10:12 ` kbuild test robot @ 2018-08-30 10:13 ` kbuild test robot 3 siblings, 0 replies; 11+ messages in thread From: kbuild test robot @ 2018-08-30 10:13 UTC (permalink / raw) To: Codrin Ciubotariu Cc: kbuild-all, alsa-devel, devicetree, broonie, robh+dt, alexandre.belloni, nicolas.ferre, linux-kernel, linux-arm-kernel, florian.meier, cristian.birsan From: kbuild test robot <fengguang.wu@intel.com> 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 Fixes: 395c2cec021d ("ASoC: Add driver for PROTO Audio CODEC (with a WM8731)") CC: Codrin Ciubotariu <codrin.ciubotariu@microchip.com> Signed-off-by: kbuild test robot <fengguang.wu@intel.com> --- 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(-) --- a/sound/soc/atmel/mikroe-proto.c +++ b/sound/soc/atmel/mikroe-proto.c @@ -175,7 +175,6 @@ MODULE_DEVICE_TABLE(of, snd_proto_of_mat static 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, ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 2/2] ASoC: mikroe-proto: dt-bindings: add DT bindings for PROTO board 2018-08-29 14:47 [PATCH 0/2] ASoC: Add support for MikroElektronika PROTO codec Codrin Ciubotariu 2018-08-29 14:47 ` [PATCH 1/2] ASoC: Add driver for PROTO Audio CODEC (with a WM8731) Codrin Ciubotariu @ 2018-08-29 14:47 ` Codrin Ciubotariu 1 sibling, 0 replies; 11+ messages in thread From: Codrin Ciubotariu @ 2018-08-29 14:47 UTC (permalink / raw) To: alsa-devel, devicetree, broonie, robh+dt, alexandre.belloni, nicolas.ferre Cc: linux-kernel, linux-arm-kernel, florian.meier, cristian.birsan DT binding documentation for this new ASoC driver. Signed-off-by: Codrin Ciubotariu <codrin.ciubotariu@microchip.com> --- .../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 diff --git a/Documentation/devicetree/bindings/sound/mikroe,mikroe-proto.txt b/Documentation/devicetree/bindings/sound/mikroe,mikroe-proto.txt new file mode 100644 index 000000000000..912f8fae11c5 --- /dev/null +++ b/Documentation/devicetree/bindings/sound/mikroe,mikroe-proto.txt @@ -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"; + }; +}; diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt index f4a98c85340a..8ac3ec1f36e5 100644 --- a/Documentation/devicetree/bindings/vendor-prefixes.txt +++ b/Documentation/devicetree/bindings/vendor-prefixes.txt @@ -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. -- 2.17.1 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH v3 3/8] ASoC: Add sun8i digital audio codec
@ 2017-01-31 11:34 kbuild test robot
2017-01-31 10:05 ` Mylène Josserand
0 siblings, 1 reply; 11+ messages in thread
From: kbuild test robot @ 2017-01-31 11:34 UTC (permalink / raw)
Cc: kbuild-all-JC7UmRfGjtg, lgirdwood-Re5JQEeQqe8AvxtiuMwx3w,
broonie-DgEjT+Ai2ygdnm+yROfE0A, robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
mark.rutland-5wv7dgnIgG8,
maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8, wens-jdAy2FN1RRM,
perex-/Fr2/VpizcU, tiwai-IBi9RG/b67k,
alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw,
devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
mylene.josserand-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
alexandre.belloni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8
Hi Mylène,
[auto build test WARNING on next-20170130]
[also build test WARNING on v4.10-rc6]
[cannot apply to asoc/for-next robh/for-next mripard/sunxi/for-next v4.9-rc8 v4.9-rc7 v4.9-rc6]
[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/Myl-ne-Josserand/Add-sun8i-A33-audio-driver/20170131-181539
coccinelle warnings: (new ones prefixed by >>)
>> sound/soc/sunxi/sun8i-codec.c:487: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
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 11+ messages in thread* [PATCH v3 3/8] ASoC: Add sun8i digital audio codec @ 2017-01-31 10:05 ` Mylène Josserand 2017-01-31 11:34 ` [PATCH] ASoC: fix platform_no_drv_owner.cocci warnings kbuild test robot 0 siblings, 1 reply; 11+ messages in thread From: Mylène Josserand @ 2017-01-31 10:05 UTC (permalink / raw) To: lgirdwood-Re5JQEeQqe8AvxtiuMwx3w, broonie-DgEjT+Ai2ygdnm+yROfE0A, robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8, maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8, wens-jdAy2FN1RRM, perex-/Fr2/VpizcU, tiwai-IBi9RG/b67k Cc: alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw, devicetree-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8, mylene.josserand-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8, alexandre.belloni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8 Add the sun8i audio codec which handles the digital register of A33 codec. The driver handles only the basic playback from the DAC to headphones. All other features (microphone, capture, etc) will be added later. Signed-off-by: Mylène Josserand <mylene.josserand-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org> --- sound/soc/sunxi/Kconfig | 11 + sound/soc/sunxi/Makefile | 1 + sound/soc/sunxi/sun8i-codec.c | 499 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 511 insertions(+) create mode 100644 sound/soc/sunxi/sun8i-codec.c diff --git a/sound/soc/sunxi/Kconfig b/sound/soc/sunxi/Kconfig index 6c344e16aca4..13a8267f17c7 100644 --- a/sound/soc/sunxi/Kconfig +++ b/sound/soc/sunxi/Kconfig @@ -9,6 +9,17 @@ config SND_SUN4I_CODEC Select Y or M to add support for the Codec embedded in the Allwinner A10 and affiliated SoCs. +config SND_SUN8I_CODEC + tristate "Allwinner SUN8I audio codec" + depends on OF + depends on MACH_SUN8I || COMPILE_TEST + select REGMAP_MMIO + help + This option enables the digital part of the internal audio codec for + Allwinner sun8i SoC (and particularly A33). + + Say Y or M if you want to add sun8i digital audio codec support. + config SND_SUN8I_CODEC_ANALOG tristate "Allwinner sun8i Codec Analog Controls Support" depends on MACH_SUN8I || COMPILE_TEST diff --git a/sound/soc/sunxi/Makefile b/sound/soc/sunxi/Makefile index 241c0df9ca0c..1f1af6271731 100644 --- a/sound/soc/sunxi/Makefile +++ b/sound/soc/sunxi/Makefile @@ -2,3 +2,4 @@ obj-$(CONFIG_SND_SUN4I_CODEC) += sun4i-codec.o obj-$(CONFIG_SND_SUN4I_I2S) += sun4i-i2s.o obj-$(CONFIG_SND_SUN4I_SPDIF) += sun4i-spdif.o obj-$(CONFIG_SND_SUN8I_CODEC_ANALOG) += sun8i-codec-analog.o +obj-$(CONFIG_SND_SUN8I_CODEC) += sun8i-codec.o diff --git a/sound/soc/sunxi/sun8i-codec.c b/sound/soc/sunxi/sun8i-codec.c new file mode 100644 index 000000000000..27fede54671b --- /dev/null +++ b/sound/soc/sunxi/sun8i-codec.c @@ -0,0 +1,499 @@ +/* + * This driver supports the digital controls for the internal codec + * found in Allwinner's A33 SoCs. + * + * (C) Copyright 2010-2016 + * Reuuimlla Technology Co., Ltd. <www.reuuimllatech.com> + * huangxin <huangxin-VvRAZUq9tDuYHARAtoI1EgC/G2K4zDHf@public.gmane.org> + * Mylène Josserand <mylene.josserand-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include <linux/module.h> +#include <linux/delay.h> +#include <linux/clk.h> +#include <linux/io.h> +#include <linux/pm_runtime.h> +#include <linux/regmap.h> + +#include <sound/pcm_params.h> +#include <sound/soc.h> +#include <sound/soc-dapm.h> + +#define SUN8I_SYSCLK_CTL 0x00c +#define SUN8I_SYSCLK_CTL_AIF1CLK_ENA 11 +#define SUN8I_SYSCLK_CTL_AIF1CLK_SRC_PLL 9 +#define SUN8I_SYSCLK_CTL_AIF1CLK_SRC 8 +#define SUN8I_SYSCLK_CTL_SYSCLK_ENA 3 +#define SUN8I_SYSCLK_CTL_SYSCLK_SRC 0 +#define SUN8I_MOD_CLK_ENA 0x010 +#define SUN8I_MOD_CLK_ENA_AIF1 15 +#define SUN8I_MOD_CLK_ENA_DAC 2 +#define SUN8I_MOD_RST_CTL 0x014 +#define SUN8I_MOD_RST_CTL_AIF1 15 +#define SUN8I_MOD_RST_CTL_DAC 2 +#define SUN8I_SYS_SR_CTRL 0x018 +#define SUN8I_SYS_SR_CTRL_AIF1_FS 12 +#define SUN8I_SYS_SR_CTRL_AIF2_FS 8 +#define SUN8I_AIF1CLK_CTRL 0x040 +#define SUN8I_AIF1CLK_CTRL_AIF1_MSTR_MOD 15 +#define SUN8I_AIF1CLK_CTRL_AIF1_BCLK_INV 14 +#define SUN8I_AIF1CLK_CTRL_AIF1_LRCK_INV 13 +#define SUN8I_AIF1CLK_CTRL_AIF1_BCLK_DIV 9 +#define SUN8I_AIF1CLK_CTRL_AIF1_LRCK_DIV 6 +#define SUN8I_AIF1CLK_CTRL_AIF1_LRCK_DIV_16 (1 << 6) +#define SUN8I_AIF1CLK_CTRL_AIF1_WORD_SIZ 4 +#define SUN8I_AIF1CLK_CTRL_AIF1_WORD_SIZ_16 (1 << 4) +#define SUN8I_AIF1CLK_CTRL_AIF1_DATA_FMT 2 +#define SUN8I_AIF1_DACDAT_CTRL 0x048 +#define SUN8I_AIF1_DACDAT_CTRL_AIF1_DA0L_ENA 15 +#define SUN8I_AIF1_DACDAT_CTRL_AIF1_DA0R_ENA 14 +#define SUN8I_DAC_DIG_CTRL 0x120 +#define SUN8I_DAC_DIG_CTRL_ENDA 15 +#define SUN8I_DAC_MXR_SRC 0x130 +#define SUN8I_DAC_MXR_SRC_DACL_MXR_SRC_AIF1DA0L 15 +#define SUN8I_DAC_MXR_SRC_DACL_MXR_SRC_AIF1DA1L 14 +#define SUN8I_DAC_MXR_SRC_DACL_MXR_SRC_AIF2DACL 13 +#define SUN8I_DAC_MXR_SRC_DACL_MXR_SRC_ADCL 12 +#define SUN8I_DAC_MXR_SRC_DACR_MXR_SRC_AIF1DA0R 11 +#define SUN8I_DAC_MXR_SRC_DACR_MXR_SRC_AIF1DA1R 10 +#define SUN8I_DAC_MXR_SRC_DACR_MXR_SRC_AIF2DACR 9 +#define SUN8I_DAC_MXR_SRC_DACR_MXR_SRC_ADCR 8 + +#define SUN8I_SYS_SR_CTRL_AIF1_FS_MASK GENMASK(15, 12) +#define SUN8I_SYS_SR_CTRL_AIF2_FS_MASK GENMASK(11, 8) +#define SUN8I_AIF1CLK_CTRL_AIF1_WORD_SIZ_MASK GENMASK(5, 4) +#define SUN8I_AIF1CLK_CTRL_AIF1_LRCK_DIV_MASK GENMASK(8, 6) + +struct sun8i_codec { + struct device *dev; + struct regmap *regmap; + struct clk *clk_module; + struct clk *clk_bus; +}; + +static int sun8i_codec_runtime_resume(struct device *dev) +{ + struct sun8i_codec *scodec = dev_get_drvdata(dev); + int ret; + + ret = clk_prepare_enable(scodec->clk_module); + if (ret) { + dev_err(dev, "Failed to enable the module clock\n"); + return ret; + } + + ret = clk_prepare_enable(scodec->clk_bus); + if (ret) { + dev_err(dev, "Failed to enable the bus clock\n"); + goto err_disable_modclk; + } + + regcache_cache_only(scodec->regmap, false); + + ret = regcache_sync(scodec->regmap); + if (ret) { + dev_err(dev, "Failed to sync regmap cache\n"); + goto err_disable_clk; + } + + return 0; + +err_disable_clk: + clk_disable_unprepare(scodec->clk_bus); + +err_disable_modclk: + clk_disable_unprepare(scodec->clk_module); + + return ret; +} + +static int sun8i_codec_runtime_suspend(struct device *dev) +{ + struct sun8i_codec *scodec = dev_get_drvdata(dev); + + regcache_cache_only(scodec->regmap, true); + regcache_mark_dirty(scodec->regmap); + + clk_disable_unprepare(scodec->clk_module); + clk_disable_unprepare(scodec->clk_bus); + + return 0; +} + +static int sun8i_codec_get_hw_rate(struct snd_pcm_hw_params *params) +{ + unsigned int rate = params_rate(params); + + switch (rate) { + case 8000: + case 7350: + return 0x0; + case 11025: + return 0x1; + case 12000: + return 0x2; + case 16000: + return 0x3; + case 22050: + return 0x4; + case 24000: + return 0x5; + case 32000: + return 0x6; + case 44100: + return 0x7; + case 48000: + return 0x8; + case 96000: + return 0x9; + case 192000: + return 0xa; + default: + return -EINVAL; + } +} + +static int sun8i_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) +{ + struct sun8i_codec *scodec = snd_soc_codec_get_drvdata(dai->codec); + u32 value; + + /* clock masters */ + switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { + case SND_SOC_DAIFMT_CBS_CFS: /* DAI Slave */ + value = 0x0; /* Codec Master */ + break; + case SND_SOC_DAIFMT_CBM_CFM: /* DAI Master */ + value = 0x1; /* Codec Slave */ + break; + default: + return -EINVAL; + } + regmap_update_bits(scodec->regmap, SUN8I_AIF1CLK_CTRL, + BIT(SUN8I_AIF1CLK_CTRL_AIF1_MSTR_MOD), + value << SUN8I_AIF1CLK_CTRL_AIF1_MSTR_MOD); + + /* clock inversion */ + switch (fmt & SND_SOC_DAIFMT_INV_MASK) { + case SND_SOC_DAIFMT_NB_NF: /* Normal */ + value = 0x0; + break; + case SND_SOC_DAIFMT_IB_IF: /* Inversion */ + value = 0x1; + break; + default: + return -EINVAL; + } + regmap_update_bits(scodec->regmap, SUN8I_AIF1CLK_CTRL, + BIT(SUN8I_AIF1CLK_CTRL_AIF1_BCLK_INV), + value << SUN8I_AIF1CLK_CTRL_AIF1_BCLK_INV); + regmap_update_bits(scodec->regmap, SUN8I_AIF1CLK_CTRL, + BIT(SUN8I_AIF1CLK_CTRL_AIF1_LRCK_INV), + value << SUN8I_AIF1CLK_CTRL_AIF1_LRCK_INV); + + /* DAI format */ + switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { + case SND_SOC_DAIFMT_I2S: + value = 0x0; + break; + case SND_SOC_DAIFMT_LEFT_J: + value = 0x1; + break; + case SND_SOC_DAIFMT_RIGHT_J: + value = 0x2; + break; + case SND_SOC_DAIFMT_DSP_A: + case SND_SOC_DAIFMT_DSP_B: + value = 0x3; + break; + default: + return -EINVAL; + } + regmap_update_bits(scodec->regmap, SUN8I_AIF1CLK_CTRL, + BIT(SUN8I_AIF1CLK_CTRL_AIF1_DATA_FMT), + value << SUN8I_AIF1CLK_CTRL_AIF1_DATA_FMT); + + return 0; +} + +static int sun8i_codec_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params, + struct snd_soc_dai *dai) +{ + struct sun8i_codec *scodec = snd_soc_codec_get_drvdata(dai->codec); + int sample_rate; + + /* + * The CPU DAI handles only a sample of 16 bits. Configure the + * codec to handle this type of sample resolution. + */ + regmap_update_bits(scodec->regmap, SUN8I_AIF1CLK_CTRL, + SUN8I_AIF1CLK_CTRL_AIF1_WORD_SIZ_MASK, + SUN8I_AIF1CLK_CTRL_AIF1_WORD_SIZ_16); + + regmap_update_bits(scodec->regmap, SUN8I_AIF1CLK_CTRL, + SUN8I_AIF1CLK_CTRL_AIF1_LRCK_DIV_MASK, + SUN8I_AIF1CLK_CTRL_AIF1_LRCK_DIV_16); + + sample_rate = sun8i_codec_get_hw_rate(params); + if (sample_rate < 0) + return sample_rate; + + regmap_update_bits(scodec->regmap, SUN8I_SYS_SR_CTRL, + SUN8I_SYS_SR_CTRL_AIF1_FS_MASK, + sample_rate << SUN8I_SYS_SR_CTRL_AIF1_FS); + regmap_update_bits(scodec->regmap, SUN8I_SYS_SR_CTRL, + SUN8I_SYS_SR_CTRL_AIF2_FS_MASK, + sample_rate << SUN8I_SYS_SR_CTRL_AIF2_FS); + + return 0; +} + +static const struct snd_kcontrol_new sun8i_output_left_mixer_controls[] = { + SOC_DAPM_SINGLE("LSlot 0", SUN8I_DAC_MXR_SRC, + SUN8I_DAC_MXR_SRC_DACL_MXR_SRC_AIF1DA0L, 1, 0), + SOC_DAPM_SINGLE("LSlot 1", SUN8I_DAC_MXR_SRC, + SUN8I_DAC_MXR_SRC_DACL_MXR_SRC_AIF1DA1L, 1, 0), + SOC_DAPM_SINGLE("DACL", SUN8I_DAC_MXR_SRC, + SUN8I_DAC_MXR_SRC_DACL_MXR_SRC_AIF2DACL, 1, 0), + SOC_DAPM_SINGLE("ADCL", SUN8I_DAC_MXR_SRC, + SUN8I_DAC_MXR_SRC_DACL_MXR_SRC_ADCL, 1, 0), +}; + +static const struct snd_kcontrol_new sun8i_output_right_mixer_controls[] = { + SOC_DAPM_SINGLE("RSlot 0", SUN8I_DAC_MXR_SRC, + SUN8I_DAC_MXR_SRC_DACR_MXR_SRC_AIF1DA0R, 1, 0), + SOC_DAPM_SINGLE("RSlot 1", SUN8I_DAC_MXR_SRC, + SUN8I_DAC_MXR_SRC_DACR_MXR_SRC_AIF1DA1R, 1, 0), + SOC_DAPM_SINGLE("DACR", SUN8I_DAC_MXR_SRC, + SUN8I_DAC_MXR_SRC_DACR_MXR_SRC_AIF2DACR, 1, 0), + SOC_DAPM_SINGLE("ADCR", SUN8I_DAC_MXR_SRC, + SUN8I_DAC_MXR_SRC_DACR_MXR_SRC_ADCR, 1, 0), +}; + +static const struct snd_soc_dapm_widget sun8i_codec_dapm_widgets[] = { + /* Digital parts of the DACs */ + SND_SOC_DAPM_SUPPLY("DAC", SUN8I_DAC_DIG_CTRL, SUN8I_DAC_DIG_CTRL_ENDA, + 0, NULL, 0), + + /* Analog DAC */ + SND_SOC_DAPM_DAC("Digital Left DAC", "Playback", SUN8I_AIF1_DACDAT_CTRL, + SUN8I_AIF1_DACDAT_CTRL_AIF1_DA0L_ENA, 0), + SND_SOC_DAPM_DAC("Digital Right DAC", "Playback", SUN8I_AIF1_DACDAT_CTRL, + SUN8I_AIF1_DACDAT_CTRL_AIF1_DA0R_ENA, 0), + + /* DAC Mixers */ + SND_SOC_DAPM_MIXER("Left DAC Mixer", SND_SOC_NOPM, 0, 0, + sun8i_output_left_mixer_controls, + ARRAY_SIZE(sun8i_output_left_mixer_controls)), + SND_SOC_DAPM_MIXER("Right DAC Mixer", SND_SOC_NOPM, 0, 0, + sun8i_output_right_mixer_controls, + ARRAY_SIZE(sun8i_output_right_mixer_controls)), + + /* Clocks */ + SND_SOC_DAPM_SUPPLY("MODCLK AFI1", SUN8I_MOD_CLK_ENA, + SUN8I_MOD_CLK_ENA_AIF1, 0, NULL, 0), + SND_SOC_DAPM_SUPPLY("MODCLK DAC", SUN8I_MOD_CLK_ENA, + SUN8I_MOD_CLK_ENA_DAC, 0, NULL, 0), + SND_SOC_DAPM_SUPPLY("AIF1", SUN8I_SYSCLK_CTL, + SUN8I_SYSCLK_CTL_AIF1CLK_ENA, 0, NULL, 0), + SND_SOC_DAPM_SUPPLY("SYSCLK", SUN8I_SYSCLK_CTL, + SUN8I_SYSCLK_CTL_SYSCLK_ENA, 0, NULL, 0), + + SND_SOC_DAPM_SUPPLY("AIF1 PLL", SUN8I_SYSCLK_CTL, + SUN8I_SYSCLK_CTL_AIF1CLK_SRC_PLL, 0, NULL, 0), + /* Inversion as 0=AIF1, 1=AIF2 */ + SND_SOC_DAPM_SUPPLY("SYSCLK AIF1", SUN8I_SYSCLK_CTL, + SUN8I_SYSCLK_CTL_SYSCLK_SRC, 1, NULL, 0), + + /* Module reset */ + SND_SOC_DAPM_SUPPLY("RST AIF1", SUN8I_MOD_RST_CTL, + SUN8I_MOD_RST_CTL_AIF1, 0, NULL, 0), + SND_SOC_DAPM_SUPPLY("RST DAC", SUN8I_MOD_RST_CTL, + SUN8I_MOD_RST_CTL_DAC, 0, NULL, 0), + + SND_SOC_DAPM_OUTPUT("HP"), +}; + +static const struct snd_soc_dapm_route sun8i_codec_dapm_routes[] = { + /* Clock Routes */ + { "AIF1", NULL, "SYSCLK AIF1" }, + { "AIF1 PLL", NULL, "AIF1" }, + { "RST AIF1", NULL, "AIF1 PLL" }, + { "MODCLK AFI1", NULL, "RST AIF1" }, + { "DAC", NULL, "MODCLK AFI1" }, + + { "RST DAC", NULL, "SYSCLK" }, + { "MODCLK DAC", NULL, "RST DAC" }, + { "DAC", NULL, "MODCLK DAC" }, + + /* DAC Routes */ + { "Digital Left DAC", NULL, "DAC" }, + { "Digital Right DAC", NULL, "DAC" }, + + /* DAC Mixer Routes */ + { "Left DAC Mixer", "LSlot 0", "Digital Left DAC"}, + { "Right DAC Mixer", "RSlot 0", "Digital Right DAC"}, + + /* End of route : HP out */ + { "HP", NULL, "Left DAC Mixer" }, + { "HP", NULL, "Right DAC Mixer" }, +}; + +static struct snd_soc_dai_ops sun8i_codec_dai_ops = { + .hw_params = sun8i_codec_hw_params, + .set_fmt = sun8i_set_fmt, +}; + +static struct snd_soc_dai_driver sun8i_codec_dai = { + .name = "sun8i", + /* playback capabilities */ + .playback = { + .stream_name = "Playback", + .channels_min = 1, + .channels_max = 2, + .rates = SNDRV_PCM_RATE_8000_192000, + .formats = SNDRV_PCM_FMTBIT_S16_LE, + }, + /* pcm operations */ + .ops = &sun8i_codec_dai_ops, +}; + +static struct snd_soc_codec_driver sun8i_soc_codec = { + .component_driver = { + .dapm_widgets = sun8i_codec_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(sun8i_codec_dapm_widgets), + .dapm_routes = sun8i_codec_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(sun8i_codec_dapm_routes), + }, +}; + +static const struct regmap_config sun8i_codec_regmap_config = { + .reg_bits = 32, + .reg_stride = 4, + .val_bits = 32, + .max_register = SUN8I_DAC_MXR_SRC, + + .cache_type = REGCACHE_FLAT, +}; + +static int sun8i_codec_probe(struct platform_device *pdev) +{ + struct resource *res_base; + struct sun8i_codec *scodec; + void __iomem *base; + int ret; + + scodec = devm_kzalloc(&pdev->dev, sizeof(*scodec), GFP_KERNEL); + if (!scodec) + return -ENOMEM; + + scodec->dev = &pdev->dev; + + scodec->clk_module = devm_clk_get(&pdev->dev, "mod"); + if (IS_ERR(scodec->clk_module)) { + dev_err(&pdev->dev, "Failed to get the module clock\n"); + return PTR_ERR(scodec->clk_module); + } + + scodec->clk_bus = devm_clk_get(&pdev->dev, "bus"); + if (IS_ERR(scodec->clk_bus)) { + dev_err(&pdev->dev, "Failed to get the bus clock\n"); + return PTR_ERR(scodec->clk_bus); + } + + res_base = platform_get_resource(pdev, IORESOURCE_MEM, 0); + base = devm_ioremap_resource(&pdev->dev, res_base); + if (IS_ERR(base)) { + dev_err(&pdev->dev, "Failed to map the registers\n"); + return PTR_ERR(base); + } + + scodec->regmap = devm_regmap_init_mmio(&pdev->dev, base, + &sun8i_codec_regmap_config); + if (IS_ERR(scodec->regmap)) { + dev_err(&pdev->dev, "Failed to create our regmap\n"); + return PTR_ERR(scodec->regmap); + } + + platform_set_drvdata(pdev, scodec); + + pm_runtime_enable(&pdev->dev); + if (!pm_runtime_enabled(&pdev->dev)) { + ret = sun8i_codec_runtime_resume(&pdev->dev); + if (ret) + goto err_pm_disable; + } + + ret = snd_soc_register_codec(&pdev->dev, &sun8i_soc_codec, + &sun8i_codec_dai, 1); + if (ret) { + dev_err(&pdev->dev, "Failed to register codec\n"); + goto err_suspend; + } + + return ret; + +err_suspend: + if (!pm_runtime_status_suspended(&pdev->dev)) + sun8i_codec_runtime_suspend(&pdev->dev); + +err_pm_disable: + pm_runtime_disable(&pdev->dev); + + return ret; +} + +static int sun8i_codec_remove(struct platform_device *pdev) +{ + struct snd_soc_card *card = platform_get_drvdata(pdev); + struct sun8i_codec *scodec = snd_soc_card_get_drvdata(card); + + pm_runtime_disable(&pdev->dev); + if (!pm_runtime_status_suspended(&pdev->dev)) + sun8i_codec_runtime_suspend(&pdev->dev); + + snd_soc_unregister_codec(&pdev->dev); + clk_disable_unprepare(scodec->clk_module); + clk_disable_unprepare(scodec->clk_bus); + + return 0; +} + +static const struct of_device_id sun8i_codec_of_match[] = { + { .compatible = "allwinner,sun8i-a33-codec" }, + {} +}; +MODULE_DEVICE_TABLE(of, sun8i_codec_of_match); + +static const struct dev_pm_ops sun8i_codec_pm_ops = { + SET_RUNTIME_PM_OPS(sun8i_codec_runtime_suspend, + sun8i_codec_runtime_resume, NULL) +}; + +static struct platform_driver sun8i_codec_driver = { + .driver = { + .name = "sun8i-codec", + .owner = THIS_MODULE, + .of_match_table = sun8i_codec_of_match, + .pm = &sun8i_codec_pm_ops, + }, + .probe = sun8i_codec_probe, + .remove = sun8i_codec_remove, +}; +module_platform_driver(sun8i_codec_driver); + +MODULE_DESCRIPTION("Allwinner A33 (sun8i) codec driver"); +MODULE_AUTHOR("Mylène Josserand <mylene.josserand-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:sun8i-codec"); -- 2.11.0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH] ASoC: fix platform_no_drv_owner.cocci warnings 2017-01-31 10:05 ` Mylène Josserand @ 2017-01-31 11:34 ` kbuild test robot 0 siblings, 0 replies; 11+ messages in thread From: kbuild test robot @ 2017-01-31 11:34 UTC (permalink / raw) Cc: mark.rutland, devicetree, alsa-devel, linux-kernel, tiwai, lgirdwood, robh+dt, wens, broonie, alexandre.belloni, kbuild-all, maxime.ripard, mylene.josserand, thomas.petazzoni, linux-arm-kernel sound/soc/sunxi/sun8i-codec.c:487: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 CC: Mylène Josserand <mylene.josserand@free-electrons.com> Signed-off-by: Fengguang Wu <fengguang.wu@intel.com> --- sun8i-codec.c | 1 - 1 file changed, 1 deletion(-) --- a/sound/soc/sunxi/sun8i-codec.c +++ b/sound/soc/sunxi/sun8i-codec.c @@ -484,7 +484,6 @@ static const struct dev_pm_ops sun8i_cod static struct platform_driver sun8i_codec_driver = { .driver = { .name = "sun8i-codec", - .owner = THIS_MODULE, .of_match_table = sun8i_codec_of_match, .pm = &sun8i_codec_pm_ops, }, ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2018-08-30 10:13 UTC | newest] Thread overview: 11+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2018-08-29 14:47 [PATCH 0/2] ASoC: Add support for MikroElektronika PROTO codec Codrin Ciubotariu 2018-08-29 14:47 ` [PATCH 1/2] ASoC: Add driver for PROTO Audio CODEC (with a WM8731) Codrin Ciubotariu 2018-08-29 14:53 ` Mark Brown 2018-08-29 15:20 ` Codrin Ciubotariu 2018-08-29 15:26 ` Mark Brown 2018-08-29 15:33 ` Codrin Ciubotariu 2018-08-29 23:43 ` kbuild test robot 2018-08-30 10:12 ` kbuild test robot 2018-08-30 10:13 ` [PATCH] ASoC: fix platform_no_drv_owner.cocci warnings kbuild test robot 2018-08-29 14:47 ` [PATCH 2/2] ASoC: mikroe-proto: dt-bindings: add DT bindings for PROTO board Codrin Ciubotariu -- strict thread matches above, loose matches on Subject: below -- 2017-01-31 11:34 [PATCH v3 3/8] ASoC: Add sun8i digital audio codec kbuild test robot 2017-01-31 10:05 ` Mylène Josserand 2017-01-31 11:34 ` [PATCH] ASoC: fix platform_no_drv_owner.cocci warnings kbuild test robot
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).