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
473 map->lock(map->lock_arg); in regmap_cache_only_write_file()
475 if (new_val && !map->cache_only) { in regmap_cache_only_write_file()
476 dev_warn(map->dev, "debugfs cache_only=Y forced\n"); in regmap_cache_only_write_file()
478 } else if (!new_val && map->cache_only) { in regmap_cache_only_write_file()
479 dev_warn(map->dev, "debugfs cache_only=N forced: syncing cache\n"); in regmap_cache_only_write_file()
482 map->cache_only = new_val; in regmap_cache_only_write_file()
484 map->unlock(map->lock_arg); in regmap_cache_only_write_file()
487 err = regcache_sync(map); in regmap_cache_only_write_file()
489 dev_err(map->dev, "Failed to sync cache %d\n", err); in regmap_cache_only_write_file()
505 struct regmap *map = container_of(file->private_data, in regmap_cache_bypass_write_file() local
515 map->lock(map->lock_arg); in regmap_cache_bypass_write_file()
517 if (new_val && !map->cache_bypass) { in regmap_cache_bypass_write_file()
518 dev_warn(map->dev, "debugfs cache_bypass=Y forced\n"); in regmap_cache_bypass_write_file()
520 } else if (!new_val && map->cache_bypass) { in regmap_cache_bypass_write_file()
521 dev_warn(map->dev, "debugfs cache_bypass=N forced\n"); in regmap_cache_bypass_write_file()
523 map->cache_bypass = new_val; in regmap_cache_bypass_write_file()
525 map->unlock(map->lock_arg); in regmap_cache_bypass_write_file()
536 void regmap_debugfs_init(struct regmap *map) in regmap_debugfs_init() argument
541 const char *name = map->name; in regmap_debugfs_init()
550 if (map->debugfs_disable) { in regmap_debugfs_init()
551 dev_dbg(map->dev, "regmap locking disabled - not creating debugfs entries\n"); in regmap_debugfs_init()
561 node->map = map; in regmap_debugfs_init()
568 INIT_LIST_HEAD(&map->debugfs_off_cache); in regmap_debugfs_init()
569 mutex_init(&map->cache_lock); in regmap_debugfs_init()
571 if (map->dev) in regmap_debugfs_init()
572 devname = dev_name(map->dev); in regmap_debugfs_init()
575 if (!map->debugfs_name) { in regmap_debugfs_init()
576 map->debugfs_name = kasprintf(GFP_KERNEL, "%s-%s", in regmap_debugfs_init()
578 if (!map->debugfs_name) in regmap_debugfs_init()
581 name = map->debugfs_name; in regmap_debugfs_init()
587 kfree(map->debugfs_name); in regmap_debugfs_init()
588 map->debugfs_name = kasprintf(GFP_KERNEL, "dummy%d", in regmap_debugfs_init()
590 if (!map->debugfs_name) in regmap_debugfs_init()
592 name = map->debugfs_name; in regmap_debugfs_init()
596 map->debugfs = debugfs_create_dir(name, regmap_debugfs_root); in regmap_debugfs_init()
598 debugfs_create_file("name", 0400, map->debugfs, in regmap_debugfs_init()
599 map, ®map_name_fops); in regmap_debugfs_init()
601 debugfs_create_file("range", 0400, map->debugfs, in regmap_debugfs_init()
602 map, ®map_reg_ranges_fops); in regmap_debugfs_init()
604 if (map->max_register || regmap_readable(map, 0)) { in regmap_debugfs_init()
613 debugfs_create_file("registers", registers_mode, map->debugfs, in regmap_debugfs_init()
614 map, ®map_map_fops); in regmap_debugfs_init()
615 debugfs_create_file("access", 0400, map->debugfs, in regmap_debugfs_init()
616 map, ®map_access_fops); in regmap_debugfs_init()
619 if (map->cache_type) { in regmap_debugfs_init()
620 debugfs_create_file("cache_only", 0600, map->debugfs, in regmap_debugfs_init()
621 &map->cache_only, ®map_cache_only_fops); in regmap_debugfs_init()
622 debugfs_create_bool("cache_dirty", 0400, map->debugfs, in regmap_debugfs_init()
623 &map->cache_dirty); in regmap_debugfs_init()
624 debugfs_create_file("cache_bypass", 0600, map->debugfs, in regmap_debugfs_init()
625 &map->cache_bypass, in regmap_debugfs_init()
636 debugfs_create_bool("force_write_field", 0600, map->debugfs, in regmap_debugfs_init()
637 &map->force_write_field); in regmap_debugfs_init()
640 next = rb_first(&map->range_tree); in regmap_debugfs_init()
646 map->debugfs, range_node, in regmap_debugfs_init()
652 if (map->cache_ops && map->cache_ops->debugfs_init) in regmap_debugfs_init()
653 map->cache_ops->debugfs_init(map); in regmap_debugfs_init()
656 void regmap_debugfs_exit(struct regmap *map) in regmap_debugfs_exit() argument
658 if (map->debugfs) { in regmap_debugfs_exit()
659 debugfs_remove_recursive(map->debugfs); in regmap_debugfs_exit()
660 mutex_lock(&map->cache_lock); in regmap_debugfs_exit()
661 regmap_debugfs_free_dump_cache(map); in regmap_debugfs_exit()
662 mutex_unlock(&map->cache_lock); in regmap_debugfs_exit()
663 kfree(map->debugfs_name); in regmap_debugfs_exit()
664 map->debugfs_name = NULL; in regmap_debugfs_exit()
671 if (node->map == map) { in regmap_debugfs_exit()
688 regmap_debugfs_init(node->map); in regmap_debugfs_initcall()