This source file includes following definitions.
- i2c_master_recv
- i2c_master_recv_dmasafe
- i2c_master_send
- i2c_master_send_dmasafe
- i2c_smbus_read_word_swapped
- i2c_smbus_write_word_swapped
- kobj_to_i2c_client
- i2c_get_clientdata
- i2c_set_clientdata
- i2c_slave_event
- i2c_detect_slave_mode
- i2c_register_board_info
- i2c_get_adapdata
- i2c_set_adapdata
- i2c_parent_is_i2c_adapter
- i2c_lock_bus
- i2c_trylock_bus
- i2c_unlock_bus
- i2c_mark_adapter_suspended
- i2c_mark_adapter_resumed
- i2c_get_functionality
- i2c_check_functionality
- i2c_check_quirks
- i2c_adapter_id
- i2c_8bit_addr_from_msg
- of_find_i2c_device_by_node
- of_find_i2c_adapter_by_node
- of_get_i2c_adapter_by_node
- i2c_of_match_device
- of_i2c_get_board_info
- i2c_acpi_get_i2c_resource
- i2c_acpi_find_bus_speed
- i2c_acpi_new_device
- i2c_acpi_find_adapter_by_handle
1
2
3
4
5
6
7
8
9
10 #ifndef _LINUX_I2C_H
11 #define _LINUX_I2C_H
12
13 #include <linux/acpi.h>
14 #include <linux/mod_devicetable.h>
15 #include <linux/device.h>
16 #include <linux/sched.h>
17 #include <linux/mutex.h>
18 #include <linux/rtmutex.h>
19 #include <linux/irqdomain.h>
20 #include <linux/of.h>
21 #include <linux/swab.h>
22 #include <uapi/linux/i2c.h>
23
24 extern struct bus_type i2c_bus_type;
25 extern struct device_type i2c_adapter_type;
26 extern struct device_type i2c_client_type;
27
28
29
30 struct i2c_msg;
31 struct i2c_algorithm;
32 struct i2c_adapter;
33 struct i2c_client;
34 struct i2c_driver;
35 struct i2c_device_identity;
36 union i2c_smbus_data;
37 struct i2c_board_info;
38 enum i2c_slave_event;
39 typedef int (*i2c_slave_cb_t)(struct i2c_client *client,
40 enum i2c_slave_event event, u8 *val);
41
42 struct module;
43 struct property_entry;
44
45 #if IS_ENABLED(CONFIG_I2C)
46
47
48
49
50
51
52
53 extern int i2c_transfer_buffer_flags(const struct i2c_client *client,
54 char *buf, int count, u16 flags);
55
56
57
58
59
60
61
62
63
64 static inline int i2c_master_recv(const struct i2c_client *client,
65 char *buf, int count)
66 {
67 return i2c_transfer_buffer_flags(client, buf, count, I2C_M_RD);
68 };
69
70
71
72
73
74
75
76
77
78
79 static inline int i2c_master_recv_dmasafe(const struct i2c_client *client,
80 char *buf, int count)
81 {
82 return i2c_transfer_buffer_flags(client, buf, count,
83 I2C_M_RD | I2C_M_DMA_SAFE);
84 };
85
86
87
88
89
90
91
92
93
94 static inline int i2c_master_send(const struct i2c_client *client,
95 const char *buf, int count)
96 {
97 return i2c_transfer_buffer_flags(client, (char *)buf, count, 0);
98 };
99
100
101
102
103
104
105
106
107
108
109 static inline int i2c_master_send_dmasafe(const struct i2c_client *client,
110 const char *buf, int count)
111 {
112 return i2c_transfer_buffer_flags(client, (char *)buf, count,
113 I2C_M_DMA_SAFE);
114 };
115
116
117
118 extern int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
119 int num);
120
121 extern int __i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
122 int num);
123
124
125
126
127
128
129 s32 i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr,
130 unsigned short flags, char read_write, u8 command,
131 int protocol, union i2c_smbus_data *data);
132
133
134 s32 __i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr,
135 unsigned short flags, char read_write, u8 command,
136 int protocol, union i2c_smbus_data *data);
137
138
139
140
141 extern s32 i2c_smbus_read_byte(const struct i2c_client *client);
142 extern s32 i2c_smbus_write_byte(const struct i2c_client *client, u8 value);
143 extern s32 i2c_smbus_read_byte_data(const struct i2c_client *client,
144 u8 command);
145 extern s32 i2c_smbus_write_byte_data(const struct i2c_client *client,
146 u8 command, u8 value);
147 extern s32 i2c_smbus_read_word_data(const struct i2c_client *client,
148 u8 command);
149 extern s32 i2c_smbus_write_word_data(const struct i2c_client *client,
150 u8 command, u16 value);
151
152 static inline s32
153 i2c_smbus_read_word_swapped(const struct i2c_client *client, u8 command)
154 {
155 s32 value = i2c_smbus_read_word_data(client, command);
156
157 return (value < 0) ? value : swab16(value);
158 }
159
160 static inline s32
161 i2c_smbus_write_word_swapped(const struct i2c_client *client,
162 u8 command, u16 value)
163 {
164 return i2c_smbus_write_word_data(client, command, swab16(value));
165 }
166
167
168 extern s32 i2c_smbus_read_block_data(const struct i2c_client *client,
169 u8 command, u8 *values);
170 extern s32 i2c_smbus_write_block_data(const struct i2c_client *client,
171 u8 command, u8 length, const u8 *values);
172
173 extern s32 i2c_smbus_read_i2c_block_data(const struct i2c_client *client,
174 u8 command, u8 length, u8 *values);
175 extern s32 i2c_smbus_write_i2c_block_data(const struct i2c_client *client,
176 u8 command, u8 length,
177 const u8 *values);
178 extern s32
179 i2c_smbus_read_i2c_block_data_or_emulated(const struct i2c_client *client,
180 u8 command, u8 length, u8 *values);
181 int i2c_get_device_id(const struct i2c_client *client,
182 struct i2c_device_identity *id);
183 #endif
184
185
186
187
188
189
190
191 struct i2c_device_identity {
192 u16 manufacturer_id;
193 #define I2C_DEVICE_ID_NXP_SEMICONDUCTORS 0
194 #define I2C_DEVICE_ID_NXP_SEMICONDUCTORS_1 1
195 #define I2C_DEVICE_ID_NXP_SEMICONDUCTORS_2 2
196 #define I2C_DEVICE_ID_NXP_SEMICONDUCTORS_3 3
197 #define I2C_DEVICE_ID_RAMTRON_INTERNATIONAL 4
198 #define I2C_DEVICE_ID_ANALOG_DEVICES 5
199 #define I2C_DEVICE_ID_STMICROELECTRONICS 6
200 #define I2C_DEVICE_ID_ON_SEMICONDUCTOR 7
201 #define I2C_DEVICE_ID_SPRINTEK_CORPORATION 8
202 #define I2C_DEVICE_ID_ESPROS_PHOTONICS_AG 9
203 #define I2C_DEVICE_ID_FUJITSU_SEMICONDUCTOR 10
204 #define I2C_DEVICE_ID_FLIR 11
205 #define I2C_DEVICE_ID_O2MICRO 12
206 #define I2C_DEVICE_ID_ATMEL 13
207 #define I2C_DEVICE_ID_NONE 0xffff
208 u16 part_id;
209 u8 die_revision;
210 };
211
212 enum i2c_alert_protocol {
213 I2C_PROTOCOL_SMBUS_ALERT,
214 I2C_PROTOCOL_SMBUS_HOST_NOTIFY,
215 };
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253 struct i2c_driver {
254 unsigned int class;
255
256
257 int (*probe)(struct i2c_client *client, const struct i2c_device_id *id);
258 int (*remove)(struct i2c_client *client);
259
260
261
262
263 int (*probe_new)(struct i2c_client *client);
264
265
266 void (*shutdown)(struct i2c_client *client);
267
268
269
270
271
272
273
274
275 void (*alert)(struct i2c_client *client, enum i2c_alert_protocol protocol,
276 unsigned int data);
277
278
279
280
281 int (*command)(struct i2c_client *client, unsigned int cmd, void *arg);
282
283 struct device_driver driver;
284 const struct i2c_device_id *id_table;
285
286
287 int (*detect)(struct i2c_client *client, struct i2c_board_info *info);
288 const unsigned short *address_list;
289 struct list_head clients;
290
291 bool disable_i2c_core_irq_mapping;
292 };
293 #define to_i2c_driver(d) container_of(d, struct i2c_driver, driver)
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313 struct i2c_client {
314 unsigned short flags;
315 #define I2C_CLIENT_PEC 0x04
316 #define I2C_CLIENT_TEN 0x10
317
318 #define I2C_CLIENT_SLAVE 0x20
319 #define I2C_CLIENT_HOST_NOTIFY 0x40
320 #define I2C_CLIENT_WAKE 0x80
321 #define I2C_CLIENT_SCCB 0x9000
322
323
324 unsigned short addr;
325
326
327 char name[I2C_NAME_SIZE];
328 struct i2c_adapter *adapter;
329 struct device dev;
330 int init_irq;
331 int irq;
332 struct list_head detected;
333 #if IS_ENABLED(CONFIG_I2C_SLAVE)
334 i2c_slave_cb_t slave_cb;
335 #endif
336 };
337 #define to_i2c_client(d) container_of(d, struct i2c_client, dev)
338
339 extern struct i2c_client *i2c_verify_client(struct device *dev);
340 extern struct i2c_adapter *i2c_verify_adapter(struct device *dev);
341 extern const struct i2c_device_id *i2c_match_id(const struct i2c_device_id *id,
342 const struct i2c_client *client);
343
344 static inline struct i2c_client *kobj_to_i2c_client(struct kobject *kobj)
345 {
346 struct device * const dev = container_of(kobj, struct device, kobj);
347 return to_i2c_client(dev);
348 }
349
350 static inline void *i2c_get_clientdata(const struct i2c_client *dev)
351 {
352 return dev_get_drvdata(&dev->dev);
353 }
354
355 static inline void i2c_set_clientdata(struct i2c_client *dev, void *data)
356 {
357 dev_set_drvdata(&dev->dev, data);
358 }
359
360
361
362 #if IS_ENABLED(CONFIG_I2C_SLAVE)
363 enum i2c_slave_event {
364 I2C_SLAVE_READ_REQUESTED,
365 I2C_SLAVE_WRITE_REQUESTED,
366 I2C_SLAVE_READ_PROCESSED,
367 I2C_SLAVE_WRITE_RECEIVED,
368 I2C_SLAVE_STOP,
369 };
370
371 extern int i2c_slave_register(struct i2c_client *client, i2c_slave_cb_t slave_cb);
372 extern int i2c_slave_unregister(struct i2c_client *client);
373 extern bool i2c_detect_slave_mode(struct device *dev);
374
375 static inline int i2c_slave_event(struct i2c_client *client,
376 enum i2c_slave_event event, u8 *val)
377 {
378 return client->slave_cb(client, event, val);
379 }
380 #else
381 static inline bool i2c_detect_slave_mode(struct device *dev) { return false; }
382 #endif
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409 struct i2c_board_info {
410 char type[I2C_NAME_SIZE];
411 unsigned short flags;
412 unsigned short addr;
413 const char *dev_name;
414 void *platform_data;
415 struct device_node *of_node;
416 struct fwnode_handle *fwnode;
417 const struct property_entry *properties;
418 const struct resource *resources;
419 unsigned int num_resources;
420 int irq;
421 };
422
423
424
425
426
427
428
429
430
431
432
433 #define I2C_BOARD_INFO(dev_type, dev_addr) \
434 .type = dev_type, .addr = (dev_addr)
435
436
437 #if IS_ENABLED(CONFIG_I2C)
438
439
440
441
442 extern struct i2c_client *
443 i2c_new_device(struct i2c_adapter *adap, struct i2c_board_info const *info);
444
445 extern struct i2c_client *
446 i2c_new_client_device(struct i2c_adapter *adap, struct i2c_board_info const *info);
447
448
449
450
451
452
453
454 extern struct i2c_client *
455 i2c_new_probed_device(struct i2c_adapter *adap,
456 struct i2c_board_info *info,
457 unsigned short const *addr_list,
458 int (*probe)(struct i2c_adapter *adap, unsigned short addr));
459
460
461 extern int i2c_probe_func_quick_read(struct i2c_adapter *adap, unsigned short addr);
462
463
464
465
466 extern struct i2c_client *
467 i2c_new_dummy(struct i2c_adapter *adap, u16 address);
468
469 extern struct i2c_client *
470 i2c_new_dummy_device(struct i2c_adapter *adapter, u16 address);
471
472 extern struct i2c_client *
473 devm_i2c_new_dummy_device(struct device *dev, struct i2c_adapter *adap, u16 address);
474
475 extern struct i2c_client *
476 i2c_new_ancillary_device(struct i2c_client *client,
477 const char *name,
478 u16 default_addr);
479
480 extern void i2c_unregister_device(struct i2c_client *client);
481 #endif
482
483
484
485
486
487 #ifdef CONFIG_I2C_BOARDINFO
488 extern int
489 i2c_register_board_info(int busnum, struct i2c_board_info const *info,
490 unsigned n);
491 #else
492 static inline int
493 i2c_register_board_info(int busnum, struct i2c_board_info const *info,
494 unsigned n)
495 {
496 return 0;
497 }
498 #endif
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526 struct i2c_algorithm {
527
528
529
530
531
532
533
534
535
536 int (*master_xfer)(struct i2c_adapter *adap, struct i2c_msg *msgs,
537 int num);
538 int (*master_xfer_atomic)(struct i2c_adapter *adap,
539 struct i2c_msg *msgs, int num);
540 int (*smbus_xfer)(struct i2c_adapter *adap, u16 addr,
541 unsigned short flags, char read_write,
542 u8 command, int size, union i2c_smbus_data *data);
543 int (*smbus_xfer_atomic)(struct i2c_adapter *adap, u16 addr,
544 unsigned short flags, char read_write,
545 u8 command, int size, union i2c_smbus_data *data);
546
547
548 u32 (*functionality)(struct i2c_adapter *adap);
549
550 #if IS_ENABLED(CONFIG_I2C_SLAVE)
551 int (*reg_slave)(struct i2c_client *client);
552 int (*unreg_slave)(struct i2c_client *client);
553 #endif
554 };
555
556
557
558
559
560
561
562
563
564 struct i2c_lock_operations {
565 void (*lock_bus)(struct i2c_adapter *adapter, unsigned int flags);
566 int (*trylock_bus)(struct i2c_adapter *adapter, unsigned int flags);
567 void (*unlock_bus)(struct i2c_adapter *adapter, unsigned int flags);
568 };
569
570
571
572
573
574
575
576
577
578
579 struct i2c_timings {
580 u32 bus_freq_hz;
581 u32 scl_rise_ns;
582 u32 scl_fall_ns;
583 u32 scl_int_delay_ns;
584 u32 sda_fall_ns;
585 u32 sda_hold_ns;
586 };
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611 struct i2c_bus_recovery_info {
612 int (*recover_bus)(struct i2c_adapter *adap);
613
614 int (*get_scl)(struct i2c_adapter *adap);
615 void (*set_scl)(struct i2c_adapter *adap, int val);
616 int (*get_sda)(struct i2c_adapter *adap);
617 void (*set_sda)(struct i2c_adapter *adap, int val);
618 int (*get_bus_free)(struct i2c_adapter *adap);
619
620 void (*prepare_recovery)(struct i2c_adapter *adap);
621 void (*unprepare_recovery)(struct i2c_adapter *adap);
622
623
624 struct gpio_desc *scl_gpiod;
625 struct gpio_desc *sda_gpiod;
626 };
627
628 int i2c_recover_bus(struct i2c_adapter *adap);
629
630
631 int i2c_generic_scl_recovery(struct i2c_adapter *adap);
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654 struct i2c_adapter_quirks {
655 u64 flags;
656 int max_num_msgs;
657 u16 max_write_len;
658 u16 max_read_len;
659 u16 max_comb_1st_msg_len;
660 u16 max_comb_2nd_msg_len;
661 };
662
663
664 #define I2C_AQ_COMB BIT(0)
665
666 #define I2C_AQ_COMB_WRITE_FIRST BIT(1)
667
668 #define I2C_AQ_COMB_READ_SECOND BIT(2)
669
670 #define I2C_AQ_COMB_SAME_ADDR BIT(3)
671
672 #define I2C_AQ_COMB_WRITE_THEN_READ (I2C_AQ_COMB | I2C_AQ_COMB_WRITE_FIRST | \
673 I2C_AQ_COMB_READ_SECOND | I2C_AQ_COMB_SAME_ADDR)
674
675 #define I2C_AQ_NO_CLK_STRETCH BIT(4)
676
677 #define I2C_AQ_NO_ZERO_LEN_READ BIT(5)
678 #define I2C_AQ_NO_ZERO_LEN_WRITE BIT(6)
679 #define I2C_AQ_NO_ZERO_LEN (I2C_AQ_NO_ZERO_LEN_READ | I2C_AQ_NO_ZERO_LEN_WRITE)
680
681
682
683
684
685 struct i2c_adapter {
686 struct module *owner;
687 unsigned int class;
688 const struct i2c_algorithm *algo;
689 void *algo_data;
690
691
692 const struct i2c_lock_operations *lock_ops;
693 struct rt_mutex bus_lock;
694 struct rt_mutex mux_lock;
695
696 int timeout;
697 int retries;
698 struct device dev;
699 unsigned long locked_flags;
700 #define I2C_ALF_IS_SUSPENDED 0
701 #define I2C_ALF_SUSPEND_REPORTED 1
702
703 int nr;
704 char name[48];
705 struct completion dev_released;
706
707 struct mutex userspace_clients_lock;
708 struct list_head userspace_clients;
709
710 struct i2c_bus_recovery_info *bus_recovery_info;
711 const struct i2c_adapter_quirks *quirks;
712
713 struct irq_domain *host_notify_domain;
714 };
715 #define to_i2c_adapter(d) container_of(d, struct i2c_adapter, dev)
716
717 static inline void *i2c_get_adapdata(const struct i2c_adapter *adap)
718 {
719 return dev_get_drvdata(&adap->dev);
720 }
721
722 static inline void i2c_set_adapdata(struct i2c_adapter *adap, void *data)
723 {
724 dev_set_drvdata(&adap->dev, data);
725 }
726
727 static inline struct i2c_adapter *
728 i2c_parent_is_i2c_adapter(const struct i2c_adapter *adapter)
729 {
730 #if IS_ENABLED(CONFIG_I2C_MUX)
731 struct device *parent = adapter->dev.parent;
732
733 if (parent != NULL && parent->type == &i2c_adapter_type)
734 return to_i2c_adapter(parent);
735 else
736 #endif
737 return NULL;
738 }
739
740 int i2c_for_each_dev(void *data, int (*fn)(struct device *dev, void *data));
741
742
743 #define I2C_LOCK_ROOT_ADAPTER BIT(0)
744 #define I2C_LOCK_SEGMENT BIT(1)
745
746
747
748
749
750
751
752 static inline void
753 i2c_lock_bus(struct i2c_adapter *adapter, unsigned int flags)
754 {
755 adapter->lock_ops->lock_bus(adapter, flags);
756 }
757
758
759
760
761
762
763
764
765
766 static inline int
767 i2c_trylock_bus(struct i2c_adapter *adapter, unsigned int flags)
768 {
769 return adapter->lock_ops->trylock_bus(adapter, flags);
770 }
771
772
773
774
775
776
777
778 static inline void
779 i2c_unlock_bus(struct i2c_adapter *adapter, unsigned int flags)
780 {
781 adapter->lock_ops->unlock_bus(adapter, flags);
782 }
783
784
785
786
787
788
789
790
791
792
793
794 static inline void i2c_mark_adapter_suspended(struct i2c_adapter *adap)
795 {
796 i2c_lock_bus(adap, I2C_LOCK_ROOT_ADAPTER);
797 set_bit(I2C_ALF_IS_SUSPENDED, &adap->locked_flags);
798 i2c_unlock_bus(adap, I2C_LOCK_ROOT_ADAPTER);
799 }
800
801
802
803
804
805
806
807
808
809 static inline void i2c_mark_adapter_resumed(struct i2c_adapter *adap)
810 {
811 i2c_lock_bus(adap, I2C_LOCK_ROOT_ADAPTER);
812 clear_bit(I2C_ALF_IS_SUSPENDED, &adap->locked_flags);
813 i2c_unlock_bus(adap, I2C_LOCK_ROOT_ADAPTER);
814 }
815
816
817 #define I2C_CLASS_HWMON (1<<0)
818 #define I2C_CLASS_DDC (1<<3)
819 #define I2C_CLASS_SPD (1<<7)
820
821 #define I2C_CLASS_DEPRECATED (1<<8)
822
823
824 #define I2C_CLIENT_END 0xfffeU
825
826
827 #define I2C_ADDRS(addr, addrs...) \
828 ((const unsigned short []){ addr, ## addrs, I2C_CLIENT_END })
829
830
831
832
833
834
835 #if IS_ENABLED(CONFIG_I2C)
836 extern int i2c_add_adapter(struct i2c_adapter *adap);
837 extern void i2c_del_adapter(struct i2c_adapter *adap);
838 extern int i2c_add_numbered_adapter(struct i2c_adapter *adap);
839
840 extern int i2c_register_driver(struct module *owner, struct i2c_driver *driver);
841 extern void i2c_del_driver(struct i2c_driver *driver);
842
843
844 #define i2c_add_driver(driver) \
845 i2c_register_driver(THIS_MODULE, driver)
846
847 extern struct i2c_client *i2c_use_client(struct i2c_client *client);
848 extern void i2c_release_client(struct i2c_client *client);
849
850
851
852 extern void i2c_clients_command(struct i2c_adapter *adap,
853 unsigned int cmd, void *arg);
854
855 extern struct i2c_adapter *i2c_get_adapter(int nr);
856 extern void i2c_put_adapter(struct i2c_adapter *adap);
857 extern unsigned int i2c_adapter_depth(struct i2c_adapter *adapter);
858
859 void i2c_parse_fw_timings(struct device *dev, struct i2c_timings *t, bool use_defaults);
860
861
862 static inline u32 i2c_get_functionality(struct i2c_adapter *adap)
863 {
864 return adap->algo->functionality(adap);
865 }
866
867
868 static inline int i2c_check_functionality(struct i2c_adapter *adap, u32 func)
869 {
870 return (func & i2c_get_functionality(adap)) == func;
871 }
872
873
874
875
876
877
878
879
880 static inline bool i2c_check_quirks(struct i2c_adapter *adap, u64 quirks)
881 {
882 if (!adap->quirks)
883 return false;
884 return (adap->quirks->flags & quirks) == quirks;
885 }
886
887
888 static inline int i2c_adapter_id(struct i2c_adapter *adap)
889 {
890 return adap->nr;
891 }
892
893 static inline u8 i2c_8bit_addr_from_msg(const struct i2c_msg *msg)
894 {
895 return (msg->addr << 1) | (msg->flags & I2C_M_RD ? 1 : 0);
896 }
897
898 u8 *i2c_get_dma_safe_msg_buf(struct i2c_msg *msg, unsigned int threshold);
899 void i2c_put_dma_safe_msg_buf(u8 *buf, struct i2c_msg *msg, bool xferred);
900
901 int i2c_handle_smbus_host_notify(struct i2c_adapter *adap, unsigned short addr);
902
903
904
905
906
907
908
909
910 #define module_i2c_driver(__i2c_driver) \
911 module_driver(__i2c_driver, i2c_add_driver, \
912 i2c_del_driver)
913
914
915
916
917
918
919
920
921
922 #define builtin_i2c_driver(__i2c_driver) \
923 builtin_driver(__i2c_driver, i2c_add_driver)
924
925 #endif
926
927 #if IS_ENABLED(CONFIG_OF)
928
929 extern struct i2c_client *of_find_i2c_device_by_node(struct device_node *node);
930
931
932 extern struct i2c_adapter *of_find_i2c_adapter_by_node(struct device_node *node);
933
934
935 struct i2c_adapter *of_get_i2c_adapter_by_node(struct device_node *node);
936
937 extern const struct of_device_id
938 *i2c_of_match_device(const struct of_device_id *matches,
939 struct i2c_client *client);
940
941 int of_i2c_get_board_info(struct device *dev, struct device_node *node,
942 struct i2c_board_info *info);
943
944 #else
945
946 static inline struct i2c_client *of_find_i2c_device_by_node(struct device_node *node)
947 {
948 return NULL;
949 }
950
951 static inline struct i2c_adapter *of_find_i2c_adapter_by_node(struct device_node *node)
952 {
953 return NULL;
954 }
955
956 static inline struct i2c_adapter *of_get_i2c_adapter_by_node(struct device_node *node)
957 {
958 return NULL;
959 }
960
961 static inline const struct of_device_id
962 *i2c_of_match_device(const struct of_device_id *matches,
963 struct i2c_client *client)
964 {
965 return NULL;
966 }
967
968 static inline int of_i2c_get_board_info(struct device *dev,
969 struct device_node *node,
970 struct i2c_board_info *info)
971 {
972 return -ENOTSUPP;
973 }
974
975 #endif
976
977 struct acpi_resource;
978 struct acpi_resource_i2c_serialbus;
979
980 #if IS_ENABLED(CONFIG_ACPI)
981 bool i2c_acpi_get_i2c_resource(struct acpi_resource *ares,
982 struct acpi_resource_i2c_serialbus **i2c);
983 u32 i2c_acpi_find_bus_speed(struct device *dev);
984 struct i2c_client *i2c_acpi_new_device(struct device *dev, int index,
985 struct i2c_board_info *info);
986 struct i2c_adapter *i2c_acpi_find_adapter_by_handle(acpi_handle handle);
987 #else
988 static inline bool i2c_acpi_get_i2c_resource(struct acpi_resource *ares,
989 struct acpi_resource_i2c_serialbus **i2c)
990 {
991 return false;
992 }
993 static inline u32 i2c_acpi_find_bus_speed(struct device *dev)
994 {
995 return 0;
996 }
997 static inline struct i2c_client *i2c_acpi_new_device(struct device *dev,
998 int index, struct i2c_board_info *info)
999 {
1000 return NULL;
1001 }
1002 static inline struct i2c_adapter *i2c_acpi_find_adapter_by_handle(acpi_handle handle)
1003 {
1004 return NULL;
1005 }
1006 #endif
1007
1008 #endif