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.

Linux/PROCESSOR-SDK-AM335X: Accessing I2C from User Space got error.

Part Number: PROCESSOR-SDK-AM335X
Other Parts Discussed in Thread: AM3352

Tool/software: Linux

Hi,

I am using am3352 with SDK 5.0.0.15. Two chips are connected to I2c. ADC 0x4C is accessible and EEPROM 0x51 is not. 

My dts is as following:

                i2c0: i2c@44e0b000 {

                        compatible = "ti,omap4-i2c";

                        #address-cells = <1>;

                        #size-cells = <0>;

                        ti,hwmods = "i2c1";

                        reg = <0x44e0b000 0x1000>;

                        interrupts = <70>;

                        status = "disabled";

                };

        i2c0_pins: pinmux_i2c0_pins {

                pinctrl-single,pins = <

                        AM33XX_IOPAD(0x988, PIN_INPUT_PULLUP | MUX_MODE0)      

                        AM33XX_IOPAD(0x98c, PIN_INPUT_PULLUP | MUX_MODE0)      

                >;

        };

&i2c0 {

        pinctrl-names = "default";

        pinctrl-0 = <&i2c0_pins>;

        status = "okay";

        clock-frequency = <400000>;

        U14_adc: U14_adc@4C {

                reg = <0x4C>;

        };

        /*system eeprom*/

        U21_24c512: U21_24c512@51 {

                reg = <0x51>;

        };

};

When I did:

>devmem2 0x44e0b000  (The control register of i2c0)

/dev/mem opened.[  760.481821] Unhandled fault: external abort on non-linefetch (0x1018) at 0xb6f1b000

[  760.490741] pgd = c1e5c000

[  760.493460] [b6f1b000] *pgd=81d12831, *pte=44e0b303, *ppte=44e0ba33

Memory mapped at address 0xb6f1b000.

Bus error (core dumped)

I tried i2c tools

root@am335x-evm:~# i2cdetect -r 0                                                                                                                 

WARNING! This program can confuse your I2C bus, cause data loss and worse!                                                                        

I will probe file /dev/i2c-0 using read byte commands.                                                                                            

I will probe address range 0x03-0x77.                                                                                                             

Continue? [Y/n] y                                                                                                                                 

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f                                                                                               

00:          -- -- -- -- -- -- -- -- -- -- -- -- --                                                                                               

10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --                                                                                               

20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --                                                                                               

30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --                                                                                               

40: -- -- -- -- -- -- -- -- -- -- -- -- 4c -- -- --                                                                                               

50: -- UU -- -- -- -- -- -- -- -- -- -- -- -- -- --                                                                                               

60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --                                                                                               

70: -- -- -- -- -- -- -- --                                                                                                                       

root@am335x-evm:~# i2cset 0 0x51 0xf 0xf                                                                                                          

Error: Could not set address to 0x51: Device or resource busy                                                                                     

root@am335x-evm:~# i2cset 0 0x4c 0xf 0xf                                                                                                         

WARNING! This program can confuse your I2C bus, cause data loss and worse!                                                                        

I will write to device file /dev/i2c-0, chip address 0x4c, data address                                                                           

0x0f, data 0x0f, mode byte.                                                                                                                       

Continue? [Y/n] y                                                                                                                                 

root@am335x-evm:~# cd /sys/bus/i2c/devices/                                                                                                       

0-0050/ 0-0051/ i2c-0/                                                                                                                            

root@am335x-evm:~# cd /sys/bus/i2c/devices/i2c-0/                                                                                                

0-0050/    0-0051/    device/    i2c-dev/   of_node/   power/     subsystem/

I also tried 

open(/dev/i2c-0,O_RWDR)

open is successful, but when read/write(fd, data, count)  got I2C Error.

Can anybody help me to find the problem?