Lines Matching refs:map
23 struct regmap *map; member
42 struct regmap *map = file->private_data; in regmap_name_read_file() local
50 ret = snprintf(buf, PAGE_SIZE, "%s\n", 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()
84 static unsigned int regmap_debugfs_get_dump_start(struct regmap *map, in regmap_debugfs_get_dump_start() argument
103 mutex_lock(&map->cache_lock); in regmap_debugfs_get_dump_start()
105 if (list_empty(&map->debugfs_off_cache)) { in regmap_debugfs_get_dump_start()
106 for (; i <= map->max_register; i += map->reg_stride) { in regmap_debugfs_get_dump_start()
108 if (!regmap_readable(map, i) || in regmap_debugfs_get_dump_start()
109 regmap_precious(map, i)) { in regmap_debugfs_get_dump_start()
112 c->max_reg = i - map->reg_stride; in regmap_debugfs_get_dump_start()
114 &map->debugfs_off_cache); in regmap_debugfs_get_dump_start()
125 regmap_debugfs_free_dump_cache(map); in regmap_debugfs_get_dump_start()
126 mutex_unlock(&map->cache_lock); in regmap_debugfs_get_dump_start()
133 p += map->debugfs_tot_len; in regmap_debugfs_get_dump_start()
140 c->max_reg = i - map->reg_stride; in regmap_debugfs_get_dump_start()
142 &map->debugfs_off_cache); in regmap_debugfs_get_dump_start()
150 WARN_ON(list_empty(&map->debugfs_off_cache)); in regmap_debugfs_get_dump_start()
154 list_for_each_entry(c, &map->debugfs_off_cache, list) { in regmap_debugfs_get_dump_start()
157 reg_offset = fpos_offset / map->debugfs_tot_len; in regmap_debugfs_get_dump_start()
158 *pos = c->min + (reg_offset * map->debugfs_tot_len); in regmap_debugfs_get_dump_start()
159 mutex_unlock(&map->cache_lock); in regmap_debugfs_get_dump_start()
160 return c->base_reg + (reg_offset * map->reg_stride); in regmap_debugfs_get_dump_start()
166 mutex_unlock(&map->cache_lock); in regmap_debugfs_get_dump_start()
171 static inline void regmap_calc_tot_len(struct regmap *map, in regmap_calc_tot_len() argument
175 if (!map->debugfs_tot_len) { in regmap_calc_tot_len()
176 map->debugfs_reg_len = regmap_calc_reg_len(map->max_register), in regmap_calc_tot_len()
177 map->debugfs_val_len = 2 * map->format.val_bytes; in regmap_calc_tot_len()
178 map->debugfs_tot_len = map->debugfs_reg_len + in regmap_calc_tot_len()
179 map->debugfs_val_len + 3; /* : \n */ in regmap_calc_tot_len()
183 static ssize_t regmap_read_debugfs(struct regmap *map, unsigned int from, in regmap_read_debugfs() argument
201 regmap_calc_tot_len(map, buf, count); in regmap_read_debugfs()
204 start_reg = regmap_debugfs_get_dump_start(map, from, *ppos, &p); in regmap_read_debugfs()
206 for (i = start_reg; i <= to; i += map->reg_stride) { in regmap_read_debugfs()
207 if (!regmap_readable(map, i)) in regmap_read_debugfs()
210 if (regmap_precious(map, i)) in regmap_read_debugfs()
216 if (buf_pos + map->debugfs_tot_len > count) in regmap_read_debugfs()
221 map->debugfs_reg_len, i - from); in regmap_read_debugfs()
222 buf_pos += map->debugfs_reg_len + 2; in regmap_read_debugfs()
225 ret = regmap_read(map, i, &val); in regmap_read_debugfs()
228 "%.*x", map->debugfs_val_len, val); in regmap_read_debugfs()
231 map->debugfs_val_len); in regmap_read_debugfs()
232 buf_pos += 2 * map->format.val_bytes; in regmap_read_debugfs()
236 p += map->debugfs_tot_len; in regmap_read_debugfs()
256 struct regmap *map = file->private_data; in regmap_map_read_file() local
258 return regmap_read_debugfs(map, 0, map->max_register, user_buf, in regmap_map_read_file()
278 struct regmap *map = file->private_data; in regmap_map_write_file() local
297 ret = regmap_write(map, reg, value); in regmap_map_write_file()
317 struct regmap *map = range->map; in regmap_range_read_file() local
319 return regmap_read_debugfs(map, range->range_min, range->range_max, in regmap_range_read_file()
333 struct regmap *map = file->private_data; in regmap_reg_ranges_read_file() local
360 regmap_calc_tot_len(map, buf, count); in regmap_reg_ranges_read_file()
361 regmap_debugfs_get_dump_start(map, 0, *ppos, &p); in regmap_reg_ranges_read_file()
366 mutex_lock(&map->cache_lock); in regmap_reg_ranges_read_file()
367 list_for_each_entry(c, &map->debugfs_off_cache, list) { in regmap_reg_ranges_read_file()
378 mutex_unlock(&map->cache_lock); in regmap_reg_ranges_read_file()
409 struct regmap *map = file->private_data; in regmap_access_read_file() local
420 reg_len = regmap_calc_reg_len(map->max_register); in regmap_access_read_file()
423 for (i = 0; i <= map->max_register; i += map->reg_stride) { in regmap_access_read_file()
425 if (!regmap_readable(map, i) && !regmap_writeable(map, i)) in regmap_access_read_file()
438 regmap_readable(map, i) ? 'y' : 'n', in regmap_access_read_file()
439 regmap_writeable(map, i) ? 'y' : 'n', in regmap_access_read_file()
440 regmap_volatile(map, i) ? 'y' : 'n', in regmap_access_read_file()
441 regmap_precious(map, i) ? 'y' : 'n'); in regmap_access_read_file()
472 struct regmap *map = container_of(file->private_data, in regmap_cache_only_write_file() local
478 map->lock(map->lock_arg); in regmap_cache_only_write_file()
480 was_enabled = map->cache_only; in regmap_cache_only_write_file()
484 map->unlock(map->lock_arg); in regmap_cache_only_write_file()
488 if (map->cache_only && !was_enabled) { in regmap_cache_only_write_file()
489 dev_warn(map->dev, "debugfs cache_only=Y forced\n"); in regmap_cache_only_write_file()
491 } else if (!map->cache_only && was_enabled) { in regmap_cache_only_write_file()
492 dev_warn(map->dev, "debugfs cache_only=N forced: syncing cache\n"); in regmap_cache_only_write_file()
496 map->unlock(map->lock_arg); in regmap_cache_only_write_file()
499 err = regcache_sync(map); in regmap_cache_only_write_file()
501 dev_err(map->dev, "Failed to sync cache %d\n", err); in regmap_cache_only_write_file()
517 struct regmap *map = container_of(file->private_data, in regmap_cache_bypass_write_file() local
522 map->lock(map->lock_arg); in regmap_cache_bypass_write_file()
524 was_enabled = map->cache_bypass; in regmap_cache_bypass_write_file()
530 if (map->cache_bypass && !was_enabled) { in regmap_cache_bypass_write_file()
531 dev_warn(map->dev, "debugfs cache_bypass=Y forced\n"); in regmap_cache_bypass_write_file()
533 } else if (!map->cache_bypass && was_enabled) { in regmap_cache_bypass_write_file()
534 dev_warn(map->dev, "debugfs cache_bypass=N forced\n"); in regmap_cache_bypass_write_file()
538 map->unlock(map->lock_arg); in regmap_cache_bypass_write_file()
549 void regmap_debugfs_init(struct regmap *map, const char *name) in regmap_debugfs_init() argument
561 node->map = map; in regmap_debugfs_init()
569 INIT_LIST_HEAD(&map->debugfs_off_cache); in regmap_debugfs_init()
570 mutex_init(&map->cache_lock); in regmap_debugfs_init()
572 if (map->dev) in regmap_debugfs_init()
573 devname = dev_name(map->dev); in regmap_debugfs_init()
576 map->debugfs_name = kasprintf(GFP_KERNEL, "%s-%s", in regmap_debugfs_init()
578 name = map->debugfs_name; in regmap_debugfs_init()
583 map->debugfs = debugfs_create_dir(name, regmap_debugfs_root); in regmap_debugfs_init()
584 if (!map->debugfs) { in regmap_debugfs_init()
585 dev_warn(map->dev, "Failed to create debugfs directory\n"); in regmap_debugfs_init()
589 debugfs_create_file("name", 0400, map->debugfs, in regmap_debugfs_init()
590 map, ®map_name_fops); in regmap_debugfs_init()
592 debugfs_create_file("range", 0400, map->debugfs, in regmap_debugfs_init()
593 map, ®map_reg_ranges_fops); in regmap_debugfs_init()
595 if (map->max_register || regmap_readable(map, 0)) { in regmap_debugfs_init()
604 debugfs_create_file("registers", registers_mode, map->debugfs, in regmap_debugfs_init()
605 map, ®map_map_fops); in regmap_debugfs_init()
606 debugfs_create_file("access", 0400, map->debugfs, in regmap_debugfs_init()
607 map, ®map_access_fops); in regmap_debugfs_init()
610 if (map->cache_type) { in regmap_debugfs_init()
611 debugfs_create_file("cache_only", 0600, map->debugfs, in regmap_debugfs_init()
612 &map->cache_only, ®map_cache_only_fops); in regmap_debugfs_init()
613 debugfs_create_bool("cache_dirty", 0400, map->debugfs, in regmap_debugfs_init()
614 &map->cache_dirty); in regmap_debugfs_init()
615 debugfs_create_file("cache_bypass", 0600, map->debugfs, in regmap_debugfs_init()
616 &map->cache_bypass, in regmap_debugfs_init()
620 next = rb_first(&map->range_tree); in regmap_debugfs_init()
626 map->debugfs, range_node, in regmap_debugfs_init()
632 if (map->cache_ops && map->cache_ops->debugfs_init) in regmap_debugfs_init()
633 map->cache_ops->debugfs_init(map); in regmap_debugfs_init()
636 void regmap_debugfs_exit(struct regmap *map) in regmap_debugfs_exit() argument
638 if (map->debugfs) { in regmap_debugfs_exit()
639 debugfs_remove_recursive(map->debugfs); in regmap_debugfs_exit()
640 mutex_lock(&map->cache_lock); in regmap_debugfs_exit()
641 regmap_debugfs_free_dump_cache(map); in regmap_debugfs_exit()
642 mutex_unlock(&map->cache_lock); in regmap_debugfs_exit()
643 kfree(map->debugfs_name); in regmap_debugfs_exit()
650 if (node->map == map) { in regmap_debugfs_exit()
671 regmap_debugfs_init(node->map, node->name); in regmap_debugfs_initcall()