Skip to content

Conversation

@mariopaja
Copy link
Contributor

@mariopaja mariopaja commented Dec 13, 2024

Development status:

Board used:
B-U585I-IOT02A
Nucleo-U575

Tests (16-bit, 2-channels, 44.1KHz):

Overlays:
nucleo_u575zi_q.overlay

/ {
	aliases {
		sai1a = &sai1_a;
		sai1b = &sai1_b;
	};

	soc {
		pinctrl: pin-controller@42020000 {
			/* SAI1_A */
			/omit-if-no-ref/ sai1_mclk_a_pe2: sai1_mclk_a_pe2 {
				pinmux = <STM32_PINMUX('E', 2, AF13)>;
				slew-rate = "very-high-speed";
			};
			/omit-if-no-ref/ sai1_sd_a_pe6: sai1_sd_a_pe6 {
				pinmux = <STM32_PINMUX('E', 6, AF13)>;
				slew-rate = "very-high-speed";
			};
			/omit-if-no-ref/ sai1_fs_a_pe4: sai1_fs_a_pe4 {
				pinmux = <STM32_PINMUX('E', 4, AF13)>;
				slew-rate = "very-high-speed";
			};
			/omit-if-no-ref/ sai1_sck_a_pe5: sai1_sck_a_pe5 {
				pinmux = <STM32_PINMUX('E', 5, AF13)>;
				slew-rate = "very-high-speed";
			};

			/* SAI1_B */
			/omit-if-no-ref/ sai1_sd_b_pe3: sai1_sd_b_pe3 {
				pinmux = <STM32_PINMUX('E', 3, AF13)>;
				slew-rate = "very-high-speed";
			};
			/omit-if-no-ref/ sai1_sck_b_pf8: sai1_sck_b_pf8 {
				pinmux = <STM32_PINMUX('F', 8, AF13)>;
				slew-rate = "very-high-speed";
			};
			/omit-if-no-ref/ sai1_fs_b_pf9: sai1_fs_b_pf9 {
				pinmux = <STM32_PINMUX('F', 9, AF13)>;
				slew-rate = "very-high-speed";
			};
			/omit-if-no-ref/ sai1_mclk_b_pf7: sai1_mclk_b_pf7 {
				pinmux = <STM32_PINMUX('F', 7, AF13)>;
				slew-rate = "very-high-speed";
			};
		};
	};
};

&sai1_a {
	pinctrl-0 = <&sai1_mclk_a_pe2 &sai1_sd_a_pe6
	&sai1_fs_a_pe4 &sai1_sck_a_pe5>;
	pinctrl-names = "default";
	status = "okay";
	dmas = <&gpdma1 1 36 (STM32_DMA_PERIPH_TX | STM32_DMA_PRIORITY_HIGH | STM32_DMA_MEM_16BITS | STM32_DMA_PERIPH_16BITS)>;
	dma-names = "tx";
	mclk-enable;
	mclk-div-enable;
};

&sai1_b {
	pinctrl-0 = <&sai1_sd_b_pe3 &sai1_sck_b_pf8 &sai1_fs_b_pf9 &sai1_mclk_b_pf7>;
	pinctrl-names = "default";
	status = "disabled";
	dmas = <&gpdma1 0 37 (STM32_DMA_PERIPH_TX | STM32_DMA_PRIORITY_HIGH | STM32_DMA_MEM_16BITS | STM32_DMA_PERIPH_16BITS)>;
	dma-names = "tx";
};

&gpdma1 {
	status = "okay";
};

&pll2 {
	/* 44.1KHz (-0.03% Error) */
	div-m = <1>;
	mul-n = <79>;
	div-q = <2>;
	div-r = <2>;
	div-p = <7>;
	clocks = <&clk_msis>;
	status = "okay";
};

&dac1 {
	status = "disabled";
};

b_u585i_iot02a.overlay

/ {
	aliases {
		sai1a = &sai1_a;
	};

	soc {
		pinctrl: pin-controller@42020000 {
			/omit-if-no-ref/ sai1_mclk_a_pe2: sai1_mclk_a_pe2 {
				pinmux = <STM32_PINMUX('E', 2, AF13)>;
				slew-rate = "very-high-speed";
			};
			/omit-if-no-ref/ sai1_sd_a_pe6: sai1_sd_a_pe6 {
				pinmux = <STM32_PINMUX('E', 6, AF13)>;
			};
			/omit-if-no-ref/ sai1_fs_a_pe4: sai1_fs_a_pe4 {
				pinmux = <STM32_PINMUX('E', 4, AF13)>;
			};
			/omit-if-no-ref/ sai1_sck_a_pe5: sai1_sck_a_pe5 {
				pinmux = <STM32_PINMUX('E', 5, AF13)>;
				slew-rate = "very-high-speed";
			};
		};

		sai1_a: sai1_a@40015404 {
			compatible = "st,stm32-sai";
			#address-cells = <1>;
			#size-cells = <0>;
			reg = <0x40015404 0x20>;
			clocks = <&rcc STM32_CLOCK(APB2, 21U)>,
			         <&rcc STM32_SRC_PLL1_P SAI1_SEL(2)>;
			status = "disabled";
		};

	};

};

&sai1_a {
	pinctrl-0 = <&sai1_mclk_a_pe2 &sai1_sd_a_pe6
	&sai1_fs_a_pe4 &sai1_sck_a_pe5>;
	pinctrl-names = "default";
	status = "okay";
	dmas = <&gpdma1 1 36 (STM32_DMA_PERIPH_TX | STM32_DMA_PRIORITY_HIGH | STM32_DMA_MEM_16BITS | STM32_DMA_PERIPH_16BITS)>;
	dma-names = "tx";
	mclk-enable;
	mclk-div-enable;
};

&gpdma1 {
	status = "okay";
};

&pll2 {
	/* 44.1KHz (-0.03% Error) */
	div-m = <1>;
	mul-n = <79>;
	div-q = <2>;
	div-r = <2>;
	div-p = <7>;
	clocks = <&clk_msis>;
	status = "okay";
};

@mariopaja mariopaja force-pushed the sai_hal_stm32 branch 4 times, most recently from f8ceb83 to eaa6008 Compare December 13, 2024 11:21
@mariopaja mariopaja force-pushed the sai_hal_stm32 branch 2 times, most recently from 0d5e107 to 0822bdf Compare January 30, 2025 10:33
@mariopaja mariopaja force-pushed the sai_hal_stm32 branch 4 times, most recently from 0acc7b3 to 8648fe2 Compare February 10, 2025 14:21
@mariopaja mariopaja changed the title [WIP] drivers: i2s: add sai support for stm32u5xx drivers: i2s: add sai support for stm32u5xx Apr 8, 2025
@mariopaja mariopaja force-pushed the sai_hal_stm32 branch 3 times, most recently from e199134 to 7ac5f73 Compare April 16, 2025 12:45
@mariopaja mariopaja marked this pull request as ready for review April 16, 2025 12:53
@github-actions github-actions bot requested a review from djiatsaf-st April 16, 2025 12:54
Copy link
Member

@erwango erwango left a comment

Choose a reason for hiding this comment

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

I didn't go into details but this is a great work. I have few initial comments but the main request would be to add a way to build and use this driver in tree (add a (simple) sample if missing or a board configuration to make use of existing sample)

uint32_t dma_channel;
struct dma_config dma_cfg;

/* STM32U5 HAL SAI */
Copy link
Member

Choose a reason for hiding this comment

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

Is this really U5 specific ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@erwango I dont think so, but since I have build the driver around U5 and havent checked other platforms at all I wanted to specify where I got this

Copy link
Member

Choose a reason for hiding this comment

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

Let's remove. This will be soon obsolete and don't add anything.

@mariopaja mariopaja force-pushed the sai_hal_stm32 branch 4 times, most recently from 9391608 to 0737d2c Compare April 30, 2025 07:43
@mariopaja
Copy link
Contributor Author

I didn't go into details but this is a great work. I have few initial comments but the main request would be to add a way to build and use this driver in tree (add a (simple) sample if missing or a board configuration to make use of existing sample)

@erwango An overlay of Nucleo U575 is added to samples/i2s/output

uint32_t dma_channel;
struct dma_config dma_cfg;

/* STM32U5 HAL SAI */
Copy link
Member

Choose a reason for hiding this comment

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

Let's remove. This will be soon obsolete and don't add anything.

Copy link
Member

@erwango erwango left a comment

Choose a reason for hiding this comment

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

Thanks for your feedback. Last round of comments I hope from my part.

Add SAI1 A & B nodes on STM32U5 Series

Signed-off-by: Mario Paja <mario.paja@zal.aero>
@mariopaja mariopaja force-pushed the sai_hal_stm32 branch 2 times, most recently from 7ee77c1 to ad44748 Compare May 19, 2025 09:47
Copy link
Member

@erwango erwango left a comment

Choose a reason for hiding this comment

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

Otherwise LGTM

This PR adds initial sai support for STM32u5xx

Signed-off-by: Mario Paja <mario.paja@zal.aero>
Adds Nucleo U575 overlay and config files

Signed-off-by: Mario Paja <mario.paja@zal.aero>
@sonarqubecloud
Copy link

@kartben kartben merged commit f12ba46 into zephyrproject-rtos:main Jun 6, 2025
26 checks passed
@mariopaja mariopaja mentioned this pull request Jun 11, 2025
21 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants