diff options
-rw-r--r-- | Documentation/DocBook/kernel-api.tmpl | 55 | ||||
-rw-r--r-- | drivers/i2c/i2c-core.c | 13 | ||||
-rw-r--r-- | include/linux/i2c.h | 11 |
3 files changed, 76 insertions, 3 deletions
diff --git a/Documentation/DocBook/kernel-api.tmpl b/Documentation/DocBook/kernel-api.tmpl index 8c5698a8c2e1..46bcff2849bd 100644 --- a/Documentation/DocBook/kernel-api.tmpl +++ b/Documentation/DocBook/kernel-api.tmpl | |||
@@ -643,6 +643,60 @@ X!Idrivers/video/console/fonts.c | |||
643 | !Edrivers/spi/spi.c | 643 | !Edrivers/spi/spi.c |
644 | </chapter> | 644 | </chapter> |
645 | 645 | ||
646 | <chapter id="i2c"> | ||
647 | <title>I<superscript>2</superscript>C and SMBus Subsystem</title> | ||
648 | |||
649 | <para> | ||
650 | I<superscript>2</superscript>C (or without fancy typography, "I2C") | ||
651 | is an acronym for the "Inter-IC" bus, a simple bus protocol which is | ||
652 | widely used where low data rate communications suffice. | ||
653 | Since it's also a licensed trademark, some vendors use another | ||
654 | name (such as "Two-Wire Interface", TWI) for the same bus. | ||
655 | I2C only needs two signals (SCL for clock, SDA for data), conserving | ||
656 | board real estate and minimizing signal quality issues. | ||
657 | Most I2C devices use seven bit addresses, and bus speeds of up | ||
658 | to 400 kHz; there's a high speed extension (3.4 MHz) that's not yet | ||
659 | found wide use. | ||
660 | I2C is a multi-master bus; open drain signaling is used to | ||
661 | arbitrate between masters, as well as to handshake and to | ||
662 | synchronize clocks from slower clients. | ||
663 | </para> | ||
664 | |||
665 | <para> | ||
666 | The Linux I2C programming interfaces support only the master | ||
667 | side of bus interactions, not the slave side. | ||
668 | The programming interface is structured around two kinds of driver, | ||
669 | and two kinds of device. | ||
670 | An I2C "Adapter Driver" abstracts the controller hardware; it binds | ||
671 | to a physical device (perhaps a PCI device or platform_device) and | ||
672 | exposes a <structname>struct i2c_adapter</structname> representing | ||
673 | each I2C bus segment it manages. | ||
674 | On each I2C bus segment will be I2C devices represented by a | ||
675 | <structname>struct i2c_client</structname>. Those devices will | ||
676 | be bound to a <structname>struct i2c_driver</structname>, | ||
677 | which should follow the standard Linux driver model. | ||
678 | (At this writing, a legacy model is more widely used.) | ||
679 | There are functions to perform various I2C protocol operations; at | ||
680 | this writing all such functions are usable only from task context. | ||
681 | </para> | ||
682 | |||
683 | <para> | ||
684 | The System Management Bus (SMBus) is a sibling protocol. Most SMBus | ||
685 | systems are also I2C conformant. The electrical constraints are | ||
686 | tighter for SMBus, and it standardizes particular protocol messages | ||
687 | and idioms. Controllers that support I2C can also support most | ||
688 | SMBus operations, but SMBus controllers don't support all the protocol | ||
689 | options that an I2C controller will. | ||
690 | There are functions to perform various SMBus protocol operations, | ||
691 | either using I2C primitives or by issuing SMBus commands to | ||
692 | i2c_adapter devices which don't support those I2C operations. | ||
693 | </para> | ||
694 | |||
695 | !Iinclude/linux/i2c.h | ||
696 | !Fdrivers/i2c/i2c-boardinfo.c i2c_register_board_info | ||
697 | !Edrivers/i2c/i2c-core.c | ||
698 | </chapter> | ||
699 | |||
646 | <chapter id="splice"> | 700 | <chapter id="splice"> |
647 | <title>splice API</title> | 701 | <title>splice API</title> |
648 | <para>) | 702 | <para>) |
@@ -654,4 +708,5 @@ X!Idrivers/video/console/fonts.c | |||
654 | !Ffs/splice.c | 708 | !Ffs/splice.c |
655 | </chapter> | 709 | </chapter> |
656 | 710 | ||
711 | |||
657 | </book> | 712 | </book> |
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 435925eba437..cccfa8678245 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c | |||
@@ -207,6 +207,7 @@ EXPORT_SYMBOL_GPL(i2c_bus_type); | |||
207 | * i2c_new_device - instantiate an i2c device for use with a new style driver | 207 | * i2c_new_device - instantiate an i2c device for use with a new style driver |
208 | * @adap: the adapter managing the device | 208 | * @adap: the adapter managing the device |
209 | * @info: describes one I2C device; bus_num is ignored | 209 | * @info: describes one I2C device; bus_num is ignored |
210 | * Context: can sleep | ||
210 | * | 211 | * |
211 | * Create a device to work with a new style i2c driver, where binding is | 212 | * Create a device to work with a new style i2c driver, where binding is |
212 | * handled through driver model probe()/remove() methods. This call is not | 213 | * handled through driver model probe()/remove() methods. This call is not |
@@ -255,6 +256,7 @@ EXPORT_SYMBOL_GPL(i2c_new_device); | |||
255 | /** | 256 | /** |
256 | * i2c_unregister_device - reverse effect of i2c_new_device() | 257 | * i2c_unregister_device - reverse effect of i2c_new_device() |
257 | * @client: value returned from i2c_new_device() | 258 | * @client: value returned from i2c_new_device() |
259 | * Context: can sleep | ||
258 | */ | 260 | */ |
259 | void i2c_unregister_device(struct i2c_client *client) | 261 | void i2c_unregister_device(struct i2c_client *client) |
260 | { | 262 | { |
@@ -379,6 +381,7 @@ out_list: | |||
379 | /** | 381 | /** |
380 | * i2c_add_adapter - declare i2c adapter, use dynamic bus number | 382 | * i2c_add_adapter - declare i2c adapter, use dynamic bus number |
381 | * @adapter: the adapter to add | 383 | * @adapter: the adapter to add |
384 | * Context: can sleep | ||
382 | * | 385 | * |
383 | * This routine is used to declare an I2C adapter when its bus number | 386 | * This routine is used to declare an I2C adapter when its bus number |
384 | * doesn't matter. Examples: for I2C adapters dynamically added by | 387 | * doesn't matter. Examples: for I2C adapters dynamically added by |
@@ -416,6 +419,7 @@ EXPORT_SYMBOL(i2c_add_adapter); | |||
416 | /** | 419 | /** |
417 | * i2c_add_numbered_adapter - declare i2c adapter, use static bus number | 420 | * i2c_add_numbered_adapter - declare i2c adapter, use static bus number |
418 | * @adap: the adapter to register (with adap->nr initialized) | 421 | * @adap: the adapter to register (with adap->nr initialized) |
422 | * Context: can sleep | ||
419 | * | 423 | * |
420 | * This routine is used to declare an I2C adapter when its bus number | 424 | * This routine is used to declare an I2C adapter when its bus number |
421 | * matters. Example: for I2C adapters from system-on-chip CPUs, or | 425 | * matters. Example: for I2C adapters from system-on-chip CPUs, or |
@@ -463,6 +467,14 @@ retry: | |||
463 | } | 467 | } |
464 | EXPORT_SYMBOL_GPL(i2c_add_numbered_adapter); | 468 | EXPORT_SYMBOL_GPL(i2c_add_numbered_adapter); |
465 | 469 | ||
470 | /** | ||
471 | * i2c_del_adapter - unregister I2C adapter | ||
472 | * @adap: the adapter being unregistered | ||
473 | * Context: can sleep | ||
474 | * | ||
475 | * This unregisters an I2C adapter which was previously registered | ||
476 | * by @i2c_add_adapter or @i2c_add_numbered_adapter. | ||
477 | */ | ||
466 | int i2c_del_adapter(struct i2c_adapter *adap) | 478 | int i2c_del_adapter(struct i2c_adapter *adap) |
467 | { | 479 | { |
468 | struct list_head *item, *_n; | 480 | struct list_head *item, *_n; |
@@ -598,6 +610,7 @@ EXPORT_SYMBOL(i2c_register_driver); | |||
598 | /** | 610 | /** |
599 | * i2c_del_driver - unregister I2C driver | 611 | * i2c_del_driver - unregister I2C driver |
600 | * @driver: the driver being unregistered | 612 | * @driver: the driver being unregistered |
613 | * Context: can sleep | ||
601 | */ | 614 | */ |
602 | void i2c_del_driver(struct i2c_driver *driver) | 615 | void i2c_del_driver(struct i2c_driver *driver) |
603 | { | 616 | { |
diff --git a/include/linux/i2c.h b/include/linux/i2c.h index cae7d618030c..a24e267fd189 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h | |||
@@ -150,15 +150,20 @@ struct i2c_driver { | |||
150 | 150 | ||
151 | /** | 151 | /** |
152 | * struct i2c_client - represent an I2C slave device | 152 | * struct i2c_client - represent an I2C slave device |
153 | * @flags: I2C_CLIENT_TEN indicates the device uses a ten bit chip address; | ||
154 | * I2C_CLIENT_PEC indicates it uses SMBus Packet Error Checking | ||
153 | * @addr: Address used on the I2C bus connected to the parent adapter. | 155 | * @addr: Address used on the I2C bus connected to the parent adapter. |
154 | * @name: Indicates the type of the device, usually a chip name that's | 156 | * @name: Indicates the type of the device, usually a chip name that's |
155 | * generic enough to hide second-sourcing and compatible revisions. | 157 | * generic enough to hide second-sourcing and compatible revisions. |
158 | * @adapter: manages the bus segment hosting this I2C device | ||
156 | * @dev: Driver model device node for the slave. | 159 | * @dev: Driver model device node for the slave. |
160 | * @irq: indicates the IRQ generated by this device (if any) | ||
157 | * @driver_name: Identifies new-style driver used with this device; also | 161 | * @driver_name: Identifies new-style driver used with this device; also |
158 | * used as the module name for hotplug/coldplug modprobe support. | 162 | * used as the module name for hotplug/coldplug modprobe support. |
159 | * | 163 | * |
160 | * An i2c_client identifies a single device (i.e. chip) connected to an | 164 | * An i2c_client identifies a single device (i.e. chip) connected to an |
161 | * i2c bus. The behaviour is defined by the routines of the driver. | 165 | * i2c bus. The behaviour exposed to Linux is defined by the driver |
166 | * managing the device. | ||
162 | */ | 167 | */ |
163 | struct i2c_client { | 168 | struct i2c_client { |
164 | unsigned short flags; /* div., see below */ | 169 | unsigned short flags; /* div., see below */ |
@@ -201,7 +206,7 @@ static inline void i2c_set_clientdata (struct i2c_client *dev, void *data) | |||
201 | * @addr: stored in i2c_client.addr | 206 | * @addr: stored in i2c_client.addr |
202 | * @platform_data: stored in i2c_client.dev.platform_data | 207 | * @platform_data: stored in i2c_client.dev.platform_data |
203 | * @irq: stored in i2c_client.irq | 208 | * @irq: stored in i2c_client.irq |
204 | 209 | * | |
205 | * I2C doesn't actually support hardware probing, although controllers and | 210 | * I2C doesn't actually support hardware probing, although controllers and |
206 | * devices may be able to use I2C_SMBUS_QUICK to tell whether or not there's | 211 | * devices may be able to use I2C_SMBUS_QUICK to tell whether or not there's |
207 | * a device at a given address. Drivers commonly need more information than | 212 | * a device at a given address. Drivers commonly need more information than |
@@ -210,7 +215,7 @@ static inline void i2c_set_clientdata (struct i2c_client *dev, void *data) | |||
210 | * i2c_board_info is used to build tables of information listing I2C devices | 215 | * i2c_board_info is used to build tables of information listing I2C devices |
211 | * that are present. This information is used to grow the driver model tree | 216 | * that are present. This information is used to grow the driver model tree |
212 | * for "new style" I2C drivers. For mainboards this is done statically using | 217 | * for "new style" I2C drivers. For mainboards this is done statically using |
213 | * i2c_register_board_info(), where @bus_num represents an adapter that isn't | 218 | * i2c_register_board_info(); bus numbers identify adapters that aren't |
214 | * yet available. For add-on boards, i2c_new_device() does this dynamically | 219 | * yet available. For add-on boards, i2c_new_device() does this dynamically |
215 | * with the adapter already known. | 220 | * with the adapter already known. |
216 | */ | 221 | */ |