aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/regmap.h
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2012-12-10 22:39:32 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-12-10 22:39:32 -0500
commit8e24a6e696ebdc44513357ac00b6ee18f54e69f5 (patch)
tree82cc7ac9259a9f20159f9265aca52533b1cb3ca8 /include/linux/regmap.h
parentdb760fbecd3d609098ef4121d7988ff2a5db15d1 (diff)
parent76aad392f75e6ce5be3f106554e16f7ff96543e5 (diff)
Merge remote-tracking branch 'regmap/topic/table' into regmap-next
Diffstat (limited to 'include/linux/regmap.h')
-rw-r--r--include/linux/regmap.h83
1 files changed, 72 insertions, 11 deletions
diff --git a/include/linux/regmap.h b/include/linux/regmap.h
index fedf7ba74590..b7e95bf942c9 100644
--- a/include/linux/regmap.h
+++ b/include/linux/regmap.h
@@ -54,6 +54,36 @@ enum regmap_endian {
54 REGMAP_ENDIAN_NATIVE, 54 REGMAP_ENDIAN_NATIVE,
55}; 55};
56 56
57/**
58 * A register range, used for access related checks
59 * (readable/writeable/volatile/precious checks)
60 *
61 * @range_min: address of first register
62 * @range_max: address of last register
63 */
64struct regmap_range {
65 unsigned int range_min;
66 unsigned int range_max;
67};
68
69/*
70 * A table of ranges including some yes ranges and some no ranges.
71 * If a register belongs to a no_range, the corresponding check function
72 * will return false. If a register belongs to a yes range, the corresponding
73 * check function will return true. "no_ranges" are searched first.
74 *
75 * @yes_ranges : pointer to an array of regmap ranges used as "yes ranges"
76 * @n_yes_ranges: size of the above array
77 * @no_ranges: pointer to an array of regmap ranges used as "no ranges"
78 * @n_no_ranges: size of the above array
79 */
80struct regmap_access_table {
81 const struct regmap_range *yes_ranges;
82 unsigned int n_yes_ranges;
83 const struct regmap_range *no_ranges;
84 unsigned int n_no_ranges;
85};
86
57typedef void (*regmap_lock)(void *); 87typedef void (*regmap_lock)(void *);
58typedef void (*regmap_unlock)(void *); 88typedef void (*regmap_unlock)(void *);
59 89
@@ -71,22 +101,39 @@ typedef void (*regmap_unlock)(void *);
71 * @val_bits: Number of bits in a register value, mandatory. 101 * @val_bits: Number of bits in a register value, mandatory.
72 * 102 *
73 * @writeable_reg: Optional callback returning true if the register 103 * @writeable_reg: Optional callback returning true if the register
74 * can be written to. 104 * can be written to. If this field is NULL but wr_table
105 * (see below) is not, the check is performed on such table
106 * (a register is writeable if it belongs to one of the ranges
107 * specified by wr_table).
75 * @readable_reg: Optional callback returning true if the register 108 * @readable_reg: Optional callback returning true if the register
76 * can be read from. 109 * can be read from. If this field is NULL but rd_table
110 * (see below) is not, the check is performed on such table
111 * (a register is readable if it belongs to one of the ranges
112 * specified by rd_table).
77 * @volatile_reg: Optional callback returning true if the register 113 * @volatile_reg: Optional callback returning true if the register
78 * value can't be cached. 114 * value can't be cached. If this field is NULL but
115 * volatile_table (see below) is not, the check is performed on
116 * such table (a register is volatile if it belongs to one of
117 * the ranges specified by volatile_table).
79 * @precious_reg: Optional callback returning true if the rgister 118 * @precious_reg: Optional callback returning true if the rgister
80 * should not be read outside of a call from the driver 119 * should not be read outside of a call from the driver
81 * (eg, a clear on read interrupt status register). 120 * (eg, a clear on read interrupt status register). If this
82 * @lock: Optional lock callback (overrides regmap's default lock 121 * field is NULL but precious_table (see below) is not, the
83 * function, based on spinlock or mutex). 122 * check is performed on such table (a register is precious if
84 * @unlock: As above for unlocking. 123 * it belongs to one of the ranges specified by precious_table).
85 * @lock_arg: this field is passed as the only argument of lock/unlock 124 * @lock: Optional lock callback (overrides regmap's default lock
86 * functions (ignored in case regular lock/unlock functions 125 * function, based on spinlock or mutex).
87 * are not overridden). 126 * @unlock: As above for unlocking.
127 * @lock_arg: this field is passed as the only argument of lock/unlock
128 * functions (ignored in case regular lock/unlock functions
129 * are not overridden).
88 * 130 *
89 * @max_register: Optional, specifies the maximum valid register index. 131 * @max_register: Optional, specifies the maximum valid register index.
132 * @wr_table: Optional, points to a struct regmap_access_table specifying
133 * valid ranges for write access.
134 * @rd_table: As above, for read access.
135 * @volatile_table: As above, for volatile registers.
136 * @precious_table: As above, for precious registers.
90 * @reg_defaults: Power on reset values for registers (for use with 137 * @reg_defaults: Power on reset values for registers (for use with
91 * register cache support). 138 * register cache support).
92 * @num_reg_defaults: Number of elements in reg_defaults. 139 * @num_reg_defaults: Number of elements in reg_defaults.
@@ -131,6 +178,10 @@ struct regmap_config {
131 void *lock_arg; 178 void *lock_arg;
132 179
133 unsigned int max_register; 180 unsigned int max_register;
181 const struct regmap_access_table *wr_table;
182 const struct regmap_access_table *rd_table;
183 const struct regmap_access_table *volatile_table;
184 const struct regmap_access_table *precious_table;
134 const struct reg_default *reg_defaults; 185 const struct reg_default *reg_defaults;
135 unsigned int num_reg_defaults; 186 unsigned int num_reg_defaults;
136 enum regcache_type cache_type; 187 enum regcache_type cache_type;
@@ -281,6 +332,16 @@ void regcache_mark_dirty(struct regmap *map);
281int regmap_register_patch(struct regmap *map, const struct reg_default *regs, 332int regmap_register_patch(struct regmap *map, const struct reg_default *regs,
282 int num_regs); 333 int num_regs);
283 334
335static inline bool regmap_reg_in_range(unsigned int reg,
336 const struct regmap_range *range)
337{
338 return reg >= range->range_min && reg <= range->range_max;
339}
340
341bool regmap_reg_in_ranges(unsigned int reg,
342 const struct regmap_range *ranges,
343 unsigned int nranges);
344
284/** 345/**
285 * Description of an IRQ for the generic regmap irq_chip. 346 * Description of an IRQ for the generic regmap irq_chip.
286 * 347 *