diff options
Diffstat (limited to 'include/linux/i2c.h')
-rw-r--r-- | include/linux/i2c.h | 112 |
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 | */ | ||
367 | static 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 | */ | ||
376 | static 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 | */ |
381 | struct i2c_client_address_data { | 398 | struct 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) \ | ||
600 | I2C_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 \ |
607 | I2C_CLIENT_MODULE_PARM(probe, "List of adapter,address pairs to scan " \ | ||
608 | "additionally"); \ | ||
609 | I2C_CLIENT_MODULE_PARM(ignore, "List of adapter,address pairs not to " \ | ||
610 | "scan"); \ | ||
611 | static const struct i2c_client_address_data addr_data = { \ | 614 | static 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 \ |
624 | I2C_CLIENT_MODULE_PARM(force, I2C_CLIENT_FORCE_TEXT); \ | ||
625 | static const unsigned short * const forces[] = { force, NULL }; \ | ||
626 | I2C_CLIENT_INSMOD_COMMON | 621 | I2C_CLIENT_INSMOD_COMMON |
627 | 622 | ||
628 | #define I2C_CLIENT_INSMOD_1(chip1) \ | 623 | #define I2C_CLIENT_INSMOD_1(chip1) \ |
629 | enum chips { any_chip, chip1 }; \ | 624 | enum chips { any_chip, chip1 }; \ |
630 | I2C_CLIENT_MODULE_PARM(force, I2C_CLIENT_FORCE_TEXT); \ | ||
631 | I2C_CLIENT_MODULE_PARM_FORCE(chip1); \ | ||
632 | static const unsigned short * const forces[] = { force, \ | ||
633 | force_##chip1, NULL }; \ | ||
634 | I2C_CLIENT_INSMOD_COMMON | 625 | I2C_CLIENT_INSMOD_COMMON |
635 | 626 | ||
636 | #define I2C_CLIENT_INSMOD_2(chip1, chip2) \ | 627 | #define I2C_CLIENT_INSMOD_2(chip1, chip2) \ |
637 | enum chips { any_chip, chip1, chip2 }; \ | 628 | enum chips { any_chip, chip1, chip2 }; \ |
638 | I2C_CLIENT_MODULE_PARM(force, I2C_CLIENT_FORCE_TEXT); \ | ||
639 | I2C_CLIENT_MODULE_PARM_FORCE(chip1); \ | ||
640 | I2C_CLIENT_MODULE_PARM_FORCE(chip2); \ | ||
641 | static const unsigned short * const forces[] = { force, \ | ||
642 | force_##chip1, force_##chip2, NULL }; \ | ||
643 | I2C_CLIENT_INSMOD_COMMON | 629 | I2C_CLIENT_INSMOD_COMMON |
644 | 630 | ||
645 | #define I2C_CLIENT_INSMOD_3(chip1, chip2, chip3) \ | 631 | #define I2C_CLIENT_INSMOD_3(chip1, chip2, chip3) \ |
646 | enum chips { any_chip, chip1, chip2, chip3 }; \ | 632 | enum chips { any_chip, chip1, chip2, chip3 }; \ |
647 | I2C_CLIENT_MODULE_PARM(force, I2C_CLIENT_FORCE_TEXT); \ | ||
648 | I2C_CLIENT_MODULE_PARM_FORCE(chip1); \ | ||
649 | I2C_CLIENT_MODULE_PARM_FORCE(chip2); \ | ||
650 | I2C_CLIENT_MODULE_PARM_FORCE(chip3); \ | ||
651 | static const unsigned short * const forces[] = { force, \ | ||
652 | force_##chip1, force_##chip2, force_##chip3, NULL }; \ | ||
653 | I2C_CLIENT_INSMOD_COMMON | 633 | I2C_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) \ |
656 | enum chips { any_chip, chip1, chip2, chip3, chip4 }; \ | 636 | enum chips { any_chip, chip1, chip2, chip3, chip4 }; \ |
657 | I2C_CLIENT_MODULE_PARM(force, I2C_CLIENT_FORCE_TEXT); \ | ||
658 | I2C_CLIENT_MODULE_PARM_FORCE(chip1); \ | ||
659 | I2C_CLIENT_MODULE_PARM_FORCE(chip2); \ | ||
660 | I2C_CLIENT_MODULE_PARM_FORCE(chip3); \ | ||
661 | I2C_CLIENT_MODULE_PARM_FORCE(chip4); \ | ||
662 | static const unsigned short * const forces[] = { force, \ | ||
663 | force_##chip1, force_##chip2, force_##chip3, \ | ||
664 | force_##chip4, NULL}; \ | ||
665 | I2C_CLIENT_INSMOD_COMMON | 637 | I2C_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) \ |
668 | enum chips { any_chip, chip1, chip2, chip3, chip4, chip5 }; \ | 640 | enum chips { any_chip, chip1, chip2, chip3, chip4, chip5 }; \ |
669 | I2C_CLIENT_MODULE_PARM(force, I2C_CLIENT_FORCE_TEXT); \ | ||
670 | I2C_CLIENT_MODULE_PARM_FORCE(chip1); \ | ||
671 | I2C_CLIENT_MODULE_PARM_FORCE(chip2); \ | ||
672 | I2C_CLIENT_MODULE_PARM_FORCE(chip3); \ | ||
673 | I2C_CLIENT_MODULE_PARM_FORCE(chip4); \ | ||
674 | I2C_CLIENT_MODULE_PARM_FORCE(chip5); \ | ||
675 | static const unsigned short * const forces[] = { force, \ | ||
676 | force_##chip1, force_##chip2, force_##chip3, \ | ||
677 | force_##chip4, force_##chip5, NULL }; \ | ||
678 | I2C_CLIENT_INSMOD_COMMON | 641 | I2C_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) \ |
681 | enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6 }; \ | 644 | enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6 }; \ |
682 | I2C_CLIENT_MODULE_PARM(force, I2C_CLIENT_FORCE_TEXT); \ | ||
683 | I2C_CLIENT_MODULE_PARM_FORCE(chip1); \ | ||
684 | I2C_CLIENT_MODULE_PARM_FORCE(chip2); \ | ||
685 | I2C_CLIENT_MODULE_PARM_FORCE(chip3); \ | ||
686 | I2C_CLIENT_MODULE_PARM_FORCE(chip4); \ | ||
687 | I2C_CLIENT_MODULE_PARM_FORCE(chip5); \ | ||
688 | I2C_CLIENT_MODULE_PARM_FORCE(chip6); \ | ||
689 | static const unsigned short * const forces[] = { force, \ | ||
690 | force_##chip1, force_##chip2, force_##chip3, \ | ||
691 | force_##chip4, force_##chip5, force_##chip6, NULL }; \ | ||
692 | I2C_CLIENT_INSMOD_COMMON | 645 | I2C_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) \ |
695 | enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6, \ | 648 | enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6, \ |
696 | chip7 }; \ | 649 | chip7 }; \ |
697 | I2C_CLIENT_MODULE_PARM(force, I2C_CLIENT_FORCE_TEXT); \ | ||
698 | I2C_CLIENT_MODULE_PARM_FORCE(chip1); \ | ||
699 | I2C_CLIENT_MODULE_PARM_FORCE(chip2); \ | ||
700 | I2C_CLIENT_MODULE_PARM_FORCE(chip3); \ | ||
701 | I2C_CLIENT_MODULE_PARM_FORCE(chip4); \ | ||
702 | I2C_CLIENT_MODULE_PARM_FORCE(chip5); \ | ||
703 | I2C_CLIENT_MODULE_PARM_FORCE(chip6); \ | ||
704 | I2C_CLIENT_MODULE_PARM_FORCE(chip7); \ | ||
705 | static const unsigned short * const forces[] = { force, \ | ||
706 | force_##chip1, force_##chip2, force_##chip3, \ | ||
707 | force_##chip4, force_##chip5, force_##chip6, \ | ||
708 | force_##chip7, NULL }; \ | ||
709 | I2C_CLIENT_INSMOD_COMMON | 650 | I2C_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) \ |
712 | enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6, \ | 653 | enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6, \ |
713 | chip7, chip8 }; \ | 654 | chip7, chip8 }; \ |
714 | I2C_CLIENT_MODULE_PARM(force, I2C_CLIENT_FORCE_TEXT); \ | ||
715 | I2C_CLIENT_MODULE_PARM_FORCE(chip1); \ | ||
716 | I2C_CLIENT_MODULE_PARM_FORCE(chip2); \ | ||
717 | I2C_CLIENT_MODULE_PARM_FORCE(chip3); \ | ||
718 | I2C_CLIENT_MODULE_PARM_FORCE(chip4); \ | ||
719 | I2C_CLIENT_MODULE_PARM_FORCE(chip5); \ | ||
720 | I2C_CLIENT_MODULE_PARM_FORCE(chip6); \ | ||
721 | I2C_CLIENT_MODULE_PARM_FORCE(chip7); \ | ||
722 | I2C_CLIENT_MODULE_PARM_FORCE(chip8); \ | ||
723 | static 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 }; \ | ||
727 | I2C_CLIENT_INSMOD_COMMON | 655 | I2C_CLIENT_INSMOD_COMMON |
728 | #endif /* __KERNEL__ */ | 656 | #endif /* __KERNEL__ */ |
729 | #endif /* _LINUX_I2C_H */ | 657 | #endif /* _LINUX_I2C_H */ |