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