aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/regmap
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2013-03-29 16:12:21 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2013-03-30 09:52:31 -0400
commitcfdeb8c37ed32024dcb7d2e3bd70e2a9f9dfc0e6 (patch)
treee10157dd5d641acc1a680f4615e7ecb013f1f311 /drivers/base/regmap
parentf8bd822cbf953299b2957b45f6a43c08e7931ddc (diff)
regmap: cache: Split raw and non-raw syncs
For code clarity after implementing block writes split out the raw and non-raw I/O sync implementations. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Reviewed-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/base/regmap')
-rw-r--r--drivers/base/regmap/regcache.c64
1 files changed, 53 insertions, 11 deletions
diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c
index bb317db6818f..da4d9843520f 100644
--- a/drivers/base/regmap/regcache.c
+++ b/drivers/base/regmap/regcache.c
@@ -545,9 +545,43 @@ int regcache_lookup_reg(struct regmap *map, unsigned int reg)
545 return -ENOENT; 545 return -ENOENT;
546} 546}
547 547
548int regcache_sync_block(struct regmap *map, void *block, 548static int regcache_sync_block_single(struct regmap *map, void *block,
549 unsigned int block_base, unsigned int start, 549 unsigned int block_base,
550 unsigned int end) 550 unsigned int start, unsigned int end)
551{
552 unsigned int i, regtmp, val;
553 int ret;
554
555 for (i = start; i < end; i++) {
556 regtmp = block_base + (i * map->reg_stride);
557
558 if (!regcache_reg_present(map, regtmp))
559 continue;
560
561 val = regcache_get_val(map, block, i);
562
563 /* Is this the hardware default? If so skip. */
564 ret = regcache_lookup_reg(map, regtmp);
565 if (ret >= 0 && val == map->reg_defaults[ret].def)
566 continue;
567
568 map->cache_bypass = 1;
569
570 ret = _regmap_write(map, regtmp, val);
571
572 map->cache_bypass = 0;
573 if (ret != 0)
574 return ret;
575 dev_dbg(map->dev, "Synced register %#x, value %#x\n",
576 regtmp, val);
577 }
578
579 return 0;
580}
581
582int regcache_sync_block_raw(struct regmap *map, void *block,
583 unsigned int block_base, unsigned int start,
584 unsigned int end)
551{ 585{
552 unsigned int i, regtmp, val; 586 unsigned int i, regtmp, val;
553 const void *addr; 587 const void *addr;
@@ -568,14 +602,10 @@ int regcache_sync_block(struct regmap *map, void *block,
568 602
569 map->cache_bypass = 1; 603 map->cache_bypass = 1;
570 604
571 if (regmap_can_raw_write(map)) { 605 addr = regcache_get_val_addr(map, block, i);
572 addr = regcache_get_val_addr(map, block, i); 606 ret = _regmap_raw_write(map, regtmp, addr,
573 ret = _regmap_raw_write(map, regtmp, addr, 607 map->format.val_bytes,
574 map->format.val_bytes, 608 false);
575 false);
576 } else {
577 ret = _regmap_write(map, regtmp, val);
578 }
579 609
580 map->cache_bypass = 0; 610 map->cache_bypass = 0;
581 if (ret != 0) 611 if (ret != 0)
@@ -586,3 +616,15 @@ int regcache_sync_block(struct regmap *map, void *block,
586 616
587 return 0; 617 return 0;
588} 618}
619
620int regcache_sync_block(struct regmap *map, void *block,
621 unsigned int block_base, unsigned int start,
622 unsigned int end)
623{
624 if (regmap_can_raw_write(map))
625 return regcache_sync_block_raw(map, block, block_base,
626 start, end);
627 else
628 return regcache_sync_block_single(map, block, block_base,
629 start, end);
630}