xref: /minix/minix/drivers/bus/i2c/README.txt (revision 045e0ed3)
1Minix i2c Driver
2================
3
4TODO: this probably belongs on the wiki
5
6Overview
7--------
8
9This is the driver for the i2c bus. It provides the same /dev interface as
10NetBSD and OpenBSD (see dev/i2c/i2c_io.h). It also provides an interface for
11other drivers to access the I2C bus using Minix IPC.
12
13Organization and Layout
14-----------------------
15
16i2c.c					generic i2c bus driver
17arch/					arch specific code
18	earm/				earm specific code
19		omap_i2c.c		AM335X/DM37XX i2c bus driver
20		omap_i2c.h		AM335X/DM37XX function prototypes
21		omap_i2c_registers.h 	AM335X/DM37XX register offsets, etc.
22
23Testing the Code
24----------------
25
26Below are the steps needed to start up the i2c driver instances. Though,
27now they get started at boot in /usr/etc/rc, it's still useful to know if
28you take down the service and need to start it again.
29
30Creating the device files (this is already done automatically, but if not):
31
32cd /dev && MAKEDEV i2c-1 && MAKEDEV i2c-2 && MAKEDEV i2c-3
33
34Starting up the instances:
35
36/sbin/minix-service up /service/i2c -dev /dev/i2c-1 -label i2c.1 -args instance=1
37/sbin/minix-service up /service/i2c -dev /dev/i2c-2 -label i2c.2 -args instance=2
38/sbin/minix-service up /service/i2c -dev /dev/i2c-3 -label i2c.3 -args instance=3
39
40There is an i2cscan program from NetBSD which can detect devices on the bus:
41
42i2cscan -r /dev/i2c-1
43i2cscan -r /dev/i2c-2
44i2cscan -r /dev/i2c-3
45
46Limitations
47-----------
48
49The i2c controllers used in the am335x and the dm37xx do not support zero
50byte transfers. Writing 0 bytes is a common method used to probe the bus
51for devices. Most of the address ranges i2cscan scans are done by this
52method. Therefore, only a subset of devices on the bus will be detected by
53i2cscan (i.e. the devices it detects using the 1 byte read method). See
54the register description for I2C_CNT in the technical reference manuals
55for details about why 0 byte transfers are not allowed.
56
57Developing I2C Device Drivers
58-----------------------------
59
60The driver for the EEPROM (a.k.a. drivers/cat24c256) is the hello world of
61Minix i2c device drivers. It shows how to use the i2cdriver library and
62how to use the bus for reads and writes. commands/eepromread is another
63place to look if you're interested in accessing devices through the /dev
64interface.
65