Skip to content

ASoC: SOF: imx8m: add SAI2,5,6,7#4391

Merged
plbossart merged 1 commit intothesofproject:topic/sof-devfrom
eurofun:more-SAIs
Sep 25, 2023
Merged

ASoC: SOF: imx8m: add SAI2,5,6,7#4391
plbossart merged 1 commit intothesofproject:topic/sof-devfrom
eurofun:more-SAIs

Conversation

@eurofun
Copy link
Copy Markdown

@eurofun eurofun commented May 30, 2023

Added the remaining SAIs in addition to SAI1 and SAI3. There is no SAI4, to my knowledge. I checked the imx93 ref manual, for imx8ulp I couldn't even find the reference manual...
This is related to sof #7689.

The (necessary...) sai aux clks have always been missing in the topic/sof-dev branch, they are only present in the nxp linux-imx repo:
nxp-imx/linux-imx@bdef7ec

It is a pretty simple additional modification for linux-imx:

static struct clk_bulk_data imx8m_aux_clks[] = {
	{ .id = "sai1_bus" },
	{ .id = "sai1_mclk0" },
	{ .id = "sai1_mclk1" },
	{ .id = "sai1_mclk2" },
	{ .id = "sai1_mclk3" },

	{ .id = "sai2_bus" },
	{ .id = "sai2_mclk0" },
	{ .id = "sai2_mclk1" },
	{ .id = "sai2_mclk2" },
	{ .id = "sai2_mclk3" },

	{ .id = "sai3_bus" },
	{ .id = "sai3_mclk0" },
	{ .id = "sai3_mclk1" },
	{ .id = "sai3_mclk2" },
	{ .id = "sai3_mclk3" },

	{ .id = "sai5_bus" },
	{ .id = "sai5_mclk0" },
	{ .id = "sai5_mclk1" },
	{ .id = "sai5_mclk2" },
	{ .id = "sai5_mclk3" },

	{ .id = "sai6_bus" },
	{ .id = "sai6_mclk0" },
	{ .id = "sai6_mclk1" },
	{ .id = "sai6_mclk2" },
	{ .id = "sai6_mclk3" },

	{ .id = "sai7_bus" },
	{ .id = "sai7_mclk0" },
	{ .id = "sai7_mclk1" },
	{ .id = "sai7_mclk2" },
	{ .id = "sai7_mclk3" },

	{ .id = "sdma3_root" },
};

Tested on imx8mp with a .dts that looks like that:

bt_sco_codec: bt_sco_codec {
    #sound-dai-cells = <1>;
    compatible = "linux,bt-sco";
};

bt_sco_codec0: bt_sco_codec0 {
    #sound-dai-cells = <1>;
    compatible = "linux,bt-sco";
};

sof-sound-btsco {
    compatible = "simple-audio-card";
    label = "btsco-audio";
    simple-audio-card,name = "bt-dsp-a";

    simple-audio-card,dai-link@0 {
        bitclock-master = <&cpudai0>;
        frame-master = <&cpudai0>;
        cpudai0: cpu {
            sound-dai = <&dsp 1>;
        };
        codec {
            sound-dai = <&bt_sco_codec0 1>;
        };
    };

    simple-audio-card,dai-link@1 {
        bitclock-master = <&cpudai1>;
        frame-master = <&cpudai1>;
        cpudai1: cpu {
            sound-dai = <&dsp 2>;
        };
        codec {
            sound-dai = <&bt_sco_codec 1>;
        };
    };
};

reserved-memory {
        /delete-node/ dsp_reserved;
        /delete-node/ dsp_reserved_heap;
        /delete-node/ dsp_vdev0vring0;
        /delete-node/ dsp_vdev0vring1;
        /delete-node/ dsp_vdev0buffer;

        dsp_reserved: dsp@92400000 {
            reg = <0 0x92400000 0 0x2000000>;
            no-map;
        };
};

dsp: dsp@3b6e8000 {
    #sound-dai-cells = <1>;
    compatible = "fsl,imx8mp-dsp";
    reg = <0x0 0x3B6E8000 0x0 0x88000>;

    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_sai3>;
    pinctrl-1 = <&pinctrl_sai2>;

    power-domains = <&audiomix_pd>;
    audiomix-dsp-regmap = <&audio_blk_ctrl>;

    assigned-clocks = <&clk IMX8MP_CLK_SAI3>, <&clk IMX8MP_CLK_SAI2>;
    assigned-clock-parents = <&clk IMX8MP_AUDIO_PLL1_OUT>;
    assigned-clock-rates = <12288000>;
    clocks = <&audio_blk_ctrl IMX8MP_CLK_AUDIO_BLK_CTRL_OCRAMA_IPG>,
        <&audio_blk_ctrl IMX8MP_CLK_AUDIO_BLK_CTRL_DSP_ROOT>,
        <&audio_blk_ctrl IMX8MP_CLK_AUDIO_BLK_CTRL_DSPDBG_ROOT>,
        <&audio_blk_ctrl IMX8MP_CLK_AUDIO_BLK_CTRL_SAI3_IPG>, <&clk IMX8MP_CLK_DUMMY>,
        <&audio_blk_ctrl IMX8MP_CLK_AUDIO_BLK_CTRL_SAI3_MCLK1>, <&clk IMX8MP_CLK_DUMMY>,
        <&clk IMX8MP_CLK_DUMMY>,
        <&audio_blk_ctrl IMX8MP_CLK_AUDIO_BLK_CTRL_SAI2_IPG>, <&clk IMX8MP_CLK_DUMMY>,
        <&audio_blk_ctrl IMX8MP_CLK_AUDIO_BLK_CTRL_SAI2_MCLK1>, <&clk IMX8MP_CLK_DUMMY>,
        <&clk IMX8MP_CLK_DUMMY>,
        <&audio_blk_ctrl IMX8MP_CLK_AUDIO_BLK_CTRL_SDMA3_ROOT>;

    clock-names = "ipg", "ocram", "core",
        "sai3_bus", "sai3_mclk0", "sai3_mclk1", "sai3_mclk2", "sai3_mclk3",
        "sai2_bus", "sai2_mclk0", "sai2_mclk1", "sai2_mclk2", "sai2_mclk3",
        "sdma3_root";

    mbox-names = "txdb0", "txdb1", "rxdb0", "rxdb1";
    mboxes = <&mu2 2 0>, <&mu2 2 1>,
         <&mu2 3 0>, <&mu2 3 1>;
    memory-region = <&dsp_reserved>;
    /delete-property/ firmware-name;

    tplg-name = "sof-imx8mp-btsco-dual-8ch.tplg";
    machine-drv-name = "asoc-simple-card";

    fsl,dsp-ctrl = <&audio_blk_ctrl>;
    status = "okay";
};

This leads me to a, maybe somewhat off-topic, question about the reserved memory:
imx8mp-evk-sof-wm8960.dts over in the linux-imx repo contains:

dsp_reserved: dsp@92400000 {
	reg = <0 0x92400000 0 0x2000000>;
	no-map;
};

sof imx8m platform memory.h:

#define SDRAM0_BASE	0x92400000
#define SDRAM0_SIZE	0x800000

#define SDRAM1_BASE	0x92C00000
#define SDRAM1_SIZE	0x800000

Why is more than SDRAM0_SIZE+SDRAM1_SIZE reserved? And what is SDRAM0 used for, seemingly nothing?

Added the remaining SAIs in addition to SAI1 and SAI3. There is no SAI4.

Signed-off-by: Alexander Boehm <aboehm@eurofunk.com>
@sofci
Copy link
Copy Markdown
Collaborator

sofci commented May 30, 2023

Can one of the admins verify this patch?

reply test this please to run this test once

@paulstelian97
Copy link
Copy Markdown

paulstelian97 commented May 30, 2023

I may be wrong but I believe SDRAM0 contains parts of the code and data of SOF (and Zephyr, in the Zephyr build) itself, so it is in fact in use. For example in coredumps (when they actually work AKA on panics) typically you see addresses in that range for the code itself. And if you do "nm" on the .elf intermediate file in the build process you will also see addresses from that range.

The reserved memory region is larger than SDRAM0 + SDRAM1 mostly in order to allow ourselves some room to expand without having to do any kernel changes. This has mostly been unnecessary but we did need more memory than normal in order to do e.g. MP3 decoding, which is pretty heavy in terms of memory compared to the default. That thing has in fact been the reason why our code and data sections are not in DSP memory like normal but instead in the SDRAM0 region.

@eurofun
Copy link
Copy Markdown
Author

eurofun commented May 30, 2023

Thanks @paulstelian97, sometimes I'm really blind. Now that I read your explanation it all makes sense and I found that SDRAM0 is used in imx8m.x.in. I also just could have read the nice memory map output at the end of the build process - but for unknown reasons I didn't.

@plbossart
Copy link
Copy Markdown
Member

test this please

.channels_max = 32,
},
},
{
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"There is no SAI4" would be a highly unusual way of designing hardware?

The first Google search gives me this
image

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect that NXP won't support HDMI in Sound Open Firmware, so skipping it is likely fine here. If that changes at some point then fair game though.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"skipped - not supported" is different to "does not exist"...

Copy link
Copy Markdown
Author

@eurofun eurofun Jun 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use of imx8m in SOF is a bit unfortunate (or I just don't understand it) because NXP i.MX8M does not even have a DSP. So it is more about i.MX8MPlus...
imx8 and imx8ulp don't have a SAI 4 with external connections as far as I saw. They do have more SAIs than are defined in imx8.c and imx8ulp.c but I concerned myself only with imx8mp.

@plbossart
Copy link
Copy Markdown
Member

@dbaluta I'll let you review this first

@plbossart plbossart merged commit b9c9909 into thesofproject:topic/sof-dev Sep 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants