Commit 3def927ea8c0a1983aa9f1499645efc53e005bb6

Authored by Peter Ujfalusi
Committed by Lee Jones
1 parent 8daf354065

mfd: twl-core: API to set the regcache bypass for a given regmap in twl

If the regcache is enabled on the regmap module drivers might need to access
to HW register(s) in certain cases in cache bypass mode.
As an example of this is the audio block's ANAMICL register. In normal
operation the content can be cached but during initialization one bit from
the register need to be monitored. With the twl_set_regcache_bypass() the
client driver can switch regcache bypass on and off when it is needed so
we can utilize the regcache for more registers.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Acked-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>

Showing 2 changed files with 24 additions and 0 deletions Side-by-side Diff

drivers/mfd/twl-core.c
... ... @@ -383,6 +383,27 @@
383 383 }
384 384 EXPORT_SYMBOL(twl_i2c_read);
385 385  
  386 +/**
  387 + * twl_regcache_bypass - Configure the regcache bypass for the regmap associated
  388 + * with the module
  389 + * @mod_no: module number
  390 + * @enable: Regcache bypass state
  391 + *
  392 + * Returns 0 else failure.
  393 + */
  394 +int twl_set_regcache_bypass(u8 mod_no, bool enable)
  395 +{
  396 + struct regmap *regmap = twl_get_regmap(mod_no);
  397 +
  398 + if (!regmap)
  399 + return -EPERM;
  400 +
  401 + regcache_cache_bypass(regmap, enable);
  402 +
  403 + return 0;
  404 +}
  405 +EXPORT_SYMBOL(twl_set_regcache_bypass);
  406 +
386 407 /*----------------------------------------------------------------------*/
387 408  
388 409 /**
include/linux/i2c/twl.h
... ... @@ -175,6 +175,9 @@
175 175 TWL_CLASS_IS(4030, TWL4030_CLASS_ID)
176 176 TWL_CLASS_IS(6030, TWL6030_CLASS_ID)
177 177  
  178 +/* Set the regcache bypass for the regmap associated with the nodule */
  179 +int twl_set_regcache_bypass(u8 mod_no, bool enable);
  180 +
178 181 /*
179 182 * Read and write several 8-bit registers at once.
180 183 */