aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Ujfalusi <peter.ujfalusi@ti.com>2011-09-22 04:05:48 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2011-09-22 12:20:21 -0400
commitd17bf31832d30b91225a84b53fae380dbdd07d3d (patch)
tree4f048ca6c78aab7efec4210c34cedf01ae8c0355
parent5bf692d97225a1e714cfd40a9a67401ebd630a7b (diff)
ASoC: twl6040: Introduce SW only shadow register
Software only shadow register to be used by the driver. For example Earpiece path will need this shadow register. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Acked-by: Liam Girdwood <lrg@ti.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
-rw-r--r--include/linux/mfd/twl6040.h2
-rw-r--r--sound/soc/codecs/twl6040.c19
2 files changed, 16 insertions, 5 deletions
diff --git a/include/linux/mfd/twl6040.h b/include/linux/mfd/twl6040.h
index ec1ec794fa23..47470cadf969 100644
--- a/include/linux/mfd/twl6040.h
+++ b/include/linux/mfd/twl6040.h
@@ -68,8 +68,6 @@
68#define TWL6040_REG_ACCCTL 0x2D 68#define TWL6040_REG_ACCCTL 0x2D
69#define TWL6040_REG_STATUS 0x2E 69#define TWL6040_REG_STATUS 0x2E
70 70
71#define TWL6040_CACHEREGNUM (TWL6040_REG_STATUS + 1)
72
73/* INTID (0x03) fields */ 71/* INTID (0x03) fields */
74 72
75#define TWL6040_THINT 0x01 73#define TWL6040_THINT 0x01
diff --git a/sound/soc/codecs/twl6040.c b/sound/soc/codecs/twl6040.c
index 9fbfe0ee90ff..96354660c343 100644
--- a/sound/soc/codecs/twl6040.c
+++ b/sound/soc/codecs/twl6040.c
@@ -57,6 +57,10 @@
57#define TWL6040_HF_VOL_MASK 0x1F 57#define TWL6040_HF_VOL_MASK 0x1F
58#define TWL6040_HF_VOL_SHIFT 0 58#define TWL6040_HF_VOL_SHIFT 0
59 59
60/* Shadow register used by the driver */
61#define TWL6040_REG_SW_SHADOW 0x2F
62#define TWL6040_CACHEREGNUM (TWL6040_REG_SW_SHADOW + 1)
63
60struct twl6040_output { 64struct twl6040_output {
61 u16 active; 65 u16 active;
62 u16 left_vol; 66 u16 left_vol;
@@ -153,6 +157,8 @@ static const u8 twl6040_reg[TWL6040_CACHEREGNUM] = {
153 0x00, /* REG_HFOTRIM 0x2C */ 157 0x00, /* REG_HFOTRIM 0x2C */
154 0x09, /* REG_ACCCTL 0x2D */ 158 0x09, /* REG_ACCCTL 0x2D */
155 0x00, /* REG_STATUS 0x2E (ro) */ 159 0x00, /* REG_STATUS 0x2E (ro) */
160
161 0x00, /* REG_SW_SHADOW 0x2F - Shadow, non HW register */
156}; 162};
157 163
158/* List of registers to be restored after power up */ 164/* List of registers to be restored after power up */
@@ -236,8 +242,12 @@ static int twl6040_read_reg_volatile(struct snd_soc_codec *codec,
236 if (reg >= TWL6040_CACHEREGNUM) 242 if (reg >= TWL6040_CACHEREGNUM)
237 return -EIO; 243 return -EIO;
238 244
239 value = twl6040_reg_read(twl6040, reg); 245 if (likely(reg < TWL6040_REG_SW_SHADOW)) {
240 twl6040_write_reg_cache(codec, reg, value); 246 value = twl6040_reg_read(twl6040, reg);
247 twl6040_write_reg_cache(codec, reg, value);
248 } else {
249 value = twl6040_read_reg_cache(codec, reg);
250 }
241 251
242 return value; 252 return value;
243} 253}
@@ -254,7 +264,10 @@ static int twl6040_write(struct snd_soc_codec *codec,
254 return -EIO; 264 return -EIO;
255 265
256 twl6040_write_reg_cache(codec, reg, value); 266 twl6040_write_reg_cache(codec, reg, value);
257 return twl6040_reg_write(twl6040, reg, value); 267 if (likely(reg < TWL6040_REG_SW_SHADOW))
268 return twl6040_reg_write(twl6040, reg, value);
269 else
270 return 0;
258} 271}
259 272
260static void twl6040_init_chip(struct snd_soc_codec *codec) 273static void twl6040_init_chip(struct snd_soc_codec *codec)