Other Parts Discussed in Thread: TPS65217
Tool/software: Linux
Hi
Team
I am trying to test my i2c-omap.c driver on the beagle bone black board
I am using the default driver present
insmod install
[techveda@BBBlack:]# insmod i2c-original.ko
[ 24.326899] tps65217 0-0024: TPS65217 ID 0xe version 1.2
[ 24.333257] omap_i2c 44e0b000.i2c: bus 0 rev0.11 at 400 kHz
[ 24.356118] omap_i2c 4802a000.i2c: bus 1 rev0.11 at 100 kHz
[ 24.373599] omap_i2c 4819c000.i2c: bus 2 rev0.11 at 100 kHz
I am using the following application for testing this
i am Sure the i2c-omap driver is inserted
But when i try to run my applcation i get a timeout error
as below
ERROR: write() failed
[techveda@BBBlack:]# ./i2c50
SUCCESS: open(3) passed
SUCCESS: ioctl(fd, I2C_SLAVE, 0x50>>1) passed
Performing EEPROM Write operation
[ 172.058433] omap_i2c 4in my code in 819c000.i2c: controller timed out
[ 173.098410] omap_i2c 4819c000.i2c: controller timed out
ERROR: write() failed
[techveda@BBBlack:]#
[techveda@BBBlack:]#
Not sure what is wrong as per the patch from the source link
i have modified the delay to 6*1000
KIndly please help me out my application i have attached
Let me know if any another application to be used in case
I just wanna write the bytes to eeprom that is internally present and read back
as from the dtsi file i find the base_eeprom
&i2c2 { pinctrl-names = "default"; pinctrl-0 = <&i2c2_pins>; status = "okay"; clock-frequency = <100000>; cape_eeprom0: cape_eeprom0@54 { compatible = "at,24c256"; reg = <0x54>; #address-cells = <1>; #size-cells = <1>; cape0_data: cape_data@0 { reg = <0 0x100>; }; }; cape_eeprom1: cape_eeprom1@55 { compatible = "at,24c256"; reg = <0x55>; #address-cells = <1>; #size-cells = <1>; cape1_data: cape_data@0 { reg = <0 0x100>; }; }; cape_eeprom2: cape_eeprom2@56 { compatible = "at,24c256"; reg = <0x56>; #address-cells = <1>; #size-cells = <1>;
and my application is like
#include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/ioctl.h> #include <fcntl.h> #include <linux/fs.h> #include <errno.h> #include <string.h> #include <linux/i2c-dev.h> #include <linux/i2c.h> /* chmod 666 /dev/i2c-0 */ int main(void) { // Data to be written to eeprom unsigned char wbuf[17] = {0x00, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F }; unsigned char rbuf[16]; int i2c_addr = 0x54; int status; unsigned short int i; // OPENING I2C DEVICE int fd = open("/dev/i2c-2", O_RDWR); if (fd < 0) { printf("ERROR: open(%d) failed\n", fd); return -1; } printf("\nSUCCESS: open(%d) passed\n", fd); // SETTING EEPROM ADDR status = ioctl(fd, I2C_SLAVE, i2c_addr); if (status < 0) { printf("ERROR: ioctl(fd, I2C_SLAVE, 0x%02X) failed\n", i2c_addr); close(fd); return -1; } printf("\nSUCCESS: ioctl(fd, I2C_SLAVE, 0x%02X>>1) passed\n", i2c_addr); // WRITING TO EEPROM printf ("\nPerforming EEPROM Write operation\n"); write(fd,wbuf,16); sleep(10); //till eeprom completes writes if (write(fd,wbuf,16) != 16) { printf("ERROR: write() failed\n"); close(fd); return -1; } printf("\nSUCCESS: Data written to the EEPROM\n"); // READING FROM EEPROM printf ("\nPerforming EEPROM Read operation\n"); wbuf[0]=0; if(write(fd,wbuf,1)!=1){ printf("ERROR: buffer pointer initialization of read() failed\n"); } if (read(fd,rbuf,16) != 16) { printf("ERROR: read() failed\n"); close(fd); return -1; } for(i = 0; i< 16; i++) printf("ReadBuffer[%d] %d \r\n", i, rbuf[i]); printf("\nSUCCESS: Data READ from the EEPROM\n"); printf("\neerprom test successfull \n"); close(fd); }
kindly let me know what i can try for doing this
Thank you
Deepak R