Skip to content

Commit

Permalink
Merge remote-tracking branch 'regmap/topic/mmio' into regmap-next
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Brown committed Mar 5, 2016
2 parents 0e03ae7 + aacaaa4 commit 781aab8
Showing 14 changed files with 191 additions and 145 deletions.
11 changes: 7 additions & 4 deletions Documentation/devicetree/bindings/regmap/regmap.txt
Original file line number Diff line number Diff line change
@@ -5,15 +5,18 @@ Index Device Endianness properties
---------------------------------------------------
1 BE 'big-endian'
2 LE 'little-endian'
3 Native 'native-endian'

For one device driver, which will run in different scenarios above
on different SoCs using the devicetree, we need one way to simplify
this.

Required properties:
- {big,little}-endian: these are boolean properties, if absent
meaning that the CPU and the Device are in the same endianness mode,
these properties are for register values and all the buffers only.
Optional properties:
- {big,little,native}-endian: these are boolean properties, if absent
then the implementation will choose a default based on the device
being controlled. These properties are for register values and all
the buffers only. Native endian means that the CPU and device have
the same endianness.

Examples:
Scenario 1 : CPU in LE mode & device in LE mode.
2 changes: 1 addition & 1 deletion arch/mips/boot/dts/brcm/bcm6328.dtsi
Original file line number Diff line number Diff line change
@@ -74,7 +74,7 @@
timer: timer@10000040 {
compatible = "syscon";
reg = <0x10000040 0x2c>;
little-endian;
native-endian;
};

reboot {
2 changes: 1 addition & 1 deletion arch/mips/boot/dts/brcm/bcm6368.dtsi
Original file line number Diff line number Diff line change
@@ -54,7 +54,7 @@
periph_cntl: syscon@10000000 {
compatible = "syscon";
reg = <0x10000000 0x14>;
little-endian;
native-endian;
};

reboot: syscon-reboot@10000008 {
2 changes: 1 addition & 1 deletion arch/mips/boot/dts/brcm/bcm7125.dtsi
Original file line number Diff line number Diff line change
@@ -98,7 +98,7 @@
sun_top_ctrl: syscon@404000 {
compatible = "brcm,bcm7125-sun-top-ctrl", "syscon";
reg = <0x404000 0x60c>;
little-endian;
native-endian;
};

reboot {
2 changes: 1 addition & 1 deletion arch/mips/boot/dts/brcm/bcm7346.dtsi
Original file line number Diff line number Diff line change
@@ -118,7 +118,7 @@
sun_top_ctrl: syscon@404000 {
compatible = "brcm,bcm7346-sun-top-ctrl", "syscon";
reg = <0x404000 0x51c>;
little-endian;
native-endian;
};

reboot {
2 changes: 1 addition & 1 deletion arch/mips/boot/dts/brcm/bcm7358.dtsi
Original file line number Diff line number Diff line change
@@ -112,7 +112,7 @@
sun_top_ctrl: syscon@404000 {
compatible = "brcm,bcm7358-sun-top-ctrl", "syscon";
reg = <0x404000 0x51c>;
little-endian;
native-endian;
};

reboot {
2 changes: 1 addition & 1 deletion arch/mips/boot/dts/brcm/bcm7360.dtsi
Original file line number Diff line number Diff line change
@@ -112,7 +112,7 @@
sun_top_ctrl: syscon@404000 {
compatible = "brcm,bcm7360-sun-top-ctrl", "syscon";
reg = <0x404000 0x51c>;
little-endian;
native-endian;
};

reboot {
2 changes: 1 addition & 1 deletion arch/mips/boot/dts/brcm/bcm7362.dtsi
Original file line number Diff line number Diff line change
@@ -118,7 +118,7 @@
sun_top_ctrl: syscon@404000 {
compatible = "brcm,bcm7362-sun-top-ctrl", "syscon";
reg = <0x404000 0x51c>;
little-endian;
native-endian;
};

reboot {
2 changes: 1 addition & 1 deletion arch/mips/boot/dts/brcm/bcm7420.dtsi
Original file line number Diff line number Diff line change
@@ -99,7 +99,7 @@
sun_top_ctrl: syscon@404000 {
compatible = "brcm,bcm7420-sun-top-ctrl", "syscon";
reg = <0x404000 0x60c>;
little-endian;
native-endian;
};

reboot {
2 changes: 1 addition & 1 deletion arch/mips/boot/dts/brcm/bcm7425.dtsi
Original file line number Diff line number Diff line change
@@ -100,7 +100,7 @@
sun_top_ctrl: syscon@404000 {
compatible = "brcm,bcm7425-sun-top-ctrl", "syscon";
reg = <0x404000 0x51c>;
little-endian;
native-endian;
};

reboot {
2 changes: 1 addition & 1 deletion arch/mips/boot/dts/brcm/bcm7435.dtsi
Original file line number Diff line number Diff line change
@@ -114,7 +114,7 @@
sun_top_ctrl: syscon@404000 {
compatible = "brcm,bcm7425-sun-top-ctrl", "syscon";
reg = <0x404000 0x51c>;
little-endian;
native-endian;
};

reboot {
41 changes: 30 additions & 11 deletions drivers/base/regmap/regcache.c
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@ static int regcache_hw_init(struct regmap *map)
int i, j;
int ret;
int count;
unsigned int val;
unsigned int reg, val;
void *tmp_buf;

if (!map->num_reg_defaults_raw)
@@ -67,27 +67,46 @@ static int regcache_hw_init(struct regmap *map)
ret = regmap_raw_read(map, 0, tmp_buf,
map->cache_size_raw);
map->cache_bypass = cache_bypass;
if (ret < 0)
goto err_cache_free;

map->reg_defaults_raw = tmp_buf;
map->cache_free = 1;
if (ret == 0) {
map->reg_defaults_raw = tmp_buf;
map->cache_free = 1;
} else {
kfree(tmp_buf);
}
}

/* fill the reg_defaults */
for (i = 0, j = 0; i < map->num_reg_defaults_raw; i++) {
if (regmap_volatile(map, i * map->reg_stride))
reg = i * map->reg_stride;

if (!regmap_readable(map, reg))
continue;
val = regcache_get_val(map, map->reg_defaults_raw, i);
map->reg_defaults[j].reg = i * map->reg_stride;

if (regmap_volatile(map, reg))
continue;

if (map->reg_defaults_raw) {
val = regcache_get_val(map, map->reg_defaults_raw, i);
} else {
bool cache_bypass = map->cache_bypass;

map->cache_bypass = true;
ret = regmap_read(map, reg, &val);
map->cache_bypass = cache_bypass;
if (ret != 0) {
dev_err(map->dev, "Failed to read %d: %d\n",
reg, ret);
goto err_free;
}
}

map->reg_defaults[j].reg = reg;
map->reg_defaults[j].def = val;
j++;
}

return 0;

err_cache_free:
kfree(tmp_buf);
err_free:
kfree(map->reg_defaults);

Loading

0 comments on commit 781aab8

Please sign in to comment.