Lines Matching full:i2c

1 Usually, i2c devices are controlled by a kernel driver. But it is also
3 the /dev interface. You need to load module i2c-dev for this.
5 Each registered i2c adapter gets a number, counting from 0. You can
6 examine /sys/class/i2c-dev/ to see what number corresponds to which adapter.
8 i2c adapters present on your system at a given time. i2cdetect is part of
9 the i2c-tools package.
11 I2C device files are character device files with major device number 89
13 explained above. They should be called "i2c-%d" (i2c-0, i2c-1, ...,
14 i2c-10, ...). All 256 minor device numbers are reserved for i2c.
20 So let's say you want to access an i2c adapter from a C program. The
21 first thing to do is "#include <linux/i2c-dev.h>". Please note that
22 there are two files named "i2c-dev.h" out there, one is distributed
24 driver code, the other one is distributed with i2c-tools and is
29 inspect /sys/class/i2c-dev/ or run "i2cdetect -l" to decide this.
39 snprintf(filename, 19, "/dev/i2c-%d", adapter_nr);
49 int addr = 0x40; /* The I2C address */
57 I2C to communicate with your device. SMBus commands are preferred if
67 /* ERROR HANDLING: i2c transaction failed */
72 /* Using I2C Write, equivalent of
78 /* ERROR HANDLING: i2c transaction failed */
81 /* Using I2C Read, equivalent of i2c_smbus_read_byte(file) */
83 /* ERROR HANDLING: i2c transaction failed */
88 Note that only a subset of the I2C and SMBus protocols can be achieved by
143 You can do plain i2c transactions by using read(2) and write(2) calls.
176 when you use the /dev interface to I2C:
178 1* Your program opens /dev/i2c-N and calls ioctl() on it, as described in
181 2* These open() and ioctl() calls are handled by the i2c-dev kernel
182 driver: see i2c-dev.c:i2cdev_open() and i2c-dev.c:i2cdev_ioctl(),
183 respectively. You can think of i2c-dev as a generic I2C chip driver
187 i2c-dev directly. Examples include I2C_SLAVE (set the address of the
192 i2c-dev. Examples include I2C_FUNCS, which queries the I2C adapter
193 functionality using i2c.h:i2c_get_functionality(), and I2C_SMBUS, which
194 performs an SMBus transaction using i2c-core.c:i2c_smbus_xfer().
196 The i2c-dev driver is responsible for checking all the parameters that
198 difference between these calls that came from user-space through i2c-dev
199 and calls that would have been performed by kernel I2C chip drivers
200 directly. This means that I2C bus drivers don't need to implement
203 5* These i2c-core.c/i2c.h functions are wrappers to the actual
204 implementation of your I2C bus driver. Each adapter must declare
206 i2c.h:i2c_get_functionality() calls i2c_adapter.algo->functionality(),
207 while i2c-core.c:i2c_smbus_xfer() calls either
209 i2c-core.c:i2c_smbus_xfer_emulated() which in turn calls
212 After your I2C bus driver has processed these requests, execution runs
213 up the call chain, with almost no processing done, except by i2c-dev to