1#ifndef __LINUX_REGMAP_H
2#define __LINUX_REGMAP_H
3
4
5
6
7
8
9
10
11
12
13
14
15
16#include <linux/list.h>
17#include <linux/rbtree.h>
18#include <linux/delay.h>
19#include <linux/err.h>
20#include <linux/bug.h>
21#include <linux/lockdep.h>
22
23struct module;
24struct device;
25struct i2c_client;
26struct irq_domain;
27struct slim_device;
28struct spi_device;
29struct spmi_device;
30struct regmap;
31struct regmap_range_cfg;
32struct regmap_field;
33struct snd_ac97;
34struct sdw_slave;
35
36
37enum regcache_type {
38 REGCACHE_NONE,
39 REGCACHE_RBTREE,
40 REGCACHE_COMPRESSED,
41 REGCACHE_FLAT,
42};
43
44
45
46
47
48
49
50
51
52
53struct reg_default {
54 unsigned int reg;
55 unsigned int def;
56};
57
58
59
60
61
62
63
64
65
66
67
68struct reg_sequence {
69 unsigned int reg;
70 unsigned int def;
71 unsigned int delay_us;
72};
73
74#define regmap_update_bits(map, reg, mask, val) \
75 regmap_update_bits_base(map, reg, mask, val, NULL, false, false)
76#define regmap_update_bits_async(map, reg, mask, val)\
77 regmap_update_bits_base(map, reg, mask, val, NULL, true, false)
78#define regmap_update_bits_check(map, reg, mask, val, change)\
79 regmap_update_bits_base(map, reg, mask, val, change, false, false)
80#define regmap_update_bits_check_async(map, reg, mask, val, change)\
81 regmap_update_bits_base(map, reg, mask, val, change, true, false)
82
83#define regmap_write_bits(map, reg, mask, val) \
84 regmap_update_bits_base(map, reg, mask, val, NULL, false, true)
85
86#define regmap_field_write(field, val) \
87 regmap_field_update_bits_base(field, ~0, val, NULL, false, false)
88#define regmap_field_force_write(field, val) \
89 regmap_field_update_bits_base(field, ~0, val, NULL, false, true)
90#define regmap_field_update_bits(field, mask, val)\
91 regmap_field_update_bits_base(field, mask, val, NULL, false, false)
92#define regmap_field_force_update_bits(field, mask, val) \
93 regmap_field_update_bits_base(field, mask, val, NULL, false, true)
94
95#define regmap_fields_write(field, id, val) \
96 regmap_fields_update_bits_base(field, id, ~0, val, NULL, false, false)
97#define regmap_fields_force_write(field, id, val) \
98 regmap_fields_update_bits_base(field, id, ~0, val, NULL, false, true)
99#define regmap_fields_update_bits(field, id, mask, val)\
100 regmap_fields_update_bits_base(field, id, mask, val, NULL, false, false)
101#define regmap_fields_force_update_bits(field, id, mask, val) \
102 regmap_fields_update_bits_base(field, id, mask, val, NULL, false, true)
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123#define regmap_read_poll_timeout(map, addr, val, cond, sleep_us, timeout_us) \
124({ \
125 u64 __timeout_us = (timeout_us); \
126 unsigned long __sleep_us = (sleep_us); \
127 ktime_t __timeout = ktime_add_us(ktime_get(), __timeout_us); \
128 int __ret; \
129 might_sleep_if(__sleep_us); \
130 for (;;) { \
131 __ret = regmap_read((map), (addr), &(val)); \
132 if (__ret) \
133 break; \
134 if (cond) \
135 break; \
136 if ((__timeout_us) && \
137 ktime_compare(ktime_get(), __timeout) > 0) { \
138 __ret = regmap_read((map), (addr), &(val)); \
139 break; \
140 } \
141 if (__sleep_us) \
142 usleep_range((__sleep_us >> 2) + 1, __sleep_us); \
143 } \
144 __ret ?: ((cond) ? 0 : -ETIMEDOUT); \
145})
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165#define regmap_field_read_poll_timeout(field, val, cond, sleep_us, timeout_us) \
166({ \
167 u64 __timeout_us = (timeout_us); \
168 unsigned long __sleep_us = (sleep_us); \
169 ktime_t timeout = ktime_add_us(ktime_get(), __timeout_us); \
170 int pollret; \
171 might_sleep_if(__sleep_us); \
172 for (;;) { \
173 pollret = regmap_field_read((field), &(val)); \
174 if (pollret) \
175 break; \
176 if (cond) \
177 break; \
178 if (__timeout_us && ktime_compare(ktime_get(), timeout) > 0) { \
179 pollret = regmap_field_read((field), &(val)); \
180 break; \
181 } \
182 if (__sleep_us) \
183 usleep_range((__sleep_us >> 2) + 1, __sleep_us); \
184 } \
185 pollret ?: ((cond) ? 0 : -ETIMEDOUT); \
186})
187
188#ifdef CONFIG_REGMAP
189
190enum regmap_endian {
191
192 REGMAP_ENDIAN_DEFAULT = 0,
193 REGMAP_ENDIAN_BIG,
194 REGMAP_ENDIAN_LITTLE,
195 REGMAP_ENDIAN_NATIVE,
196};
197
198
199
200
201
202
203
204
205struct regmap_range {
206 unsigned int range_min;
207 unsigned int range_max;
208};
209
210#define regmap_reg_range(low, high) { .range_min = low, .range_max = high, }
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225struct regmap_access_table {
226 const struct regmap_range *yes_ranges;
227 unsigned int n_yes_ranges;
228 const struct regmap_range *no_ranges;
229 unsigned int n_no_ranges;
230};
231
232typedef void (*regmap_lock)(void *);
233typedef void (*regmap_unlock)(void *);
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
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333struct regmap_config {
334 const char *name;
335
336 int reg_bits;
337 int reg_stride;
338 int pad_bits;
339 int val_bits;
340
341 bool (*writeable_reg)(struct device *dev, unsigned int reg);
342 bool (*readable_reg)(struct device *dev, unsigned int reg);
343 bool (*volatile_reg)(struct device *dev, unsigned int reg);
344 bool (*precious_reg)(struct device *dev, unsigned int reg);
345
346 bool disable_locking;
347 regmap_lock lock;
348 regmap_unlock unlock;
349 void *lock_arg;
350
351 int (*reg_read)(void *context, unsigned int reg, unsigned int *val);
352 int (*reg_write)(void *context, unsigned int reg, unsigned int val);
353
354 bool fast_io;
355
356 unsigned int max_register;
357 const struct regmap_access_table *wr_table;
358 const struct regmap_access_table *rd_table;
359 const struct regmap_access_table *volatile_table;
360 const struct regmap_access_table *precious_table;
361 const struct reg_default *reg_defaults;
362 unsigned int num_reg_defaults;
363 enum regcache_type cache_type;
364 const void *reg_defaults_raw;
365 unsigned int num_reg_defaults_raw;
366
367 unsigned long read_flag_mask;
368 unsigned long write_flag_mask;
369 bool zero_flag_mask;
370
371 bool use_single_rw;
372 bool can_multi_write;
373
374 enum regmap_endian reg_format_endian;
375 enum regmap_endian val_format_endian;
376
377 const struct regmap_range_cfg *ranges;
378 unsigned int num_ranges;
379
380 bool use_hwlock;
381 unsigned int hwlock_id;
382 unsigned int hwlock_mode;
383};
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405struct regmap_range_cfg {
406 const char *name;
407
408
409 unsigned int range_min;
410 unsigned int range_max;
411
412
413 unsigned int selector_reg;
414 unsigned int selector_mask;
415 int selector_shift;
416
417
418 unsigned int window_start;
419 unsigned int window_len;
420};
421
422struct regmap_async;
423
424typedef int (*regmap_hw_write)(void *context, const void *data,
425 size_t count);
426typedef int (*regmap_hw_gather_write)(void *context,
427 const void *reg, size_t reg_len,
428 const void *val, size_t val_len);
429typedef int (*regmap_hw_async_write)(void *context,
430 const void *reg, size_t reg_len,
431 const void *val, size_t val_len,
432 struct regmap_async *async);
433typedef int (*regmap_hw_read)(void *context,
434 const void *reg_buf, size_t reg_size,
435 void *val_buf, size_t val_size);
436typedef int (*regmap_hw_reg_read)(void *context, unsigned int reg,
437 unsigned int *val);
438typedef int (*regmap_hw_reg_write)(void *context, unsigned int reg,
439 unsigned int val);
440typedef int (*regmap_hw_reg_update_bits)(void *context, unsigned int reg,
441 unsigned int mask, unsigned int val);
442typedef struct regmap_async *(*regmap_hw_async_alloc)(void);
443typedef void (*regmap_hw_free_context)(void *context);
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480struct regmap_bus {
481 bool fast_io;
482 regmap_hw_write write;
483 regmap_hw_gather_write gather_write;
484 regmap_hw_async_write async_write;
485 regmap_hw_reg_write reg_write;
486 regmap_hw_reg_update_bits reg_update_bits;
487 regmap_hw_read read;
488 regmap_hw_reg_read reg_read;
489 regmap_hw_free_context free_context;
490 regmap_hw_async_alloc async_alloc;
491 u8 read_flag_mask;
492 enum regmap_endian reg_format_endian_default;
493 enum regmap_endian val_format_endian_default;
494 size_t max_raw_read;
495 size_t max_raw_write;
496};
497
498
499
500
501
502
503
504
505struct regmap *__regmap_init(struct device *dev,
506 const struct regmap_bus *bus,
507 void *bus_context,
508 const struct regmap_config *config,
509 struct lock_class_key *lock_key,
510 const char *lock_name);
511struct regmap *__regmap_init_i2c(struct i2c_client *i2c,
512 const struct regmap_config *config,
513 struct lock_class_key *lock_key,
514 const char *lock_name);
515struct regmap *__regmap_init_slimbus(struct slim_device *slimbus,
516 const struct regmap_config *config,
517 struct lock_class_key *lock_key,
518 const char *lock_name);
519struct regmap *__regmap_init_spi(struct spi_device *dev,
520 const struct regmap_config *config,
521 struct lock_class_key *lock_key,
522 const char *lock_name);
523struct regmap *__regmap_init_spmi_base(struct spmi_device *dev,
524 const struct regmap_config *config,
525 struct lock_class_key *lock_key,
526 const char *lock_name);
527struct regmap *__regmap_init_spmi_ext(struct spmi_device *dev,
528 const struct regmap_config *config,
529 struct lock_class_key *lock_key,
530 const char *lock_name);
531struct regmap *__regmap_init_w1(struct device *w1_dev,
532 const struct regmap_config *config,
533 struct lock_class_key *lock_key,
534 const char *lock_name);
535struct regmap *__regmap_init_mmio_clk(struct device *dev, const char *clk_id,
536 void __iomem *regs,
537 const struct regmap_config *config,
538 struct lock_class_key *lock_key,
539 const char *lock_name);
540struct regmap *__regmap_init_ac97(struct snd_ac97 *ac97,
541 const struct regmap_config *config,
542 struct lock_class_key *lock_key,
543 const char *lock_name);
544struct regmap *__regmap_init_sdw(struct sdw_slave *sdw,
545 const struct regmap_config *config,
546 struct lock_class_key *lock_key,
547 const char *lock_name);
548
549struct regmap *__devm_regmap_init(struct device *dev,
550 const struct regmap_bus *bus,
551 void *bus_context,
552 const struct regmap_config *config,
553 struct lock_class_key *lock_key,
554 const char *lock_name);
555struct regmap *__devm_regmap_init_i2c(struct i2c_client *i2c,
556 const struct regmap_config *config,
557 struct lock_class_key *lock_key,
558 const char *lock_name);
559struct regmap *__devm_regmap_init_spi(struct spi_device *dev,
560 const struct regmap_config *config,
561 struct lock_class_key *lock_key,
562 const char *lock_name);
563struct regmap *__devm_regmap_init_spmi_base(struct spmi_device *dev,
564 const struct regmap_config *config,
565 struct lock_class_key *lock_key,
566 const char *lock_name);
567struct regmap *__devm_regmap_init_spmi_ext(struct spmi_device *dev,
568 const struct regmap_config *config,
569 struct lock_class_key *lock_key,
570 const char *lock_name);
571struct regmap *__devm_regmap_init_w1(struct device *w1_dev,
572 const struct regmap_config *config,
573 struct lock_class_key *lock_key,
574 const char *lock_name);
575struct regmap *__devm_regmap_init_mmio_clk(struct device *dev,
576 const char *clk_id,
577 void __iomem *regs,
578 const struct regmap_config *config,
579 struct lock_class_key *lock_key,
580 const char *lock_name);
581struct regmap *__devm_regmap_init_ac97(struct snd_ac97 *ac97,
582 const struct regmap_config *config,
583 struct lock_class_key *lock_key,
584 const char *lock_name);
585struct regmap *__devm_regmap_init_sdw(struct sdw_slave *sdw,
586 const struct regmap_config *config,
587 struct lock_class_key *lock_key,
588 const char *lock_name);
589
590
591
592
593
594
595
596
597#ifdef CONFIG_LOCKDEP
598#define __regmap_lockdep_wrapper(fn, name, ...) \
599( \
600 ({ \
601 static struct lock_class_key _key; \
602 fn(__VA_ARGS__, &_key, \
603 KBUILD_BASENAME ":" \
604 __stringify(__LINE__) ":" \
605 "(" name ")->lock"); \
606 }) \
607)
608#else
609#define __regmap_lockdep_wrapper(fn, name, ...) fn(__VA_ARGS__, NULL, NULL)
610#endif
611
612
613
614
615
616
617
618
619
620
621
622
623
624#define regmap_init(dev, bus, bus_context, config) \
625 __regmap_lockdep_wrapper(__regmap_init, #config, \
626 dev, bus, bus_context, config)
627int regmap_attach_dev(struct device *dev, struct regmap *map,
628 const struct regmap_config *config);
629
630
631
632
633
634
635
636
637
638
639#define regmap_init_i2c(i2c, config) \
640 __regmap_lockdep_wrapper(__regmap_init_i2c, #config, \
641 i2c, config)
642
643
644
645
646
647
648
649
650
651
652#define regmap_init_slimbus(slimbus, config) \
653 __regmap_lockdep_wrapper(__regmap_init_slimbus, #config, \
654 slimbus, config)
655
656
657
658
659
660
661
662
663
664
665#define regmap_init_spi(dev, config) \
666 __regmap_lockdep_wrapper(__regmap_init_spi, #config, \
667 dev, config)
668
669
670
671
672
673
674
675
676
677
678#define regmap_init_spmi_base(dev, config) \
679 __regmap_lockdep_wrapper(__regmap_init_spmi_base, #config, \
680 dev, config)
681
682
683
684
685
686
687
688
689
690
691#define regmap_init_spmi_ext(dev, config) \
692 __regmap_lockdep_wrapper(__regmap_init_spmi_ext, #config, \
693 dev, config)
694
695
696
697
698
699
700
701
702
703
704#define regmap_init_w1(w1_dev, config) \
705 __regmap_lockdep_wrapper(__regmap_init_w1, #config, \
706 w1_dev, config)
707
708
709
710
711
712
713
714
715
716
717
718
719#define regmap_init_mmio_clk(dev, clk_id, regs, config) \
720 __regmap_lockdep_wrapper(__regmap_init_mmio_clk, #config, \
721 dev, clk_id, regs, config)
722
723
724
725
726
727
728
729
730
731
732
733#define regmap_init_mmio(dev, regs, config) \
734 regmap_init_mmio_clk(dev, NULL, regs, config)
735
736
737
738
739
740
741
742
743
744
745#define regmap_init_ac97(ac97, config) \
746 __regmap_lockdep_wrapper(__regmap_init_ac97, #config, \
747 ac97, config)
748bool regmap_ac97_default_volatile(struct device *dev, unsigned int reg);
749
750
751
752
753
754
755
756
757
758
759#define regmap_init_sdw(sdw, config) \
760 __regmap_lockdep_wrapper(__regmap_init_sdw, #config, \
761 sdw, config)
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777#define devm_regmap_init(dev, bus, bus_context, config) \
778 __regmap_lockdep_wrapper(__devm_regmap_init, #config, \
779 dev, bus, bus_context, config)
780
781
782
783
784
785
786
787
788
789
790
791#define devm_regmap_init_i2c(i2c, config) \
792 __regmap_lockdep_wrapper(__devm_regmap_init_i2c, #config, \
793 i2c, config)
794
795
796
797
798
799
800
801
802
803
804
805#define devm_regmap_init_spi(dev, config) \
806 __regmap_lockdep_wrapper(__devm_regmap_init_spi, #config, \
807 dev, config)
808
809
810
811
812
813
814
815
816
817
818
819#define devm_regmap_init_spmi_base(dev, config) \
820 __regmap_lockdep_wrapper(__devm_regmap_init_spmi_base, #config, \
821 dev, config)
822
823
824
825
826
827
828
829
830
831
832
833#define devm_regmap_init_spmi_ext(dev, config) \
834 __regmap_lockdep_wrapper(__devm_regmap_init_spmi_ext, #config, \
835 dev, config)
836
837
838
839
840
841
842
843
844
845
846
847#define devm_regmap_init_w1(w1_dev, config) \
848 __regmap_lockdep_wrapper(__devm_regmap_init_w1, #config, \
849 w1_dev, config)
850
851
852
853
854
855
856
857
858
859
860
861
862#define devm_regmap_init_mmio_clk(dev, clk_id, regs, config) \
863 __regmap_lockdep_wrapper(__devm_regmap_init_mmio_clk, #config, \
864 dev, clk_id, regs, config)
865
866
867
868
869
870
871
872
873
874
875
876
877#define devm_regmap_init_mmio(dev, regs, config) \
878 devm_regmap_init_mmio_clk(dev, NULL, regs, config)
879
880
881
882
883
884
885
886
887
888
889
890#define devm_regmap_init_ac97(ac97, config) \
891 __regmap_lockdep_wrapper(__devm_regmap_init_ac97, #config, \
892 ac97, config)
893
894
895
896
897
898
899
900
901
902
903
904#define devm_regmap_init_sdw(sdw, config) \
905 __regmap_lockdep_wrapper(__devm_regmap_init_sdw, #config, \
906 sdw, config)
907
908void regmap_exit(struct regmap *map);
909int regmap_reinit_cache(struct regmap *map,
910 const struct regmap_config *config);
911struct regmap *dev_get_regmap(struct device *dev, const char *name);
912struct device *regmap_get_device(struct regmap *map);
913int regmap_write(struct regmap *map, unsigned int reg, unsigned int val);
914int regmap_write_async(struct regmap *map, unsigned int reg, unsigned int val);
915int regmap_raw_write(struct regmap *map, unsigned int reg,
916 const void *val, size_t val_len);
917int regmap_bulk_write(struct regmap *map, unsigned int reg, const void *val,
918 size_t val_count);
919int regmap_multi_reg_write(struct regmap *map, const struct reg_sequence *regs,
920 int num_regs);
921int regmap_multi_reg_write_bypassed(struct regmap *map,
922 const struct reg_sequence *regs,
923 int num_regs);
924int regmap_raw_write_async(struct regmap *map, unsigned int reg,
925 const void *val, size_t val_len);
926int regmap_read(struct regmap *map, unsigned int reg, unsigned int *val);
927int regmap_raw_read(struct regmap *map, unsigned int reg,
928 void *val, size_t val_len);
929int regmap_bulk_read(struct regmap *map, unsigned int reg, void *val,
930 size_t val_count);
931int regmap_update_bits_base(struct regmap *map, unsigned int reg,
932 unsigned int mask, unsigned int val,
933 bool *change, bool async, bool force);
934int regmap_get_val_bytes(struct regmap *map);
935int regmap_get_max_register(struct regmap *map);
936int regmap_get_reg_stride(struct regmap *map);
937int regmap_async_complete(struct regmap *map);
938bool regmap_can_raw_write(struct regmap *map);
939size_t regmap_get_raw_read_max(struct regmap *map);
940size_t regmap_get_raw_write_max(struct regmap *map);
941
942int regcache_sync(struct regmap *map);
943int regcache_sync_region(struct regmap *map, unsigned int min,
944 unsigned int max);
945int regcache_drop_region(struct regmap *map, unsigned int min,
946 unsigned int max);
947void regcache_cache_only(struct regmap *map, bool enable);
948void regcache_cache_bypass(struct regmap *map, bool enable);
949void regcache_mark_dirty(struct regmap *map);
950
951bool regmap_check_range_table(struct regmap *map, unsigned int reg,
952 const struct regmap_access_table *table);
953
954int regmap_register_patch(struct regmap *map, const struct reg_sequence *regs,
955 int num_regs);
956int regmap_parse_val(struct regmap *map, const void *buf,
957 unsigned int *val);
958
959static inline bool regmap_reg_in_range(unsigned int reg,
960 const struct regmap_range *range)
961{
962 return reg >= range->range_min && reg <= range->range_max;
963}
964
965bool regmap_reg_in_ranges(unsigned int reg,
966 const struct regmap_range *ranges,
967 unsigned int nranges);
968
969
970
971
972
973
974
975
976
977
978struct reg_field {
979 unsigned int reg;
980 unsigned int lsb;
981 unsigned int msb;
982 unsigned int id_size;
983 unsigned int id_offset;
984};
985
986#define REG_FIELD(_reg, _lsb, _msb) { \
987 .reg = _reg, \
988 .lsb = _lsb, \
989 .msb = _msb, \
990 }
991
992struct regmap_field *regmap_field_alloc(struct regmap *regmap,
993 struct reg_field reg_field);
994void regmap_field_free(struct regmap_field *field);
995
996struct regmap_field *devm_regmap_field_alloc(struct device *dev,
997 struct regmap *regmap, struct reg_field reg_field);
998void devm_regmap_field_free(struct device *dev, struct regmap_field *field);
999
1000int regmap_field_read(struct regmap_field *field, unsigned int *val);
1001int regmap_field_update_bits_base(struct regmap_field *field,
1002 unsigned int mask, unsigned int val,
1003 bool *change, bool async, bool force);
1004int regmap_fields_read(struct regmap_field *field, unsigned int id,
1005 unsigned int *val);
1006int regmap_fields_update_bits_base(struct regmap_field *field, unsigned int id,
1007 unsigned int mask, unsigned int val,
1008 bool *change, bool async, bool force);
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019struct regmap_irq {
1020 unsigned int reg_offset;
1021 unsigned int mask;
1022 unsigned int type_reg_offset;
1023 unsigned int type_rising_mask;
1024 unsigned int type_falling_mask;
1025};
1026
1027#define REGMAP_IRQ_REG(_irq, _off, _mask) \
1028 [_irq] = { .reg_offset = (_off), .mask = (_mask) }
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071struct regmap_irq_chip {
1072 const char *name;
1073
1074 unsigned int status_base;
1075 unsigned int mask_base;
1076 unsigned int unmask_base;
1077 unsigned int ack_base;
1078 unsigned int wake_base;
1079 unsigned int type_base;
1080 unsigned int irq_reg_stride;
1081 bool mask_writeonly:1;
1082 bool init_ack_masked:1;
1083 bool mask_invert:1;
1084 bool use_ack:1;
1085 bool ack_invert:1;
1086 bool wake_invert:1;
1087 bool runtime_pm:1;
1088 bool type_invert:1;
1089
1090 int num_regs;
1091
1092 const struct regmap_irq *irqs;
1093 int num_irqs;
1094
1095 int num_type_reg;
1096 unsigned int type_reg_stride;
1097
1098 int (*handle_pre_irq)(void *irq_drv_data);
1099 int (*handle_post_irq)(void *irq_drv_data);
1100 void *irq_drv_data;
1101};
1102
1103struct regmap_irq_chip_data;
1104
1105int regmap_add_irq_chip(struct regmap *map, int irq, int irq_flags,
1106 int irq_base, const struct regmap_irq_chip *chip,
1107 struct regmap_irq_chip_data **data);
1108void regmap_del_irq_chip(int irq, struct regmap_irq_chip_data *data);
1109
1110int devm_regmap_add_irq_chip(struct device *dev, struct regmap *map, int irq,
1111 int irq_flags, int irq_base,
1112 const struct regmap_irq_chip *chip,
1113 struct regmap_irq_chip_data **data);
1114void devm_regmap_del_irq_chip(struct device *dev, int irq,
1115 struct regmap_irq_chip_data *data);
1116
1117int regmap_irq_chip_get_base(struct regmap_irq_chip_data *data);
1118int regmap_irq_get_virq(struct regmap_irq_chip_data *data, int irq);
1119struct irq_domain *regmap_irq_get_domain(struct regmap_irq_chip_data *data);
1120
1121#else
1122
1123
1124
1125
1126
1127
1128
1129
1130static inline int regmap_write(struct regmap *map, unsigned int reg,
1131 unsigned int val)
1132{
1133 WARN_ONCE(1, "regmap API is disabled");
1134 return -EINVAL;
1135}
1136
1137static inline int regmap_write_async(struct regmap *map, unsigned int reg,
1138 unsigned int val)
1139{
1140 WARN_ONCE(1, "regmap API is disabled");
1141 return -EINVAL;
1142}
1143
1144static inline int regmap_raw_write(struct regmap *map, unsigned int reg,
1145 const void *val, size_t val_len)
1146{
1147 WARN_ONCE(1, "regmap API is disabled");
1148 return -EINVAL;
1149}
1150
1151static inline int regmap_raw_write_async(struct regmap *map, unsigned int reg,
1152 const void *val, size_t val_len)
1153{
1154 WARN_ONCE(1, "regmap API is disabled");
1155 return -EINVAL;
1156}
1157
1158static inline int regmap_bulk_write(struct regmap *map, unsigned int reg,
1159 const void *val, size_t val_count)
1160{
1161 WARN_ONCE(1, "regmap API is disabled");
1162 return -EINVAL;
1163}
1164
1165static inline int regmap_read(struct regmap *map, unsigned int reg,
1166 unsigned int *val)
1167{
1168 WARN_ONCE(1, "regmap API is disabled");
1169 return -EINVAL;
1170}
1171
1172static inline int regmap_raw_read(struct regmap *map, unsigned int reg,
1173 void *val, size_t val_len)
1174{
1175 WARN_ONCE(1, "regmap API is disabled");
1176 return -EINVAL;
1177}
1178
1179static inline int regmap_bulk_read(struct regmap *map, unsigned int reg,
1180 void *val, size_t val_count)
1181{
1182 WARN_ONCE(1, "regmap API is disabled");
1183 return -EINVAL;
1184}
1185
1186static inline int regmap_update_bits_base(struct regmap *map, unsigned int reg,
1187 unsigned int mask, unsigned int val,
1188 bool *change, bool async, bool force)
1189{
1190 WARN_ONCE(1, "regmap API is disabled");
1191 return -EINVAL;
1192}
1193
1194static inline int regmap_field_update_bits_base(struct regmap_field *field,
1195 unsigned int mask, unsigned int val,
1196 bool *change, bool async, bool force)
1197{
1198 WARN_ONCE(1, "regmap API is disabled");
1199 return -EINVAL;
1200}
1201
1202static inline int regmap_fields_update_bits_base(struct regmap_field *field,
1203 unsigned int id,
1204 unsigned int mask, unsigned int val,
1205 bool *change, bool async, bool force)
1206{
1207 WARN_ONCE(1, "regmap API is disabled");
1208 return -EINVAL;
1209}
1210
1211static inline int regmap_get_val_bytes(struct regmap *map)
1212{
1213 WARN_ONCE(1, "regmap API is disabled");
1214 return -EINVAL;
1215}
1216
1217static inline int regmap_get_max_register(struct regmap *map)
1218{
1219 WARN_ONCE(1, "regmap API is disabled");
1220 return -EINVAL;
1221}
1222
1223static inline int regmap_get_reg_stride(struct regmap *map)
1224{
1225 WARN_ONCE(1, "regmap API is disabled");
1226 return -EINVAL;
1227}
1228
1229static inline int regcache_sync(struct regmap *map)
1230{
1231 WARN_ONCE(1, "regmap API is disabled");
1232 return -EINVAL;
1233}
1234
1235static inline int regcache_sync_region(struct regmap *map, unsigned int min,
1236 unsigned int max)
1237{
1238 WARN_ONCE(1, "regmap API is disabled");
1239 return -EINVAL;
1240}
1241
1242static inline int regcache_drop_region(struct regmap *map, unsigned int min,
1243 unsigned int max)
1244{
1245 WARN_ONCE(1, "regmap API is disabled");
1246 return -EINVAL;
1247}
1248
1249static inline void regcache_cache_only(struct regmap *map, bool enable)
1250{
1251 WARN_ONCE(1, "regmap API is disabled");
1252}
1253
1254static inline void regcache_cache_bypass(struct regmap *map, bool enable)
1255{
1256 WARN_ONCE(1, "regmap API is disabled");
1257}
1258
1259static inline void regcache_mark_dirty(struct regmap *map)
1260{
1261 WARN_ONCE(1, "regmap API is disabled");
1262}
1263
1264static inline void regmap_async_complete(struct regmap *map)
1265{
1266 WARN_ONCE(1, "regmap API is disabled");
1267}
1268
1269static inline int regmap_register_patch(struct regmap *map,
1270 const struct reg_sequence *regs,
1271 int num_regs)
1272{
1273 WARN_ONCE(1, "regmap API is disabled");
1274 return -EINVAL;
1275}
1276
1277static inline int regmap_parse_val(struct regmap *map, const void *buf,
1278 unsigned int *val)
1279{
1280 WARN_ONCE(1, "regmap API is disabled");
1281 return -EINVAL;
1282}
1283
1284static inline struct regmap *dev_get_regmap(struct device *dev,
1285 const char *name)
1286{
1287 return NULL;
1288}
1289
1290static inline struct device *regmap_get_device(struct regmap *map)
1291{
1292 WARN_ONCE(1, "regmap API is disabled");
1293 return NULL;
1294}
1295
1296#endif
1297
1298#endif
1299