@@ -9,54 +9,27 @@ reason, the kernel code must instantiate I2C devices explicitly. There are
99several ways to achieve this, depending on the context and requirements.
1010
1111
12- Method 1a : Declare the I2C devices by bus number
13- ------------------------------------------------
12+ Method 1 : Declare the I2C devices statically
13+ --------------------------------------------
1414
1515This method is appropriate when the I2C bus is a system bus as is the case
16- for many embedded systems. On such systems, each I2C bus has a number
17- which is known in advance. It is thus possible to pre-declare the I2C
18- devices which live on this bus. This is done with an array of struct
19- i2c_board_info which is registered by calling i2c_register_board_info().
16+ for many embedded systems. On such systems, each I2C bus has a number which
17+ is known in advance. It is thus possible to pre-declare the I2C devices
18+ which live on this bus.
2019
21- Example (from omap2 h4)::
20+ This information is provided to the kernel in a different way on different
21+ architectures: device tree, ACPI or board files.
2222
23- static struct i2c_board_info h4_i2c_board_info[] __initdata = {
24- {
25- I2C_BOARD_INFO("isp1301_omap", 0x2d),
26- .irq = OMAP_GPIO_IRQ(125),
27- },
28- { /* EEPROM on mainboard */
29- I2C_BOARD_INFO("24c01", 0x52),
30- .platform_data = &m24c01,
31- },
32- { /* EEPROM on cpu card */
33- I2C_BOARD_INFO("24c01", 0x57),
34- .platform_data = &m24c01,
35- },
36- };
37-
38- static void __init omap_h4_init(void)
39- {
40- (...)
41- i2c_register_board_info(1, h4_i2c_board_info,
42- ARRAY_SIZE(h4_i2c_board_info));
43- (...)
44- }
45-
46- The above code declares 3 devices on I2C bus 1, including their respective
47- addresses and custom data needed by their drivers. When the I2C bus in
48- question is registered, the I2C devices will be instantiated automatically
49- by i2c-core.
23+ When the I2C bus in question is registered, the I2C devices will be
24+ instantiated automatically by i2c-core. The devices will be automatically
25+ unbound and destroyed when the I2C bus they sit on goes away (if ever).
5026
51- The devices will be automatically unbound and destroyed when the I2C bus
52- they sit on goes away (if ever.)
5327
28+ Declare the I2C devices via devicetree
29+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5430
55- Method 1b: Declare the I2C devices via devicetree
56- -------------------------------------------------
57-
58- This method has the same implications as method 1a. The declaration of I2C
59- devices is here done via devicetree as subnodes of the master controller.
31+ On platforms using devicetree, the declaration of I2C devices is done in
32+ subnodes of the master controller.
6033
6134Example::
6235
@@ -82,13 +55,51 @@ additional properties which might be needed to set up the device, please refer
8255to its devicetree documentation in Documentation/devicetree/bindings/.
8356
8457
85- Method 1c: Declare the I2C devices via ACPI
86- -------------------------------------------
58+ Declare the I2C devices via ACPI
59+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
8760
8861ACPI can also describe I2C devices. There is special documentation for this
8962which is currently located at :doc: `../firmware-guide/acpi/enumeration `.
9063
9164
65+ Declare the I2C devices in board files
66+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
67+
68+ In many embedded architectures, devicetree has replaced the old hardware
69+ description based on board files, but the latter are still used in old
70+ code. Instantiating I2C devices via board files is done with an array of
71+ struct i2c_board_info which is registered by calling
72+ i2c_register_board_info().
73+
74+ Example (from omap2 h4)::
75+
76+ static struct i2c_board_info h4_i2c_board_info[] __initdata = {
77+ {
78+ I2C_BOARD_INFO("isp1301_omap", 0x2d),
79+ .irq = OMAP_GPIO_IRQ(125),
80+ },
81+ { /* EEPROM on mainboard */
82+ I2C_BOARD_INFO("24c01", 0x52),
83+ .platform_data = &m24c01,
84+ },
85+ { /* EEPROM on cpu card */
86+ I2C_BOARD_INFO("24c01", 0x57),
87+ .platform_data = &m24c01,
88+ },
89+ };
90+
91+ static void __init omap_h4_init(void)
92+ {
93+ (...)
94+ i2c_register_board_info(1, h4_i2c_board_info,
95+ ARRAY_SIZE(h4_i2c_board_info));
96+ (...)
97+ }
98+
99+ The above code declares 3 devices on I2C bus 1, including their respective
100+ addresses and custom data needed by their drivers.
101+
102+
92103Method 2: Instantiate the devices explicitly
93104--------------------------------------------
94105
0 commit comments