unable to access some imx6ull registers from userspace using memtool or devmem2

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

unable to access some imx6ull registers from userspace using memtool or devmem2

2,643 Views
vemularamavarap
Contributor II

Dear I.MX Community,

 I am using imx6ull for driving led matrix boards(used in railways) through spi interface, there i need to send huge data within a second for 100 times. But i achieved 40 times only through ioctl. So  to improve the performance i need to access the spi registers directly through memtool or devmem2.  But when i try to access spi registers virtual address is creating and then when i try to read the register board is not responding. But when i read the iomuxc (0x020E0000) it is reading successfully. So Please Provide the solution how to read spi registers from user space using memtool(i.e. through mmap) or devmem2 to achieve the required performance.

Below are the examples:

(iomuxc read successfully)

root@colibri-imx6ull:~# devmem2 0x20e0000                                       
/dev/mem opened.                                                                
Memory mapped at address 0x76f23000.                                            
Read at address  0x020E0000 (0x76f23000): 0x00000000

(ecspi1 read fail).

root@colibri-imx6ull:~# devmem2 0x2008000                                       
/dev/mem opened.

*Not Displaying any thing after above statement and board is in hang state.

Kindly do the needful as early as possible.
Eagerly awaiting for your replies 
 Thanks in advance.

Labels (2)
0 Kudos
Reply
11 Replies

2,458 Views
weidong_sun
NXP TechSupport
NXP TechSupport

Hi, vemula,

For all registers that drivers can access , memtool or devmem2 can also access them.

BUT the clock of the module where the register is located must be enabled, otherwise, corresponding registers can't be accessed.

Hope the information is helpful for you.

Have a nice day!

B.R,

Weidong

0 Kudos
Reply

2,458 Views
vemularamavarap
Contributor II

Thanks for reply. But I am new to processors and it's drivers.

So Please Provide how to enable clock for spi module(in spi_imx.c driver) of imx6ull. or Please provide the clock enabled spi driver.

Kindly do the needful as early as possible.

 

0 Kudos
Reply

2,458 Views
weidong_sun
NXP TechSupport
NXP TechSupport

Hi ,

  Add spi node in device tree , setting it's status = "okay".

weidong

0 Kudos
Reply

2,458 Views
vemularamavarap
Contributor II

Hi,

Thanks For Reply.

That i have done and i have verified the spi clock frequency to 30 Mhz and spi data transfer also performed through ioctl system call using inbuilt driver but i am not achieving the performance. so i want to directly access the spi registers through devmem2 or memtool and want to transfer the data to achieve the required performance. But i am not able to access spi registers through memtool or devmem2.

I have Enabled below two SPI.

root@colibri-imx6ull:~# ls /dev/spidev*.*                                       
/dev/spidev0.0  /dev/spidev2.0  

Dts file for Reference:

&ecspi1 {
    status = "okay";

    mcp251x0: mcp251x@0 {
        compatible = "microchip,mcp2515";
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_can_int>;
        reg = <0>;
        clocks = <&clk16m>;
        interrupt-parent = <&gpio2>;
        interrupts = <4 IRQ_TYPE_EDGE_FALLING>;
        spi-max-frequency = <10000000>;
        //status = "okay";
                status = "disabled";
    };

    spidev0: spidev@0 {
        compatible = "toradex,evalspi";
        reg = <0>;
        spi-max-frequency = <60000000>;
        //status = "disabled";
                status = "okay";
    };
};

&ecspi3{
    status = "okay";    
    spidev2: spidev@0 {
        compatible = "toradex,evalspi";
        reg = <0>;
        spi-max-frequency = <60000000>;
        //status = "disabled";
         status = "okay";
    };
};

Kindly do the needful as early as possible.

0 Kudos
Reply

2,458 Views
weidong_sun
NXP TechSupport
NXP TechSupport

Hi,

  The max speed of SPI in i.MX6UL is 52MHz, 60MHz setting is no valid.

weidong

0 Kudos
Reply

2,458 Views
vemularamavarap
Contributor II

Hi,

Even though i have changed SPI max speed to 52 Mhz same result came . unable to access SPI  address(0x2008000) board is hanging.

root@colibri-imx6ull:~# devmem2 0x2008000                                       
/dev/mem opened.

*Not Displaying any thing after above statement and board is in hang state.

Is any thing need to be modified in driver for imx6ull???

Since with imx7d i am able to read SPI Address(0x30630000) :

Log is below:

colibri-imx7-emmc login: root                                                   
Last login: Tue Oct 15 09:18:00 UTC 2019 on ttymxc0                             
root@colibri-imx7-emmc:~# devmem2 0x30630000                                    
/dev/mem opened.                                                                
Memory mapped at address 0x76fb1000.                                            
Read at address  0x30630000 (0x76fb1000): 0x00000000 

Kindly provide the solution.

vara prasad

0 Kudos
Reply

2,458 Views
weidong_sun
NXP TechSupport
NXP TechSupport

Hello vemula,

See below, please!

0x200_8000 register is a read-only register, even if you access it, you can't write data to it.

pastedImage_1.png

pastedImage_2.png

Register is used to receive data, not control register, you don't need to configure it.

Hope the infromation is helpful to you.

Have a nice day!

B.R,

Weidong

0 Kudos
Reply

2,458 Views
vemularamavarap
Contributor II

Hi,

Here My Query is unable to read the read-only register, and unable to read/write the read/write register.

So Please provide the solution how to access it via user space. or Any thing to be modified in driver(spi_imx.c) to access it in user space.

vara prasad

0 Kudos
Reply

2,458 Views
weidong_sun
NXP TechSupport
NXP TechSupport

Hi vemula ,

     For spi driver, by default, it is in suspend mode, when it works, clock will be provided.  If you can try it like this:

COMMENT these funtions like "unprepare clock" . Then try to access register.

 

I am not sure if devmem2  is OK, so use memtool to try it.

Hope the information is helpful to you.

Have a nice day!

B.R,

Weidong

0 Kudos
Reply

2,459 Views
weidong_sun
NXP TechSupport
NXP TechSupport

try to do like this:

----------------------------------------------

diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c

index 91e32291c44e..00e092f2f4ff 100644

--- a/drivers/spi/spi-imx.c

+++ b/drivers/spi/spi-imx.c

@@ -1602,8 +1602,8 @@ spi_imx_unprepare_message(struct spi_master *master, struct spi_message *msg)

 {

        struct spi_imx_data *spi_imx = spi_master_get_devdata(master);

 

-       clk_disable_unprepare(spi_imx->clk_ipg);

-       clk_disable_unprepare(spi_imx->clk_per);

+       // clk_disable_unprepare(spi_imx->clk_ipg);

+       // clk_disable_unprepare(spi_imx->clk_per);

        return 0;

 }

 

@@ -1791,8 +1791,8 @@ static int spi_imx_probe(struct platform_device *pdev)

 

        dev_info(&pdev->dev, "probed\n");

 

-       clk_disable_unprepare(spi_imx->clk_ipg);

-       clk_disable_unprepare(spi_imx->clk_per);

+       // clk_disable_unprepare(spi_imx->clk_ipg);

+       // clk_disable_unprepare(spi_imx->clk_per);

        return ret;

-----------------------------------------

Weidong

0 Kudos
Reply

2,459 Views
vemularamavarap
Contributor II

Thank you Very much, it is working.

0 Kudos
Reply