Skip to main content
Explorer
December 8, 2023
Question

SPI5 clock in STM32MP151

  • December 8, 2023
  • 4 replies
  • 5822 views

Working on setting up SPI bus and get a connection to ESP32C6 WiFi/BT module. Trying to configure SPI5 clock in device tree for STM32MP151. Have used different sources (HSI, HSE, PLL4Q), but the enable count on the SPI5_k clock is always zero. I am suspecting now that problem must be elsewhere. Has anyone stumbled upon this? 

    This topic has been closed for replies.

    4 replies

    Technical Moderator
    December 8, 2023

    Hello @vsaakian ,
    A little bit difficult to help with no context, can you explain :

    - On which OpenSTLinux are you ? 
    - Is it a custom board ? 
    - Can you share your platform device tree involving SPI5 node ? 

    Kind regards,
    Erwan.

    vsaakianAuthor
    Explorer
    December 8, 2023

    Hi, it is Dunfell OpenSTLinux, HEAD:ed4cbda9145779f757d92d158ae612238d1c7078
    Yes, It is a custom board

    SPI5 part looks like this:

    ```&spi5 {
    pinctrl-names = "default", "sleep";
    pinctrl-0 = <&spi5_pins_mx>;
    pinctrl-1 = <&spi5_sleep_pins_mx>;
    cs-gpios = <&gpioj 1 1>;
    clocks = <&rcc SPI5_K>;
    status = "okay";
     
    esp32c6mini: esp32c6@0 {
    compatible = "esp,esp32c3";
    spi-max-frequency = <50000000>;
    reg = <0>;
    status = "okay";
     
    };
    };```
     
    And pins defined:
    ```spi5_pins_mx: spi5_mx-0 {
    pins {
    pinmux = <STM32_PINMUX('K', 0, AF5)>, /* SPI1_SCK */
    <STM32_PINMUX('J', 10, AF5)>, /* SPI_MOSI */
    <STM32_PINMUX('J', 11, AF5)>; /* SPI_MISO */
    bias-disable;
    drive-push-pull;
    slew-rate = <1>;
    };
    };
     
    spi5_sleep_pins_mx: spi5_sleep_mx-0 {
    pins {
    pinmux = <STM32_PINMUX('K', 0, ANALOG)>, /* SPI1_SCK */
    <STM32_PINMUX('J', 10, ANALOG)>, /* SPI_MOSI */
    <STM32_PINMUX('J', 11, ANALOG)>; /* SPI_MISO */
    };
    };```
    vsaakianAuthor
    Explorer
    December 8, 2023

    And this is what clk_summary says about SPI5_K clock:

    vsaakian_0-1702048053699.png

     

    Technical Moderator
    December 8, 2023

    Thank you for additional information,
    Do you have any trace of the driver of esp32c6 in dmesg ? Are you sure it is probed ?

    Kind regards,
    Erwan.

    vsaakianAuthor
    Explorer
    December 8, 2023

    I so far have only tried with spidev which did not work really. DT example above I have not tried yet. This is how spidev probing looks like:
    vsaakian_1-1702049632370.png

     

     

     

    Technical Moderator
    December 8, 2023

    @vsaakian ,
    Can you show me your DT with spidev on SPI5 ? 

    Kind regards,
    Erwan.

    vsaakianAuthor
    Explorer
    December 8, 2023
    &spi5{
    pinctrl-names = "default", "sleep";
    pinctrl-0 = <&spi5_pins_mx>;
    pinctrl-1 = <&spi5_sleep_pins_mx>;
        cs-gpios = <&gpioj 1 1>;
    clocks = <&rcc SPI5_K>;
    status = "okay";
     
    esp32c6mini: esp32c6@0 {
    compatible = "linux,spidev";
    spi-max-frequency = <50000000>;
    reg = <0>;
    status = "okay";
    };
    };
    vsaakianAuthor
    Explorer
    December 8, 2023

    As for esp32c6 - I don't see anything in dmesg. I doubt it is a valid driver

    Technical Moderator
    December 8, 2023

    @vsaakian ,
    Different comments :

    1) esp32c6 seems to not be a driver upstreamed on Linux and I do not see any compatible that matches with the one you put in the device tree. If this driver is not upstreamed, it must at least exist on your side if you declare it like that in the device tree, or Linux will never make any link between the driver you try to use through SPI5, and the real one (that does not exist ?).
    When I see your device tree, it means that you have your own driver (or a driver you found somewhere) that has been added to your sources, with the corresponding compatible. If it is not the case, it is not a clock issue, this is just a driver issue.

    2) Concerning spidev, the compatible "linux,spidev" does not exist anymore. You need to look at spidev.c file and you will see the list of compatible supported : 

    #ifdef CONFIG_OF
    static const struct of_device_id spidev_dt_ids[] = {
    	{ .compatible = "rohm,dh2228fv" },
    	{ .compatible = "lineartechnology,ltc2488" },
    	{ .compatible = "ge,achc" },
    	{ .compatible = "semtech,sx1301" },
    	{ .compatible = "lwn,bk4" },
    	{ .compatible = "dh,dhcom-board" },
    	{ .compatible = "menlo,m53cpld" },
    	{},
    };

    I hope these explanations will help you to go forward.

    Kind regards,
    Erwan.

    vsaakianAuthor
    Explorer
    December 8, 2023

    Thanks. I also suspect it is a driver issue. I tried to plug in a driver from ESP32 (esp-hosted-ng), but I am not sure how to do it properly right now. It is "baked" together with image, but I am just not sure what to write in "compatible" field