diff options
author | Xiubo Li <Li.Xiubo@freescale.com> | 2014-04-11 02:27:16 (GMT) |
---|---|---|
committer | Matthew Weigel <Matthew.Weigel@freescale.com> | 2014-12-11 18:36:13 (GMT) |
commit | aba9bc9b6a99f4bde2ab22f42feff4c1de8aea50 (patch) | |
tree | 7aa0bcbc3f8d484e735d1e6164c3444f2a5145d6 /drivers/base/regmap | |
parent | 2837afbc45893c37e0ae28d653209da6937fa952 (diff) | |
download | linux-fsl-qoriq-aba9bc9b6a99f4bde2ab22f42feff4c1de8aea50.tar.xz |
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>
---
This patch is pulled back from upstream:
commit 932580409a9dacbf42215fa737bf06ae2c0aa624
Change-Id: I148882774797f7a53d6123d0b5dd757231025b6e
Reviewed-on: http://git.am.freescale.net:8181/19673
Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com>
Reviewed-by: Zhengxiong Jin <Jason.Jin@freescale.com>
Diffstat (limited to 'drivers/base/regmap')
-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 3eddd76..c76f278 100644 --- a/drivers/base/regmap/regmap-mmio.c +++ b/drivers/base/regmap/regmap-mmio.c @@ -26,18 +26,30 @@ struct regmap_mmio_context { void __iomem *regs; + unsigned reg_bytes; unsigned val_bytes; + unsigned pad_bytes; struct clk *clk; }; static inline void regmap_mmio_regsize_check(size_t reg_size) { - BUG_ON(reg_size != 4); + switch (reg_size) { + case 1: + case 2: + case 4: +#ifdef CONFIG_64BIT + case 8: +#endif + break; + default: + BUG(); + } } static inline void regmap_mmio_count_check(size_t count) { - BUG_ON(count < 4); + BUG_ON(count % 2 != 0); } static int regmap_mmio_gather_write(void *context, @@ -91,9 +103,13 @@ static int regmap_mmio_gather_write(void *context, static int regmap_mmio_write(void *context, const void *data, size_t count) { + struct regmap_mmio_context *ctx = context; + u32 offset = ctx->reg_bytes + ctx->pad_bytes; + regmap_mmio_count_check(count); - return regmap_mmio_gather_write(context, data, 4, data + 4, count - 4); + return regmap_mmio_gather_write(context, data, ctx->reg_bytes, + data + offset, count - offset); } static int regmap_mmio_read(void *context, @@ -219,6 +235,8 @@ static struct regmap_mmio_context *regmap_mmio_gen_context(struct device *dev, ctx->regs = regs; ctx->val_bytes = config->val_bits / 8; + ctx->reg_bytes = config->reg_bits / 8; + ctx->pad_bytes = config->pad_bits / 8; if (clk_id == NULL) return ctx; |