Skip to main content
Visitor II
August 19, 2019
Solved

Clock output on MCO1 pin (STM32MP157)

  • August 19, 2019
  • 7 replies
  • 4989 views

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

    This topic has been closed for replies.
    Best answer by Moises Araya

    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

    7 replies

    Technical Moderator
    August 20, 2019
    AKacpAuthor
    Visitor II
    August 20, 2019

    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

    AKacpAuthor
    Visitor II
    August 26, 2019

    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

    Technical Moderator
    August 27, 2019

    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

    AKacpAuthor
    Visitor II
    August 28, 2019

    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

    Visitor II
    May 24, 2020

    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

    ST Employee
    January 25, 2021

    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

    Visitor II
    November 24, 2021

    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