Lines Matching full:map
2 * Register map access API - debugfs
23 struct regmap *map; member
43 struct regmap *map = file->private_data; in regmap_name_read_file() local
52 if (map->dev && map->dev->driver) in regmap_name_read_file()
53 name = map->dev->driver->name; in regmap_name_read_file()
72 static void regmap_debugfs_free_dump_cache(struct regmap *map) in regmap_debugfs_free_dump_cache() argument
76 while (!list_empty(&map->debugfs_off_cache)) { in regmap_debugfs_free_dump_cache()
77 c = list_first_entry(&map->debugfs_off_cache, in regmap_debugfs_free_dump_cache()
85 static bool regmap_printable(struct regmap *map, unsigned int reg) in regmap_printable() argument
87 if (regmap_precious(map, reg)) in regmap_printable()
90 if (!regmap_readable(map, reg) && !regmap_cached(map, reg)) in regmap_printable()
100 static unsigned int regmap_debugfs_get_dump_start(struct regmap *map, in regmap_debugfs_get_dump_start() argument
119 mutex_lock(&map->cache_lock); in regmap_debugfs_get_dump_start()
121 if (list_empty(&map->debugfs_off_cache)) { in regmap_debugfs_get_dump_start()
122 for (; i <= map->max_register; i += map->reg_stride) { in regmap_debugfs_get_dump_start()
124 if (!regmap_printable(map, i)) { in regmap_debugfs_get_dump_start()
127 c->max_reg = i - map->reg_stride; in regmap_debugfs_get_dump_start()
129 &map->debugfs_off_cache); in regmap_debugfs_get_dump_start()
140 regmap_debugfs_free_dump_cache(map); in regmap_debugfs_get_dump_start()
141 mutex_unlock(&map->cache_lock); in regmap_debugfs_get_dump_start()
148 p += map->debugfs_tot_len; in regmap_debugfs_get_dump_start()
155 c->max_reg = i - map->reg_stride; in regmap_debugfs_get_dump_start()
157 &map->debugfs_off_cache); in regmap_debugfs_get_dump_start()
165 WARN_ON(list_empty(&map->debugfs_off_cache)); in regmap_debugfs_get_dump_start()
169 list_for_each_entry(c, &map->debugfs_off_cache, list) { in regmap_debugfs_get_dump_start()
172 reg_offset = fpos_offset / map->debugfs_tot_len; in regmap_debugfs_get_dump_start()
173 *pos = c->min + (reg_offset * map->debugfs_tot_len); in regmap_debugfs_get_dump_start()
174 mutex_unlock(&map->cache_lock); in regmap_debugfs_get_dump_start()
175 return c->base_reg + (reg_offset * map->reg_stride); in regmap_debugfs_get_dump_start()
181 mutex_unlock(&map->cache_lock); in regmap_debugfs_get_dump_start()
186 static inline void regmap_calc_tot_len(struct regmap *map, in regmap_calc_tot_len() argument
190 if (!map->debugfs_tot_len) { in regmap_calc_tot_len()
191 map->debugfs_reg_len = regmap_calc_reg_len(map->max_register), in regmap_calc_tot_len()
192 map->debugfs_val_len = 2 * map->format.val_bytes; in regmap_calc_tot_len()
193 map->debugfs_tot_len = map->debugfs_reg_len + in regmap_calc_tot_len()
194 map->debugfs_val_len + 3; /* : \n */ in regmap_calc_tot_len()
198 static ssize_t regmap_read_debugfs(struct regmap *map, unsigned int from, in regmap_read_debugfs() argument
219 regmap_calc_tot_len(map, buf, count); in regmap_read_debugfs()
222 start_reg = regmap_debugfs_get_dump_start(map, from, *ppos, &p); in regmap_read_debugfs()
224 for (i = start_reg; i <= to; i += map->reg_stride) { in regmap_read_debugfs()
225 if (!regmap_readable(map, i) && !regmap_cached(map, i)) in regmap_read_debugfs()
228 if (regmap_precious(map, i)) in regmap_read_debugfs()
234 if (buf_pos + map->debugfs_tot_len > count) in regmap_read_debugfs()
239 map->debugfs_reg_len, i - from); in regmap_read_debugfs()
240 buf_pos += map->debugfs_reg_len + 2; in regmap_read_debugfs()
243 ret = regmap_read(map, i, &val); in regmap_read_debugfs()
246 "%.*x", map->debugfs_val_len, val); in regmap_read_debugfs()
249 map->debugfs_val_len); in regmap_read_debugfs()
250 buf_pos += 2 * map->format.val_bytes; in regmap_read_debugfs()
254 p += map->debugfs_tot_len; in regmap_read_debugfs()
274 struct regmap *map = file->private_data; in regmap_map_read_file() local
276 return regmap_read_debugfs(map, 0, map->max_register, user_buf, in regmap_map_read_file()
296 struct regmap *map = file->private_data; in regmap_map_write_file() local
315 ret = regmap_write(map, reg, value); in regmap_map_write_file()
335 struct regmap *map = range->map; in regmap_range_read_file() local
337 return regmap_read_debugfs(map, range->range_min, range->range_max, in regmap_range_read_file()
351 struct regmap *map = file->private_data; in regmap_reg_ranges_read_file() local
381 regmap_calc_tot_len(map, buf, count); in regmap_reg_ranges_read_file()
382 regmap_debugfs_get_dump_start(map, 0, *ppos, &p); in regmap_reg_ranges_read_file()
387 mutex_lock(&map->cache_lock); in regmap_reg_ranges_read_file()
388 list_for_each_entry(c, &map->debugfs_off_cache, list) { in regmap_reg_ranges_read_file()
399 mutex_unlock(&map->cache_lock); in regmap_reg_ranges_read_file()
423 struct regmap *map = s->private; in regmap_access_show() local
426 reg_len = regmap_calc_reg_len(map->max_register); in regmap_access_show()
428 for (i = 0; i <= map->max_register; i += map->reg_stride) { in regmap_access_show()
430 if (!regmap_readable(map, i) && !regmap_writeable(map, i)) in regmap_access_show()
435 regmap_readable(map, i) ? 'y' : 'n', in regmap_access_show()
436 regmap_writeable(map, i) ? 'y' : 'n', in regmap_access_show()
437 regmap_volatile(map, i) ? 'y' : 'n', in regmap_access_show()
438 regmap_precious(map, i) ? 'y' : 'n'); in regmap_access_show()
460 struct regmap *map = container_of(file->private_data, in regmap_cache_only_write_file() local
474 map->lock(map->lock_arg); in regmap_cache_only_write_file()
476 if (new_val && !map->cache_only) { in regmap_cache_only_write_file()
477 dev_warn(map->dev, "debugfs cache_only=Y forced\n"); in regmap_cache_only_write_file()
479 } else if (!new_val && map->cache_only) { in regmap_cache_only_write_file()
480 dev_warn(map->dev, "debugfs cache_only=N forced: syncing cache\n"); in regmap_cache_only_write_file()
483 map->cache_only = new_val; in regmap_cache_only_write_file()
485 map->unlock(map->lock_arg); in regmap_cache_only_write_file()
489 err = regcache_sync(map); in regmap_cache_only_write_file()
491 dev_err(map->dev, "Failed to sync cache %d\n", err); in regmap_cache_only_write_file()
507 struct regmap *map = container_of(file->private_data, in regmap_cache_bypass_write_file() local
521 map->lock(map->lock_arg); in regmap_cache_bypass_write_file()
523 if (new_val && !map->cache_bypass) { in regmap_cache_bypass_write_file()
524 dev_warn(map->dev, "debugfs cache_bypass=Y forced\n"); in regmap_cache_bypass_write_file()
526 } else if (!new_val && map->cache_bypass) { in regmap_cache_bypass_write_file()
527 dev_warn(map->dev, "debugfs cache_bypass=N forced\n"); in regmap_cache_bypass_write_file()
529 map->cache_bypass = new_val; in regmap_cache_bypass_write_file()
531 map->unlock(map->lock_arg); in regmap_cache_bypass_write_file()
543 void regmap_debugfs_init(struct regmap *map, const char *name) in regmap_debugfs_init() argument
556 if (map->debugfs_disable) { in regmap_debugfs_init()
557 dev_dbg(map->dev, "regmap locking disabled - not creating debugfs entries\n"); in regmap_debugfs_init()
567 node->map = map; in regmap_debugfs_init()
575 INIT_LIST_HEAD(&map->debugfs_off_cache); in regmap_debugfs_init()
576 mutex_init(&map->cache_lock); in regmap_debugfs_init()
578 if (map->dev) in regmap_debugfs_init()
579 devname = dev_name(map->dev); in regmap_debugfs_init()
582 map->debugfs_name = kasprintf(GFP_KERNEL, "%s-%s", in regmap_debugfs_init()
584 name = map->debugfs_name; in regmap_debugfs_init()
590 kfree(map->debugfs_name); in regmap_debugfs_init()
592 map->debugfs_name = kasprintf(GFP_KERNEL, "dummy%d", in regmap_debugfs_init()
594 name = map->debugfs_name; in regmap_debugfs_init()
598 map->debugfs = debugfs_create_dir(name, regmap_debugfs_root); in regmap_debugfs_init()
599 if (!map->debugfs) { in regmap_debugfs_init()
600 dev_warn(map->dev, in regmap_debugfs_init()
603 kfree(map->debugfs_name); in regmap_debugfs_init()
604 map->debugfs_name = NULL; in regmap_debugfs_init()
608 debugfs_create_file("name", 0400, map->debugfs, in regmap_debugfs_init()
609 map, ®map_name_fops); in regmap_debugfs_init()
611 debugfs_create_file("range", 0400, map->debugfs, in regmap_debugfs_init()
612 map, ®map_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, ®map_map_fops); in regmap_debugfs_init()
625 debugfs_create_file("access", 0400, map->debugfs, in regmap_debugfs_init()
626 map, ®map_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, ®map_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()
639 next = rb_first(&map->range_tree); in regmap_debugfs_init()
645 map->debugfs, range_node, in regmap_debugfs_init()
651 if (map->cache_ops && map->cache_ops->debugfs_init) in regmap_debugfs_init()
652 map->cache_ops->debugfs_init(map); in regmap_debugfs_init()
655 void regmap_debugfs_exit(struct regmap *map) in regmap_debugfs_exit() argument
657 if (map->debugfs) { in regmap_debugfs_exit()
658 debugfs_remove_recursive(map->debugfs); in regmap_debugfs_exit()
659 mutex_lock(&map->cache_lock); in regmap_debugfs_exit()
660 regmap_debugfs_free_dump_cache(map); in regmap_debugfs_exit()
661 mutex_unlock(&map->cache_lock); in regmap_debugfs_exit()
662 kfree(map->debugfs_name); in regmap_debugfs_exit()
669 if (node->map == map) { in regmap_debugfs_exit()
690 regmap_debugfs_init(node->map, node->name); in regmap_debugfs_initcall()