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

Configure Feed

Select the types of activity you want to include in your feed.

ASoC: codecs: ES8326: Solving headphone detection and

Merge series from Zhang Yi <zhangyi@everest-semi.com>:

We propose four patches to solve headphone detection and suspend issues.
And there are several registers that should be read-only registers. So
we create es8326_writeable_register, and set these registers to false.

+47 -11
+47 -11
sound/soc/codecs/es8326.c
··· 329 329 } 330 330 } 331 331 332 + static bool es8326_writeable_register(struct device *dev, unsigned int reg) 333 + { 334 + switch (reg) { 335 + case ES8326_BIAS_SW1: 336 + case ES8326_BIAS_SW2: 337 + case ES8326_BIAS_SW3: 338 + case ES8326_BIAS_SW4: 339 + case ES8326_ADC_HPFS1: 340 + case ES8326_ADC_HPFS2: 341 + return false; 342 + default: 343 + return true; 344 + } 345 + } 346 + 332 347 static const struct regmap_config es8326_regmap_config = { 333 348 .reg_bits = 8, 334 349 .val_bits = 8, 335 350 .max_register = 0xff, 351 + .use_single_read = true, 352 + .use_single_write = true, 336 353 .volatile_reg = es8326_volatile_register, 354 + .writeable_reg = es8326_writeable_register, 337 355 .cache_type = REGCACHE_RBTREE, 338 356 }; 339 357 ··· 895 877 if (es8326->jack->status & SND_JACK_HEADSET) { 896 878 /* detect button */ 897 879 dev_dbg(comp->dev, "button pressed\n"); 880 + regmap_write(es8326->regmap, ES8326_INT_SOURCE, 881 + (ES8326_INT_SRC_PIN9 | ES8326_INT_SRC_BUTTON)); 898 882 queue_delayed_work(system_wq, &es8326->button_press_work, 10); 899 883 goto exit; 900 884 } ··· 992 972 return 0; 993 973 } 994 974 995 - static int es8326_resume(struct snd_soc_component *component) 975 + static void es8326_init(struct snd_soc_component *component) 996 976 { 997 977 struct es8326_priv *es8326 = snd_soc_component_get_drvdata(component); 998 978 999 - regcache_cache_only(es8326->regmap, false); 1000 - regcache_sync(es8326->regmap); 1001 - 1002 - /* reset internal clock state */ 1003 979 regmap_write(es8326->regmap, ES8326_RESET, 0x1f); 1004 980 regmap_write(es8326->regmap, ES8326_VMIDSEL, 0x0E); 1005 981 regmap_write(es8326->regmap, ES8326_ANA_LP, 0xf0); ··· 1051 1035 es8326_enable_micbias(es8326->component); 1052 1036 usleep_range(50000, 70000); 1053 1037 regmap_update_bits(es8326->regmap, ES8326_HPDET_TYPE, 0x03, 0x00); 1054 - regmap_write(es8326->regmap, ES8326_INT_SOURCE, ES8326_INT_SRC_PIN9); 1055 1038 regmap_write(es8326->regmap, ES8326_INTOUT_IO, 1056 1039 es8326->interrupt_clk); 1057 1040 regmap_write(es8326->regmap, ES8326_SDINOUT1_IO, ··· 1066 1051 ES8326_MUTE); 1067 1052 1068 1053 regmap_write(es8326->regmap, ES8326_ADC_MUTE, 0x0f); 1054 + regmap_write(es8326->regmap, ES8326_CLK_DIV_LRCK, 0xff); 1069 1055 1070 - es8326->jack_remove_retry = 0; 1071 - es8326->hp = 0; 1072 - es8326->hpl_vol = 0x03; 1073 - es8326->hpr_vol = 0x03; 1056 + msleep(200); 1057 + regmap_write(es8326->regmap, ES8326_INT_SOURCE, ES8326_INT_SRC_PIN9); 1058 + } 1059 + 1060 + static int es8326_resume(struct snd_soc_component *component) 1061 + { 1062 + struct es8326_priv *es8326 = snd_soc_component_get_drvdata(component); 1063 + unsigned int reg; 1064 + 1065 + regcache_cache_only(es8326->regmap, false); 1066 + regcache_cache_bypass(es8326->regmap, true); 1067 + regmap_read(es8326->regmap, ES8326_CLK_RESAMPLE, &reg); 1068 + regcache_cache_bypass(es8326->regmap, false); 1069 + /* reset internal clock state */ 1070 + if (reg == 0x05) 1071 + regmap_write(es8326->regmap, ES8326_CLK_CTL, ES8326_CLK_ON); 1072 + else 1073 + es8326_init(component); 1074 + 1075 + regcache_sync(es8326->regmap); 1074 1076 1075 1077 es8326_irq(es8326->irq, es8326); 1076 1078 return 0; ··· 1147 1115 } 1148 1116 dev_dbg(component->dev, "interrupt-clk %x", es8326->interrupt_clk); 1149 1117 1150 - es8326_resume(component); 1118 + es8326_init(component); 1151 1119 return 0; 1152 1120 } 1153 1121 ··· 1243 1211 } 1244 1212 1245 1213 es8326->irq = i2c->irq; 1214 + es8326->jack_remove_retry = 0; 1215 + es8326->hp = 0; 1216 + es8326->hpl_vol = 0x03; 1217 + es8326->hpr_vol = 0x03; 1246 1218 INIT_DELAYED_WORK(&es8326->jack_detect_work, 1247 1219 es8326_jack_detect_handler); 1248 1220 INIT_DELAYED_WORK(&es8326->button_press_work,