From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.41 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795474876; b=LAsoTHbupHl2MXgljhBDzGhrM8tkfGyrJr8TlFIentGXfEtDoyTl9HL8SkJSmX7g2mQI UmA986Nhezs8AL3EYagx1a30gFPn3QoQFB+IppRc+gyVgvHvUEQDGMoTwoEYMf+sco94n 7eZohE6nwPQKebNTm3ndidArSm8kZ24PNhVYyLS1u7p2cbbprFTG80eeTvD0qI5xNmGXP eRJvNfI0SnGtTtbk+u3HyTZFxDT7yTk7kmkhIgDSeeKgTHDw3q7KTupozoSweKWHiQD2/ q2WzIhrYzMqh09nFbU5l4cZkr5TrHb2FYfgHbv6bUgCPIp9cIc46irDQE4u4YagqLoQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795474876; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:Date:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding: Message-Id:References:In-Reply-To:To:Cc:X-Mailer; bh=LVj/2IPCO/rsyUxwejJA/YKSv8ccPTCCNt+bis0ReOA=; b=d/tPU2034OjGstqp66SF7aNK+3WwYTLHhzpQjmAN4JZypS+foGX0q9pB+BnIcvthi9Ze xcNNt7wK8T+cCl8w77U2Ol15KfpTy9Wodyt9wwON5M624VRYKyHHyg2C0ortEPYWtDozN iBRldaKStfavzMtRisV6WXQ3kW0K2ADYGDGq4EZkErrrxbUIU0VHcyCqwK9czfFD9h0d6 8P7U9spRLMtZkxw+fABjBWrWEz4NqofD7yhg6CJbsbXspDCqaYUPrjyMsl+sIl147yFLs RSKfZMluRAXmWuAy9p9w5rOHrj2VA69TuqDZNzwm5Lng8MBfzQcDWU2pPuTsMAF2LZA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=Xd5bYdvc; arc=none smtp.remote-ip=74.125.82.41 Received: from mail-dl1-f41.google.com (mail-dl1-f41.google.com [74.125.82.41]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9AD63606A333 for ; Mon, 23 Nov 2026 23:01:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 9AD63606A333 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=Xd5bYdvc Received: by mail-dl1-f41.google.com with SMTP id a92af1059eb24-1b3ada81853so4446703c88.0 for ; Mon, 23 Nov 2026 15:01:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795474875; x=1796079675; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=LVj/2IPCO/rsyUxwejJA/YKSv8ccPTCCNt+bis0ReOA=; b=Xd5bYdvciTl/1qz8UZ1QOXbSQdBrlICShYBqauUGhYrTHHz5f41WXibn7/296E6+M+ j3MReR9mRuNvKQJ6D2U2vjqFSjID7ekBJoNExKNZURzmpGHUqr9llB5PC437+gW+7p/A 69QwbTUjejPo7FvpmZPHrBgP7MdPNv6xxY6cPKqTp9ISLN4AE1tFQRQU0gPJjRWx8eNZ /gh5ycvAR9qz6Qvy3TE1wnQnXYhxWtqNHzPqrIVjyOc1p1OQEttmR/HMdSrjLfEf4skC vAf5qdoh2dKnLwWs3rSwuExHd37G/DC+twUe+ggm+QjkGn9/RSHkp+h+DqeGTcq4uqWL IDlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795474875; x=1796079675; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=LVj/2IPCO/rsyUxwejJA/YKSv8ccPTCCNt+bis0ReOA=; b=TZrxXBfD2/4c6DhEjrYSCtek/jEFHe5VhK5AdC0tD88zZ0+uUNErzvIDtlTGhA9F1h 991wANFgXfL5UCUmXcnpyhgo8vjQaKUlvufPfheU+oMZEwtAD1WKMm0EvVRhCpif/jdU ZkjDvwiyuRXdGVXK80xr7jP0EMohUEUB16RigLf2pAi9Q577cbQQJ+YmFsR+UqQDNS5W yRdWNqctEJdoyrdThAUUMICe7kPRbFC0HkeZqfoSh9Atbc03gWb7a0bO2+l4yrAfFjrX fBWgU39loUMz3uUQdacADj5Qwjz4rRbCyVCgluoF+6osUB22Wy8i0NfKL/rexMILUXyu s/GA== X-Forwarded-Encrypted: i=1; AL+hErEWxFPmtB81o0NyzW6v+xkfaME8Ved8/Yphpr6f1X0NwuJiDBKlqTF2KMBgxUV0MdPpxgu+pveHEv0Ghrc=@vger.kernel.org X-Gm-Message-State: APuU4Z85G5Gh0xSWPhZBUt3oWtFoGD5vRKY0a5fSquUI8NkVVUmv3pqu sC/UyEcYy8Ujhk14Hku/TpQ22k8hshwb/CX6NfoOGzwDuEpSSdzhKtwD X-Gm-Gg: AZFdTZer5ZBhFM/lTpsbL6B+E5P9qvAkkpmLJE+R3Zi9g0/oHjb5cu4DFVcesny03AH b4j9uZW2+CTjfOqdSDk/SOYG5qRbJRMZYo0pdzZ0fQY6Wto5USf5oxjztN12thbptG+8/R201yk DC64sdyeSNei8DxE9qA4pXXq6ksK7ecwQSyWoyBOmhf64xUHIKFzvpgQKzxF2oeSBfgG9i31AM3 2y9C4SB6xKE8DTCxBIQjiTWkEnsaE3uvtyUT5xkLr36IHY+Lj1ohq7wBGI6xjMoywmRkwTQ2AGs bSDjBeIel8e7coTXGG/MfAwpY1IVw9PzcN14HllGK1P9ajnR19OElo0c2wsV7ZxqkfqbSL/DVBN J0ChxuqBl0BC/XBoRvR1baYJU/fSvxDcrKar0MZaY/Owkau14zCdvIzvOzR5zlHjOPe64nWebWP uGm8RQIMt0u3HVptszd+3ydSRZt/sULHPn8x7uQ/y1a3mjpDEJqyTu2IKGdvvSbFJCicfnlYqVJ sHcp+nW3+YdC29H/eTRF0tiH2maqDGcEh7uIv9NYUws+lxjwLpDD+mxeJqdEZbBmn66rrkoNsEJ SKTP711YFOFv1ubPQlzpYooxnntoVETNVtZTAiyPphrY1LRN2fHBKcNaR5b092WS3nxdnkZe23P RL6otHtXMC1YiHHOgGQ== X-Received: by 2002:a05:693c:88d4:20b0:386:a8de:2bfc with SMTP id 5a478bee46e88-386a8de2f67mr5900155eec.6.1795474874471; Mon, 23 Nov 2026 15:01:14 -0800 (PST) Received: from dtor-ws.sjc.corp.google.com ([2a00:79e0:2ebe:8:4121:d698:201c:9274]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-385677c349csm41359262eec.22.2026.11.23.15.01.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Nov 2026 15:01:11 -0800 (PST) From: Dmitry Torokhov Date: Mon, 23 Nov 2026 15:00:56 -0800 Subject: [PATCH v2 3/4] ASoC: arizona: drop unused HPDET accessory ID support X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261123-arizona-asoc-v2-3-6323d3c0961a@gmail.com> References: <20261123-arizona-asoc-v2-0-6323d3c0961a@gmail.com> In-Reply-To: <20261123-arizona-asoc-v2-0-6323d3c0961a@gmail.com> To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Charles Keepax , Richard Fitzgerald , David Rhodes , Lee Jones Cc: patches@opensource.cirrus.com, linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, mfd@lists.linux.dev X-Mailer: b4 0.17-dev-dd645 Nothing in the kernel sets hpdet_acc_id or hpdet_acc_id_line in struct arizona_pdata, and neither has any Device Tree or ACPI bindings. Remove both platform data fields and all exclusively connected HPDET accessory identification logic, work items, GPIO lookup, and state from the Arizona jack detection driver. Signed-off-by: Dmitry Torokhov --- include/linux/mfd/arizona/pdata.h | 6 -- sound/soc/codecs/arizona-jack.c | 181 +------------------------------------- sound/soc/codecs/arizona.h | 6 -- 3 files changed, 4 insertions(+), 189 deletions(-) diff --git a/include/linux/mfd/arizona/pdata.h b/include/linux/mfd/arizona/pdata.h index 984b2edfec07..96ef9c97d4cc 100644 --- a/include/linux/mfd/arizona/pdata.h +++ b/include/linux/mfd/arizona/pdata.h @@ -112,12 +112,6 @@ struct arizona_pdata { /** set to true if jackdet contact opens on insert */ bool jd_invert; - /** Use the headphone detect circuit to identify the accessory */ - bool hpdet_acc_id; - - /** Check for line output with HPDET method */ - bool hpdet_acc_id_line; - /** Channel to use for headphone detection */ unsigned int hpdet_channel; diff --git a/sound/soc/codecs/arizona-jack.c b/sound/soc/codecs/arizona-jack.c index f36d314a6a54..5650a7f47ede 100644 --- a/sound/soc/codecs/arizona-jack.c +++ b/sound/soc/codecs/arizona-jack.c @@ -45,7 +45,6 @@ #define ARIZONA_HPDET_MAX 10000 -#define HPDET_DEBOUNCE 500 #define DEFAULT_MICD_TIMEOUT 2000 #define ARIZONA_HPDET_WAIT_COUNT 15 @@ -92,8 +91,6 @@ static const int arizona_micd_levels[] = { 1257, 30000, }; -static void arizona_start_hpdet_acc_id(struct arizona_priv *info); - static void arizona_extcon_hp_clamp(struct arizona_priv *info, bool clamp) { @@ -455,79 +452,11 @@ static int arizona_hpdet_read(struct arizona_priv *info) return val; } -static int arizona_hpdet_do_id(struct arizona_priv *info, int *reading, - bool *mic) -{ - struct arizona *arizona = info->arizona; - - if (!arizona->pdata.hpdet_acc_id) - return 0; - - /* - * If we're using HPDET for accessory identification we need - * to take multiple measurements, step through them in sequence. - */ - info->hpdet_res[info->num_hpdet_res++] = *reading; - - /* Only check the mic directly if we didn't already ID it */ - if (info->hpdet_id_gpio && info->num_hpdet_res == 1) { - dev_dbg(arizona->dev, "Measuring mic\n"); - - regmap_update_bits(arizona->regmap, - ARIZONA_ACCESSORY_DETECT_MODE_1, - ARIZONA_ACCDET_MODE_MASK | - ARIZONA_ACCDET_SRC, - ARIZONA_ACCDET_MODE_HPR | - info->micd_modes[0].src); - - gpiod_set_value_cansleep(info->hpdet_id_gpio, 1); - - regmap_update_bits(arizona->regmap, ARIZONA_HEADPHONE_DETECT_1, - ARIZONA_HP_POLL, ARIZONA_HP_POLL); - return -EAGAIN; - } - - /* OK, got both. Now, compare... */ - dev_dbg(arizona->dev, "HPDET measured %d %d\n", - info->hpdet_res[0], info->hpdet_res[1]); - - /* Take the headphone impedance for the main report */ - *reading = info->hpdet_res[0]; - - /* Sometimes we get false readings due to slow insert */ - if (*reading >= ARIZONA_HPDET_MAX && !info->hpdet_retried) { - dev_dbg(arizona->dev, "Retrying high impedance\n"); - info->num_hpdet_res = 0; - info->hpdet_retried = true; - arizona_start_hpdet_acc_id(info); - pm_runtime_put(arizona->dev); - return -EAGAIN; - } - - /* - * If we measure the mic as high impedance - */ - if (!info->hpdet_id_gpio || info->hpdet_res[1] > 50) { - dev_dbg(arizona->dev, "Detected mic\n"); - *mic = true; - info->detecting = true; - } else { - dev_dbg(arizona->dev, "Detected headphone\n"); - } - - /* Make sure everything is reset back to the real polarity */ - regmap_update_bits(arizona->regmap, ARIZONA_ACCESSORY_DETECT_MODE_1, - ARIZONA_ACCDET_SRC, info->micd_modes[0].src); - - return 0; -} - static irqreturn_t arizona_hpdet_irq(int irq, void *data) { struct arizona_priv *info = data; struct arizona *arizona = info->arizona; int ret, reading, state, report; - bool mic = false; mutex_lock(&info->lock); @@ -552,18 +481,6 @@ static irqreturn_t arizona_hpdet_irq(int irq, void *data) goto done; reading = ret; - /* Reset back to starting range */ - regmap_update_bits(arizona->regmap, - ARIZONA_HEADPHONE_DETECT_1, - ARIZONA_HP_IMPEDANCE_RANGE_MASK | ARIZONA_HP_POLL, - 0); - - ret = arizona_hpdet_do_id(info, &reading, &mic); - if (ret == -EAGAIN) - goto out; - else if (ret < 0) - goto done; - /* Report high impedence cables as line outputs */ if (reading >= 5000) report = SND_JACK_LINEOUT; @@ -581,11 +498,8 @@ static irqreturn_t arizona_hpdet_irq(int irq, void *data) arizona_extcon_hp_clamp(info, false); - if (info->hpdet_id_gpio) - gpiod_set_value_cansleep(info->hpdet_id_gpio, 0); - /* If we have a mic then reenable MICDET */ - if (state && (mic || info->mic)) + if (state && info->mic) arizona_start_mic(info); if (info->hpdet_active) { @@ -654,55 +568,6 @@ static void arizona_identify_headphone(struct arizona_priv *info) info->hpdet_active = false; } -static void arizona_start_hpdet_acc_id(struct arizona_priv *info) -{ - struct arizona *arizona = info->arizona; - int hp_reading = 32; - bool mic; - int ret; - - dev_dbg(arizona->dev, "Starting identification via HPDET\n"); - - /* Make sure we keep the device enabled during the measurement */ - pm_runtime_get_sync(arizona->dev); - - info->hpdet_active = true; - - arizona_extcon_hp_clamp(info, true); - - ret = regmap_update_bits(arizona->regmap, - ARIZONA_ACCESSORY_DETECT_MODE_1, - ARIZONA_ACCDET_SRC | ARIZONA_ACCDET_MODE_MASK, - info->micd_modes[0].src | - arizona->pdata.hpdet_channel); - if (ret != 0) { - dev_err(arizona->dev, "Failed to set HPDET mode: %d\n", ret); - goto err; - } - - if (arizona->pdata.hpdet_acc_id_line) { - ret = regmap_update_bits(arizona->regmap, - ARIZONA_HEADPHONE_DETECT_1, - ARIZONA_HP_POLL, ARIZONA_HP_POLL); - if (ret) { - dev_err(arizona->dev, "Can't start HPDETL measurement: %d\n", ret); - goto err; - } - } else { - arizona_hpdet_do_id(info, &hp_reading, &mic); - } - - return; - -err: - /* Just report headphone */ - snd_soc_jack_report(info->jack, SND_JACK_HEADPHONE, - SND_JACK_LINEOUT | SND_JACK_HEADPHONE); - - pm_runtime_put_autosuspend(arizona->dev); - info->hpdet_active = false; -} - static void arizona_micd_timeout_work(struct work_struct *work) { struct arizona_priv *info = container_of(work, @@ -961,16 +826,6 @@ static irqreturn_t arizona_micdet(int irq, void *data) return IRQ_HANDLED; } -static void arizona_hpdet_work(struct work_struct *work) -{ - struct arizona_priv *info = container_of(work, - struct arizona_priv, - hpdet_work.work); - - guard(mutex)(&info->lock); - arizona_start_hpdet_acc_id(info); -} - static int arizona_hpdet_wait(struct arizona_priv *info) { struct arizona *arizona = info->arizona; @@ -1009,10 +864,9 @@ static irqreturn_t arizona_jackdet(int irq, void *data) struct arizona_priv *info = data; struct arizona *arizona = info->arizona; unsigned int val, present, mask; - bool cancelled_hp, cancelled_mic; - int ret, i; + bool cancelled_mic; + int ret; - cancelled_hp = cancel_delayed_work_sync(&info->hpdet_work); cancelled_mic = cancel_delayed_work_sync(&info->micd_timeout_work); guard(pm_runtime_active_auto)(arizona->dev); @@ -1039,11 +893,6 @@ static irqreturn_t arizona_jackdet(int irq, void *data) val &= mask; if (val == info->last_jackdet) { dev_dbg(arizona->dev, "Suppressing duplicate JACKDET\n"); - if (cancelled_hp) - queue_delayed_work(system_power_efficient_wq, - &info->hpdet_work, - msecs_to_jiffies(HPDET_DEBOUNCE)); - if (cancelled_mic) { int micd_timeout = arizona->pdata.micd_timeout; @@ -1062,13 +911,7 @@ static irqreturn_t arizona_jackdet(int irq, void *data) info->mic = false; info->jack_flips = 0; - if (!arizona->pdata.hpdet_acc_id) { - arizona_start_mic(info); - } else { - queue_delayed_work(system_power_efficient_wq, - &info->hpdet_work, - msecs_to_jiffies(HPDET_DEBOUNCE)); - } + arizona_start_mic(info); if (info->micd_clamp || !arizona->pdata.jd_invert) regmap_update_bits(arizona->regmap, @@ -1080,12 +923,8 @@ static irqreturn_t arizona_jackdet(int irq, void *data) arizona_stop_mic(info); - info->num_hpdet_res = 0; - for (i = 0; i < ARRAY_SIZE(info->hpdet_res); i++) - info->hpdet_res[i] = 0; info->mic = false; info->hpdet_done = false; - info->hpdet_retried = false; snd_soc_jack_report(info->jack, 0, ARIZONA_JACK_MASK | info->micd_button_mask); @@ -1253,7 +1092,6 @@ int arizona_jack_codec_dev_probe(struct arizona_priv *info, struct device *dev) mutex_init(&info->lock); info->last_jackdet = ~(ARIZONA_MICD_CLAMP_STS | ARIZONA_JD1_STS); - INIT_DELAYED_WORK(&info->hpdet_work, arizona_hpdet_work); INIT_DELAYED_WORK(&info->micd_detect_work, arizona_micd_detect); INIT_DELAYED_WORK(&info->micd_timeout_work, arizona_micd_timeout_work); @@ -1326,15 +1164,6 @@ int arizona_jack_codec_dev_probe(struct arizona_priv *info, struct device *dev) return ret; } - info->hpdet_id_gpio = gpiod_get_optional(arizona->dev, - "wlf,hpdet-id-gpio", - mode); - if (IS_ERR(info->hpdet_id_gpio)) { - ret = PTR_ERR(info->hpdet_id_gpio); - dev_err_probe(arizona->dev, ret, "getting headphone detect ID GPIO\n"); - return ret; - } - return 0; } EXPORT_SYMBOL_GPL(arizona_jack_codec_dev_probe); @@ -1342,7 +1171,6 @@ EXPORT_SYMBOL_GPL(arizona_jack_codec_dev_probe); int arizona_jack_codec_dev_remove(struct arizona_priv *info) { gpiod_put(info->micd_pol_gpio); - gpiod_put(info->hpdet_id_gpio); return 0; } EXPORT_SYMBOL_GPL(arizona_jack_codec_dev_remove); @@ -1588,7 +1416,6 @@ static int arizona_jack_disable_jack_detect(struct arizona_priv *info) arizona_free_irq(arizona, ARIZONA_IRQ_MICDET, info); arizona_free_irq(arizona, jack_irq_rise, info); arizona_free_irq(arizona, jack_irq_fall, info); - cancel_delayed_work_sync(&info->hpdet_work); cancel_delayed_work_sync(&info->micd_detect_work); cancel_delayed_work_sync(&info->micd_timeout_work); diff --git a/sound/soc/codecs/arizona.h b/sound/soc/codecs/arizona.h index 499891e62183..766a29a23893 100644 --- a/sound/soc/codecs/arizona.h +++ b/sound/soc/codecs/arizona.h @@ -94,13 +94,11 @@ struct arizona_priv { /* Variables used by arizona-jack.c code */ struct mutex lock; - struct delayed_work hpdet_work; struct delayed_work micd_detect_work; struct delayed_work micd_timeout_work; struct snd_soc_jack *jack; struct regulator *micvdd; struct gpio_desc *micd_pol_gpio; - struct gpio_desc *hpdet_id_gpio; u16 last_jackdet; @@ -117,14 +115,10 @@ struct arizona_priv { bool hpdet_active; bool hpdet_done; - bool hpdet_retried; bool mic; bool detecting; - int num_hpdet_res; - unsigned int hpdet_res[3]; - int jack_flips; int hpdet_ip_version; }; -- 2.56.1.809.ga0b61035b5-goog