Lines Matching refs:map

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