diff options
author | Xiubo Li <Li.Xiubo@freescale.com> | 2014-03-27 00:42:43 -0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2014-03-27 06:55:55 -0400 |
commit | 932580409a9dacbf42215fa737bf06ae2c0aa624 (patch) | |
tree | 58609e1ba0911aba76a70b7219ddfea92bdbb3fc /drivers/base | |
parent | 41b0c2c976a8758a2b7f5b14cbc5d1a7436932cc (diff) |
regmap: mmio: Add support for 1/2/8 bytes wide register address.
Since regmap core and mmio have already support for 1/2/8 bytes wide values,
so adds support for 1/2/8 bytes wide registers address.
Signed-off-by: Xiubo Li <Li.Xiubo@freescale.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'drivers/base')
-rw-r--r-- | drivers/base/regmap/regmap-mmio.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/drivers/base/regmap/regmap-mmio.c b/drivers/base/regmap/regmap-mmio.c index 4f1efce94034..ed080a47b1f8 100644 --- a/drivers/base/regmap/regmap-mmio.c +++ b/drivers/base/regmap/regmap-mmio.c | |||
@@ -26,18 +26,30 @@ | |||
26 | 26 | ||
27 | struct regmap_mmio_context { | 27 | struct regmap_mmio_context { |
28 | void __iomem *regs; | 28 | void __iomem *regs; |
29 | unsigned reg_bytes; | ||
29 | unsigned val_bytes; | 30 | unsigned val_bytes; |
31 | unsigned pad_bytes; | ||
30 | struct clk *clk; | 32 | struct clk *clk; |
31 | }; | 33 | }; |
32 | 34 | ||
33 | static inline void regmap_mmio_regsize_check(size_t reg_size) | 35 | static inline void regmap_mmio_regsize_check(size_t reg_size) |
34 | { | 36 | { |
35 | BUG_ON(reg_size != 4); | 37 | switch (reg_size) { |
38 | case 1: | ||
39 | case 2: | ||
40 | case 4: | ||
41 | #ifdef CONFIG_64BIT | ||
42 | case 8: | ||
43 | #endif | ||
44 | break; | ||
45 | default: | ||
46 | BUG(); | ||
47 | } | ||
36 | } | 48 | } |
37 | 49 | ||
38 | static inline void regmap_mmio_count_check(size_t count) | 50 | static inline void regmap_mmio_count_check(size_t count) |
39 | { | 51 | { |
40 | BUG_ON(count < 4); | 52 | BUG_ON(count % 2 != 0); |
41 | } | 53 | } |
42 | 54 | ||
43 | static int regmap_mmio_gather_write(void *context, | 55 | static int regmap_mmio_gather_write(void *context, |
@@ -91,9 +103,13 @@ static int regmap_mmio_gather_write(void *context, | |||
91 | 103 | ||
92 | static int regmap_mmio_write(void *context, const void *data, size_t count) | 104 | static int regmap_mmio_write(void *context, const void *data, size_t count) |
93 | { | 105 | { |
106 | struct regmap_mmio_context *ctx = context; | ||
107 | u32 offset = ctx->reg_bytes + ctx->pad_bytes; | ||
108 | |||
94 | regmap_mmio_count_check(count); | 109 | regmap_mmio_count_check(count); |
95 | 110 | ||
96 | return regmap_mmio_gather_write(context, data, 4, data + 4, count - 4); | 111 | return regmap_mmio_gather_write(context, data, ctx->reg_bytes, |
112 | data + offset, count - offset); | ||
97 | } | 113 | } |
98 | 114 | ||
99 | static int regmap_mmio_read(void *context, | 115 | static int regmap_mmio_read(void *context, |
@@ -219,6 +235,8 @@ static struct regmap_mmio_context *regmap_mmio_gen_context(struct device *dev, | |||
219 | 235 | ||
220 | ctx->regs = regs; | 236 | ctx->regs = regs; |
221 | ctx->val_bytes = config->val_bits / 8; | 237 | ctx->val_bytes = config->val_bits / 8; |
238 | ctx->reg_bytes = config->reg_bits / 8; | ||
239 | ctx->pad_bytes = config->pad_bits / 8; | ||
222 | ctx->clk = ERR_PTR(-ENODEV); | 240 | ctx->clk = ERR_PTR(-ENODEV); |
223 | 241 | ||
224 | if (clk_id == NULL) | 242 | if (clk_id == NULL) |