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.h112
1 files changed, 20 insertions, 92 deletions
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index 57d41b0abce..419ab546b26 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -110,7 +110,7 @@ extern s32 i2c_smbus_write_i2c_block_data(struct i2c_client *client,
110 * @driver: Device driver model driver 110 * @driver: Device driver model driver
111 * @id_table: List of I2C devices supported by this driver 111 * @id_table: List of I2C devices supported by this driver
112 * @detect: Callback for device detection 112 * @detect: Callback for device detection
113 * @address_data: The I2C addresses to probe, ignore or force (for detect) 113 * @address_data: The I2C addresses to probe (for detect)
114 * @clients: List of detected clients we created (for i2c-core use only) 114 * @clients: List of detected clients we created (for i2c-core use only)
115 * 115 *
116 * The driver.owner field should be set to the module owner of this driver. 116 * The driver.owner field should be set to the module owner of this driver.
@@ -338,8 +338,7 @@ struct i2c_adapter {
338 void *algo_data; 338 void *algo_data;
339 339
340 /* data fields that are valid for all devices */ 340 /* data fields that are valid for all devices */
341 u8 level; /* nesting level for lockdep */ 341 struct rt_mutex bus_lock;
342 struct mutex bus_lock;
343 342
344 int timeout; /* in jiffies */ 343 int timeout; /* in jiffies */
345 int retries; 344 int retries;
@@ -361,6 +360,24 @@ static inline void i2c_set_adapdata(struct i2c_adapter *dev, void *data)
361 dev_set_drvdata(&dev->dev, data); 360 dev_set_drvdata(&dev->dev, data);
362} 361}
363 362
363/**
364 * i2c_lock_adapter - Prevent access to an I2C bus segment
365 * @adapter: Target I2C bus segment
366 */
367static inline void i2c_lock_adapter(struct i2c_adapter *adapter)
368{
369 rt_mutex_lock(&adapter->bus_lock);
370}
371
372/**
373 * i2c_unlock_adapter - Reauthorize access to an I2C bus segment
374 * @adapter: Target I2C bus segment
375 */
376static inline void i2c_unlock_adapter(struct i2c_adapter *adapter)
377{
378 rt_mutex_unlock(&adapter->bus_lock);
379}
380
364/*flags for the client struct: */ 381/*flags for the client struct: */
365#define I2C_CLIENT_PEC 0x04 /* Use Packet Error Checking */ 382#define I2C_CLIENT_PEC 0x04 /* Use Packet Error Checking */
366#define I2C_CLIENT_TEN 0x10 /* we have a ten bit chip address */ 383#define I2C_CLIENT_TEN 0x10 /* we have a ten bit chip address */
@@ -380,9 +397,6 @@ static inline void i2c_set_adapdata(struct i2c_adapter *dev, void *data)
380 */ 397 */
381struct i2c_client_address_data { 398struct i2c_client_address_data {
382 const unsigned short *normal_i2c; 399 const unsigned short *normal_i2c;
383 const unsigned short *probe;
384 const unsigned short *ignore;
385 const unsigned short * const *forces;
386}; 400};
387 401
388/* Internal numbers to terminate lists */ 402/* Internal numbers to terminate lists */
@@ -596,134 +610,48 @@ union i2c_smbus_data {
596 module_param_array(var, short, &var##_num, 0); \ 610 module_param_array(var, short, &var##_num, 0); \
597 MODULE_PARM_DESC(var, desc) 611 MODULE_PARM_DESC(var, desc)
598 612
599#define I2C_CLIENT_MODULE_PARM_FORCE(name) \
600I2C_CLIENT_MODULE_PARM(force_##name, \
601 "List of adapter,address pairs which are " \
602 "unquestionably assumed to contain a `" \
603 # name "' chip")
604
605
606#define I2C_CLIENT_INSMOD_COMMON \ 613#define I2C_CLIENT_INSMOD_COMMON \
607I2C_CLIENT_MODULE_PARM(probe, "List of adapter,address pairs to scan " \
608 "additionally"); \
609I2C_CLIENT_MODULE_PARM(ignore, "List of adapter,address pairs not to " \
610 "scan"); \
611static const struct i2c_client_address_data addr_data = { \ 614static const struct i2c_client_address_data addr_data = { \
612 .normal_i2c = normal_i2c, \ 615 .normal_i2c = normal_i2c, \
613 .probe = probe, \
614 .ignore = ignore, \
615 .forces = forces, \
616} 616}
617 617
618#define I2C_CLIENT_FORCE_TEXT \
619 "List of adapter,address pairs to boldly assume to be present"
620
621/* These are the ones you want to use in your own drivers. Pick the one 618/* These are the ones you want to use in your own drivers. Pick the one
622 which matches the number of devices the driver differenciates between. */ 619 which matches the number of devices the driver differenciates between. */
623#define I2C_CLIENT_INSMOD \ 620#define I2C_CLIENT_INSMOD \
624I2C_CLIENT_MODULE_PARM(force, I2C_CLIENT_FORCE_TEXT); \
625static const unsigned short * const forces[] = { force, NULL }; \
626I2C_CLIENT_INSMOD_COMMON 621I2C_CLIENT_INSMOD_COMMON
627 622
628#define I2C_CLIENT_INSMOD_1(chip1) \ 623#define I2C_CLIENT_INSMOD_1(chip1) \
629enum chips { any_chip, chip1 }; \ 624enum chips { any_chip, chip1 }; \
630I2C_CLIENT_MODULE_PARM(force, I2C_CLIENT_FORCE_TEXT); \
631I2C_CLIENT_MODULE_PARM_FORCE(chip1); \
632static const unsigned short * const forces[] = { force, \
633 force_##chip1, NULL }; \
634I2C_CLIENT_INSMOD_COMMON 625I2C_CLIENT_INSMOD_COMMON
635 626
636#define I2C_CLIENT_INSMOD_2(chip1, chip2) \ 627#define I2C_CLIENT_INSMOD_2(chip1, chip2) \
637enum chips { any_chip, chip1, chip2 }; \ 628enum chips { any_chip, chip1, chip2 }; \
638I2C_CLIENT_MODULE_PARM(force, I2C_CLIENT_FORCE_TEXT); \
639I2C_CLIENT_MODULE_PARM_FORCE(chip1); \
640I2C_CLIENT_MODULE_PARM_FORCE(chip2); \
641static const unsigned short * const forces[] = { force, \
642 force_##chip1, force_##chip2, NULL }; \
643I2C_CLIENT_INSMOD_COMMON 629I2C_CLIENT_INSMOD_COMMON
644 630
645#define I2C_CLIENT_INSMOD_3(chip1, chip2, chip3) \ 631#define I2C_CLIENT_INSMOD_3(chip1, chip2, chip3) \
646enum chips { any_chip, chip1, chip2, chip3 }; \ 632enum chips { any_chip, chip1, chip2, chip3 }; \
647I2C_CLIENT_MODULE_PARM(force, I2C_CLIENT_FORCE_TEXT); \
648I2C_CLIENT_MODULE_PARM_FORCE(chip1); \
649I2C_CLIENT_MODULE_PARM_FORCE(chip2); \
650I2C_CLIENT_MODULE_PARM_FORCE(chip3); \
651static const unsigned short * const forces[] = { force, \
652 force_##chip1, force_##chip2, force_##chip3, NULL }; \
653I2C_CLIENT_INSMOD_COMMON 633I2C_CLIENT_INSMOD_COMMON
654 634
655#define I2C_CLIENT_INSMOD_4(chip1, chip2, chip3, chip4) \ 635#define I2C_CLIENT_INSMOD_4(chip1, chip2, chip3, chip4) \
656enum chips { any_chip, chip1, chip2, chip3, chip4 }; \ 636enum chips { any_chip, chip1, chip2, chip3, chip4 }; \
657I2C_CLIENT_MODULE_PARM(force, I2C_CLIENT_FORCE_TEXT); \
658I2C_CLIENT_MODULE_PARM_FORCE(chip1); \
659I2C_CLIENT_MODULE_PARM_FORCE(chip2); \
660I2C_CLIENT_MODULE_PARM_FORCE(chip3); \
661I2C_CLIENT_MODULE_PARM_FORCE(chip4); \
662static const unsigned short * const forces[] = { force, \
663 force_##chip1, force_##chip2, force_##chip3, \
664 force_##chip4, NULL}; \
665I2C_CLIENT_INSMOD_COMMON 637I2C_CLIENT_INSMOD_COMMON
666 638
667#define I2C_CLIENT_INSMOD_5(chip1, chip2, chip3, chip4, chip5) \ 639#define I2C_CLIENT_INSMOD_5(chip1, chip2, chip3, chip4, chip5) \
668enum chips { any_chip, chip1, chip2, chip3, chip4, chip5 }; \ 640enum chips { any_chip, chip1, chip2, chip3, chip4, chip5 }; \
669I2C_CLIENT_MODULE_PARM(force, I2C_CLIENT_FORCE_TEXT); \
670I2C_CLIENT_MODULE_PARM_FORCE(chip1); \
671I2C_CLIENT_MODULE_PARM_FORCE(chip2); \
672I2C_CLIENT_MODULE_PARM_FORCE(chip3); \
673I2C_CLIENT_MODULE_PARM_FORCE(chip4); \
674I2C_CLIENT_MODULE_PARM_FORCE(chip5); \
675static const unsigned short * const forces[] = { force, \
676 force_##chip1, force_##chip2, force_##chip3, \
677 force_##chip4, force_##chip5, NULL }; \
678I2C_CLIENT_INSMOD_COMMON 641I2C_CLIENT_INSMOD_COMMON
679 642
680#define I2C_CLIENT_INSMOD_6(chip1, chip2, chip3, chip4, chip5, chip6) \ 643#define I2C_CLIENT_INSMOD_6(chip1, chip2, chip3, chip4, chip5, chip6) \
681enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6 }; \ 644enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6 }; \
682I2C_CLIENT_MODULE_PARM(force, I2C_CLIENT_FORCE_TEXT); \
683I2C_CLIENT_MODULE_PARM_FORCE(chip1); \
684I2C_CLIENT_MODULE_PARM_FORCE(chip2); \
685I2C_CLIENT_MODULE_PARM_FORCE(chip3); \
686I2C_CLIENT_MODULE_PARM_FORCE(chip4); \
687I2C_CLIENT_MODULE_PARM_FORCE(chip5); \
688I2C_CLIENT_MODULE_PARM_FORCE(chip6); \
689static const unsigned short * const forces[] = { force, \
690 force_##chip1, force_##chip2, force_##chip3, \
691 force_##chip4, force_##chip5, force_##chip6, NULL }; \
692I2C_CLIENT_INSMOD_COMMON 645I2C_CLIENT_INSMOD_COMMON
693 646
694#define I2C_CLIENT_INSMOD_7(chip1, chip2, chip3, chip4, chip5, chip6, chip7) \ 647#define I2C_CLIENT_INSMOD_7(chip1, chip2, chip3, chip4, chip5, chip6, chip7) \
695enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6, \ 648enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6, \
696 chip7 }; \ 649 chip7 }; \
697I2C_CLIENT_MODULE_PARM(force, I2C_CLIENT_FORCE_TEXT); \
698I2C_CLIENT_MODULE_PARM_FORCE(chip1); \
699I2C_CLIENT_MODULE_PARM_FORCE(chip2); \
700I2C_CLIENT_MODULE_PARM_FORCE(chip3); \
701I2C_CLIENT_MODULE_PARM_FORCE(chip4); \
702I2C_CLIENT_MODULE_PARM_FORCE(chip5); \
703I2C_CLIENT_MODULE_PARM_FORCE(chip6); \
704I2C_CLIENT_MODULE_PARM_FORCE(chip7); \
705static const unsigned short * const forces[] = { force, \
706 force_##chip1, force_##chip2, force_##chip3, \
707 force_##chip4, force_##chip5, force_##chip6, \
708 force_##chip7, NULL }; \
709I2C_CLIENT_INSMOD_COMMON 650I2C_CLIENT_INSMOD_COMMON
710 651
711#define I2C_CLIENT_INSMOD_8(chip1, chip2, chip3, chip4, chip5, chip6, chip7, chip8) \ 652#define I2C_CLIENT_INSMOD_8(chip1, chip2, chip3, chip4, chip5, chip6, chip7, chip8) \
712enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6, \ 653enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6, \
713 chip7, chip8 }; \ 654 chip7, chip8 }; \
714I2C_CLIENT_MODULE_PARM(force, I2C_CLIENT_FORCE_TEXT); \
715I2C_CLIENT_MODULE_PARM_FORCE(chip1); \
716I2C_CLIENT_MODULE_PARM_FORCE(chip2); \
717I2C_CLIENT_MODULE_PARM_FORCE(chip3); \
718I2C_CLIENT_MODULE_PARM_FORCE(chip4); \
719I2C_CLIENT_MODULE_PARM_FORCE(chip5); \
720I2C_CLIENT_MODULE_PARM_FORCE(chip6); \
721I2C_CLIENT_MODULE_PARM_FORCE(chip7); \
722I2C_CLIENT_MODULE_PARM_FORCE(chip8); \
723static const unsigned short * const forces[] = { force, \
724 force_##chip1, force_##chip2, force_##chip3, \
725 force_##chip4, force_##chip5, force_##chip6, \
726 force_##chip7, force_##chip8, NULL }; \
727I2C_CLIENT_INSMOD_COMMON 655I2C_CLIENT_INSMOD_COMMON
728#endif /* __KERNEL__ */ 656#endif /* __KERNEL__ */
729#endif /* _LINUX_I2C_H */ 657#endif /* _LINUX_I2C_H */