This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

How to enable MCSPI clk in kernel?

Hello,

I am trying to enable start mcspi on AM57xx. I have modified device tree and pin muxing for that. After that much of modification I am able to see the spi devices in /dev directory.

But I have noticed that the SPI clock is not enabled in kernel. Value of CM_L4PER_MCSPI4_CLKCTRL register is 0x30000. So could anyone please let me know how can I enable the MCSPI clock in kernel? I am looking for, where in kernel I have to modify and what I need to change?

I am using SDK v2.0.0.0

  • Hi,

    Can you share your dts SPI node?

    Have you tried writing/reading to/from dev/spidevx.x? You can use the test application located in Documentation/spi/spidev_test.c.

    Best Regards,
    Yordan
  • Hello Yordan,
    Below is my spi node in dts file.

    mcspi4_pins: mcspi4_pins {
    pinctrl-single,pins = <
    0x350 (PIN_OUTPUT | MUX_MODE2) /*mcasp5_axr1.spi4_cs0*/
    0x34C (PIN_OUTPUT | MUX_MODE2) /*mcasp5_axr0.spi4_d0*/
    0x348 (PIN_INPUT | MUX_MODE2) /*mcasp5_fsx.spi4_d1*/
    0x344 (PIN_INPUT | MUX_MODE2) /*mcasp5_aclkx.spi4_clk*/
    >;
    };

    &mcspi4 {
    pinctrl-names = "default";
    pinctrl-0 = <&mcspi4_pins>;
    status = "okay";
    spidev@0 {
    compatible = "linux, spidev";
    spi-max-frequency = <48000000>;
    reg = <0x0>;
    status = "okay";
    };
    };

    I have tried to read/write on spi device as per the example. But unfortunately I can not see any transactions on SPI signals. So I have verified clk control register and its value is 0x30000, as mentioned in my first post.
  • Hello,
    Is there any update on this thread?
  • Hi,

    Change:

     compatible = "linux, spidev";

    to

     compatible = "rohm,dh2228fv"

    Or modify the spidev driver, adding:

      static const struct of_device_id spidev_dt_ids[] = {

         { .compatible = "rohm,dh2228fv" },

         { .compatible = "linux,spidev"},

           {},

    }

    Best Regards,

    Yordan

  • Hello Yordan,
    I have already modified Linux driver, after that modification only I can see spidev in /dev directory. My problem is after probe, I have noticed in kernel log, that somehow mcspi gets disabled. After kernel boot, I am not able to access the SPI registers also, using devmem2 utility.
    Thanks & Regards,

    Rakesh Modi
  • Hi,

    I did test this on my AM57xx beagle x15.

    I muxed mcspi4 on expansion P17

     P17_37 -> mmc3_dat4.spi4_clk

     P17_35-> mmc3_dat5.spi4_d1

     P17_38 ->mmc3_dat6.spi4_d0

     P17_6    ->mmc3_dat7.spi4_cs0

    I added the following in am57xx-beagle-x15.dts:

    mcspi4_pins: mcspi4_pins{

                 pinctrl-single,pins = <

                           0x394 (PIN_INPUT_PULLUP | MANUAL_MODE | MUX_MODE1) /*mmc3_dat4.spi4_clk*/

                           0x398 (PIN_INPUT_PULLUP | MANUAL_MODE | MUX_MODE1) /*mmc3_dat5.spi4_d1*/

                           0x39C (PIN_OUTPUT_PULLUP | MANUAL_MODE | MUX_MODE1) /*mmc3_dat6.spi4_d0*/

                           0x3A0 (PIN_OUTPUT_PULLUP | MANUAL_MODE | MUX_MODE1) /*mmc3_dat7.spi4_cs0*/

                 >;

    };

    &mcspi4 {
           status = "okay";
           pinctrl-names = "default";
           pinctrl-0 = <&mcspi4_pins>;
           spidev@4 {
                  spi-max-frequency = <24000000>;
                  reg = <0>;
                  compatible = "rohm,dh2228fv";
           };
    };

    As a result i saw /dev/spidev1.0 (not sure why its enumerated as 1.0, since i point 4.0, but this is not the issue here). 

    After booting the board indeed the spi4 clock was disabled and I could read mcspi4 registers with devmem2:    

    root@am57xx-evm:~# devmem2 0x4A009808
    /dev/mem opened.
    Memory mapped at address 0xb6f8f000.
    Read at address 0x4A009808 (0xb6f8f808): 0x00030000

    However, when I try to write on the spi4 using /dev/spidev1.0, I could see spi4_clk toggle.  I probed only spi4_clk, because the expansions are not comfortable for probing all the spi pins; I used 

    root@am57xx-evm:/dev# echo "DEADBEEF" > spidev1.0 

    The result was: 

    So to summarize, indeed MCPSI4 module is disabled after device bootup. But, as you can see from the scope screen above, device is activate as soon as you open /dev/spidev1.0 for read/write (root@am57xx-evm:/dev# echo "DEADBEEF" > spidev1.0 ). 

    Best Regards, 
    Yordan

  • Hi Yordan,
    Thanks for your reply. I have found that in pinmux I was not adding PULLUP option and that was only the reason why my SPI was not working. Thanks for your all kind of helps.