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