* [PATCH 1/2] regmap: mmio: add regmap_mmio_{regsize, count}_check.
@ 2014-03-27 4:42 Xiubo Li
2014-03-27 4:42 ` [PATCH 2/2] regmap: mmio: Add support for 1/2/8 bytes wide register address Xiubo Li
2014-03-27 10:58 ` [PATCH 1/2] regmap: mmio: add regmap_mmio_{regsize, count}_check Mark Brown
0 siblings, 2 replies; 3+ messages in thread
From: Xiubo Li @ 2014-03-27 4:42 UTC (permalink / raw)
To: broonie, gregkh; +Cc: linux-kernel, Xiubo Li
Signed-off-by: Xiubo Li <Li.Xiubo@freescale.com>
---
drivers/base/regmap/regmap-mmio.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/drivers/base/regmap/regmap-mmio.c b/drivers/base/regmap/regmap-mmio.c
index 81f9775..4f1efce 100644
--- a/drivers/base/regmap/regmap-mmio.c
+++ b/drivers/base/regmap/regmap-mmio.c
@@ -30,6 +30,16 @@ struct regmap_mmio_context {
struct clk *clk;
};
+static inline void regmap_mmio_regsize_check(size_t reg_size)
+{
+ BUG_ON(reg_size != 4);
+}
+
+static inline void regmap_mmio_count_check(size_t count)
+{
+ BUG_ON(count < 4);
+}
+
static int regmap_mmio_gather_write(void *context,
const void *reg, size_t reg_size,
const void *val, size_t val_size)
@@ -38,7 +48,7 @@ static int regmap_mmio_gather_write(void *context,
u32 offset;
int ret;
- BUG_ON(reg_size != 4);
+ regmap_mmio_regsize_check(reg_size);
if (!IS_ERR(ctx->clk)) {
ret = clk_enable(ctx->clk);
@@ -81,7 +91,7 @@ static int regmap_mmio_gather_write(void *context,
static int regmap_mmio_write(void *context, const void *data, size_t count)
{
- BUG_ON(count < 4);
+ regmap_mmio_count_check(count);
return regmap_mmio_gather_write(context, data, 4, data + 4, count - 4);
}
@@ -94,7 +104,7 @@ static int regmap_mmio_read(void *context,
u32 offset;
int ret;
- BUG_ON(reg_size != 4);
+ regmap_mmio_regsize_check(reg_size);
if (!IS_ERR(ctx->clk)) {
ret = clk_enable(ctx->clk);
--
1.8.4
^ permalink raw reply [flat|nested] 3+ messages in thread* [PATCH 2/2] regmap: mmio: Add support for 1/2/8 bytes wide register address.
2014-03-27 4:42 [PATCH 1/2] regmap: mmio: add regmap_mmio_{regsize, count}_check Xiubo Li
@ 2014-03-27 4:42 ` Xiubo Li
2014-03-27 10:58 ` [PATCH 1/2] regmap: mmio: add regmap_mmio_{regsize, count}_check Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Xiubo Li @ 2014-03-27 4:42 UTC (permalink / raw)
To: broonie, gregkh; +Cc: linux-kernel, Xiubo Li
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>
---
drivers/base/regmap/regmap-mmio.c | 24 +++++++++++++++++++++---
1 file changed, 21 insertions(+), 3 deletions(-)
diff --git a/drivers/base/regmap/regmap-mmio.c b/drivers/base/regmap/regmap-mmio.c
index 4f1efce..ed080a4 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;
ctx->clk = ERR_PTR(-ENODEV);
if (clk_id == NULL)
--
1.8.4
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH 1/2] regmap: mmio: add regmap_mmio_{regsize, count}_check.
2014-03-27 4:42 [PATCH 1/2] regmap: mmio: add regmap_mmio_{regsize, count}_check Xiubo Li
2014-03-27 4:42 ` [PATCH 2/2] regmap: mmio: Add support for 1/2/8 bytes wide register address Xiubo Li
@ 2014-03-27 10:58 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2014-03-27 10:58 UTC (permalink / raw)
To: Xiubo Li; +Cc: gregkh, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 132 bytes --]
On Thu, Mar 27, 2014 at 12:42:42PM +0800, Xiubo Li wrote:
> Signed-off-by: Xiubo Li <Li.Xiubo@freescale.com>
Applied both, thanks.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-03-27 10:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-27 4:42 [PATCH 1/2] regmap: mmio: add regmap_mmio_{regsize, count}_check Xiubo Li
2014-03-27 4:42 ` [PATCH 2/2] regmap: mmio: Add support for 1/2/8 bytes wide register address Xiubo Li
2014-03-27 10:58 ` [PATCH 1/2] regmap: mmio: add regmap_mmio_{regsize, count}_check Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®