aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/i2c.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/i2c.h')
-rw-r--r--include/linux/i2c.h126
1 files changed, 56 insertions, 70 deletions
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index a100c9f8eb7c..76014f8f3c60 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -140,7 +140,6 @@ struct i2c_driver {
140 int (*command)(struct i2c_client *client,unsigned int cmd, void *arg); 140 int (*command)(struct i2c_client *client,unsigned int cmd, void *arg);
141 141
142 struct device_driver driver; 142 struct device_driver driver;
143 struct list_head list;
144}; 143};
145#define to_i2c_driver(d) container_of(d, struct i2c_driver, driver) 144#define to_i2c_driver(d) container_of(d, struct i2c_driver, driver)
146 145
@@ -155,12 +154,11 @@ struct i2c_driver {
155 * generic enough to hide second-sourcing and compatible revisions. 154 * generic enough to hide second-sourcing and compatible revisions.
156 * @adapter: manages the bus segment hosting this I2C device 155 * @adapter: manages the bus segment hosting this I2C device
157 * @driver: device's driver, hence pointer to access routines 156 * @driver: device's driver, hence pointer to access routines
158 * @usage_count: counts current number of users of this client
159 * @dev: Driver model device node for the slave. 157 * @dev: Driver model device node for the slave.
160 * @irq: indicates the IRQ generated by this device (if any) 158 * @irq: indicates the IRQ generated by this device (if any)
161 * @driver_name: Identifies new-style driver used with this device; also 159 * @driver_name: Identifies new-style driver used with this device; also
162 * used as the module name for hotplug/coldplug modprobe support. 160 * used as the module name for hotplug/coldplug modprobe support.
163 * @list: list of active/busy clients 161 * @list: list of active/busy clients (DEPRECATED)
164 * @released: used to synchronize client releases & detaches and references 162 * @released: used to synchronize client releases & detaches and references
165 * 163 *
166 * 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
@@ -175,16 +173,16 @@ struct i2c_client {
175 char name[I2C_NAME_SIZE]; 173 char name[I2C_NAME_SIZE];
176 struct i2c_adapter *adapter; /* the adapter we sit on */ 174 struct i2c_adapter *adapter; /* the adapter we sit on */
177 struct i2c_driver *driver; /* and our access routines */ 175 struct i2c_driver *driver; /* and our access routines */
178 int usage_count; /* How many accesses currently */
179 /* to the client */
180 struct device dev; /* the device structure */ 176 struct device dev; /* the device structure */
181 int irq; /* irq issued by device (or -1) */ 177 int irq; /* irq issued by device (or -1) */
182 char driver_name[KOBJ_NAME_LEN]; 178 char driver_name[KOBJ_NAME_LEN];
183 struct list_head list; 179 struct list_head list; /* DEPRECATED */
184 struct completion released; 180 struct completion released;
185}; 181};
186#define to_i2c_client(d) container_of(d, struct i2c_client, dev) 182#define to_i2c_client(d) container_of(d, struct i2c_client, dev)
187 183
184extern struct i2c_client *i2c_verify_client(struct device *dev);
185
188static inline struct i2c_client *kobj_to_i2c_client(struct kobject *kobj) 186static inline struct i2c_client *kobj_to_i2c_client(struct kobject *kobj)
189{ 187{
190 struct device * const dev = container_of(kobj, struct device, kobj); 188 struct device * const dev = container_of(kobj, struct device, kobj);
@@ -261,6 +259,12 @@ i2c_new_probed_device(struct i2c_adapter *adap,
261 struct i2c_board_info *info, 259 struct i2c_board_info *info,
262 unsigned short const *addr_list); 260 unsigned short const *addr_list);
263 261
262/* For devices that use several addresses, use i2c_new_dummy() to make
263 * client handles for the extra addresses.
264 */
265extern struct i2c_client *
266i2c_new_dummy(struct i2c_adapter *adap, u16 address, const char *type);
267
264extern void i2c_unregister_device(struct i2c_client *); 268extern void i2c_unregister_device(struct i2c_client *);
265 269
266/* Mainboard arch_initcall() code should register all its I2C devices. 270/* Mainboard arch_initcall() code should register all its I2C devices.
@@ -319,8 +323,7 @@ struct i2c_adapter {
319 struct device dev; /* the adapter device */ 323 struct device dev; /* the adapter device */
320 324
321 int nr; 325 int nr;
322 struct list_head clients; 326 struct list_head clients; /* DEPRECATED */
323 struct list_head list;
324 char name[48]; 327 char name[48];
325 struct completion dev_released; 328 struct completion dev_released;
326}; 329};
@@ -357,10 +360,10 @@ static inline void i2c_set_adapdata (struct i2c_adapter *dev, void *data)
357 * command line 360 * command line
358 */ 361 */
359struct i2c_client_address_data { 362struct i2c_client_address_data {
360 unsigned short *normal_i2c; 363 const unsigned short *normal_i2c;
361 unsigned short *probe; 364 const unsigned short *probe;
362 unsigned short *ignore; 365 const unsigned short *ignore;
363 unsigned short **forces; 366 const unsigned short * const *forces;
364}; 367};
365 368
366/* Internal numbers to terminate lists */ 369/* Internal numbers to terminate lists */
@@ -389,11 +392,8 @@ static inline int i2c_add_driver(struct i2c_driver *driver)
389extern int i2c_attach_client(struct i2c_client *); 392extern int i2c_attach_client(struct i2c_client *);
390extern int i2c_detach_client(struct i2c_client *); 393extern int i2c_detach_client(struct i2c_client *);
391 394
392/* Should be used to make sure that client-struct is valid and that it 395extern struct i2c_client *i2c_use_client(struct i2c_client *client);
393 is okay to access the i2c-client. 396extern void i2c_release_client(struct i2c_client *client);
394 returns -ENODEV if client has gone in the meantime */
395extern int i2c_use_client(struct i2c_client *);
396extern int i2c_release_client(struct i2c_client *);
397 397
398/* call the i2c_client->command() of all attached clients with 398/* call the i2c_client->command() of all attached clients with
399 * the given arguments */ 399 * the given arguments */
@@ -405,7 +405,7 @@ extern void i2c_clients_command(struct i2c_adapter *adap,
405 * specific address (unless a 'force' matched); 405 * specific address (unless a 'force' matched);
406 */ 406 */
407extern int i2c_probe(struct i2c_adapter *adapter, 407extern int i2c_probe(struct i2c_adapter *adapter,
408 struct i2c_client_address_data *address_data, 408 const struct i2c_client_address_data *address_data,
409 int (*found_proc) (struct i2c_adapter *, int, int)); 409 int (*found_proc) (struct i2c_adapter *, int, int));
410 410
411extern struct i2c_adapter* i2c_get_adapter(int id); 411extern struct i2c_adapter* i2c_get_adapter(int id);
@@ -598,104 +598,93 @@ I2C_CLIENT_MODULE_PARM(probe, "List of adapter,address pairs to scan " \
598 "additionally"); \ 598 "additionally"); \
599I2C_CLIENT_MODULE_PARM(ignore, "List of adapter,address pairs not to " \ 599I2C_CLIENT_MODULE_PARM(ignore, "List of adapter,address pairs not to " \
600 "scan"); \ 600 "scan"); \
601static struct i2c_client_address_data addr_data = { \ 601const static struct i2c_client_address_data addr_data = { \
602 .normal_i2c = normal_i2c, \ 602 .normal_i2c = normal_i2c, \
603 .probe = probe, \ 603 .probe = probe, \
604 .ignore = ignore, \ 604 .ignore = ignore, \
605 .forces = forces, \ 605 .forces = forces, \
606} 606}
607 607
608#define I2C_CLIENT_FORCE_TEXT \
609 "List of adapter,address pairs to boldly assume to be present"
610
608/* These are the ones you want to use in your own drivers. Pick the one 611/* These are the ones you want to use in your own drivers. Pick the one
609 which matches the number of devices the driver differenciates between. */ 612 which matches the number of devices the driver differenciates between. */
610#define I2C_CLIENT_INSMOD \ 613#define I2C_CLIENT_INSMOD \
611 I2C_CLIENT_MODULE_PARM(force, \ 614I2C_CLIENT_MODULE_PARM(force, I2C_CLIENT_FORCE_TEXT); \
612 "List of adapter,address pairs to boldly assume " \ 615static const unsigned short * const forces[] = { force, NULL }; \
613 "to be present"); \
614 static unsigned short *forces[] = { \
615 force, \
616 NULL \
617 }; \
618I2C_CLIENT_INSMOD_COMMON 616I2C_CLIENT_INSMOD_COMMON
619 617
620#define I2C_CLIENT_INSMOD_1(chip1) \ 618#define I2C_CLIENT_INSMOD_1(chip1) \
621enum chips { any_chip, chip1 }; \ 619enum chips { any_chip, chip1 }; \
622I2C_CLIENT_MODULE_PARM(force, "List of adapter,address pairs to " \ 620I2C_CLIENT_MODULE_PARM(force, I2C_CLIENT_FORCE_TEXT); \
623 "boldly assume to be present"); \
624I2C_CLIENT_MODULE_PARM_FORCE(chip1); \ 621I2C_CLIENT_MODULE_PARM_FORCE(chip1); \
625static unsigned short *forces[] = { force, force_##chip1, NULL }; \ 622static const unsigned short * const forces[] = { force, \
623 force_##chip1, NULL }; \
626I2C_CLIENT_INSMOD_COMMON 624I2C_CLIENT_INSMOD_COMMON
627 625
628#define I2C_CLIENT_INSMOD_2(chip1, chip2) \ 626#define I2C_CLIENT_INSMOD_2(chip1, chip2) \
629enum chips { any_chip, chip1, chip2 }; \ 627enum chips { any_chip, chip1, chip2 }; \
630I2C_CLIENT_MODULE_PARM(force, "List of adapter,address pairs to " \ 628I2C_CLIENT_MODULE_PARM(force, I2C_CLIENT_FORCE_TEXT); \
631 "boldly assume to be present"); \
632I2C_CLIENT_MODULE_PARM_FORCE(chip1); \ 629I2C_CLIENT_MODULE_PARM_FORCE(chip1); \
633I2C_CLIENT_MODULE_PARM_FORCE(chip2); \ 630I2C_CLIENT_MODULE_PARM_FORCE(chip2); \
634static unsigned short *forces[] = { force, force_##chip1, \ 631static const unsigned short * const forces[] = { force, \
635 force_##chip2, NULL }; \ 632 force_##chip1, force_##chip2, NULL }; \
636I2C_CLIENT_INSMOD_COMMON 633I2C_CLIENT_INSMOD_COMMON
637 634
638#define I2C_CLIENT_INSMOD_3(chip1, chip2, chip3) \ 635#define I2C_CLIENT_INSMOD_3(chip1, chip2, chip3) \
639enum chips { any_chip, chip1, chip2, chip3 }; \ 636enum chips { any_chip, chip1, chip2, chip3 }; \
640I2C_CLIENT_MODULE_PARM(force, "List of adapter,address pairs to " \ 637I2C_CLIENT_MODULE_PARM(force, I2C_CLIENT_FORCE_TEXT); \
641 "boldly assume to be present"); \
642I2C_CLIENT_MODULE_PARM_FORCE(chip1); \ 638I2C_CLIENT_MODULE_PARM_FORCE(chip1); \
643I2C_CLIENT_MODULE_PARM_FORCE(chip2); \ 639I2C_CLIENT_MODULE_PARM_FORCE(chip2); \
644I2C_CLIENT_MODULE_PARM_FORCE(chip3); \ 640I2C_CLIENT_MODULE_PARM_FORCE(chip3); \
645static unsigned short *forces[] = { force, force_##chip1, \ 641static const unsigned short * const forces[] = { force, \
646 force_##chip2, force_##chip3, \ 642 force_##chip1, force_##chip2, force_##chip3, NULL }; \
647 NULL }; \
648I2C_CLIENT_INSMOD_COMMON 643I2C_CLIENT_INSMOD_COMMON
649 644
650#define I2C_CLIENT_INSMOD_4(chip1, chip2, chip3, chip4) \ 645#define I2C_CLIENT_INSMOD_4(chip1, chip2, chip3, chip4) \
651enum chips { any_chip, chip1, chip2, chip3, chip4 }; \ 646enum chips { any_chip, chip1, chip2, chip3, chip4 }; \
652I2C_CLIENT_MODULE_PARM(force, "List of adapter,address pairs to " \ 647I2C_CLIENT_MODULE_PARM(force, I2C_CLIENT_FORCE_TEXT); \
653 "boldly assume to be present"); \
654I2C_CLIENT_MODULE_PARM_FORCE(chip1); \ 648I2C_CLIENT_MODULE_PARM_FORCE(chip1); \
655I2C_CLIENT_MODULE_PARM_FORCE(chip2); \ 649I2C_CLIENT_MODULE_PARM_FORCE(chip2); \
656I2C_CLIENT_MODULE_PARM_FORCE(chip3); \ 650I2C_CLIENT_MODULE_PARM_FORCE(chip3); \
657I2C_CLIENT_MODULE_PARM_FORCE(chip4); \ 651I2C_CLIENT_MODULE_PARM_FORCE(chip4); \
658static unsigned short *forces[] = { force, force_##chip1, \ 652static const unsigned short * const forces[] = { force, \
659 force_##chip2, force_##chip3, \ 653 force_##chip1, force_##chip2, force_##chip3, \
660 force_##chip4, NULL}; \ 654 force_##chip4, NULL}; \
661I2C_CLIENT_INSMOD_COMMON 655I2C_CLIENT_INSMOD_COMMON
662 656
663#define I2C_CLIENT_INSMOD_5(chip1, chip2, chip3, chip4, chip5) \ 657#define I2C_CLIENT_INSMOD_5(chip1, chip2, chip3, chip4, chip5) \
664enum chips { any_chip, chip1, chip2, chip3, chip4, chip5 }; \ 658enum chips { any_chip, chip1, chip2, chip3, chip4, chip5 }; \
665I2C_CLIENT_MODULE_PARM(force, "List of adapter,address pairs to " \ 659I2C_CLIENT_MODULE_PARM(force, I2C_CLIENT_FORCE_TEXT); \
666 "boldly assume to be present"); \
667I2C_CLIENT_MODULE_PARM_FORCE(chip1); \ 660I2C_CLIENT_MODULE_PARM_FORCE(chip1); \
668I2C_CLIENT_MODULE_PARM_FORCE(chip2); \ 661I2C_CLIENT_MODULE_PARM_FORCE(chip2); \
669I2C_CLIENT_MODULE_PARM_FORCE(chip3); \ 662I2C_CLIENT_MODULE_PARM_FORCE(chip3); \
670I2C_CLIENT_MODULE_PARM_FORCE(chip4); \ 663I2C_CLIENT_MODULE_PARM_FORCE(chip4); \
671I2C_CLIENT_MODULE_PARM_FORCE(chip5); \ 664I2C_CLIENT_MODULE_PARM_FORCE(chip5); \
672static unsigned short *forces[] = { force, force_##chip1, \ 665static const unsigned short * const forces[] = { force, \
673 force_##chip2, force_##chip3, \ 666 force_##chip1, force_##chip2, force_##chip3, \
674 force_##chip4, force_##chip5, \ 667 force_##chip4, force_##chip5, NULL }; \
675 NULL }; \
676I2C_CLIENT_INSMOD_COMMON 668I2C_CLIENT_INSMOD_COMMON
677 669
678#define I2C_CLIENT_INSMOD_6(chip1, chip2, chip3, chip4, chip5, chip6) \ 670#define I2C_CLIENT_INSMOD_6(chip1, chip2, chip3, chip4, chip5, chip6) \
679enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6 }; \ 671enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6 }; \
680I2C_CLIENT_MODULE_PARM(force, "List of adapter,address pairs to " \ 672I2C_CLIENT_MODULE_PARM(force, I2C_CLIENT_FORCE_TEXT); \
681 "boldly assume to be present"); \
682I2C_CLIENT_MODULE_PARM_FORCE(chip1); \ 673I2C_CLIENT_MODULE_PARM_FORCE(chip1); \
683I2C_CLIENT_MODULE_PARM_FORCE(chip2); \ 674I2C_CLIENT_MODULE_PARM_FORCE(chip2); \
684I2C_CLIENT_MODULE_PARM_FORCE(chip3); \ 675I2C_CLIENT_MODULE_PARM_FORCE(chip3); \
685I2C_CLIENT_MODULE_PARM_FORCE(chip4); \ 676I2C_CLIENT_MODULE_PARM_FORCE(chip4); \
686I2C_CLIENT_MODULE_PARM_FORCE(chip5); \ 677I2C_CLIENT_MODULE_PARM_FORCE(chip5); \
687I2C_CLIENT_MODULE_PARM_FORCE(chip6); \ 678I2C_CLIENT_MODULE_PARM_FORCE(chip6); \
688static unsigned short *forces[] = { force, force_##chip1, \ 679static const unsigned short * const forces[] = { force, \
689 force_##chip2, force_##chip3, \ 680 force_##chip1, force_##chip2, force_##chip3, \
690 force_##chip4, force_##chip5, \ 681 force_##chip4, force_##chip5, force_##chip6, NULL }; \
691 force_##chip6, NULL }; \
692I2C_CLIENT_INSMOD_COMMON 682I2C_CLIENT_INSMOD_COMMON
693 683
694#define I2C_CLIENT_INSMOD_7(chip1, chip2, chip3, chip4, chip5, chip6, chip7) \ 684#define I2C_CLIENT_INSMOD_7(chip1, chip2, chip3, chip4, chip5, chip6, chip7) \
695enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6, \ 685enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6, \
696 chip7 }; \ 686 chip7 }; \
697I2C_CLIENT_MODULE_PARM(force, "List of adapter,address pairs to " \ 687I2C_CLIENT_MODULE_PARM(force, I2C_CLIENT_FORCE_TEXT); \
698 "boldly assume to be present"); \
699I2C_CLIENT_MODULE_PARM_FORCE(chip1); \ 688I2C_CLIENT_MODULE_PARM_FORCE(chip1); \
700I2C_CLIENT_MODULE_PARM_FORCE(chip2); \ 689I2C_CLIENT_MODULE_PARM_FORCE(chip2); \
701I2C_CLIENT_MODULE_PARM_FORCE(chip3); \ 690I2C_CLIENT_MODULE_PARM_FORCE(chip3); \
@@ -703,18 +692,16 @@ I2C_CLIENT_MODULE_PARM_FORCE(chip4); \
703I2C_CLIENT_MODULE_PARM_FORCE(chip5); \ 692I2C_CLIENT_MODULE_PARM_FORCE(chip5); \
704I2C_CLIENT_MODULE_PARM_FORCE(chip6); \ 693I2C_CLIENT_MODULE_PARM_FORCE(chip6); \
705I2C_CLIENT_MODULE_PARM_FORCE(chip7); \ 694I2C_CLIENT_MODULE_PARM_FORCE(chip7); \
706static unsigned short *forces[] = { force, force_##chip1, \ 695static const unsigned short * const forces[] = { force, \
707 force_##chip2, force_##chip3, \ 696 force_##chip1, force_##chip2, force_##chip3, \
708 force_##chip4, force_##chip5, \ 697 force_##chip4, force_##chip5, force_##chip6, \
709 force_##chip6, force_##chip7, \ 698 force_##chip7, NULL }; \
710 NULL }; \
711I2C_CLIENT_INSMOD_COMMON 699I2C_CLIENT_INSMOD_COMMON
712 700
713#define I2C_CLIENT_INSMOD_8(chip1, chip2, chip3, chip4, chip5, chip6, chip7, chip8) \ 701#define I2C_CLIENT_INSMOD_8(chip1, chip2, chip3, chip4, chip5, chip6, chip7, chip8) \
714enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6, \ 702enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6, \
715 chip7, chip8 }; \ 703 chip7, chip8 }; \
716I2C_CLIENT_MODULE_PARM(force, "List of adapter,address pairs to " \ 704I2C_CLIENT_MODULE_PARM(force, I2C_CLIENT_FORCE_TEXT); \
717 "boldly assume to be present"); \
718I2C_CLIENT_MODULE_PARM_FORCE(chip1); \ 705I2C_CLIENT_MODULE_PARM_FORCE(chip1); \
719I2C_CLIENT_MODULE_PARM_FORCE(chip2); \ 706I2C_CLIENT_MODULE_PARM_FORCE(chip2); \
720I2C_CLIENT_MODULE_PARM_FORCE(chip3); \ 707I2C_CLIENT_MODULE_PARM_FORCE(chip3); \
@@ -723,11 +710,10 @@ I2C_CLIENT_MODULE_PARM_FORCE(chip5); \
723I2C_CLIENT_MODULE_PARM_FORCE(chip6); \ 710I2C_CLIENT_MODULE_PARM_FORCE(chip6); \
724I2C_CLIENT_MODULE_PARM_FORCE(chip7); \ 711I2C_CLIENT_MODULE_PARM_FORCE(chip7); \
725I2C_CLIENT_MODULE_PARM_FORCE(chip8); \ 712I2C_CLIENT_MODULE_PARM_FORCE(chip8); \
726static unsigned short *forces[] = { force, force_##chip1, \ 713static const unsigned short * const forces[] = { force, \
727 force_##chip2, force_##chip3, \ 714 force_##chip1, force_##chip2, force_##chip3, \
728 force_##chip4, force_##chip5, \ 715 force_##chip4, force_##chip5, force_##chip6, \
729 force_##chip6, force_##chip7, \ 716 force_##chip7, force_##chip8, NULL }; \
730 force_##chip8, NULL }; \
731I2C_CLIENT_INSMOD_COMMON 717I2C_CLIENT_INSMOD_COMMON
732#endif /* __KERNEL__ */ 718#endif /* __KERNEL__ */
733#endif /* _LINUX_I2C_H */ 719#endif /* _LINUX_I2C_H */