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()
178 map->debugfs_val_len = 2 * map->format.val_bytes; in regmap_calc_tot_len()
179 map->debugfs_tot_len = map->debugfs_reg_len + in regmap_calc_tot_len()
180 map->debugfs_val_len + 3; /* : \n */ in regmap_calc_tot_len()
184 static ssize_t regmap_read_debugfs(struct regmap *map, unsigned int from, in regmap_read_debugfs() argument
202 regmap_calc_tot_len(map, buf, count); in regmap_read_debugfs()
205 start_reg = regmap_debugfs_get_dump_start(map, from, *ppos, &p); in regmap_read_debugfs()
207 for (i = start_reg; i <= to; i += map->reg_stride) { in regmap_read_debugfs()
208 if (!regmap_readable(map, i)) in regmap_read_debugfs()
211 if (regmap_precious(map, i)) in regmap_read_debugfs()
217 if (buf_pos + map->debugfs_tot_len > count) in regmap_read_debugfs()
222 map->debugfs_reg_len, i - from); in regmap_read_debugfs()
223 buf_pos += map->debugfs_reg_len + 2; in regmap_read_debugfs()
226 ret = regmap_read(map, i, &val); in regmap_read_debugfs()
229 "%.*x", map->debugfs_val_len, val); in regmap_read_debugfs()
232 map->debugfs_val_len); in regmap_read_debugfs()
233 buf_pos += 2 * map->format.val_bytes; in regmap_read_debugfs()
237 p += map->debugfs_tot_len; in regmap_read_debugfs()
257 struct regmap *map = file->private_data; in regmap_map_read_file() local
259 return regmap_read_debugfs(map, 0, map->max_register, user_buf, in regmap_map_read_file()
279 struct regmap *map = file->private_data; in regmap_map_write_file() local
298 ret = regmap_write(map, reg, value); in regmap_map_write_file()
318 struct regmap *map = range->map; in regmap_range_read_file() local
320 return regmap_read_debugfs(map, range->range_min, range->range_max, in regmap_range_read_file()
334 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()
381 mutex_unlock(&map->cache_lock); in regmap_reg_ranges_read_file()
412 struct regmap *map = file->private_data; in regmap_access_read_file() local
423 reg_len = regmap_calc_reg_len(map->max_register, buf, count); in regmap_access_read_file()
426 for (i = 0; i <= map->max_register; i += map->reg_stride) { in regmap_access_read_file()
428 if (!regmap_readable(map, i) && !regmap_writeable(map, i)) in regmap_access_read_file()
441 regmap_readable(map, i) ? 'y' : 'n', in regmap_access_read_file()
442 regmap_writeable(map, i) ? 'y' : 'n', in regmap_access_read_file()
443 regmap_volatile(map, i) ? 'y' : 'n', in regmap_access_read_file()
444 regmap_precious(map, i) ? 'y' : 'n'); in regmap_access_read_file()
471 void regmap_debugfs_init(struct regmap *map, const char *name) in regmap_debugfs_init() argument
483 node->map = map; in regmap_debugfs_init()
491 INIT_LIST_HEAD(&map->debugfs_off_cache); in regmap_debugfs_init()
492 mutex_init(&map->cache_lock); in regmap_debugfs_init()
494 if (map->dev) in regmap_debugfs_init()
495 devname = dev_name(map->dev); in regmap_debugfs_init()
498 map->debugfs_name = kasprintf(GFP_KERNEL, "%s-%s", in regmap_debugfs_init()
500 name = map->debugfs_name; in regmap_debugfs_init()
505 map->debugfs = debugfs_create_dir(name, regmap_debugfs_root); in regmap_debugfs_init()
506 if (!map->debugfs) { in regmap_debugfs_init()
507 dev_warn(map->dev, "Failed to create debugfs directory\n"); in regmap_debugfs_init()
511 debugfs_create_file("name", 0400, map->debugfs, in regmap_debugfs_init()
512 map, ®map_name_fops); in regmap_debugfs_init()
514 debugfs_create_file("range", 0400, map->debugfs, in regmap_debugfs_init()
515 map, ®map_reg_ranges_fops); in regmap_debugfs_init()
517 if (map->max_register || regmap_readable(map, 0)) { in regmap_debugfs_init()
525 debugfs_create_file("registers", registers_mode, map->debugfs, in regmap_debugfs_init()
526 map, ®map_map_fops); in regmap_debugfs_init()
527 debugfs_create_file("access", 0400, map->debugfs, in regmap_debugfs_init()
528 map, ®map_access_fops); in regmap_debugfs_init()
531 if (map->cache_type) { in regmap_debugfs_init()
532 debugfs_create_bool("cache_only", 0400, map->debugfs, in regmap_debugfs_init()
533 &map->cache_only); in regmap_debugfs_init()
534 debugfs_create_bool("cache_dirty", 0400, map->debugfs, in regmap_debugfs_init()
535 &map->cache_dirty); in regmap_debugfs_init()
536 debugfs_create_bool("cache_bypass", 0400, map->debugfs, in regmap_debugfs_init()
537 &map->cache_bypass); in regmap_debugfs_init()
540 next = rb_first(&map->range_tree); in regmap_debugfs_init()
546 map->debugfs, range_node, in regmap_debugfs_init()
552 if (map->cache_ops && map->cache_ops->debugfs_init) in regmap_debugfs_init()
553 map->cache_ops->debugfs_init(map); in regmap_debugfs_init()
556 void regmap_debugfs_exit(struct regmap *map) in regmap_debugfs_exit() argument
558 if (map->debugfs) { in regmap_debugfs_exit()
559 debugfs_remove_recursive(map->debugfs); in regmap_debugfs_exit()
560 mutex_lock(&map->cache_lock); in regmap_debugfs_exit()
561 regmap_debugfs_free_dump_cache(map); in regmap_debugfs_exit()
562 mutex_unlock(&map->cache_lock); in regmap_debugfs_exit()
563 kfree(map->debugfs_name); in regmap_debugfs_exit()
570 if (node->map == map) { in regmap_debugfs_exit()
591 regmap_debugfs_init(node->map, node->name); in regmap_debugfs_initcall()