Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ASoC: Add platform data for WM9081 IRQ pin configuration

The WM9081 IRQ output can be either active high or active low and can
support either CMOS or open drain modes.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>

+25 -13
+6 -3
include/sound/wm9081.h
··· 17 17 u16 config[20]; 18 18 }; 19 19 20 - struct wm9081_retune_mobile_config { 21 - struct wm9081_retune_mobile_setting *configs; 22 - int num_configs; 20 + struct wm9081_pdata { 21 + bool irq_high; /* IRQ is active high */ 22 + bool irq_cmos; /* IRQ is in CMOS mode */ 23 + 24 + struct wm9081_retune_mobile_setting *retune_configs; 25 + int num_retune_configs; 23 26 }; 24 27 25 28 #endif
+19 -10
sound/soc/codecs/wm9081.c
··· 167 167 int fll_fref; 168 168 int fll_fout; 169 169 int tdm_width; 170 - struct wm9081_retune_mobile_config *retune; 170 + struct wm9081_pdata pdata; 171 171 }; 172 172 173 173 static int wm9081_volatile_register(struct snd_soc_codec *codec, unsigned int reg) ··· 1082 1082 aif4 |= wm9081->bclk / wm9081->fs; 1083 1083 1084 1084 /* Apply a ReTune Mobile configuration if it's in use */ 1085 - if (wm9081->retune) { 1086 - struct wm9081_retune_mobile_config *retune = wm9081->retune; 1085 + if (wm9081->pdata.num_retune_configs) { 1086 + struct wm9081_pdata *pdata = &wm9081->pdata; 1087 1087 struct wm9081_retune_mobile_setting *s; 1088 1088 int eq1; 1089 1089 1090 1090 best = 0; 1091 - best_val = abs(retune->configs[0].rate - wm9081->fs); 1092 - for (i = 0; i < retune->num_configs; i++) { 1093 - cur_val = abs(retune->configs[i].rate - wm9081->fs); 1091 + best_val = abs(pdata->retune_configs[0].rate - wm9081->fs); 1092 + for (i = 0; i < pdata->num_retune_configs; i++) { 1093 + cur_val = abs(pdata->retune_configs[i].rate - 1094 + wm9081->fs); 1094 1095 if (cur_val < best_val) { 1095 1096 best_val = cur_val; 1096 1097 best = i; 1097 1098 } 1098 1099 } 1099 - s = &retune->configs[best]; 1100 + s = &pdata->retune_configs[best]; 1100 1101 1101 1102 dev_dbg(codec->dev, "ReTune Mobile %s tuned for %dHz\n", 1102 1103 s->name, s->rate); ··· 1256 1255 return ret; 1257 1256 } 1258 1257 1258 + reg = 0; 1259 + if (wm9081->pdata.irq_high) 1260 + reg |= WM9081_IRQ_POL; 1261 + if (!wm9081->pdata.irq_cmos) 1262 + reg |= WM9081_IRQ_OP_CTRL; 1263 + snd_soc_update_bits(codec, WM9081_INTERRUPT_CONTROL, 1264 + WM9081_IRQ_POL | WM9081_IRQ_OP_CTRL, reg); 1265 + 1259 1266 wm9081_set_bias_level(codec, SND_SOC_BIAS_STANDBY); 1260 1267 1261 1268 /* Enable zero cross by default */ ··· 1275 1266 1276 1267 snd_soc_add_controls(codec, wm9081_snd_controls, 1277 1268 ARRAY_SIZE(wm9081_snd_controls)); 1278 - if (!wm9081->retune) { 1269 + if (!wm9081->pdata.num_retune_configs) { 1279 1270 dev_dbg(codec->dev, 1280 1271 "No ReTune Mobile data, using normal EQ\n"); 1281 1272 snd_soc_add_controls(codec, wm9081_eq_controls, ··· 1352 1343 wm9081->control_data = i2c; 1353 1344 1354 1345 if (dev_get_platdata(&i2c->dev)) 1355 - memcpy(&wm9081->retune, dev_get_platdata(&i2c->dev), 1356 - sizeof(wm9081->retune)); 1346 + memcpy(&wm9081->pdata, dev_get_platdata(&i2c->dev), 1347 + sizeof(wm9081->pdata)); 1357 1348 1358 1349 ret = snd_soc_register_codec(&i2c->dev, 1359 1350 &soc_codec_dev_wm9081, &wm9081_dai, 1);