Lines Matching refs:map
3 // Register map access API - debugfs
19 struct regmap *map;
38 struct regmap *map = file->private_data;
47 if (map->dev && map->dev->driver)
48 name = map->dev->driver->name;
67 static void regmap_debugfs_free_dump_cache(struct regmap *map)
71 while (!list_empty(&map->debugfs_off_cache)) {
72 c = list_first_entry(&map->debugfs_off_cache,
80 static bool regmap_printable(struct regmap *map, unsigned int reg)
82 if (regmap_precious(map, reg))
85 if (!regmap_readable(map, reg) && !regmap_cached(map, reg))
95 static unsigned int regmap_debugfs_get_dump_start(struct regmap *map,
114 mutex_lock(&map->cache_lock);
116 if (list_empty(&map->debugfs_off_cache)) {
117 for (; i <= map->max_register; i += map->reg_stride) {
119 if (!regmap_printable(map, i)) {
122 c->max_reg = i - map->reg_stride;
124 &map->debugfs_off_cache);
135 regmap_debugfs_free_dump_cache(map);
136 mutex_unlock(&map->cache_lock);
143 p += map->debugfs_tot_len;
150 c->max_reg = i - map->reg_stride;
152 &map->debugfs_off_cache);
160 WARN_ON(list_empty(&map->debugfs_off_cache));
164 list_for_each_entry(c, &map->debugfs_off_cache, list) {
167 reg_offset = fpos_offset / map->debugfs_tot_len;
168 *pos = c->min + (reg_offset * map->debugfs_tot_len);
169 mutex_unlock(&map->cache_lock);
170 return c->base_reg + (reg_offset * map->reg_stride);
176 mutex_unlock(&map->cache_lock);
181 static inline void regmap_calc_tot_len(struct regmap *map,
185 if (!map->debugfs_tot_len) {
186 map->debugfs_reg_len = regmap_calc_reg_len(map->max_register);
187 map->debugfs_val_len = 2 * map->format.val_bytes;
188 map->debugfs_tot_len = map->debugfs_reg_len +
189 map->debugfs_val_len + 3; /* : \n */
193 static int regmap_next_readable_reg(struct regmap *map, int reg)
198 if (regmap_printable(map, reg + map->reg_stride)) {
199 ret = reg + map->reg_stride;
201 mutex_lock(&map->cache_lock);
202 list_for_each_entry(c, &map->debugfs_off_cache, list) {
210 mutex_unlock(&map->cache_lock);
215 static ssize_t regmap_read_debugfs(struct regmap *map, unsigned int from,
236 regmap_calc_tot_len(map, buf, count);
239 start_reg = regmap_debugfs_get_dump_start(map, from, *ppos, &p);
242 i = regmap_next_readable_reg(map, i)) {
247 if (buf_pos + map->debugfs_tot_len > count)
252 map->debugfs_reg_len, i - from);
253 buf_pos += map->debugfs_reg_len + 2;
256 ret = regmap_read(map, i, &val);
259 "%.*x", map->debugfs_val_len, val);
262 map->debugfs_val_len);
263 buf_pos += 2 * map->format.val_bytes;
267 p += map->debugfs_tot_len;
287 struct regmap *map = file->private_data;
289 return regmap_read_debugfs(map, 0, map->max_register, user_buf,
309 struct regmap *map = file->private_data;
328 ret = regmap_write(map, reg, value);
348 struct regmap *map = range->map;
350 return regmap_read_debugfs(map, range->range_min, range->range_max,
364 struct regmap *map = file->private_data;
394 regmap_calc_tot_len(map, buf, count);
395 regmap_debugfs_get_dump_start(map, 0, *ppos, &p);
400 mutex_lock(&map->cache_lock);
401 list_for_each_entry(c, &map->debugfs_off_cache, list) {
412 mutex_unlock(&map->cache_lock);
436 struct regmap *map = s->private;
439 reg_len = regmap_calc_reg_len(map->max_register);
441 for (i = 0; i <= map->max_register; i += map->reg_stride) {
443 if (!regmap_readable(map, i) && !regmap_writeable(map, i))
448 regmap_readable(map, i) ? 'y' : 'n',
449 regmap_writeable(map, i) ? 'y' : 'n',
450 regmap_volatile(map, i) ? 'y' : 'n',
451 regmap_precious(map, i) ? 'y' : 'n');
463 struct regmap *map = container_of(file->private_data,
477 map->lock(map->lock_arg);
479 if (new_val && !map->cache_only) {
480 dev_warn(map->dev, "debugfs cache_only=Y forced\n");
482 } else if (!new_val && map->cache_only) {
483 dev_warn(map->dev, "debugfs cache_only=N forced: syncing cache\n");
486 map->cache_only = new_val;
488 map->unlock(map->lock_arg);
492 err = regcache_sync(map);
494 dev_err(map->dev, "Failed to sync cache %d\n", err);
510 struct regmap *map = container_of(file->private_data,
524 map->lock(map->lock_arg);
526 if (new_val && !map->cache_bypass) {
527 dev_warn(map->dev, "debugfs cache_bypass=Y forced\n");
529 } else if (!new_val && map->cache_bypass) {
530 dev_warn(map->dev, "debugfs cache_bypass=N forced\n");
532 map->cache_bypass = new_val;
534 map->unlock(map->lock_arg);
546 void regmap_debugfs_init(struct regmap *map)
551 const char *name = map->name;
560 if (map->debugfs_disable) {
561 dev_dbg(map->dev, "regmap locking disabled - not creating debugfs entries\n");
571 node->map = map;
578 INIT_LIST_HEAD(&map->debugfs_off_cache);
579 mutex_init(&map->cache_lock);
581 if (map->dev)
582 devname = dev_name(map->dev);
585 if (!map->debugfs_name) {
586 map->debugfs_name = kasprintf(GFP_KERNEL, "%s-%s",
588 if (!map->debugfs_name)
591 name = map->debugfs_name;
597 kfree(map->debugfs_name);
598 map->debugfs_name = kasprintf(GFP_KERNEL, "dummy%d",
600 if (!map->debugfs_name)
602 name = map->debugfs_name;
606 map->debugfs = debugfs_create_dir(name, regmap_debugfs_root);
608 debugfs_create_file("name", 0400, map->debugfs,
609 map, ®map_name_fops);
611 debugfs_create_file("range", 0400, map->debugfs,
612 map, ®map_reg_ranges_fops);
614 if (map->max_register || regmap_readable(map, 0)) {
623 debugfs_create_file("registers", registers_mode, map->debugfs,
624 map, ®map_map_fops);
625 debugfs_create_file("access", 0400, map->debugfs,
626 map, ®map_access_fops);
629 if (map->cache_type) {
630 debugfs_create_file("cache_only", 0600, map->debugfs,
631 &map->cache_only, ®map_cache_only_fops);
632 debugfs_create_bool("cache_dirty", 0400, map->debugfs,
633 &map->cache_dirty);
634 debugfs_create_file("cache_bypass", 0600, map->debugfs,
635 &map->cache_bypass,
639 next = rb_first(&map->range_tree);
645 map->debugfs, range_node,
651 if (map->cache_ops && map->cache_ops->debugfs_init)
652 map->cache_ops->debugfs_init(map);
655 void regmap_debugfs_exit(struct regmap *map)
657 if (map->debugfs) {
658 debugfs_remove_recursive(map->debugfs);
659 mutex_lock(&map->cache_lock);
660 regmap_debugfs_free_dump_cache(map);
661 mutex_unlock(&map->cache_lock);
662 kfree(map->debugfs_name);
663 map->debugfs_name = NULL;
670 if (node->map == map) {
687 regmap_debugfs_init(node->map);