aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorStephen Warren <swarren@nvidia.com>2012-05-24 12:47:27 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-06-03 08:11:43 -0400
commit6a55244e897d32952832a67cb35cfbfa3f722c50 (patch)
treebe0a289314b2f99ea6d4ffc2d7632d53c844e137 /drivers
parent141eba2e006dd8145bed2e49fae3de5af65ab9b0 (diff)
regmap: mmio: request native endian formatting
This will avoid the regmap core converting all addresses and values into big endian, only for the mmio bus driver to have to convert them back to native endian. Signed-off-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/base/regmap/regmap-mmio.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/drivers/base/regmap/regmap-mmio.c b/drivers/base/regmap/regmap-mmio.c
index febd6de6c8ac..eec86639cac4 100644
--- a/drivers/base/regmap/regmap-mmio.c
+++ b/drivers/base/regmap/regmap-mmio.c
@@ -37,7 +37,7 @@ static int regmap_mmio_gather_write(void *context,
37 37
38 BUG_ON(reg_size != 4); 38 BUG_ON(reg_size != 4);
39 39
40 offset = be32_to_cpup(reg); 40 offset = *(u32 *)reg;
41 41
42 while (val_size) { 42 while (val_size) {
43 switch (ctx->val_bytes) { 43 switch (ctx->val_bytes) {
@@ -45,14 +45,14 @@ static int regmap_mmio_gather_write(void *context,
45 writeb(*(u8 *)val, ctx->regs + offset); 45 writeb(*(u8 *)val, ctx->regs + offset);
46 break; 46 break;
47 case 2: 47 case 2:
48 writew(be16_to_cpup(val), ctx->regs + offset); 48 writew(*(u16 *)val, ctx->regs + offset);
49 break; 49 break;
50 case 4: 50 case 4:
51 writel(be32_to_cpup(val), ctx->regs + offset); 51 writel(*(u32 *)val, ctx->regs + offset);
52 break; 52 break;
53#ifdef CONFIG_64BIT 53#ifdef CONFIG_64BIT
54 case 8: 54 case 8:
55 writeq(be64_to_cpup(val), ctx->regs + offset); 55 writeq(*(u64 *)val, ctx->regs + offset);
56 break; 56 break;
57#endif 57#endif
58 default: 58 default:
@@ -83,7 +83,7 @@ static int regmap_mmio_read(void *context,
83 83
84 BUG_ON(reg_size != 4); 84 BUG_ON(reg_size != 4);
85 85
86 offset = be32_to_cpup(reg); 86 offset = *(u32 *)reg;
87 87
88 while (val_size) { 88 while (val_size) {
89 switch (ctx->val_bytes) { 89 switch (ctx->val_bytes) {
@@ -91,14 +91,14 @@ static int regmap_mmio_read(void *context,
91 *(u8 *)val = readb(ctx->regs + offset); 91 *(u8 *)val = readb(ctx->regs + offset);
92 break; 92 break;
93 case 2: 93 case 2:
94 *(u16 *)val = cpu_to_be16(readw(ctx->regs + offset)); 94 *(u16 *)val = readw(ctx->regs + offset);
95 break; 95 break;
96 case 4: 96 case 4:
97 *(u32 *)val = cpu_to_be32(readl(ctx->regs + offset)); 97 *(u32 *)val = readl(ctx->regs + offset);
98 break; 98 break;
99#ifdef CONFIG_64BIT 99#ifdef CONFIG_64BIT
100 case 8: 100 case 8:
101 *(u64 *)val = cpu_to_be32(readq(ctx->regs + offset)); 101 *(u64 *)val = readq(ctx->regs + offset);
102 break; 102 break;
103#endif 103#endif
104 default: 104 default:
@@ -124,6 +124,8 @@ static struct regmap_bus regmap_mmio = {
124 .gather_write = regmap_mmio_gather_write, 124 .gather_write = regmap_mmio_gather_write,
125 .read = regmap_mmio_read, 125 .read = regmap_mmio_read,
126 .free_context = regmap_mmio_free_context, 126 .free_context = regmap_mmio_free_context,
127 .reg_format_endian_default = REGMAP_ENDIAN_NATIVE,
128 .val_format_endian_default = REGMAP_ENDIAN_NATIVE,
127}; 129};
128 130
129struct regmap_mmio_context *regmap_mmio_gen_context(void __iomem *regs, 131struct regmap_mmio_context *regmap_mmio_gen_context(void __iomem *regs,
@@ -162,6 +164,14 @@ struct regmap_mmio_context *regmap_mmio_gen_context(void __iomem *regs,
162 if (config->reg_stride < min_stride) 164 if (config->reg_stride < min_stride)
163 return ERR_PTR(-EINVAL); 165 return ERR_PTR(-EINVAL);
164 166
167 switch (config->reg_format_endian) {
168 case REGMAP_ENDIAN_DEFAULT:
169 case REGMAP_ENDIAN_NATIVE:
170 break;
171 default:
172 return ERR_PTR(-EINVAL);
173 }
174
165 ctx = kzalloc(GFP_KERNEL, sizeof(*ctx)); 175 ctx = kzalloc(GFP_KERNEL, sizeof(*ctx));
166 if (!ctx) 176 if (!ctx)
167 return ERR_PTR(-ENOMEM); 177 return ERR_PTR(-ENOMEM);