cancel
Showing results for 
Search instead for 
Did you mean: 

Clock output on MCO1 pin (STM32MP157)

AKacp
Associate II

I need to provide 32kHz clock at MCO1 output pin on STM32MP157.

I have successfully configured u-boot to provide this clock but as soon as kernel is started clock disappears.

After some checks I have found that clock is disabled.

My question is if it is possible to create device tree entry to force kernel to enable MCO1 output ?

Regards

Arkadiusz

1 ACCEPTED SOLUTION

Accepted Solutions
Moises Araya
Associate III

Hello @Marie-Christine CAYALE​ ,

Thanks for your useful hints. As this is still not resolved in the 5.10 STM-Kernel, I made a small platform driver based on your suggestions. For anyone having this issue you can take a look at this thread for a reference implementation:

https://community.st.com/s/question/0D53W00001Co3JdSAJ/how-to-configure-device-trees-tfaubootkernel-to-output-the-mco2-clock-on-an-external-pin-of-the-stm32mp15x?t=1637764677328

Kind regards,

Moises

View solution in original post

8 REPLIES 8
Olivier GALLIEN
ST Employee

Hi @AKacp​ 

Did you have a look to wiki user guide ?

https://wiki.st.com/stm32mpu/wiki/Clock_device_tree_configuration

https://wiki.st.com/stm32mpu/wiki/Clock_device_tree_configuration_-_Bootloader_specific

Let me know if it help

Olivier

Olivier GALLIEN
In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

Hello Olivier,

unfortunatelly this does not help.

As I wrote already, I have configured u-boot device tree to generate 32kHz on MCO1 output and it works well as long as bootloader is running. But, when Linux is starting and begins drivers initialization MCO1 output is disabled - MCO1ON bit in register RCC_MCO1CFG is 0. I have checked also 32k quartz - it is working while Linux is running.

Regards

Arkadiusz

AKacp
Associate II

Hello Olivier,

do you have any idea if this can be handled by configuring just device tree or I need to change some code in Linuc clock driver ?

Regards

Arkadiusz

Olivier GALLIEN
ST Employee

Hi @AKacp​ 

Are you using CubeMX to generate the Device Tree ?

MCO1 pin configuration should be also present in your kernel Device Tree. Is it the case ?

Olivier

Olivier GALLIEN
In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
AKacp
Associate II

Hi Olivier,

configuration is present:

here are parts of config from u-boot device tree:

&rcc {
	u-boot,dm-pre-reloc;
	st,clksrc = <
		CLK_MPU_PLL1P_DIV
		CLK_AXI_PLL2P
		CLK_MCU_PLL3P
		CLK_PLL12_HSE
		CLK_PLL3_HSE
		CLK_PLL4_HSE
		CLK_RTC_LSE
		CLK_MCO1_LSE
		CLK_MCO2_DISABLED
	>;
 
&rcc{
	u-boot,dm-pre-reloc;
	pinctrl-names = "default", "sleep";
	pinctrl-0 = <&rcc_pins_mx>;
	pinctrl-1 = <&rcc_sleep_pins_mx>;
	status = "okay";
 
	/* USER CODE BEGIN rcc */
	/* USER CODE END rcc */
};
 
	rcc_pins_mx: rcc_mx-0 {
		u-boot,dm-pre-reloc;
		pins {
			u-boot,dm-pre-reloc;
			pinmux = <STM32_PINMUX('A', 13, AF2)>; /* RCC_MCO_1 */
			bias-disable;
			drive-push-pull;
			slew-rate = <0>;
		};
	};

And here parts of dts file from kernel:

&rcc{
	u-boot,dm-pre-reloc;
	pinctrl-names = "default", "sleep";
	pinctrl-0 = <&rcc_pins_mx>;
	pinctrl-1 = <&rcc_sleep_pins_mx>;
	status = "okay";
 
	/* USER CODE BEGIN rcc */
	/* USER CODE END rcc */
};
 
	rcc_pins_mx: rcc_mx-0 {
		u-boot,dm-pre-reloc;
		pins {
			u-boot,dm-pre-reloc;
			pinmux = <STM32_PINMUX('A', 13, AF2)>; /* RCC_MCO_1 */
			bias-disable;
			drive-push-pull;
			slew-rate = <0>;
		};
	};

Regards

Arkadiusz

ROlss.1
Associate

I am actually having the very same issue over here. Was this solved and in that case, how?

I can manually enable the clock from Linux, but it would be much nicer if this could be sorted out from the device tree.

BR

RO

I know this post is quite old, but this is for reference solution

You can create a dummy device node to declare the clock. 

Then in this device, you create some functions to switch on/off the clock (enable/disable).

in dts file in node describing simple driver (wifi or any "dummy" one)

add new clock

clocks = , ;

clock-names = , "my_mco1";

in probe function of same driver

calling clock enable on clock using

devm_clk_get(&pdev->dev, "my_mco1");

(can reuse clock enabling examples from other drivers)

Another solution can be changing clock to CRITICAL in kernel

linux-stm32mp-***/linux-***/drivers/clk/clk-stm32mp1.c

(if the clock is set to critical like described, it will be always ON.

But it is not optimized for power consumption in this case)

You can see clock status with 

cat /sys/kernel/debug/clk/clk_summary

https://wiki.st.com/stm32mpu/wiki/Debugfs#How_to_visualize_debugfs_information

Moises Araya
Associate III

Hello @Marie-Christine CAYALE​ ,

Thanks for your useful hints. As this is still not resolved in the 5.10 STM-Kernel, I made a small platform driver based on your suggestions. For anyone having this issue you can take a look at this thread for a reference implementation:

https://community.st.com/s/question/0D53W00001Co3JdSAJ/how-to-configure-device-trees-tfaubootkernel-to-output-the-mco2-clock-on-an-external-pin-of-the-stm32mp15x?t=1637764677328

Kind regards,

Moises