From 1ca159a38c52aa28f9ec91ac9f8e4f25cb9cfd2f Mon Sep 17 00:00:00 2001 From: Vatsal Bucha Date: Thu, 12 Nov 2020 13:30:09 +0530 Subject: [PATCH] fsa4480: Resolve euro usb analog headset detect issue after PDR Euro headset is sometimes detected as headphone post PDR. This is due to race condition between powering up of PGA and cross connection detection due to which cross conn detection is not successful resulting in usb analog headset being detected as headphone post PDR. Save switch_control value before PDR and apply same value during fsa reg notifier after PDR so that euro side does not detect as cross conn post PDR to resolve issue. Change-Id: I4af17d83a8e4a55185421b370162d8e7a5d5b91f Signed-off-by: Vatsal Bucha --- drivers/soc/qcom/fsa4480-i2c.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/soc/qcom/fsa4480-i2c.c b/drivers/soc/qcom/fsa4480-i2c.c index a0568ab3a0ba..0811744289af 100644 --- a/drivers/soc/qcom/fsa4480-i2c.c +++ b/drivers/soc/qcom/fsa4480-i2c.c @@ -40,6 +40,7 @@ struct fsa4480_priv { struct blocking_notifier_head fsa4480_notifier; struct mutex notification_lock; u32 use_powersupply; + int switch_control; }; struct fsa4480_reg_val { @@ -310,7 +311,8 @@ int fsa4480_reg_notifier(struct notifier_block *nb, dev_dbg(fsa_priv->dev, "%s: verify if USB adapter is already inserted\n", __func__); rc = fsa4480_usbc_analog_setup_switches(fsa_priv); - + fsa4480_usbc_update_settings(fsa_priv, fsa_priv->switch_control, + 0x9F); return rc; } EXPORT_SYMBOL(fsa4480_reg_notifier); @@ -373,7 +375,6 @@ static int fsa4480_validate_display_port_settings(struct fsa4480_priv *fsa_priv) int fsa4480_switch_event(struct device_node *node, enum fsa_function event) { - int switch_control = 0; struct i2c_client *client = of_find_i2c_device_by_node(node); struct fsa4480_priv *fsa_priv; @@ -389,12 +390,13 @@ int fsa4480_switch_event(struct device_node *node, switch (event) { case FSA_MIC_GND_SWAP: regmap_read(fsa_priv->regmap, FSA4480_SWITCH_CONTROL, - &switch_control); - if ((switch_control & 0x07) == 0x07) - switch_control = 0x0; + &fsa_priv->switch_control); + if ((fsa_priv->switch_control & 0x07) == 0x07) + fsa_priv->switch_control = 0x0; else - switch_control = 0x7; - fsa4480_usbc_update_settings(fsa_priv, switch_control, 0x9F); + fsa_priv->switch_control = 0x7; + fsa4480_usbc_update_settings(fsa_priv, fsa_priv->switch_control, + 0x9F); break; case FSA_USBC_ORIENTATION_CC1: fsa4480_usbc_update_settings(fsa_priv, 0x18, 0xF8);