1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright (C) 2020 ROHM Semiconductors */
7 #include <linux/types.h>
10 * struct linear_range - table of selector - value pairs
12 * Define a lookup-table for range of values. Intended to help when looking
13 * for a register value matching certaing physical measure (like voltage).
14 * Usable when increment of one in register always results a constant increment
15 * of the physical measure (like voltage).
17 * @min: Lowest value in range
18 * @min_sel: Lowest selector for range
19 * @max_sel: Highest selector for range
20 * @step: Value step size
29 unsigned int linear_range_values_in_range(const struct linear_range *r);
30 unsigned int linear_range_values_in_range_array(const struct linear_range *r,
32 unsigned int linear_range_get_max_value(const struct linear_range *r);
34 int linear_range_get_value(const struct linear_range *r, unsigned int selector,
36 int linear_range_get_value_array(const struct linear_range *r, int ranges,
37 unsigned int selector, unsigned int *val);
38 int linear_range_get_selector_low(const struct linear_range *r,
39 unsigned int val, unsigned int *selector,
41 int linear_range_get_selector_high(const struct linear_range *r,
42 unsigned int val, unsigned int *selector,
44 void linear_range_get_selector_within(const struct linear_range *r,
45 unsigned int val, unsigned int *selector);
46 int linear_range_get_selector_low_array(const struct linear_range *r,
47 int ranges, unsigned int val,
48 unsigned int *selector, bool *found);