Hi
How C developer can get to know to which i2c bus number your device is connected? In linux shell it is easy.
Firstly You must know the i2c address of your device. Let's assume I know. Then I execute:
it returns numbers.
Code:
i2cdetect -r 0
i2cdetect -r 1
i2cdetect -r 2
i2cdetect -r 3
i2cdetect -r 4
and I can found the bus 0,1,2,3 or 4.
The problem is that I need to know the bus in kernel source files before I run linux image. Because the function for registering i2c client forces me to set number - i2c_get_adapter:
Code:
// Setup device
i2c_dev = i2c_get_adapter(n); //n bus number, means i2c-n
i2c_client = i2c_new_device(i2c_dev, board_info);
//in board_info you set device name (it might be whatever) and i2c address of device
//then You can read write through functions, for example:
i2c_smbus_write_byte_data(i2c_client, 0x40, 0);
i2c_smbus_read_byte(i2c_client);
Any idea? Should I try to search something on board schematics?