aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/regmap.h
diff options
context:
space:
mode:
authorKrystian Garbaciak <krystian.garbaciak@diasemi.com>2012-06-15 06:23:56 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-06-17 16:34:18 -0400
commit6863ca6227598d15c372f1e03449bbb4cfbcca7f (patch)
treef665b666606afe35dcfe38899bd153412fed4771 /include/linux/regmap.h
parentfc3ebd788e894b4dd6c9524cb3874eeeb1e862d6 (diff)
regmap: Add support for register indirect addressing.
Devices with register paging or indirectly accessed registers can configure register mapping to map those on virtual address range. During access to virtually mapped register range, indirect addressing is processed automatically, in following steps: 1. selector for page or indirect register is updated (when needed); 2. register in data window is accessed. Configuration should provide minimum and maximum register for virtual range, details of selector field for page selection, minimum and maximum register of data window for indirect access. Virtual range registers are managed by cache as well as direct access registers. In order to make indirect access more efficient, selector register should be declared as non-volatile, if possible. struct regmap_config is extended with the following: struct regmap_range_cfg *ranges; unsigned int n_ranges; [Also reordered debugfs init to later on since the cleanup code was conflicting with the new cleanup code for ranges anyway -- broonie] Signed-off-by: Krystian Garbaciak <krystian.garbaciak@diasemi.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'include/linux/regmap.h')
-rw-r--r--include/linux/regmap.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/include/linux/regmap.h b/include/linux/regmap.h
index 56af22ec9aba..5f69d4ad3eb1 100644
--- a/include/linux/regmap.h
+++ b/include/linux/regmap.h
@@ -14,12 +14,14 @@
14 */ 14 */
15 15
16#include <linux/list.h> 16#include <linux/list.h>
17#include <linux/rbtree.h>
17 18
18struct module; 19struct module;
19struct device; 20struct device;
20struct i2c_client; 21struct i2c_client;
21struct spi_device; 22struct spi_device;
22struct regmap; 23struct regmap;
24struct regmap_range_cfg;
23 25
24/* An enum of all the supported cache types */ 26/* An enum of all the supported cache types */
25enum regcache_type { 27enum regcache_type {
@@ -84,6 +86,9 @@ struct reg_default {
84 * @reg_defaults_raw: Power on reset values for registers (for use with 86 * @reg_defaults_raw: Power on reset values for registers (for use with
85 * register cache support). 87 * register cache support).
86 * @num_reg_defaults_raw: Number of elements in reg_defaults_raw. 88 * @num_reg_defaults_raw: Number of elements in reg_defaults_raw.
89 *
90 * @ranges: Array of configuration entries for virtual address ranges.
91 * @num_ranges: Number of range configuration entries.
87 */ 92 */
88struct regmap_config { 93struct regmap_config {
89 const char *name; 94 const char *name;
@@ -109,6 +114,40 @@ struct regmap_config {
109 u8 write_flag_mask; 114 u8 write_flag_mask;
110 115
111 bool use_single_rw; 116 bool use_single_rw;
117
118 const struct regmap_range_cfg *ranges;
119 unsigned int n_ranges;
120};
121
122/**
123 * Configuration for indirectly accessed or paged registers.
124 * Registers, mapped to this virtual range, are accessed in two steps:
125 * 1. page selector register update;
126 * 2. access through data window registers.
127 *
128 * @range_min: Address of the lowest register address in virtual range.
129 * @range_max: Address of the highest register in virtual range.
130 *
131 * @page_sel_reg: Register with selector field.
132 * @page_sel_mask: Bit shift for selector value.
133 * @page_sel_shift: Bit mask for selector value.
134 *
135 * @window_start: Address of first (lowest) register in data window.
136 * @window_len: Number of registers in data window.
137 */
138struct regmap_range_cfg {
139 /* Registers of virtual address range */
140 unsigned int range_min;
141 unsigned int range_max;
142
143 /* Page selector for indirect addressing */
144 unsigned int selector_reg;
145 unsigned int selector_mask;
146 int selector_shift;
147
148 /* Data window (per each page) */
149 unsigned int window_start;
150 unsigned int window_len;
112}; 151};
113 152
114typedef int (*regmap_hw_write)(void *context, const void *data, 153typedef int (*regmap_hw_write)(void *context, const void *data,