Lines Matching refs:map
19 struct regmap *map; member
39 struct regmap *map = file->private_data; in regmap_name_read_file() local
48 if (map->dev && map->dev->driver) in regmap_name_read_file()
49 name = map->dev->driver->name; in regmap_name_read_file()
68 static void regmap_debugfs_free_dump_cache(struct regmap *map) in regmap_debugfs_free_dump_cache() argument
72 while (!list_empty(&map->debugfs_off_cache)) { in regmap_debugfs_free_dump_cache()
73 c = list_first_entry(&map->debugfs_off_cache, in regmap_debugfs_free_dump_cache()
81 static bool regmap_printable(struct regmap *map, unsigned int reg) in regmap_printable() argument
83 if (regmap_precious(map, reg)) in regmap_printable()
86 if (!regmap_readable(map, reg) && !regmap_cached(map, reg)) in regmap_printable()
96 static unsigned int regmap_debugfs_get_dump_start(struct regmap *map, in regmap_debugfs_get_dump_start() argument
115 mutex_lock(&map->cache_lock); in regmap_debugfs_get_dump_start()
117 if (list_empty(&map->debugfs_off_cache)) { in regmap_debugfs_get_dump_start()
118 for (; i <= map->max_register; i += map->reg_stride) { in regmap_debugfs_get_dump_start()
120 if (!regmap_printable(map, i)) { in regmap_debugfs_get_dump_start()
123 c->max_reg = i - map->reg_stride; in regmap_debugfs_get_dump_start()
125 &map->debugfs_off_cache); in regmap_debugfs_get_dump_start()
136 regmap_debugfs_free_dump_cache(map); in regmap_debugfs_get_dump_start()
137 mutex_unlock(&map->cache_lock); in regmap_debugfs_get_dump_start()
144 p += map->debugfs_tot_len; in regmap_debugfs_get_dump_start()
151 c->max_reg = i - map->reg_stride; in regmap_debugfs_get_dump_start()
153 &map->debugfs_off_cache); in regmap_debugfs_get_dump_start()
161 WARN_ON(list_empty(&map->debugfs_off_cache)); in regmap_debugfs_get_dump_start()
165 list_for_each_entry(c, &map->debugfs_off_cache, list) { in regmap_debugfs_get_dump_start()
168 reg_offset = fpos_offset / map->debugfs_tot_len; in regmap_debugfs_get_dump_start()
169 *pos = c->min + (reg_offset * map->debugfs_tot_len); in regmap_debugfs_get_dump_start()
170 mutex_unlock(&map->cache_lock); in regmap_debugfs_get_dump_start()
171 return c->base_reg + (reg_offset * map->reg_stride); in regmap_debugfs_get_dump_start()
177 mutex_unlock(&map->cache_lock); in regmap_debugfs_get_dump_start()
182 static inline void regmap_calc_tot_len(struct regmap *map, in regmap_calc_tot_len() argument
186 if (!map->debugfs_tot_len) { in regmap_calc_tot_len()
187 map->debugfs_reg_len = regmap_calc_reg_len(map->max_register), in regmap_calc_tot_len()
188 map->debugfs_val_len = 2 * map->format.val_bytes; in regmap_calc_tot_len()
189 map->debugfs_tot_len = map->debugfs_reg_len + in regmap_calc_tot_len()
190 map->debugfs_val_len + 3; /* : \n */ in regmap_calc_tot_len()
194 static int regmap_next_readable_reg(struct regmap *map, int reg) in regmap_next_readable_reg() argument
199 if (regmap_printable(map, reg + map->reg_stride)) { in regmap_next_readable_reg()
200 ret = reg + map->reg_stride; in regmap_next_readable_reg()
202 mutex_lock(&map->cache_lock); in regmap_next_readable_reg()
203 list_for_each_entry(c, &map->debugfs_off_cache, list) { in regmap_next_readable_reg()
211 mutex_unlock(&map->cache_lock); in regmap_next_readable_reg()
216 static ssize_t regmap_read_debugfs(struct regmap *map, unsigned int from, in regmap_read_debugfs() argument
234 regmap_calc_tot_len(map, buf, count); in regmap_read_debugfs()
237 start_reg = regmap_debugfs_get_dump_start(map, from, *ppos, &p); in regmap_read_debugfs()
240 i = regmap_next_readable_reg(map, i)) { in regmap_read_debugfs()
245 if (buf_pos + map->debugfs_tot_len > count) in regmap_read_debugfs()
250 map->debugfs_reg_len, i - from); in regmap_read_debugfs()
251 buf_pos += map->debugfs_reg_len + 2; in regmap_read_debugfs()
254 ret = regmap_read(map, i, &val); in regmap_read_debugfs()
257 "%.*x", map->debugfs_val_len, val); in regmap_read_debugfs()
260 map->debugfs_val_len); in regmap_read_debugfs()
261 buf_pos += 2 * map->format.val_bytes; in regmap_read_debugfs()
265 p += map->debugfs_tot_len; in regmap_read_debugfs()
285 struct regmap *map = file->private_data; in regmap_map_read_file() local
287 return regmap_read_debugfs(map, 0, map->max_register, user_buf, in regmap_map_read_file()
307 struct regmap *map = file->private_data; in regmap_map_write_file() local
326 ret = regmap_write(map, reg, value); in regmap_map_write_file()
346 struct regmap *map = range->map; in regmap_range_read_file() local
348 return regmap_read_debugfs(map, range->range_min, range->range_max, in regmap_range_read_file()
362 struct regmap *map = file->private_data; in regmap_reg_ranges_read_file() local
389 regmap_calc_tot_len(map, buf, count); in regmap_reg_ranges_read_file()
390 regmap_debugfs_get_dump_start(map, 0, *ppos, &p); in regmap_reg_ranges_read_file()
395 mutex_lock(&map->cache_lock); in regmap_reg_ranges_read_file()
396 list_for_each_entry(c, &map->debugfs_off_cache, list) { in regmap_reg_ranges_read_file()
407 mutex_unlock(&map->cache_lock); in regmap_reg_ranges_read_file()
431 struct regmap *map = s->private; in regmap_access_show() local
434 reg_len = regmap_calc_reg_len(map->max_register); in regmap_access_show()
436 for (i = 0; i <= map->max_register; i += map->reg_stride) { in regmap_access_show()
438 if (!regmap_readable(map, i) && !regmap_writeable(map, i)) in regmap_access_show()
443 regmap_readable(map, i) ? 'y' : 'n', in regmap_access_show()
444 regmap_writeable(map, i) ? 'y' : 'n', in regmap_access_show()
445 regmap_volatile(map, i) ? 'y' : 'n', in regmap_access_show()
446 regmap_precious(map, i) ? 'y' : 'n'); in regmap_access_show()
458 struct regmap *map = container_of(file->private_data, in regmap_cache_only_write_file() local
464 map->lock(map->lock_arg); in regmap_cache_only_write_file()
466 was_enabled = map->cache_only; in regmap_cache_only_write_file()
470 map->unlock(map->lock_arg); in regmap_cache_only_write_file()
474 if (map->cache_only && !was_enabled) { in regmap_cache_only_write_file()
475 dev_warn(map->dev, "debugfs cache_only=Y forced\n"); in regmap_cache_only_write_file()
477 } else if (!map->cache_only && was_enabled) { in regmap_cache_only_write_file()
478 dev_warn(map->dev, "debugfs cache_only=N forced: syncing cache\n"); in regmap_cache_only_write_file()
482 map->unlock(map->lock_arg); in regmap_cache_only_write_file()
485 err = regcache_sync(map); in regmap_cache_only_write_file()
487 dev_err(map->dev, "Failed to sync cache %d\n", err); in regmap_cache_only_write_file()
503 struct regmap *map = container_of(file->private_data, in regmap_cache_bypass_write_file() local
508 map->lock(map->lock_arg); in regmap_cache_bypass_write_file()
510 was_enabled = map->cache_bypass; in regmap_cache_bypass_write_file()
516 if (map->cache_bypass && !was_enabled) { in regmap_cache_bypass_write_file()
517 dev_warn(map->dev, "debugfs cache_bypass=Y forced\n"); in regmap_cache_bypass_write_file()
519 } else if (!map->cache_bypass && was_enabled) { in regmap_cache_bypass_write_file()
520 dev_warn(map->dev, "debugfs cache_bypass=N forced\n"); in regmap_cache_bypass_write_file()
524 map->unlock(map->lock_arg); in regmap_cache_bypass_write_file()
535 void regmap_debugfs_init(struct regmap *map, const char *name) in regmap_debugfs_init() argument
548 if (map->debugfs_disable) { in regmap_debugfs_init()
549 dev_dbg(map->dev, "regmap locking disabled - not creating debugfs entries\n"); in regmap_debugfs_init()
559 node->map = map; in regmap_debugfs_init()
567 INIT_LIST_HEAD(&map->debugfs_off_cache); in regmap_debugfs_init()
568 mutex_init(&map->cache_lock); in regmap_debugfs_init()
570 if (map->dev) in regmap_debugfs_init()
571 devname = dev_name(map->dev); in regmap_debugfs_init()
574 map->debugfs_name = kasprintf(GFP_KERNEL, "%s-%s", in regmap_debugfs_init()
576 name = map->debugfs_name; in regmap_debugfs_init()
582 kfree(map->debugfs_name); in regmap_debugfs_init()
584 map->debugfs_name = kasprintf(GFP_KERNEL, "dummy%d", in regmap_debugfs_init()
586 name = map->debugfs_name; in regmap_debugfs_init()
590 map->debugfs = debugfs_create_dir(name, regmap_debugfs_root); in regmap_debugfs_init()
592 debugfs_create_file("name", 0400, map->debugfs, in regmap_debugfs_init()
593 map, ®map_name_fops); in regmap_debugfs_init()
595 debugfs_create_file("range", 0400, map->debugfs, in regmap_debugfs_init()
596 map, ®map_reg_ranges_fops); in regmap_debugfs_init()
598 if (map->max_register || regmap_readable(map, 0)) { in regmap_debugfs_init()
607 debugfs_create_file("registers", registers_mode, map->debugfs, in regmap_debugfs_init()
608 map, ®map_map_fops); in regmap_debugfs_init()
609 debugfs_create_file("access", 0400, map->debugfs, in regmap_debugfs_init()
610 map, ®map_access_fops); in regmap_debugfs_init()
613 if (map->cache_type) { in regmap_debugfs_init()
614 debugfs_create_file("cache_only", 0600, map->debugfs, in regmap_debugfs_init()
615 &map->cache_only, ®map_cache_only_fops); in regmap_debugfs_init()
616 debugfs_create_bool("cache_dirty", 0400, map->debugfs, in regmap_debugfs_init()
617 &map->cache_dirty); in regmap_debugfs_init()
618 debugfs_create_file("cache_bypass", 0600, map->debugfs, in regmap_debugfs_init()
619 &map->cache_bypass, in regmap_debugfs_init()
623 next = rb_first(&map->range_tree); in regmap_debugfs_init()
629 map->debugfs, range_node, in regmap_debugfs_init()
635 if (map->cache_ops && map->cache_ops->debugfs_init) in regmap_debugfs_init()
636 map->cache_ops->debugfs_init(map); in regmap_debugfs_init()
639 void regmap_debugfs_exit(struct regmap *map) in regmap_debugfs_exit() argument
641 if (map->debugfs) { in regmap_debugfs_exit()
642 debugfs_remove_recursive(map->debugfs); in regmap_debugfs_exit()
643 mutex_lock(&map->cache_lock); in regmap_debugfs_exit()
644 regmap_debugfs_free_dump_cache(map); in regmap_debugfs_exit()
645 mutex_unlock(&map->cache_lock); in regmap_debugfs_exit()
646 kfree(map->debugfs_name); in regmap_debugfs_exit()
653 if (node->map == map) { in regmap_debugfs_exit()
670 regmap_debugfs_init(node->map, node->name); in regmap_debugfs_initcall()