srishan
Hi Sri Shan,
The clock for the I2C module is disabled from the Driver. To access I2C MemoryMap register, first of all, you need to enable Clock for the I2C Module.
That is not a legitimate way to access physical memory from userspace. To Read/Write the I2C MemoryMap Register you have to use Linux Driver. if you want to read those register from userspace then you have to create SYSFS entry in the Linux kernel, which will Communicate the Linux Driver from the userspace.
The below-attached file is the driver file in which I2C Clock is Enabled, and the SYSFS entry to read the I2C MemoryMap Register from the userspace.
you have to Replace below driver with your driver in the driver/i2c/busses/i2c-imx.c. this will Enable the I2C Clock. and By following bellow command you can read I2C MemoryMap Register.
| To find a i2c_show entry from sysfs |
|---|
root@imx6ull14x14evk:/# find /sys/ -name "i2c_show" /sys/devices/platform/soc/2100000.aips-bus/21a0000.i2c/i2c_show /sys/devices/platform/soc/2100000.aips-bus/21a4000.i2c/i2c_show |
| To read register value from I2C driver |
|---|
| root@imx6ull14x14evk:/# cat /sys/devices/platform/soc/2100000.aips-bus/21a0000.i2c/i2c_show |
Above command will call the i2c_show function which will enable I2C clock and then print I2C Memorymap Register.
Once you run Above Command after that you are able to read those Register with devmem2.c
| To read I2C register using devmem2.c |
|---|
| root@imx6ull14x14evk:/# devmem2 0x21A0008 h |
NOTE:- all the I2C register are 16-bits if you try to read those register as 32-bit then it will crash your kernel or restart your kernel.
----------------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
----------------------------------------------------------------------------------------------------------------------------