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