Re: [PATCH 07/14] ASoC: Add sun8i audio card

2016-10-05 Thread Jean-Francois Moine
On Wed, 5 Oct 2016 08:04:26 +0200
Code Kipper  wrote:

> > +static int sun8i_probe(struct platform_device *pdev)
> > +{
> > +   struct snd_soc_dai_link *link = _dai_link;
> > +   struct device_node *np = pdev->dev.of_node;
> > +   int ret;
> > +
> > +   /* register the soc card */
> > +   sun8i_card.dev = >dev;
> > +
> > +   /* Retrieve the audio-codec from DT */
> > +   link->codec_of_node = of_parse_phandle(np, "allwinner,audio-codec", 
> > 0);
> > +   if (!link->codec_of_node) {
> > +   dev_err(>dev, "Missing audio codec\n");
> > +   return -EINVAL;
> > +   }
> > +
> > +   /* Retrieve DAI from DT */
> > +   link->cpu_of_node = of_parse_phandle(np, 
> > "allwinner,i2s-controller", 0);
> Now that I've spent some time trying to add my changes for the H3
> ontop of your code,  I think this file should be more generic and rely
> on the dtsi more. It's pretty A33 specific but with little effort it
> can be worked to cover all of the sun8i type drivers. I would change
> "allwinner,i2s-controller" to "allwinner,audio-dai" for starters and
> then maybe pull in some info for the dai-link from the dtsi.
> CK
[snip]

In fact, there should be no audio card driver as proposed here:
with such a simple layout
CPU DAI (sun4i-a10-i2s) -> CODEC DAI (sun8i-a33-codec)
the 'simple-card' does the job.

BTW, I have a I2S/PCM/TDM driver for the H3 and A83T.
But, as it works with HDMI and contains echanges with the DRM driver,
it cannot go yet to the mainline...

-- 
Ken ar c'hentañ | ** Breizh ha Linux atav! **
Jef |   http://moinejf.free.fr/


Re: [PATCH 07/14] ASoC: Add sun8i audio card

2016-10-05 Thread Jean-Francois Moine
On Wed, 5 Oct 2016 08:04:26 +0200
Code Kipper  wrote:

> > +static int sun8i_probe(struct platform_device *pdev)
> > +{
> > +   struct snd_soc_dai_link *link = _dai_link;
> > +   struct device_node *np = pdev->dev.of_node;
> > +   int ret;
> > +
> > +   /* register the soc card */
> > +   sun8i_card.dev = >dev;
> > +
> > +   /* Retrieve the audio-codec from DT */
> > +   link->codec_of_node = of_parse_phandle(np, "allwinner,audio-codec", 
> > 0);
> > +   if (!link->codec_of_node) {
> > +   dev_err(>dev, "Missing audio codec\n");
> > +   return -EINVAL;
> > +   }
> > +
> > +   /* Retrieve DAI from DT */
> > +   link->cpu_of_node = of_parse_phandle(np, 
> > "allwinner,i2s-controller", 0);
> Now that I've spent some time trying to add my changes for the H3
> ontop of your code,  I think this file should be more generic and rely
> on the dtsi more. It's pretty A33 specific but with little effort it
> can be worked to cover all of the sun8i type drivers. I would change
> "allwinner,i2s-controller" to "allwinner,audio-dai" for starters and
> then maybe pull in some info for the dai-link from the dtsi.
> CK
[snip]

In fact, there should be no audio card driver as proposed here:
with such a simple layout
CPU DAI (sun4i-a10-i2s) -> CODEC DAI (sun8i-a33-codec)
the 'simple-card' does the job.

BTW, I have a I2S/PCM/TDM driver for the H3 and A83T.
But, as it works with HDMI and contains echanges with the DRM driver,
it cannot go yet to the mainline...

-- 
Ken ar c'hentañ | ** Breizh ha Linux atav! **
Jef |   http://moinejf.free.fr/


Re: [PATCH 07/14] ASoC: Add sun8i audio card

2016-10-05 Thread Code Kipper
On 4 October 2016 at 11:46, Mylène Josserand
 wrote:
> Add the audio card for sun8i SoC. This card links the codec driver
> (digital part) with the DAI driver. The analog codec driver is
> added as an aux_device.
>
> Signed-off-by: Mylène Josserand 
> ---
>  sound/soc/sunxi/Kconfig  |  14 +++
>  sound/soc/sunxi/Makefile |   1 +
>  sound/soc/sunxi/sun8i.c  | 101 
> +++
>  3 files changed, 116 insertions(+)
>  create mode 100644 sound/soc/sunxi/sun8i.c
>
> diff --git a/sound/soc/sunxi/Kconfig b/sound/soc/sunxi/Kconfig
> index 9e287b0..7b97395 100644
> --- a/sound/soc/sunxi/Kconfig
> +++ b/sound/soc/sunxi/Kconfig
> @@ -27,6 +27,20 @@ config SND_SUN4I_SPDIF
>   Say Y or M to add support for the S/PDIF audio block in the 
> Allwinner
>   A10 and affiliated SoCs.
>
> +config SND_SUN8I
> +   tristate "Allwinner SUN6I/SUN8I audio card support"
> +   select SND_SUN8I_CODEC
> +   select SND_SUN4I_I2S
> +   select SND_SUN8I_CODEC_ANALOG
> +   select REGMAP_MMIO
> +   help
> + This option enables the audio card for Allwinner A33 (sun8i) SoC.
> + It enables the DAI driver (SND_SUN4I_I2S), the digital audio
> + codec driver (SND_SUN8I_CODEC) and the analog codec driver
> + (SND_SUN8I_CODEC_ANALOG).
> +
> + Say Y or M if you want to add sun8i/6i card support
> +
>  config SND_SUN8I_CODEC
> tristate "Allwinner SUN8I audio codec"
> select REGMAP_MMIO
> diff --git a/sound/soc/sunxi/Makefile b/sound/soc/sunxi/Makefile
> index 1da63d3..7f1bab9 100644
> --- a/sound/soc/sunxi/Makefile
> +++ b/sound/soc/sunxi/Makefile
> @@ -1,5 +1,6 @@
>  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) += sun8i.o
>  obj-$(CONFIG_SND_SUN8I_CODEC) += sun8i-codec.o
>  obj-$(CONFIG_SND_SUN8I_CODEC_ANALOG) += sun8i-codec-analog.o
> diff --git a/sound/soc/sunxi/sun8i.c b/sound/soc/sunxi/sun8i.c
> new file mode 100644
> index 000..565cd88
> --- /dev/null
> +++ b/sound/soc/sunxi/sun8i.c
> @@ -0,0 +1,101 @@
> +/*
> + * ALSA SoC driver for Allwinner sun8i SoC
> + *
> + * Copyright (C) 2016 Mylène Josserand 
> + *
> + * 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 
> +#include 
> +
> +#include 
> +
> +static struct snd_soc_aux_dev sun8i_audio_prcm_aux_devs[] = {
> +   {
> +   .name = "sun8i-codec-analog",
> +   .codec_name = "sun8i-codec-analog.0",
> +   },
> +};
> +
> +static struct snd_soc_dai_link sun8i_dai_link = {
> +   .name   = "sun4i-i2s",
> +   .stream_name= "Playback",
> +   .codec_dai_name = "sun8i",
> +   .dai_fmt= SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_I2S |
> +   SND_SOC_DAIFMT_CBM_CFM,
> +};
> +
> +static struct snd_soc_card sun8i_card = {
> +   .name   = "sun8i-card",
> +   .owner  = THIS_MODULE,
> +   .dai_link   = _dai_link,
> +   .num_links  = 1,
> +   .aux_dev= sun8i_audio_prcm_aux_devs,
> +   .num_aux_devs   = ARRAY_SIZE(sun8i_audio_prcm_aux_devs),
> +};
> +
> +static int sun8i_probe(struct platform_device *pdev)
> +{
> +   struct snd_soc_dai_link *link = _dai_link;
> +   struct device_node *np = pdev->dev.of_node;
> +   int ret;
> +
> +   /* register the soc card */
> +   sun8i_card.dev = >dev;
> +
> +   /* Retrieve the audio-codec from DT */
> +   link->codec_of_node = of_parse_phandle(np, "allwinner,audio-codec", 
> 0);
> +   if (!link->codec_of_node) {
> +   dev_err(>dev, "Missing audio codec\n");
> +   return -EINVAL;
> +   }
> +
> +   /* Retrieve DAI from DT */
> +   link->cpu_of_node = of_parse_phandle(np, "allwinner,i2s-controller", 
> 0);
Now that I've spent some time trying to add my changes for the H3
ontop of your code,  I think this file should be more generic and rely
on the dtsi more. It's pretty A33 specific but with little effort it
can be worked to cover all of the sun8i type drivers. I would change
"allwinner,i2s-controller" to "allwinner,audio-dai" for starters and
then maybe pull in some info for the dai-link from the dtsi.
CK
> +   if (!link->cpu_of_node) {
> +   dev_err(>dev, "Missing I2S controller\n");
> +   

Re: [PATCH 07/14] ASoC: Add sun8i audio card

2016-10-05 Thread Code Kipper
On 4 October 2016 at 11:46, Mylène Josserand
 wrote:
> Add the audio card for sun8i SoC. This card links the codec driver
> (digital part) with the DAI driver. The analog codec driver is
> added as an aux_device.
>
> Signed-off-by: Mylène Josserand 
> ---
>  sound/soc/sunxi/Kconfig  |  14 +++
>  sound/soc/sunxi/Makefile |   1 +
>  sound/soc/sunxi/sun8i.c  | 101 
> +++
>  3 files changed, 116 insertions(+)
>  create mode 100644 sound/soc/sunxi/sun8i.c
>
> diff --git a/sound/soc/sunxi/Kconfig b/sound/soc/sunxi/Kconfig
> index 9e287b0..7b97395 100644
> --- a/sound/soc/sunxi/Kconfig
> +++ b/sound/soc/sunxi/Kconfig
> @@ -27,6 +27,20 @@ config SND_SUN4I_SPDIF
>   Say Y or M to add support for the S/PDIF audio block in the 
> Allwinner
>   A10 and affiliated SoCs.
>
> +config SND_SUN8I
> +   tristate "Allwinner SUN6I/SUN8I audio card support"
> +   select SND_SUN8I_CODEC
> +   select SND_SUN4I_I2S
> +   select SND_SUN8I_CODEC_ANALOG
> +   select REGMAP_MMIO
> +   help
> + This option enables the audio card for Allwinner A33 (sun8i) SoC.
> + It enables the DAI driver (SND_SUN4I_I2S), the digital audio
> + codec driver (SND_SUN8I_CODEC) and the analog codec driver
> + (SND_SUN8I_CODEC_ANALOG).
> +
> + Say Y or M if you want to add sun8i/6i card support
> +
>  config SND_SUN8I_CODEC
> tristate "Allwinner SUN8I audio codec"
> select REGMAP_MMIO
> diff --git a/sound/soc/sunxi/Makefile b/sound/soc/sunxi/Makefile
> index 1da63d3..7f1bab9 100644
> --- a/sound/soc/sunxi/Makefile
> +++ b/sound/soc/sunxi/Makefile
> @@ -1,5 +1,6 @@
>  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) += sun8i.o
>  obj-$(CONFIG_SND_SUN8I_CODEC) += sun8i-codec.o
>  obj-$(CONFIG_SND_SUN8I_CODEC_ANALOG) += sun8i-codec-analog.o
> diff --git a/sound/soc/sunxi/sun8i.c b/sound/soc/sunxi/sun8i.c
> new file mode 100644
> index 000..565cd88
> --- /dev/null
> +++ b/sound/soc/sunxi/sun8i.c
> @@ -0,0 +1,101 @@
> +/*
> + * ALSA SoC driver for Allwinner sun8i SoC
> + *
> + * Copyright (C) 2016 Mylène Josserand 
> + *
> + * 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 
> +#include 
> +
> +#include 
> +
> +static struct snd_soc_aux_dev sun8i_audio_prcm_aux_devs[] = {
> +   {
> +   .name = "sun8i-codec-analog",
> +   .codec_name = "sun8i-codec-analog.0",
> +   },
> +};
> +
> +static struct snd_soc_dai_link sun8i_dai_link = {
> +   .name   = "sun4i-i2s",
> +   .stream_name= "Playback",
> +   .codec_dai_name = "sun8i",
> +   .dai_fmt= SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_I2S |
> +   SND_SOC_DAIFMT_CBM_CFM,
> +};
> +
> +static struct snd_soc_card sun8i_card = {
> +   .name   = "sun8i-card",
> +   .owner  = THIS_MODULE,
> +   .dai_link   = _dai_link,
> +   .num_links  = 1,
> +   .aux_dev= sun8i_audio_prcm_aux_devs,
> +   .num_aux_devs   = ARRAY_SIZE(sun8i_audio_prcm_aux_devs),
> +};
> +
> +static int sun8i_probe(struct platform_device *pdev)
> +{
> +   struct snd_soc_dai_link *link = _dai_link;
> +   struct device_node *np = pdev->dev.of_node;
> +   int ret;
> +
> +   /* register the soc card */
> +   sun8i_card.dev = >dev;
> +
> +   /* Retrieve the audio-codec from DT */
> +   link->codec_of_node = of_parse_phandle(np, "allwinner,audio-codec", 
> 0);
> +   if (!link->codec_of_node) {
> +   dev_err(>dev, "Missing audio codec\n");
> +   return -EINVAL;
> +   }
> +
> +   /* Retrieve DAI from DT */
> +   link->cpu_of_node = of_parse_phandle(np, "allwinner,i2s-controller", 
> 0);
Now that I've spent some time trying to add my changes for the H3
ontop of your code,  I think this file should be more generic and rely
on the dtsi more. It's pretty A33 specific but with little effort it
can be worked to cover all of the sun8i type drivers. I would change
"allwinner,i2s-controller" to "allwinner,audio-dai" for starters and
then maybe pull in some info for the dai-link from the dtsi.
CK
> +   if (!link->cpu_of_node) {
> +   dev_err(>dev, "Missing I2S controller\n");
> +   return -EINVAL;
> +   }
> +
> +   link->platform_of_node = link->cpu_of_node;
> +
> +   /* Register 

Re: [PATCH 07/14] ASoC: Add sun8i audio card

2016-10-04 Thread Thomas Petazzoni
Hello,

On Tue,  4 Oct 2016 11:46:20 +0200, Mylène Josserand wrote:

> +config SND_SUN8I
> + tristate "Allwinner SUN6I/SUN8I audio card support"
> + select SND_SUN8I_CODEC
> + select SND_SUN4I_I2S
> + select SND_SUN8I_CODEC_ANALOG
> + select REGMAP_MMIO

I believe you need a:

depends on OF

since you're unconditionally using some DT-related functionality in the
driver code.

> +#include 

Do you really need this header file? I don't see anything
firmware-loading related in the driver.

> +static int sun8i_probe(struct platform_device *pdev)
> +{
> + struct snd_soc_dai_link *link = _dai_link;
> + struct device_node *np = pdev->dev.of_node;
> + int ret;
> +
> + /* register the soc card */
> + sun8i_card.dev = >dev;
> +
> + /* Retrieve the audio-codec from DT */
> + link->codec_of_node = of_parse_phandle(np, "allwinner,audio-codec", 0);

Whenever you're using of_parse_phandle(), you must have a corresponding
of_node_put() to release the reference to the Device Tree node. So I
guess this should be done 1/ in the error path of ->probe(), and 2/
during the ->remove() hook.

Best regards,

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com


Re: [PATCH 07/14] ASoC: Add sun8i audio card

2016-10-04 Thread Thomas Petazzoni
Hello,

On Tue,  4 Oct 2016 11:46:20 +0200, Mylène Josserand wrote:

> +config SND_SUN8I
> + tristate "Allwinner SUN6I/SUN8I audio card support"
> + select SND_SUN8I_CODEC
> + select SND_SUN4I_I2S
> + select SND_SUN8I_CODEC_ANALOG
> + select REGMAP_MMIO

I believe you need a:

depends on OF

since you're unconditionally using some DT-related functionality in the
driver code.

> +#include 

Do you really need this header file? I don't see anything
firmware-loading related in the driver.

> +static int sun8i_probe(struct platform_device *pdev)
> +{
> + struct snd_soc_dai_link *link = _dai_link;
> + struct device_node *np = pdev->dev.of_node;
> + int ret;
> +
> + /* register the soc card */
> + sun8i_card.dev = >dev;
> +
> + /* Retrieve the audio-codec from DT */
> + link->codec_of_node = of_parse_phandle(np, "allwinner,audio-codec", 0);

Whenever you're using of_parse_phandle(), you must have a corresponding
of_node_put() to release the reference to the Device Tree node. So I
guess this should be done 1/ in the error path of ->probe(), and 2/
during the ->remove() hook.

Best regards,

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com


Re: [PATCH 07/14] ASoC: Add sun8i audio card

2016-10-04 Thread Chen-Yu Tsai
On Tue, Oct 4, 2016 at 6:16 PM, Code Kipper  wrote:
> On 4 October 2016 at 11:46, Mylène Josserand
>  wrote:
>> Add the audio card for sun8i SoC. This card links the codec driver
>> (digital part) with the DAI driver. The analog codec driver is
>> added as an aux_device.
>>
>> Signed-off-by: Mylène Josserand 
>> ---
>>  sound/soc/sunxi/Kconfig  |  14 +++
>>  sound/soc/sunxi/Makefile |   1 +
>>  sound/soc/sunxi/sun8i.c  | 101 
>> +++
>>  3 files changed, 116 insertions(+)
>>  create mode 100644 sound/soc/sunxi/sun8i.c
>>
>> diff --git a/sound/soc/sunxi/Kconfig b/sound/soc/sunxi/Kconfig
>> index 9e287b0..7b97395 100644
>> --- a/sound/soc/sunxi/Kconfig
>> +++ b/sound/soc/sunxi/Kconfig
>> @@ -27,6 +27,20 @@ config SND_SUN4I_SPDIF
>>   Say Y or M to add support for the S/PDIF audio block in the 
>> Allwinner
>>   A10 and affiliated SoCs.
>>
>> +config SND_SUN8I
>> +   tristate "Allwinner SUN6I/SUN8I audio card support"
>> +   select SND_SUN8I_CODEC
>> +   select SND_SUN4I_I2S
>> +   select SND_SUN8I_CODEC_ANALOG
>> +   select REGMAP_MMIO
>> +   help
>> + This option enables the audio card for Allwinner A33 (sun8i) SoC.
>> + It enables the DAI driver (SND_SUN4I_I2S), the digital audio
>> + codec driver (SND_SUN8I_CODEC) and the analog codec driver
>> + (SND_SUN8I_CODEC_ANALOG).
>> +
>> + Say Y or M if you want to add sun8i/6i card support
>> +
>>  config SND_SUN8I_CODEC
>> tristate "Allwinner SUN8I audio codec"
>> select REGMAP_MMIO
>> diff --git a/sound/soc/sunxi/Makefile b/sound/soc/sunxi/Makefile
>> index 1da63d3..7f1bab9 100644
>> --- a/sound/soc/sunxi/Makefile
>> +++ b/sound/soc/sunxi/Makefile
>> @@ -1,5 +1,6 @@
>>  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) += sun8i.o
> Great work with this...I've been battling with the audio codec for the
> h3 for a while and it looks like almost everything that I need is
> delivered here.
>>  obj-$(CONFIG_SND_SUN8I_CODEC) += sun8i-codec.o
>>  obj-$(CONFIG_SND_SUN8I_CODEC_ANALOG) += sun8i-codec-analog.o
>> diff --git a/sound/soc/sunxi/sun8i.c b/sound/soc/sunxi/sun8i.c
>> new file mode 100644
>> index 000..565cd88
>> --- /dev/null
>> +++ b/sound/soc/sunxi/sun8i.c
>> @@ -0,0 +1,101 @@
>> +/*
>> + * ALSA SoC driver for Allwinner sun8i SoC
>> + *
>> + * Copyright (C) 2016 Mylène Josserand 
>> + *
>> + * 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 
>> +#include 
>> +
>> +#include 
>> +
>> +static struct snd_soc_aux_dev sun8i_audio_prcm_aux_devs[] = {
>> +   {
>> +   .name = "sun8i-codec-analog",
>> +   .codec_name = "sun8i-codec-analog.0",
>> +   },
>> +};
>> +
>> +static struct snd_soc_dai_link sun8i_dai_link = {
>> +   .name   = "sun4i-i2s",
>> +   .stream_name= "Playback",
>> +   .codec_dai_name = "sun8i",
>> +   .dai_fmt= SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_I2S |
>> +   SND_SOC_DAIFMT_CBM_CFM,
>> +};
>> +
>> +static struct snd_soc_card sun8i_card = {
>> +   .name   = "sun8i-card",
>> +   .owner  = THIS_MODULE,
>> +   .dai_link   = _dai_link,
>> +   .num_links  = 1,
>> +   .aux_dev= sun8i_audio_prcm_aux_devs,
>> +   .num_aux_devs   = ARRAY_SIZE(sun8i_audio_prcm_aux_devs),
>> +};
>> +
>> +static int sun8i_probe(struct platform_device *pdev)
>> +{
>> +   struct snd_soc_dai_link *link = _dai_link;
>> +   struct device_node *np = pdev->dev.of_node;
>> +   int ret;
>> +
>> +   /* register the soc card */
>> +   sun8i_card.dev = >dev;
>> +
>> +   /* Retrieve the audio-codec from DT */
>> +   link->codec_of_node = of_parse_phandle(np, "allwinner,audio-codec", 
>> 0);
>> +   if (!link->codec_of_node) {
>> +   dev_err(>dev, "Missing audio codec\n");
>> +   return -EINVAL;
>> +   }
>> +
>> +   /* Retrieve DAI from DT */
>> +   link->cpu_of_node = of_parse_phandle(np, "allwinner,i2s-controller", 
>> 0);
>> +   if (!link->cpu_of_node) {
>> +   dev_err(>dev, "Missing I2S controller\n");
>> +   return -EINVAL;
>> +   }
>> +
> My one 

Re: [PATCH 07/14] ASoC: Add sun8i audio card

2016-10-04 Thread Chen-Yu Tsai
On Tue, Oct 4, 2016 at 6:16 PM, Code Kipper  wrote:
> On 4 October 2016 at 11:46, Mylène Josserand
>  wrote:
>> Add the audio card for sun8i SoC. This card links the codec driver
>> (digital part) with the DAI driver. The analog codec driver is
>> added as an aux_device.
>>
>> Signed-off-by: Mylène Josserand 
>> ---
>>  sound/soc/sunxi/Kconfig  |  14 +++
>>  sound/soc/sunxi/Makefile |   1 +
>>  sound/soc/sunxi/sun8i.c  | 101 
>> +++
>>  3 files changed, 116 insertions(+)
>>  create mode 100644 sound/soc/sunxi/sun8i.c
>>
>> diff --git a/sound/soc/sunxi/Kconfig b/sound/soc/sunxi/Kconfig
>> index 9e287b0..7b97395 100644
>> --- a/sound/soc/sunxi/Kconfig
>> +++ b/sound/soc/sunxi/Kconfig
>> @@ -27,6 +27,20 @@ config SND_SUN4I_SPDIF
>>   Say Y or M to add support for the S/PDIF audio block in the 
>> Allwinner
>>   A10 and affiliated SoCs.
>>
>> +config SND_SUN8I
>> +   tristate "Allwinner SUN6I/SUN8I audio card support"
>> +   select SND_SUN8I_CODEC
>> +   select SND_SUN4I_I2S
>> +   select SND_SUN8I_CODEC_ANALOG
>> +   select REGMAP_MMIO
>> +   help
>> + This option enables the audio card for Allwinner A33 (sun8i) SoC.
>> + It enables the DAI driver (SND_SUN4I_I2S), the digital audio
>> + codec driver (SND_SUN8I_CODEC) and the analog codec driver
>> + (SND_SUN8I_CODEC_ANALOG).
>> +
>> + Say Y or M if you want to add sun8i/6i card support
>> +
>>  config SND_SUN8I_CODEC
>> tristate "Allwinner SUN8I audio codec"
>> select REGMAP_MMIO
>> diff --git a/sound/soc/sunxi/Makefile b/sound/soc/sunxi/Makefile
>> index 1da63d3..7f1bab9 100644
>> --- a/sound/soc/sunxi/Makefile
>> +++ b/sound/soc/sunxi/Makefile
>> @@ -1,5 +1,6 @@
>>  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) += sun8i.o
> Great work with this...I've been battling with the audio codec for the
> h3 for a while and it looks like almost everything that I need is
> delivered here.
>>  obj-$(CONFIG_SND_SUN8I_CODEC) += sun8i-codec.o
>>  obj-$(CONFIG_SND_SUN8I_CODEC_ANALOG) += sun8i-codec-analog.o
>> diff --git a/sound/soc/sunxi/sun8i.c b/sound/soc/sunxi/sun8i.c
>> new file mode 100644
>> index 000..565cd88
>> --- /dev/null
>> +++ b/sound/soc/sunxi/sun8i.c
>> @@ -0,0 +1,101 @@
>> +/*
>> + * ALSA SoC driver for Allwinner sun8i SoC
>> + *
>> + * Copyright (C) 2016 Mylène Josserand 
>> + *
>> + * 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 
>> +#include 
>> +
>> +#include 
>> +
>> +static struct snd_soc_aux_dev sun8i_audio_prcm_aux_devs[] = {
>> +   {
>> +   .name = "sun8i-codec-analog",
>> +   .codec_name = "sun8i-codec-analog.0",
>> +   },
>> +};
>> +
>> +static struct snd_soc_dai_link sun8i_dai_link = {
>> +   .name   = "sun4i-i2s",
>> +   .stream_name= "Playback",
>> +   .codec_dai_name = "sun8i",
>> +   .dai_fmt= SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_I2S |
>> +   SND_SOC_DAIFMT_CBM_CFM,
>> +};
>> +
>> +static struct snd_soc_card sun8i_card = {
>> +   .name   = "sun8i-card",
>> +   .owner  = THIS_MODULE,
>> +   .dai_link   = _dai_link,
>> +   .num_links  = 1,
>> +   .aux_dev= sun8i_audio_prcm_aux_devs,
>> +   .num_aux_devs   = ARRAY_SIZE(sun8i_audio_prcm_aux_devs),
>> +};
>> +
>> +static int sun8i_probe(struct platform_device *pdev)
>> +{
>> +   struct snd_soc_dai_link *link = _dai_link;
>> +   struct device_node *np = pdev->dev.of_node;
>> +   int ret;
>> +
>> +   /* register the soc card */
>> +   sun8i_card.dev = >dev;
>> +
>> +   /* Retrieve the audio-codec from DT */
>> +   link->codec_of_node = of_parse_phandle(np, "allwinner,audio-codec", 
>> 0);
>> +   if (!link->codec_of_node) {
>> +   dev_err(>dev, "Missing audio codec\n");
>> +   return -EINVAL;
>> +   }
>> +
>> +   /* Retrieve DAI from DT */
>> +   link->cpu_of_node = of_parse_phandle(np, "allwinner,i2s-controller", 
>> 0);
>> +   if (!link->cpu_of_node) {
>> +   dev_err(>dev, "Missing I2S controller\n");
>> +   return -EINVAL;
>> +   }
>> +
> My one question is that we have sun8i-a23 and sun8i-a33, and I think
> we need to distinguish them here. The sun8i-a23 doesn't use the i2s
> block 

Re: [PATCH 07/14] ASoC: Add sun8i audio card

2016-10-04 Thread Code Kipper
On 4 October 2016 at 11:46, Mylène Josserand
 wrote:
> Add the audio card for sun8i SoC. This card links the codec driver
> (digital part) with the DAI driver. The analog codec driver is
> added as an aux_device.
>
> Signed-off-by: Mylène Josserand 
> ---
>  sound/soc/sunxi/Kconfig  |  14 +++
>  sound/soc/sunxi/Makefile |   1 +
>  sound/soc/sunxi/sun8i.c  | 101 
> +++
>  3 files changed, 116 insertions(+)
>  create mode 100644 sound/soc/sunxi/sun8i.c
>
> diff --git a/sound/soc/sunxi/Kconfig b/sound/soc/sunxi/Kconfig
> index 9e287b0..7b97395 100644
> --- a/sound/soc/sunxi/Kconfig
> +++ b/sound/soc/sunxi/Kconfig
> @@ -27,6 +27,20 @@ config SND_SUN4I_SPDIF
>   Say Y or M to add support for the S/PDIF audio block in the 
> Allwinner
>   A10 and affiliated SoCs.
>
> +config SND_SUN8I
> +   tristate "Allwinner SUN6I/SUN8I audio card support"
> +   select SND_SUN8I_CODEC
> +   select SND_SUN4I_I2S
> +   select SND_SUN8I_CODEC_ANALOG
> +   select REGMAP_MMIO
> +   help
> + This option enables the audio card for Allwinner A33 (sun8i) SoC.
> + It enables the DAI driver (SND_SUN4I_I2S), the digital audio
> + codec driver (SND_SUN8I_CODEC) and the analog codec driver
> + (SND_SUN8I_CODEC_ANALOG).
> +
> + Say Y or M if you want to add sun8i/6i card support
> +
>  config SND_SUN8I_CODEC
> tristate "Allwinner SUN8I audio codec"
> select REGMAP_MMIO
> diff --git a/sound/soc/sunxi/Makefile b/sound/soc/sunxi/Makefile
> index 1da63d3..7f1bab9 100644
> --- a/sound/soc/sunxi/Makefile
> +++ b/sound/soc/sunxi/Makefile
> @@ -1,5 +1,6 @@
>  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) += sun8i.o
Great work with this...I've been battling with the audio codec for the
h3 for a while and it looks like almost everything that I need is
delivered here.
>  obj-$(CONFIG_SND_SUN8I_CODEC) += sun8i-codec.o
>  obj-$(CONFIG_SND_SUN8I_CODEC_ANALOG) += sun8i-codec-analog.o
> diff --git a/sound/soc/sunxi/sun8i.c b/sound/soc/sunxi/sun8i.c
> new file mode 100644
> index 000..565cd88
> --- /dev/null
> +++ b/sound/soc/sunxi/sun8i.c
> @@ -0,0 +1,101 @@
> +/*
> + * ALSA SoC driver for Allwinner sun8i SoC
> + *
> + * Copyright (C) 2016 Mylène Josserand 
> + *
> + * 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 
> +#include 
> +
> +#include 
> +
> +static struct snd_soc_aux_dev sun8i_audio_prcm_aux_devs[] = {
> +   {
> +   .name = "sun8i-codec-analog",
> +   .codec_name = "sun8i-codec-analog.0",
> +   },
> +};
> +
> +static struct snd_soc_dai_link sun8i_dai_link = {
> +   .name   = "sun4i-i2s",
> +   .stream_name= "Playback",
> +   .codec_dai_name = "sun8i",
> +   .dai_fmt= SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_I2S |
> +   SND_SOC_DAIFMT_CBM_CFM,
> +};
> +
> +static struct snd_soc_card sun8i_card = {
> +   .name   = "sun8i-card",
> +   .owner  = THIS_MODULE,
> +   .dai_link   = _dai_link,
> +   .num_links  = 1,
> +   .aux_dev= sun8i_audio_prcm_aux_devs,
> +   .num_aux_devs   = ARRAY_SIZE(sun8i_audio_prcm_aux_devs),
> +};
> +
> +static int sun8i_probe(struct platform_device *pdev)
> +{
> +   struct snd_soc_dai_link *link = _dai_link;
> +   struct device_node *np = pdev->dev.of_node;
> +   int ret;
> +
> +   /* register the soc card */
> +   sun8i_card.dev = >dev;
> +
> +   /* Retrieve the audio-codec from DT */
> +   link->codec_of_node = of_parse_phandle(np, "allwinner,audio-codec", 
> 0);
> +   if (!link->codec_of_node) {
> +   dev_err(>dev, "Missing audio codec\n");
> +   return -EINVAL;
> +   }
> +
> +   /* Retrieve DAI from DT */
> +   link->cpu_of_node = of_parse_phandle(np, "allwinner,i2s-controller", 
> 0);
> +   if (!link->cpu_of_node) {
> +   dev_err(>dev, "Missing I2S controller\n");
> +   return -EINVAL;
> +   }
> +
My one question is that we have sun8i-a23 and sun8i-a33, and I think
we need to distinguish them here. The sun8i-a23 doesn't use the i2s
block but does use the prcm.
> +   link->platform_of_node = link->cpu_of_node;
> +
> 

Re: [PATCH 07/14] ASoC: Add sun8i audio card

2016-10-04 Thread Code Kipper
On 4 October 2016 at 11:46, Mylène Josserand
 wrote:
> Add the audio card for sun8i SoC. This card links the codec driver
> (digital part) with the DAI driver. The analog codec driver is
> added as an aux_device.
>
> Signed-off-by: Mylène Josserand 
> ---
>  sound/soc/sunxi/Kconfig  |  14 +++
>  sound/soc/sunxi/Makefile |   1 +
>  sound/soc/sunxi/sun8i.c  | 101 
> +++
>  3 files changed, 116 insertions(+)
>  create mode 100644 sound/soc/sunxi/sun8i.c
>
> diff --git a/sound/soc/sunxi/Kconfig b/sound/soc/sunxi/Kconfig
> index 9e287b0..7b97395 100644
> --- a/sound/soc/sunxi/Kconfig
> +++ b/sound/soc/sunxi/Kconfig
> @@ -27,6 +27,20 @@ config SND_SUN4I_SPDIF
>   Say Y or M to add support for the S/PDIF audio block in the 
> Allwinner
>   A10 and affiliated SoCs.
>
> +config SND_SUN8I
> +   tristate "Allwinner SUN6I/SUN8I audio card support"
> +   select SND_SUN8I_CODEC
> +   select SND_SUN4I_I2S
> +   select SND_SUN8I_CODEC_ANALOG
> +   select REGMAP_MMIO
> +   help
> + This option enables the audio card for Allwinner A33 (sun8i) SoC.
> + It enables the DAI driver (SND_SUN4I_I2S), the digital audio
> + codec driver (SND_SUN8I_CODEC) and the analog codec driver
> + (SND_SUN8I_CODEC_ANALOG).
> +
> + Say Y or M if you want to add sun8i/6i card support
> +
>  config SND_SUN8I_CODEC
> tristate "Allwinner SUN8I audio codec"
> select REGMAP_MMIO
> diff --git a/sound/soc/sunxi/Makefile b/sound/soc/sunxi/Makefile
> index 1da63d3..7f1bab9 100644
> --- a/sound/soc/sunxi/Makefile
> +++ b/sound/soc/sunxi/Makefile
> @@ -1,5 +1,6 @@
>  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) += sun8i.o
Great work with this...I've been battling with the audio codec for the
h3 for a while and it looks like almost everything that I need is
delivered here.
>  obj-$(CONFIG_SND_SUN8I_CODEC) += sun8i-codec.o
>  obj-$(CONFIG_SND_SUN8I_CODEC_ANALOG) += sun8i-codec-analog.o
> diff --git a/sound/soc/sunxi/sun8i.c b/sound/soc/sunxi/sun8i.c
> new file mode 100644
> index 000..565cd88
> --- /dev/null
> +++ b/sound/soc/sunxi/sun8i.c
> @@ -0,0 +1,101 @@
> +/*
> + * ALSA SoC driver for Allwinner sun8i SoC
> + *
> + * Copyright (C) 2016 Mylène Josserand 
> + *
> + * 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 
> +#include 
> +
> +#include 
> +
> +static struct snd_soc_aux_dev sun8i_audio_prcm_aux_devs[] = {
> +   {
> +   .name = "sun8i-codec-analog",
> +   .codec_name = "sun8i-codec-analog.0",
> +   },
> +};
> +
> +static struct snd_soc_dai_link sun8i_dai_link = {
> +   .name   = "sun4i-i2s",
> +   .stream_name= "Playback",
> +   .codec_dai_name = "sun8i",
> +   .dai_fmt= SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_I2S |
> +   SND_SOC_DAIFMT_CBM_CFM,
> +};
> +
> +static struct snd_soc_card sun8i_card = {
> +   .name   = "sun8i-card",
> +   .owner  = THIS_MODULE,
> +   .dai_link   = _dai_link,
> +   .num_links  = 1,
> +   .aux_dev= sun8i_audio_prcm_aux_devs,
> +   .num_aux_devs   = ARRAY_SIZE(sun8i_audio_prcm_aux_devs),
> +};
> +
> +static int sun8i_probe(struct platform_device *pdev)
> +{
> +   struct snd_soc_dai_link *link = _dai_link;
> +   struct device_node *np = pdev->dev.of_node;
> +   int ret;
> +
> +   /* register the soc card */
> +   sun8i_card.dev = >dev;
> +
> +   /* Retrieve the audio-codec from DT */
> +   link->codec_of_node = of_parse_phandle(np, "allwinner,audio-codec", 
> 0);
> +   if (!link->codec_of_node) {
> +   dev_err(>dev, "Missing audio codec\n");
> +   return -EINVAL;
> +   }
> +
> +   /* Retrieve DAI from DT */
> +   link->cpu_of_node = of_parse_phandle(np, "allwinner,i2s-controller", 
> 0);
> +   if (!link->cpu_of_node) {
> +   dev_err(>dev, "Missing I2S controller\n");
> +   return -EINVAL;
> +   }
> +
My one question is that we have sun8i-a23 and sun8i-a33, and I think
we need to distinguish them here. The sun8i-a23 doesn't use the i2s
block but does use the prcm.
> +   link->platform_of_node = link->cpu_of_node;
> +
> +   /* Register the sound card */
> +   ret = devm_snd_soc_register_card(>dev, _card);
> +   if 

[PATCH 07/14] ASoC: Add sun8i audio card

2016-10-04 Thread Mylène Josserand
Add the audio card for sun8i SoC. This card links the codec driver
(digital part) with the DAI driver. The analog codec driver is
added as an aux_device.

Signed-off-by: Mylène Josserand 
---
 sound/soc/sunxi/Kconfig  |  14 +++
 sound/soc/sunxi/Makefile |   1 +
 sound/soc/sunxi/sun8i.c  | 101 +++
 3 files changed, 116 insertions(+)
 create mode 100644 sound/soc/sunxi/sun8i.c

diff --git a/sound/soc/sunxi/Kconfig b/sound/soc/sunxi/Kconfig
index 9e287b0..7b97395 100644
--- a/sound/soc/sunxi/Kconfig
+++ b/sound/soc/sunxi/Kconfig
@@ -27,6 +27,20 @@ config SND_SUN4I_SPDIF
  Say Y or M to add support for the S/PDIF audio block in the Allwinner
  A10 and affiliated SoCs.
 
+config SND_SUN8I
+   tristate "Allwinner SUN6I/SUN8I audio card support"
+   select SND_SUN8I_CODEC
+   select SND_SUN4I_I2S
+   select SND_SUN8I_CODEC_ANALOG
+   select REGMAP_MMIO
+   help
+ This option enables the audio card for Allwinner A33 (sun8i) SoC.
+ It enables the DAI driver (SND_SUN4I_I2S), the digital audio
+ codec driver (SND_SUN8I_CODEC) and the analog codec driver
+ (SND_SUN8I_CODEC_ANALOG).
+
+ Say Y or M if you want to add sun8i/6i card support
+
 config SND_SUN8I_CODEC
tristate "Allwinner SUN8I audio codec"
select REGMAP_MMIO
diff --git a/sound/soc/sunxi/Makefile b/sound/soc/sunxi/Makefile
index 1da63d3..7f1bab9 100644
--- a/sound/soc/sunxi/Makefile
+++ b/sound/soc/sunxi/Makefile
@@ -1,5 +1,6 @@
 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) += sun8i.o
 obj-$(CONFIG_SND_SUN8I_CODEC) += sun8i-codec.o
 obj-$(CONFIG_SND_SUN8I_CODEC_ANALOG) += sun8i-codec-analog.o
diff --git a/sound/soc/sunxi/sun8i.c b/sound/soc/sunxi/sun8i.c
new file mode 100644
index 000..565cd88
--- /dev/null
+++ b/sound/soc/sunxi/sun8i.c
@@ -0,0 +1,101 @@
+/*
+ * ALSA SoC driver for Allwinner sun8i SoC
+ *
+ * Copyright (C) 2016 Mylène Josserand 
+ *
+ * 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 
+#include 
+
+#include 
+
+static struct snd_soc_aux_dev sun8i_audio_prcm_aux_devs[] = {
+   {
+   .name = "sun8i-codec-analog",
+   .codec_name = "sun8i-codec-analog.0",
+   },
+};
+
+static struct snd_soc_dai_link sun8i_dai_link = {
+   .name   = "sun4i-i2s",
+   .stream_name= "Playback",
+   .codec_dai_name = "sun8i",
+   .dai_fmt= SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_I2S |
+   SND_SOC_DAIFMT_CBM_CFM,
+};
+
+static struct snd_soc_card sun8i_card = {
+   .name   = "sun8i-card",
+   .owner  = THIS_MODULE,
+   .dai_link   = _dai_link,
+   .num_links  = 1,
+   .aux_dev= sun8i_audio_prcm_aux_devs,
+   .num_aux_devs   = ARRAY_SIZE(sun8i_audio_prcm_aux_devs),
+};
+
+static int sun8i_probe(struct platform_device *pdev)
+{
+   struct snd_soc_dai_link *link = _dai_link;
+   struct device_node *np = pdev->dev.of_node;
+   int ret;
+
+   /* register the soc card */
+   sun8i_card.dev = >dev;
+
+   /* Retrieve the audio-codec from DT */
+   link->codec_of_node = of_parse_phandle(np, "allwinner,audio-codec", 0);
+   if (!link->codec_of_node) {
+   dev_err(>dev, "Missing audio codec\n");
+   return -EINVAL;
+   }
+
+   /* Retrieve DAI from DT */
+   link->cpu_of_node = of_parse_phandle(np, "allwinner,i2s-controller", 0);
+   if (!link->cpu_of_node) {
+   dev_err(>dev, "Missing I2S controller\n");
+   return -EINVAL;
+   }
+
+   link->platform_of_node = link->cpu_of_node;
+
+   /* Register the sound card */
+   ret = devm_snd_soc_register_card(>dev, _card);
+   if (ret) {
+   dev_err(>dev,
+   "Soc register card failed %d\n", ret);
+   return ret;
+   }
+
+   return ret;
+}
+
+static const struct of_device_id sun8i_of_match[] = {
+   { .compatible = "allwinner,sun8i-audio", },
+   {},
+};
+
+MODULE_DEVICE_TABLE(of, sun8i_of_match);
+
+static struct platform_driver sun8i_card_driver = {
+   .probe = sun8i_probe,
+   .driver = {
+   .name   = "sun8i-audio",
+   .of_match_table = sun8i_of_match,
+   },
+};
+

[PATCH 07/14] ASoC: Add sun8i audio card

2016-10-04 Thread Mylène Josserand
Add the audio card for sun8i SoC. This card links the codec driver
(digital part) with the DAI driver. The analog codec driver is
added as an aux_device.

Signed-off-by: Mylène Josserand 
---
 sound/soc/sunxi/Kconfig  |  14 +++
 sound/soc/sunxi/Makefile |   1 +
 sound/soc/sunxi/sun8i.c  | 101 +++
 3 files changed, 116 insertions(+)
 create mode 100644 sound/soc/sunxi/sun8i.c

diff --git a/sound/soc/sunxi/Kconfig b/sound/soc/sunxi/Kconfig
index 9e287b0..7b97395 100644
--- a/sound/soc/sunxi/Kconfig
+++ b/sound/soc/sunxi/Kconfig
@@ -27,6 +27,20 @@ config SND_SUN4I_SPDIF
  Say Y or M to add support for the S/PDIF audio block in the Allwinner
  A10 and affiliated SoCs.
 
+config SND_SUN8I
+   tristate "Allwinner SUN6I/SUN8I audio card support"
+   select SND_SUN8I_CODEC
+   select SND_SUN4I_I2S
+   select SND_SUN8I_CODEC_ANALOG
+   select REGMAP_MMIO
+   help
+ This option enables the audio card for Allwinner A33 (sun8i) SoC.
+ It enables the DAI driver (SND_SUN4I_I2S), the digital audio
+ codec driver (SND_SUN8I_CODEC) and the analog codec driver
+ (SND_SUN8I_CODEC_ANALOG).
+
+ Say Y or M if you want to add sun8i/6i card support
+
 config SND_SUN8I_CODEC
tristate "Allwinner SUN8I audio codec"
select REGMAP_MMIO
diff --git a/sound/soc/sunxi/Makefile b/sound/soc/sunxi/Makefile
index 1da63d3..7f1bab9 100644
--- a/sound/soc/sunxi/Makefile
+++ b/sound/soc/sunxi/Makefile
@@ -1,5 +1,6 @@
 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) += sun8i.o
 obj-$(CONFIG_SND_SUN8I_CODEC) += sun8i-codec.o
 obj-$(CONFIG_SND_SUN8I_CODEC_ANALOG) += sun8i-codec-analog.o
diff --git a/sound/soc/sunxi/sun8i.c b/sound/soc/sunxi/sun8i.c
new file mode 100644
index 000..565cd88
--- /dev/null
+++ b/sound/soc/sunxi/sun8i.c
@@ -0,0 +1,101 @@
+/*
+ * ALSA SoC driver for Allwinner sun8i SoC
+ *
+ * Copyright (C) 2016 Mylène Josserand 
+ *
+ * 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 
+#include 
+
+#include 
+
+static struct snd_soc_aux_dev sun8i_audio_prcm_aux_devs[] = {
+   {
+   .name = "sun8i-codec-analog",
+   .codec_name = "sun8i-codec-analog.0",
+   },
+};
+
+static struct snd_soc_dai_link sun8i_dai_link = {
+   .name   = "sun4i-i2s",
+   .stream_name= "Playback",
+   .codec_dai_name = "sun8i",
+   .dai_fmt= SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_I2S |
+   SND_SOC_DAIFMT_CBM_CFM,
+};
+
+static struct snd_soc_card sun8i_card = {
+   .name   = "sun8i-card",
+   .owner  = THIS_MODULE,
+   .dai_link   = _dai_link,
+   .num_links  = 1,
+   .aux_dev= sun8i_audio_prcm_aux_devs,
+   .num_aux_devs   = ARRAY_SIZE(sun8i_audio_prcm_aux_devs),
+};
+
+static int sun8i_probe(struct platform_device *pdev)
+{
+   struct snd_soc_dai_link *link = _dai_link;
+   struct device_node *np = pdev->dev.of_node;
+   int ret;
+
+   /* register the soc card */
+   sun8i_card.dev = >dev;
+
+   /* Retrieve the audio-codec from DT */
+   link->codec_of_node = of_parse_phandle(np, "allwinner,audio-codec", 0);
+   if (!link->codec_of_node) {
+   dev_err(>dev, "Missing audio codec\n");
+   return -EINVAL;
+   }
+
+   /* Retrieve DAI from DT */
+   link->cpu_of_node = of_parse_phandle(np, "allwinner,i2s-controller", 0);
+   if (!link->cpu_of_node) {
+   dev_err(>dev, "Missing I2S controller\n");
+   return -EINVAL;
+   }
+
+   link->platform_of_node = link->cpu_of_node;
+
+   /* Register the sound card */
+   ret = devm_snd_soc_register_card(>dev, _card);
+   if (ret) {
+   dev_err(>dev,
+   "Soc register card failed %d\n", ret);
+   return ret;
+   }
+
+   return ret;
+}
+
+static const struct of_device_id sun8i_of_match[] = {
+   { .compatible = "allwinner,sun8i-audio", },
+   {},
+};
+
+MODULE_DEVICE_TABLE(of, sun8i_of_match);
+
+static struct platform_driver sun8i_card_driver = {
+   .probe = sun8i_probe,
+   .driver = {
+   .name   = "sun8i-audio",
+   .of_match_table = sun8i_of_match,
+   },
+};
+
+module_platform_driver(sun8i_card_driver);
+
+MODULE_AUTHOR("Mylène Josserand ");