diff options
author | Boris BREZILLON <boris.brezillon@free-electrons.com> | 2014-04-17 05:40:11 -0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2014-04-18 11:07:22 -0400 |
commit | 3ac170376f2c5123414e0267aa0f9cf218965e24 (patch) | |
tree | 2c825d39794623bdd034190f72a8acb1617d54ba /drivers/base | |
parent | c9eaa447e77efe77b7fa4c953bd62de8297fd6c5 (diff) |
regmap: add reg_read/reg_write callbacks to regmap_bus struct
Some busses do not support sending/receiving multiple registers in one go.
Such kind of busses just unpack the registers that have been previously
packed by the regmap core or pack registers that will be later unpacked by
the core code.
Add reg_write and reg_read callbacks in order to optimize access through
this kind of busses.
Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'drivers/base')
-rw-r--r-- | drivers/base/regmap/regmap.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index 63e30ef096e2..2209de0ceabc 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c | |||
@@ -35,10 +35,14 @@ static int _regmap_update_bits(struct regmap *map, unsigned int reg, | |||
35 | unsigned int mask, unsigned int val, | 35 | unsigned int mask, unsigned int val, |
36 | bool *change); | 36 | bool *change); |
37 | 37 | ||
38 | static int _regmap_bus_reg_read(void *context, unsigned int reg, | ||
39 | unsigned int *val); | ||
38 | static int _regmap_bus_read(void *context, unsigned int reg, | 40 | static int _regmap_bus_read(void *context, unsigned int reg, |
39 | unsigned int *val); | 41 | unsigned int *val); |
40 | static int _regmap_bus_formatted_write(void *context, unsigned int reg, | 42 | static int _regmap_bus_formatted_write(void *context, unsigned int reg, |
41 | unsigned int val); | 43 | unsigned int val); |
44 | static int _regmap_bus_reg_write(void *context, unsigned int reg, | ||
45 | unsigned int val); | ||
42 | static int _regmap_bus_raw_write(void *context, unsigned int reg, | 46 | static int _regmap_bus_raw_write(void *context, unsigned int reg, |
43 | unsigned int val); | 47 | unsigned int val); |
44 | 48 | ||
@@ -495,6 +499,12 @@ struct regmap *regmap_init(struct device *dev, | |||
495 | 499 | ||
496 | map->defer_caching = false; | 500 | map->defer_caching = false; |
497 | goto skip_format_initialization; | 501 | goto skip_format_initialization; |
502 | } else if (!bus->read || !bus->write) { | ||
503 | map->reg_read = _regmap_bus_reg_read; | ||
504 | map->reg_write = _regmap_bus_reg_write; | ||
505 | |||
506 | map->defer_caching = false; | ||
507 | goto skip_format_initialization; | ||
498 | } else { | 508 | } else { |
499 | map->reg_read = _regmap_bus_read; | 509 | map->reg_read = _regmap_bus_read; |
500 | } | 510 | } |
@@ -1284,6 +1294,14 @@ static int _regmap_bus_formatted_write(void *context, unsigned int reg, | |||
1284 | return ret; | 1294 | return ret; |
1285 | } | 1295 | } |
1286 | 1296 | ||
1297 | static int _regmap_bus_reg_write(void *context, unsigned int reg, | ||
1298 | unsigned int val) | ||
1299 | { | ||
1300 | struct regmap *map = context; | ||
1301 | |||
1302 | return map->bus->reg_write(map->bus_context, reg, val); | ||
1303 | } | ||
1304 | |||
1287 | static int _regmap_bus_raw_write(void *context, unsigned int reg, | 1305 | static int _regmap_bus_raw_write(void *context, unsigned int reg, |
1288 | unsigned int val) | 1306 | unsigned int val) |
1289 | { | 1307 | { |
@@ -1925,6 +1943,14 @@ static int _regmap_raw_read(struct regmap *map, unsigned int reg, void *val, | |||
1925 | return ret; | 1943 | return ret; |
1926 | } | 1944 | } |
1927 | 1945 | ||
1946 | static int _regmap_bus_reg_read(void *context, unsigned int reg, | ||
1947 | unsigned int *val) | ||
1948 | { | ||
1949 | struct regmap *map = context; | ||
1950 | |||
1951 | return map->bus->reg_read(map->bus_context, reg, val); | ||
1952 | } | ||
1953 | |||
1928 | static int _regmap_bus_read(void *context, unsigned int reg, | 1954 | static int _regmap_bus_read(void *context, unsigned int reg, |
1929 | unsigned int *val) | 1955 | unsigned int *val) |
1930 | { | 1956 | { |