ASoC: wm8960: Support headphone jack detection function

Add two platform variables for headphone jack detection.
"hp_cfg" is for configuration of heaphone jack detection.
"gpio_cfg" is for configuration of gpio, the gpio is used
for plug & unplug interrupt on SoC.

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Link: https://lore.kernel.org/r/1591180013-12416-2-git-send-email-shengjiu.wang@nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Shengjiu Wang 2020-06-03 18:26:53 +08:00 committed by Mark Brown
parent 6f1519a0ff
commit c9015a1723
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0
2 changed files with 37 additions and 0 deletions

View File

@ -16,6 +16,23 @@ struct wm8960_data {
bool capless; /* Headphone outputs configured in capless mode */
bool shared_lrclk; /* DAC and ADC LRCLKs are wired together */
/*
* Setup for headphone detection
*
* hp_cfg[0]: HPSEL[1:0] of R48 (Additional Control 4)
* hp_cfg[1]: {HPSWEN:HPSWPOL} of R24 (Additional Control 2).
* hp_cfg[2]: {TOCLKSEL:TOEN} of R23 (Additional Control 1).
*/
u32 hp_cfg[3];
/*
* Setup for gpio configuration
*
* gpio_cfg[0]: ALRCGPIO of R9 (Audio interface)
* gpio_cfg[1]: {GPIOPOL:GPIOSEL[2:0]} of R48 (Additional Control 4).
*/
u32 gpio_cfg[2];
};
#endif

View File

@ -1389,6 +1389,12 @@ static void wm8960_set_pdata_from_of(struct i2c_client *i2c,
if (of_property_read_bool(np, "wlf,shared-lrclk"))
pdata->shared_lrclk = true;
of_property_read_u32_array(np, "wlf,gpio-cfg", pdata->gpio_cfg,
ARRAY_SIZE(pdata->gpio_cfg));
of_property_read_u32_array(np, "wlf,hp-cfg", pdata->hp_cfg,
ARRAY_SIZE(pdata->hp_cfg));
}
static int wm8960_i2c_probe(struct i2c_client *i2c,
@ -1446,6 +1452,20 @@ static int wm8960_i2c_probe(struct i2c_client *i2c,
regmap_update_bits(wm8960->regmap, WM8960_LOUT2, 0x100, 0x100);
regmap_update_bits(wm8960->regmap, WM8960_ROUT2, 0x100, 0x100);
/* ADCLRC pin configured as GPIO. */
regmap_update_bits(wm8960->regmap, WM8960_IFACE2, 1 << 6,
wm8960->pdata.gpio_cfg[0] << 6);
regmap_update_bits(wm8960->regmap, WM8960_ADDCTL4, 0xF << 4,
wm8960->pdata.gpio_cfg[1] << 4);
/* Enable headphone jack detect */
regmap_update_bits(wm8960->regmap, WM8960_ADDCTL4, 3 << 2,
wm8960->pdata.hp_cfg[0] << 2);
regmap_update_bits(wm8960->regmap, WM8960_ADDCTL2, 3 << 5,
wm8960->pdata.hp_cfg[1] << 5);
regmap_update_bits(wm8960->regmap, WM8960_ADDCTL1, 3,
wm8960->pdata.hp_cfg[2]);
i2c_set_clientdata(i2c, wm8960);
ret = devm_snd_soc_register_component(&i2c->dev,