Commit 4006f157 authored by Mark Brown's avatar Mark Brown

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.
parents 00dd4d86 34fa846f
......@@ -329,11 +329,29 @@ static bool es8326_volatile_register(struct device *dev, unsigned int reg)
}
}
static bool es8326_writeable_register(struct device *dev, unsigned int reg)
{
switch (reg) {
case ES8326_BIAS_SW1:
case ES8326_BIAS_SW2:
case ES8326_BIAS_SW3:
case ES8326_BIAS_SW4:
case ES8326_ADC_HPFS1:
case ES8326_ADC_HPFS2:
return false;
default:
return true;
}
}
static const struct regmap_config es8326_regmap_config = {
.reg_bits = 8,
.val_bits = 8,
.max_register = 0xff,
.use_single_read = true,
.use_single_write = true,
.volatile_reg = es8326_volatile_register,
.writeable_reg = es8326_writeable_register,
.cache_type = REGCACHE_RBTREE,
};
......@@ -877,6 +895,8 @@ static void es8326_jack_detect_handler(struct work_struct *work)
if (es8326->jack->status & SND_JACK_HEADSET) {
/* detect button */
dev_dbg(comp->dev, "button pressed\n");
regmap_write(es8326->regmap, ES8326_INT_SOURCE,
(ES8326_INT_SRC_PIN9 | ES8326_INT_SRC_BUTTON));
queue_delayed_work(system_wq, &es8326->button_press_work, 10);
goto exit;
}
......@@ -972,14 +992,10 @@ static int es8326_calibrate(struct snd_soc_component *component)
return 0;
}
static int es8326_resume(struct snd_soc_component *component)
static void es8326_init(struct snd_soc_component *component)
{
struct es8326_priv *es8326 = snd_soc_component_get_drvdata(component);
regcache_cache_only(es8326->regmap, false);
regcache_sync(es8326->regmap);
/* reset internal clock state */
regmap_write(es8326->regmap, ES8326_RESET, 0x1f);
regmap_write(es8326->regmap, ES8326_VMIDSEL, 0x0E);
regmap_write(es8326->regmap, ES8326_ANA_LP, 0xf0);
......@@ -1035,7 +1051,6 @@ static int es8326_resume(struct snd_soc_component *component)
es8326_enable_micbias(es8326->component);
usleep_range(50000, 70000);
regmap_update_bits(es8326->regmap, ES8326_HPDET_TYPE, 0x03, 0x00);
regmap_write(es8326->regmap, ES8326_INT_SOURCE, ES8326_INT_SRC_PIN9);
regmap_write(es8326->regmap, ES8326_INTOUT_IO,
es8326->interrupt_clk);
regmap_write(es8326->regmap, ES8326_SDINOUT1_IO,
......@@ -1051,11 +1066,28 @@ static int es8326_resume(struct snd_soc_component *component)
ES8326_MUTE);
regmap_write(es8326->regmap, ES8326_ADC_MUTE, 0x0f);
regmap_write(es8326->regmap, ES8326_CLK_DIV_LRCK, 0xff);
es8326->jack_remove_retry = 0;
es8326->hp = 0;
es8326->hpl_vol = 0x03;
es8326->hpr_vol = 0x03;
msleep(200);
regmap_write(es8326->regmap, ES8326_INT_SOURCE, ES8326_INT_SRC_PIN9);
}
static int es8326_resume(struct snd_soc_component *component)
{
struct es8326_priv *es8326 = snd_soc_component_get_drvdata(component);
unsigned int reg;
regcache_cache_only(es8326->regmap, false);
regcache_cache_bypass(es8326->regmap, true);
regmap_read(es8326->regmap, ES8326_CLK_RESAMPLE, &reg);
regcache_cache_bypass(es8326->regmap, false);
/* reset internal clock state */
if (reg == 0x05)
regmap_write(es8326->regmap, ES8326_CLK_CTL, ES8326_CLK_ON);
else
es8326_init(component);
regcache_sync(es8326->regmap);
es8326_irq(es8326->irq, es8326);
return 0;
......@@ -1115,7 +1147,7 @@ static int es8326_probe(struct snd_soc_component *component)
}
dev_dbg(component->dev, "interrupt-clk %x", es8326->interrupt_clk);
es8326_resume(component);
es8326_init(component);
return 0;
}
......@@ -1211,6 +1243,10 @@ static int es8326_i2c_probe(struct i2c_client *i2c)
}
es8326->irq = i2c->irq;
es8326->jack_remove_retry = 0;
es8326->hp = 0;
es8326->hpl_vol = 0x03;
es8326->hpr_vol = 0x03;
INIT_DELAYED_WORK(&es8326->jack_detect_work,
es8326_jack_detect_handler);
INIT_DELAYED_WORK(&es8326->button_press_work,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment