^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Register map access API internal header
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright 2011 Wolfson Microelectronics plc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #ifndef _REGMAP_INTERNAL_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #define _REGMAP_INTERNAL_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/regmap.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/list.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/wait.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) struct regmap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) struct regcache_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) struct regmap_debugfs_off_cache {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) off_t min;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) off_t max;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) unsigned int base_reg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) unsigned int max_reg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) struct regmap_format {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) size_t buf_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) size_t reg_bytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) size_t pad_bytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) size_t val_bytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) void (*format_write)(struct regmap *map,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) unsigned int reg, unsigned int val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) void (*format_reg)(void *buf, unsigned int reg, unsigned int shift);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) void (*format_val)(void *buf, unsigned int val, unsigned int shift);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) unsigned int (*parse_val)(const void *buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) void (*parse_inplace)(void *buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) struct regmap_async {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) struct regmap *map;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) void *work_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) struct regmap {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) struct mutex mutex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) spinlock_t spinlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) unsigned long spinlock_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) regmap_lock lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) regmap_unlock unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) void *lock_arg; /* This is passed to lock/unlock functions */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) gfp_t alloc_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) struct device *dev; /* Device we do I/O on */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) void *work_buf; /* Scratch buffer used to format I/O */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) struct regmap_format format; /* Buffer format */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) const struct regmap_bus *bus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) void *bus_context;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) const char *name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) bool async;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) spinlock_t async_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) wait_queue_head_t async_waitq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) struct list_head async_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) struct list_head async_free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) int async_ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) #ifdef CONFIG_DEBUG_FS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) bool debugfs_disable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) struct dentry *debugfs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) const char *debugfs_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) unsigned int debugfs_reg_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) unsigned int debugfs_val_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) unsigned int debugfs_tot_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) struct list_head debugfs_off_cache;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) struct mutex cache_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) unsigned int max_register;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) bool (*writeable_reg)(struct device *dev, unsigned int reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) bool (*readable_reg)(struct device *dev, unsigned int reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) bool (*volatile_reg)(struct device *dev, unsigned int reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) bool (*precious_reg)(struct device *dev, unsigned int reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) bool (*writeable_noinc_reg)(struct device *dev, unsigned int reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) bool (*readable_noinc_reg)(struct device *dev, unsigned int reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) const struct regmap_access_table *wr_table;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) const struct regmap_access_table *rd_table;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) const struct regmap_access_table *volatile_table;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) const struct regmap_access_table *precious_table;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) const struct regmap_access_table *wr_noinc_table;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) const struct regmap_access_table *rd_noinc_table;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) int (*reg_read)(void *context, unsigned int reg, unsigned int *val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) int (*reg_write)(void *context, unsigned int reg, unsigned int val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) int (*reg_update_bits)(void *context, unsigned int reg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) unsigned int mask, unsigned int val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) bool defer_caching;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) unsigned long read_flag_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) unsigned long write_flag_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) /* number of bits to (left) shift the reg value when formatting*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) int reg_shift;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) int reg_stride;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) int reg_stride_order;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) /* regcache specific members */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) const struct regcache_ops *cache_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) enum regcache_type cache_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) /* number of bytes in reg_defaults_raw */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) unsigned int cache_size_raw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) /* number of bytes per word in reg_defaults_raw */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) unsigned int cache_word_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) /* number of entries in reg_defaults */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) unsigned int num_reg_defaults;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) /* number of entries in reg_defaults_raw */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) unsigned int num_reg_defaults_raw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) /* if set, only the cache is modified not the HW */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) bool cache_only;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) /* if set, only the HW is modified not the cache */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) bool cache_bypass;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) /* if set, remember to free reg_defaults_raw */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) bool cache_free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) struct reg_default *reg_defaults;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) const void *reg_defaults_raw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) void *cache;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) /* if set, the cache contains newer data than the HW */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) bool cache_dirty;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) /* if set, the HW registers are known to match map->reg_defaults */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) bool no_sync_defaults;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) struct reg_sequence *patch;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) int patch_regs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) /* if set, converts bulk read to single read */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) bool use_single_read;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) /* if set, converts bulk write to single write */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) bool use_single_write;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) /* if set, the device supports multi write mode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) bool can_multi_write;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) /* if set, raw reads/writes are limited to this size */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) size_t max_raw_read;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) size_t max_raw_write;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) struct rb_root range_tree;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) void *selector_work_buf; /* Scratch buffer used for selector */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) struct hwspinlock *hwlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) /* if set, the regmap core can sleep */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) bool can_sleep;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) struct regcache_ops {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) const char *name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) enum regcache_type type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) int (*init)(struct regmap *map);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) int (*exit)(struct regmap *map);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) #ifdef CONFIG_DEBUG_FS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) void (*debugfs_init)(struct regmap *map);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) int (*read)(struct regmap *map, unsigned int reg, unsigned int *value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) int (*write)(struct regmap *map, unsigned int reg, unsigned int value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) int (*sync)(struct regmap *map, unsigned int min, unsigned int max);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) int (*drop)(struct regmap *map, unsigned int min, unsigned int max);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) bool regmap_cached(struct regmap *map, unsigned int reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) bool regmap_writeable(struct regmap *map, unsigned int reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) bool regmap_readable(struct regmap *map, unsigned int reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) bool regmap_volatile(struct regmap *map, unsigned int reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) bool regmap_precious(struct regmap *map, unsigned int reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) bool regmap_writeable_noinc(struct regmap *map, unsigned int reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) bool regmap_readable_noinc(struct regmap *map, unsigned int reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) int _regmap_write(struct regmap *map, unsigned int reg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) unsigned int val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) struct regmap_range_node {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) struct rb_node node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) const char *name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) struct regmap *map;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) unsigned int range_min;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) unsigned int range_max;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) unsigned int selector_reg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) unsigned int selector_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) int selector_shift;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) unsigned int window_start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) unsigned int window_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) struct regmap_field {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) struct regmap *regmap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) unsigned int mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) /* lsb */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) unsigned int shift;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) unsigned int reg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) unsigned int id_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) unsigned int id_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) #ifdef CONFIG_DEBUG_FS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) extern void regmap_debugfs_initcall(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) extern void regmap_debugfs_init(struct regmap *map);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) extern void regmap_debugfs_exit(struct regmap *map);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) static inline void regmap_debugfs_disable(struct regmap *map)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) map->debugfs_disable = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) static inline void regmap_debugfs_initcall(void) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) static inline void regmap_debugfs_init(struct regmap *map) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) static inline void regmap_debugfs_exit(struct regmap *map) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) static inline void regmap_debugfs_disable(struct regmap *map) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) /* regcache core declarations */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) int regcache_init(struct regmap *map, const struct regmap_config *config);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) void regcache_exit(struct regmap *map);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) int regcache_read(struct regmap *map,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) unsigned int reg, unsigned int *value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) int regcache_write(struct regmap *map,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) unsigned int reg, unsigned int value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) int regcache_sync(struct regmap *map);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) int regcache_sync_block(struct regmap *map, void *block,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) unsigned long *cache_present,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) unsigned int block_base, unsigned int start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) unsigned int end);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) static inline const void *regcache_get_val_addr(struct regmap *map,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) const void *base,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) unsigned int idx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) return base + (map->cache_word_size * idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) unsigned int regcache_get_val(struct regmap *map, const void *base,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) unsigned int idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) bool regcache_set_val(struct regmap *map, void *base, unsigned int idx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) unsigned int val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) int regcache_lookup_reg(struct regmap *map, unsigned int reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) int _regmap_raw_write(struct regmap *map, unsigned int reg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) const void *val, size_t val_len, bool noinc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) void regmap_async_complete_cb(struct regmap_async *async, int ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) enum regmap_endian regmap_get_val_endian(struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) const struct regmap_bus *bus,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) const struct regmap_config *config);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) extern struct regcache_ops regcache_rbtree_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) extern struct regcache_ops regcache_lzo_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) extern struct regcache_ops regcache_flat_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) static inline const char *regmap_name(const struct regmap *map)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) if (map->dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) return dev_name(map->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) return map->name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) static inline unsigned int regmap_get_offset(const struct regmap *map,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) unsigned int index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) if (map->reg_stride_order >= 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) return index << map->reg_stride_order;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) return index * map->reg_stride;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) static inline unsigned int regcache_get_index_by_order(const struct regmap *map,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) unsigned int reg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) return reg >> map->reg_stride_order;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) #endif