This source file includes following definitions.
- regmap_reg_in_range
- regmap_write
- regmap_write_async
- regmap_raw_write
- regmap_raw_write_async
- regmap_noinc_write
- regmap_bulk_write
- regmap_read
- regmap_raw_read
- regmap_noinc_read
- regmap_bulk_read
- regmap_update_bits_base
- regmap_field_update_bits_base
- regmap_fields_update_bits_base
- regmap_get_val_bytes
- regmap_get_max_register
- regmap_get_reg_stride
- regcache_sync
- regcache_sync_region
- regcache_drop_region
- regcache_cache_only
- regcache_cache_bypass
- regcache_mark_dirty
- regmap_async_complete
- regmap_register_patch
- regmap_parse_val
- dev_get_regmap
- regmap_get_device
1
2 #ifndef __LINUX_REGMAP_H
3 #define __LINUX_REGMAP_H
4
5
6
7
8
9
10
11
12
13 #include <linux/list.h>
14 #include <linux/rbtree.h>
15 #include <linux/ktime.h>
16 #include <linux/delay.h>
17 #include <linux/err.h>
18 #include <linux/bug.h>
19 #include <linux/lockdep.h>
20
21 struct module;
22 struct clk;
23 struct device;
24 struct i2c_client;
25 struct i3c_device;
26 struct irq_domain;
27 struct slim_device;
28 struct spi_device;
29 struct spmi_device;
30 struct regmap;
31 struct regmap_range_cfg;
32 struct regmap_field;
33 struct snd_ac97;
34 struct sdw_slave;
35
36
37 enum 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
53 struct reg_default {
54 unsigned int reg;
55 unsigned int def;
56 };
57
58
59
60
61
62
63
64
65
66
67
68 struct 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
190 enum 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
205 struct 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
225 struct 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
232 typedef void (*regmap_lock)(void *);
233 typedef 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
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352 struct regmap_config {
353 const char *name;
354
355 int reg_bits;
356 int reg_stride;
357 int pad_bits;
358 int val_bits;
359
360 bool (*writeable_reg)(struct device *dev, unsigned int reg);
361 bool (*readable_reg)(struct device *dev, unsigned int reg);
362 bool (*volatile_reg)(struct device *dev, unsigned int reg);
363 bool (*precious_reg)(struct device *dev, unsigned int reg);
364 bool (*writeable_noinc_reg)(struct device *dev, unsigned int reg);
365 bool (*readable_noinc_reg)(struct device *dev, unsigned int reg);
366
367 bool disable_locking;
368 regmap_lock lock;
369 regmap_unlock unlock;
370 void *lock_arg;
371
372 int (*reg_read)(void *context, unsigned int reg, unsigned int *val);
373 int (*reg_write)(void *context, unsigned int reg, unsigned int val);
374
375 bool fast_io;
376
377 unsigned int max_register;
378 const struct regmap_access_table *wr_table;
379 const struct regmap_access_table *rd_table;
380 const struct regmap_access_table *volatile_table;
381 const struct regmap_access_table *precious_table;
382 const struct regmap_access_table *wr_noinc_table;
383 const struct regmap_access_table *rd_noinc_table;
384 const struct reg_default *reg_defaults;
385 unsigned int num_reg_defaults;
386 enum regcache_type cache_type;
387 const void *reg_defaults_raw;
388 unsigned int num_reg_defaults_raw;
389
390 unsigned long read_flag_mask;
391 unsigned long write_flag_mask;
392 bool zero_flag_mask;
393
394 bool use_single_read;
395 bool use_single_write;
396 bool can_multi_write;
397
398 enum regmap_endian reg_format_endian;
399 enum regmap_endian val_format_endian;
400
401 const struct regmap_range_cfg *ranges;
402 unsigned int num_ranges;
403
404 bool use_hwlock;
405 unsigned int hwlock_id;
406 unsigned int hwlock_mode;
407 };
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429 struct regmap_range_cfg {
430 const char *name;
431
432
433 unsigned int range_min;
434 unsigned int range_max;
435
436
437 unsigned int selector_reg;
438 unsigned int selector_mask;
439 int selector_shift;
440
441
442 unsigned int window_start;
443 unsigned int window_len;
444 };
445
446 struct regmap_async;
447
448 typedef int (*regmap_hw_write)(void *context, const void *data,
449 size_t count);
450 typedef int (*regmap_hw_gather_write)(void *context,
451 const void *reg, size_t reg_len,
452 const void *val, size_t val_len);
453 typedef int (*regmap_hw_async_write)(void *context,
454 const void *reg, size_t reg_len,
455 const void *val, size_t val_len,
456 struct regmap_async *async);
457 typedef int (*regmap_hw_read)(void *context,
458 const void *reg_buf, size_t reg_size,
459 void *val_buf, size_t val_size);
460 typedef int (*regmap_hw_reg_read)(void *context, unsigned int reg,
461 unsigned int *val);
462 typedef int (*regmap_hw_reg_write)(void *context, unsigned int reg,
463 unsigned int val);
464 typedef int (*regmap_hw_reg_update_bits)(void *context, unsigned int reg,
465 unsigned int mask, unsigned int val);
466 typedef struct regmap_async *(*regmap_hw_async_alloc)(void);
467 typedef void (*regmap_hw_free_context)(void *context);
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504 struct regmap_bus {
505 bool fast_io;
506 regmap_hw_write write;
507 regmap_hw_gather_write gather_write;
508 regmap_hw_async_write async_write;
509 regmap_hw_reg_write reg_write;
510 regmap_hw_reg_update_bits reg_update_bits;
511 regmap_hw_read read;
512 regmap_hw_reg_read reg_read;
513 regmap_hw_free_context free_context;
514 regmap_hw_async_alloc async_alloc;
515 u8 read_flag_mask;
516 enum regmap_endian reg_format_endian_default;
517 enum regmap_endian val_format_endian_default;
518 size_t max_raw_read;
519 size_t max_raw_write;
520 };
521
522
523
524
525
526
527
528
529 struct regmap *__regmap_init(struct device *dev,
530 const struct regmap_bus *bus,
531 void *bus_context,
532 const struct regmap_config *config,
533 struct lock_class_key *lock_key,
534 const char *lock_name);
535 struct regmap *__regmap_init_i2c(struct i2c_client *i2c,
536 const struct regmap_config *config,
537 struct lock_class_key *lock_key,
538 const char *lock_name);
539 struct regmap *__regmap_init_sccb(struct i2c_client *i2c,
540 const struct regmap_config *config,
541 struct lock_class_key *lock_key,
542 const char *lock_name);
543 struct regmap *__regmap_init_slimbus(struct slim_device *slimbus,
544 const struct regmap_config *config,
545 struct lock_class_key *lock_key,
546 const char *lock_name);
547 struct regmap *__regmap_init_spi(struct spi_device *dev,
548 const struct regmap_config *config,
549 struct lock_class_key *lock_key,
550 const char *lock_name);
551 struct regmap *__regmap_init_spmi_base(struct spmi_device *dev,
552 const struct regmap_config *config,
553 struct lock_class_key *lock_key,
554 const char *lock_name);
555 struct regmap *__regmap_init_spmi_ext(struct spmi_device *dev,
556 const struct regmap_config *config,
557 struct lock_class_key *lock_key,
558 const char *lock_name);
559 struct regmap *__regmap_init_w1(struct device *w1_dev,
560 const struct regmap_config *config,
561 struct lock_class_key *lock_key,
562 const char *lock_name);
563 struct regmap *__regmap_init_mmio_clk(struct device *dev, const char *clk_id,
564 void __iomem *regs,
565 const struct regmap_config *config,
566 struct lock_class_key *lock_key,
567 const char *lock_name);
568 struct regmap *__regmap_init_ac97(struct snd_ac97 *ac97,
569 const struct regmap_config *config,
570 struct lock_class_key *lock_key,
571 const char *lock_name);
572 struct regmap *__regmap_init_sdw(struct sdw_slave *sdw,
573 const struct regmap_config *config,
574 struct lock_class_key *lock_key,
575 const char *lock_name);
576
577 struct regmap *__devm_regmap_init(struct device *dev,
578 const struct regmap_bus *bus,
579 void *bus_context,
580 const struct regmap_config *config,
581 struct lock_class_key *lock_key,
582 const char *lock_name);
583 struct regmap *__devm_regmap_init_i2c(struct i2c_client *i2c,
584 const struct regmap_config *config,
585 struct lock_class_key *lock_key,
586 const char *lock_name);
587 struct regmap *__devm_regmap_init_sccb(struct i2c_client *i2c,
588 const struct regmap_config *config,
589 struct lock_class_key *lock_key,
590 const char *lock_name);
591 struct regmap *__devm_regmap_init_spi(struct spi_device *dev,
592 const struct regmap_config *config,
593 struct lock_class_key *lock_key,
594 const char *lock_name);
595 struct regmap *__devm_regmap_init_spmi_base(struct spmi_device *dev,
596 const struct regmap_config *config,
597 struct lock_class_key *lock_key,
598 const char *lock_name);
599 struct regmap *__devm_regmap_init_spmi_ext(struct spmi_device *dev,
600 const struct regmap_config *config,
601 struct lock_class_key *lock_key,
602 const char *lock_name);
603 struct regmap *__devm_regmap_init_w1(struct device *w1_dev,
604 const struct regmap_config *config,
605 struct lock_class_key *lock_key,
606 const char *lock_name);
607 struct regmap *__devm_regmap_init_mmio_clk(struct device *dev,
608 const char *clk_id,
609 void __iomem *regs,
610 const struct regmap_config *config,
611 struct lock_class_key *lock_key,
612 const char *lock_name);
613 struct regmap *__devm_regmap_init_ac97(struct snd_ac97 *ac97,
614 const struct regmap_config *config,
615 struct lock_class_key *lock_key,
616 const char *lock_name);
617 struct regmap *__devm_regmap_init_sdw(struct sdw_slave *sdw,
618 const struct regmap_config *config,
619 struct lock_class_key *lock_key,
620 const char *lock_name);
621 struct regmap *__devm_regmap_init_slimbus(struct slim_device *slimbus,
622 const struct regmap_config *config,
623 struct lock_class_key *lock_key,
624 const char *lock_name);
625 struct regmap *__devm_regmap_init_i3c(struct i3c_device *i3c,
626 const struct regmap_config *config,
627 struct lock_class_key *lock_key,
628 const char *lock_name);
629
630
631
632
633
634
635
636 #ifdef CONFIG_LOCKDEP
637 #define __regmap_lockdep_wrapper(fn, name, ...) \
638 ( \
639 ({ \
640 static struct lock_class_key _key; \
641 fn(__VA_ARGS__, &_key, \
642 KBUILD_BASENAME ":" \
643 __stringify(__LINE__) ":" \
644 "(" name ")->lock"); \
645 }) \
646 )
647 #else
648 #define __regmap_lockdep_wrapper(fn, name, ...) fn(__VA_ARGS__, NULL, NULL)
649 #endif
650
651
652
653
654
655
656
657
658
659
660
661
662
663 #define regmap_init(dev, bus, bus_context, config) \
664 __regmap_lockdep_wrapper(__regmap_init, #config, \
665 dev, bus, bus_context, config)
666 int regmap_attach_dev(struct device *dev, struct regmap *map,
667 const struct regmap_config *config);
668
669
670
671
672
673
674
675
676
677
678 #define regmap_init_i2c(i2c, config) \
679 __regmap_lockdep_wrapper(__regmap_init_i2c, #config, \
680 i2c, config)
681
682
683
684
685
686
687
688
689
690
691 #define regmap_init_sccb(i2c, config) \
692 __regmap_lockdep_wrapper(__regmap_init_sccb, #config, \
693 i2c, config)
694
695
696
697
698
699
700
701
702
703
704 #define regmap_init_slimbus(slimbus, config) \
705 __regmap_lockdep_wrapper(__regmap_init_slimbus, #config, \
706 slimbus, config)
707
708
709
710
711
712
713
714
715
716
717 #define regmap_init_spi(dev, config) \
718 __regmap_lockdep_wrapper(__regmap_init_spi, #config, \
719 dev, config)
720
721
722
723
724
725
726
727
728
729
730 #define regmap_init_spmi_base(dev, config) \
731 __regmap_lockdep_wrapper(__regmap_init_spmi_base, #config, \
732 dev, config)
733
734
735
736
737
738
739
740
741
742
743 #define regmap_init_spmi_ext(dev, config) \
744 __regmap_lockdep_wrapper(__regmap_init_spmi_ext, #config, \
745 dev, config)
746
747
748
749
750
751
752
753
754
755
756 #define regmap_init_w1(w1_dev, config) \
757 __regmap_lockdep_wrapper(__regmap_init_w1, #config, \
758 w1_dev, config)
759
760
761
762
763
764
765
766
767
768
769
770
771 #define regmap_init_mmio_clk(dev, clk_id, regs, config) \
772 __regmap_lockdep_wrapper(__regmap_init_mmio_clk, #config, \
773 dev, clk_id, regs, config)
774
775
776
777
778
779
780
781
782
783
784
785 #define regmap_init_mmio(dev, regs, config) \
786 regmap_init_mmio_clk(dev, NULL, regs, config)
787
788
789
790
791
792
793
794
795
796
797 #define regmap_init_ac97(ac97, config) \
798 __regmap_lockdep_wrapper(__regmap_init_ac97, #config, \
799 ac97, config)
800 bool regmap_ac97_default_volatile(struct device *dev, unsigned int reg);
801
802
803
804
805
806
807
808
809
810
811 #define regmap_init_sdw(sdw, config) \
812 __regmap_lockdep_wrapper(__regmap_init_sdw, #config, \
813 sdw, config)
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829 #define devm_regmap_init(dev, bus, bus_context, config) \
830 __regmap_lockdep_wrapper(__devm_regmap_init, #config, \
831 dev, bus, bus_context, config)
832
833
834
835
836
837
838
839
840
841
842
843 #define devm_regmap_init_i2c(i2c, config) \
844 __regmap_lockdep_wrapper(__devm_regmap_init_i2c, #config, \
845 i2c, config)
846
847
848
849
850
851
852
853
854
855
856
857 #define devm_regmap_init_sccb(i2c, config) \
858 __regmap_lockdep_wrapper(__devm_regmap_init_sccb, #config, \
859 i2c, config)
860
861
862
863
864
865
866
867
868
869
870
871 #define devm_regmap_init_spi(dev, config) \
872 __regmap_lockdep_wrapper(__devm_regmap_init_spi, #config, \
873 dev, config)
874
875
876
877
878
879
880
881
882
883
884
885 #define devm_regmap_init_spmi_base(dev, config) \
886 __regmap_lockdep_wrapper(__devm_regmap_init_spmi_base, #config, \
887 dev, config)
888
889
890
891
892
893
894
895
896
897
898
899 #define devm_regmap_init_spmi_ext(dev, config) \
900 __regmap_lockdep_wrapper(__devm_regmap_init_spmi_ext, #config, \
901 dev, config)
902
903
904
905
906
907
908
909
910
911
912
913 #define devm_regmap_init_w1(w1_dev, config) \
914 __regmap_lockdep_wrapper(__devm_regmap_init_w1, #config, \
915 w1_dev, config)
916
917
918
919
920
921
922
923
924
925
926
927
928 #define devm_regmap_init_mmio_clk(dev, clk_id, regs, config) \
929 __regmap_lockdep_wrapper(__devm_regmap_init_mmio_clk, #config, \
930 dev, clk_id, regs, config)
931
932
933
934
935
936
937
938
939
940
941
942
943 #define devm_regmap_init_mmio(dev, regs, config) \
944 devm_regmap_init_mmio_clk(dev, NULL, regs, config)
945
946
947
948
949
950
951
952
953
954
955
956 #define devm_regmap_init_ac97(ac97, config) \
957 __regmap_lockdep_wrapper(__devm_regmap_init_ac97, #config, \
958 ac97, config)
959
960
961
962
963
964
965
966
967
968
969
970 #define devm_regmap_init_sdw(sdw, config) \
971 __regmap_lockdep_wrapper(__devm_regmap_init_sdw, #config, \
972 sdw, config)
973
974
975
976
977
978
979
980
981
982
983
984 #define devm_regmap_init_slimbus(slimbus, config) \
985 __regmap_lockdep_wrapper(__devm_regmap_init_slimbus, #config, \
986 slimbus, config)
987
988
989
990
991
992
993
994
995
996
997
998 #define devm_regmap_init_i3c(i3c, config) \
999 __regmap_lockdep_wrapper(__devm_regmap_init_i3c, #config, \
1000 i3c, config)
1001
1002 int regmap_mmio_attach_clk(struct regmap *map, struct clk *clk);
1003 void regmap_mmio_detach_clk(struct regmap *map);
1004 void regmap_exit(struct regmap *map);
1005 int regmap_reinit_cache(struct regmap *map,
1006 const struct regmap_config *config);
1007 struct regmap *dev_get_regmap(struct device *dev, const char *name);
1008 struct device *regmap_get_device(struct regmap *map);
1009 int regmap_write(struct regmap *map, unsigned int reg, unsigned int val);
1010 int regmap_write_async(struct regmap *map, unsigned int reg, unsigned int val);
1011 int regmap_raw_write(struct regmap *map, unsigned int reg,
1012 const void *val, size_t val_len);
1013 int regmap_noinc_write(struct regmap *map, unsigned int reg,
1014 const void *val, size_t val_len);
1015 int regmap_bulk_write(struct regmap *map, unsigned int reg, const void *val,
1016 size_t val_count);
1017 int regmap_multi_reg_write(struct regmap *map, const struct reg_sequence *regs,
1018 int num_regs);
1019 int regmap_multi_reg_write_bypassed(struct regmap *map,
1020 const struct reg_sequence *regs,
1021 int num_regs);
1022 int regmap_raw_write_async(struct regmap *map, unsigned int reg,
1023 const void *val, size_t val_len);
1024 int regmap_read(struct regmap *map, unsigned int reg, unsigned int *val);
1025 int regmap_raw_read(struct regmap *map, unsigned int reg,
1026 void *val, size_t val_len);
1027 int regmap_noinc_read(struct regmap *map, unsigned int reg,
1028 void *val, size_t val_len);
1029 int regmap_bulk_read(struct regmap *map, unsigned int reg, void *val,
1030 size_t val_count);
1031 int regmap_update_bits_base(struct regmap *map, unsigned int reg,
1032 unsigned int mask, unsigned int val,
1033 bool *change, bool async, bool force);
1034 int regmap_get_val_bytes(struct regmap *map);
1035 int regmap_get_max_register(struct regmap *map);
1036 int regmap_get_reg_stride(struct regmap *map);
1037 int regmap_async_complete(struct regmap *map);
1038 bool regmap_can_raw_write(struct regmap *map);
1039 size_t regmap_get_raw_read_max(struct regmap *map);
1040 size_t regmap_get_raw_write_max(struct regmap *map);
1041
1042 int regcache_sync(struct regmap *map);
1043 int regcache_sync_region(struct regmap *map, unsigned int min,
1044 unsigned int max);
1045 int regcache_drop_region(struct regmap *map, unsigned int min,
1046 unsigned int max);
1047 void regcache_cache_only(struct regmap *map, bool enable);
1048 void regcache_cache_bypass(struct regmap *map, bool enable);
1049 void regcache_mark_dirty(struct regmap *map);
1050
1051 bool regmap_check_range_table(struct regmap *map, unsigned int reg,
1052 const struct regmap_access_table *table);
1053
1054 int regmap_register_patch(struct regmap *map, const struct reg_sequence *regs,
1055 int num_regs);
1056 int regmap_parse_val(struct regmap *map, const void *buf,
1057 unsigned int *val);
1058
1059 static inline bool regmap_reg_in_range(unsigned int reg,
1060 const struct regmap_range *range)
1061 {
1062 return reg >= range->range_min && reg <= range->range_max;
1063 }
1064
1065 bool regmap_reg_in_ranges(unsigned int reg,
1066 const struct regmap_range *ranges,
1067 unsigned int nranges);
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078 struct reg_field {
1079 unsigned int reg;
1080 unsigned int lsb;
1081 unsigned int msb;
1082 unsigned int id_size;
1083 unsigned int id_offset;
1084 };
1085
1086 #define REG_FIELD(_reg, _lsb, _msb) { \
1087 .reg = _reg, \
1088 .lsb = _lsb, \
1089 .msb = _msb, \
1090 }
1091
1092 struct regmap_field *regmap_field_alloc(struct regmap *regmap,
1093 struct reg_field reg_field);
1094 void regmap_field_free(struct regmap_field *field);
1095
1096 struct regmap_field *devm_regmap_field_alloc(struct device *dev,
1097 struct regmap *regmap, struct reg_field reg_field);
1098 void devm_regmap_field_free(struct device *dev, struct regmap_field *field);
1099
1100 int regmap_field_read(struct regmap_field *field, unsigned int *val);
1101 int regmap_field_update_bits_base(struct regmap_field *field,
1102 unsigned int mask, unsigned int val,
1103 bool *change, bool async, bool force);
1104 int regmap_fields_read(struct regmap_field *field, unsigned int id,
1105 unsigned int *val);
1106 int regmap_fields_update_bits_base(struct regmap_field *field, unsigned int id,
1107 unsigned int mask, unsigned int val,
1108 bool *change, bool async, bool force);
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119 struct regmap_irq_type {
1120 unsigned int type_reg_offset;
1121 unsigned int type_reg_mask;
1122 unsigned int type_rising_val;
1123 unsigned int type_falling_val;
1124 unsigned int type_level_low_val;
1125 unsigned int type_level_high_val;
1126 unsigned int types_supported;
1127 };
1128
1129
1130
1131
1132
1133
1134
1135
1136 struct regmap_irq {
1137 unsigned int reg_offset;
1138 unsigned int mask;
1139 struct regmap_irq_type type;
1140 };
1141
1142 #define REGMAP_IRQ_REG(_irq, _off, _mask) \
1143 [_irq] = { .reg_offset = (_off), .mask = (_mask) }
1144
1145 #define REGMAP_IRQ_REG_LINE(_id, _reg_bits) \
1146 [_id] = { \
1147 .mask = BIT((_id) % (_reg_bits)), \
1148 .reg_offset = (_id) / (_reg_bits), \
1149 }
1150
1151 #define REGMAP_IRQ_MAIN_REG_OFFSET(arr) \
1152 { .num_regs = ARRAY_SIZE((arr)), .offset = &(arr)[0] }
1153
1154 struct regmap_irq_sub_irq_map {
1155 unsigned int num_regs;
1156 unsigned int *offset;
1157 };
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224 struct regmap_irq_chip {
1225 const char *name;
1226
1227 unsigned int main_status;
1228 unsigned int num_main_status_bits;
1229 struct regmap_irq_sub_irq_map *sub_reg_offsets;
1230 int num_main_regs;
1231
1232 unsigned int status_base;
1233 unsigned int mask_base;
1234 unsigned int unmask_base;
1235 unsigned int ack_base;
1236 unsigned int wake_base;
1237 unsigned int type_base;
1238 unsigned int irq_reg_stride;
1239 bool mask_writeonly:1;
1240 bool init_ack_masked:1;
1241 bool mask_invert:1;
1242 bool use_ack:1;
1243 bool ack_invert:1;
1244 bool wake_invert:1;
1245 bool runtime_pm:1;
1246 bool type_invert:1;
1247 bool type_in_mask:1;
1248 bool clear_on_unmask:1;
1249
1250 int num_regs;
1251
1252 const struct regmap_irq *irqs;
1253 int num_irqs;
1254
1255 int num_type_reg;
1256 unsigned int type_reg_stride;
1257
1258 int (*handle_pre_irq)(void *irq_drv_data);
1259 int (*handle_post_irq)(void *irq_drv_data);
1260 void *irq_drv_data;
1261 };
1262
1263 struct regmap_irq_chip_data;
1264
1265 int regmap_add_irq_chip(struct regmap *map, int irq, int irq_flags,
1266 int irq_base, const struct regmap_irq_chip *chip,
1267 struct regmap_irq_chip_data **data);
1268 void regmap_del_irq_chip(int irq, struct regmap_irq_chip_data *data);
1269
1270 int devm_regmap_add_irq_chip(struct device *dev, struct regmap *map, int irq,
1271 int irq_flags, int irq_base,
1272 const struct regmap_irq_chip *chip,
1273 struct regmap_irq_chip_data **data);
1274 void devm_regmap_del_irq_chip(struct device *dev, int irq,
1275 struct regmap_irq_chip_data *data);
1276
1277 int regmap_irq_chip_get_base(struct regmap_irq_chip_data *data);
1278 int regmap_irq_get_virq(struct regmap_irq_chip_data *data, int irq);
1279 struct irq_domain *regmap_irq_get_domain(struct regmap_irq_chip_data *data);
1280
1281 #else
1282
1283
1284
1285
1286
1287
1288
1289
1290 static inline int regmap_write(struct regmap *map, unsigned int reg,
1291 unsigned int val)
1292 {
1293 WARN_ONCE(1, "regmap API is disabled");
1294 return -EINVAL;
1295 }
1296
1297 static inline int regmap_write_async(struct regmap *map, unsigned int reg,
1298 unsigned int val)
1299 {
1300 WARN_ONCE(1, "regmap API is disabled");
1301 return -EINVAL;
1302 }
1303
1304 static inline int regmap_raw_write(struct regmap *map, unsigned int reg,
1305 const void *val, size_t val_len)
1306 {
1307 WARN_ONCE(1, "regmap API is disabled");
1308 return -EINVAL;
1309 }
1310
1311 static inline int regmap_raw_write_async(struct regmap *map, unsigned int reg,
1312 const void *val, size_t val_len)
1313 {
1314 WARN_ONCE(1, "regmap API is disabled");
1315 return -EINVAL;
1316 }
1317
1318 static inline int regmap_noinc_write(struct regmap *map, unsigned int reg,
1319 const void *val, size_t val_len)
1320 {
1321 WARN_ONCE(1, "regmap API is disabled");
1322 return -EINVAL;
1323 }
1324
1325 static inline int regmap_bulk_write(struct regmap *map, unsigned int reg,
1326 const void *val, size_t val_count)
1327 {
1328 WARN_ONCE(1, "regmap API is disabled");
1329 return -EINVAL;
1330 }
1331
1332 static inline int regmap_read(struct regmap *map, unsigned int reg,
1333 unsigned int *val)
1334 {
1335 WARN_ONCE(1, "regmap API is disabled");
1336 return -EINVAL;
1337 }
1338
1339 static inline int regmap_raw_read(struct regmap *map, unsigned int reg,
1340 void *val, size_t val_len)
1341 {
1342 WARN_ONCE(1, "regmap API is disabled");
1343 return -EINVAL;
1344 }
1345
1346 static inline int regmap_noinc_read(struct regmap *map, unsigned int reg,
1347 void *val, size_t val_len)
1348 {
1349 WARN_ONCE(1, "regmap API is disabled");
1350 return -EINVAL;
1351 }
1352
1353 static inline int regmap_bulk_read(struct regmap *map, unsigned int reg,
1354 void *val, size_t val_count)
1355 {
1356 WARN_ONCE(1, "regmap API is disabled");
1357 return -EINVAL;
1358 }
1359
1360 static inline int regmap_update_bits_base(struct regmap *map, unsigned int reg,
1361 unsigned int mask, unsigned int val,
1362 bool *change, bool async, bool force)
1363 {
1364 WARN_ONCE(1, "regmap API is disabled");
1365 return -EINVAL;
1366 }
1367
1368 static inline int regmap_field_update_bits_base(struct regmap_field *field,
1369 unsigned int mask, unsigned int val,
1370 bool *change, bool async, bool force)
1371 {
1372 WARN_ONCE(1, "regmap API is disabled");
1373 return -EINVAL;
1374 }
1375
1376 static inline int regmap_fields_update_bits_base(struct regmap_field *field,
1377 unsigned int id,
1378 unsigned int mask, unsigned int val,
1379 bool *change, bool async, bool force)
1380 {
1381 WARN_ONCE(1, "regmap API is disabled");
1382 return -EINVAL;
1383 }
1384
1385 static inline int regmap_get_val_bytes(struct regmap *map)
1386 {
1387 WARN_ONCE(1, "regmap API is disabled");
1388 return -EINVAL;
1389 }
1390
1391 static inline int regmap_get_max_register(struct regmap *map)
1392 {
1393 WARN_ONCE(1, "regmap API is disabled");
1394 return -EINVAL;
1395 }
1396
1397 static inline int regmap_get_reg_stride(struct regmap *map)
1398 {
1399 WARN_ONCE(1, "regmap API is disabled");
1400 return -EINVAL;
1401 }
1402
1403 static inline int regcache_sync(struct regmap *map)
1404 {
1405 WARN_ONCE(1, "regmap API is disabled");
1406 return -EINVAL;
1407 }
1408
1409 static inline int regcache_sync_region(struct regmap *map, unsigned int min,
1410 unsigned int max)
1411 {
1412 WARN_ONCE(1, "regmap API is disabled");
1413 return -EINVAL;
1414 }
1415
1416 static inline int regcache_drop_region(struct regmap *map, unsigned int min,
1417 unsigned int max)
1418 {
1419 WARN_ONCE(1, "regmap API is disabled");
1420 return -EINVAL;
1421 }
1422
1423 static inline void regcache_cache_only(struct regmap *map, bool enable)
1424 {
1425 WARN_ONCE(1, "regmap API is disabled");
1426 }
1427
1428 static inline void regcache_cache_bypass(struct regmap *map, bool enable)
1429 {
1430 WARN_ONCE(1, "regmap API is disabled");
1431 }
1432
1433 static inline void regcache_mark_dirty(struct regmap *map)
1434 {
1435 WARN_ONCE(1, "regmap API is disabled");
1436 }
1437
1438 static inline void regmap_async_complete(struct regmap *map)
1439 {
1440 WARN_ONCE(1, "regmap API is disabled");
1441 }
1442
1443 static inline int regmap_register_patch(struct regmap *map,
1444 const struct reg_sequence *regs,
1445 int num_regs)
1446 {
1447 WARN_ONCE(1, "regmap API is disabled");
1448 return -EINVAL;
1449 }
1450
1451 static inline int regmap_parse_val(struct regmap *map, const void *buf,
1452 unsigned int *val)
1453 {
1454 WARN_ONCE(1, "regmap API is disabled");
1455 return -EINVAL;
1456 }
1457
1458 static inline struct regmap *dev_get_regmap(struct device *dev,
1459 const char *name)
1460 {
1461 return NULL;
1462 }
1463
1464 static inline struct device *regmap_get_device(struct regmap *map)
1465 {
1466 WARN_ONCE(1, "regmap API is disabled");
1467 return NULL;
1468 }
1469
1470 #endif
1471
1472 #endif