Skip to content

Commit 4a98da2

Browse files
nomisbroonie
authored andcommitted
regmap-mmio: Use native endianness for read/write
The regmap API has an endianness setting for formatting reads and writes. This can be set by the usual DT "little-endian" and "big-endian" properties. To work properly the associated regmap_bus needs to read/write in native endian. The "syscon" DT device binding creates an mmio-based regmap_bus which performs all reads/writes as little-endian. These values are then converted again by regmap, which means that all of the MIPS BCM boards (which are big-endian) have been declared as "little-endian" to get regmap to convert them back to big-endian. Modify regmap-mmio to use the native-endian functions __raw_read*() and __raw_write*() instead of the little-endian functions read*() and write*(). Modify the big-endian MIPS BCM boards to use what will now be the correct endianness instead of pretending that the devices are little-endian. Signed-off-by: Simon Arlott <simon@fire.lp0.eu> Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 6ff33f3 commit 4a98da2

File tree

10 files changed

+8
-17
lines changed

10 files changed

+8
-17
lines changed

arch/mips/boot/dts/brcm/bcm6328.dtsi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@
7373
timer: timer@10000040 {
7474
compatible = "syscon";
7575
reg = <0x10000040 0x2c>;
76-
little-endian;
7776
};
7877

7978
reboot {

arch/mips/boot/dts/brcm/bcm7125.dtsi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@
9898
sun_top_ctrl: syscon@404000 {
9999
compatible = "brcm,bcm7125-sun-top-ctrl", "syscon";
100100
reg = <0x404000 0x60c>;
101-
little-endian;
102101
};
103102

104103
reboot {

arch/mips/boot/dts/brcm/bcm7346.dtsi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@
100100
sun_top_ctrl: syscon@404000 {
101101
compatible = "brcm,bcm7346-sun-top-ctrl", "syscon";
102102
reg = <0x404000 0x51c>;
103-
little-endian;
104103
};
105104

106105
reboot {

arch/mips/boot/dts/brcm/bcm7358.dtsi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@
9494
sun_top_ctrl: syscon@404000 {
9595
compatible = "brcm,bcm7358-sun-top-ctrl", "syscon";
9696
reg = <0x404000 0x51c>;
97-
little-endian;
9897
};
9998

10099
reboot {

arch/mips/boot/dts/brcm/bcm7360.dtsi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@
9494
sun_top_ctrl: syscon@404000 {
9595
compatible = "brcm,bcm7360-sun-top-ctrl", "syscon";
9696
reg = <0x404000 0x51c>;
97-
little-endian;
9897
};
9998

10099
reboot {

arch/mips/boot/dts/brcm/bcm7362.dtsi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@
100100
sun_top_ctrl: syscon@404000 {
101101
compatible = "brcm,bcm7362-sun-top-ctrl", "syscon";
102102
reg = <0x404000 0x51c>;
103-
little-endian;
104103
};
105104

106105
reboot {

arch/mips/boot/dts/brcm/bcm7420.dtsi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@
9999
sun_top_ctrl: syscon@404000 {
100100
compatible = "brcm,bcm7420-sun-top-ctrl", "syscon";
101101
reg = <0x404000 0x60c>;
102-
little-endian;
103102
};
104103

105104
reboot {

arch/mips/boot/dts/brcm/bcm7425.dtsi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@
100100
sun_top_ctrl: syscon@404000 {
101101
compatible = "brcm,bcm7425-sun-top-ctrl", "syscon";
102102
reg = <0x404000 0x51c>;
103-
little-endian;
104103
};
105104

106105
reboot {

arch/mips/boot/dts/brcm/bcm7435.dtsi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@
114114
sun_top_ctrl: syscon@404000 {
115115
compatible = "brcm,bcm7425-sun-top-ctrl", "syscon";
116116
reg = <0x404000 0x51c>;
117-
little-endian;
118117
};
119118

120119
reboot {

drivers/base/regmap/regmap-mmio.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,17 +106,17 @@ static int regmap_mmio_gather_write(void *context,
106106
while (val_size) {
107107
switch (ctx->val_bytes) {
108108
case 1:
109-
writeb(*(u8 *)val, ctx->regs + offset);
109+
__raw_writeb(*(u8 *)val, ctx->regs + offset);
110110
break;
111111
case 2:
112-
writew(*(u16 *)val, ctx->regs + offset);
112+
__raw_writew(*(u16 *)val, ctx->regs + offset);
113113
break;
114114
case 4:
115-
writel(*(u32 *)val, ctx->regs + offset);
115+
__raw_writel(*(u32 *)val, ctx->regs + offset);
116116
break;
117117
#ifdef CONFIG_64BIT
118118
case 8:
119-
writeq(*(u64 *)val, ctx->regs + offset);
119+
__raw_writeq(*(u64 *)val, ctx->regs + offset);
120120
break;
121121
#endif
122122
default:
@@ -166,17 +166,17 @@ static int regmap_mmio_read(void *context,
166166
while (val_size) {
167167
switch (ctx->val_bytes) {
168168
case 1:
169-
*(u8 *)val = readb(ctx->regs + offset);
169+
*(u8 *)val = __raw_readb(ctx->regs + offset);
170170
break;
171171
case 2:
172-
*(u16 *)val = readw(ctx->regs + offset);
172+
*(u16 *)val = __raw_readw(ctx->regs + offset);
173173
break;
174174
case 4:
175-
*(u32 *)val = readl(ctx->regs + offset);
175+
*(u32 *)val = __raw_readl(ctx->regs + offset);
176176
break;
177177
#ifdef CONFIG_64BIT
178178
case 8:
179-
*(u64 *)val = readq(ctx->regs + offset);
179+
*(u64 *)val = __raw_readq(ctx->regs + offset);
180180
break;
181181
#endif
182182
default:

0 commit comments

Comments
 (0)