All of lore.kernel.org
 help / color / mirror / Atom feed
* Imx6 i2s master driver without i2c
       [not found]     ` <CABPh3UNi79pMZPgJBisaq9Qo847MV-6riCEQ=Akt_RoLdqeVpw@mail.gmail.com>
@ 2016-05-05 19:56       ` nick83ola
  2016-05-06 15:38         ` Caleb Crome
  0 siblings, 1 reply; 18+ messages in thread
From: nick83ola @ 2016-05-05 19:56 UTC (permalink / raw)
  To: alsa-devel

Hello Alsa dev!

Anyone have an example of an i2s only driver for imx6 solo? I need a driver
without i2c....

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Imx6 i2s master driver without i2c
  2016-05-05 19:56       ` Imx6 i2s master driver without i2c nick83ola
@ 2016-05-06 15:38         ` Caleb Crome
  2016-05-09 11:17           ` nick83ola
  0 siblings, 1 reply; 18+ messages in thread
From: Caleb Crome @ 2016-05-06 15:38 UTC (permalink / raw)
  To: nick83ola; +Cc: alsa-devel

Hi there,
   Arnaud had a neat patch here that lets you set up a dummy sound
card from the DTS.

http://mailman.alsa-project.org/pipermail/alsa-devel/2015-November/100896.html

With that patch, you can set up your DTS to simply start streaming, no
codec or anything required, which should work for a codec with no I2C.


Hope that helps,
  -Caleb


On Thu, May 5, 2016 at 12:56 PM, nick83ola <nick83ola@gmail.com> wrote:
> Hello Alsa dev!
>
> Anyone have an example of an i2s only driver for imx6 solo? I need a driver
> without i2c....
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Imx6 i2s master driver without i2c
  2016-05-06 15:38         ` Caleb Crome
@ 2016-05-09 11:17           ` nick83ola
  2016-05-09 17:21             ` Caleb Crome
  0 siblings, 1 reply; 18+ messages in thread
From: nick83ola @ 2016-05-09 11:17 UTC (permalink / raw)
  To: Caleb Crome; +Cc: support, alsa-devel, arnaud.mouiche

Dear Alsa, Caleb and Arnaud

I need to output an i2s master stream from my IMX6 solo board

my board have this configuration for sound: (it have an sgtl5000 codec not
on module, but on dev board)

==========================================================================
sound {
        compatible = "fsl,imx6q-icore-sgtl5000",
                 "fsl,imx-audio-sgtl5000";
        model = "imx6q-icore-sgtl5000";
        ssi-controller = <&ssi1>;
        audio-codec = <&codec>;
        audio-routing =
           "MIC_IN", "Mic Jack",
            "Mic Jack", "Mic Bias",
            "Headphone Jack", "HP_OUT";
        mux-int-port = <2>;
        mux-ext-port = <4>;
    };
&ssi1 {
    fsl,mode = "i2s-master";
    status = "okay";
};

&audmux {
    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_audmux_4>;
    status = "okay";
};

&iomuxc {
    audmux {
        pinctrl_audmux_4: audmux-4 {
            fsl,pins = <
                MX6QDL_PAD_DISP0_DAT20__AUD4_TXC  0x130b0
                MX6QDL_PAD_DISP0_DAT21__AUD4_TXD 0x110b0
                MX6QDL_PAD_DISP0_DAT22__AUD4_TXFS  0x130b0
                MX6QDL_PAD_DISP0_DAT23__AUD4_RXD  0x130b0
            >;
       };
  };
==========================================================================

I need to output i2s on the same port as sgtl5000, bit in master mode
i've patched sound/soc/soc-utils.c to add support for dts as per arnaud
patch

==========================================================================
#ifdef CONFIG_OF
static const struct of_device_id soc_dummy_ids[] = {
    { .compatible = "linux,snd-soc-dummy", },
    { }
};
MODULE_DEVICE_TABLE(of, soc_dummy_ids);
#endif
...
.of_match_table = of_match_ptr(soc_dummy_ids),
==========================================================================

--> (it is necessary?????? or can I use simple audio card??????


-> i've put this in my dts file

==========================================================================
&audmux {
    ssi3 {
        fsl,audmux-port = <6>;
        fsl,port-config = <
             0x00000000
             IMX_AUDMUX_V2_PDCR_RXDSEL(4)
         >;
     };

     port5 {
         fsl,audmux-port = <4>;
         fsl,port-config = <
             (IMX_AUDMUX_V2_PTCR_TFSDIR |
             IMX_AUDMUX_V2_PTCR_TFSEL(6) |
             IMX_AUDMUX_V2_PTCR_TCLKDIR |
             IMX_AUDMUX_V2_PTCR_TCSEL(6))
             IMX_AUDMUX_V2_PDCR_RXDSEL(6)
         >;
     };
};

&ssi1 {
     status = "disabled";
};

&ssi2 {
     status = "disabled";
};

&ssi3 {
     status = "okay";
     #sound-dai-cells = <0>;
     // select the a clock parent suitable for 48000 Hz sampling rate
     assigned-clocks = <&clks IMX6QDL_CLK_SSI3_SEL>, <&clks
IMX6QDL_CLK_SSI3>;
     assigned-clock-parents = <&clks IMX6QDL_CLK_PLL4_AUDIO_DIV>;
     assigned-clock-rates = <0>, <49152000>;
};

/ {
    model = "Engicam i.CoreM6 DualLite/Solo starterkit";
    compatible = "fsl,imx6-icore", "fsl,imx6dl";

    sound{
     status = "disabled";
    };

    sound-itel {
        compatible = "simple-audio-card";
        simple-audio-card,name = "test";
        simple-audio-card,format="dsp_a";
        simple-audio-card,frame-master = <&sound2_ssi>;
        simple-audio-card,bitclock-master = <&sound2_ssi>;
        sound2_ssi: simple-audio-card,cpu {
            sound-dai = <&ssi3>;
            system-clock-frequency = <1536000>;
            dai-tdm-slot-num = <2>;
            dai-tdm-slot-width = <16>;
        };
    };
};
==========================================================================


here's my log

/sound-itel/simple-audio-card,cpu: arguments longer than property
asoc-simple-card sound-itel.31: parse error -22
asoc-simple-card: probe of sound-itel.31 failed with error -22












2016-05-06 17:38 GMT+02:00 Caleb Crome <caleb@crome.org>:

> Hi there,
>    Arnaud had a neat patch here that lets you set up a dummy sound
> card from the DTS.
>
>
> http://mailman.alsa-project.org/pipermail/alsa-devel/2015-November/100896.html
>
> With that patch, you can set up your DTS to simply start streaming, no
> codec or anything required, which should work for a codec with no I2C.
>
>
> Hope that helps,
>   -Caleb
>
>
> On Thu, May 5, 2016 at 12:56 PM, nick83ola <nick83ola@gmail.com> wrote:
> > Hello Alsa dev!
> >
> > Anyone have an example of an i2s only driver for imx6 solo? I need a
> driver
> > without i2c....
> > _______________________________________________
> > Alsa-devel mailing list
> > Alsa-devel@alsa-project.org
> > http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
>



-- 

P.S. Le informazioni trasmesse attraverso la presente comunicazione sono di
esclusiva
spettanza dell'effettivo destinatario. Nel caso in cui le stesse
raggiungessero, per
qualunque motivo, soggetti non interessati, questi ultimi vorranno darne
immediata
notizia al mittente. In ogni caso, eventuali soggetti diversi dai legittimi
destinatari
della presente comunicazione e dei dati contenuti negli allegati, possono
essere
sanzionati ai sensi del T.U. sul trattamento dei dati personali d.lgs.
196/2003, sia ai
sensi dell'art. 616 del Codice Penale che disciplina la violazione del
segreto sulla
corrispondenza.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Imx6 i2s master driver without i2c
  2016-05-09 11:17           ` nick83ola
@ 2016-05-09 17:21             ` Caleb Crome
  2016-05-10 14:57               ` nick83ola
  0 siblings, 1 reply; 18+ messages in thread
From: Caleb Crome @ 2016-05-09 17:21 UTC (permalink / raw)
  To: nick83ola; +Cc: support, alsa-devel, Arnaud Mouiche

On Mon, May 9, 2016 at 4:17 AM, nick83ola <nick83ola@gmail.com> wrote:
> Dear Alsa, Caleb and Arnaud
>
> I need to output an i2s master stream from my IMX6 solo board
>
> my board have this configuration for sound: (it have an sgtl5000 codec not
> on module, but on dev board)
>
> ==========================================================================
> sound {
>         compatible = "fsl,imx6q-icore-sgtl5000",
>                  "fsl,imx-audio-sgtl5000";
>         model = "imx6q-icore-sgtl5000";
>         ssi-controller = <&ssi1>;
>         audio-codec = <&codec>;
>         audio-routing =
>            "MIC_IN", "Mic Jack",
>             "Mic Jack", "Mic Bias",
>             "Headphone Jack", "HP_OUT";
>         mux-int-port = <2>;
>         mux-ext-port = <4>;
>     };
> &ssi1 {
>     fsl,mode = "i2s-master";
>     status = "okay";
> };
>
> &audmux {
>     pinctrl-names = "default";
>     pinctrl-0 = <&pinctrl_audmux_4>;
>     status = "okay";
> };
>
> &iomuxc {
>     audmux {
>         pinctrl_audmux_4: audmux-4 {
>             fsl,pins = <
>                 MX6QDL_PAD_DISP0_DAT20__AUD4_TXC  0x130b0
>                 MX6QDL_PAD_DISP0_DAT21__AUD4_TXD 0x110b0
>                 MX6QDL_PAD_DISP0_DAT22__AUD4_TXFS  0x130b0
>                 MX6QDL_PAD_DISP0_DAT23__AUD4_RXD  0x130b0
>             >;
>        };
>   };
> ==========================================================================
>
> I need to output i2s on the same port as sgtl5000, bit in master mode
> i've patched sound/soc/soc-utils.c to add support for dts as per arnaud
> patch
>
> ==========================================================================
> #ifdef CONFIG_OF
> static const struct of_device_id soc_dummy_ids[] = {
>     { .compatible = "linux,snd-soc-dummy", },
>     { }
> };
> MODULE_DEVICE_TABLE(of, soc_dummy_ids);
> #endif
> ...
> .of_match_table = of_match_ptr(soc_dummy_ids),
> ==========================================================================
>
> --> (it is necessary?????? or can I use simple audio card??????
>
>
> -> i've put this in my dts file
>
> ==========================================================================
> &audmux {
>     ssi3 {
>         fsl,audmux-port = <6>;
>         fsl,port-config = <
>              0x00000000
>              IMX_AUDMUX_V2_PDCR_RXDSEL(4)
>          >;
>      };
>
>      port5 {
>          fsl,audmux-port = <4>;
>          fsl,port-config = <
>              (IMX_AUDMUX_V2_PTCR_TFSDIR |
>              IMX_AUDMUX_V2_PTCR_TFSEL(6) |
>              IMX_AUDMUX_V2_PTCR_TCLKDIR |
>              IMX_AUDMUX_V2_PTCR_TCSEL(6))
>              IMX_AUDMUX_V2_PDCR_RXDSEL(6)
>          >;
>      };
> };
>
> &ssi1 {
>      status = "disabled";
> };
>
> &ssi2 {
>      status = "disabled";
> };
>
> &ssi3 {
>      status = "okay";
>      #sound-dai-cells = <0>;
>      // select the a clock parent suitable for 48000 Hz sampling rate
>      assigned-clocks = <&clks IMX6QDL_CLK_SSI3_SEL>, <&clks
> IMX6QDL_CLK_SSI3>;
>      assigned-clock-parents = <&clks IMX6QDL_CLK_PLL4_AUDIO_DIV>;
>      assigned-clock-rates = <0>, <49152000>;
> };
>
> / {
>     model = "Engicam i.CoreM6 DualLite/Solo starterkit";
>     compatible = "fsl,imx6-icore", "fsl,imx6dl";
>
>     sound{
>      status = "disabled";
>     };
>
>     sound-itel {
>         compatible = "simple-audio-card";
>         simple-audio-card,name = "test";
>         simple-audio-card,format="dsp_a";
>         simple-audio-card,frame-master = <&sound2_ssi>;
>         simple-audio-card,bitclock-master = <&sound2_ssi>;
>         sound2_ssi: simple-audio-card,cpu {
>             sound-dai = <&ssi3>;
>             system-clock-frequency = <1536000>;
>             dai-tdm-slot-num = <2>;
>             dai-tdm-slot-width = <16>;
>         };
>     };
> };
> ==========================================================================
>
>
> here's my log
>
> /sound-itel/simple-audio-card,cpu: arguments longer than property
> asoc-simple-card sound-itel.31: parse error -22
> asoc-simple-card: probe of sound-itel.31 failed with error -22
>
>
>


Hi Nikola,
   Here is my working setup for a wandboard with no i2c codecs.

https://github.com/ccrome/linux-caleb-dev/blob/v4.5-caleb-wandboard/arch/arm/boot/dts/imx6qdl-wandboard.dtsi

You need to be sure to set up the audmux right.    I'm not sure with
that old kernel if everything with audmux works right or not -- I
haven't tested it.

That should get you pretty close to what you need for your board I suspect.

That branch (v4.5-caleb-wandboard) will build and run the SSI3 port on
AUD5 port, with the mx6 in master mode.  And, with all arnaud's
patches (included already in that repo), it will actually be robust.

-caleb






>
>
>
>
>
>
>
>
>
> 2016-05-06 17:38 GMT+02:00 Caleb Crome <caleb@crome.org>:
>>
>> Hi there,
>>    Arnaud had a neat patch here that lets you set up a dummy sound
>> card from the DTS.
>>
>>
>> http://mailman.alsa-project.org/pipermail/alsa-devel/2015-November/100896.html
>>
>> With that patch, you can set up your DTS to simply start streaming, no
>> codec or anything required, which should work for a codec with no I2C.
>>
>>
>> Hope that helps,
>>   -Caleb
>>
>>
>> On Thu, May 5, 2016 at 12:56 PM, nick83ola <nick83ola@gmail.com> wrote:
>> > Hello Alsa dev!
>> >
>> > Anyone have an example of an i2s only driver for imx6 solo? I need a
>> > driver
>> > without i2c....
>> > _______________________________________________
>> > Alsa-devel mailing list
>> > Alsa-devel@alsa-project.org
>> > http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
>
>
>
>
> --
>
> P.S. Le informazioni trasmesse attraverso la presente comunicazione sono di
> esclusiva
> spettanza dell'effettivo destinatario. Nel caso in cui le stesse
> raggiungessero, per
> qualunque motivo, soggetti non interessati, questi ultimi vorranno darne
> immediata
> notizia al mittente. In ogni caso, eventuali soggetti diversi dai legittimi
> destinatari
> della presente comunicazione e dei dati contenuti negli allegati, possono
> essere
> sanzionati ai sensi del T.U. sul trattamento dei dati personali d.lgs.
> 196/2003, sia ai
> sensi dell'art. 616 del Codice Penale che disciplina la violazione del
> segreto sulla
> corrispondenza.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Imx6 i2s master driver without i2c
  2016-05-09 17:21             ` Caleb Crome
@ 2016-05-10 14:57               ` nick83ola
  2016-05-10 15:28                 ` nick83ola
  0 siblings, 1 reply; 18+ messages in thread
From: nick83ola @ 2016-05-10 14:57 UTC (permalink / raw)
  To: Caleb Crome; +Cc: alsa-devel

Hello Caleb
thanks for your help

Here's my current dts
I want to use ssi1 on port 4
I added #sound-dai-cells = <0>; on ssi1 because simple card complaijning
about it (what is that?? I could not find documentation about it)

Now the driver says:
 asoc-simple-card sound.26: snd-soc-dummy-dai <-> 2028000.ssi mapping ok

and

> aplay -l

**** List of PLAYBACK Hardware Devices ****
card 0: D2028000ssisnds [2028000.ssi-snd-soc-dummy-dai], device 0:
2028000.ssi-snd-soc-dummy-dai snd-soc-dummy-dai-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0

> aplay -L

null
    Discard all samples (playback) or generate zero samples (capture)
sysdefault:CARD=D2028000ssisnds
    2028000.ssi-snd-soc-dummy-dai,
    Default Audio Device

but if I try to play a file it hangs and nothing escape

How I can debug the various modules? ssi, dma, ???

how I can print debug messages?? (i cannot see the various dev_dbg no
matter what I try...)


==================================================================
/dts-v1/;

#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/sound/fsl-imx-audmux.h>

#include "imx6dl.dtsi"
#include "imx6qdl-icore.dtsi"

#define SSI_TEST_MASTER
/*
 * port 4 is datasheet port 5 (aud5)
 * port 6 is datasheet port 7 (ssi3)
 */
#define AUDMUX_EXT_PORT 3
#define AUDMUX_INT_PORT 0
#define AUDMUX_INT_PORT_NAME port4

&audmux {
/*    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_audmux_4>;*/
    status = "okay";
};

&ssi1 {
    #sound-dai-cells = <0>;
    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_audmux_4>;

    // select the a clock parent suitable for 48000 Hz sampling rate
    assigned-clocks = <&clks IMX6QDL_CLK_SSI1_SEL>, <&clks
IMX6QDL_CLK_SSI1>;
    assigned-clock-parents = <&clks IMX6QDL_CLK_PLL4_AUDIO_DIV>;
    assigned-clock-rates = <0>, <49152000>;
    fsl,mode = "i2s-master";
    status = "okay";
};

&audmux {
    status = "okay";

    ssi1 {
        fsl,audmux-port = <AUDMUX_INT_PORT>;
        fsl,port-config = <
#ifdef SSI_TEST_MASTER
            IMX_AUDMUX_V2_PTCR_SYN
#else
            (IMX_AUDMUX_V2_PTCR_TFSDIR |
            IMX_AUDMUX_V2_PTCR_TFSEL(AUDMUX_EXT_PORT) |
            IMX_AUDMUX_V2_PTCR_TCLKDIR |
            IMX_AUDMUX_V2_PTCR_TCSEL(AUDMUX_EXT_PORT) |
            IMX_AUDMUX_V2_PTCR_SYN
            )
#endif
            IMX_AUDMUX_V2_PDCR_RXDSEL(AUDMUX_EXT_PORT)
        >;
    };

    AUDMUX_INT_PORT_NAME {
        fsl,audmux-port = <AUDMUX_EXT_PORT>;
        fsl,port-config = <
#ifdef SSI_TEST_MASTER
            (IMX_AUDMUX_V2_PTCR_TFSDIR |
            IMX_AUDMUX_V2_PTCR_TFSEL(AUDMUX_INT_PORT) |
            IMX_AUDMUX_V2_PTCR_TCLKDIR |
            IMX_AUDMUX_V2_PTCR_TCSEL(AUDMUX_INT_PORT) |
            IMX_AUDMUX_V2_PTCR_SYN
            )
#else
            IMX_AUDMUX_V2_PTCR_SYN
#endif
            IMX_AUDMUX_V2_PDCR_RXDSEL(AUDMUX_INT_PORT)
        >;
    };
};


/ {
    model = "Engicam i.CoreM6 DualLite/Solo starterkit";
    compatible = "fsl,imx6-icore", "fsl,imx6dl";

    codec_test: codec_test {
        compatible = "linux,snd-soc-dummy";
        #sound-dai-cells = <0>;
    };

    sound {
        compatible = "simple-audio-card";
        simple-audio-card,name = "test";
        simple-audio-card,format="dsp_a";
        simple-audio-card,frame-master = <&sound2_ssi>;
        simple-audio-card,bitclock-master = <&sound2_ssi>;

        sound2_ssi: simple-audio-card,cpu {
            sound-dai = <&ssi1>;
            system-clock-frequency = <1536000>;
            dai-tdm-slot-num = <2>;
            dai-tdm-slot-width = <16>;
        };

        sound2codec: simple-audio-card,codec {
            sound-dai = <&codec_test>;
        };
    };

};

&iomuxc {
    audmux {
        pinctrl_audmux_1: audmux-1 {
            fsl,pins = <
                MX6QDL_PAD_SD2_DAT0__AUD4_RXD  0x130b0
                MX6QDL_PAD_SD2_DAT3__AUD4_TXC  0x130b0
                MX6QDL_PAD_SD2_DAT2__AUD4_TXD  0x110b0
                MX6QDL_PAD_SD2_DAT1__AUD4_TXFS 0x130b0
            >;
        };

        pinctrl_audmux_2: audmux-2 {
            fsl,pins = <
                MX6QDL_PAD_CSI0_DAT7__AUD3_RXD  0x130b0
                MX6QDL_PAD_CSI0_DAT4__AUD3_TXC  0x130b0
                MX6QDL_PAD_CSI0_DAT5__AUD3_TXD  0x110b0
                MX6QDL_PAD_CSI0_DAT6__AUD3_TXFS 0x130b0
            >;
        };

        pinctrl_audmux_3: audmux-3 {
            fsl,pins = <
                MX6QDL_PAD_DISP0_DAT16__AUD5_TXC  0x130b0
                MX6QDL_PAD_DISP0_DAT18__AUD5_TXFS 0x130b0
                MX6QDL_PAD_DISP0_DAT19__AUD5_RXD  0x130b0
            >;
        };

        pinctrl_audmux_4: audmux-4 {
            fsl,pins = <
                MX6QDL_PAD_DISP0_DAT20__AUD4_TXC  0x130b0
                MX6QDL_PAD_DISP0_DAT21__AUD4_TXD 0x110b0
                MX6QDL_PAD_DISP0_DAT22__AUD4_TXFS  0x130b0
                MX6QDL_PAD_DISP0_DAT23__AUD4_RXD  0x130b0
            >;
        };
    };
};



2016-05-09 19:21 GMT+02:00 Caleb Crome <caleb@crome.org>:

> On Mon, May 9, 2016 at 4:17 AM, nick83ola <nick83ola@gmail.com> wrote:
> > Dear Alsa, Caleb and Arnaud
> >
> > I need to output an i2s master stream from my IMX6 solo board
> >
> > my board have this configuration for sound: (it have an sgtl5000 codec
> not
> > on module, but on dev board)
> >
> >
> ==========================================================================
> > sound {
> >         compatible = "fsl,imx6q-icore-sgtl5000",
> >                  "fsl,imx-audio-sgtl5000";
> >         model = "imx6q-icore-sgtl5000";
> >         ssi-controller = <&ssi1>;
> >         audio-codec = <&codec>;
> >         audio-routing =
> >            "MIC_IN", "Mic Jack",
> >             "Mic Jack", "Mic Bias",
> >             "Headphone Jack", "HP_OUT";
> >         mux-int-port = <2>;
> >         mux-ext-port = <4>;
> >     };
> > &ssi1 {
> >     fsl,mode = "i2s-master";
> >     status = "okay";
> > };
> >
> > &audmux {
> >     pinctrl-names = "default";
> >     pinctrl-0 = <&pinctrl_audmux_4>;
> >     status = "okay";
> > };
> >
> > &iomuxc {
> >     audmux {
> >         pinctrl_audmux_4: audmux-4 {
> >             fsl,pins = <
> >                 MX6QDL_PAD_DISP0_DAT20__AUD4_TXC  0x130b0
> >                 MX6QDL_PAD_DISP0_DAT21__AUD4_TXD 0x110b0
> >                 MX6QDL_PAD_DISP0_DAT22__AUD4_TXFS  0x130b0
> >                 MX6QDL_PAD_DISP0_DAT23__AUD4_RXD  0x130b0
> >             >;
> >        };
> >   };
> >
> ==========================================================================
> >
> > I need to output i2s on the same port as sgtl5000, bit in master mode
> > i've patched sound/soc/soc-utils.c to add support for dts as per arnaud
> > patch
> >
> >
> ==========================================================================
> > #ifdef CONFIG_OF
> > static const struct of_device_id soc_dummy_ids[] = {
> >     { .compatible = "linux,snd-soc-dummy", },
> >     { }
> > };
> > MODULE_DEVICE_TABLE(of, soc_dummy_ids);
> > #endif
> > ...
> > .of_match_table = of_match_ptr(soc_dummy_ids),
> >
> ==========================================================================
> >
> > --> (it is necessary?????? or can I use simple audio card??????
> >
> >
> > -> i've put this in my dts file
> >
> >
> ==========================================================================
> > &audmux {
> >     ssi3 {
> >         fsl,audmux-port = <6>;
> >         fsl,port-config = <
> >              0x00000000
> >              IMX_AUDMUX_V2_PDCR_RXDSEL(4)
> >          >;
> >      };
> >
> >      port5 {
> >          fsl,audmux-port = <4>;
> >          fsl,port-config = <
> >              (IMX_AUDMUX_V2_PTCR_TFSDIR |
> >              IMX_AUDMUX_V2_PTCR_TFSEL(6) |
> >              IMX_AUDMUX_V2_PTCR_TCLKDIR |
> >              IMX_AUDMUX_V2_PTCR_TCSEL(6))
> >              IMX_AUDMUX_V2_PDCR_RXDSEL(6)
> >          >;
> >      };
> > };
> >
> > &ssi1 {
> >      status = "disabled";
> > };
> >
> > &ssi2 {
> >      status = "disabled";
> > };
> >
> > &ssi3 {
> >      status = "okay";
> >      #sound-dai-cells = <0>;
> >      // select the a clock parent suitable for 48000 Hz sampling rate
> >      assigned-clocks = <&clks IMX6QDL_CLK_SSI3_SEL>, <&clks
> > IMX6QDL_CLK_SSI3>;
> >      assigned-clock-parents = <&clks IMX6QDL_CLK_PLL4_AUDIO_DIV>;
> >      assigned-clock-rates = <0>, <49152000>;
> > };
> >
> > / {
> >     model = "Engicam i.CoreM6 DualLite/Solo starterkit";
> >     compatible = "fsl,imx6-icore", "fsl,imx6dl";
> >
> >     sound{
> >      status = "disabled";
> >     };
> >
> >     sound-itel {
> >         compatible = "simple-audio-card";
> >         simple-audio-card,name = "test";
> >         simple-audio-card,format="dsp_a";
> >         simple-audio-card,frame-master = <&sound2_ssi>;
> >         simple-audio-card,bitclock-master = <&sound2_ssi>;
> >         sound2_ssi: simple-audio-card,cpu {
> >             sound-dai = <&ssi3>;
> >             system-clock-frequency = <1536000>;
> >             dai-tdm-slot-num = <2>;
> >             dai-tdm-slot-width = <16>;
> >         };
> >     };
> > };
> >
> ==========================================================================
> >
> >
> > here's my log
> >
> > /sound-itel/simple-audio-card,cpu: arguments longer than property
> > asoc-simple-card sound-itel.31: parse error -22
> > asoc-simple-card: probe of sound-itel.31 failed with error -22
> >
> >
> >
>
>
> Hi Nikola,
>    Here is my working setup for a wandboard with no i2c codecs.
>
>
> https://github.com/ccrome/linux-caleb-dev/blob/v4.5-caleb-wandboard/arch/arm/boot/dts/imx6qdl-wandboard.dtsi
>
> You need to be sure to set up the audmux right.    I'm not sure with
> that old kernel if everything with audmux works right or not -- I
> haven't tested it.
>
> That should get you pretty close to what you need for your board I suspect.
>
> That branch (v4.5-caleb-wandboard) will build and run the SSI3 port on
> AUD5 port, with the mx6 in master mode.  And, with all arnaud's
> patches (included already in that repo), it will actually be robust.
>
> -caleb
>
>
>
>
>
>
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > 2016-05-06 17:38 GMT+02:00 Caleb Crome <caleb@crome.org>:
> >>
> >> Hi there,
> >>    Arnaud had a neat patch here that lets you set up a dummy sound
> >> card from the DTS.
> >>
> >>
> >>
> http://mailman.alsa-project.org/pipermail/alsa-devel/2015-November/100896.html
> >>
> >> With that patch, you can set up your DTS to simply start streaming, no
> >> codec or anything required, which should work for a codec with no I2C.
> >>
> >>
> >> Hope that helps,
> >>   -Caleb
> >>
> >>
> >> On Thu, May 5, 2016 at 12:56 PM, nick83ola <nick83ola@gmail.com> wrote:
> >> > Hello Alsa dev!
> >> >
> >> > Anyone have an example of an i2s only driver for imx6 solo? I need a
> >> > driver
> >> > without i2c....
> >> > _______________________________________________
> >> > Alsa-devel mailing list
> >> > Alsa-devel@alsa-project.org
> >> > http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
> >
> >
> >
> >
> > --
> >
> > P.S. Le informazioni trasmesse attraverso la presente comunicazione sono
> di
> > esclusiva
> > spettanza dell'effettivo destinatario. Nel caso in cui le stesse
> > raggiungessero, per
> > qualunque motivo, soggetti non interessati, questi ultimi vorranno darne
> > immediata
> > notizia al mittente. In ogni caso, eventuali soggetti diversi dai
> legittimi
> > destinatari
> > della presente comunicazione e dei dati contenuti negli allegati, possono
> > essere
> > sanzionati ai sensi del T.U. sul trattamento dei dati personali d.lgs.
> > 196/2003, sia ai
> > sensi dell'art. 616 del Codice Penale che disciplina la violazione del
> > segreto sulla
> > corrispondenza.
>



-- 

P.S. Le informazioni trasmesse attraverso la presente comunicazione sono di
esclusiva
spettanza dell'effettivo destinatario. Nel caso in cui le stesse
raggiungessero, per
qualunque motivo, soggetti non interessati, questi ultimi vorranno darne
immediata
notizia al mittente. In ogni caso, eventuali soggetti diversi dai legittimi
destinatari
della presente comunicazione e dei dati contenuti negli allegati, possono
essere
sanzionati ai sensi del T.U. sul trattamento dei dati personali d.lgs.
196/2003, sia ai
sensi dell'art. 616 del Codice Penale che disciplina la violazione del
segreto sulla
corrispondenza.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Imx6 i2s master driver without i2c
  2016-05-10 14:57               ` nick83ola
@ 2016-05-10 15:28                 ` nick83ola
  2016-05-10 16:14                   ` Caleb Crome
  0 siblings, 1 reply; 18+ messages in thread
From: nick83ola @ 2016-05-10 15:28 UTC (permalink / raw)
  To: Caleb Crome; +Cc: alsa-devel

enabling kernel debug on all modules it says:

sound/soc/fsl/imx-pcm-fiq.c:226 [imx_pcm_fiq]snd_imx_pcm_mmap =_ "%s: ret:
%d %p 0x%08x 0x%08x\012"
sound/soc/fsl/fsl_ssi.c:1289 [snd_soc_fsl_ssi]fsl_ssi_imx_probe =_ "could
not get baud clock: %ld\012"
sound/soc/fsl/imx-audmux.c:333 [snd_soc_imx_audmux]imx_audmux_probe =p
"cannot get clock: %ld\012"
sound/soc/generic/simple-card.c:180
[snd_soc_simple_card]asoc_simple_card_parse_of =p "card-name : %s\012"
sound/soc/generic/simple-card.c:181
[snd_soc_simple_card]asoc_simple_card_parse_of =p "platform : %04x\012"
sound/soc/generic/simple-card.c:185
[snd_soc_simple_card]asoc_simple_card_parse_of =p "cpu : %s / %04x / %d\012"
sound/soc/generic/simple-card.c:189
[snd_soc_simple_card]asoc_simple_card_parse_of =p "codec : %s / %04x /
%d\012"
sound/soc/generic/simple-card.c:33
[snd_soc_simple_card]__asoc_simple_card_dai_init =p "ASoC: set_fmt is not
supported\012"

2016-05-10 16:57 GMT+02:00 nick83ola <nick83ola@gmail.com>:

> Hello Caleb
> thanks for your help
>
> Here's my current dts
> I want to use ssi1 on port 4
> I added #sound-dai-cells = <0>; on ssi1 because simple card complaijning
> about it (what is that?? I could not find documentation about it)
>
> Now the driver says:
>  asoc-simple-card sound.26: snd-soc-dummy-dai <-> 2028000.ssi mapping ok
>
> and
>
> > aplay -l
>
> **** List of PLAYBACK Hardware Devices ****
> card 0: D2028000ssisnds [2028000.ssi-snd-soc-dummy-dai], device 0:
> 2028000.ssi-snd-soc-dummy-dai snd-soc-dummy-dai-0 []
>   Subdevices: 1/1
>   Subdevice #0: subdevice #0
>
> > aplay -L
>
> null
>     Discard all samples (playback) or generate zero samples (capture)
> sysdefault:CARD=D2028000ssisnds
>     2028000.ssi-snd-soc-dummy-dai,
>     Default Audio Device
>
> but if I try to play a file it hangs and nothing escape
>
> How I can debug the various modules? ssi, dma, ???
>
> how I can print debug messages?? (i cannot see the various dev_dbg no
> matter what I try...)
>
>
> ==================================================================
> /dts-v1/;
>
> #include <dt-bindings/gpio/gpio.h>
> #include <dt-bindings/sound/fsl-imx-audmux.h>
>
> #include "imx6dl.dtsi"
> #include "imx6qdl-icore.dtsi"
>
> #define SSI_TEST_MASTER
> /*
>  * port 4 is datasheet port 5 (aud5)
>  * port 6 is datasheet port 7 (ssi3)
>  */
> #define AUDMUX_EXT_PORT 3
> #define AUDMUX_INT_PORT 0
> #define AUDMUX_INT_PORT_NAME port4
>
> &audmux {
> /*    pinctrl-names = "default";
>     pinctrl-0 = <&pinctrl_audmux_4>;*/
>     status = "okay";
> };
>
> &ssi1 {
>     #sound-dai-cells = <0>;
>     pinctrl-names = "default";
>     pinctrl-0 = <&pinctrl_audmux_4>;
>
>     // select the a clock parent suitable for 48000 Hz sampling rate
>     assigned-clocks = <&clks IMX6QDL_CLK_SSI1_SEL>, <&clks
> IMX6QDL_CLK_SSI1>;
>     assigned-clock-parents = <&clks IMX6QDL_CLK_PLL4_AUDIO_DIV>;
>     assigned-clock-rates = <0>, <49152000>;
>     fsl,mode = "i2s-master";
>     status = "okay";
> };
>
> &audmux {
>     status = "okay";
>
>     ssi1 {
>         fsl,audmux-port = <AUDMUX_INT_PORT>;
>         fsl,port-config = <
> #ifdef SSI_TEST_MASTER
>             IMX_AUDMUX_V2_PTCR_SYN
> #else
>             (IMX_AUDMUX_V2_PTCR_TFSDIR |
>             IMX_AUDMUX_V2_PTCR_TFSEL(AUDMUX_EXT_PORT) |
>             IMX_AUDMUX_V2_PTCR_TCLKDIR |
>             IMX_AUDMUX_V2_PTCR_TCSEL(AUDMUX_EXT_PORT) |
>             IMX_AUDMUX_V2_PTCR_SYN
>             )
> #endif
>             IMX_AUDMUX_V2_PDCR_RXDSEL(AUDMUX_EXT_PORT)
>         >;
>     };
>
>     AUDMUX_INT_PORT_NAME {
>         fsl,audmux-port = <AUDMUX_EXT_PORT>;
>         fsl,port-config = <
> #ifdef SSI_TEST_MASTER
>             (IMX_AUDMUX_V2_PTCR_TFSDIR |
>             IMX_AUDMUX_V2_PTCR_TFSEL(AUDMUX_INT_PORT) |
>             IMX_AUDMUX_V2_PTCR_TCLKDIR |
>             IMX_AUDMUX_V2_PTCR_TCSEL(AUDMUX_INT_PORT) |
>             IMX_AUDMUX_V2_PTCR_SYN
>             )
> #else
>             IMX_AUDMUX_V2_PTCR_SYN
> #endif
>             IMX_AUDMUX_V2_PDCR_RXDSEL(AUDMUX_INT_PORT)
>         >;
>     };
> };
>
>
> / {
>     model = "Engicam i.CoreM6 DualLite/Solo starterkit";
>     compatible = "fsl,imx6-icore", "fsl,imx6dl";
>
>     codec_test: codec_test {
>         compatible = "linux,snd-soc-dummy";
>         #sound-dai-cells = <0>;
>     };
>
>     sound {
>         compatible = "simple-audio-card";
>         simple-audio-card,name = "test";
>         simple-audio-card,format="dsp_a";
>         simple-audio-card,frame-master = <&sound2_ssi>;
>         simple-audio-card,bitclock-master = <&sound2_ssi>;
>
>         sound2_ssi: simple-audio-card,cpu {
>             sound-dai = <&ssi1>;
>             system-clock-frequency = <1536000>;
>             dai-tdm-slot-num = <2>;
>             dai-tdm-slot-width = <16>;
>         };
>
>         sound2codec: simple-audio-card,codec {
>             sound-dai = <&codec_test>;
>         };
>     };
>
> };
>
> &iomuxc {
>     audmux {
>         pinctrl_audmux_1: audmux-1 {
>             fsl,pins = <
>                 MX6QDL_PAD_SD2_DAT0__AUD4_RXD  0x130b0
>                 MX6QDL_PAD_SD2_DAT3__AUD4_TXC  0x130b0
>                 MX6QDL_PAD_SD2_DAT2__AUD4_TXD  0x110b0
>                 MX6QDL_PAD_SD2_DAT1__AUD4_TXFS 0x130b0
>             >;
>         };
>
>         pinctrl_audmux_2: audmux-2 {
>             fsl,pins = <
>                 MX6QDL_PAD_CSI0_DAT7__AUD3_RXD  0x130b0
>                 MX6QDL_PAD_CSI0_DAT4__AUD3_TXC  0x130b0
>                 MX6QDL_PAD_CSI0_DAT5__AUD3_TXD  0x110b0
>                 MX6QDL_PAD_CSI0_DAT6__AUD3_TXFS 0x130b0
>             >;
>         };
>
>         pinctrl_audmux_3: audmux-3 {
>             fsl,pins = <
>                 MX6QDL_PAD_DISP0_DAT16__AUD5_TXC  0x130b0
>                 MX6QDL_PAD_DISP0_DAT18__AUD5_TXFS 0x130b0
>                 MX6QDL_PAD_DISP0_DAT19__AUD5_RXD  0x130b0
>             >;
>         };
>
>         pinctrl_audmux_4: audmux-4 {
>             fsl,pins = <
>                 MX6QDL_PAD_DISP0_DAT20__AUD4_TXC  0x130b0
>                 MX6QDL_PAD_DISP0_DAT21__AUD4_TXD 0x110b0
>                 MX6QDL_PAD_DISP0_DAT22__AUD4_TXFS  0x130b0
>                 MX6QDL_PAD_DISP0_DAT23__AUD4_RXD  0x130b0
>             >;
>         };
>     };
> };
>
>
>
> 2016-05-09 19:21 GMT+02:00 Caleb Crome <caleb@crome.org>:
>
>> On Mon, May 9, 2016 at 4:17 AM, nick83ola <nick83ola@gmail.com> wrote:
>> > Dear Alsa, Caleb and Arnaud
>> >
>> > I need to output an i2s master stream from my IMX6 solo board
>> >
>> > my board have this configuration for sound: (it have an sgtl5000 codec
>> not
>> > on module, but on dev board)
>> >
>> >
>> ==========================================================================
>> > sound {
>> >         compatible = "fsl,imx6q-icore-sgtl5000",
>> >                  "fsl,imx-audio-sgtl5000";
>> >         model = "imx6q-icore-sgtl5000";
>> >         ssi-controller = <&ssi1>;
>> >         audio-codec = <&codec>;
>> >         audio-routing =
>> >            "MIC_IN", "Mic Jack",
>> >             "Mic Jack", "Mic Bias",
>> >             "Headphone Jack", "HP_OUT";
>> >         mux-int-port = <2>;
>> >         mux-ext-port = <4>;
>> >     };
>> > &ssi1 {
>> >     fsl,mode = "i2s-master";
>> >     status = "okay";
>> > };
>> >
>> > &audmux {
>> >     pinctrl-names = "default";
>> >     pinctrl-0 = <&pinctrl_audmux_4>;
>> >     status = "okay";
>> > };
>> >
>> > &iomuxc {
>> >     audmux {
>> >         pinctrl_audmux_4: audmux-4 {
>> >             fsl,pins = <
>> >                 MX6QDL_PAD_DISP0_DAT20__AUD4_TXC  0x130b0
>> >                 MX6QDL_PAD_DISP0_DAT21__AUD4_TXD 0x110b0
>> >                 MX6QDL_PAD_DISP0_DAT22__AUD4_TXFS  0x130b0
>> >                 MX6QDL_PAD_DISP0_DAT23__AUD4_RXD  0x130b0
>> >             >;
>> >        };
>> >   };
>> >
>> ==========================================================================
>> >
>> > I need to output i2s on the same port as sgtl5000, bit in master mode
>> > i've patched sound/soc/soc-utils.c to add support for dts as per arnaud
>> > patch
>> >
>> >
>> ==========================================================================
>> > #ifdef CONFIG_OF
>> > static const struct of_device_id soc_dummy_ids[] = {
>> >     { .compatible = "linux,snd-soc-dummy", },
>> >     { }
>> > };
>> > MODULE_DEVICE_TABLE(of, soc_dummy_ids);
>> > #endif
>> > ...
>> > .of_match_table = of_match_ptr(soc_dummy_ids),
>> >
>> ==========================================================================
>> >
>> > --> (it is necessary?????? or can I use simple audio card??????
>> >
>> >
>> > -> i've put this in my dts file
>> >
>> >
>> ==========================================================================
>> > &audmux {
>> >     ssi3 {
>> >         fsl,audmux-port = <6>;
>> >         fsl,port-config = <
>> >              0x00000000
>> >              IMX_AUDMUX_V2_PDCR_RXDSEL(4)
>> >          >;
>> >      };
>> >
>> >      port5 {
>> >          fsl,audmux-port = <4>;
>> >          fsl,port-config = <
>> >              (IMX_AUDMUX_V2_PTCR_TFSDIR |
>> >              IMX_AUDMUX_V2_PTCR_TFSEL(6) |
>> >              IMX_AUDMUX_V2_PTCR_TCLKDIR |
>> >              IMX_AUDMUX_V2_PTCR_TCSEL(6))
>> >              IMX_AUDMUX_V2_PDCR_RXDSEL(6)
>> >          >;
>> >      };
>> > };
>> >
>> > &ssi1 {
>> >      status = "disabled";
>> > };
>> >
>> > &ssi2 {
>> >      status = "disabled";
>> > };
>> >
>> > &ssi3 {
>> >      status = "okay";
>> >      #sound-dai-cells = <0>;
>> >      // select the a clock parent suitable for 48000 Hz sampling rate
>> >      assigned-clocks = <&clks IMX6QDL_CLK_SSI3_SEL>, <&clks
>> > IMX6QDL_CLK_SSI3>;
>> >      assigned-clock-parents = <&clks IMX6QDL_CLK_PLL4_AUDIO_DIV>;
>> >      assigned-clock-rates = <0>, <49152000>;
>> > };
>> >
>> > / {
>> >     model = "Engicam i.CoreM6 DualLite/Solo starterkit";
>> >     compatible = "fsl,imx6-icore", "fsl,imx6dl";
>> >
>> >     sound{
>> >      status = "disabled";
>> >     };
>> >
>> >     sound-itel {
>> >         compatible = "simple-audio-card";
>> >         simple-audio-card,name = "test";
>> >         simple-audio-card,format="dsp_a";
>> >         simple-audio-card,frame-master = <&sound2_ssi>;
>> >         simple-audio-card,bitclock-master = <&sound2_ssi>;
>> >         sound2_ssi: simple-audio-card,cpu {
>> >             sound-dai = <&ssi3>;
>> >             system-clock-frequency = <1536000>;
>> >             dai-tdm-slot-num = <2>;
>> >             dai-tdm-slot-width = <16>;
>> >         };
>> >     };
>> > };
>> >
>> ==========================================================================
>> >
>> >
>> > here's my log
>> >
>> > /sound-itel/simple-audio-card,cpu: arguments longer than property
>> > asoc-simple-card sound-itel.31: parse error -22
>> > asoc-simple-card: probe of sound-itel.31 failed with error -22
>> >
>> >
>> >
>>
>>
>> Hi Nikola,
>>    Here is my working setup for a wandboard with no i2c codecs.
>>
>>
>> https://github.com/ccrome/linux-caleb-dev/blob/v4.5-caleb-wandboard/arch/arm/boot/dts/imx6qdl-wandboard.dtsi
>>
>> You need to be sure to set up the audmux right.    I'm not sure with
>> that old kernel if everything with audmux works right or not -- I
>> haven't tested it.
>>
>> That should get you pretty close to what you need for your board I
>> suspect.
>>
>> That branch (v4.5-caleb-wandboard) will build and run the SSI3 port on
>> AUD5 port, with the mx6 in master mode.  And, with all arnaud's
>> patches (included already in that repo), it will actually be robust.
>>
>> -caleb
>>
>>
>>
>>
>>
>>
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > 2016-05-06 17:38 GMT+02:00 Caleb Crome <caleb@crome.org>:
>> >>
>> >> Hi there,
>> >>    Arnaud had a neat patch here that lets you set up a dummy sound
>> >> card from the DTS.
>> >>
>> >>
>> >>
>> http://mailman.alsa-project.org/pipermail/alsa-devel/2015-November/100896.html
>> >>
>> >> With that patch, you can set up your DTS to simply start streaming, no
>> >> codec or anything required, which should work for a codec with no I2C.
>> >>
>> >>
>> >> Hope that helps,
>> >>   -Caleb
>> >>
>> >>
>> >> On Thu, May 5, 2016 at 12:56 PM, nick83ola <nick83ola@gmail.com>
>> wrote:
>> >> > Hello Alsa dev!
>> >> >
>> >> > Anyone have an example of an i2s only driver for imx6 solo? I need a
>> >> > driver
>> >> > without i2c....
>> >> > _______________________________________________
>> >> > Alsa-devel mailing list
>> >> > Alsa-devel@alsa-project.org
>> >> > http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
>> >
>> >
>> >
>> >
>> > --
>> >
>> > P.S. Le informazioni trasmesse attraverso la presente comunicazione
>> sono di
>> > esclusiva
>> > spettanza dell'effettivo destinatario. Nel caso in cui le stesse
>> > raggiungessero, per
>> > qualunque motivo, soggetti non interessati, questi ultimi vorranno darne
>> > immediata
>> > notizia al mittente. In ogni caso, eventuali soggetti diversi dai
>> legittimi
>> > destinatari
>> > della presente comunicazione e dei dati contenuti negli allegati,
>> possono
>> > essere
>> > sanzionati ai sensi del T.U. sul trattamento dei dati personali d.lgs.
>> > 196/2003, sia ai
>> > sensi dell'art. 616 del Codice Penale che disciplina la violazione del
>> > segreto sulla
>> > corrispondenza.
>>
>
>
>
> --
>
> P.S. Le informazioni trasmesse attraverso la presente comunicazione sono
> di esclusiva
> spettanza dell'effettivo destinatario. Nel caso in cui le stesse
> raggiungessero, per
> qualunque motivo, soggetti non interessati, questi ultimi vorranno darne
> immediata
> notizia al mittente. In ogni caso, eventuali soggetti diversi dai
> legittimi destinatari
> della presente comunicazione e dei dati contenuti negli allegati, possono
> essere
> sanzionati ai sensi del T.U. sul trattamento dei dati personali d.lgs.
> 196/2003, sia ai
> sensi dell'art. 616 del Codice Penale che disciplina la violazione del
> segreto sulla
> corrispondenza.
>



-- 

P.S. Le informazioni trasmesse attraverso la presente comunicazione sono di
esclusiva
spettanza dell'effettivo destinatario. Nel caso in cui le stesse
raggiungessero, per
qualunque motivo, soggetti non interessati, questi ultimi vorranno darne
immediata
notizia al mittente. In ogni caso, eventuali soggetti diversi dai legittimi
destinatari
della presente comunicazione e dei dati contenuti negli allegati, possono
essere
sanzionati ai sensi del T.U. sul trattamento dei dati personali d.lgs.
196/2003, sia ai
sensi dell'art. 616 del Codice Penale che disciplina la violazione del
segreto sulla
corrispondenza.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Imx6 i2s master driver without i2c
  2016-05-10 15:28                 ` nick83ola
@ 2016-05-10 16:14                   ` Caleb Crome
  2016-05-10 17:00                     ` nick83ola
  0 siblings, 1 reply; 18+ messages in thread
From: Caleb Crome @ 2016-05-10 16:14 UTC (permalink / raw)
  To: nick83ola; +Cc: alsa-devel

Hi Nicola,

Answers inline.  BTW, it's highly preferred on this list that you
don't 'top-post', which I had to look up when I was told not to do it
:-).  Basically, put replies below the stuff they refer to, not above,
so somebody coming into the middle of the conversation later can read
it in a normal top to bottom order rather than a bottom to top, or
worse yet, some combination.

On Tue, May 10, 2016 at 8:28 AM, nick83ola <nick83ola@gmail.com> wrote:
> enabling kernel debug on all modules it says:
>
> sound/soc/fsl/imx-pcm-fiq.c:226 [imx_pcm_fiq]snd_imx_pcm_mmap =_ "%s: ret:
> %d %p 0x%08x 0x%08x\012"
> sound/soc/fsl/fsl_ssi.c:1289 [snd_soc_fsl_ssi]fsl_ssi_imx_probe =_ "could
> not get baud clock: %ld\012"
> sound/soc/fsl/imx-audmux.c:333 [snd_soc_imx_audmux]imx_audmux_probe =p
> "cannot get clock: %ld\012"
> sound/soc/generic/simple-card.c:180
> [snd_soc_simple_card]asoc_simple_card_parse_of =p "card-name : %s\012"
> sound/soc/generic/simple-card.c:181
> [snd_soc_simple_card]asoc_simple_card_parse_of =p "platform : %04x\012"
> sound/soc/generic/simple-card.c:185
> [snd_soc_simple_card]asoc_simple_card_parse_of =p "cpu : %s / %04x / %d\012"
> sound/soc/generic/simple-card.c:189
> [snd_soc_simple_card]asoc_simple_card_parse_of =p "codec : %s / %04x /
> %d\012"
> sound/soc/generic/simple-card.c:33
> [snd_soc_simple_card]__asoc_simple_card_dai_init =p "ASoC: set_fmt is not
> supported\012"
>
> 2016-05-10 16:57 GMT+02:00 nick83ola <nick83ola@gmail.com>:
>>
>> Hello Caleb
>> thanks for your help
>>
>> Here's my current dts
>> I want to use ssi1 on port 4
>> I added #sound-dai-cells = <0>; on ssi1 because simple card complaijning
>> about it (what is that?? I could not find documentation about it)

Yeah, I don't really understand how that stuff works.  I just have a
working setup, so I go with it.

>>
>> Now the driver says:
>>  asoc-simple-card sound.26: snd-soc-dummy-dai <-> 2028000.ssi mapping ok

Yay!

>>
>> and
>>
>> > aplay -l
>>
>> **** List of PLAYBACK Hardware Devices ****
>> card 0: D2028000ssisnds [2028000.ssi-snd-soc-dummy-dai], device 0:
>> 2028000.ssi-snd-soc-dummy-dai snd-soc-dummy-dai-0 []
>>   Subdevices: 1/1
>>   Subdevice #0: subdevice #0
>>
>> > aplay -L
>>
>> null
>>     Discard all samples (playback) or generate zero samples (capture)
>> sysdefault:CARD=D2028000ssisnds
>>     2028000.ssi-snd-soc-dummy-dai,
>>     Default Audio Device

Are you using the new kernel I pointed you to (v4.5) , or still the
old 3.14?  I don't have my system up right now to check against what
mine looks like.

For the most part, people on this list are on the latest kernel, and
are not terribly motivated to go back and figure out problems with old
kernels.

>>
>> but if I try to play a file it hangs and nothing escape
>>
>> How I can debug the various modules? ssi, dma, ???

Well, the way I do it is with lots and lots of printk's, and a really
fast automated way to rebuild/copy/reboot the kernel (a custom
makefile that does it all for me).

I don't see anything obviously wrong with your DTS, but I'm no expert.

You might want to try with a v4.5 kernel to see if that makes any
difference.  Sorry I can't be of more help, but kernel hacking is
definitely not my main job :-)

-Caleb


>>
>> how I can print debug messages?? (i cannot see the various dev_dbg no
>> matter what I try...)
>>
>>
>> ==================================================================
>> /dts-v1/;
>>
>> #include <dt-bindings/gpio/gpio.h>
>> #include <dt-bindings/sound/fsl-imx-audmux.h>
>>
>> #include "imx6dl.dtsi"
>> #include "imx6qdl-icore.dtsi"
>>
>> #define SSI_TEST_MASTER
>> /*
>>  * port 4 is datasheet port 5 (aud5)
>>  * port 6 is datasheet port 7 (ssi3)
>>  */
>> #define AUDMUX_EXT_PORT 3
>> #define AUDMUX_INT_PORT 0
>> #define AUDMUX_INT_PORT_NAME port4
>>
>> &audmux {
>> /*    pinctrl-names = "default";
>>     pinctrl-0 = <&pinctrl_audmux_4>;*/
>>     status = "okay";
>> };
>>
>> &ssi1 {
>>     #sound-dai-cells = <0>;
>>     pinctrl-names = "default";
>>     pinctrl-0 = <&pinctrl_audmux_4>;
>>
>>     // select the a clock parent suitable for 48000 Hz sampling rate
>>     assigned-clocks = <&clks IMX6QDL_CLK_SSI1_SEL>, <&clks
>> IMX6QDL_CLK_SSI1>;
>>     assigned-clock-parents = <&clks IMX6QDL_CLK_PLL4_AUDIO_DIV>;
>>     assigned-clock-rates = <0>, <49152000>;
>>     fsl,mode = "i2s-master";
>>     status = "okay";
>> };
>>
>> &audmux {
>>     status = "okay";
>>
>>     ssi1 {
>>         fsl,audmux-port = <AUDMUX_INT_PORT>;
>>         fsl,port-config = <
>> #ifdef SSI_TEST_MASTER
>>             IMX_AUDMUX_V2_PTCR_SYN
>> #else
>>             (IMX_AUDMUX_V2_PTCR_TFSDIR |
>>             IMX_AUDMUX_V2_PTCR_TFSEL(AUDMUX_EXT_PORT) |
>>             IMX_AUDMUX_V2_PTCR_TCLKDIR |
>>             IMX_AUDMUX_V2_PTCR_TCSEL(AUDMUX_EXT_PORT) |
>>             IMX_AUDMUX_V2_PTCR_SYN
>>             )
>> #endif
>>             IMX_AUDMUX_V2_PDCR_RXDSEL(AUDMUX_EXT_PORT)
>>         >;
>>     };
>>
>>     AUDMUX_INT_PORT_NAME {
>>         fsl,audmux-port = <AUDMUX_EXT_PORT>;
>>         fsl,port-config = <
>> #ifdef SSI_TEST_MASTER
>>             (IMX_AUDMUX_V2_PTCR_TFSDIR |
>>             IMX_AUDMUX_V2_PTCR_TFSEL(AUDMUX_INT_PORT) |
>>             IMX_AUDMUX_V2_PTCR_TCLKDIR |
>>             IMX_AUDMUX_V2_PTCR_TCSEL(AUDMUX_INT_PORT) |
>>             IMX_AUDMUX_V2_PTCR_SYN
>>             )
>> #else
>>             IMX_AUDMUX_V2_PTCR_SYN
>> #endif
>>             IMX_AUDMUX_V2_PDCR_RXDSEL(AUDMUX_INT_PORT)
>>         >;
>>     };
>> };





>>
>>
>> / {
>>     model = "Engicam i.CoreM6 DualLite/Solo starterkit";
>>     compatible = "fsl,imx6-icore", "fsl,imx6dl";
>>
>>     codec_test: codec_test {
>>         compatible = "linux,snd-soc-dummy";
>>         #sound-dai-cells = <0>;
>>     };
>>
>>     sound {
>>         compatible = "simple-audio-card";
>>         simple-audio-card,name = "test";
>>         simple-audio-card,format="dsp_a";
>>         simple-audio-card,frame-master = <&sound2_ssi>;
>>         simple-audio-card,bitclock-master = <&sound2_ssi>;
>>
>>         sound2_ssi: simple-audio-card,cpu {
>>             sound-dai = <&ssi1>;
>>             system-clock-frequency = <1536000>;
>>             dai-tdm-slot-num = <2>;
>>             dai-tdm-slot-width = <16>;
>>         };
>>
>>         sound2codec: simple-audio-card,codec {
>>             sound-dai = <&codec_test>;
>>         };
>>     };
>>
>> };
>>
>> &iomuxc {
>>     audmux {
>>         pinctrl_audmux_1: audmux-1 {
>>             fsl,pins = <
>>                 MX6QDL_PAD_SD2_DAT0__AUD4_RXD  0x130b0
>>                 MX6QDL_PAD_SD2_DAT3__AUD4_TXC  0x130b0
>>                 MX6QDL_PAD_SD2_DAT2__AUD4_TXD  0x110b0
>>                 MX6QDL_PAD_SD2_DAT1__AUD4_TXFS 0x130b0
>>             >;
>>         };
>>
>>         pinctrl_audmux_2: audmux-2 {
>>             fsl,pins = <
>>                 MX6QDL_PAD_CSI0_DAT7__AUD3_RXD  0x130b0
>>                 MX6QDL_PAD_CSI0_DAT4__AUD3_TXC  0x130b0
>>                 MX6QDL_PAD_CSI0_DAT5__AUD3_TXD  0x110b0
>>                 MX6QDL_PAD_CSI0_DAT6__AUD3_TXFS 0x130b0
>>             >;
>>         };
>>
>>         pinctrl_audmux_3: audmux-3 {
>>             fsl,pins = <
>>                 MX6QDL_PAD_DISP0_DAT16__AUD5_TXC  0x130b0
>>                 MX6QDL_PAD_DISP0_DAT18__AUD5_TXFS 0x130b0
>>                 MX6QDL_PAD_DISP0_DAT19__AUD5_RXD  0x130b0
>>             >;
>>         };
>>
>>         pinctrl_audmux_4: audmux-4 {
>>             fsl,pins = <
>>                 MX6QDL_PAD_DISP0_DAT20__AUD4_TXC  0x130b0
>>                 MX6QDL_PAD_DISP0_DAT21__AUD4_TXD 0x110b0
>>                 MX6QDL_PAD_DISP0_DAT22__AUD4_TXFS  0x130b0
>>                 MX6QDL_PAD_DISP0_DAT23__AUD4_RXD  0x130b0
>>             >;
>>         };
>>     };
>> };
>>
>>
>>
>> 2016-05-09 19:21 GMT+02:00 Caleb Crome <caleb@crome.org>:
>>>
>>> On Mon, May 9, 2016 at 4:17 AM, nick83ola <nick83ola@gmail.com> wrote:
>>> > Dear Alsa, Caleb and Arnaud
>>> >
>>> > I need to output an i2s master stream from my IMX6 solo board
>>> >
>>> > my board have this configuration for sound: (it have an sgtl5000 codec
>>> > not
>>> > on module, but on dev board)
>>> >
>>> >
>>> > ==========================================================================
>>> > sound {
>>> >         compatible = "fsl,imx6q-icore-sgtl5000",
>>> >                  "fsl,imx-audio-sgtl5000";
>>> >         model = "imx6q-icore-sgtl5000";
>>> >         ssi-controller = <&ssi1>;
>>> >         audio-codec = <&codec>;
>>> >         audio-routing =
>>> >            "MIC_IN", "Mic Jack",
>>> >             "Mic Jack", "Mic Bias",
>>> >             "Headphone Jack", "HP_OUT";
>>> >         mux-int-port = <2>;
>>> >         mux-ext-port = <4>;
>>> >     };
>>> > &ssi1 {
>>> >     fsl,mode = "i2s-master";
>>> >     status = "okay";
>>> > };
>>> >
>>> > &audmux {
>>> >     pinctrl-names = "default";
>>> >     pinctrl-0 = <&pinctrl_audmux_4>;
>>> >     status = "okay";
>>> > };
>>> >
>>> > &iomuxc {
>>> >     audmux {
>>> >         pinctrl_audmux_4: audmux-4 {
>>> >             fsl,pins = <
>>> >                 MX6QDL_PAD_DISP0_DAT20__AUD4_TXC  0x130b0
>>> >                 MX6QDL_PAD_DISP0_DAT21__AUD4_TXD 0x110b0
>>> >                 MX6QDL_PAD_DISP0_DAT22__AUD4_TXFS  0x130b0
>>> >                 MX6QDL_PAD_DISP0_DAT23__AUD4_RXD  0x130b0
>>> >             >;
>>> >        };
>>> >   };
>>> >
>>> > ==========================================================================
>>> >
>>> > I need to output i2s on the same port as sgtl5000, bit in master mode
>>> > i've patched sound/soc/soc-utils.c to add support for dts as per arnaud
>>> > patch
>>> >
>>> >
>>> > ==========================================================================
>>> > #ifdef CONFIG_OF
>>> > static const struct of_device_id soc_dummy_ids[] = {
>>> >     { .compatible = "linux,snd-soc-dummy", },
>>> >     { }
>>> > };
>>> > MODULE_DEVICE_TABLE(of, soc_dummy_ids);
>>> > #endif
>>> > ...
>>> > .of_match_table = of_match_ptr(soc_dummy_ids),
>>> >
>>> > ==========================================================================
>>> >
>>> > --> (it is necessary?????? or can I use simple audio card??????
>>> >
>>> >
>>> > -> i've put this in my dts file
>>> >
>>> >
>>> > ==========================================================================
>>> > &audmux {
>>> >     ssi3 {
>>> >         fsl,audmux-port = <6>;
>>> >         fsl,port-config = <
>>> >              0x00000000
>>> >              IMX_AUDMUX_V2_PDCR_RXDSEL(4)
>>> >          >;
>>> >      };
>>> >
>>> >      port5 {
>>> >          fsl,audmux-port = <4>;
>>> >          fsl,port-config = <
>>> >              (IMX_AUDMUX_V2_PTCR_TFSDIR |
>>> >              IMX_AUDMUX_V2_PTCR_TFSEL(6) |
>>> >              IMX_AUDMUX_V2_PTCR_TCLKDIR |
>>> >              IMX_AUDMUX_V2_PTCR_TCSEL(6))
>>> >              IMX_AUDMUX_V2_PDCR_RXDSEL(6)
>>> >          >;
>>> >      };
>>> > };
>>> >
>>> > &ssi1 {
>>> >      status = "disabled";
>>> > };
>>> >
>>> > &ssi2 {
>>> >      status = "disabled";
>>> > };
>>> >
>>> > &ssi3 {
>>> >      status = "okay";
>>> >      #sound-dai-cells = <0>;
>>> >      // select the a clock parent suitable for 48000 Hz sampling rate
>>> >      assigned-clocks = <&clks IMX6QDL_CLK_SSI3_SEL>, <&clks
>>> > IMX6QDL_CLK_SSI3>;
>>> >      assigned-clock-parents = <&clks IMX6QDL_CLK_PLL4_AUDIO_DIV>;
>>> >      assigned-clock-rates = <0>, <49152000>;
>>> > };
>>> >
>>> > / {
>>> >     model = "Engicam i.CoreM6 DualLite/Solo starterkit";
>>> >     compatible = "fsl,imx6-icore", "fsl,imx6dl";
>>> >
>>> >     sound{
>>> >      status = "disabled";
>>> >     };
>>> >
>>> >     sound-itel {
>>> >         compatible = "simple-audio-card";
>>> >         simple-audio-card,name = "test";
>>> >         simple-audio-card,format="dsp_a";
>>> >         simple-audio-card,frame-master = <&sound2_ssi>;
>>> >         simple-audio-card,bitclock-master = <&sound2_ssi>;
>>> >         sound2_ssi: simple-audio-card,cpu {
>>> >             sound-dai = <&ssi3>;
>>> >             system-clock-frequency = <1536000>;
>>> >             dai-tdm-slot-num = <2>;
>>> >             dai-tdm-slot-width = <16>;
>>> >         };
>>> >     };
>>> > };
>>> >
>>> > ==========================================================================
>>> >
>>> >
>>> > here's my log
>>> >
>>> > /sound-itel/simple-audio-card,cpu: arguments longer than property
>>> > asoc-simple-card sound-itel.31: parse error -22
>>> > asoc-simple-card: probe of sound-itel.31 failed with error -22
>>> >
>>> >
>>> >
>>>
>>>
>>> Hi Nikola,
>>>    Here is my working setup for a wandboard with no i2c codecs.
>>>
>>>
>>> https://github.com/ccrome/linux-caleb-dev/blob/v4.5-caleb-wandboard/arch/arm/boot/dts/imx6qdl-wandboard.dtsi
>>>
>>> You need to be sure to set up the audmux right.    I'm not sure with
>>> that old kernel if everything with audmux works right or not -- I
>>> haven't tested it.
>>>
>>> That should get you pretty close to what you need for your board I
>>> suspect.
>>>
>>> That branch (v4.5-caleb-wandboard) will build and run the SSI3 port on
>>> AUD5 port, with the mx6 in master mode.  And, with all arnaud's
>>> patches (included already in that repo), it will actually be robust.
>>>
>>> -caleb
>>>
>>>
>>>
>>>
>>>
>>>
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> > 2016-05-06 17:38 GMT+02:00 Caleb Crome <caleb@crome.org>:
>>> >>
>>> >> Hi there,
>>> >>    Arnaud had a neat patch here that lets you set up a dummy sound
>>> >> card from the DTS.
>>> >>
>>> >>
>>> >>
>>> >> http://mailman.alsa-project.org/pipermail/alsa-devel/2015-November/100896.html
>>> >>
>>> >> With that patch, you can set up your DTS to simply start streaming, no
>>> >> codec or anything required, which should work for a codec with no I2C.
>>> >>
>>> >>
>>> >> Hope that helps,
>>> >>   -Caleb
>>> >>
>>> >>
>>> >> On Thu, May 5, 2016 at 12:56 PM, nick83ola <nick83ola@gmail.com>
>>> >> wrote:
>>> >> > Hello Alsa dev!
>>> >> >
>>> >> > Anyone have an example of an i2s only driver for imx6 solo? I need a
>>> >> > driver
>>> >> > without i2c....
>>> >> > _______________________________________________
>>> >> > Alsa-devel mailing list
>>> >> > Alsa-devel@alsa-project.org
>>> >> > http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
>>> >
>>> >
>>> >
>>> >
>>> > --
>>> >
>>> > P.S. Le informazioni trasmesse attraverso la presente comunicazione
>>> > sono di
>>> > esclusiva
>>> > spettanza dell'effettivo destinatario. Nel caso in cui le stesse
>>> > raggiungessero, per
>>> > qualunque motivo, soggetti non interessati, questi ultimi vorranno
>>> > darne
>>> > immediata
>>> > notizia al mittente. In ogni caso, eventuali soggetti diversi dai
>>> > legittimi
>>> > destinatari
>>> > della presente comunicazione e dei dati contenuti negli allegati,
>>> > possono
>>> > essere
>>> > sanzionati ai sensi del T.U. sul trattamento dei dati personali d.lgs.
>>> > 196/2003, sia ai
>>> > sensi dell'art. 616 del Codice Penale che disciplina la violazione del
>>> > segreto sulla
>>> > corrispondenza.
>>
>>
>>
>>
>> --
>>
>> P.S. Le informazioni trasmesse attraverso la presente comunicazione sono
>> di esclusiva
>> spettanza dell'effettivo destinatario. Nel caso in cui le stesse
>> raggiungessero, per
>> qualunque motivo, soggetti non interessati, questi ultimi vorranno darne
>> immediata
>> notizia al mittente. In ogni caso, eventuali soggetti diversi dai
>> legittimi destinatari
>> della presente comunicazione e dei dati contenuti negli allegati, possono
>> essere
>> sanzionati ai sensi del T.U. sul trattamento dei dati personali d.lgs.
>> 196/2003, sia ai
>> sensi dell'art. 616 del Codice Penale che disciplina la violazione del
>> segreto sulla
>> corrispondenza.
>
>
>
>
> --
>
> P.S. Le informazioni trasmesse attraverso la presente comunicazione sono di
> esclusiva
> spettanza dell'effettivo destinatario. Nel caso in cui le stesse
> raggiungessero, per
> qualunque motivo, soggetti non interessati, questi ultimi vorranno darne
> immediata
> notizia al mittente. In ogni caso, eventuali soggetti diversi dai legittimi
> destinatari
> della presente comunicazione e dei dati contenuti negli allegati, possono
> essere
> sanzionati ai sensi del T.U. sul trattamento dei dati personali d.lgs.
> 196/2003, sia ai
> sensi dell'art. 616 del Codice Penale che disciplina la violazione del
> segreto sulla
> corrispondenza.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Imx6 i2s master driver without i2c
  2016-05-10 16:14                   ` Caleb Crome
@ 2016-05-10 17:00                     ` nick83ola
  2016-05-10 17:43                       ` Caleb Crome
  0 siblings, 1 reply; 18+ messages in thread
From: nick83ola @ 2016-05-10 17:00 UTC (permalink / raw)
  To: alsa-devel

Ok I tested the output pin and the bclk pin is set as an input not output!
And i have obviusly no clock

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Imx6 i2s master driver without i2c
  2016-05-10 17:00                     ` nick83ola
@ 2016-05-10 17:43                       ` Caleb Crome
  2016-05-11  6:25                         ` nick83ola
  0 siblings, 1 reply; 18+ messages in thread
From: Caleb Crome @ 2016-05-10 17:43 UTC (permalink / raw)
  To: nick83ola; +Cc: alsa-devel

On Tue, May 10, 2016 at 10:00 AM, nick83ola <nick83ola@gmail.com> wrote:
> Ok I tested the output pin and the bclk pin is set as an input not output!
> And i have obviusly no clock

I'd put printk's where in the audmux driver where the DT's
'fsl,port-config' is parsed and used, and make sure it's all getting
read properly.  You need to trace the signal settings from the pin,
through the iomux, audmux and finally to the SSI.  Something's not
right somewhere, but I don't really know.

-Caleb


> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Imx6 i2s master driver without i2c
  2016-05-10 17:43                       ` Caleb Crome
@ 2016-05-11  6:25                         ` nick83ola
  2016-05-11 17:34                           ` Caleb Crome
  0 siblings, 1 reply; 18+ messages in thread
From: nick83ola @ 2016-05-11  6:25 UTC (permalink / raw)
  To: Caleb Crome; +Cc: alsa-devel

What I don't understand is the sequence of init.
​of the driver.
I think that I need to :
init dma to transfer from ssi1 (what file???)
init ssi1 with a clock and a mode (i2s master) (i think fsl_ssi or imx-ssi
file?? )
init audmux to put ssi1 (port 1) to port 4 (is a clock needed?) (imx-audmux
module??)
init iomux to put port4 output on output pin (I need to set pin direction
also or is automatic???) (only in dts? what function set that?)

and where those init are? and what file/function does the actual memory
transfer?
and ... last how I can check separately all those things??
I can init ssi for example without audio as a "serial port" and test it???
or I can Init the output port as gpio and set pins to test if its
initializated??

How I can read the cpu register back from linux to check that are correctly
initializated (for example I can read iomux registers????)
The documentation/tutorial on alsa driver are very scarse, and freescale
community is not of help

Thanks for your help

Nicola
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Imx6 i2s master driver without i2c
  2016-05-11  6:25                         ` nick83ola
@ 2016-05-11 17:34                           ` Caleb Crome
  2016-05-12  7:55                             ` nick83ola
  0 siblings, 1 reply; 18+ messages in thread
From: Caleb Crome @ 2016-05-11 17:34 UTC (permalink / raw)
  To: nick83ola; +Cc: alsa-devel

On Tue, May 10, 2016 at 11:25 PM, nick83ola <nick83ola@gmail.com> wrote:
> What I don't understand is the sequence of init.
> of the driver.
> I think that I need to :
> init dma to transfer from ssi1 (what file???)
> init ssi1 with a clock and a mode (i2s master) (i think fsl_ssi or imx-ssi
> file?? )
> init audmux to put ssi1 (port 1) to port 4 (is a clock needed?) (imx-audmux
> module??)
> init iomux to put port4 output on output pin (I need to set pin direction
> also or is automatic???) (only in dts? what function set that?)
>
> and where those init are? and what file/function does the actual memory
> transfer?
> and ... last how I can check separately all those things??
> I can init ssi for example without audio as a "serial port" and test it???
> or I can Init the output port as gpio and set pins to test if its
> initializated??

In pricipal, but you don't want to mess with the structure that's in place.

>
> How I can read the cpu register back from linux to check that are correctly
> initializated (for example I can read iomux registers????)

Yes, use printk from fsl_ssi.c
For example:

   u32 stcr_val;
   regmap_read(regs, CCSR_SSI_STCR, &stcr_val);
   printk(KERN_INFO "This is the STCR register: 0x%08x\n", strc_val);

There is also a regmap entry in /sys that has your ssi values there,
which can be great for reading all the register values at once.
However, these are really only useful when the port is open.
Generally, I want to see the values are they are written into the
registers so I can see exampley what's going on..

> The documentation/tutorial on alsa driver are very scarse, and freescale
> community is not of help
>
> Thanks for your help
>
> Nicola
>

Yeah, it's all a bit complicated, and I don't understand most of it.
But, the good news is that you shouldn't really have to deal with much
of it.  The SSI is already connected to the DMA and the DMA is
connected to user space, so that's not something you need to worry
about.
The things you need to make sure of is that the pins & audmux & SSI
are configured properly via the device tree, and you shouldn't really
need to do much more than that.

It sounds like you're not getting your TX clock into master mode,
right?  It should start generating a master clock when you start
recording and playing back from your sound card.

For example, looking at the IMX6DQRM.pdf (section 61.8.1.4 among
others), you'll want SSI.TXDIR set to 1 (generate bit clock) and TFDIR
set to 1 (generated frame sync).

The way these bits are set is a bit round-about.  But here goes:

For master mode, (for simple-audio-card anyway), in your DTB you set:

   simple-audio-card,frame-master = <&sound2_ssi>;
   simple-audio-card,bitclock-master = <&sound2_ssi>;

(see here https://github.com/ccrome/linux-caleb-dev/blob/b9bf92b9d9f2121bab38d5e927faa4bc2f80c18c/arch/arm/boot/dts/imx6qdl-wandboard.dtsi).

This tells the simple-audio-card driver (here:
http://lxr.free-electrons.com/source/sound/soc/generic/simple-card.c#L278)
to set the DAI format so that the SSI is master.  This will in turn
call fsl_set_dai_fmt here:
http://lxr.free-electrons.com/source/sound/soc/fsl/fsl_ssi.c#L1044,
which should set the TDDIR and TXDIR bits appropriately.

So, I'd put prink's in fsl_ssi_set_dai_fmt and to see what's actually
getting set, just to check.

Are you successfully getting it set to master mode?

Are you getting a clock?  This is trickier for me since I totally
don't understand how the clock tree stuff works.  But, if you use SSI3
instead of SSI1, my config should work.  Is there any reason you're
using the other SSI?

For me, once I got the audmux directions right, the bits started
flying out of the port (but only when the alsa device is open).

-Caleb

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Imx6 i2s master driver without i2c
  2016-05-11 17:34                           ` Caleb Crome
@ 2016-05-12  7:55                             ` nick83ola
  2016-05-13  7:59                               ` nick83ola
  0 siblings, 1 reply; 18+ messages in thread
From: nick83ola @ 2016-05-12  7:55 UTC (permalink / raw)
  To: Caleb Crome; +Cc: alsa-devel

I am using ssi1 because I have an example of setting master mode on sabre
board dts

I have a problem with iomux/pinctrl  I think because

root@icorem6solo:/sys/kernel/debug/pinctrl/20e0000.iomuxc# cat pinmux-pins
|grep audmux
pin 57 (MX6DL_PAD_DISP0_DAT20): 2028000.ssi (GPIO UNCLAIMED) function
audmux group audmux-4
pin 58 (MX6DL_PAD_DISP0_DAT21): 2028000.ssi (GPIO UNCLAIMED) function
audmux group audmux-4
pin 59 (MX6DL_PAD_DISP0_DAT22): 2028000.ssi (GPIO UNCLAIMED) function
audmux group audmux-4
pin 60 (MX6DL_PAD_DISP0_DAT23): 2028000.ssi (GPIO UNCLAIMED) function
audmux group audmux-4

says: GPIO_UNCLAIMED? it is correct??

/sys/kernel/debug/pinctrl/20e0000.iomuxc# cat pinconf-groups |grep -A 1
audmux
1 (audmux-1):
MX6DL_PAD_SD2_DAT0: 0x17070MX6DL_PAD_SD2_DAT3: 0x17070MX6DL_PAD_SD2_DAT2:
0x17070MX6DL_PAD_SD2_DAT1: 0x17070
2 (audmux-2):
MX6DL_PAD_CSI0_DAT7: 0x1b0b0MX6DL_PAD_CSI0_DAT4:
0x1b0b0MX6DL_PAD_CSI0_DAT5: 0x1b0b0MX6DL_PAD_CSI0_DAT6: 0x1b0b0
3 (audmux-3):
MX6DL_PAD_DISP0_DAT16: 0x10MX6DL_PAD_DISP0_DAT18:
0x1b0b0MX6DL_PAD_DISP0_DAT19: 0x1b0b0
4 (audmux-4):
MX6DL_PAD_DISP0_DAT20: 0x130b0MX6DL_PAD_DISP0_DAT21:
0x110b0MX6DL_PAD_DISP0_DAT22: 0x130b0MX6DL_PAD_DISP0_DAT23: 0x130b0

0x130b0?

audmux# cat ssi0
    PDCR: 0000a000
    PTCR: ad400800
    TxFS output from SSI6, TxClk output from SSI6
    Port is symmetric
    Data received from SSI6
root@icorem6solo:/sys/kernel/debug/audmux# cat ssi1
    PDCR: 00008000
    PTCR: 00000800
    TxFS input, TxClk input
    Port is symmetric
    Data received from SSI5
root@icorem6solo:/sys/kernel/debug/audmux# cat ssi2
    PDCR: 00006000
    PTCR: 9cc00800
    TxFS output from SSI4, TxClk output from SSI4
    Port is symmetric
    Data received from SSI4
root@icorem6solo:/sys/kernel/debug/audmux# cat ssi3
    PDCR: 00004000
    PTCR: 00000800
    TxFS input, TxClk input
    Port is symmetric
    Data received from SSI3
root@icorem6solo:/sys/kernel/debug/audmux# cat ssi4
    PDCR: 00002000
    PTCR: 8c400800
    TxFS output from imx-ssi.1, TxClk output from imx-ssi.1
    Port is symmetric
    Data received from imx-ssi.1
root@icorem6solo:/sys/kernel/debug/audmux# cat ssi5
    PDCR: 00000000
    PTCR: 00000800
    TxFS input, TxClk input
    Port is symmetric
    Data received from imx-ssi.0
root@icorem6solo:/sys/kernel/debug/audmux# cat ssi6
    PDCR: 0000c000
    PTCR: 00000800
    TxFS input, TxClk input
    Port is symmetric
    Data received from UNKNOWN

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Imx6 i2s master driver without i2c
  2016-05-12  7:55                             ` nick83ola
@ 2016-05-13  7:59                               ` nick83ola
  2016-05-13  8:21                                 ` nick83ola
  2016-05-13 19:30                                 ` Caleb Crome
  0 siblings, 2 replies; 18+ messages in thread
From: nick83ola @ 2016-05-13  7:59 UTC (permalink / raw)
  To: Caleb Crome; +Cc: alsa-devel

Caleb thanks for your help!!!! the documentation is really orrible!!!!

but now I'm getting something out of TXD!!!!

only no clock and very fast (I think that I need to configure the
oscillator/pll and iomux???)

In my kernel (3.14.28-1.0.0_ga+g91cf351) some of the statement in you dts
are not supported in simple driver so I stripped down the imx-si476 driver
and use with your dummy codec driver

&audmux {
    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_audmux_4>;
    status = "okay";
};

&ssi2 {
    assigned-clocks = <&clks IMX6QDL_CLK_SSI2_SEL>;
    assigned-clock-parents = <&clks IMX6QDL_CLK_PLL4_AUDIO_DIV>;
    assigned-clock-rates = <0>;
    fsl,mode = "i2s-master";
    status = "okay";
};


/ {
    model = "Engicam i.CoreM6 DualLite/Solo starterkit";
    compatible = "fsl,imx6-icore", "fsl,imx6dl";

    codec_test: codec_test {
        compatible = "linux,snd-soc-dummy";
        status = "okay";
    };

    sound {
        compatible = "fsl,imx-audio-itel";
        model = "imx-itel";
        ssi-controller = <&ssi2>;
        audio-codec = <&codec_test>;
        mux-int-port = <4>;
        mux-ext-port = <2>;
        status = "okay";
    };

    sound-hdmi {
        status = "disabled";
    };
};


&iomuxc {
    audmux {
        pinctrl_audmux_4: audmux-4 {
            fsl,pins = <
                MX6QDL_PAD_DISP0_DAT20__AUD4_TXC  0x130b0
                MX6QDL_PAD_DISP0_DAT21__AUD4_TXD 0x110b0
                MX6QDL_PAD_DISP0_DAT22__AUD4_TXFS  0x130b0
                MX6QDL_PAD_DISP0_DAT23__AUD4_RXD  0x130b0
            >;
        };
    };
};

======================================================================================================================
imx-itel.c
======================================================================================================================


/*
 * Copyright (C) 2013 Freescale Semiconductor, Inc.
 *
 * The code contained herein is licensed under the GNU General Public
 * License. You may obtain a copy of the GNU General Public License
 * Version 2 or later at the following locations:
 *
 * http://www.opensource.org/licenses/gpl-license.html
 * http://www.gnu.org/copyleft/gpl.html
 */

#define DEBUG 1

#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_platform.h>
#include <linux/device.h>
#include <linux/clk.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/soc.h>
#include <sound/initval.h>
#include <sound/pcm_params.h>

#include "imx-audmux.h"

struct imx_itel_data {
    struct snd_soc_dai_link dai;
    struct snd_soc_card card;
};


static int imx_audmux_config(int slave, int master)
{
    unsigned int ptcr, pdcr;
    slave = slave - 1;
    master = master - 1;

    ptcr = IMX_AUDMUX_V2_PTCR_SYN |
        IMX_AUDMUX_V2_PTCR_TFSDIR |
        IMX_AUDMUX_V2_PTCR_TFSEL(slave) |
        IMX_AUDMUX_V2_PTCR_TCLKDIR |
        IMX_AUDMUX_V2_PTCR_TCSEL(slave);
    pdcr = IMX_AUDMUX_V2_PDCR_RXDSEL(slave);

    imx_audmux_v2_configure_port(master, ptcr, pdcr);

    /*
     * According to RM, RCLKDIR and SYN should not be changed at same time.
     * So separate to two step for configuring this port.
     */
    ptcr |= IMX_AUDMUX_V2_PTCR_RFSDIR |
        IMX_AUDMUX_V2_PTCR_RFSEL(slave) |
        IMX_AUDMUX_V2_PTCR_RCLKDIR |
        IMX_AUDMUX_V2_PTCR_RCSEL(slave);
    imx_audmux_v2_configure_port(master, ptcr, pdcr);

    printk(KERN_ERR "--> ITEL imx-audmux-confic ext-port port=%#010x
ptcr=%#010x pdcr=%#010x\n", master, ptcr, pdcr);

    ptcr = IMX_AUDMUX_V2_PTCR_SYN;
    pdcr = IMX_AUDMUX_V2_PDCR_RXDSEL(master);

    printk(KERN_ERR "--> ITEL imx-audmux-config int-port port=%#010x
ptcr=%#010x pdcr=%#010x\n", master, ptcr, pdcr);
    imx_audmux_v2_configure_port(slave, ptcr, pdcr);

    return 0;
}


static int imx_itel_hw_params(struct snd_pcm_substream *substream,
                              struct snd_pcm_hw_params *params)
{
    struct snd_soc_pcm_runtime *rtd = substream->private_data;
    struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
    u32 channels = params_channels(params);
    u32 rate = params_rate(params);
    u32 bclk = rate * channels * 32;
    int ret = 0;

    printk(KERN_ERR "--> ITEL imx-itel-hw-params NAME=%s  \n VALUE=%#010x  "
                        "SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
SND_SOC_DAIFMT_CBS_CFS\n",
                        cpu_dai->name,
                        (SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
SND_SOC_DAIFMT_CBS_CFS));

    /* set cpu DAI configuration */
    ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S
            | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
    if (ret) {
        dev_err(cpu_dai->dev, "failed to set dai fmt\n");
        return ret;
    }
    printk(KERN_ERR "--> ITEL imx-itel-hw-params set tdm slots
channels=%d", channels);

    ret = snd_soc_dai_set_tdm_slot(cpu_dai,
            channels == 1 ? 0xfffffffe : 0xfffffffc,
            channels == 1 ? 0xfffffffe : 0xfffffffc,
            2, 32);
    if (ret) {
        dev_err(cpu_dai->dev, "failed to set dai tdm slot\n");
        return ret;
    }

    printk(KERN_ERR "--> ITEL imx-audmux-config set sysclk NAME=%s
\n",cpu_dai->name);

    ret = snd_soc_dai_set_sysclk(cpu_dai, 0, bclk, SND_SOC_CLOCK_OUT);
    if (ret)
        dev_err(cpu_dai->dev, "failed to set sysclk\n");

    return ret;
}


static struct snd_soc_ops imx_itel_ops = {
    .hw_params = imx_itel_hw_params,
};


static struct snd_soc_dai_link imx_itel_dai[] = {
    {
        .name            = "Hifi",
        .stream_name     = "Hifi",
        .codec_dai_name     = "snd-soc-dummy-dai",
        //.codec_name         = "snd-soc-dummy",
        .ops             = &imx_itel_ops,
        // .symmetric_rates = 1,
    },
};

static struct snd_soc_card snd_soc_card_imx_itel = {
    .name       = "imx-audio-itel",
    .dai_link   = imx_itel_dai,
    .num_links    = ARRAY_SIZE(imx_itel_dai),
    .owner      = THIS_MODULE,
};


static int imx_itel_probe(struct platform_device *pdev)
{
    struct snd_soc_card *card = &snd_soc_card_imx_itel;
    struct device_node *ssi_np;
    struct platform_device *ssi_pdev;
    struct device_node *codec_np;
    // struct imx_itel_data *data = NULL;
    int int_port, ext_port, ret;

    printk(KERN_ERR "--> ITEL imx_itel_probe");

    ret = of_property_read_u32(pdev->dev.of_node, "mux-int-port",
&int_port);
    if (ret) {
        dev_err(&pdev->dev, "mux-int-port missing or invalid\n");
        return ret;
    }


    ret = of_property_read_u32(pdev->dev.of_node, "mux-ext-port",
&ext_port);
    if (ret) {
        dev_err(&pdev->dev, "mux-ext-port missing or invalid\n");
        return ret;
    }

    printk(KERN_ERR "--> ITEL Configuro audmux\n");
    imx_audmux_config(int_port, ext_port);

    /* find value in devicetree for ssi controller */
    ssi_np = of_parse_phandle(pdev->dev.of_node, "ssi-controller", 0);
    if (!ssi_np) {
        dev_err(&pdev->dev, "ssi-controller missing or invalid\n");
        ret = -EINVAL;
        goto fail;
    }

    /* find SSI platform driver */
    ssi_pdev = of_find_device_by_node(ssi_np);
    if (!ssi_pdev) {
        dev_err(&pdev->dev, "failed to find SSI platform device\n");
        ret = -EPROBE_DEFER;
        goto fail;
    }

    codec_np = of_parse_phandle(pdev->dev.of_node, "audio-codec", 0);
    if (!codec_np) {
        dev_err(&pdev->dev, "codec missing or invalid\n");
        ret = -EINVAL;
        goto fail;
    }

    // codec_dev = NULL;

    card->dev = &pdev->dev;
    card->dai_link->cpu_dai_name = dev_name(&ssi_pdev->dev);
    card->dai_link->platform_of_node = ssi_np;
    card->dai_link->codec_of_node = codec_np;

    platform_set_drvdata(pdev, card);
    snd_soc_card_set_drvdata(card, &snd_soc_card_imx_itel);

    printk(KERN_ERR "--> ITEL imx-probe registro card\n");

    ret = snd_soc_register_card(card);
    if (ret) {
        dev_err(&pdev->dev, "Failed to register card: %d\n", ret);
        goto fail;
    }

    printk(KERN_ERR "--> ITEL imx-probe of ssi\n");
    of_node_put(ssi_np);
    printk(KERN_ERR "--> ITEL imx-probe of codec\n");
    of_node_put(codec_np);

    return 0;

fail:
    if (ssi_np)
        of_node_put(ssi_np);
    if (codec_np)
        of_node_put(codec_np);

    return ret;
}

static int imx_itel_remove(struct platform_device *pdev)
{
    struct snd_soc_card *card = &snd_soc_card_imx_itel;

    snd_soc_unregister_card(card);

    return 0;
}

static const struct of_device_id imx_itel_dt_ids[] = {
    { .compatible = "fsl,imx-audio-itel", },
    { /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, imx_itel_dt_ids);

static struct platform_driver imx_itel_driver = {
    .driver = {
        .name = "imx-itel",
        .owner = THIS_MODULE,
        .pm = &snd_soc_pm_ops,
        .of_match_table = imx_itel_dt_ids,
    },
    .probe = imx_itel_probe,
    .remove = imx_itel_remove,
};

module_platform_driver(imx_itel_driver);

MODULE_AUTHOR("Nicola Lunghi");
MODULE_DESCRIPTION("ITEL I2S Platform Driver");
MODULE_LICENSE("GPL v2");
MODULE_ALIAS("platform:imx-itel");

2016-05-12 9:55 GMT+02:00 nick83ola <nick83ola@gmail.com>:

> I am using ssi1 because I have an example of setting master mode on sabre
> board dts
>
> I have a problem with iomux/pinctrl  I think because
>
> root@icorem6solo:/sys/kernel/debug/pinctrl/20e0000.iomuxc# cat
> pinmux-pins |grep audmux
> pin 57 (MX6DL_PAD_DISP0_DAT20): 2028000.ssi (GPIO UNCLAIMED) function
> audmux group audmux-4
> pin 58 (MX6DL_PAD_DISP0_DAT21): 2028000.ssi (GPIO UNCLAIMED) function
> audmux group audmux-4
> pin 59 (MX6DL_PAD_DISP0_DAT22): 2028000.ssi (GPIO UNCLAIMED) function
> audmux group audmux-4
> pin 60 (MX6DL_PAD_DISP0_DAT23): 2028000.ssi (GPIO UNCLAIMED) function
> audmux group audmux-4
>
> says: GPIO_UNCLAIMED? it is correct??
>
> /sys/kernel/debug/pinctrl/20e0000.iomuxc# cat pinconf-groups |grep -A 1
> audmux
> 1 (audmux-1):
> MX6DL_PAD_SD2_DAT0: 0x17070MX6DL_PAD_SD2_DAT3: 0x17070MX6DL_PAD_SD2_DAT2:
> 0x17070MX6DL_PAD_SD2_DAT1: 0x17070
> 2 (audmux-2):
> MX6DL_PAD_CSI0_DAT7: 0x1b0b0MX6DL_PAD_CSI0_DAT4:
> 0x1b0b0MX6DL_PAD_CSI0_DAT5: 0x1b0b0MX6DL_PAD_CSI0_DAT6: 0x1b0b0
> 3 (audmux-3):
> MX6DL_PAD_DISP0_DAT16: 0x10MX6DL_PAD_DISP0_DAT18:
> 0x1b0b0MX6DL_PAD_DISP0_DAT19: 0x1b0b0
> 4 (audmux-4):
> MX6DL_PAD_DISP0_DAT20: 0x130b0MX6DL_PAD_DISP0_DAT21:
> 0x110b0MX6DL_PAD_DISP0_DAT22: 0x130b0MX6DL_PAD_DISP0_DAT23: 0x130b0
>
> 0x130b0?
>
> audmux# cat ssi0
>     PDCR: 0000a000
>     PTCR: ad400800
>     TxFS output from SSI6, TxClk output from SSI6
>     Port is symmetric
>     Data received from SSI6
> root@icorem6solo:/sys/kernel/debug/audmux# cat ssi1
>     PDCR: 00008000
>     PTCR: 00000800
>     TxFS input, TxClk input
>     Port is symmetric
>     Data received from SSI5
> root@icorem6solo:/sys/kernel/debug/audmux# cat ssi2
>     PDCR: 00006000
>     PTCR: 9cc00800
>     TxFS output from SSI4, TxClk output from SSI4
>     Port is symmetric
>     Data received from SSI4
> root@icorem6solo:/sys/kernel/debug/audmux# cat ssi3
>     PDCR: 00004000
>     PTCR: 00000800
>     TxFS input, TxClk input
>     Port is symmetric
>     Data received from SSI3
> root@icorem6solo:/sys/kernel/debug/audmux# cat ssi4
>     PDCR: 00002000
>     PTCR: 8c400800
>     TxFS output from imx-ssi.1, TxClk output from imx-ssi.1
>     Port is symmetric
>     Data received from imx-ssi.1
> root@icorem6solo:/sys/kernel/debug/audmux# cat ssi5
>     PDCR: 00000000
>     PTCR: 00000800
>     TxFS input, TxClk input
>     Port is symmetric
>     Data received from imx-ssi.0
> root@icorem6solo:/sys/kernel/debug/audmux# cat ssi6
>     PDCR: 0000c000
>     PTCR: 00000800
>     TxFS input, TxClk input
>     Port is symmetric
>     Data received from UNKNOWN
>
>
>


-- 

P.S. Le informazioni trasmesse attraverso la presente comunicazione sono di
esclusiva
spettanza dell'effettivo destinatario. Nel caso in cui le stesse
raggiungessero, per
qualunque motivo, soggetti non interessati, questi ultimi vorranno darne
immediata
notizia al mittente. In ogni caso, eventuali soggetti diversi dai legittimi
destinatari
della presente comunicazione e dei dati contenuti negli allegati, possono
essere
sanzionati ai sensi del T.U. sul trattamento dei dati personali d.lgs.
196/2003, sia ai
sensi dell'art. 616 del Codice Penale che disciplina la violazione del
segreto sulla
corrispondenza.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Imx6 i2s master driver without i2c
  2016-05-13  7:59                               ` nick83ola
@ 2016-05-13  8:21                                 ` nick83ola
  2016-05-13 19:30                                 ` Caleb Crome
  1 sibling, 0 replies; 18+ messages in thread
From: nick83ola @ 2016-05-13  8:21 UTC (permalink / raw)
  To: Caleb Crome; +Cc: alsa-devel

also you have a typo in your dts I think that the define is

#define AUDMUX_EXT_PORT_NAME port5

not

#define AUDMUX_INT_PORT_NAME port5

and -> correct the other

(i found that imx-audmux support audmux port-config...)

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Imx6 i2s master driver without i2c
  2016-05-13  7:59                               ` nick83ola
  2016-05-13  8:21                                 ` nick83ola
@ 2016-05-13 19:30                                 ` Caleb Crome
  2016-05-17 14:51                                   ` nick83ola
  1 sibling, 1 reply; 18+ messages in thread
From: Caleb Crome @ 2016-05-13 19:30 UTC (permalink / raw)
  To: nick83ola; +Cc: alsa-devel

On Fri, May 13, 2016 at 12:59 AM, nick83ola <nick83ola@gmail.com> wrote:

> Caleb thanks for your help!!!! the documentation is really orrible!!!!
>
> but now I'm getting something out of TXD!!!!
>

Wooo!


>
> only no clock and very fast (I think that I need to configure the
> oscillator/pll and iomux???)
>

Right, I wish I understood how to do that.  I don't.  It's got something to
do with some function called 'clock' I bet :-)  Or maybe 'clk'.  Or maybe
in the DTS and not a function call...


>
> In my kernel (3.14.28-1.0.0_ga+g91cf351) some of the statement in you dts
> are not supported in simple driver so I stripped down the imx-si476 driver
> and use with your dummy codec driver
>

Yeah, that's the problem with old kernels.  I try to just look towards the
future :-)

I'm glad things are working, and thanks for posting your working DTS.
Having your DTS here may help the next guy with an old kernel.

Cheers
-Caleb


>
> &audmux {
>     pinctrl-names = "default";
>     pinctrl-0 = <&pinctrl_audmux_4>;
>     status = "okay";
> };
>
> &ssi2 {
>     assigned-clocks = <&clks IMX6QDL_CLK_SSI2_SEL>;
>     assigned-clock-parents = <&clks IMX6QDL_CLK_PLL4_AUDIO_DIV>;
>     assigned-clock-rates = <0>;
>     fsl,mode = "i2s-master";
>     status = "okay";
> };
>
>
> / {
>     model = "Engicam i.CoreM6 DualLite/Solo starterkit";
>     compatible = "fsl,imx6-icore", "fsl,imx6dl";
>
>     codec_test: codec_test {
>         compatible = "linux,snd-soc-dummy";
>         status = "okay";
>     };
>
>     sound {
>         compatible = "fsl,imx-audio-itel";
>         model = "imx-itel";
>         ssi-controller = <&ssi2>;
>         audio-codec = <&codec_test>;
>         mux-int-port = <4>;
>         mux-ext-port = <2>;
>         status = "okay";
>     };
>
>     sound-hdmi {
>         status = "disabled";
>     };
> };
>
>
> &iomuxc {
>     audmux {
>         pinctrl_audmux_4: audmux-4 {
>             fsl,pins = <
>                 MX6QDL_PAD_DISP0_DAT20__AUD4_TXC  0x130b0
>                 MX6QDL_PAD_DISP0_DAT21__AUD4_TXD 0x110b0
>                 MX6QDL_PAD_DISP0_DAT22__AUD4_TXFS  0x130b0
>                 MX6QDL_PAD_DISP0_DAT23__AUD4_RXD  0x130b0
>             >;
>         };
>     };
> };
>
>
> ======================================================================================================================
> imx-itel.c
>
> ======================================================================================================================
>
>
> /*
>  * Copyright (C) 2013 Freescale Semiconductor, Inc.
>  *
>  * The code contained herein is licensed under the GNU General Public
>  * License. You may obtain a copy of the GNU General Public License
>  * Version 2 or later at the following locations:
>  *
>  * http://www.opensource.org/licenses/gpl-license.html
>  * http://www.gnu.org/copyleft/gpl.html
>  */
>
> #define DEBUG 1
>
> #include <linux/module.h>
> #include <linux/of.h>
> #include <linux/of_platform.h>
> #include <linux/device.h>
> #include <linux/clk.h>
> #include <sound/core.h>
> #include <sound/pcm.h>
> #include <sound/soc.h>
> #include <sound/initval.h>
> #include <sound/pcm_params.h>
>
> #include "imx-audmux.h"
>
> struct imx_itel_data {
>     struct snd_soc_dai_link dai;
>     struct snd_soc_card card;
> };
>
>
> static int imx_audmux_config(int slave, int master)
> {
>     unsigned int ptcr, pdcr;
>     slave = slave - 1;
>     master = master - 1;
>
>     ptcr = IMX_AUDMUX_V2_PTCR_SYN |
>         IMX_AUDMUX_V2_PTCR_TFSDIR |
>         IMX_AUDMUX_V2_PTCR_TFSEL(slave) |
>         IMX_AUDMUX_V2_PTCR_TCLKDIR |
>         IMX_AUDMUX_V2_PTCR_TCSEL(slave);
>     pdcr = IMX_AUDMUX_V2_PDCR_RXDSEL(slave);
>
>     imx_audmux_v2_configure_port(master, ptcr, pdcr);
>
>     /*
>      * According to RM, RCLKDIR and SYN should not be changed at same time.
>      * So separate to two step for configuring this port.
>      */
>     ptcr |= IMX_AUDMUX_V2_PTCR_RFSDIR |
>         IMX_AUDMUX_V2_PTCR_RFSEL(slave) |
>         IMX_AUDMUX_V2_PTCR_RCLKDIR |
>         IMX_AUDMUX_V2_PTCR_RCSEL(slave);
>     imx_audmux_v2_configure_port(master, ptcr, pdcr);
>
>     printk(KERN_ERR "--> ITEL imx-audmux-confic ext-port port=%#010x
> ptcr=%#010x pdcr=%#010x\n", master, ptcr, pdcr);
>
>     ptcr = IMX_AUDMUX_V2_PTCR_SYN;
>     pdcr = IMX_AUDMUX_V2_PDCR_RXDSEL(master);
>
>     printk(KERN_ERR "--> ITEL imx-audmux-config int-port port=%#010x
> ptcr=%#010x pdcr=%#010x\n", master, ptcr, pdcr);
>     imx_audmux_v2_configure_port(slave, ptcr, pdcr);
>
>     return 0;
> }
>
>
> static int imx_itel_hw_params(struct snd_pcm_substream *substream,
>                               struct snd_pcm_hw_params *params)
> {
>     struct snd_soc_pcm_runtime *rtd = substream->private_data;
>     struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
>     u32 channels = params_channels(params);
>     u32 rate = params_rate(params);
>     u32 bclk = rate * channels * 32;
>     int ret = 0;
>
>     printk(KERN_ERR "--> ITEL imx-itel-hw-params NAME=%s  \n VALUE=%#010x
> "
>                         "SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
> SND_SOC_DAIFMT_CBS_CFS\n",
>                         cpu_dai->name,
>                         (SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
> SND_SOC_DAIFMT_CBS_CFS));
>
>     /* set cpu DAI configuration */
>     ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S
>             | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
>     if (ret) {
>         dev_err(cpu_dai->dev, "failed to set dai fmt\n");
>         return ret;
>     }
>     printk(KERN_ERR "--> ITEL imx-itel-hw-params set tdm slots
> channels=%d", channels);
>
>     ret = snd_soc_dai_set_tdm_slot(cpu_dai,
>             channels == 1 ? 0xfffffffe : 0xfffffffc,
>             channels == 1 ? 0xfffffffe : 0xfffffffc,
>             2, 32);
>     if (ret) {
>         dev_err(cpu_dai->dev, "failed to set dai tdm slot\n");
>         return ret;
>     }
>
>     printk(KERN_ERR "--> ITEL imx-audmux-config set sysclk NAME=%s
> \n",cpu_dai->name);
>
>     ret = snd_soc_dai_set_sysclk(cpu_dai, 0, bclk, SND_SOC_CLOCK_OUT);
>     if (ret)
>         dev_err(cpu_dai->dev, "failed to set sysclk\n");
>
>     return ret;
> }
>
>
> static struct snd_soc_ops imx_itel_ops = {
>     .hw_params = imx_itel_hw_params,
> };
>
>
> static struct snd_soc_dai_link imx_itel_dai[] = {
>     {
>         .name            = "Hifi",
>         .stream_name     = "Hifi",
>         .codec_dai_name     = "snd-soc-dummy-dai",
>         //.codec_name         = "snd-soc-dummy",
>         .ops             = &imx_itel_ops,
>         // .symmetric_rates = 1,
>     },
> };
>
> static struct snd_soc_card snd_soc_card_imx_itel = {
>     .name       = "imx-audio-itel",
>     .dai_link   = imx_itel_dai,
>     .num_links    = ARRAY_SIZE(imx_itel_dai),
>     .owner      = THIS_MODULE,
> };
>
>
> static int imx_itel_probe(struct platform_device *pdev)
> {
>     struct snd_soc_card *card = &snd_soc_card_imx_itel;
>     struct device_node *ssi_np;
>     struct platform_device *ssi_pdev;
>     struct device_node *codec_np;
>     // struct imx_itel_data *data = NULL;
>     int int_port, ext_port, ret;
>
>     printk(KERN_ERR "--> ITEL imx_itel_probe");
>
>     ret = of_property_read_u32(pdev->dev.of_node, "mux-int-port",
> &int_port);
>     if (ret) {
>         dev_err(&pdev->dev, "mux-int-port missing or invalid\n");
>         return ret;
>     }
>
>
>     ret = of_property_read_u32(pdev->dev.of_node, "mux-ext-port",
> &ext_port);
>     if (ret) {
>         dev_err(&pdev->dev, "mux-ext-port missing or invalid\n");
>         return ret;
>     }
>
>     printk(KERN_ERR "--> ITEL Configuro audmux\n");
>     imx_audmux_config(int_port, ext_port);
>
>     /* find value in devicetree for ssi controller */
>     ssi_np = of_parse_phandle(pdev->dev.of_node, "ssi-controller", 0);
>     if (!ssi_np) {
>         dev_err(&pdev->dev, "ssi-controller missing or invalid\n");
>         ret = -EINVAL;
>         goto fail;
>     }
>
>     /* find SSI platform driver */
>     ssi_pdev = of_find_device_by_node(ssi_np);
>     if (!ssi_pdev) {
>         dev_err(&pdev->dev, "failed to find SSI platform device\n");
>         ret = -EPROBE_DEFER;
>         goto fail;
>     }
>
>     codec_np = of_parse_phandle(pdev->dev.of_node, "audio-codec", 0);
>     if (!codec_np) {
>         dev_err(&pdev->dev, "codec missing or invalid\n");
>         ret = -EINVAL;
>         goto fail;
>     }
>
>     // codec_dev = NULL;
>
>     card->dev = &pdev->dev;
>     card->dai_link->cpu_dai_name = dev_name(&ssi_pdev->dev);
>     card->dai_link->platform_of_node = ssi_np;
>     card->dai_link->codec_of_node = codec_np;
>
>     platform_set_drvdata(pdev, card);
>     snd_soc_card_set_drvdata(card, &snd_soc_card_imx_itel);
>
>     printk(KERN_ERR "--> ITEL imx-probe registro card\n");
>
>     ret = snd_soc_register_card(card);
>     if (ret) {
>         dev_err(&pdev->dev, "Failed to register card: %d\n", ret);
>         goto fail;
>     }
>
>     printk(KERN_ERR "--> ITEL imx-probe of ssi\n");
>     of_node_put(ssi_np);
>     printk(KERN_ERR "--> ITEL imx-probe of codec\n");
>     of_node_put(codec_np);
>
>     return 0;
>
> fail:
>     if (ssi_np)
>         of_node_put(ssi_np);
>     if (codec_np)
>         of_node_put(codec_np);
>
>     return ret;
> }
>
> static int imx_itel_remove(struct platform_device *pdev)
> {
>     struct snd_soc_card *card = &snd_soc_card_imx_itel;
>
>     snd_soc_unregister_card(card);
>
>     return 0;
> }
>
> static const struct of_device_id imx_itel_dt_ids[] = {
>     { .compatible = "fsl,imx-audio-itel", },
>     { /* sentinel */ }
> };
> MODULE_DEVICE_TABLE(of, imx_itel_dt_ids);
>
> static struct platform_driver imx_itel_driver = {
>     .driver = {
>         .name = "imx-itel",
>         .owner = THIS_MODULE,
>         .pm = &snd_soc_pm_ops,
>         .of_match_table = imx_itel_dt_ids,
>     },
>     .probe = imx_itel_probe,
>     .remove = imx_itel_remove,
> };
>
> module_platform_driver(imx_itel_driver);
>
> MODULE_AUTHOR("Nicola Lunghi");
> MODULE_DESCRIPTION("ITEL I2S Platform Driver");
> MODULE_LICENSE("GPL v2");
> MODULE_ALIAS("platform:imx-itel");
>
> 2016-05-12 9:55 GMT+02:00 nick83ola <nick83ola@gmail.com>:
>
>> I am using ssi1 because I have an example of setting master mode on sabre
>> board dts
>>
>> I have a problem with iomux/pinctrl  I think because
>>
>> root@icorem6solo:/sys/kernel/debug/pinctrl/20e0000.iomuxc# cat
>> pinmux-pins |grep audmux
>> pin 57 (MX6DL_PAD_DISP0_DAT20): 2028000.ssi (GPIO UNCLAIMED) function
>> audmux group audmux-4
>> pin 58 (MX6DL_PAD_DISP0_DAT21): 2028000.ssi (GPIO UNCLAIMED) function
>> audmux group audmux-4
>> pin 59 (MX6DL_PAD_DISP0_DAT22): 2028000.ssi (GPIO UNCLAIMED) function
>> audmux group audmux-4
>> pin 60 (MX6DL_PAD_DISP0_DAT23): 2028000.ssi (GPIO UNCLAIMED) function
>> audmux group audmux-4
>>
>> says: GPIO_UNCLAIMED? it is correct??
>>
>> /sys/kernel/debug/pinctrl/20e0000.iomuxc# cat pinconf-groups |grep -A 1
>> audmux
>> 1 (audmux-1):
>> MX6DL_PAD_SD2_DAT0: 0x17070MX6DL_PAD_SD2_DAT3: 0x17070MX6DL_PAD_SD2_DAT2:
>> 0x17070MX6DL_PAD_SD2_DAT1: 0x17070
>> 2 (audmux-2):
>> MX6DL_PAD_CSI0_DAT7: 0x1b0b0MX6DL_PAD_CSI0_DAT4:
>> 0x1b0b0MX6DL_PAD_CSI0_DAT5: 0x1b0b0MX6DL_PAD_CSI0_DAT6: 0x1b0b0
>> 3 (audmux-3):
>> MX6DL_PAD_DISP0_DAT16: 0x10MX6DL_PAD_DISP0_DAT18:
>> 0x1b0b0MX6DL_PAD_DISP0_DAT19: 0x1b0b0
>> 4 (audmux-4):
>> MX6DL_PAD_DISP0_DAT20: 0x130b0MX6DL_PAD_DISP0_DAT21:
>> 0x110b0MX6DL_PAD_DISP0_DAT22: 0x130b0MX6DL_PAD_DISP0_DAT23: 0x130b0
>>
>> 0x130b0?
>>
>> audmux# cat ssi0
>>     PDCR: 0000a000
>>     PTCR: ad400800
>>     TxFS output from SSI6, TxClk output from SSI6
>>     Port is symmetric
>>     Data received from SSI6
>> root@icorem6solo:/sys/kernel/debug/audmux# cat ssi1
>>     PDCR: 00008000
>>     PTCR: 00000800
>>     TxFS input, TxClk input
>>     Port is symmetric
>>     Data received from SSI5
>> root@icorem6solo:/sys/kernel/debug/audmux# cat ssi2
>>     PDCR: 00006000
>>     PTCR: 9cc00800
>>     TxFS output from SSI4, TxClk output from SSI4
>>     Port is symmetric
>>     Data received from SSI4
>> root@icorem6solo:/sys/kernel/debug/audmux# cat ssi3
>>     PDCR: 00004000
>>     PTCR: 00000800
>>     TxFS input, TxClk input
>>     Port is symmetric
>>     Data received from SSI3
>> root@icorem6solo:/sys/kernel/debug/audmux# cat ssi4
>>     PDCR: 00002000
>>     PTCR: 8c400800
>>     TxFS output from imx-ssi.1, TxClk output from imx-ssi.1
>>     Port is symmetric
>>     Data received from imx-ssi.1
>> root@icorem6solo:/sys/kernel/debug/audmux# cat ssi5
>>     PDCR: 00000000
>>     PTCR: 00000800
>>     TxFS input, TxClk input
>>     Port is symmetric
>>     Data received from imx-ssi.0
>> root@icorem6solo:/sys/kernel/debug/audmux# cat ssi6
>>     PDCR: 0000c000
>>     PTCR: 00000800
>>     TxFS input, TxClk input
>>     Port is symmetric
>>     Data received from UNKNOWN
>>
>>
>>
>
>
> --
>
> P.S. Le informazioni trasmesse attraverso la presente comunicazione sono
> di esclusiva
> spettanza dell'effettivo destinatario. Nel caso in cui le stesse
> raggiungessero, per
> qualunque motivo, soggetti non interessati, questi ultimi vorranno darne
> immediata
> notizia al mittente. In ogni caso, eventuali soggetti diversi dai
> legittimi destinatari
> della presente comunicazione e dei dati contenuti negli allegati, possono
> essere
> sanzionati ai sensi del T.U. sul trattamento dei dati personali d.lgs.
> 196/2003, sia ai
> sensi dell'art. 616 del Codice Penale che disciplina la violazione del
> segreto sulla
> corrispondenza.
>

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Imx6 i2s master driver without i2c
  2016-05-13 19:30                                 ` Caleb Crome
@ 2016-05-17 14:51                                   ` nick83ola
  2016-05-17 16:51                                     ` Caleb Crome
  0 siblings, 1 reply; 18+ messages in thread
From: nick83ola @ 2016-05-17 14:51 UTC (permalink / raw)
  To: Caleb Crome; +Cc: alsa-devel

[-- Attachment #1: Type: text/plain, Size: 18009 bytes --]

Ok I'm almost there

Now I have an audio driver that works in both recording / playing

The only bug that I have is this:

I have this function that set the clock based on the stream properties
i tested it with:   speaker-test -r 48000

Playback device is default
Stream parameters are 48000Hz, S16_LE, 1 channels
Using 16 octaves of pink noise
Rate set to 48000Hz (requested 48000Hz)
Buffer size range from 3840 to 17280
Period size range from 1920 to 1920
Using max buffer size 17280


but my function get everytime 44100 no matter what I put in -r parameter as
playback frequency!!!!

configuration rate=44100, format=2, channels=2, bclk=2822400
fsl-ssi-dai 202c000.ssi: set tdm slots channels=2
fsl-ssi-dai 202c000.ssi: set ssi bclk NAME=202c000.ssi

what I'm missing??

and the function

snd_soc_dai_set_pll(cpu_dai, 0, 0, 24000000, itel_audio_fmts[i].sysclk);

is correct??? I need to set pll4 frequency based on rate

/*****************************************************************************************************************************************************
static int imx_itel_hw_params(struct snd_pcm_substream *substream,
                              struct snd_pcm_hw_params *params)
{
    struct snd_soc_pcm_runtime *rtd = substream->private_data;
    struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
    snd_pcm_format_t format = params_format(params);
    u32 channels = params_channels(params);
    u32 rate     = params_rate(params);
    u32 bclk = rate * channels * 32;
    int ret = 0, i;

    dev_info(cpu_dai->dev, "set cpu DAI configuration rate=%d, format=%d,
channels=%d, bclk=%d\n", rate, format, channels, bclk);

    /* find the correct audio parameters */
    for (i = 0; i < ARRAY_SIZE(itel_audio_fmts); i++) {
        if (rate == itel_audio_fmts[i].rate)
        {
            ret = 1;
            break;
        }
    }
    if (!ret)
        return -EINVAL;

    /* codec FLL input is 14.75 MHz from MCLK */
    /**
     * snd_soc_dai_set_pll - configure DAI PLL.
     * @dai: DAI
     * @pll_id: DAI specific PLL ID
     * @source: DAI specific source for the PLL
     * @freq_in: PLL input clock frequency in Hz
     * @freq_out: requested PLL output clock frequency in Hz
     *
     * Configures and enables PLL to generate output clock based on input
clock.
     */
    // snd_soc_dai_set_pll(struct snd_soc_dai *dai, int pll_id, int source,
unsigned int freq_in, unsigned int freq_out);

    snd_soc_dai_set_pll(cpu_dai, 0, 0, 24000000, itel_audio_fmts[i].sysclk);

    /* set cpu DAI configuration */
    ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
    if (ret) {
        dev_err(cpu_dai->dev, "failed to set dai fmt\n");
        return ret;
    }

    dev_info(cpu_dai->dev, "set tdm slots channels=%d", channels);

    ret = snd_soc_dai_set_tdm_slot(cpu_dai, channels == 1 ? 0xfffffffe :
0xfffffffc, channels == 1 ? 0xfffffffe : 0xfffffffc, 2, 32);
    if (ret) {
        dev_err(cpu_dai->dev, "failed to set dai tdm slot\n");
        return ret;
    }

    dev_info(cpu_dai->dev, "set ssi bclk NAME=%s \n",cpu_dai->name);
    /* set clock */
    ret = snd_soc_dai_set_sysclk(cpu_dai, IMX_SSP_SYS_CLK, bclk,
SND_SOC_CLOCK_OUT);
    if (ret)
        dev_err(cpu_dai->dev, "failed to set sysclk\n");

    return ret;
}



2016-05-13 21:30 GMT+02:00 Caleb Crome <caleb@crome.org>:

>
>
> On Fri, May 13, 2016 at 12:59 AM, nick83ola <nick83ola@gmail.com> wrote:
>
>> Caleb thanks for your help!!!! the documentation is really orrible!!!!
>>
>> but now I'm getting something out of TXD!!!!
>>
>
> Wooo!
>
>
>>
>> only no clock and very fast (I think that I need to configure the
>> oscillator/pll and iomux???)
>>
>
> Right, I wish I understood how to do that.  I don't.  It's got something
> to do with some function called 'clock' I bet :-)  Or maybe 'clk'.  Or
> maybe in the DTS and not a function call...
>
>
>>
>> In my kernel (3.14.28-1.0.0_ga+g91cf351) some of the statement in you dts
>> are not supported in simple driver so I stripped down the imx-si476 driver
>> and use with your dummy codec driver
>>
>
> Yeah, that's the problem with old kernels.  I try to just look towards the
> future :-)
>
> I'm glad things are working, and thanks for posting your working DTS.
> Having your DTS here may help the next guy with an old kernel.
>
> Cheers
> -Caleb
>
>
>>
>> &audmux {
>>     pinctrl-names = "default";
>>     pinctrl-0 = <&pinctrl_audmux_4>;
>>     status = "okay";
>> };
>>
>> &ssi2 {
>>     assigned-clocks = <&clks IMX6QDL_CLK_SSI2_SEL>;
>>     assigned-clock-parents = <&clks IMX6QDL_CLK_PLL4_AUDIO_DIV>;
>>     assigned-clock-rates = <0>;
>>     fsl,mode = "i2s-master";
>>     status = "okay";
>> };
>>
>>
>> / {
>>     model = "Engicam i.CoreM6 DualLite/Solo starterkit";
>>     compatible = "fsl,imx6-icore", "fsl,imx6dl";
>>
>>     codec_test: codec_test {
>>         compatible = "linux,snd-soc-dummy";
>>         status = "okay";
>>     };
>>
>>     sound {
>>         compatible = "fsl,imx-audio-itel";
>>         model = "imx-itel";
>>         ssi-controller = <&ssi2>;
>>         audio-codec = <&codec_test>;
>>         mux-int-port = <4>;
>>         mux-ext-port = <2>;
>>         status = "okay";
>>     };
>>
>>     sound-hdmi {
>>         status = "disabled";
>>     };
>> };
>>
>>
>> &iomuxc {
>>     audmux {
>>         pinctrl_audmux_4: audmux-4 {
>>             fsl,pins = <
>>                 MX6QDL_PAD_DISP0_DAT20__AUD4_TXC  0x130b0
>>                 MX6QDL_PAD_DISP0_DAT21__AUD4_TXD 0x110b0
>>                 MX6QDL_PAD_DISP0_DAT22__AUD4_TXFS  0x130b0
>>                 MX6QDL_PAD_DISP0_DAT23__AUD4_RXD  0x130b0
>>             >;
>>         };
>>     };
>> };
>>
>>
>> ======================================================================================================================
>> imx-itel.c
>>
>> ======================================================================================================================
>>
>>
>> /*
>>  * Copyright (C) 2013 Freescale Semiconductor, Inc.
>>  *
>>  * The code contained herein is licensed under the GNU General Public
>>  * License. You may obtain a copy of the GNU General Public License
>>  * Version 2 or later at the following locations:
>>  *
>>  * http://www.opensource.org/licenses/gpl-license.html
>>  * http://www.gnu.org/copyleft/gpl.html
>>  */
>>
>> #define DEBUG 1
>>
>> #include <linux/module.h>
>> #include <linux/of.h>
>> #include <linux/of_platform.h>
>> #include <linux/device.h>
>> #include <linux/clk.h>
>> #include <sound/core.h>
>> #include <sound/pcm.h>
>> #include <sound/soc.h>
>> #include <sound/initval.h>
>> #include <sound/pcm_params.h>
>>
>> #include "imx-audmux.h"
>>
>> struct imx_itel_data {
>>     struct snd_soc_dai_link dai;
>>     struct snd_soc_card card;
>> };
>>
>>
>> static int imx_audmux_config(int slave, int master)
>> {
>>     unsigned int ptcr, pdcr;
>>     slave = slave - 1;
>>     master = master - 1;
>>
>>     ptcr = IMX_AUDMUX_V2_PTCR_SYN |
>>         IMX_AUDMUX_V2_PTCR_TFSDIR |
>>         IMX_AUDMUX_V2_PTCR_TFSEL(slave) |
>>         IMX_AUDMUX_V2_PTCR_TCLKDIR |
>>         IMX_AUDMUX_V2_PTCR_TCSEL(slave);
>>     pdcr = IMX_AUDMUX_V2_PDCR_RXDSEL(slave);
>>
>>     imx_audmux_v2_configure_port(master, ptcr, pdcr);
>>
>>     /*
>>      * According to RM, RCLKDIR and SYN should not be changed at same
>> time.
>>      * So separate to two step for configuring this port.
>>      */
>>     ptcr |= IMX_AUDMUX_V2_PTCR_RFSDIR |
>>         IMX_AUDMUX_V2_PTCR_RFSEL(slave) |
>>         IMX_AUDMUX_V2_PTCR_RCLKDIR |
>>         IMX_AUDMUX_V2_PTCR_RCSEL(slave);
>>     imx_audmux_v2_configure_port(master, ptcr, pdcr);
>>
>>     printk(KERN_ERR "--> ITEL imx-audmux-confic ext-port port=%#010x
>> ptcr=%#010x pdcr=%#010x\n", master, ptcr, pdcr);
>>
>>     ptcr = IMX_AUDMUX_V2_PTCR_SYN;
>>     pdcr = IMX_AUDMUX_V2_PDCR_RXDSEL(master);
>>
>>     printk(KERN_ERR "--> ITEL imx-audmux-config int-port port=%#010x
>> ptcr=%#010x pdcr=%#010x\n", master, ptcr, pdcr);
>>     imx_audmux_v2_configure_port(slave, ptcr, pdcr);
>>
>>     return 0;
>> }
>>
>>
>> static int imx_itel_hw_params(struct snd_pcm_substream *substream,
>>                               struct snd_pcm_hw_params *params)
>> {
>>     struct snd_soc_pcm_runtime *rtd = substream->private_data;
>>     struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
>>     u32 channels = params_channels(params);
>>     u32 rate = params_rate(params);
>>     u32 bclk = rate * channels * 32;
>>     int ret = 0;
>>
>>     printk(KERN_ERR "--> ITEL imx-itel-hw-params NAME=%s  \n
>> VALUE=%#010x  "
>>                         "SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
>> SND_SOC_DAIFMT_CBS_CFS\n",
>>                         cpu_dai->name,
>>                         (SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
>> SND_SOC_DAIFMT_CBS_CFS));
>>
>>     /* set cpu DAI configuration */
>>     ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S
>>             | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
>>     if (ret) {
>>         dev_err(cpu_dai->dev, "failed to set dai fmt\n");
>>         return ret;
>>     }
>>     printk(KERN_ERR "--> ITEL imx-itel-hw-params set tdm slots
>> channels=%d", channels);
>>
>>     ret = snd_soc_dai_set_tdm_slot(cpu_dai,
>>             channels == 1 ? 0xfffffffe : 0xfffffffc,
>>             channels == 1 ? 0xfffffffe : 0xfffffffc,
>>             2, 32);
>>     if (ret) {
>>         dev_err(cpu_dai->dev, "failed to set dai tdm slot\n");
>>         return ret;
>>     }
>>
>>     printk(KERN_ERR "--> ITEL imx-audmux-config set sysclk NAME=%s
>> \n",cpu_dai->name);
>>
>>     ret = snd_soc_dai_set_sysclk(cpu_dai, 0, bclk, SND_SOC_CLOCK_OUT);
>>     if (ret)
>>         dev_err(cpu_dai->dev, "failed to set sysclk\n");
>>
>>     return ret;
>> }
>>
>>
>> static struct snd_soc_ops imx_itel_ops = {
>>     .hw_params = imx_itel_hw_params,
>> };
>>
>>
>> static struct snd_soc_dai_link imx_itel_dai[] = {
>>     {
>>         .name            = "Hifi",
>>         .stream_name     = "Hifi",
>>         .codec_dai_name     = "snd-soc-dummy-dai",
>>         //.codec_name         = "snd-soc-dummy",
>>         .ops             = &imx_itel_ops,
>>         // .symmetric_rates = 1,
>>     },
>> };
>>
>> static struct snd_soc_card snd_soc_card_imx_itel = {
>>     .name       = "imx-audio-itel",
>>     .dai_link   = imx_itel_dai,
>>     .num_links    = ARRAY_SIZE(imx_itel_dai),
>>     .owner      = THIS_MODULE,
>> };
>>
>>
>> static int imx_itel_probe(struct platform_device *pdev)
>> {
>>     struct snd_soc_card *card = &snd_soc_card_imx_itel;
>>     struct device_node *ssi_np;
>>     struct platform_device *ssi_pdev;
>>     struct device_node *codec_np;
>>     // struct imx_itel_data *data = NULL;
>>     int int_port, ext_port, ret;
>>
>>     printk(KERN_ERR "--> ITEL imx_itel_probe");
>>
>>     ret = of_property_read_u32(pdev->dev.of_node, "mux-int-port",
>> &int_port);
>>     if (ret) {
>>         dev_err(&pdev->dev, "mux-int-port missing or invalid\n");
>>         return ret;
>>     }
>>
>>
>>     ret = of_property_read_u32(pdev->dev.of_node, "mux-ext-port",
>> &ext_port);
>>     if (ret) {
>>         dev_err(&pdev->dev, "mux-ext-port missing or invalid\n");
>>         return ret;
>>     }
>>
>>     printk(KERN_ERR "--> ITEL Configuro audmux\n");
>>     imx_audmux_config(int_port, ext_port);
>>
>>     /* find value in devicetree for ssi controller */
>>     ssi_np = of_parse_phandle(pdev->dev.of_node, "ssi-controller", 0);
>>     if (!ssi_np) {
>>         dev_err(&pdev->dev, "ssi-controller missing or invalid\n");
>>         ret = -EINVAL;
>>         goto fail;
>>     }
>>
>>     /* find SSI platform driver */
>>     ssi_pdev = of_find_device_by_node(ssi_np);
>>     if (!ssi_pdev) {
>>         dev_err(&pdev->dev, "failed to find SSI platform device\n");
>>         ret = -EPROBE_DEFER;
>>         goto fail;
>>     }
>>
>>     codec_np = of_parse_phandle(pdev->dev.of_node, "audio-codec", 0);
>>     if (!codec_np) {
>>         dev_err(&pdev->dev, "codec missing or invalid\n");
>>         ret = -EINVAL;
>>         goto fail;
>>     }
>>
>>     // codec_dev = NULL;
>>
>>     card->dev = &pdev->dev;
>>     card->dai_link->cpu_dai_name = dev_name(&ssi_pdev->dev);
>>     card->dai_link->platform_of_node = ssi_np;
>>     card->dai_link->codec_of_node = codec_np;
>>
>>     platform_set_drvdata(pdev, card);
>>     snd_soc_card_set_drvdata(card, &snd_soc_card_imx_itel);
>>
>>     printk(KERN_ERR "--> ITEL imx-probe registro card\n");
>>
>>     ret = snd_soc_register_card(card);
>>     if (ret) {
>>         dev_err(&pdev->dev, "Failed to register card: %d\n", ret);
>>         goto fail;
>>     }
>>
>>     printk(KERN_ERR "--> ITEL imx-probe of ssi\n");
>>     of_node_put(ssi_np);
>>     printk(KERN_ERR "--> ITEL imx-probe of codec\n");
>>     of_node_put(codec_np);
>>
>>     return 0;
>>
>> fail:
>>     if (ssi_np)
>>         of_node_put(ssi_np);
>>     if (codec_np)
>>         of_node_put(codec_np);
>>
>>     return ret;
>> }
>>
>> static int imx_itel_remove(struct platform_device *pdev)
>> {
>>     struct snd_soc_card *card = &snd_soc_card_imx_itel;
>>
>>     snd_soc_unregister_card(card);
>>
>>     return 0;
>> }
>>
>> static const struct of_device_id imx_itel_dt_ids[] = {
>>     { .compatible = "fsl,imx-audio-itel", },
>>     { /* sentinel */ }
>> };
>> MODULE_DEVICE_TABLE(of, imx_itel_dt_ids);
>>
>> static struct platform_driver imx_itel_driver = {
>>     .driver = {
>>         .name = "imx-itel",
>>         .owner = THIS_MODULE,
>>         .pm = &snd_soc_pm_ops,
>>         .of_match_table = imx_itel_dt_ids,
>>     },
>>     .probe = imx_itel_probe,
>>     .remove = imx_itel_remove,
>> };
>>
>> module_platform_driver(imx_itel_driver);
>>
>> MODULE_AUTHOR("Nicola Lunghi");
>> MODULE_DESCRIPTION("ITEL I2S Platform Driver");
>> MODULE_LICENSE("GPL v2");
>> MODULE_ALIAS("platform:imx-itel");
>>
>> 2016-05-12 9:55 GMT+02:00 nick83ola <nick83ola@gmail.com>:
>>
>>> I am using ssi1 because I have an example of setting master mode on
>>> sabre board dts
>>>
>>> I have a problem with iomux/pinctrl  I think because
>>>
>>> root@icorem6solo:/sys/kernel/debug/pinctrl/20e0000.iomuxc# cat
>>> pinmux-pins |grep audmux
>>> pin 57 (MX6DL_PAD_DISP0_DAT20): 2028000.ssi (GPIO UNCLAIMED) function
>>> audmux group audmux-4
>>> pin 58 (MX6DL_PAD_DISP0_DAT21): 2028000.ssi (GPIO UNCLAIMED) function
>>> audmux group audmux-4
>>> pin 59 (MX6DL_PAD_DISP0_DAT22): 2028000.ssi (GPIO UNCLAIMED) function
>>> audmux group audmux-4
>>> pin 60 (MX6DL_PAD_DISP0_DAT23): 2028000.ssi (GPIO UNCLAIMED) function
>>> audmux group audmux-4
>>>
>>> says: GPIO_UNCLAIMED? it is correct??
>>>
>>> /sys/kernel/debug/pinctrl/20e0000.iomuxc# cat pinconf-groups |grep -A 1
>>> audmux
>>> 1 (audmux-1):
>>> MX6DL_PAD_SD2_DAT0: 0x17070MX6DL_PAD_SD2_DAT3:
>>> 0x17070MX6DL_PAD_SD2_DAT2: 0x17070MX6DL_PAD_SD2_DAT1: 0x17070
>>> 2 (audmux-2):
>>> MX6DL_PAD_CSI0_DAT7: 0x1b0b0MX6DL_PAD_CSI0_DAT4:
>>> 0x1b0b0MX6DL_PAD_CSI0_DAT5: 0x1b0b0MX6DL_PAD_CSI0_DAT6: 0x1b0b0
>>> 3 (audmux-3):
>>> MX6DL_PAD_DISP0_DAT16: 0x10MX6DL_PAD_DISP0_DAT18:
>>> 0x1b0b0MX6DL_PAD_DISP0_DAT19: 0x1b0b0
>>> 4 (audmux-4):
>>> MX6DL_PAD_DISP0_DAT20: 0x130b0MX6DL_PAD_DISP0_DAT21:
>>> 0x110b0MX6DL_PAD_DISP0_DAT22: 0x130b0MX6DL_PAD_DISP0_DAT23: 0x130b0
>>>
>>> 0x130b0?
>>>
>>> audmux# cat ssi0
>>>     PDCR: 0000a000
>>>     PTCR: ad400800
>>>     TxFS output from SSI6, TxClk output from SSI6
>>>     Port is symmetric
>>>     Data received from SSI6
>>> root@icorem6solo:/sys/kernel/debug/audmux# cat ssi1
>>>     PDCR: 00008000
>>>     PTCR: 00000800
>>>     TxFS input, TxClk input
>>>     Port is symmetric
>>>     Data received from SSI5
>>> root@icorem6solo:/sys/kernel/debug/audmux# cat ssi2
>>>     PDCR: 00006000
>>>     PTCR: 9cc00800
>>>     TxFS output from SSI4, TxClk output from SSI4
>>>     Port is symmetric
>>>     Data received from SSI4
>>> root@icorem6solo:/sys/kernel/debug/audmux# cat ssi3
>>>     PDCR: 00004000
>>>     PTCR: 00000800
>>>     TxFS input, TxClk input
>>>     Port is symmetric
>>>     Data received from SSI3
>>> root@icorem6solo:/sys/kernel/debug/audmux# cat ssi4
>>>     PDCR: 00002000
>>>     PTCR: 8c400800
>>>     TxFS output from imx-ssi.1, TxClk output from imx-ssi.1
>>>     Port is symmetric
>>>     Data received from imx-ssi.1
>>> root@icorem6solo:/sys/kernel/debug/audmux# cat ssi5
>>>     PDCR: 00000000
>>>     PTCR: 00000800
>>>     TxFS input, TxClk input
>>>     Port is symmetric
>>>     Data received from imx-ssi.0
>>> root@icorem6solo:/sys/kernel/debug/audmux# cat ssi6
>>>     PDCR: 0000c000
>>>     PTCR: 00000800
>>>     TxFS input, TxClk input
>>>     Port is symmetric
>>>     Data received from UNKNOWN
>>>
>>>
>>>
>>
>>
>> --
>>
>> P.S. Le informazioni trasmesse attraverso la presente comunicazione sono
>> di esclusiva
>> spettanza dell'effettivo destinatario. Nel caso in cui le stesse
>> raggiungessero, per
>> qualunque motivo, soggetti non interessati, questi ultimi vorranno darne
>> immediata
>> notizia al mittente. In ogni caso, eventuali soggetti diversi dai
>> legittimi destinatari
>> della presente comunicazione e dei dati contenuti negli allegati, possono
>> essere
>> sanzionati ai sensi del T.U. sul trattamento dei dati personali d.lgs.
>> 196/2003, sia ai
>> sensi dell'art. 616 del Codice Penale che disciplina la violazione del
>> segreto sulla
>> corrispondenza.
>>
>
>


-- 

P.S. Le informazioni trasmesse attraverso la presente comunicazione sono di
esclusiva
spettanza dell'effettivo destinatario. Nel caso in cui le stesse
raggiungessero, per
qualunque motivo, soggetti non interessati, questi ultimi vorranno darne
immediata
notizia al mittente. In ogni caso, eventuali soggetti diversi dai legittimi
destinatari
della presente comunicazione e dei dati contenuti negli allegati, possono
essere
sanzionati ai sensi del T.U. sul trattamento dei dati personali d.lgs.
196/2003, sia ai
sensi dell'art. 616 del Codice Penale che disciplina la violazione del
segreto sulla
corrispondenza.

[-- Attachment #2: imx6dl-icore.dts --]
[-- Type: audio/vnd.dts, Size: 5660 bytes --]

[-- Attachment #3: imx-itel.c --]
[-- Type: text/x-csrc, Size: 7167 bytes --]

/*
 * Copyright (C) 2013 Freescale Semiconductor, Inc.
 *
 * The code contained herein is licensed under the GNU General Public
 * License. You may obtain a copy of the GNU General Public License
 * Version 2 or later at the following locations:
 *
 * http://www.opensource.org/licenses/gpl-license.html
 * http://www.gnu.org/copyleft/gpl.html
 */
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_platform.h>
#include <linux/device.h>
#include <linux/clk.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/soc.h>
#include <sound/initval.h>
#include <sound/pcm_params.h>

#include "imx-ssi.h"

struct imx_itel_data {
	struct snd_soc_dai_link dai;
	struct snd_soc_card card;
};


struct _itel_audio_fmts {
	unsigned int rate;
	unsigned int sysclk;
};

/* in order of power consumption per rate (lowest first) */
static const struct _itel_audio_fmts itel_audio_fmts[] = {
/*channels format               rate	    sysclk div2 psr pm lr_rate; */
    /* 16 Bit multiple of 8k */
	{8000,      12288000},
	{16000,     12288000},
	{32000,     12288000},
	{48000,     12288000},
	{96000,     24576000},
	{192000,    49152000},

    /* 16 bit 44100 multiples */
	{11025,     11289600},
	{22050,     11289600},
	{44100,     11289600},
	{88200,     22579200},
};


static int imx_itel_hw_params(struct snd_pcm_substream *substream,
                              struct snd_pcm_hw_params *params)
{
	struct snd_soc_pcm_runtime *rtd = substream->private_data;
	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
	snd_pcm_format_t format = params_format(params);
	u32 channels = params_channels(params);
	u32 rate     = params_rate(params);
	u32 bclk = rate * channels * 32;
	int ret = 0, i;

    dev_info(cpu_dai->dev, "set cpu DAI configuration rate=%d, format=%d, channels=%d, bclk=%d\n", rate, format, channels, bclk);

	/* find the correct audio parameters */
	for (i = 0; i < ARRAY_SIZE(itel_audio_fmts); i++) {
		if (rate == itel_audio_fmts[i].rate)
		{
		    ret = 1;
		    break;
		}
	}
	if (!ret)
		return -EINVAL;

	/* codec FLL input is 14.75 MHz from MCLK */
    /**
     * snd_soc_dai_set_pll - configure DAI PLL.
     * @dai: DAI
     * @pll_id: DAI specific PLL ID
     * @source: DAI specific source for the PLL
     * @freq_in: PLL input clock frequency in Hz
     * @freq_out: requested PLL output clock frequency in Hz
     *
     * Configures and enables PLL to generate output clock based on input clock.
     */
    // snd_soc_dai_set_pll(struct snd_soc_dai *dai, int pll_id, int source, unsigned int freq_in, unsigned int freq_out);

	snd_soc_dai_set_pll(cpu_dai, 0, 0, 24000000, itel_audio_fmts[i].sysclk);

	/* set cpu DAI configuration */
	ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
	if (ret) {
		dev_err(cpu_dai->dev, "failed to set dai fmt\n");
		return ret;
	}

    dev_info(cpu_dai->dev, "set tdm slots channels=%d", channels);

	ret = snd_soc_dai_set_tdm_slot(cpu_dai, channels == 1 ? 0xfffffffe : 0xfffffffc, channels == 1 ? 0xfffffffe : 0xfffffffc, 2, 32);
	if (ret) {
		dev_err(cpu_dai->dev, "failed to set dai tdm slot\n");
		return ret;
	}

    dev_info(cpu_dai->dev, "set ssi bclk NAME=%s \n",cpu_dai->name);
    /* set clock */
	ret = snd_soc_dai_set_sysclk(cpu_dai, IMX_SSP_SYS_CLK, bclk, SND_SOC_CLOCK_OUT);
	if (ret)
		dev_err(cpu_dai->dev, "failed to set sysclk\n");

	return ret;
}


static struct snd_soc_ops imx_itel_ops = {
	.hw_params = imx_itel_hw_params,
};


static const struct snd_soc_dapm_widget imx_itel_dapm_widgets[] = {
//	SND_SOC_DAPM_LINE("Line Out Jack", NULL),
//	SND_SOC_DAPM_LINE("Line In Jack", NULL),
};

static struct snd_soc_dai_link imx_itel_dai[] = {
	{
		.name            = "Hifi",
		.stream_name	 = "Hifi",
		.codec_dai_name	 = "snd-soc-itel-dai",
		//.codec_name	     = "snd-soc-itel",
		.ops		     = &imx_itel_ops,
		.symmetric_rates = 1,
	},
};

static struct snd_soc_card snd_soc_card_imx_itel = {
	.name               = "imx-audio-itel",
	.dai_link           = imx_itel_dai,
	.num_links	        = ARRAY_SIZE(imx_itel_dai),
	.dapm_widgets       = imx_itel_dapm_widgets,
	.num_dapm_widgets   = ARRAY_SIZE(imx_itel_dapm_widgets),
    .owner              = THIS_MODULE,
};


static int imx_itel_probe(struct platform_device *pdev)
{
	struct snd_soc_card *card = &snd_soc_card_imx_itel;
	struct device_node *ssi_np;
	struct platform_device *ssi_pdev;
	struct device_node *codec_np;
	struct platform_device *codec_pdev;
	// struct imx_itel_data *data = NULL;
	int int_port, ext_port, ret;

    dev_info(&pdev->dev,"enter imx_itel_probe");

	ret = of_property_read_u32(pdev->dev.of_node, "mux-int-port", &int_port);
	if (ret) {
		dev_err(&pdev->dev, "mux-int-port missing or invalid\n");
		return ret;
	}
   

	ret = of_property_read_u32(pdev->dev.of_node, "mux-ext-port", &ext_port);
	if (ret) {
		dev_err(&pdev->dev, "mux-ext-port missing or invalid\n");
		return ret;
	}

    /* find value in devicetree for ssi controller */
	ssi_np = of_parse_phandle(pdev->dev.of_node, "ssi-controller", 0);
	if (!ssi_np) {
		dev_err(&pdev->dev, "ssi-controller missing or invalid\n");
		ret = -EINVAL;
		goto fail;
	}

    /* find SSI platform driver */
	ssi_pdev = of_find_device_by_node(ssi_np);
	if (!ssi_pdev) {
		dev_err(&pdev->dev, "failed to find SSI platform device\n");
		ret = -EPROBE_DEFER;
		goto fail;
	}

	codec_np = of_parse_phandle(pdev->dev.of_node, "audio-codec", 0);
	if (!codec_np) {
		dev_err(&pdev->dev, "codec missing or invalid\n");
		ret = -EINVAL;
		goto fail;
	}

    /* find SSI platform driver */
	codec_pdev = of_find_device_by_node(codec_np);
	if (!codec_pdev) {
		dev_err(&pdev->dev, "failed to find codec platform device\n");
		ret = -EPROBE_DEFER;
		goto fail;
	}

	card->dev = &pdev->dev;
	card->dai_link->cpu_dai_name = dev_name(&ssi_pdev->dev);
	card->dai_link->platform_of_node = ssi_np;
	card->dai_link->codec_of_node = codec_np;
	card->dai_link->dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS;


	platform_set_drvdata(pdev, card);
	snd_soc_card_set_drvdata(card, &snd_soc_card_imx_itel);

    dev_info(&pdev->dev,"registro la scheda\n");

	ret = snd_soc_register_card(card);
	if (ret) {
		dev_err(&pdev->dev, "Failed to register card: %d\n", ret);
		goto fail;
    }

	of_node_put(ssi_np);
	of_node_put(codec_np);

	return 0;
	
fail:
	if (ssi_np)
		of_node_put(ssi_np);
	if (codec_np)
		of_node_put(codec_np);

	return ret;
}

static int imx_itel_remove(struct platform_device *pdev)
{
	struct snd_soc_card *card = &snd_soc_card_imx_itel;

	snd_soc_unregister_card(card);

	return 0;
}

static const struct of_device_id imx_itel_dt_ids[] = {
	{ .compatible = "fsl,imx-audio-itel", },
	{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, imx_itel_dt_ids);

static struct platform_driver imx_itel_driver = {
	.driver = {
		.name = "imx-itel",
		.owner = THIS_MODULE,
		.pm = &snd_soc_pm_ops,
		.of_match_table = imx_itel_dt_ids,
	},
	.probe = imx_itel_probe,
	.remove = imx_itel_remove,
};

module_platform_driver(imx_itel_driver);

MODULE_AUTHOR("Nicola Lunghi");
MODULE_DESCRIPTION("ITEL I2S Platform Driver");
MODULE_LICENSE("GPL v2");
MODULE_ALIAS("platform:imx-itel");

[-- Attachment #4: itel.c --]
[-- Type: text/x-csrc, Size: 3190 bytes --]

/*
 * itel.c  --  ALSA SoC Audio Layer utility functions
 *
 * Copyright 2009 Wolfson Microelectronics PLC.
 *
 * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
 *         Liam Girdwood <lrg@slimlogic.co.uk>
 *         
 *
 *  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.
 */

#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/slab.h>
#include <sound/soc.h>
#include <sound/pcm.h>
#include <sound/initval.h>
#include <linux/of.h>

static struct snd_soc_platform_driver itel_platform = {
	//.ops = &dummy_dma_ops,
};

#define ITEL_RX_RATES	SNDRV_PCM_RATE_8000_192000
#define ITEL_RX_FORMATS	(   SNDRV_PCM_FMTBIT_S16_LE |   \
			                SNDRV_PCM_FMTBIT_S20_3LE|   \
			                SNDRV_PCM_FMTBIT_S24_LE |   \
			                SNDRV_PCM_FMTBIT_S32_LE )

#define ITEL_TX_RATES	SNDRV_PCM_RATE_8000_192000
#define ITEL_TX_FORMATS	(   SNDRV_PCM_FMTBIT_S16_LE |   \
			                SNDRV_PCM_FMTBIT_S20_3LE|   \
			                SNDRV_PCM_FMTBIT_S24_LE |   \
			                SNDRV_PCM_FMTBIT_S32_LE)

static const struct snd_soc_dapm_widget itel_widgets[] = {
	SND_SOC_DAPM_INPUT("i2s-in"),
	SND_SOC_DAPM_OUTPUT("i2s-out"),
};

static const struct snd_soc_dapm_route itel_routes[] = {
	{ "Capture", NULL, "i2s-in" },
	{ "i2s-out", NULL, "Playback" },
};

static struct snd_soc_codec_driver itel_codec = {
	.dapm_widgets = itel_widgets,
	.num_dapm_widgets = ARRAY_SIZE(itel_widgets),
	.dapm_routes = itel_routes,
	.num_dapm_routes = ARRAY_SIZE(itel_routes),
};

static struct snd_soc_dai_driver itel_dai = {
	.name = "snd-soc-itel-dai",
	.playback = {
		.stream_name	= "Playback",
		.channels_min	= 1,
		.channels_max	= 2,
		.rates		= ITEL_TX_RATES,
		.formats	= ITEL_TX_FORMATS,
	},
	.capture = {
		.stream_name	= "Capture",
		.channels_min	= 1,
		.channels_max	= 2,
		.rates = ITEL_RX_RATES,
		.formats = ITEL_RX_FORMATS,
	 },
};

static int snd_soc_itel_probe(struct platform_device *pdev)
{
	int ret;

	return snd_soc_register_codec(&pdev->dev, &itel_codec, &itel_dai, 1);
	if (ret < 0)
		return ret;

	ret = snd_soc_register_platform(&pdev->dev, &itel_platform);
	if (ret < 0) {
		snd_soc_unregister_codec(&pdev->dev);
		return ret;
	}

	return ret;
}

static int snd_soc_itel_remove(struct platform_device *pdev)
{
	snd_soc_unregister_platform(&pdev->dev);
	snd_soc_unregister_codec(&pdev->dev);
	return 0;
}

#ifdef CONFIG_OF
static const struct of_device_id soc_itel_ids[] = {
    { .compatible = "fsl,snd-soc-itel", },
    { }
};
MODULE_DEVICE_TABLE(of, soc_itel_ids);
#endif

static struct platform_driver soc_itel_driver = {
	.probe = snd_soc_itel_probe,
	.remove = snd_soc_itel_remove,
	.driver = {
		.name = "snd-soc-itel",
		.owner = THIS_MODULE,
        .of_match_table = of_match_ptr(soc_itel_ids),
	},
};

module_platform_driver(soc_itel_driver);

MODULE_AUTHOR("Nicola Lunghi <nicola.lunghi@itel.it>");
MODULE_DESCRIPTION("ITEL I2S Codec Driver");
MODULE_LICENSE("GPL");
MODULE_ALIAS("platform:snd-soc-itel");

[-- Attachment #5: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Imx6 i2s master driver without i2c
  2016-05-17 14:51                                   ` nick83ola
@ 2016-05-17 16:51                                     ` Caleb Crome
  0 siblings, 0 replies; 18+ messages in thread
From: Caleb Crome @ 2016-05-17 16:51 UTC (permalink / raw)
  To: nick83ola; +Cc: alsa-devel

On Tue, May 17, 2016 at 7:51 AM, nick83ola <nick83ola@gmail.com> wrote:
> Ok I'm almost there

> Now I have an audio driver that works in both recording / playing
>
> The only bug that I have is this:
>
> I have this function that set the clock based on the stream properties
> i tested it with:   speaker-test -r 48000
>
> Playback device is default
> Stream parameters are 48000Hz, S16_LE, 1 channels
> Using 16 octaves of pink noise
> Rate set to 48000Hz (requested 48000Hz)
> Buffer size range from 3840 to 17280
> Period size range from 1920 to 1920
> Using max buffer size 17280
>
>
> but my function get everytime 44100 no matter what I put in -r parameter as
> playback frequency!!!!
>
> configuration rate=44100, format=2, channels=2, bclk=2822400
> fsl-ssi-dai 202c000.ssi: set tdm slots channels=2
> fsl-ssi-dai 202c000.ssi: set ssi bclk NAME=202c000.ssi
>
> what I'm missing??
>
> and the function
>
> snd_soc_dai_set_pll(cpu_dai, 0, 0, 24000000, itel_audio_fmts[i].sysclk);

>
> is correct??? I need to set pll4 frequency based on rate

I'm not terribly sure how this stuff is supposed to work, but it looks
like the clock frequency should be set in

 fsl_ssi_set_bclk
(http://lxr.free-electrons.com/source/sound/soc/fsl/fsl_ssi.c#L650)

It looks like the it can (depending on settings) call clk_set_rate.  I
really should read the docs on the clock system.  It's all a mystery
to me.  But, I suspect that'll eventually call a FSL specific clock
setter, which should automatically get to the clocks you need and set
the values you need.  I think there's a big table that describes how
all the clocks are interrelated.

I'm sure somebody else knows how this works :-)

Let me know what you discover.

-Caleb


>
> /*****************************************************************************************************************************************************
> static int imx_itel_hw_params(struct snd_pcm_substream *substream,
>                               struct snd_pcm_hw_params *params)
> {
>     struct snd_soc_pcm_runtime *rtd = substream->private_data;
>     struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
>     snd_pcm_format_t format = params_format(params);
>     u32 channels = params_channels(params);
>     u32 rate     = params_rate(params);
>     u32 bclk = rate * channels * 32;
>     int ret = 0, i;
>
>     dev_info(cpu_dai->dev, "set cpu DAI configuration rate=%d, format=%d,
> channels=%d, bclk=%d\n", rate, format, channels, bclk);
>
>     /* find the correct audio parameters */
>     for (i = 0; i < ARRAY_SIZE(itel_audio_fmts); i++) {
>         if (rate == itel_audio_fmts[i].rate)
>         {
>             ret = 1;
>             break;
>         }
>     }
>     if (!ret)
>         return -EINVAL;
>
>     /* codec FLL input is 14.75 MHz from MCLK */
>     /**
>      * snd_soc_dai_set_pll - configure DAI PLL.
>      * @dai: DAI
>      * @pll_id: DAI specific PLL ID
>      * @source: DAI specific source for the PLL
>      * @freq_in: PLL input clock frequency in Hz
>      * @freq_out: requested PLL output clock frequency in Hz
>      *
>      * Configures and enables PLL to generate output clock based on input
> clock.
>      */
>     // snd_soc_dai_set_pll(struct snd_soc_dai *dai, int pll_id, int source,
> unsigned int freq_in, unsigned int freq_out);
>
>     snd_soc_dai_set_pll(cpu_dai, 0, 0, 24000000, itel_audio_fmts[i].sysclk);
>
>     /* set cpu DAI configuration */
>     ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
> SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
>     if (ret) {
>         dev_err(cpu_dai->dev, "failed to set dai fmt\n");
>         return ret;
>     }
>
>     dev_info(cpu_dai->dev, "set tdm slots channels=%d", channels);
>
>     ret = snd_soc_dai_set_tdm_slot(cpu_dai, channels == 1 ? 0xfffffffe :
> 0xfffffffc, channels == 1 ? 0xfffffffe : 0xfffffffc, 2, 32);
>     if (ret) {
>         dev_err(cpu_dai->dev, "failed to set dai tdm slot\n");
>         return ret;
>     }
>
>     dev_info(cpu_dai->dev, "set ssi bclk NAME=%s \n",cpu_dai->name);
>     /* set clock */
>     ret = snd_soc_dai_set_sysclk(cpu_dai, IMX_SSP_SYS_CLK, bclk,
> SND_SOC_CLOCK_OUT);
>     if (ret)
>         dev_err(cpu_dai->dev, "failed to set sysclk\n");
>
>     return ret;
> }
>
>
>
> 2016-05-13 21:30 GMT+02:00 Caleb Crome <caleb@crome.org>:
>>
>>
>>
>> On Fri, May 13, 2016 at 12:59 AM, nick83ola <nick83ola@gmail.com> wrote:
>>>
>>> Caleb thanks for your help!!!! the documentation is really orrible!!!!
>>>
>>> but now I'm getting something out of TXD!!!!
>>
>>
>> Wooo!
>>
>>>
>>>
>>> only no clock and very fast (I think that I need to configure the
>>> oscillator/pll and iomux???)
>>
>>
>> Right, I wish I understood how to do that.  I don't.  It's got something
>> to do with some function called 'clock' I bet :-)  Or maybe 'clk'.  Or maybe
>> in the DTS and not a function call...
>>
>>>
>>>
>>> In my kernel (3.14.28-1.0.0_ga+g91cf351) some of the statement in you dts
>>> are not supported in simple driver so I stripped down the imx-si476 driver
>>> and use with your dummy codec driver
>>
>>
>> Yeah, that's the problem with old kernels.  I try to just look towards the
>> future :-)
>>
>> I'm glad things are working, and thanks for posting your working DTS.
>> Having your DTS here may help the next guy with an old kernel.
>>
>> Cheers
>> -Caleb
>>
>>>
>>>
>>> &audmux {
>>>     pinctrl-names = "default";
>>>     pinctrl-0 = <&pinctrl_audmux_4>;
>>>     status = "okay";
>>> };
>>>
>>> &ssi2 {
>>>     assigned-clocks = <&clks IMX6QDL_CLK_SSI2_SEL>;
>>>     assigned-clock-parents = <&clks IMX6QDL_CLK_PLL4_AUDIO_DIV>;
>>>     assigned-clock-rates = <0>;
>>>     fsl,mode = "i2s-master";
>>>     status = "okay";
>>> };
>>>
>>>
>>> / {
>>>     model = "Engicam i.CoreM6 DualLite/Solo starterkit";
>>>     compatible = "fsl,imx6-icore", "fsl,imx6dl";
>>>
>>>     codec_test: codec_test {
>>>         compatible = "linux,snd-soc-dummy";
>>>         status = "okay";
>>>     };
>>>
>>>     sound {
>>>         compatible = "fsl,imx-audio-itel";
>>>         model = "imx-itel";
>>>         ssi-controller = <&ssi2>;
>>>         audio-codec = <&codec_test>;
>>>         mux-int-port = <4>;
>>>         mux-ext-port = <2>;
>>>         status = "okay";
>>>     };
>>>
>>>     sound-hdmi {
>>>         status = "disabled";
>>>     };
>>> };
>>>
>>>
>>> &iomuxc {
>>>     audmux {
>>>         pinctrl_audmux_4: audmux-4 {
>>>             fsl,pins = <
>>>                 MX6QDL_PAD_DISP0_DAT20__AUD4_TXC  0x130b0
>>>                 MX6QDL_PAD_DISP0_DAT21__AUD4_TXD 0x110b0
>>>                 MX6QDL_PAD_DISP0_DAT22__AUD4_TXFS  0x130b0
>>>                 MX6QDL_PAD_DISP0_DAT23__AUD4_RXD  0x130b0
>>>             >;
>>>         };
>>>     };
>>> };
>>>
>>>
>>> ======================================================================================================================
>>> imx-itel.c
>>>
>>> ======================================================================================================================
>>>
>>>
>>> /*
>>>  * Copyright (C) 2013 Freescale Semiconductor, Inc.
>>>  *
>>>  * The code contained herein is licensed under the GNU General Public
>>>  * License. You may obtain a copy of the GNU General Public License
>>>  * Version 2 or later at the following locations:
>>>  *
>>>  * http://www.opensource.org/licenses/gpl-license.html
>>>  * http://www.gnu.org/copyleft/gpl.html
>>>  */
>>>
>>> #define DEBUG 1
>>>
>>> #include <linux/module.h>
>>> #include <linux/of.h>
>>> #include <linux/of_platform.h>
>>> #include <linux/device.h>
>>> #include <linux/clk.h>
>>> #include <sound/core.h>
>>> #include <sound/pcm.h>
>>> #include <sound/soc.h>
>>> #include <sound/initval.h>
>>> #include <sound/pcm_params.h>
>>>
>>> #include "imx-audmux.h"
>>>
>>> struct imx_itel_data {
>>>     struct snd_soc_dai_link dai;
>>>     struct snd_soc_card card;
>>> };
>>>
>>>
>>> static int imx_audmux_config(int slave, int master)
>>> {
>>>     unsigned int ptcr, pdcr;
>>>     slave = slave - 1;
>>>     master = master - 1;
>>>
>>>     ptcr = IMX_AUDMUX_V2_PTCR_SYN |
>>>         IMX_AUDMUX_V2_PTCR_TFSDIR |
>>>         IMX_AUDMUX_V2_PTCR_TFSEL(slave) |
>>>         IMX_AUDMUX_V2_PTCR_TCLKDIR |
>>>         IMX_AUDMUX_V2_PTCR_TCSEL(slave);
>>>     pdcr = IMX_AUDMUX_V2_PDCR_RXDSEL(slave);
>>>
>>>     imx_audmux_v2_configure_port(master, ptcr, pdcr);
>>>
>>>     /*
>>>      * According to RM, RCLKDIR and SYN should not be changed at same
>>> time.
>>>      * So separate to two step for configuring this port.
>>>      */
>>>     ptcr |= IMX_AUDMUX_V2_PTCR_RFSDIR |
>>>         IMX_AUDMUX_V2_PTCR_RFSEL(slave) |
>>>         IMX_AUDMUX_V2_PTCR_RCLKDIR |
>>>         IMX_AUDMUX_V2_PTCR_RCSEL(slave);
>>>     imx_audmux_v2_configure_port(master, ptcr, pdcr);
>>>
>>>     printk(KERN_ERR "--> ITEL imx-audmux-confic ext-port port=%#010x
>>> ptcr=%#010x pdcr=%#010x\n", master, ptcr, pdcr);
>>>
>>>     ptcr = IMX_AUDMUX_V2_PTCR_SYN;
>>>     pdcr = IMX_AUDMUX_V2_PDCR_RXDSEL(master);
>>>
>>>     printk(KERN_ERR "--> ITEL imx-audmux-config int-port port=%#010x
>>> ptcr=%#010x pdcr=%#010x\n", master, ptcr, pdcr);
>>>     imx_audmux_v2_configure_port(slave, ptcr, pdcr);
>>>
>>>     return 0;
>>> }
>>>
>>>
>>> static int imx_itel_hw_params(struct snd_pcm_substream *substream,
>>>                               struct snd_pcm_hw_params *params)
>>> {
>>>     struct snd_soc_pcm_runtime *rtd = substream->private_data;
>>>     struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
>>>     u32 channels = params_channels(params);
>>>     u32 rate = params_rate(params);
>>>     u32 bclk = rate * channels * 32;
>>>     int ret = 0;
>>>
>>>     printk(KERN_ERR "--> ITEL imx-itel-hw-params NAME=%s  \n VALUE=%#010x
>>> "
>>>                         "SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
>>> SND_SOC_DAIFMT_CBS_CFS\n",
>>>                         cpu_dai->name,
>>>                         (SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
>>> SND_SOC_DAIFMT_CBS_CFS));
>>>
>>>     /* set cpu DAI configuration */
>>>     ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S
>>>             | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
>>>     if (ret) {
>>>         dev_err(cpu_dai->dev, "failed to set dai fmt\n");
>>>         return ret;
>>>     }
>>>     printk(KERN_ERR "--> ITEL imx-itel-hw-params set tdm slots
>>> channels=%d", channels);
>>>
>>>     ret = snd_soc_dai_set_tdm_slot(cpu_dai,
>>>             channels == 1 ? 0xfffffffe : 0xfffffffc,
>>>             channels == 1 ? 0xfffffffe : 0xfffffffc,
>>>             2, 32);
>>>     if (ret) {
>>>         dev_err(cpu_dai->dev, "failed to set dai tdm slot\n");
>>>         return ret;
>>>     }
>>>
>>>     printk(KERN_ERR "--> ITEL imx-audmux-config set sysclk NAME=%s
>>> \n",cpu_dai->name);
>>>
>>>     ret = snd_soc_dai_set_sysclk(cpu_dai, 0, bclk, SND_SOC_CLOCK_OUT);
>>>     if (ret)
>>>         dev_err(cpu_dai->dev, "failed to set sysclk\n");
>>>
>>>     return ret;
>>> }
>>>
>>>
>>> static struct snd_soc_ops imx_itel_ops = {
>>>     .hw_params = imx_itel_hw_params,
>>> };
>>>
>>>
>>> static struct snd_soc_dai_link imx_itel_dai[] = {
>>>     {
>>>         .name            = "Hifi",
>>>         .stream_name     = "Hifi",
>>>         .codec_dai_name     = "snd-soc-dummy-dai",
>>>         //.codec_name         = "snd-soc-dummy",
>>>         .ops             = &imx_itel_ops,
>>>         // .symmetric_rates = 1,
>>>     },
>>> };
>>>
>>> static struct snd_soc_card snd_soc_card_imx_itel = {
>>>     .name       = "imx-audio-itel",
>>>     .dai_link   = imx_itel_dai,
>>>     .num_links    = ARRAY_SIZE(imx_itel_dai),
>>>     .owner      = THIS_MODULE,
>>> };
>>>
>>>
>>> static int imx_itel_probe(struct platform_device *pdev)
>>> {
>>>     struct snd_soc_card *card = &snd_soc_card_imx_itel;
>>>     struct device_node *ssi_np;
>>>     struct platform_device *ssi_pdev;
>>>     struct device_node *codec_np;
>>>     // struct imx_itel_data *data = NULL;
>>>     int int_port, ext_port, ret;
>>>
>>>     printk(KERN_ERR "--> ITEL imx_itel_probe");
>>>
>>>     ret = of_property_read_u32(pdev->dev.of_node, "mux-int-port",
>>> &int_port);
>>>     if (ret) {
>>>         dev_err(&pdev->dev, "mux-int-port missing or invalid\n");
>>>         return ret;
>>>     }
>>>
>>>
>>>     ret = of_property_read_u32(pdev->dev.of_node, "mux-ext-port",
>>> &ext_port);
>>>     if (ret) {
>>>         dev_err(&pdev->dev, "mux-ext-port missing or invalid\n");
>>>         return ret;
>>>     }
>>>
>>>     printk(KERN_ERR "--> ITEL Configuro audmux\n");
>>>     imx_audmux_config(int_port, ext_port);
>>>
>>>     /* find value in devicetree for ssi controller */
>>>     ssi_np = of_parse_phandle(pdev->dev.of_node, "ssi-controller", 0);
>>>     if (!ssi_np) {
>>>         dev_err(&pdev->dev, "ssi-controller missing or invalid\n");
>>>         ret = -EINVAL;
>>>         goto fail;
>>>     }
>>>
>>>     /* find SSI platform driver */
>>>     ssi_pdev = of_find_device_by_node(ssi_np);
>>>     if (!ssi_pdev) {
>>>         dev_err(&pdev->dev, "failed to find SSI platform device\n");
>>>         ret = -EPROBE_DEFER;
>>>         goto fail;
>>>     }
>>>
>>>     codec_np = of_parse_phandle(pdev->dev.of_node, "audio-codec", 0);
>>>     if (!codec_np) {
>>>         dev_err(&pdev->dev, "codec missing or invalid\n");
>>>         ret = -EINVAL;
>>>         goto fail;
>>>     }
>>>
>>>     // codec_dev = NULL;
>>>
>>>     card->dev = &pdev->dev;
>>>     card->dai_link->cpu_dai_name = dev_name(&ssi_pdev->dev);
>>>     card->dai_link->platform_of_node = ssi_np;
>>>     card->dai_link->codec_of_node = codec_np;
>>>
>>>     platform_set_drvdata(pdev, card);
>>>     snd_soc_card_set_drvdata(card, &snd_soc_card_imx_itel);
>>>
>>>     printk(KERN_ERR "--> ITEL imx-probe registro card\n");
>>>
>>>     ret = snd_soc_register_card(card);
>>>     if (ret) {
>>>         dev_err(&pdev->dev, "Failed to register card: %d\n", ret);
>>>         goto fail;
>>>     }
>>>
>>>     printk(KERN_ERR "--> ITEL imx-probe of ssi\n");
>>>     of_node_put(ssi_np);
>>>     printk(KERN_ERR "--> ITEL imx-probe of codec\n");
>>>     of_node_put(codec_np);
>>>
>>>     return 0;
>>>
>>> fail:
>>>     if (ssi_np)
>>>         of_node_put(ssi_np);
>>>     if (codec_np)
>>>         of_node_put(codec_np);
>>>
>>>     return ret;
>>> }
>>>
>>> static int imx_itel_remove(struct platform_device *pdev)
>>> {
>>>     struct snd_soc_card *card = &snd_soc_card_imx_itel;
>>>
>>>     snd_soc_unregister_card(card);
>>>
>>>     return 0;
>>> }
>>>
>>> static const struct of_device_id imx_itel_dt_ids[] = {
>>>     { .compatible = "fsl,imx-audio-itel", },
>>>     { /* sentinel */ }
>>> };
>>> MODULE_DEVICE_TABLE(of, imx_itel_dt_ids);
>>>
>>> static struct platform_driver imx_itel_driver = {
>>>     .driver = {
>>>         .name = "imx-itel",
>>>         .owner = THIS_MODULE,
>>>         .pm = &snd_soc_pm_ops,
>>>         .of_match_table = imx_itel_dt_ids,
>>>     },
>>>     .probe = imx_itel_probe,
>>>     .remove = imx_itel_remove,
>>> };
>>>
>>> module_platform_driver(imx_itel_driver);
>>>
>>> MODULE_AUTHOR("Nicola Lunghi");
>>> MODULE_DESCRIPTION("ITEL I2S Platform Driver");
>>> MODULE_LICENSE("GPL v2");
>>> MODULE_ALIAS("platform:imx-itel");
>>>
>>> 2016-05-12 9:55 GMT+02:00 nick83ola <nick83ola@gmail.com>:
>>>>
>>>> I am using ssi1 because I have an example of setting master mode on
>>>> sabre board dts
>>>>
>>>> I have a problem with iomux/pinctrl  I think because
>>>>
>>>> root@icorem6solo:/sys/kernel/debug/pinctrl/20e0000.iomuxc# cat
>>>> pinmux-pins |grep audmux
>>>> pin 57 (MX6DL_PAD_DISP0_DAT20): 2028000.ssi (GPIO UNCLAIMED) function
>>>> audmux group audmux-4
>>>> pin 58 (MX6DL_PAD_DISP0_DAT21): 2028000.ssi (GPIO UNCLAIMED) function
>>>> audmux group audmux-4
>>>> pin 59 (MX6DL_PAD_DISP0_DAT22): 2028000.ssi (GPIO UNCLAIMED) function
>>>> audmux group audmux-4
>>>> pin 60 (MX6DL_PAD_DISP0_DAT23): 2028000.ssi (GPIO UNCLAIMED) function
>>>> audmux group audmux-4
>>>>
>>>> says: GPIO_UNCLAIMED? it is correct??
>>>>
>>>> /sys/kernel/debug/pinctrl/20e0000.iomuxc# cat pinconf-groups |grep -A 1
>>>> audmux
>>>> 1 (audmux-1):
>>>> MX6DL_PAD_SD2_DAT0: 0x17070MX6DL_PAD_SD2_DAT3:
>>>> 0x17070MX6DL_PAD_SD2_DAT2: 0x17070MX6DL_PAD_SD2_DAT1: 0x17070
>>>> 2 (audmux-2):
>>>> MX6DL_PAD_CSI0_DAT7: 0x1b0b0MX6DL_PAD_CSI0_DAT4:
>>>> 0x1b0b0MX6DL_PAD_CSI0_DAT5: 0x1b0b0MX6DL_PAD_CSI0_DAT6: 0x1b0b0
>>>> 3 (audmux-3):
>>>> MX6DL_PAD_DISP0_DAT16: 0x10MX6DL_PAD_DISP0_DAT18:
>>>> 0x1b0b0MX6DL_PAD_DISP0_DAT19: 0x1b0b0
>>>> 4 (audmux-4):
>>>> MX6DL_PAD_DISP0_DAT20: 0x130b0MX6DL_PAD_DISP0_DAT21:
>>>> 0x110b0MX6DL_PAD_DISP0_DAT22: 0x130b0MX6DL_PAD_DISP0_DAT23: 0x130b0
>>>>
>>>> 0x130b0?
>>>>
>>>> audmux# cat ssi0
>>>>     PDCR: 0000a000
>>>>     PTCR: ad400800
>>>>     TxFS output from SSI6, TxClk output from SSI6
>>>>     Port is symmetric
>>>>     Data received from SSI6
>>>> root@icorem6solo:/sys/kernel/debug/audmux# cat ssi1
>>>>     PDCR: 00008000
>>>>     PTCR: 00000800
>>>>     TxFS input, TxClk input
>>>>     Port is symmetric
>>>>     Data received from SSI5
>>>> root@icorem6solo:/sys/kernel/debug/audmux# cat ssi2
>>>>     PDCR: 00006000
>>>>     PTCR: 9cc00800
>>>>     TxFS output from SSI4, TxClk output from SSI4
>>>>     Port is symmetric
>>>>     Data received from SSI4
>>>> root@icorem6solo:/sys/kernel/debug/audmux# cat ssi3
>>>>     PDCR: 00004000
>>>>     PTCR: 00000800
>>>>     TxFS input, TxClk input
>>>>     Port is symmetric
>>>>     Data received from SSI3
>>>> root@icorem6solo:/sys/kernel/debug/audmux# cat ssi4
>>>>     PDCR: 00002000
>>>>     PTCR: 8c400800
>>>>     TxFS output from imx-ssi.1, TxClk output from imx-ssi.1
>>>>     Port is symmetric
>>>>     Data received from imx-ssi.1
>>>> root@icorem6solo:/sys/kernel/debug/audmux# cat ssi5
>>>>     PDCR: 00000000
>>>>     PTCR: 00000800
>>>>     TxFS input, TxClk input
>>>>     Port is symmetric
>>>>     Data received from imx-ssi.0
>>>> root@icorem6solo:/sys/kernel/debug/audmux# cat ssi6
>>>>     PDCR: 0000c000
>>>>     PTCR: 00000800
>>>>     TxFS input, TxClk input
>>>>     Port is symmetric
>>>>     Data received from UNKNOWN
>>>>
>>>>
>>>
>>>
>>>
>>> --
>>>
>>> P.S. Le informazioni trasmesse attraverso la presente comunicazione sono
>>> di esclusiva
>>> spettanza dell'effettivo destinatario. Nel caso in cui le stesse
>>> raggiungessero, per
>>> qualunque motivo, soggetti non interessati, questi ultimi vorranno darne
>>> immediata
>>> notizia al mittente. In ogni caso, eventuali soggetti diversi dai
>>> legittimi destinatari
>>> della presente comunicazione e dei dati contenuti negli allegati, possono
>>> essere
>>> sanzionati ai sensi del T.U. sul trattamento dei dati personali d.lgs.
>>> 196/2003, sia ai
>>> sensi dell'art. 616 del Codice Penale che disciplina la violazione del
>>> segreto sulla
>>> corrispondenza.
>>
>>
>
>
>
> --
>
> P.S. Le informazioni trasmesse attraverso la presente comunicazione sono di
> esclusiva
> spettanza dell'effettivo destinatario. Nel caso in cui le stesse
> raggiungessero, per
> qualunque motivo, soggetti non interessati, questi ultimi vorranno darne
> immediata
> notizia al mittente. In ogni caso, eventuali soggetti diversi dai legittimi
> destinatari
> della presente comunicazione e dei dati contenuti negli allegati, possono
> essere
> sanzionati ai sensi del T.U. sul trattamento dei dati personali d.lgs.
> 196/2003, sia ai
> sensi dell'art. 616 del Codice Penale che disciplina la violazione del
> segreto sulla
> corrispondenza.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Imx6 i2s master driver without i2c
@ 2016-11-07 16:17 Bode, Michael (PED-DEAS)
  0 siblings, 0 replies; 18+ messages in thread
From: Bode, Michael (PED-DEAS) @ 2016-11-07 16:17 UTC (permalink / raw)
  To: alsa-devel

Hi,

I know, it's some time ago since there was this discussion ongoing. I don't know if you already solved your problems.
Because I had a similar task to solve I maybe have some information that could help here:

In my case calling function "snd_soc_dai_set_pll(cpu_dai, 0, 0, 688128000, itel_audio_fmts[i].sysclk);" was not working. When looking into the details I found that underlying
Driver (in my case fsl_ssi.c) had not implemented function "set_pll", so calling this function was just a dummy. Then I tried to figure out how to manipulate the Audio PLL in i.MX6 and
Found the file "clk-imx6q.c" which sets all clocks of i.MX6.  To register a clock the function clk_register_clkdev needs to be called for that clock. Now I found that this registration was missing for
PLL4 which in my case should be used for audio. So I added "clk_register_clkdev(clk[IMX6QDL_CLK_PLL4_AUDIO_DIV], "pll4", NULL);".
With this change I was able to call "pll4 = clk_get(NULL, "pll4");" from my SOC-driver and do a  pllRate = clk_round_rate(pll4, 688128000); and clk_set_rate(pll4, pllRate);
Finally with this I was able to change Audio PLL according to sample rate to get proper SSI signals.

A second thing I found in your chat was that you had the problem that no matter what sample frequency you use, you always get 44100. I also ran into that issue and found that there is an ALSA feature active
That intentionally converts the audio rate. I found the config file asound.conf in /etc that defines:

pcm.dmix_44100{
type dmix
ipc_key 5678293
ipc_key_add_uid yes
slave{
pcm "hw:0,0"
period_time 40000
buffer_time 360000
format S16_LE
rate 44100
}
}

pcm.asymed{
type asym
playback.pcm "dmix_44100"
capture.pcm "dsnoop_44100"
}

As a result all my frequencies were intentionally converted to 44100 Hz. So my solution was to just rename/delete asound.conf

I hope this can help others to get an i.MX I2S Master running.


Best regards,
Michael Bode

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2016-11-07 16:18 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CABPh3UNhKMGUoiDvHn9paXVNvtpwzbzkbCwBhtSCm72jxkh3CA@mail.gmail.com>
     [not found] ` <CABPh3UMMvVKvHL0g52NqP-E8dpxoZHfwgR_t1WY08OFMSYt9tg@mail.gmail.com>
     [not found]   ` <CABPh3UMJ4gOtNN3FJg0fF7Mm+Lpw0=jXGk_+ejsHaGLG9UvWAQ@mail.gmail.com>
     [not found]     ` <CABPh3UNi79pMZPgJBisaq9Qo847MV-6riCEQ=Akt_RoLdqeVpw@mail.gmail.com>
2016-05-05 19:56       ` Imx6 i2s master driver without i2c nick83ola
2016-05-06 15:38         ` Caleb Crome
2016-05-09 11:17           ` nick83ola
2016-05-09 17:21             ` Caleb Crome
2016-05-10 14:57               ` nick83ola
2016-05-10 15:28                 ` nick83ola
2016-05-10 16:14                   ` Caleb Crome
2016-05-10 17:00                     ` nick83ola
2016-05-10 17:43                       ` Caleb Crome
2016-05-11  6:25                         ` nick83ola
2016-05-11 17:34                           ` Caleb Crome
2016-05-12  7:55                             ` nick83ola
2016-05-13  7:59                               ` nick83ola
2016-05-13  8:21                                 ` nick83ola
2016-05-13 19:30                                 ` Caleb Crome
2016-05-17 14:51                                   ` nick83ola
2016-05-17 16:51                                     ` Caleb Crome
2016-11-07 16:17 Bode, Michael (PED-DEAS)

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.