linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 00/20] Get mt6359-accdet ready for usage in Devicetree
@ 2025-03-02 16:30 Nícolas F. R. A. Prado
  2025-03-02 16:30 ` [PATCH v2 01/20] ASoC: dt-bindings: Add document for mt6359-accdet Nícolas F. R. A. Prado
                   ` (19 more replies)
  0 siblings, 20 replies; 44+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-03-02 16:30 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Matthias Brugger, AngeloGioacchino Del Regno,
	Sen Chu, Sean Wang, Macpaul Lin, Lee Jones, Jaroslav Kysela,
	Takashi Iwai, Catalin Marinas, Will Deacon
  Cc: kernel, linux-sound, devicetree, linux-kernel, linux-arm-kernel,
	linux-mediatek, linux-pm, Nícolas F. R. A. Prado,
	Andrew Perepech

This series prepares the MT6359 ACCDET for actual usage in the
Devicetree. Patches 1 and 2 add the required DT bindings, patches 3 and
4 get the mt6359-accdet driver probing, patches 5-18 clean up code
related to DT property parsing, patch 19 adds the node in the
Devicetree and patch 20 enables the kconfig for the driver.

Together with the series "Allow retrieving accessory detection reference
on MT8188" [1], and one extra patch on top enabling it on the
genio-700-evk DT, this series was tested on the Genio 700 EVK to get
audio jack detection working on it.

[1] https://lore.kernel.org/all/20250214-mt8188-accdet-v1-0-6bbd5483855b@collabora.com

Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
---
Changes in v2:
- Removed all DT-binding properties except for EINT polarity one
  (mediatek,eint-level-pol / mediatek,hp-eint-high)
  - Added patches 12-18 to make those settings internal to driver
- Renamed mediatek,eint-level-pol to mediatek,hp-eint-high and made it
  bool
- Added patch 20 to enable the MT6359 ACCDET Kconfig in the defconfig
- Removed unused btn_type variable as part of "Drop dead code for button
  detection" patch.
- Link to v1: https://lore.kernel.org/r/20250214-mt6359-accdet-dts-v1-0-677a151b9b4c@collabora.com

---
Andrew Perepech (2):
      mfd: mt6397-core: Add mfd_cell for mt6359-accdet
      ASoC: mediatek: mt6359-accdet: Implement HP_EINT polarity configuration

Nícolas F. R. A. Prado (18):
      ASoC: dt-bindings: Add document for mt6359-accdet
      dt-bindings: mfd: mediatek: mt6397: Add accdet subnode
      ASoC: mediatek: mt6359-accdet: Add compatible property
      ASoC: mediatek: mt6359-accdet: Handle hp-eint-high property
      ASoC: mediatek: mt6359-accdet: Drop dead code for EINT/GPIO IRQ handling
      ASoC: mediatek: mt6359-accdet: Drop dead code for EINT trigger setting
      ASoC: mediatek: mt6359-accdet: Drop dead code for button detection
      ASoC: mediatek: mt6359-accdet: Drop dead code for plugout-debounce
      ASoC: mediatek: mt6359-accdet: Drop unused moisture variables
      ASoC: mediatek: mt6359-accdet: Always use internal resistor
      ASoC: mediatek: mt6359-accdet: Make PWM debounce settings internal
      ASoC: mediatek: mt6359-accdet: Always use eint detect mode 4
      ASoC: mediatek: mt6359-accdet: Always set micbias1 to 2.8V
      ASoC: mediatek: mt6359-accdet: Always configure hardware as mic-mode 2
      ASoC: mediatek: mt6359-accdet: Always set comp-vth to 1.6V
      ASoC: mediatek: mt6359-accdet: Always use EINT0 IRQ
      arm64: dts: mt6359: Add accessory detect node
      arm64: defconfig: Enable MT6359 ACCDET

 .../devicetree/bindings/mfd/mediatek,mt6397.yaml   |   7 +
 .../bindings/sound/mediatek,mt6359-accdet.yaml     |  42 ++
 arch/arm64/boot/dts/mediatek/mt6359.dtsi           |   4 +
 arch/arm64/configs/defconfig                       |   1 +
 drivers/mfd/mt6397-core.c                          |  12 +
 sound/soc/codecs/mt6359-accdet.c                   | 599 +++++----------------
 sound/soc/codecs/mt6359-accdet.h                   |  55 +-
 7 files changed, 196 insertions(+), 524 deletions(-)
---
base-commit: c0eb65494e59d9834af7cbad983629e9017b25a1
change-id: 20250214-mt6359-accdet-dts-00b189847f3c

Best regards,
-- 
Nícolas F. R. A. Prado <nfraprado@collabora.com>



^ permalink raw reply	[flat|nested] 44+ messages in thread

* [PATCH v2 01/20] ASoC: dt-bindings: Add document for mt6359-accdet
  2025-03-02 16:30 [PATCH v2 00/20] Get mt6359-accdet ready for usage in Devicetree Nícolas F. R. A. Prado
@ 2025-03-02 16:30 ` Nícolas F. R. A. Prado
  2025-03-03 11:14   ` AngeloGioacchino Del Regno
  2025-03-03 15:11   ` Rob Herring
  2025-03-02 16:30 ` [PATCH v2 02/20] dt-bindings: mfd: mediatek: mt6397: Add accdet subnode Nícolas F. R. A. Prado
                   ` (18 subsequent siblings)
  19 siblings, 2 replies; 44+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-03-02 16:30 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Matthias Brugger, AngeloGioacchino Del Regno,
	Sen Chu, Sean Wang, Macpaul Lin, Lee Jones, Jaroslav Kysela,
	Takashi Iwai, Catalin Marinas, Will Deacon
  Cc: kernel, linux-sound, devicetree, linux-kernel, linux-arm-kernel,
	linux-mediatek, linux-pm, Nícolas F. R. A. Prado

Add dt-binding for the MT6359 ACCDET hardware block.

Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
---
 .../bindings/sound/mediatek,mt6359-accdet.yaml     | 42 ++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/Documentation/devicetree/bindings/sound/mediatek,mt6359-accdet.yaml b/Documentation/devicetree/bindings/sound/mediatek,mt6359-accdet.yaml
new file mode 100644
index 0000000000000000000000000000000000000000..d08a79301409374714c76135b061e20e8e8acfaf
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/mediatek,mt6359-accdet.yaml
@@ -0,0 +1,42 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/mediatek,mt6359-accdet.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: MT6359 Accessory Detection
+
+maintainers:
+  - Nícolas F. R. A. Prado <nfraprado@collabora.com>
+
+description: |
+  The MT6359 Accessory Detection block is part of the MT6359 PMIC and allows
+  detecting audio jack insertion and removal, as well as identifying the type of
+  events connected to the jack.
+
+properties:
+  compatible:
+    const: mediatek,mt6359-accdet
+
+  mediatek,hp-eint-high:
+    type: boolean
+    description:
+      By default, the HP_EINT pin is assumed to be pulled high and connected to
+      a normally open 3.5mm jack. Plug insertion is detected when the pin is
+      brought low in that case. Add this property if the behavior should be
+      inverted, for example if a normally closed 3.5mm jack is used, or if the
+      line is pulled low on open.
+
+required:
+  - compatible
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+
+    accdet: accdet {
+        compatible = "mediatek,mt6359-accdet";
+        mediatek,hp-eint-high;
+    };

-- 
2.48.1



^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v2 02/20] dt-bindings: mfd: mediatek: mt6397: Add accdet subnode
  2025-03-02 16:30 [PATCH v2 00/20] Get mt6359-accdet ready for usage in Devicetree Nícolas F. R. A. Prado
  2025-03-02 16:30 ` [PATCH v2 01/20] ASoC: dt-bindings: Add document for mt6359-accdet Nícolas F. R. A. Prado
@ 2025-03-02 16:30 ` Nícolas F. R. A. Prado
  2025-03-03 15:13   ` Rob Herring
  2025-03-02 16:30 ` [PATCH v2 03/20] mfd: mt6397-core: Add mfd_cell for mt6359-accdet Nícolas F. R. A. Prado
                   ` (17 subsequent siblings)
  19 siblings, 1 reply; 44+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-03-02 16:30 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Matthias Brugger, AngeloGioacchino Del Regno,
	Sen Chu, Sean Wang, Macpaul Lin, Lee Jones, Jaroslav Kysela,
	Takashi Iwai, Catalin Marinas, Will Deacon
  Cc: kernel, linux-sound, devicetree, linux-kernel, linux-arm-kernel,
	linux-mediatek, linux-pm, Nícolas F. R. A. Prado

Describe the accdet as a possible subnode of the MT6359 PMIC.

Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
---
 Documentation/devicetree/bindings/mfd/mediatek,mt6397.yaml | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/Documentation/devicetree/bindings/mfd/mediatek,mt6397.yaml b/Documentation/devicetree/bindings/mfd/mediatek,mt6397.yaml
index 6a89b479d10fad3c8b61cab5a3af1453baca4d1a..1a8c5748a28da6ad8aa091f8c0a74bc1dc709644 100644
--- a/Documentation/devicetree/bindings/mfd/mediatek,mt6397.yaml
+++ b/Documentation/devicetree/bindings/mfd/mediatek,mt6397.yaml
@@ -224,6 +224,13 @@ properties:
     description:
       Pin controller
 
+  accdet:
+    type: object
+    $ref: /schemas/sound/mediatek,mt6359-accdet.yaml
+    unevaluatedProperties: false
+    description:
+      Accessory Detection
+
 required:
   - compatible
   - regulators

-- 
2.48.1



^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v2 03/20] mfd: mt6397-core: Add mfd_cell for mt6359-accdet
  2025-03-02 16:30 [PATCH v2 00/20] Get mt6359-accdet ready for usage in Devicetree Nícolas F. R. A. Prado
  2025-03-02 16:30 ` [PATCH v2 01/20] ASoC: dt-bindings: Add document for mt6359-accdet Nícolas F. R. A. Prado
  2025-03-02 16:30 ` [PATCH v2 02/20] dt-bindings: mfd: mediatek: mt6397: Add accdet subnode Nícolas F. R. A. Prado
@ 2025-03-02 16:30 ` Nícolas F. R. A. Prado
  2025-03-03 11:13   ` AngeloGioacchino Del Regno
  2025-03-02 16:30 ` [PATCH v2 04/20] ASoC: mediatek: mt6359-accdet: Add compatible property Nícolas F. R. A. Prado
                   ` (16 subsequent siblings)
  19 siblings, 1 reply; 44+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-03-02 16:30 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Matthias Brugger, AngeloGioacchino Del Regno,
	Sen Chu, Sean Wang, Macpaul Lin, Lee Jones, Jaroslav Kysela,
	Takashi Iwai, Catalin Marinas, Will Deacon
  Cc: kernel, linux-sound, devicetree, linux-kernel, linux-arm-kernel,
	linux-mediatek, linux-pm, Nícolas F. R. A. Prado,
	Andrew Perepech

From: Andrew Perepech <andrew.perepech@mediatek.com>

Add an mfd_cell for mt6359-accdet and describe its IRQ resources to
allow the mt6359-accdet driver to probe.

Signed-off-by: Andrew Perepech <andrew.perepech@mediatek.com>
Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
---
 drivers/mfd/mt6397-core.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/mfd/mt6397-core.c b/drivers/mfd/mt6397-core.c
index 0e5d59ae064a696ae2111e2b558b316667c14773..5f8ed898890783c0ce4e34c7eae0d8f678e7d7bc 100644
--- a/drivers/mfd/mt6397-core.c
+++ b/drivers/mfd/mt6397-core.c
@@ -84,6 +84,12 @@ static const struct resource mt6359_keys_resources[] = {
 	DEFINE_RES_IRQ_NAMED(MT6359_IRQ_HOMEKEY_R, "homekey_r"),
 };
 
+static const struct resource mt6359_accdet_resources[] = {
+	DEFINE_RES_IRQ_NAMED(MT6359_IRQ_ACCDET, "accdet_irq"),
+	DEFINE_RES_IRQ_NAMED(MT6359_IRQ_ACCDET_EINT0, "accdet_eint0"),
+	DEFINE_RES_IRQ_NAMED(MT6359_IRQ_ACCDET_EINT1, "accdet_eint1"),
+};
+
 static const struct resource mt6323_keys_resources[] = {
 	DEFINE_RES_IRQ_NAMED(MT6323_IRQ_STATUS_PWRKEY, "powerkey"),
 	DEFINE_RES_IRQ_NAMED(MT6323_IRQ_STATUS_FCHRKEY, "homekey"),
@@ -239,6 +245,12 @@ static const struct mfd_cell mt6359_devs[] = {
 		.resources = mt6359_keys_resources,
 		.of_compatible = "mediatek,mt6359-keys"
 	},
+	{
+		.name = "mt6359-accdet",
+		.of_compatible = "mediatek,mt6359-accdet",
+		.num_resources = ARRAY_SIZE(mt6359_accdet_resources),
+		.resources = mt6359_accdet_resources,
+	},
 };
 
 static const struct mfd_cell mt6397_devs[] = {

-- 
2.48.1



^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v2 04/20] ASoC: mediatek: mt6359-accdet: Add compatible property
  2025-03-02 16:30 [PATCH v2 00/20] Get mt6359-accdet ready for usage in Devicetree Nícolas F. R. A. Prado
                   ` (2 preceding siblings ...)
  2025-03-02 16:30 ` [PATCH v2 03/20] mfd: mt6397-core: Add mfd_cell for mt6359-accdet Nícolas F. R. A. Prado
@ 2025-03-02 16:30 ` Nícolas F. R. A. Prado
  2025-03-02 16:30 ` [PATCH v2 05/20] ASoC: mediatek: mt6359-accdet: Handle hp-eint-high property Nícolas F. R. A. Prado
                   ` (15 subsequent siblings)
  19 siblings, 0 replies; 44+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-03-02 16:30 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Matthias Brugger, AngeloGioacchino Del Regno,
	Sen Chu, Sean Wang, Macpaul Lin, Lee Jones, Jaroslav Kysela,
	Takashi Iwai, Catalin Marinas, Will Deacon
  Cc: kernel, linux-sound, devicetree, linux-kernel, linux-arm-kernel,
	linux-mediatek, linux-pm, Nícolas F. R. A. Prado,
	Andrew Perepech

Add a compatible property and add it to the module device table for the
mt6359-accdet platform driver to allow automatic module loading and
probing when the compatible is present in DT.

Co-developed-by: Andrew Perepech <andrew.perepech@mediatek.com>
Signed-off-by: Andrew Perepech <andrew.perepech@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
---
 sound/soc/codecs/mt6359-accdet.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/sound/soc/codecs/mt6359-accdet.c b/sound/soc/codecs/mt6359-accdet.c
index ed34cc15b80e856356c07fd53af22207124e0d19..9bbd4497e8d481ee125693be2fc576b439574b39 100644
--- a/sound/soc/codecs/mt6359-accdet.c
+++ b/sound/soc/codecs/mt6359-accdet.c
@@ -1047,9 +1047,16 @@ static int mt6359_accdet_probe(struct platform_device *pdev)
 	return ret;
 }
 
+const struct of_device_id accdet_of_match[] = {
+	{ .compatible = "mediatek,mt6359-accdet", },
+	{ /* sentinel */ },
+};
+MODULE_DEVICE_TABLE(of, accdet_of_match);
+
 static struct platform_driver mt6359_accdet_driver = {
 	.driver = {
 		.name = "pmic-codec-accdet",
+		.of_match_table = accdet_of_match,
 	},
 	.probe = mt6359_accdet_probe,
 };

-- 
2.48.1



^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v2 05/20] ASoC: mediatek: mt6359-accdet: Handle hp-eint-high property
  2025-03-02 16:30 [PATCH v2 00/20] Get mt6359-accdet ready for usage in Devicetree Nícolas F. R. A. Prado
                   ` (3 preceding siblings ...)
  2025-03-02 16:30 ` [PATCH v2 04/20] ASoC: mediatek: mt6359-accdet: Add compatible property Nícolas F. R. A. Prado
@ 2025-03-02 16:30 ` Nícolas F. R. A. Prado
  2025-03-03 11:07   ` AngeloGioacchino Del Regno
  2025-03-02 16:30 ` [PATCH v2 06/20] ASoC: mediatek: mt6359-accdet: Implement HP_EINT polarity configuration Nícolas F. R. A. Prado
                   ` (14 subsequent siblings)
  19 siblings, 1 reply; 44+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-03-02 16:30 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Matthias Brugger, AngeloGioacchino Del Regno,
	Sen Chu, Sean Wang, Macpaul Lin, Lee Jones, Jaroslav Kysela,
	Takashi Iwai, Catalin Marinas, Will Deacon
  Cc: kernel, linux-sound, devicetree, linux-kernel, linux-arm-kernel,
	linux-mediatek, linux-pm, Nícolas F. R. A. Prado

Now that the dt-binding was introduced, the property that governs the
eint polarity is a boolean called mediatek,hp-eint-high, while the
current code handles a u32 property called mediatek,eint-level-pol.
Update the driver handling accordingly.

Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
---
 sound/soc/codecs/mt6359-accdet.c | 5 +----
 sound/soc/codecs/mt6359-accdet.h | 2 +-
 2 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/sound/soc/codecs/mt6359-accdet.c b/sound/soc/codecs/mt6359-accdet.c
index 9bbd4497e8d481ee125693be2fc576b439574b39..ca3be59d2d0ecaadccd9ba399649ba93f20490c4 100644
--- a/sound/soc/codecs/mt6359-accdet.c
+++ b/sound/soc/codecs/mt6359-accdet.c
@@ -578,10 +578,7 @@ static int mt6359_accdet_parse_dt(struct mt6359_accdet *priv)
 	if (!ret)
 		memcpy(priv->data->pwm_deb, pwm_deb, sizeof(pwm_deb));
 
-	ret = of_property_read_u32(node, "mediatek,eint-level-pol",
-				   &priv->data->eint_pol);
-	if (ret)
-		priv->data->eint_pol = 8;
+	priv->data->hp_eint_high = of_property_read_bool(node, "mediatek,hp-eint-high");
 
 	ret = of_property_read_u32(node, "mediatek,eint-use-ap", &tmp);
 	if (ret)
diff --git a/sound/soc/codecs/mt6359-accdet.h b/sound/soc/codecs/mt6359-accdet.h
index c234f2f4276a12853a6fe0b13c4198dfc551b6b4..a54a328bdf3797ce642da446c0cc6792f72ec939 100644
--- a/sound/soc/codecs/mt6359-accdet.h
+++ b/sound/soc/codecs/mt6359-accdet.h
@@ -86,7 +86,7 @@ struct dts_data {
 	unsigned int mic_vol;
 	unsigned int mic_mode;
 	unsigned int plugout_deb;
-	unsigned int eint_pol;
+	bool hp_eint_high;
 	struct pwm_deb_settings *pwm_deb;
 	struct three_key_threshold three_key;
 	struct four_key_threshold four_key;

-- 
2.48.1



^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v2 06/20] ASoC: mediatek: mt6359-accdet: Implement HP_EINT polarity configuration
  2025-03-02 16:30 [PATCH v2 00/20] Get mt6359-accdet ready for usage in Devicetree Nícolas F. R. A. Prado
                   ` (4 preceding siblings ...)
  2025-03-02 16:30 ` [PATCH v2 05/20] ASoC: mediatek: mt6359-accdet: Handle hp-eint-high property Nícolas F. R. A. Prado
@ 2025-03-02 16:30 ` Nícolas F. R. A. Prado
  2025-03-03 11:15   ` AngeloGioacchino Del Regno
  2025-03-02 16:30 ` [PATCH v2 07/20] ASoC: mediatek: mt6359-accdet: Drop dead code for EINT/GPIO IRQ handling Nícolas F. R. A. Prado
                   ` (13 subsequent siblings)
  19 siblings, 1 reply; 44+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-03-02 16:30 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Matthias Brugger, AngeloGioacchino Del Regno,
	Sen Chu, Sean Wang, Macpaul Lin, Lee Jones, Jaroslav Kysela,
	Takashi Iwai, Catalin Marinas, Will Deacon
  Cc: kernel, linux-sound, devicetree, linux-kernel, linux-arm-kernel,
	linux-mediatek, linux-pm, Nícolas F. R. A. Prado,
	Andrew Perepech

From: Andrew Perepech <andrew.perepech@mediatek.com>

The driver currently reads the HP_EINT polarity from the Devicetree but
never actually configures the hardware accordingly.

Implement the polarity configuration in hardware.

Signed-off-by: Andrew Perepech <andrew.perepech@mediatek.com>
Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
---
 sound/soc/codecs/mt6359-accdet.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/sound/soc/codecs/mt6359-accdet.c b/sound/soc/codecs/mt6359-accdet.c
index ca3be59d2d0ecaadccd9ba399649ba93f20490c4..1d4481109f6e4f473610e0797c9d3c636bdf12cf 100644
--- a/sound/soc/codecs/mt6359-accdet.c
+++ b/sound/soc/codecs/mt6359-accdet.c
@@ -730,6 +730,17 @@ static void config_digital_init_by_mode(struct mt6359_accdet *priv)
 					   BIT(ACCDET_EINT1_INVERTER_SW_EN_SFT));
 		}
 	}
+
+	if (priv->data->hp_eint_high) {
+		/* EINT polarity inverse */
+		regmap_update_bits(priv->regmap, ACCDET_EINT_IN_INVERSE_ADDR,
+				   ACCDET_EINT_IN_INVERSE_MASK_SFT,
+				   BIT(ACCDET_EINT_IN_INVERSE_SFT));
+	} else {
+		/* EINT polarity normal */
+		regmap_update_bits(priv->regmap, ACCDET_EINT_IN_INVERSE_ADDR,
+				   ACCDET_EINT_IN_INVERSE_MASK_SFT, 0);
+	}
 }
 
 static void config_eint_init_by_mode(struct mt6359_accdet *priv)

-- 
2.48.1



^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v2 07/20] ASoC: mediatek: mt6359-accdet: Drop dead code for EINT/GPIO IRQ handling
  2025-03-02 16:30 [PATCH v2 00/20] Get mt6359-accdet ready for usage in Devicetree Nícolas F. R. A. Prado
                   ` (5 preceding siblings ...)
  2025-03-02 16:30 ` [PATCH v2 06/20] ASoC: mediatek: mt6359-accdet: Implement HP_EINT polarity configuration Nícolas F. R. A. Prado
@ 2025-03-02 16:30 ` Nícolas F. R. A. Prado
  2025-03-03 11:07   ` AngeloGioacchino Del Regno
  2025-03-02 16:30 ` [PATCH v2 08/20] ASoC: mediatek: mt6359-accdet: Drop dead code for EINT trigger setting Nícolas F. R. A. Prado
                   ` (12 subsequent siblings)
  19 siblings, 1 reply; 44+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-03-02 16:30 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Matthias Brugger, AngeloGioacchino Del Regno,
	Sen Chu, Sean Wang, Macpaul Lin, Lee Jones, Jaroslav Kysela,
	Takashi Iwai, Catalin Marinas, Will Deacon
  Cc: kernel, linux-sound, devicetree, linux-kernel, linux-arm-kernel,
	linux-mediatek, linux-pm, Nícolas F. R. A. Prado

The ACCDET supports two modes for IRQ generation: PMIC EINT or AP GPIO,
which in principle could be configured through a DT property. However
this DT property has no user nor is documented in a binding, and the
driver only implements the PMIC EINT case, so drop the unused code
intended to handle both cases.

Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
---
 sound/soc/codecs/mt6359-accdet.c | 20 +++-----------------
 1 file changed, 3 insertions(+), 17 deletions(-)

diff --git a/sound/soc/codecs/mt6359-accdet.c b/sound/soc/codecs/mt6359-accdet.c
index 1d4481109f6e4f473610e0797c9d3c636bdf12cf..ce8a5e64e0b9ca508124043ca1f93aaa3cc5f9a0 100644
--- a/sound/soc/codecs/mt6359-accdet.c
+++ b/sound/soc/codecs/mt6359-accdet.c
@@ -31,9 +31,6 @@
 #define REGISTER_VAL(x)	((x) - 1)
 
 /* mt6359 accdet capability */
-#define ACCDET_PMIC_EINT_IRQ		BIT(0)
-#define ACCDET_AP_GPIO_EINT		BIT(1)
-
 #define ACCDET_PMIC_EINT0		BIT(2)
 #define ACCDET_PMIC_EINT1		BIT(3)
 #define ACCDET_PMIC_BI_EINT		BIT(4)
@@ -448,8 +445,7 @@ static void mt6359_accdet_jd_work(struct work_struct *work)
 		mt6359_accdet_recover_jd_setting(priv);
 	}
 
-	if (priv->caps & ACCDET_PMIC_EINT_IRQ)
-		recover_eint_setting(priv);
+	recover_eint_setting(priv);
 	mutex_unlock(&priv->res_lock);
 }
 
@@ -580,14 +576,6 @@ static int mt6359_accdet_parse_dt(struct mt6359_accdet *priv)
 
 	priv->data->hp_eint_high = of_property_read_bool(node, "mediatek,hp-eint-high");
 
-	ret = of_property_read_u32(node, "mediatek,eint-use-ap", &tmp);
-	if (ret)
-		tmp = 0;
-	if (tmp == 0)
-		priv->caps |= ACCDET_PMIC_EINT_IRQ;
-	else if (tmp == 1)
-		priv->caps |= ACCDET_AP_GPIO_EINT;
-
 	ret = of_property_read_u32(node, "mediatek,eint-detect-mode",
 				   &priv->data->eint_detect_mode);
 	if (ret) {
@@ -902,10 +890,8 @@ static void mt6359_accdet_init(struct mt6359_accdet *priv)
 				   0x3 << RG_ANALOGFDEN_SFT);
 	}
 
-	if (priv->caps & ACCDET_PMIC_EINT_IRQ) {
-		config_eint_init_by_mode(priv);
-		config_digital_init_by_mode(priv);
-	}
+	config_eint_init_by_mode(priv);
+	config_digital_init_by_mode(priv);
 }
 
 int mt6359_accdet_enable_jack_detect(struct snd_soc_component *component,

-- 
2.48.1



^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v2 08/20] ASoC: mediatek: mt6359-accdet: Drop dead code for EINT trigger setting
  2025-03-02 16:30 [PATCH v2 00/20] Get mt6359-accdet ready for usage in Devicetree Nícolas F. R. A. Prado
                   ` (6 preceding siblings ...)
  2025-03-02 16:30 ` [PATCH v2 07/20] ASoC: mediatek: mt6359-accdet: Drop dead code for EINT/GPIO IRQ handling Nícolas F. R. A. Prado
@ 2025-03-02 16:30 ` Nícolas F. R. A. Prado
  2025-03-03 11:07   ` AngeloGioacchino Del Regno
  2025-03-02 16:30 ` [PATCH v2 09/20] ASoC: mediatek: mt6359-accdet: Drop dead code for button detection Nícolas F. R. A. Prado
                   ` (11 subsequent siblings)
  19 siblings, 1 reply; 44+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-03-02 16:30 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Matthias Brugger, AngeloGioacchino Del Regno,
	Sen Chu, Sean Wang, Macpaul Lin, Lee Jones, Jaroslav Kysela,
	Takashi Iwai, Catalin Marinas, Will Deacon
  Cc: kernel, linux-sound, devicetree, linux-kernel, linux-arm-kernel,
	linux-mediatek, linux-pm, Nícolas F. R. A. Prado

None of the EINT trigger options are implemented and the DT property is
not described in the binding. Remove the unused code.

Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
---
 sound/soc/codecs/mt6359-accdet.c | 11 -----------
 1 file changed, 11 deletions(-)

diff --git a/sound/soc/codecs/mt6359-accdet.c b/sound/soc/codecs/mt6359-accdet.c
index ce8a5e64e0b9ca508124043ca1f93aaa3cc5f9a0..a21c6544174517e3eebc8cf25d1ea3029ba014f6 100644
--- a/sound/soc/codecs/mt6359-accdet.c
+++ b/sound/soc/codecs/mt6359-accdet.c
@@ -35,8 +35,6 @@
 #define ACCDET_PMIC_EINT1		BIT(3)
 #define ACCDET_PMIC_BI_EINT		BIT(4)
 
-#define ACCDET_PMIC_GPIO_TRIG_EINT	BIT(5)
-#define ACCDET_PMIC_INVERTER_TRIG_EINT	BIT(6)
 #define ACCDET_PMIC_RSV_EINT		BIT(7)
 
 #define ACCDET_THREE_KEY		BIT(8)
@@ -593,15 +591,6 @@ static int mt6359_accdet_parse_dt(struct mt6359_accdet *priv)
 	else if (tmp == 2)
 		priv->caps |= ACCDET_PMIC_BI_EINT;
 
-	ret = of_property_read_u32(node, "mediatek,eint-trig-mode",
-				   &tmp);
-	if (ret)
-		tmp = 0;
-	if (tmp == 0)
-		priv->caps |= ACCDET_PMIC_GPIO_TRIG_EINT;
-	else if (tmp == 1)
-		priv->caps |= ACCDET_PMIC_INVERTER_TRIG_EINT;
-
 	ret = of_property_read_u32(node, "mediatek,eint-use-ext-res",
 				   &priv->data->eint_use_ext_res);
 	if (ret) {

-- 
2.48.1



^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v2 09/20] ASoC: mediatek: mt6359-accdet: Drop dead code for button detection
  2025-03-02 16:30 [PATCH v2 00/20] Get mt6359-accdet ready for usage in Devicetree Nícolas F. R. A. Prado
                   ` (7 preceding siblings ...)
  2025-03-02 16:30 ` [PATCH v2 08/20] ASoC: mediatek: mt6359-accdet: Drop dead code for EINT trigger setting Nícolas F. R. A. Prado
@ 2025-03-02 16:30 ` Nícolas F. R. A. Prado
  2025-03-03 11:07   ` AngeloGioacchino Del Regno
  2025-03-02 16:30 ` [PATCH v2 10/20] ASoC: mediatek: mt6359-accdet: Drop dead code for plugout-debounce Nícolas F. R. A. Prado
                   ` (10 subsequent siblings)
  19 siblings, 1 reply; 44+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-03-02 16:30 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Matthias Brugger, AngeloGioacchino Del Regno,
	Sen Chu, Sean Wang, Macpaul Lin, Lee Jones, Jaroslav Kysela,
	Takashi Iwai, Catalin Marinas, Will Deacon
  Cc: kernel, linux-sound, devicetree, linux-kernel, linux-arm-kernel,
	linux-mediatek, linux-pm, Nícolas F. R. A. Prado

The button detection functionality depends on a calibration voltage
value which is currently not updated anywhere in the driver code, and
hence it doesn't actually do anything. Remove this unused code.

Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
---
 sound/soc/codecs/mt6359-accdet.c | 92 ++--------------------------------------
 sound/soc/codecs/mt6359-accdet.h | 17 --------
 2 files changed, 3 insertions(+), 106 deletions(-)

diff --git a/sound/soc/codecs/mt6359-accdet.c b/sound/soc/codecs/mt6359-accdet.c
index a21c6544174517e3eebc8cf25d1ea3029ba014f6..6b0178976d91e37c32540991693ebfd8e29c11f5 100644
--- a/sound/soc/codecs/mt6359-accdet.c
+++ b/sound/soc/codecs/mt6359-accdet.c
@@ -37,9 +37,6 @@
 
 #define ACCDET_PMIC_RSV_EINT		BIT(7)
 
-#define ACCDET_THREE_KEY		BIT(8)
-#define ACCDET_FOUR_KEY			BIT(9)
-#define ACCDET_TRI_KEY_CDD		BIT(10)
 #define ACCDET_RSV_KEY			BIT(11)
 
 #define ACCDET_ANALOG_FASTDISCHARGE	BIT(12)
@@ -255,7 +252,6 @@ static void mt6359_accdet_recover_jd_setting(struct mt6359_accdet *priv)
 			    priv->data->pwm_deb->debounce3);
 
 	priv->jack_type = 0;
-	priv->btn_type = 0;
 	priv->accdet_status = 0x3;
 	mt6359_accdet_jack_report(priv);
 }
@@ -318,45 +314,10 @@ static void mt6359_accdet_jack_report(struct mt6359_accdet *priv)
 	if (!priv->jack)
 		return;
 
-	report = priv->jack_type | priv->btn_type;
+	report = priv->jack_type;
 	snd_soc_jack_report(priv->jack, report, MT6359_ACCDET_JACK_MASK);
 }
 
-static unsigned int check_button(struct mt6359_accdet *priv, unsigned int v)
-{
-	if (priv->caps & ACCDET_FOUR_KEY) {
-		if (v < priv->data->four_key.down &&
-		    v >= priv->data->four_key.up)
-			priv->btn_type = SND_JACK_BTN_1;
-		if (v < priv->data->four_key.up &&
-		    v >= priv->data->four_key.voice)
-			priv->btn_type = SND_JACK_BTN_2;
-		if (v < priv->data->four_key.voice &&
-		    v >= priv->data->four_key.mid)
-			priv->btn_type = SND_JACK_BTN_3;
-		if (v < priv->data->four_key.mid)
-			priv->btn_type = SND_JACK_BTN_0;
-	} else {
-		if (v < priv->data->three_key.down &&
-		    v >= priv->data->three_key.up)
-			priv->btn_type = SND_JACK_BTN_1;
-		if (v < priv->data->three_key.up &&
-		    v >= priv->data->three_key.mid)
-			priv->btn_type = SND_JACK_BTN_2;
-		if (v < priv->data->three_key.mid)
-			priv->btn_type = SND_JACK_BTN_0;
-	}
-	return 0;
-}
-
-static void is_key_pressed(struct mt6359_accdet *priv, bool pressed)
-{
-	priv->btn_type = priv->jack_type & ~MT6359_ACCDET_BTN_MASK;
-
-	if (pressed)
-		check_button(priv, priv->cali_voltage);
-}
-
 static inline void check_jack_btn_type(struct mt6359_accdet *priv)
 {
 	unsigned int val = 0;
@@ -368,15 +329,11 @@ static inline void check_jack_btn_type(struct mt6359_accdet *priv)
 
 	switch (priv->accdet_status) {
 	case 0:
-		if (priv->jack_type == SND_JACK_HEADSET)
-			is_key_pressed(priv, true);
-		else
+		if (priv->jack_type != SND_JACK_HEADSET)
 			priv->jack_type = SND_JACK_HEADPHONE;
 		break;
 	case 1:
-		if (priv->jack_type == SND_JACK_HEADSET) {
-			is_key_pressed(priv, false);
-		} else {
+		if (priv->jack_type != SND_JACK_HEADSET) {
 			priv->jack_type = SND_JACK_HEADSET;
 			accdet_set_debounce(priv, eint_state011, 0x1);
 		}
@@ -603,48 +560,6 @@ static int mt6359_accdet_parse_dt(struct mt6359_accdet *priv)
 	if (ret)
 		priv->data->eint_comp_vth = 0x0;
 
-	ret = of_property_read_u32(node, "mediatek,key-mode", &tmp);
-	if (ret)
-		tmp = 0;
-	if (tmp == 0) {
-		int three_key[4];
-
-		priv->caps |= ACCDET_THREE_KEY;
-		ret = of_property_read_u32_array(node,
-						 "mediatek,three-key-thr",
-						 three_key,
-						 ARRAY_SIZE(three_key));
-		if (!ret)
-			memcpy(&priv->data->three_key, three_key + 1,
-			       sizeof(struct three_key_threshold));
-	} else if (tmp == 1) {
-		int four_key[5];
-
-		priv->caps |= ACCDET_FOUR_KEY;
-		ret = of_property_read_u32_array(node,
-						 "mediatek,four-key-thr",
-						 four_key,
-						 ARRAY_SIZE(four_key));
-		if (!ret) {
-			memcpy(&priv->data->four_key, four_key + 1,
-			       sizeof(struct four_key_threshold));
-		} else {
-			dev_warn(priv->dev,
-				 "accdet no 4-key-thrsh dts, use efuse\n");
-		}
-	} else if (tmp == 2) {
-		int three_key[4];
-
-		priv->caps |= ACCDET_TRI_KEY_CDD;
-		ret = of_property_read_u32_array(node,
-						 "mediatek,tri-key-cdd-thr",
-						 three_key,
-						 ARRAY_SIZE(three_key));
-		if (!ret)
-			memcpy(&priv->data->three_key, three_key + 1,
-			       sizeof(struct three_key_threshold));
-	}
-
 	of_node_put(node);
 	dev_warn(priv->dev, "accdet caps=%x\n", priv->caps);
 
@@ -1015,7 +930,6 @@ static int mt6359_accdet_probe(struct platform_device *pdev)
 
 	priv->jd_sts = M_PLUG_OUT;
 	priv->jack_type = 0;
-	priv->btn_type = 0;
 	priv->accdet_status = 0x3;
 	mt6359_accdet_init(priv);
 
diff --git a/sound/soc/codecs/mt6359-accdet.h b/sound/soc/codecs/mt6359-accdet.h
index a54a328bdf3797ce642da446c0cc6792f72ec939..09e1072b61a4c929bf6b764b4fab3c4b26f7cf4a 100644
--- a/sound/soc/codecs/mt6359-accdet.h
+++ b/sound/soc/codecs/mt6359-accdet.h
@@ -50,19 +50,6 @@ enum {
 	eint_inverter_state000,
 };
 
-struct three_key_threshold {
-	unsigned int mid;
-	unsigned int up;
-	unsigned int down;
-};
-
-struct four_key_threshold {
-	unsigned int mid;
-	unsigned int voice;
-	unsigned int up;
-	unsigned int down;
-};
-
 struct pwm_deb_settings {
 	unsigned int pwm_width;
 	unsigned int pwm_thresh;
@@ -88,8 +75,6 @@ struct dts_data {
 	unsigned int plugout_deb;
 	bool hp_eint_high;
 	struct pwm_deb_settings *pwm_deb;
-	struct three_key_threshold three_key;
-	struct four_key_threshold four_key;
 	unsigned int moisture_detect_enable;
 	unsigned int eint_detect_mode;
 	unsigned int eint_use_ext_res;
@@ -112,10 +97,8 @@ struct mt6359_accdet {
 	struct mutex res_lock; /* lock protection */
 	bool jack_plugged;
 	unsigned int jack_type;
-	unsigned int btn_type;
 	unsigned int accdet_status;
 	unsigned int pre_accdet_status;
-	unsigned int cali_voltage;
 	unsigned int jd_sts;
 	struct work_struct accdet_work;
 	struct workqueue_struct *accdet_workqueue;

-- 
2.48.1



^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v2 10/20] ASoC: mediatek: mt6359-accdet: Drop dead code for plugout-debounce
  2025-03-02 16:30 [PATCH v2 00/20] Get mt6359-accdet ready for usage in Devicetree Nícolas F. R. A. Prado
                   ` (8 preceding siblings ...)
  2025-03-02 16:30 ` [PATCH v2 09/20] ASoC: mediatek: mt6359-accdet: Drop dead code for button detection Nícolas F. R. A. Prado
@ 2025-03-02 16:30 ` Nícolas F. R. A. Prado
  2025-03-03 11:07   ` AngeloGioacchino Del Regno
  2025-03-02 16:30 ` [PATCH v2 11/20] ASoC: mediatek: mt6359-accdet: Drop unused moisture variables Nícolas F. R. A. Prado
                   ` (9 subsequent siblings)
  19 siblings, 1 reply; 44+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-03-02 16:30 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Matthias Brugger, AngeloGioacchino Del Regno,
	Sen Chu, Sean Wang, Macpaul Lin, Lee Jones, Jaroslav Kysela,
	Takashi Iwai, Catalin Marinas, Will Deacon
  Cc: kernel, linux-sound, devicetree, linux-kernel, linux-arm-kernel,
	linux-mediatek, linux-pm, Nícolas F. R. A. Prado

The mediatek,plugout-debounce property is undocumented in the binding
and unhandled by the driver. Remove it.

Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
---
 sound/soc/codecs/mt6359-accdet.c | 5 -----
 sound/soc/codecs/mt6359-accdet.h | 1 -
 2 files changed, 6 deletions(-)

diff --git a/sound/soc/codecs/mt6359-accdet.c b/sound/soc/codecs/mt6359-accdet.c
index 6b0178976d91e37c32540991693ebfd8e29c11f5..d78d7516342a5c2273b1c2962c0346646aa6390f 100644
--- a/sound/soc/codecs/mt6359-accdet.c
+++ b/sound/soc/codecs/mt6359-accdet.c
@@ -513,11 +513,6 @@ static int mt6359_accdet_parse_dt(struct mt6359_accdet *priv)
 	if (ret)
 		priv->data->mic_vol = 8;
 
-	ret = of_property_read_u32(node, "mediatek,plugout-debounce",
-				   &priv->data->plugout_deb);
-	if (ret)
-		priv->data->plugout_deb = 1;
-
 	ret = of_property_read_u32(node, "mediatek,mic-mode",
 				   &priv->data->mic_mode);
 	if (ret)
diff --git a/sound/soc/codecs/mt6359-accdet.h b/sound/soc/codecs/mt6359-accdet.h
index 09e1072b61a4c929bf6b764b4fab3c4b26f7cf4a..54a33a0f0e084f80df33386b3df9bba9525fa880 100644
--- a/sound/soc/codecs/mt6359-accdet.h
+++ b/sound/soc/codecs/mt6359-accdet.h
@@ -72,7 +72,6 @@ struct pwm_deb_settings {
 struct dts_data {
 	unsigned int mic_vol;
 	unsigned int mic_mode;
-	unsigned int plugout_deb;
 	bool hp_eint_high;
 	struct pwm_deb_settings *pwm_deb;
 	unsigned int moisture_detect_enable;

-- 
2.48.1



^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v2 11/20] ASoC: mediatek: mt6359-accdet: Drop unused moisture variables
  2025-03-02 16:30 [PATCH v2 00/20] Get mt6359-accdet ready for usage in Devicetree Nícolas F. R. A. Prado
                   ` (9 preceding siblings ...)
  2025-03-02 16:30 ` [PATCH v2 10/20] ASoC: mediatek: mt6359-accdet: Drop dead code for plugout-debounce Nícolas F. R. A. Prado
@ 2025-03-02 16:30 ` Nícolas F. R. A. Prado
  2025-03-03 11:07   ` AngeloGioacchino Del Regno
  2025-03-02 16:30 ` [PATCH v2 12/20] ASoC: mediatek: mt6359-accdet: Always use internal resistor Nícolas F. R. A. Prado
                   ` (8 subsequent siblings)
  19 siblings, 1 reply; 44+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-03-02 16:30 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Matthias Brugger, AngeloGioacchino Del Regno,
	Sen Chu, Sean Wang, Macpaul Lin, Lee Jones, Jaroslav Kysela,
	Takashi Iwai, Catalin Marinas, Will Deacon
  Cc: kernel, linux-sound, devicetree, linux-kernel, linux-arm-kernel,
	linux-mediatek, linux-pm, Nícolas F. R. A. Prado

The dts_data struct contains several variables for moisture
configuration that are simply never used. Drop them.

Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
---
 sound/soc/codecs/mt6359-accdet.h | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/sound/soc/codecs/mt6359-accdet.h b/sound/soc/codecs/mt6359-accdet.h
index 54a33a0f0e084f80df33386b3df9bba9525fa880..38c36d59b9cc68bd90e16137a05a62b521b75ac1 100644
--- a/sound/soc/codecs/mt6359-accdet.h
+++ b/sound/soc/codecs/mt6359-accdet.h
@@ -74,14 +74,9 @@ struct dts_data {
 	unsigned int mic_mode;
 	bool hp_eint_high;
 	struct pwm_deb_settings *pwm_deb;
-	unsigned int moisture_detect_enable;
 	unsigned int eint_detect_mode;
 	unsigned int eint_use_ext_res;
 	unsigned int eint_comp_vth;
-	unsigned int moisture_detect_mode;
-	unsigned int moisture_comp_vth;
-	unsigned int moisture_comp_vref2;
-	unsigned int moisture_use_ext_res;
 };
 
 struct mt6359_accdet {

-- 
2.48.1



^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v2 12/20] ASoC: mediatek: mt6359-accdet: Always use internal resistor
  2025-03-02 16:30 [PATCH v2 00/20] Get mt6359-accdet ready for usage in Devicetree Nícolas F. R. A. Prado
                   ` (10 preceding siblings ...)
  2025-03-02 16:30 ` [PATCH v2 11/20] ASoC: mediatek: mt6359-accdet: Drop unused moisture variables Nícolas F. R. A. Prado
@ 2025-03-02 16:30 ` Nícolas F. R. A. Prado
  2025-03-03 11:06   ` AngeloGioacchino Del Regno
  2025-03-02 16:30 ` [PATCH v2 13/20] ASoC: mediatek: mt6359-accdet: Make PWM debounce settings internal Nícolas F. R. A. Prado
                   ` (7 subsequent siblings)
  19 siblings, 1 reply; 44+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-03-02 16:30 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Matthias Brugger, AngeloGioacchino Del Regno,
	Sen Chu, Sean Wang, Macpaul Lin, Lee Jones, Jaroslav Kysela,
	Takashi Iwai, Catalin Marinas, Will Deacon
  Cc: kernel, linux-sound, devicetree, linux-kernel, linux-arm-kernel,
	linux-mediatek, linux-pm, Nícolas F. R. A. Prado

The code currently reads a property mediatek,eint-use-ext-res with
values ranging between 0 and 4. Not only should this be a boolean
property, but there's no need for it to even be a DT property, seeing as
all current boards will use the internal resistor anyway. Since there's
no current dt-binding or Devicetree user of this property, remove its
handling and make the driver always configure the internal resistor.

Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
---
 sound/soc/codecs/mt6359-accdet.c | 53 +++++++++++-----------------------------
 sound/soc/codecs/mt6359-accdet.h |  1 -
 2 files changed, 14 insertions(+), 40 deletions(-)

diff --git a/sound/soc/codecs/mt6359-accdet.c b/sound/soc/codecs/mt6359-accdet.c
index d78d7516342a5c2273b1c2962c0346646aa6390f..e04cfb9a607aa5d38d46329eb1387545fda37ccc 100644
--- a/sound/soc/codecs/mt6359-accdet.c
+++ b/sound/soc/codecs/mt6359-accdet.c
@@ -82,14 +82,10 @@ static unsigned int adjust_eint_analog_setting(struct mt6359_accdet *priv)
 					   RG_EINT1CONFIGACCDET_MASK_SFT,
 					   BIT(RG_EINT1CONFIGACCDET_SFT));
 		}
-		if (priv->data->eint_use_ext_res == 0x3 ||
-		    priv->data->eint_use_ext_res == 0x4) {
-			/*select 500k, use internal resistor */
-			regmap_update_bits(priv->regmap,
-					   RG_EINT0HIRENB_ADDR,
-					   RG_EINT0HIRENB_MASK_SFT,
-					   BIT(RG_EINT0HIRENB_SFT));
-		}
+		/*select 500k, use internal resistor */
+		regmap_update_bits(priv->regmap, RG_EINT0HIRENB_ADDR,
+				   RG_EINT0HIRENB_MASK_SFT,
+				   BIT(RG_EINT0HIRENB_SFT));
 	}
 	return 0;
 }
@@ -543,13 +539,6 @@ static int mt6359_accdet_parse_dt(struct mt6359_accdet *priv)
 	else if (tmp == 2)
 		priv->caps |= ACCDET_PMIC_BI_EINT;
 
-	ret = of_property_read_u32(node, "mediatek,eint-use-ext-res",
-				   &priv->data->eint_use_ext_res);
-	if (ret) {
-		/* eint use internal resister */
-		priv->data->eint_use_ext_res = 0x0;
-	}
-
 	ret = of_property_read_u32(node, "mediatek,eint-comp-vth",
 				   &priv->data->eint_comp_vth);
 	if (ret)
@@ -651,30 +640,16 @@ static void config_eint_init_by_mode(struct mt6359_accdet *priv)
 	if (priv->data->eint_detect_mode == 0x1 ||
 	    priv->data->eint_detect_mode == 0x2 ||
 	    priv->data->eint_detect_mode == 0x3) {
-		if (priv->data->eint_use_ext_res == 0x1) {
-			if (priv->caps & ACCDET_PMIC_EINT0) {
-				regmap_update_bits(priv->regmap,
-						   RG_EINT0CONFIGACCDET_ADDR,
-						   RG_EINT0CONFIGACCDET_MASK_SFT,
-						   0);
-			} else if (priv->caps & ACCDET_PMIC_EINT1) {
-				regmap_update_bits(priv->regmap,
-						   RG_EINT1CONFIGACCDET_ADDR,
-						   RG_EINT1CONFIGACCDET_MASK_SFT,
-						   0);
-			}
-		} else {
-			if (priv->caps & ACCDET_PMIC_EINT0) {
-				regmap_update_bits(priv->regmap,
-						   RG_EINT0CONFIGACCDET_ADDR,
-						   RG_EINT0CONFIGACCDET_MASK_SFT,
-						   BIT(RG_EINT0CONFIGACCDET_SFT));
-			} else if (priv->caps & ACCDET_PMIC_EINT1) {
-				regmap_update_bits(priv->regmap,
-						   RG_EINT1CONFIGACCDET_ADDR,
-						   RG_EINT1CONFIGACCDET_MASK_SFT,
-						   BIT(RG_EINT1CONFIGACCDET_SFT));
-			}
+		if (priv->caps & ACCDET_PMIC_EINT0) {
+			regmap_update_bits(priv->regmap,
+					   RG_EINT0CONFIGACCDET_ADDR,
+					   RG_EINT0CONFIGACCDET_MASK_SFT,
+					   BIT(RG_EINT0CONFIGACCDET_SFT));
+		} else if (priv->caps & ACCDET_PMIC_EINT1) {
+			regmap_update_bits(priv->regmap,
+					   RG_EINT1CONFIGACCDET_ADDR,
+					   RG_EINT1CONFIGACCDET_MASK_SFT,
+					   BIT(RG_EINT1CONFIGACCDET_SFT));
 		}
 	}
 
diff --git a/sound/soc/codecs/mt6359-accdet.h b/sound/soc/codecs/mt6359-accdet.h
index 38c36d59b9cc68bd90e16137a05a62b521b75ac1..99de5037a2294b62cb8535fc45dbf4c6fafb5c7f 100644
--- a/sound/soc/codecs/mt6359-accdet.h
+++ b/sound/soc/codecs/mt6359-accdet.h
@@ -75,7 +75,6 @@ struct dts_data {
 	bool hp_eint_high;
 	struct pwm_deb_settings *pwm_deb;
 	unsigned int eint_detect_mode;
-	unsigned int eint_use_ext_res;
 	unsigned int eint_comp_vth;
 };
 

-- 
2.48.1



^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v2 13/20] ASoC: mediatek: mt6359-accdet: Make PWM debounce settings internal
  2025-03-02 16:30 [PATCH v2 00/20] Get mt6359-accdet ready for usage in Devicetree Nícolas F. R. A. Prado
                   ` (11 preceding siblings ...)
  2025-03-02 16:30 ` [PATCH v2 12/20] ASoC: mediatek: mt6359-accdet: Always use internal resistor Nícolas F. R. A. Prado
@ 2025-03-02 16:30 ` Nícolas F. R. A. Prado
  2025-03-03 11:07   ` AngeloGioacchino Del Regno
  2025-03-02 16:30 ` [PATCH v2 14/20] ASoC: mediatek: mt6359-accdet: Always use eint detect mode 4 Nícolas F. R. A. Prado
                   ` (6 subsequent siblings)
  19 siblings, 1 reply; 44+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-03-02 16:30 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Matthias Brugger, AngeloGioacchino Del Regno,
	Sen Chu, Sean Wang, Macpaul Lin, Lee Jones, Jaroslav Kysela,
	Takashi Iwai, Catalin Marinas, Will Deacon
  Cc: kernel, linux-sound, devicetree, linux-kernel, linux-arm-kernel,
	linux-mediatek, linux-pm, Nícolas F. R. A. Prado

Instead of reading a bunch of PWM debounce settings from the Devicetree,
set reasonable values inside the driver that are known to work across
multiple boards. There are no current users of these DT properties, so
no backward compatibility needs to be maintained. The properties can be
properly introduced in the binding in the future if different boards
really need to override them.

Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
---
 sound/soc/codecs/mt6359-accdet.c | 70 ++++++++++++++++++++++------------------
 sound/soc/codecs/mt6359-accdet.h | 20 ------------
 2 files changed, 38 insertions(+), 52 deletions(-)

diff --git a/sound/soc/codecs/mt6359-accdet.c b/sound/soc/codecs/mt6359-accdet.c
index e04cfb9a607aa5d38d46329eb1387545fda37ccc..6728f1018c992fc9d4e4133dbaf091d256567683 100644
--- a/sound/soc/codecs/mt6359-accdet.c
+++ b/sound/soc/codecs/mt6359-accdet.c
@@ -43,6 +43,25 @@
 #define ACCDET_DIGITAL_FASTDISCHARGE	BIT(13)
 #define ACCDET_AD_FASTDISCHRAGE		BIT(14)
 
+/* Debounce time = (DEBOUNCE/32768) sec */
+#define ACCDET_DEBOUNCE0_625MS 0x800
+#define ACCDET_DEBOUNCE1_625MS 0x800
+#define ACCDET_DEBOUNCE3_976US 0x20
+#define ACCDET_DEBOUNCE_AUXADC_2MS 0x44
+/* PWM frequency = 32768/(PWM_WIDTH + 1) Hz */
+#define ACCDET_PWM_WIDTH_25_580HZ 0x500
+/* Duty cycle = (PWM_THRESH + 1) / (PWM_WIDTH + 1) */
+#define ACCDET_PWM_THRESH_100PERCENT ACCDET_PWM_WIDTH_25_580HZ
+#define ACCDET_RISE_DELAY 0x1f0
+#define ACCDET_FALL_DELAY 1
+#define ACCDET_EINT_DEBOUNCE0_1MS 5
+#define ACCDET_EINT_DEBOUNCE1_900US 3
+#define ACCDET_EINT_DEBOUNCE2_900US 3
+#define ACCDET_EINT_DEBOUNCE3_1MS 5
+#define ACCDET_EINT_INVERTER_DEBOUNCE_256MS 0xe
+#define ACCDET_EINT_CMPMEN_PWM_WIDTH_400MS 4
+#define ACCDET_EINT_CMPMEN_PWM_THRESH_2MS 1
+
 static struct platform_driver mt6359_accdet_driver;
 static const struct snd_soc_component_driver mt6359_accdet_soc_driver;
 
@@ -130,7 +149,7 @@ static unsigned int mt6359_accdet_jd_setting(struct mt6359_accdet *priv)
 	} else if (priv->jd_sts == M_PLUG_OUT) {
 		/* set debounce to 1ms */
 		accdet_set_debounce(priv, eint_state000,
-				    priv->data->pwm_deb->eint_debounce0);
+				    ACCDET_EINT_DEBOUNCE0_1MS);
 	} else {
 		dev_dbg(priv->dev, "should not be here %s()\n", __func__);
 	}
@@ -241,11 +260,11 @@ static void mt6359_accdet_recover_jd_setting(struct mt6359_accdet *priv)
 
 	/* recover accdet debounce0,3 */
 	accdet_set_debounce(priv, accdet_state000,
-			    priv->data->pwm_deb->debounce0);
+			    ACCDET_DEBOUNCE0_625MS);
 	accdet_set_debounce(priv, accdet_state001,
-			    priv->data->pwm_deb->debounce1);
+			    ACCDET_DEBOUNCE1_625MS);
 	accdet_set_debounce(priv, accdet_state011,
-			    priv->data->pwm_deb->debounce3);
+			    ACCDET_DEBOUNCE3_976US);
 
 	priv->jack_type = 0;
 	priv->accdet_status = 0x3;
@@ -390,7 +409,7 @@ static void mt6359_accdet_jd_work(struct work_struct *work)
 		priv->jack_plugged = false;
 
 		accdet_set_debounce(priv, accdet_state011,
-				    priv->data->pwm_deb->debounce3);
+				    ACCDET_DEBOUNCE3_976US);
 		regmap_update_bits(priv->regmap, ACCDET_SW_EN_ADDR,
 				   ACCDET_SW_EN_MASK_SFT, 0);
 		mt6359_accdet_recover_jd_setting(priv);
@@ -497,7 +516,6 @@ static int mt6359_accdet_parse_dt(struct mt6359_accdet *priv)
 	int ret;
 	struct device *dev = priv->dev;
 	struct device_node *node = NULL;
-	int pwm_deb[15] = {0};
 	unsigned int tmp = 0;
 
 	node = of_get_child_by_name(dev->parent->of_node, "accdet");
@@ -514,12 +532,6 @@ static int mt6359_accdet_parse_dt(struct mt6359_accdet *priv)
 	if (ret)
 		priv->data->mic_mode = 2;
 
-	ret = of_property_read_u32_array(node, "mediatek,pwm-deb-setting",
-					 pwm_deb, ARRAY_SIZE(pwm_deb));
-	/* debounce8(auxadc debounce) is default, needn't get from dts */
-	if (!ret)
-		memcpy(priv->data->pwm_deb, pwm_deb, sizeof(pwm_deb));
-
 	priv->data->hp_eint_high = of_property_read_bool(node, "mediatek,hp-eint-high");
 
 	ret = of_property_read_u32(node, "mediatek,eint-detect-mode",
@@ -554,8 +566,8 @@ static void config_digital_init_by_mode(struct mt6359_accdet *priv)
 {
 	/* enable eint cmpmem pwm */
 	regmap_write(priv->regmap, ACCDET_EINT_CMPMEN_PWM_THRESH_ADDR,
-		     (priv->data->pwm_deb->eint_pwm_width << 4 |
-		     priv->data->pwm_deb->eint_pwm_thresh));
+		     (ACCDET_EINT_CMPMEN_PWM_WIDTH_400MS << 4 |
+		      ACCDET_EINT_CMPMEN_PWM_THRESH_2MS));
 	/* DA signal stable */
 	if (priv->caps & ACCDET_PMIC_EINT0) {
 		regmap_write(priv->regmap, ACCDET_DA_STABLE_ADDR,
@@ -675,22 +687,22 @@ static void mt6359_accdet_init(struct mt6359_accdet *priv)
 	mdelay(1);
 	/* init the debounce time (debounce/32768)sec */
 	accdet_set_debounce(priv, accdet_state000,
-			    priv->data->pwm_deb->debounce0);
+			    ACCDET_DEBOUNCE0_625MS);
 	accdet_set_debounce(priv, accdet_state001,
-			    priv->data->pwm_deb->debounce1);
+			    ACCDET_DEBOUNCE1_625MS);
 	accdet_set_debounce(priv, accdet_state011,
-			    priv->data->pwm_deb->debounce3);
+			    ACCDET_DEBOUNCE3_976US);
 	accdet_set_debounce(priv, accdet_auxadc,
-			    priv->data->pwm_deb->debounce4);
+			    ACCDET_DEBOUNCE_AUXADC_2MS);
 
 	accdet_set_debounce(priv, eint_state000,
-			    priv->data->pwm_deb->eint_debounce0);
+			    ACCDET_EINT_DEBOUNCE0_1MS);
 	accdet_set_debounce(priv, eint_state001,
-			    priv->data->pwm_deb->eint_debounce1);
+			    ACCDET_EINT_DEBOUNCE1_900US);
 	accdet_set_debounce(priv, eint_state011,
-			    priv->data->pwm_deb->eint_debounce3);
+			    ACCDET_EINT_DEBOUNCE3_1MS);
 	accdet_set_debounce(priv, eint_inverter_state000,
-			    priv->data->pwm_deb->eint_inverter_debounce);
+			    ACCDET_EINT_INVERTER_DEBOUNCE_256MS);
 
 	regmap_update_bits(priv->regmap, RG_ACCDET_RST_ADDR,
 			   RG_ACCDET_RST_MASK_SFT, BIT(RG_ACCDET_RST_SFT));
@@ -705,12 +717,12 @@ static void mt6359_accdet_init(struct mt6359_accdet *priv)
 
 	/* init pwm frequency, duty & rise/falling delay */
 	regmap_write(priv->regmap, ACCDET_PWM_WIDTH_ADDR,
-		     REGISTER_VAL(priv->data->pwm_deb->pwm_width));
+		     REGISTER_VAL(ACCDET_PWM_WIDTH_25_580HZ));
 	regmap_write(priv->regmap, ACCDET_PWM_THRESH_ADDR,
-		     REGISTER_VAL(priv->data->pwm_deb->pwm_thresh));
+		     REGISTER_VAL(ACCDET_PWM_THRESH_100PERCENT));
 	regmap_write(priv->regmap, ACCDET_RISE_DELAY_ADDR,
-		     (priv->data->pwm_deb->fall_delay << 15 |
-		      priv->data->pwm_deb->rise_delay));
+		     (ACCDET_FALL_DELAY << 15 |
+		      ACCDET_RISE_DELAY));
 
 	regmap_read(priv->regmap, RG_AUDPWDBMICBIAS1_ADDR, &reg);
 	if (priv->data->mic_vol <= 7) {
@@ -806,12 +818,6 @@ static int mt6359_accdet_probe(struct platform_device *pdev)
 	if (!priv->data)
 		return -ENOMEM;
 
-	priv->data->pwm_deb = devm_kzalloc(&pdev->dev,
-					   sizeof(struct pwm_deb_settings),
-					   GFP_KERNEL);
-	if (!priv->data->pwm_deb)
-		return -ENOMEM;
-
 	priv->regmap = mt6397->regmap;
 	if (IS_ERR(priv->regmap)) {
 		ret = PTR_ERR(priv->regmap);
diff --git a/sound/soc/codecs/mt6359-accdet.h b/sound/soc/codecs/mt6359-accdet.h
index 99de5037a2294b62cb8535fc45dbf4c6fafb5c7f..287201eebe0330fa170093fd6192bf5694c30469 100644
--- a/sound/soc/codecs/mt6359-accdet.h
+++ b/sound/soc/codecs/mt6359-accdet.h
@@ -50,30 +50,10 @@ enum {
 	eint_inverter_state000,
 };
 
-struct pwm_deb_settings {
-	unsigned int pwm_width;
-	unsigned int pwm_thresh;
-	unsigned int fall_delay;
-	unsigned int rise_delay;
-	unsigned int debounce0;
-	unsigned int debounce1;
-	unsigned int debounce3;
-	unsigned int debounce4;
-	unsigned int eint_pwm_width;
-	unsigned int eint_pwm_thresh;
-	unsigned int eint_debounce0;
-	unsigned int eint_debounce1;
-	unsigned int eint_debounce2;
-	unsigned int eint_debounce3;
-	unsigned int eint_inverter_debounce;
-
-};
-
 struct dts_data {
 	unsigned int mic_vol;
 	unsigned int mic_mode;
 	bool hp_eint_high;
-	struct pwm_deb_settings *pwm_deb;
 	unsigned int eint_detect_mode;
 	unsigned int eint_comp_vth;
 };

-- 
2.48.1



^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v2 14/20] ASoC: mediatek: mt6359-accdet: Always use eint detect mode 4
  2025-03-02 16:30 [PATCH v2 00/20] Get mt6359-accdet ready for usage in Devicetree Nícolas F. R. A. Prado
                   ` (12 preceding siblings ...)
  2025-03-02 16:30 ` [PATCH v2 13/20] ASoC: mediatek: mt6359-accdet: Make PWM debounce settings internal Nícolas F. R. A. Prado
@ 2025-03-02 16:30 ` Nícolas F. R. A. Prado
  2025-03-03 11:07   ` AngeloGioacchino Del Regno
  2025-03-02 16:30 ` [PATCH v2 15/20] ASoC: mediatek: mt6359-accdet: Always set micbias1 to 2.8V Nícolas F. R. A. Prado
                   ` (5 subsequent siblings)
  19 siblings, 1 reply; 44+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-03-02 16:30 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Matthias Brugger, AngeloGioacchino Del Regno,
	Sen Chu, Sean Wang, Macpaul Lin, Lee Jones, Jaroslav Kysela,
	Takashi Iwai, Catalin Marinas, Will Deacon
  Cc: kernel, linux-sound, devicetree, linux-kernel, linux-arm-kernel,
	linux-mediatek, linux-pm, Nícolas F. R. A. Prado

The driver currently reads a mediatek,eint-detect-mode property from DT,
which determines certain register configurations. Since there are no
users of the property, it doesn't directly describe the hardware, and
the default value (4) is known to work across multiple boards, remove
the handling for this property and always assume mode 4 is used. The
property can be properly introduced in the binding in the future if
different boards actually need different configurations.

Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
---
 sound/soc/codecs/mt6359-accdet.c | 208 +++++++++++++--------------------------
 sound/soc/codecs/mt6359-accdet.h |   1 -
 2 files changed, 70 insertions(+), 139 deletions(-)

diff --git a/sound/soc/codecs/mt6359-accdet.c b/sound/soc/codecs/mt6359-accdet.c
index 6728f1018c992fc9d4e4133dbaf091d256567683..83e65b6d5845dea00a8a77d68df4b7df1f62a87c 100644
--- a/sound/soc/codecs/mt6359-accdet.c
+++ b/sound/soc/codecs/mt6359-accdet.c
@@ -81,31 +81,22 @@ static void recover_eint_setting(struct mt6359_accdet *priv);
 
 static unsigned int adjust_eint_analog_setting(struct mt6359_accdet *priv)
 {
-	if (priv->data->eint_detect_mode == 0x3 ||
-	    priv->data->eint_detect_mode == 0x4) {
-		/* ESD switches off */
-		regmap_update_bits(priv->regmap,
-				   RG_ACCDETSPARE_ADDR, 1 << 8, 0);
-	}
-	if (priv->data->eint_detect_mode == 0x4) {
-		if (priv->caps & ACCDET_PMIC_EINT0) {
-			/* enable RG_EINT0CONFIGACCDET */
-			regmap_update_bits(priv->regmap,
-					   RG_EINT0CONFIGACCDET_ADDR,
-					   RG_EINT0CONFIGACCDET_MASK_SFT,
-					   BIT(RG_EINT0CONFIGACCDET_SFT));
-		} else if (priv->caps & ACCDET_PMIC_EINT1) {
-			/* enable RG_EINT1CONFIGACCDET */
-			regmap_update_bits(priv->regmap,
-					   RG_EINT1CONFIGACCDET_ADDR,
-					   RG_EINT1CONFIGACCDET_MASK_SFT,
-					   BIT(RG_EINT1CONFIGACCDET_SFT));
-		}
-		/*select 500k, use internal resistor */
-		regmap_update_bits(priv->regmap, RG_EINT0HIRENB_ADDR,
-				   RG_EINT0HIRENB_MASK_SFT,
-				   BIT(RG_EINT0HIRENB_SFT));
+	/* ESD switches off */
+	regmap_update_bits(priv->regmap, RG_ACCDETSPARE_ADDR, 1 << 8, 0);
+	if (priv->caps & ACCDET_PMIC_EINT0) {
+		/* enable RG_EINT0CONFIGACCDET */
+		regmap_update_bits(priv->regmap, RG_EINT0CONFIGACCDET_ADDR,
+				   RG_EINT0CONFIGACCDET_MASK_SFT,
+				   BIT(RG_EINT0CONFIGACCDET_SFT));
+	} else if (priv->caps & ACCDET_PMIC_EINT1) {
+		/* enable RG_EINT1CONFIGACCDET */
+		regmap_update_bits(priv->regmap, RG_EINT1CONFIGACCDET_ADDR,
+				   RG_EINT1CONFIGACCDET_MASK_SFT,
+				   BIT(RG_EINT1CONFIGACCDET_SFT));
 	}
+	/*select 500k, use internal resistor */
+	regmap_update_bits(priv->regmap, RG_EINT0HIRENB_ADDR,
+			   RG_EINT0HIRENB_MASK_SFT, BIT(RG_EINT0HIRENB_SFT));
 	return 0;
 }
 
@@ -123,18 +114,14 @@ static unsigned int adjust_eint_digital_setting(struct mt6359_accdet *priv)
 				   ACCDET_EINT1_INVERTER_SW_EN_MASK_SFT, 0);
 	}
 
-	if (priv->data->eint_detect_mode == 0x4) {
-		if (priv->caps & ACCDET_PMIC_EINT0) {
-			/* set DA stable signal */
-			regmap_update_bits(priv->regmap,
-					   ACCDET_DA_STABLE_ADDR,
-					   ACCDET_EINT0_CEN_STABLE_MASK_SFT, 0);
-		} else if (priv->caps & ACCDET_PMIC_EINT1) {
-			/* set DA stable signal */
-			regmap_update_bits(priv->regmap,
-					   ACCDET_DA_STABLE_ADDR,
-					   ACCDET_EINT1_CEN_STABLE_MASK_SFT, 0);
-		}
+	if (priv->caps & ACCDET_PMIC_EINT0) {
+		/* set DA stable signal */
+		regmap_update_bits(priv->regmap, ACCDET_DA_STABLE_ADDR,
+				   ACCDET_EINT0_CEN_STABLE_MASK_SFT, 0);
+	} else if (priv->caps & ACCDET_PMIC_EINT1) {
+		/* set DA stable signal */
+		regmap_update_bits(priv->regmap, ACCDET_DA_STABLE_ADDR,
+				   ACCDET_EINT1_CEN_STABLE_MASK_SFT, 0);
 	}
 	return 0;
 }
@@ -159,27 +146,19 @@ static unsigned int mt6359_accdet_jd_setting(struct mt6359_accdet *priv)
 
 static void recover_eint_analog_setting(struct mt6359_accdet *priv)
 {
-	if (priv->data->eint_detect_mode == 0x3 ||
-	    priv->data->eint_detect_mode == 0x4) {
-		/* ESD switches on */
-		regmap_update_bits(priv->regmap, RG_ACCDETSPARE_ADDR,
-				   1 << 8, 1 << 8);
-	}
-	if (priv->data->eint_detect_mode == 0x4) {
-		if (priv->caps & ACCDET_PMIC_EINT0) {
-			/* disable RG_EINT0CONFIGACCDET */
-			regmap_update_bits(priv->regmap,
-					   RG_EINT0CONFIGACCDET_ADDR,
-					   RG_EINT0CONFIGACCDET_MASK_SFT, 0);
-		} else if (priv->caps & ACCDET_PMIC_EINT1) {
-			/* disable RG_EINT1CONFIGACCDET */
-			regmap_update_bits(priv->regmap,
-					   RG_EINT1CONFIGACCDET_ADDR,
-					   RG_EINT1CONFIGACCDET_MASK_SFT, 0);
-		}
-		regmap_update_bits(priv->regmap, RG_EINT0HIRENB_ADDR,
-				   RG_EINT0HIRENB_MASK_SFT, 0);
+	/* ESD switches on */
+	regmap_update_bits(priv->regmap, RG_ACCDETSPARE_ADDR, 1 << 8, 1 << 8);
+	if (priv->caps & ACCDET_PMIC_EINT0) {
+		/* disable RG_EINT0CONFIGACCDET */
+		regmap_update_bits(priv->regmap, RG_EINT0CONFIGACCDET_ADDR,
+				   RG_EINT0CONFIGACCDET_MASK_SFT, 0);
+	} else if (priv->caps & ACCDET_PMIC_EINT1) {
+		/* disable RG_EINT1CONFIGACCDET */
+		regmap_update_bits(priv->regmap, RG_EINT1CONFIGACCDET_ADDR,
+				   RG_EINT1CONFIGACCDET_MASK_SFT, 0);
 	}
+	regmap_update_bits(priv->regmap, RG_EINT0HIRENB_ADDR,
+			   RG_EINT0HIRENB_MASK_SFT, 0);
 }
 
 static void recover_eint_digital_setting(struct mt6359_accdet *priv)
@@ -193,37 +172,30 @@ static void recover_eint_digital_setting(struct mt6359_accdet *priv)
 				   ACCDET_EINT1_M_SW_EN_ADDR,
 				   ACCDET_EINT1_M_SW_EN_MASK_SFT, 0);
 	}
-	if (priv->data->eint_detect_mode == 0x4) {
+	if (priv->caps & ACCDET_PMIC_EINT0) {
 		/* enable eint0cen */
-		if (priv->caps & ACCDET_PMIC_EINT0) {
-			/* enable eint0cen */
-			regmap_update_bits(priv->regmap,
-					   ACCDET_DA_STABLE_ADDR,
-					   ACCDET_EINT0_CEN_STABLE_MASK_SFT,
-					   BIT(ACCDET_EINT0_CEN_STABLE_SFT));
-		} else if (priv->caps & ACCDET_PMIC_EINT1) {
-			/* enable eint1cen */
-			regmap_update_bits(priv->regmap,
-					   ACCDET_DA_STABLE_ADDR,
-					   ACCDET_EINT1_CEN_STABLE_MASK_SFT,
-					   BIT(ACCDET_EINT1_CEN_STABLE_SFT));
-		}
+		regmap_update_bits(priv->regmap, ACCDET_DA_STABLE_ADDR,
+				   ACCDET_EINT0_CEN_STABLE_MASK_SFT,
+				   BIT(ACCDET_EINT0_CEN_STABLE_SFT));
+	} else if (priv->caps & ACCDET_PMIC_EINT1) {
+		/* enable eint1cen */
+		regmap_update_bits(priv->regmap, ACCDET_DA_STABLE_ADDR,
+				   ACCDET_EINT1_CEN_STABLE_MASK_SFT,
+				   BIT(ACCDET_EINT1_CEN_STABLE_SFT));
 	}
 
-	if (priv->data->eint_detect_mode != 0x1) {
-		if (priv->caps & ACCDET_PMIC_EINT0) {
-			/* enable inverter */
-			regmap_update_bits(priv->regmap,
-					   ACCDET_EINT0_INVERTER_SW_EN_ADDR,
-					   ACCDET_EINT0_INVERTER_SW_EN_MASK_SFT,
-					   BIT(ACCDET_EINT0_INVERTER_SW_EN_SFT));
-		} else if (priv->caps & ACCDET_PMIC_EINT1) {
-			/* enable inverter */
-			regmap_update_bits(priv->regmap,
-					   ACCDET_EINT1_INVERTER_SW_EN_ADDR,
-					   ACCDET_EINT1_INVERTER_SW_EN_MASK_SFT,
-					   BIT(ACCDET_EINT1_INVERTER_SW_EN_SFT));
-		}
+	if (priv->caps & ACCDET_PMIC_EINT0) {
+		/* enable inverter */
+		regmap_update_bits(priv->regmap,
+				   ACCDET_EINT0_INVERTER_SW_EN_ADDR,
+				   ACCDET_EINT0_INVERTER_SW_EN_MASK_SFT,
+				   BIT(ACCDET_EINT0_INVERTER_SW_EN_SFT));
+	} else if (priv->caps & ACCDET_PMIC_EINT1) {
+		/* enable inverter */
+		regmap_update_bits(priv->regmap,
+				   ACCDET_EINT1_INVERTER_SW_EN_ADDR,
+				   ACCDET_EINT1_INVERTER_SW_EN_MASK_SFT,
+				   BIT(ACCDET_EINT1_INVERTER_SW_EN_SFT));
 	}
 }
 
@@ -534,13 +506,6 @@ static int mt6359_accdet_parse_dt(struct mt6359_accdet *priv)
 
 	priv->data->hp_eint_high = of_property_read_bool(node, "mediatek,hp-eint-high");
 
-	ret = of_property_read_u32(node, "mediatek,eint-detect-mode",
-				   &priv->data->eint_detect_mode);
-	if (ret) {
-		/* eint detection mode equals to EINT HW Mode */
-		priv->data->eint_detect_mode = 0x4;
-	}
-
 	ret = of_property_read_u32(node, "mediatek,eint-num", &tmp);
 	if (ret)
 		tmp = 0;
@@ -592,31 +557,16 @@ static void config_digital_init_by_mode(struct mt6359_accdet *priv)
 	/* enable PWM */
 	regmap_write(priv->regmap, ACCDET_CMP_PWM_EN_ADDR, 0x67);
 	/* enable inverter detection */
-	if (priv->data->eint_detect_mode == 0x1) {
-		/* disable inverter detection */
-		if (priv->caps & ACCDET_PMIC_EINT0) {
-			regmap_update_bits(priv->regmap,
-					   ACCDET_EINT0_INVERTER_SW_EN_ADDR,
-					   ACCDET_EINT0_INVERTER_SW_EN_MASK_SFT,
-					   0);
-		} else if (priv->caps & ACCDET_PMIC_EINT1) {
-			regmap_update_bits(priv->regmap,
-					   ACCDET_EINT1_INVERTER_SW_EN_ADDR,
-					   ACCDET_EINT1_INVERTER_SW_EN_MASK_SFT,
-					   0);
-		}
-	} else {
-		if (priv->caps & ACCDET_PMIC_EINT0) {
-			regmap_update_bits(priv->regmap,
-					   ACCDET_EINT0_INVERTER_SW_EN_ADDR,
-					   ACCDET_EINT0_INVERTER_SW_EN_MASK_SFT,
-					   BIT(ACCDET_EINT0_INVERTER_SW_EN_SFT));
-		} else if (priv->caps & ACCDET_PMIC_EINT1) {
-			regmap_update_bits(priv->regmap,
-					   ACCDET_EINT1_INVERTER_SW_EN_ADDR,
-					   ACCDET_EINT1_INVERTER_SW_EN_MASK_SFT,
-					   BIT(ACCDET_EINT1_INVERTER_SW_EN_SFT));
-		}
+	if (priv->caps & ACCDET_PMIC_EINT0) {
+		regmap_update_bits(priv->regmap,
+				   ACCDET_EINT0_INVERTER_SW_EN_ADDR,
+				   ACCDET_EINT0_INVERTER_SW_EN_MASK_SFT,
+				   BIT(ACCDET_EINT0_INVERTER_SW_EN_SFT));
+	} else if (priv->caps & ACCDET_PMIC_EINT1) {
+		regmap_update_bits(priv->regmap,
+				   ACCDET_EINT1_INVERTER_SW_EN_ADDR,
+				   ACCDET_EINT1_INVERTER_SW_EN_MASK_SFT,
+				   BIT(ACCDET_EINT1_INVERTER_SW_EN_SFT));
 	}
 
 	if (priv->data->hp_eint_high) {
@@ -649,28 +599,10 @@ static void config_eint_init_by_mode(struct mt6359_accdet *priv)
 	regmap_update_bits(priv->regmap, RG_NCP_PDDIS_EN_ADDR,
 			   RG_NCP_PDDIS_EN_MASK_SFT, BIT(RG_NCP_PDDIS_EN_SFT));
 
-	if (priv->data->eint_detect_mode == 0x1 ||
-	    priv->data->eint_detect_mode == 0x2 ||
-	    priv->data->eint_detect_mode == 0x3) {
-		if (priv->caps & ACCDET_PMIC_EINT0) {
-			regmap_update_bits(priv->regmap,
-					   RG_EINT0CONFIGACCDET_ADDR,
-					   RG_EINT0CONFIGACCDET_MASK_SFT,
-					   BIT(RG_EINT0CONFIGACCDET_SFT));
-		} else if (priv->caps & ACCDET_PMIC_EINT1) {
-			regmap_update_bits(priv->regmap,
-					   RG_EINT1CONFIGACCDET_ADDR,
-					   RG_EINT1CONFIGACCDET_MASK_SFT,
-					   BIT(RG_EINT1CONFIGACCDET_SFT));
-		}
-	}
-
-	if (priv->data->eint_detect_mode != 0x1) {
-		/* current detect set 0.25uA */
-		regmap_update_bits(priv->regmap, RG_ACCDETSPARE_ADDR,
-				   0x3 << RG_ACCDETSPARE_SFT,
-				   0x3 << RG_ACCDETSPARE_SFT);
-	}
+	/* current detect set 0.25uA */
+	regmap_update_bits(priv->regmap, RG_ACCDETSPARE_ADDR,
+			   0x3 << RG_ACCDETSPARE_SFT,
+			   0x3 << RG_ACCDETSPARE_SFT);
 	regmap_write(priv->regmap, RG_EINTCOMPVTH_ADDR,
 		     val | priv->data->eint_comp_vth << RG_EINTCOMPVTH_SFT);
 }
diff --git a/sound/soc/codecs/mt6359-accdet.h b/sound/soc/codecs/mt6359-accdet.h
index 287201eebe0330fa170093fd6192bf5694c30469..ff5cd6ea1b06f045b6e1b9f6bc53ef80d78e3b92 100644
--- a/sound/soc/codecs/mt6359-accdet.h
+++ b/sound/soc/codecs/mt6359-accdet.h
@@ -54,7 +54,6 @@ struct dts_data {
 	unsigned int mic_vol;
 	unsigned int mic_mode;
 	bool hp_eint_high;
-	unsigned int eint_detect_mode;
 	unsigned int eint_comp_vth;
 };
 

-- 
2.48.1



^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v2 15/20] ASoC: mediatek: mt6359-accdet: Always set micbias1 to 2.8V
  2025-03-02 16:30 [PATCH v2 00/20] Get mt6359-accdet ready for usage in Devicetree Nícolas F. R. A. Prado
                   ` (13 preceding siblings ...)
  2025-03-02 16:30 ` [PATCH v2 14/20] ASoC: mediatek: mt6359-accdet: Always use eint detect mode 4 Nícolas F. R. A. Prado
@ 2025-03-02 16:30 ` Nícolas F. R. A. Prado
  2025-03-03 11:06   ` AngeloGioacchino Del Regno
  2025-03-02 16:30 ` [PATCH v2 16/20] ASoC: mediatek: mt6359-accdet: Always configure hardware as mic-mode 2 Nícolas F. R. A. Prado
                   ` (4 subsequent siblings)
  19 siblings, 1 reply; 44+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-03-02 16:30 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Matthias Brugger, AngeloGioacchino Del Regno,
	Sen Chu, Sean Wang, Macpaul Lin, Lee Jones, Jaroslav Kysela,
	Takashi Iwai, Catalin Marinas, Will Deacon
  Cc: kernel, linux-sound, devicetree, linux-kernel, linux-arm-kernel,
	linux-mediatek, linux-pm, Nícolas F. R. A. Prado

The driver currently reads a mediatek,mic-vol property from DT to
determine the micbias1 setting to configure in hardware. Since there are
no current users of the property and the default value (2.8V) is known
to work on multiple boards, remove the code handling this property and
instead always configure the micbias1 to 2.8V. The property can be
properly introduced in the binding in the future if it really turns out
that different boards need different configurations.

Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
---
 sound/soc/codecs/mt6359-accdet.c | 23 +++--------------------
 sound/soc/codecs/mt6359-accdet.h |  1 -
 2 files changed, 3 insertions(+), 21 deletions(-)

diff --git a/sound/soc/codecs/mt6359-accdet.c b/sound/soc/codecs/mt6359-accdet.c
index 83e65b6d5845dea00a8a77d68df4b7df1f62a87c..a31e084560c7643b14fb71871699e3167075d9d9 100644
--- a/sound/soc/codecs/mt6359-accdet.c
+++ b/sound/soc/codecs/mt6359-accdet.c
@@ -494,11 +494,6 @@ static int mt6359_accdet_parse_dt(struct mt6359_accdet *priv)
 	if (!node)
 		return -EINVAL;
 
-	ret = of_property_read_u32(node, "mediatek,mic-vol",
-				   &priv->data->mic_vol);
-	if (ret)
-		priv->data->mic_vol = 8;
-
 	ret = of_property_read_u32(node, "mediatek,mic-mode",
 				   &priv->data->mic_mode);
 	if (ret)
@@ -657,22 +652,10 @@ static void mt6359_accdet_init(struct mt6359_accdet *priv)
 		      ACCDET_RISE_DELAY));
 
 	regmap_read(priv->regmap, RG_AUDPWDBMICBIAS1_ADDR, &reg);
-	if (priv->data->mic_vol <= 7) {
-		/* micbias1 <= 2.7V */
-		regmap_write(priv->regmap, RG_AUDPWDBMICBIAS1_ADDR,
-			     reg | (priv->data->mic_vol << RG_AUDMICBIAS1VREF_SFT) |
-			     RG_AUDMICBIAS1LOWPEN_MASK_SFT);
-	} else if (priv->data->mic_vol == 8) {
-		/* micbias1 = 2.8v */
-		regmap_write(priv->regmap, RG_AUDPWDBMICBIAS1_ADDR,
-			     reg | (3 << RG_AUDMICBIAS1HVEN_SFT) |
+	/* micbias1 = 2.8v */
+	regmap_write(priv->regmap, RG_AUDPWDBMICBIAS1_ADDR,
+		     reg | (3 << RG_AUDMICBIAS1HVEN_SFT) |
 			     RG_AUDMICBIAS1LOWPEN_MASK_SFT);
-	} else if (priv->data->mic_vol == 9) {
-		/* micbias1 = 2.85v */
-		regmap_write(priv->regmap, RG_AUDPWDBMICBIAS1_ADDR,
-			     reg | (1 << RG_AUDMICBIAS1HVEN_SFT) |
-			     RG_AUDMICBIAS1LOWPEN_MASK_SFT);
-	}
 	/* mic mode setting */
 	regmap_read(priv->regmap, RG_AUDACCDETMICBIAS0PULLLOW_ADDR, &reg);
 	if (priv->data->mic_mode == HEADSET_MODE_1) {
diff --git a/sound/soc/codecs/mt6359-accdet.h b/sound/soc/codecs/mt6359-accdet.h
index ff5cd6ea1b06f045b6e1b9f6bc53ef80d78e3b92..46dcd4759230a5190434b9b7c785e8b9ed12fd3d 100644
--- a/sound/soc/codecs/mt6359-accdet.h
+++ b/sound/soc/codecs/mt6359-accdet.h
@@ -51,7 +51,6 @@ enum {
 };
 
 struct dts_data {
-	unsigned int mic_vol;
 	unsigned int mic_mode;
 	bool hp_eint_high;
 	unsigned int eint_comp_vth;

-- 
2.48.1



^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v2 16/20] ASoC: mediatek: mt6359-accdet: Always configure hardware as mic-mode 2
  2025-03-02 16:30 [PATCH v2 00/20] Get mt6359-accdet ready for usage in Devicetree Nícolas F. R. A. Prado
                   ` (14 preceding siblings ...)
  2025-03-02 16:30 ` [PATCH v2 15/20] ASoC: mediatek: mt6359-accdet: Always set micbias1 to 2.8V Nícolas F. R. A. Prado
@ 2025-03-02 16:30 ` Nícolas F. R. A. Prado
  2025-03-03 11:06   ` AngeloGioacchino Del Regno
  2025-03-02 16:30 ` [PATCH v2 17/20] ASoC: mediatek: mt6359-accdet: Always set comp-vth to 1.6V Nícolas F. R. A. Prado
                   ` (3 subsequent siblings)
  19 siblings, 1 reply; 44+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-03-02 16:30 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Matthias Brugger, AngeloGioacchino Del Regno,
	Sen Chu, Sean Wang, Macpaul Lin, Lee Jones, Jaroslav Kysela,
	Takashi Iwai, Catalin Marinas, Will Deacon
  Cc: kernel, linux-sound, devicetree, linux-kernel, linux-arm-kernel,
	linux-mediatek, linux-pm, Nícolas F. R. A. Prado

The driver currently reads a mediatek,mic-mode property from DT to
determine certain register configurations. Since there are no current
users of the property, the property doesn't directly reflect the
hardware  and the default value (2) is known to work on
multiple boards, remove the code handling this property and instead
always configure the hardware according to the known to work default.
This property can be properly introduced in the binding in the future
if it really turns out that different boards need different
configurations.

Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
---
 sound/soc/codecs/mt6359-accdet.c | 43 ++++++----------------------------------
 sound/soc/codecs/mt6359-accdet.h |  5 -----
 2 files changed, 6 insertions(+), 42 deletions(-)

diff --git a/sound/soc/codecs/mt6359-accdet.c b/sound/soc/codecs/mt6359-accdet.c
index a31e084560c7643b14fb71871699e3167075d9d9..12697b02faff1be39317116cd7d8ffa359f2cd4e 100644
--- a/sound/soc/codecs/mt6359-accdet.c
+++ b/sound/soc/codecs/mt6359-accdet.c
@@ -494,11 +494,6 @@ static int mt6359_accdet_parse_dt(struct mt6359_accdet *priv)
 	if (!node)
 		return -EINVAL;
 
-	ret = of_property_read_u32(node, "mediatek,mic-mode",
-				   &priv->data->mic_mode);
-	if (ret)
-		priv->data->mic_mode = 2;
-
 	priv->data->hp_eint_high = of_property_read_bool(node, "mediatek,hp-eint-high");
 
 	ret = of_property_read_u32(node, "mediatek,eint-num", &tmp);
@@ -658,38 +653,12 @@ static void mt6359_accdet_init(struct mt6359_accdet *priv)
 			     RG_AUDMICBIAS1LOWPEN_MASK_SFT);
 	/* mic mode setting */
 	regmap_read(priv->regmap, RG_AUDACCDETMICBIAS0PULLLOW_ADDR, &reg);
-	if (priv->data->mic_mode == HEADSET_MODE_1) {
-		/* ACC mode*/
-		regmap_write(priv->regmap, RG_AUDACCDETMICBIAS0PULLLOW_ADDR,
-			     reg | RG_ACCDET_MODE_ANA11_MODE1);
-		/* enable analog fast discharge */
-		regmap_update_bits(priv->regmap, RG_ANALOGFDEN_ADDR,
-				   RG_ANALOGFDEN_MASK_SFT,
-				   BIT(RG_ANALOGFDEN_SFT));
-		regmap_update_bits(priv->regmap, RG_ACCDETSPARE_ADDR,
-				   0x3 << 11, 0x3 << 11);
-	} else if (priv->data->mic_mode == HEADSET_MODE_2) {
-		/* DCC mode Low cost mode without internal bias */
-		regmap_write(priv->regmap, RG_AUDACCDETMICBIAS0PULLLOW_ADDR,
-			     reg | RG_ACCDET_MODE_ANA11_MODE2);
-		/* enable analog fast discharge */
-		regmap_update_bits(priv->regmap, RG_ANALOGFDEN_ADDR,
-				   0x3 << RG_ANALOGFDEN_SFT,
-				   0x3 << RG_ANALOGFDEN_SFT);
-	} else if (priv->data->mic_mode == HEADSET_MODE_6) {
-		/* DCC mode Low cost mode with internal bias,
-		 * bit8 = 1 to use internal bias
-		 */
-		regmap_write(priv->regmap, RG_AUDACCDETMICBIAS0PULLLOW_ADDR,
-			     reg | RG_ACCDET_MODE_ANA11_MODE6);
-		regmap_update_bits(priv->regmap, RG_AUDPWDBMICBIAS1_ADDR,
-				   RG_AUDMICBIAS1DCSW1PEN_MASK_SFT,
-				   BIT(RG_AUDMICBIAS1DCSW1PEN_SFT));
-		/* enable analog fast discharge */
-		regmap_update_bits(priv->regmap, RG_ANALOGFDEN_ADDR,
-				   0x3 << RG_ANALOGFDEN_SFT,
-				   0x3 << RG_ANALOGFDEN_SFT);
-	}
+	/* DCC mode Low cost mode without internal bias */
+	regmap_write(priv->regmap, RG_AUDACCDETMICBIAS0PULLLOW_ADDR,
+		     reg | RG_ACCDET_MODE_ANA11_MODE2);
+	/* enable analog fast discharge */
+	regmap_update_bits(priv->regmap, RG_ANALOGFDEN_ADDR,
+			   0x3 << RG_ANALOGFDEN_SFT, 0x3 << RG_ANALOGFDEN_SFT);
 
 	config_eint_init_by_mode(priv);
 	config_digital_init_by_mode(priv);
diff --git a/sound/soc/codecs/mt6359-accdet.h b/sound/soc/codecs/mt6359-accdet.h
index 46dcd4759230a5190434b9b7c785e8b9ed12fd3d..579373807c414130b2a7384db4978e01cf1d046c 100644
--- a/sound/soc/codecs/mt6359-accdet.h
+++ b/sound/soc/codecs/mt6359-accdet.h
@@ -12,10 +12,6 @@
 
 #define ACCDET_DEVNAME "accdet"
 
-#define HEADSET_MODE_1		(1)
-#define HEADSET_MODE_2		(2)
-#define HEADSET_MODE_6		(6)
-
 #define MT6359_ACCDET_NUM_BUTTONS 4
 #define MT6359_ACCDET_JACK_MASK (SND_JACK_HEADPHONE | \
 				SND_JACK_HEADSET | \
@@ -51,7 +47,6 @@ enum {
 };
 
 struct dts_data {
-	unsigned int mic_mode;
 	bool hp_eint_high;
 	unsigned int eint_comp_vth;
 };

-- 
2.48.1



^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v2 17/20] ASoC: mediatek: mt6359-accdet: Always set comp-vth to 1.6V
  2025-03-02 16:30 [PATCH v2 00/20] Get mt6359-accdet ready for usage in Devicetree Nícolas F. R. A. Prado
                   ` (15 preceding siblings ...)
  2025-03-02 16:30 ` [PATCH v2 16/20] ASoC: mediatek: mt6359-accdet: Always configure hardware as mic-mode 2 Nícolas F. R. A. Prado
@ 2025-03-02 16:30 ` Nícolas F. R. A. Prado
  2025-03-03 11:06   ` AngeloGioacchino Del Regno
  2025-03-02 16:30 ` [PATCH v2 18/20] ASoC: mediatek: mt6359-accdet: Always use EINT0 IRQ Nícolas F. R. A. Prado
                   ` (2 subsequent siblings)
  19 siblings, 1 reply; 44+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-03-02 16:30 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Matthias Brugger, AngeloGioacchino Del Regno,
	Sen Chu, Sean Wang, Macpaul Lin, Lee Jones, Jaroslav Kysela,
	Takashi Iwai, Catalin Marinas, Will Deacon
  Cc: kernel, linux-sound, devicetree, linux-kernel, linux-arm-kernel,
	linux-mediatek, linux-pm, Nícolas F. R. A. Prado

The driver currently reads a mediatek,eint-comp-vth property from DT to
determine the voltage threshold of the EINT comparator. Since there are
no current users of the property and setting it to 1.6V is known to work
across multiple boards, remove the code handling this property and
instead always configure it to 1.6V. The property can be properly
introduced in the binding in the future if it really turns out that
different boards need different configurations.

Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
---
 sound/soc/codecs/mt6359-accdet.c | 8 ++------
 sound/soc/codecs/mt6359-accdet.h | 1 -
 2 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/sound/soc/codecs/mt6359-accdet.c b/sound/soc/codecs/mt6359-accdet.c
index 12697b02faff1be39317116cd7d8ffa359f2cd4e..3f6a97e8de8d174e59e512d53135fadc5765b5c1 100644
--- a/sound/soc/codecs/mt6359-accdet.c
+++ b/sound/soc/codecs/mt6359-accdet.c
@@ -61,6 +61,7 @@
 #define ACCDET_EINT_INVERTER_DEBOUNCE_256MS 0xe
 #define ACCDET_EINT_CMPMEN_PWM_WIDTH_400MS 4
 #define ACCDET_EINT_CMPMEN_PWM_THRESH_2MS 1
+#define ACCDET_EINT_COMP_VTH_1600MV 2
 
 static struct platform_driver mt6359_accdet_driver;
 static const struct snd_soc_component_driver mt6359_accdet_soc_driver;
@@ -506,11 +507,6 @@ static int mt6359_accdet_parse_dt(struct mt6359_accdet *priv)
 	else if (tmp == 2)
 		priv->caps |= ACCDET_PMIC_BI_EINT;
 
-	ret = of_property_read_u32(node, "mediatek,eint-comp-vth",
-				   &priv->data->eint_comp_vth);
-	if (ret)
-		priv->data->eint_comp_vth = 0x0;
-
 	of_node_put(node);
 	dev_warn(priv->dev, "accdet caps=%x\n", priv->caps);
 
@@ -594,7 +590,7 @@ static void config_eint_init_by_mode(struct mt6359_accdet *priv)
 			   0x3 << RG_ACCDETSPARE_SFT,
 			   0x3 << RG_ACCDETSPARE_SFT);
 	regmap_write(priv->regmap, RG_EINTCOMPVTH_ADDR,
-		     val | priv->data->eint_comp_vth << RG_EINTCOMPVTH_SFT);
+		     val | ACCDET_EINT_COMP_VTH_1600MV << RG_EINTCOMPVTH_SFT);
 }
 
 static void mt6359_accdet_init(struct mt6359_accdet *priv)
diff --git a/sound/soc/codecs/mt6359-accdet.h b/sound/soc/codecs/mt6359-accdet.h
index 579373807c414130b2a7384db4978e01cf1d046c..288b8fbf7c5efaee6520a2c0a5845e156f3b805d 100644
--- a/sound/soc/codecs/mt6359-accdet.h
+++ b/sound/soc/codecs/mt6359-accdet.h
@@ -48,7 +48,6 @@ enum {
 
 struct dts_data {
 	bool hp_eint_high;
-	unsigned int eint_comp_vth;
 };
 
 struct mt6359_accdet {

-- 
2.48.1



^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v2 18/20] ASoC: mediatek: mt6359-accdet: Always use EINT0 IRQ
  2025-03-02 16:30 [PATCH v2 00/20] Get mt6359-accdet ready for usage in Devicetree Nícolas F. R. A. Prado
                   ` (16 preceding siblings ...)
  2025-03-02 16:30 ` [PATCH v2 17/20] ASoC: mediatek: mt6359-accdet: Always set comp-vth to 1.6V Nícolas F. R. A. Prado
@ 2025-03-02 16:30 ` Nícolas F. R. A. Prado
  2025-03-03 11:08   ` AngeloGioacchino Del Regno
  2025-03-02 16:30 ` [PATCH v2 19/20] arm64: dts: mt6359: Add accessory detect node Nícolas F. R. A. Prado
  2025-03-02 16:30 ` [PATCH v2 20/20] arm64: defconfig: Enable MT6359 ACCDET Nícolas F. R. A. Prado
  19 siblings, 1 reply; 44+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-03-02 16:30 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Matthias Brugger, AngeloGioacchino Del Regno,
	Sen Chu, Sean Wang, Macpaul Lin, Lee Jones, Jaroslav Kysela,
	Takashi Iwai, Catalin Marinas, Will Deacon
  Cc: kernel, linux-sound, devicetree, linux-kernel, linux-arm-kernel,
	linux-mediatek, linux-pm, Nícolas F. R. A. Prado

The ACCDET block can generate two distinct EINT interrupts: EINT0 and
EINT1, and which is enabled is currently determined by mediatek,eint-num
property in DT. However, only EINT0 is used on the boards that are
known to have working ACCDET. Since there are no current users of the
property, remove its handling and instead always enable EINT0. The
property can be properly introduced in the binding in the future if it
really turns out that other boards require EINT1.

Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
---
 sound/soc/codecs/mt6359-accdet.c | 187 +++++++++------------------------------
 sound/soc/codecs/mt6359-accdet.h |   1 -
 2 files changed, 43 insertions(+), 145 deletions(-)

diff --git a/sound/soc/codecs/mt6359-accdet.c b/sound/soc/codecs/mt6359-accdet.c
index 3f6a97e8de8d174e59e512d53135fadc5765b5c1..b1e63f3f7fa44687b1cac47c0e33f68a28e15a47 100644
--- a/sound/soc/codecs/mt6359-accdet.c
+++ b/sound/soc/codecs/mt6359-accdet.c
@@ -31,10 +31,6 @@
 #define REGISTER_VAL(x)	((x) - 1)
 
 /* mt6359 accdet capability */
-#define ACCDET_PMIC_EINT0		BIT(2)
-#define ACCDET_PMIC_EINT1		BIT(3)
-#define ACCDET_PMIC_BI_EINT		BIT(4)
-
 #define ACCDET_PMIC_RSV_EINT		BIT(7)
 
 #define ACCDET_RSV_KEY			BIT(11)
@@ -84,17 +80,10 @@ static unsigned int adjust_eint_analog_setting(struct mt6359_accdet *priv)
 {
 	/* ESD switches off */
 	regmap_update_bits(priv->regmap, RG_ACCDETSPARE_ADDR, 1 << 8, 0);
-	if (priv->caps & ACCDET_PMIC_EINT0) {
-		/* enable RG_EINT0CONFIGACCDET */
-		regmap_update_bits(priv->regmap, RG_EINT0CONFIGACCDET_ADDR,
-				   RG_EINT0CONFIGACCDET_MASK_SFT,
-				   BIT(RG_EINT0CONFIGACCDET_SFT));
-	} else if (priv->caps & ACCDET_PMIC_EINT1) {
-		/* enable RG_EINT1CONFIGACCDET */
-		regmap_update_bits(priv->regmap, RG_EINT1CONFIGACCDET_ADDR,
-				   RG_EINT1CONFIGACCDET_MASK_SFT,
-				   BIT(RG_EINT1CONFIGACCDET_SFT));
-	}
+	/* enable RG_EINT0CONFIGACCDET */
+	regmap_update_bits(priv->regmap, RG_EINT0CONFIGACCDET_ADDR,
+			   RG_EINT0CONFIGACCDET_MASK_SFT,
+			   BIT(RG_EINT0CONFIGACCDET_SFT));
 	/*select 500k, use internal resistor */
 	regmap_update_bits(priv->regmap, RG_EINT0HIRENB_ADDR,
 			   RG_EINT0HIRENB_MASK_SFT, BIT(RG_EINT0HIRENB_SFT));
@@ -103,27 +92,13 @@ static unsigned int adjust_eint_analog_setting(struct mt6359_accdet *priv)
 
 static unsigned int adjust_eint_digital_setting(struct mt6359_accdet *priv)
 {
-	if (priv->caps & ACCDET_PMIC_EINT0) {
-		/* disable inverter */
-		regmap_update_bits(priv->regmap,
-				   ACCDET_EINT0_INVERTER_SW_EN_ADDR,
-				   ACCDET_EINT0_INVERTER_SW_EN_MASK_SFT, 0);
-	} else if (priv->caps & ACCDET_PMIC_EINT1) {
-		/* disable inverter */
-		regmap_update_bits(priv->regmap,
-				   ACCDET_EINT1_INVERTER_SW_EN_ADDR,
-				   ACCDET_EINT1_INVERTER_SW_EN_MASK_SFT, 0);
-	}
+	/* disable inverter */
+	regmap_update_bits(priv->regmap, ACCDET_EINT0_INVERTER_SW_EN_ADDR,
+			   ACCDET_EINT0_INVERTER_SW_EN_MASK_SFT, 0);
 
-	if (priv->caps & ACCDET_PMIC_EINT0) {
-		/* set DA stable signal */
-		regmap_update_bits(priv->regmap, ACCDET_DA_STABLE_ADDR,
-				   ACCDET_EINT0_CEN_STABLE_MASK_SFT, 0);
-	} else if (priv->caps & ACCDET_PMIC_EINT1) {
-		/* set DA stable signal */
-		regmap_update_bits(priv->regmap, ACCDET_DA_STABLE_ADDR,
-				   ACCDET_EINT1_CEN_STABLE_MASK_SFT, 0);
-	}
+	/* set DA stable signal */
+	regmap_update_bits(priv->regmap, ACCDET_DA_STABLE_ADDR,
+			   ACCDET_EINT0_CEN_STABLE_MASK_SFT, 0);
 	return 0;
 }
 
@@ -149,55 +124,26 @@ static void recover_eint_analog_setting(struct mt6359_accdet *priv)
 {
 	/* ESD switches on */
 	regmap_update_bits(priv->regmap, RG_ACCDETSPARE_ADDR, 1 << 8, 1 << 8);
-	if (priv->caps & ACCDET_PMIC_EINT0) {
-		/* disable RG_EINT0CONFIGACCDET */
-		regmap_update_bits(priv->regmap, RG_EINT0CONFIGACCDET_ADDR,
-				   RG_EINT0CONFIGACCDET_MASK_SFT, 0);
-	} else if (priv->caps & ACCDET_PMIC_EINT1) {
-		/* disable RG_EINT1CONFIGACCDET */
-		regmap_update_bits(priv->regmap, RG_EINT1CONFIGACCDET_ADDR,
-				   RG_EINT1CONFIGACCDET_MASK_SFT, 0);
-	}
+	/* disable RG_EINT0CONFIGACCDET */
+	regmap_update_bits(priv->regmap, RG_EINT0CONFIGACCDET_ADDR,
+			   RG_EINT0CONFIGACCDET_MASK_SFT, 0);
 	regmap_update_bits(priv->regmap, RG_EINT0HIRENB_ADDR,
 			   RG_EINT0HIRENB_MASK_SFT, 0);
 }
 
 static void recover_eint_digital_setting(struct mt6359_accdet *priv)
 {
-	if (priv->caps & ACCDET_PMIC_EINT0) {
-		regmap_update_bits(priv->regmap,
-				   ACCDET_EINT0_M_SW_EN_ADDR,
-				   ACCDET_EINT0_M_SW_EN_MASK_SFT, 0);
-	} else if (priv->caps & ACCDET_PMIC_EINT1) {
-		regmap_update_bits(priv->regmap,
-				   ACCDET_EINT1_M_SW_EN_ADDR,
-				   ACCDET_EINT1_M_SW_EN_MASK_SFT, 0);
-	}
-	if (priv->caps & ACCDET_PMIC_EINT0) {
-		/* enable eint0cen */
-		regmap_update_bits(priv->regmap, ACCDET_DA_STABLE_ADDR,
-				   ACCDET_EINT0_CEN_STABLE_MASK_SFT,
-				   BIT(ACCDET_EINT0_CEN_STABLE_SFT));
-	} else if (priv->caps & ACCDET_PMIC_EINT1) {
-		/* enable eint1cen */
-		regmap_update_bits(priv->regmap, ACCDET_DA_STABLE_ADDR,
-				   ACCDET_EINT1_CEN_STABLE_MASK_SFT,
-				   BIT(ACCDET_EINT1_CEN_STABLE_SFT));
-	}
-
-	if (priv->caps & ACCDET_PMIC_EINT0) {
-		/* enable inverter */
-		regmap_update_bits(priv->regmap,
-				   ACCDET_EINT0_INVERTER_SW_EN_ADDR,
-				   ACCDET_EINT0_INVERTER_SW_EN_MASK_SFT,
-				   BIT(ACCDET_EINT0_INVERTER_SW_EN_SFT));
-	} else if (priv->caps & ACCDET_PMIC_EINT1) {
-		/* enable inverter */
-		regmap_update_bits(priv->regmap,
-				   ACCDET_EINT1_INVERTER_SW_EN_ADDR,
-				   ACCDET_EINT1_INVERTER_SW_EN_MASK_SFT,
-				   BIT(ACCDET_EINT1_INVERTER_SW_EN_SFT));
-	}
+	regmap_update_bits(priv->regmap, ACCDET_EINT0_M_SW_EN_ADDR,
+			   ACCDET_EINT0_M_SW_EN_MASK_SFT, 0);
+	/* enable eint0cen */
+	regmap_update_bits(priv->regmap, ACCDET_DA_STABLE_ADDR,
+			   ACCDET_EINT0_CEN_STABLE_MASK_SFT,
+			   BIT(ACCDET_EINT0_CEN_STABLE_SFT));
+
+	/* enable inverter */
+	regmap_update_bits(priv->regmap, ACCDET_EINT0_INVERTER_SW_EN_ADDR,
+			   ACCDET_EINT0_INVERTER_SW_EN_MASK_SFT,
+			   BIT(ACCDET_EINT0_INVERTER_SW_EN_SFT));
 }
 
 static void recover_eint_setting(struct mt6359_accdet *priv)
@@ -486,10 +432,8 @@ static irqreturn_t mt6359_accdet_irq(int irq, void *data)
 
 static int mt6359_accdet_parse_dt(struct mt6359_accdet *priv)
 {
-	int ret;
 	struct device *dev = priv->dev;
 	struct device_node *node = NULL;
-	unsigned int tmp = 0;
 
 	node = of_get_child_by_name(dev->parent->of_node, "accdet");
 	if (!node)
@@ -497,16 +441,6 @@ static int mt6359_accdet_parse_dt(struct mt6359_accdet *priv)
 
 	priv->data->hp_eint_high = of_property_read_bool(node, "mediatek,hp-eint-high");
 
-	ret = of_property_read_u32(node, "mediatek,eint-num", &tmp);
-	if (ret)
-		tmp = 0;
-	if (tmp == 0)
-		priv->caps |= ACCDET_PMIC_EINT0;
-	else if (tmp == 1)
-		priv->caps |= ACCDET_PMIC_EINT1;
-	else if (tmp == 2)
-		priv->caps |= ACCDET_PMIC_BI_EINT;
-
 	of_node_put(node);
 	dev_warn(priv->dev, "accdet caps=%x\n", priv->caps);
 
@@ -520,13 +454,8 @@ static void config_digital_init_by_mode(struct mt6359_accdet *priv)
 		     (ACCDET_EINT_CMPMEN_PWM_WIDTH_400MS << 4 |
 		      ACCDET_EINT_CMPMEN_PWM_THRESH_2MS));
 	/* DA signal stable */
-	if (priv->caps & ACCDET_PMIC_EINT0) {
-		regmap_write(priv->regmap, ACCDET_DA_STABLE_ADDR,
-			     ACCDET_EINT0_STABLE_VAL);
-	} else if (priv->caps & ACCDET_PMIC_EINT1) {
-		regmap_write(priv->regmap, ACCDET_DA_STABLE_ADDR,
-			     ACCDET_EINT1_STABLE_VAL);
-	}
+	regmap_write(priv->regmap, ACCDET_DA_STABLE_ADDR,
+		     ACCDET_EINT0_STABLE_VAL);
 	/* after receive n+1 number, interrupt issued. */
 	regmap_update_bits(priv->regmap, ACCDET_EINT_M_PLUG_IN_NUM_ADDR,
 			   ACCDET_EINT_M_PLUG_IN_NUM_MASK_SFT,
@@ -543,17 +472,9 @@ static void config_digital_init_by_mode(struct mt6359_accdet *priv)
 	/* enable PWM */
 	regmap_write(priv->regmap, ACCDET_CMP_PWM_EN_ADDR, 0x67);
 	/* enable inverter detection */
-	if (priv->caps & ACCDET_PMIC_EINT0) {
-		regmap_update_bits(priv->regmap,
-				   ACCDET_EINT0_INVERTER_SW_EN_ADDR,
-				   ACCDET_EINT0_INVERTER_SW_EN_MASK_SFT,
-				   BIT(ACCDET_EINT0_INVERTER_SW_EN_SFT));
-	} else if (priv->caps & ACCDET_PMIC_EINT1) {
-		regmap_update_bits(priv->regmap,
-				   ACCDET_EINT1_INVERTER_SW_EN_ADDR,
-				   ACCDET_EINT1_INVERTER_SW_EN_MASK_SFT,
-				   BIT(ACCDET_EINT1_INVERTER_SW_EN_SFT));
-	}
+	regmap_update_bits(priv->regmap, ACCDET_EINT0_INVERTER_SW_EN_ADDR,
+			   ACCDET_EINT0_INVERTER_SW_EN_MASK_SFT,
+			   BIT(ACCDET_EINT0_INVERTER_SW_EN_SFT));
 
 	if (priv->data->hp_eint_high) {
 		/* EINT polarity inverse */
@@ -571,13 +492,8 @@ static void config_eint_init_by_mode(struct mt6359_accdet *priv)
 {
 	unsigned int val = 0;
 
-	if (priv->caps & ACCDET_PMIC_EINT0) {
-		regmap_update_bits(priv->regmap, RG_EINT0EN_ADDR,
-				   RG_EINT0EN_MASK_SFT, BIT(RG_EINT0EN_SFT));
-	} else if (priv->caps & ACCDET_PMIC_EINT1) {
-		regmap_update_bits(priv->regmap, RG_EINT1EN_ADDR,
-				   RG_EINT1EN_MASK_SFT, BIT(RG_EINT1EN_SFT));
-	}
+	regmap_update_bits(priv->regmap, RG_EINT0EN_ADDR, RG_EINT0EN_MASK_SFT,
+			   BIT(RG_EINT0EN_SFT));
 	/* ESD switches on */
 	regmap_update_bits(priv->regmap, RG_ACCDETSPARE_ADDR,
 			   1 << 8, 1 << 8);
@@ -727,35 +643,18 @@ static int mt6359_accdet_probe(struct platform_device *pdev)
 		}
 	}
 
-	if (priv->caps & ACCDET_PMIC_EINT0) {
-		priv->accdet_eint0 = platform_get_irq(pdev, 1);
-		if (priv->accdet_eint0 >= 0) {
-			ret = devm_request_threaded_irq(&pdev->dev,
-							priv->accdet_eint0,
-							NULL, mt6359_accdet_irq,
-							IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
-							"ACCDET_EINT0", priv);
-			if (ret) {
-				dev_err(&pdev->dev,
-					"Failed to request eint0 IRQ (%d)\n",
-					ret);
-				return ret;
-			}
-		}
-	} else if (priv->caps & ACCDET_PMIC_EINT1) {
-		priv->accdet_eint1 = platform_get_irq(pdev, 2);
-		if (priv->accdet_eint1 >= 0) {
-			ret = devm_request_threaded_irq(&pdev->dev,
-							priv->accdet_eint1,
-							NULL, mt6359_accdet_irq,
-							IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
-							"ACCDET_EINT1", priv);
-			if (ret) {
-				dev_err(&pdev->dev,
-					"Failed to request eint1 IRQ (%d)\n",
-					ret);
-				return ret;
-			}
+	priv->accdet_eint0 = platform_get_irq(pdev, 1);
+	if (priv->accdet_eint0 >= 0) {
+		ret = devm_request_threaded_irq(&pdev->dev,
+						priv->accdet_eint0,
+						NULL, mt6359_accdet_irq,
+						IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
+						"ACCDET_EINT0", priv);
+		if (ret) {
+			dev_err(&pdev->dev,
+				"Failed to request eint0 IRQ (%d)\n",
+				ret);
+			return ret;
 		}
 	}
 
diff --git a/sound/soc/codecs/mt6359-accdet.h b/sound/soc/codecs/mt6359-accdet.h
index 288b8fbf7c5efaee6520a2c0a5845e156f3b805d..4156cbc7f0a1744226d5f28746bd13fec6c615b4 100644
--- a/sound/soc/codecs/mt6359-accdet.h
+++ b/sound/soc/codecs/mt6359-accdet.h
@@ -58,7 +58,6 @@ struct mt6359_accdet {
 	unsigned int caps;
 	int accdet_irq;
 	int accdet_eint0;
-	int accdet_eint1;
 	struct mutex res_lock; /* lock protection */
 	bool jack_plugged;
 	unsigned int jack_type;

-- 
2.48.1



^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v2 19/20] arm64: dts: mt6359: Add accessory detect node
  2025-03-02 16:30 [PATCH v2 00/20] Get mt6359-accdet ready for usage in Devicetree Nícolas F. R. A. Prado
                   ` (17 preceding siblings ...)
  2025-03-02 16:30 ` [PATCH v2 18/20] ASoC: mediatek: mt6359-accdet: Always use EINT0 IRQ Nícolas F. R. A. Prado
@ 2025-03-02 16:30 ` Nícolas F. R. A. Prado
  2025-03-03  2:30   ` Macpaul Lin (林智斌)
  2025-03-03 11:09   ` AngeloGioacchino Del Regno
  2025-03-02 16:30 ` [PATCH v2 20/20] arm64: defconfig: Enable MT6359 ACCDET Nícolas F. R. A. Prado
  19 siblings, 2 replies; 44+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-03-02 16:30 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Matthias Brugger, AngeloGioacchino Del Regno,
	Sen Chu, Sean Wang, Macpaul Lin, Lee Jones, Jaroslav Kysela,
	Takashi Iwai, Catalin Marinas, Will Deacon
  Cc: kernel, linux-sound, devicetree, linux-kernel, linux-arm-kernel,
	linux-mediatek, linux-pm, Nícolas F. R. A. Prado,
	Andrew Perepech

Add audio jack detection node. PMIC accessory detect driver will
create an input device that will send key events on jack
insertion/removal or accessory device key presses.

Co-developed-by: Andrew Perepech <andrew.perepech@mediatek.com>
Signed-off-by: Andrew Perepech <andrew.perepech@mediatek.com>
Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
---
 arch/arm64/boot/dts/mediatek/mt6359.dtsi | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt6359.dtsi b/arch/arm64/boot/dts/mediatek/mt6359.dtsi
index 7b10f9c59819a9ad02319f00938f35c931091f9f..e24e4aeb3b9cafa2af56c62bc4c549df27d0ec73 100644
--- a/arch/arm64/boot/dts/mediatek/mt6359.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt6359.dtsi
@@ -15,6 +15,10 @@ pmic_adc: adc {
 			#io-channel-cells = <1>;
 		};
 
+		accdet: accdet {
+			compatible = "mediatek,mt6359-accdet";
+		};
+
 		mt6359codec: audio-codec {
 			compatible = "mediatek,mt6359-codec";
 		};

-- 
2.48.1



^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v2 20/20] arm64: defconfig: Enable MT6359 ACCDET
  2025-03-02 16:30 [PATCH v2 00/20] Get mt6359-accdet ready for usage in Devicetree Nícolas F. R. A. Prado
                   ` (18 preceding siblings ...)
  2025-03-02 16:30 ` [PATCH v2 19/20] arm64: dts: mt6359: Add accessory detect node Nícolas F. R. A. Prado
@ 2025-03-02 16:30 ` Nícolas F. R. A. Prado
  2025-03-03 11:09   ` AngeloGioacchino Del Regno
  19 siblings, 1 reply; 44+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-03-02 16:30 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Matthias Brugger, AngeloGioacchino Del Regno,
	Sen Chu, Sean Wang, Macpaul Lin, Lee Jones, Jaroslav Kysela,
	Takashi Iwai, Catalin Marinas, Will Deacon
  Cc: kernel, linux-sound, devicetree, linux-kernel, linux-arm-kernel,
	linux-mediatek, linux-pm, Nícolas F. R. A. Prado

Enable support for the ACCDET block in the MT6359 PMIC, which provides
jack detection capabilities to MediaTek platforms.

Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
---
 arch/arm64/configs/defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
index e675bedbc170ccb191f4991e348e36b5de0707a7..dec4708d5e946fc890751cab8de2cf3f302e9447 100644
--- a/arch/arm64/configs/defconfig
+++ b/arch/arm64/configs/defconfig
@@ -1065,6 +1065,7 @@ CONFIG_SND_SOC_WM8978=m
 CONFIG_SND_SOC_WSA881X=m
 CONFIG_SND_SOC_WSA883X=m
 CONFIG_SND_SOC_WSA884X=m
+CONFIG_SND_SOC_MT6359_ACCDET=m
 CONFIG_SND_SOC_NAU8822=m
 CONFIG_SND_SOC_LPASS_WSA_MACRO=m
 CONFIG_SND_SOC_LPASS_VA_MACRO=m

-- 
2.48.1



^ permalink raw reply related	[flat|nested] 44+ messages in thread

* Re: [PATCH v2 19/20] arm64: dts: mt6359: Add accessory detect node
  2025-03-02 16:30 ` [PATCH v2 19/20] arm64: dts: mt6359: Add accessory detect node Nícolas F. R. A. Prado
@ 2025-03-03  2:30   ` Macpaul Lin (林智斌)
  2025-03-03 11:09   ` AngeloGioacchino Del Regno
  1 sibling, 0 replies; 44+ messages in thread
From: Macpaul Lin (林智斌) @ 2025-03-03  2:30 UTC (permalink / raw)
  To: Sen Chu (储森), matthias.bgg@gmail.com,
	tiwai@suse.com, broonie@kernel.org, AngeloGioacchino Del Regno,
	robh@kernel.org, lee@kernel.org, krzk+dt@kernel.org, Sean Wang,
	will@kernel.org, lgirdwood@gmail.com, Nicolas Prado,
	perex@perex.cz, conor+dt@kernel.org, catalin.marinas@arm.com
  Cc: linux-sound@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-mediatek@lists.infradead.org, linux-pm@vger.kernel.org,
	kernel@collabora.com, Andrew Perepech

On Sun, 2025-03-02 at 13:30 -0300, Nícolas F. R. A. Prado wrote:
> 
> Add audio jack detection node. PMIC accessory detect driver will
> create an input device that will send key events on jack
> insertion/removal or accessory device key presses.
> 
> Co-developed-by: Andrew Perepech <andrew.perepech@mediatek.com>
> Signed-off-by: Andrew Perepech <andrew.perepech@mediatek.com>
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
> ---
>  arch/arm64/boot/dts/mediatek/mt6359.dtsi | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/arch/arm64/boot/dts/mediatek/mt6359.dtsi
> b/arch/arm64/boot/dts/mediatek/mt6359.dtsi
> index
> 7b10f9c59819a9ad02319f00938f35c931091f9f..e24e4aeb3b9cafa2af56c62bc4c
> 549df27d0ec73 100644
> --- a/arch/arm64/boot/dts/mediatek/mt6359.dtsi
> +++ b/arch/arm64/boot/dts/mediatek/mt6359.dtsi
> @@ -15,6 +15,10 @@ pmic_adc: adc {
>                         #io-channel-cells = <1>;
>                 };
> 
> +               accdet: accdet {
> +                       compatible = "mediatek,mt6359-accdet";
> +               };
> +
>                 mt6359codec: audio-codec {
>                         compatible = "mediatek,mt6359-codec";
>                 };
> 
> --
> 2.48.1
> 

Reviewed-by: Macpaul Lin <macpaul.lin@mediatek.com>

Thanks!
Macpaul Lin

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH v2 17/20] ASoC: mediatek: mt6359-accdet: Always set comp-vth to 1.6V
  2025-03-02 16:30 ` [PATCH v2 17/20] ASoC: mediatek: mt6359-accdet: Always set comp-vth to 1.6V Nícolas F. R. A. Prado
@ 2025-03-03 11:06   ` AngeloGioacchino Del Regno
  0 siblings, 0 replies; 44+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-03-03 11:06 UTC (permalink / raw)
  To: Nícolas F. R. A. Prado, Liam Girdwood, Mark Brown,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
	Sen Chu, Sean Wang, Macpaul Lin, Lee Jones, Jaroslav Kysela,
	Takashi Iwai, Catalin Marinas, Will Deacon
  Cc: kernel, linux-sound, devicetree, linux-kernel, linux-arm-kernel,
	linux-mediatek, linux-pm

Il 02/03/25 17:30, Nícolas F. R. A. Prado ha scritto:
> The driver currently reads a mediatek,eint-comp-vth property from DT to
> determine the voltage threshold of the EINT comparator. Since there are
> no current users of the property and setting it to 1.6V is known to work
> across multiple boards, remove the code handling this property and
> instead always configure it to 1.6V. The property can be properly
> introduced in the binding in the future if it really turns out that
> different boards need different configurations.
> 
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>


Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>




^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH v2 16/20] ASoC: mediatek: mt6359-accdet: Always configure hardware as mic-mode 2
  2025-03-02 16:30 ` [PATCH v2 16/20] ASoC: mediatek: mt6359-accdet: Always configure hardware as mic-mode 2 Nícolas F. R. A. Prado
@ 2025-03-03 11:06   ` AngeloGioacchino Del Regno
  0 siblings, 0 replies; 44+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-03-03 11:06 UTC (permalink / raw)
  To: Nícolas F. R. A. Prado, Liam Girdwood, Mark Brown,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
	Sen Chu, Sean Wang, Macpaul Lin, Lee Jones, Jaroslav Kysela,
	Takashi Iwai, Catalin Marinas, Will Deacon
  Cc: kernel, linux-sound, devicetree, linux-kernel, linux-arm-kernel,
	linux-mediatek, linux-pm

Il 02/03/25 17:30, Nícolas F. R. A. Prado ha scritto:
> The driver currently reads a mediatek,mic-mode property from DT to
> determine certain register configurations. Since there are no current
> users of the property, the property doesn't directly reflect the
> hardware  and the default value (2) is known to work on
> multiple boards, remove the code handling this property and instead
> always configure the hardware according to the known to work default.
> This property can be properly introduced in the binding in the future
> if it really turns out that different boards need different
> configurations.
> 
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>




^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH v2 15/20] ASoC: mediatek: mt6359-accdet: Always set micbias1 to 2.8V
  2025-03-02 16:30 ` [PATCH v2 15/20] ASoC: mediatek: mt6359-accdet: Always set micbias1 to 2.8V Nícolas F. R. A. Prado
@ 2025-03-03 11:06   ` AngeloGioacchino Del Regno
  0 siblings, 0 replies; 44+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-03-03 11:06 UTC (permalink / raw)
  To: Nícolas F. R. A. Prado, Liam Girdwood, Mark Brown,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
	Sen Chu, Sean Wang, Macpaul Lin, Lee Jones, Jaroslav Kysela,
	Takashi Iwai, Catalin Marinas, Will Deacon
  Cc: kernel, linux-sound, devicetree, linux-kernel, linux-arm-kernel,
	linux-mediatek, linux-pm

Il 02/03/25 17:30, Nícolas F. R. A. Prado ha scritto:
> The driver currently reads a mediatek,mic-vol property from DT to
> determine the micbias1 setting to configure in hardware. Since there are
> no current users of the property and the default value (2.8V) is known
> to work on multiple boards, remove the code handling this property and
> instead always configure the micbias1 to 2.8V. The property can be
> properly introduced in the binding in the future if it really turns out
> that different boards need different configurations.
> 
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>




^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH v2 12/20] ASoC: mediatek: mt6359-accdet: Always use internal resistor
  2025-03-02 16:30 ` [PATCH v2 12/20] ASoC: mediatek: mt6359-accdet: Always use internal resistor Nícolas F. R. A. Prado
@ 2025-03-03 11:06   ` AngeloGioacchino Del Regno
  0 siblings, 0 replies; 44+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-03-03 11:06 UTC (permalink / raw)
  To: Nícolas F. R. A. Prado, Liam Girdwood, Mark Brown,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
	Sen Chu, Sean Wang, Macpaul Lin, Lee Jones, Jaroslav Kysela,
	Takashi Iwai, Catalin Marinas, Will Deacon
  Cc: kernel, linux-sound, devicetree, linux-kernel, linux-arm-kernel,
	linux-mediatek, linux-pm

Il 02/03/25 17:30, Nícolas F. R. A. Prado ha scritto:
> The code currently reads a property mediatek,eint-use-ext-res with
> values ranging between 0 and 4. Not only should this be a boolean
> property, but there's no need for it to even be a DT property, seeing as
> all current boards will use the internal resistor anyway. Since there's
> no current dt-binding or Devicetree user of this property, remove its
> handling and make the driver always configure the internal resistor.
> 
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>

Adding up to this - I even checked a few downstream smartphone devicetrees, and
not even those are ever using external resistor. This won't ever be needed.

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>




^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH v2 13/20] ASoC: mediatek: mt6359-accdet: Make PWM debounce settings internal
  2025-03-02 16:30 ` [PATCH v2 13/20] ASoC: mediatek: mt6359-accdet: Make PWM debounce settings internal Nícolas F. R. A. Prado
@ 2025-03-03 11:07   ` AngeloGioacchino Del Regno
  0 siblings, 0 replies; 44+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-03-03 11:07 UTC (permalink / raw)
  To: Nícolas F. R. A. Prado, Liam Girdwood, Mark Brown,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
	Sen Chu, Sean Wang, Macpaul Lin, Lee Jones, Jaroslav Kysela,
	Takashi Iwai, Catalin Marinas, Will Deacon
  Cc: kernel, linux-sound, devicetree, linux-kernel, linux-arm-kernel,
	linux-mediatek, linux-pm

Il 02/03/25 17:30, Nícolas F. R. A. Prado ha scritto:
> Instead of reading a bunch of PWM debounce settings from the Devicetree,
> set reasonable values inside the driver that are known to work across
> multiple boards. There are no current users of these DT properties, so
> no backward compatibility needs to be maintained. The properties can be
> properly introduced in the binding in the future if different boards
> really need to override them.
> 
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>




^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH v2 14/20] ASoC: mediatek: mt6359-accdet: Always use eint detect mode 4
  2025-03-02 16:30 ` [PATCH v2 14/20] ASoC: mediatek: mt6359-accdet: Always use eint detect mode 4 Nícolas F. R. A. Prado
@ 2025-03-03 11:07   ` AngeloGioacchino Del Regno
  0 siblings, 0 replies; 44+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-03-03 11:07 UTC (permalink / raw)
  To: Nícolas F. R. A. Prado, Liam Girdwood, Mark Brown,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
	Sen Chu, Sean Wang, Macpaul Lin, Lee Jones, Jaroslav Kysela,
	Takashi Iwai, Catalin Marinas, Will Deacon
  Cc: kernel, linux-sound, devicetree, linux-kernel, linux-arm-kernel,
	linux-mediatek, linux-pm

Il 02/03/25 17:30, Nícolas F. R. A. Prado ha scritto:
> The driver currently reads a mediatek,eint-detect-mode property from DT,
> which determines certain register configurations. Since there are no
> users of the property, it doesn't directly describe the hardware, and
> the default value (4) is known to work across multiple boards, remove
> the handling for this property and always assume mode 4 is used. The
> property can be properly introduced in the binding in the future if
> different boards actually need different configurations.
> 
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>

Same as the internal resistor one, can't find usage of this property, not even
in downstream devicetrees for dimensity chips..... so it's safe to remove.

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>




^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH v2 10/20] ASoC: mediatek: mt6359-accdet: Drop dead code for plugout-debounce
  2025-03-02 16:30 ` [PATCH v2 10/20] ASoC: mediatek: mt6359-accdet: Drop dead code for plugout-debounce Nícolas F. R. A. Prado
@ 2025-03-03 11:07   ` AngeloGioacchino Del Regno
  0 siblings, 0 replies; 44+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-03-03 11:07 UTC (permalink / raw)
  To: Nícolas F. R. A. Prado, Liam Girdwood, Mark Brown,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
	Sen Chu, Sean Wang, Macpaul Lin, Lee Jones, Jaroslav Kysela,
	Takashi Iwai, Catalin Marinas, Will Deacon
  Cc: kernel, linux-sound, devicetree, linux-kernel, linux-arm-kernel,
	linux-mediatek, linux-pm

Il 02/03/25 17:30, Nícolas F. R. A. Prado ha scritto:
> The mediatek,plugout-debounce property is undocumented in the binding
> and unhandled by the driver. Remove it.
> 
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>




^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH v2 11/20] ASoC: mediatek: mt6359-accdet: Drop unused moisture variables
  2025-03-02 16:30 ` [PATCH v2 11/20] ASoC: mediatek: mt6359-accdet: Drop unused moisture variables Nícolas F. R. A. Prado
@ 2025-03-03 11:07   ` AngeloGioacchino Del Regno
  0 siblings, 0 replies; 44+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-03-03 11:07 UTC (permalink / raw)
  To: Nícolas F. R. A. Prado, Liam Girdwood, Mark Brown,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
	Sen Chu, Sean Wang, Macpaul Lin, Lee Jones, Jaroslav Kysela,
	Takashi Iwai, Catalin Marinas, Will Deacon
  Cc: kernel, linux-sound, devicetree, linux-kernel, linux-arm-kernel,
	linux-mediatek, linux-pm

Il 02/03/25 17:30, Nícolas F. R. A. Prado ha scritto:
> The dts_data struct contains several variables for moisture
> configuration that are simply never used. Drop them.
> 
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>




^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH v2 09/20] ASoC: mediatek: mt6359-accdet: Drop dead code for button detection
  2025-03-02 16:30 ` [PATCH v2 09/20] ASoC: mediatek: mt6359-accdet: Drop dead code for button detection Nícolas F. R. A. Prado
@ 2025-03-03 11:07   ` AngeloGioacchino Del Regno
  0 siblings, 0 replies; 44+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-03-03 11:07 UTC (permalink / raw)
  To: Nícolas F. R. A. Prado, Liam Girdwood, Mark Brown,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
	Sen Chu, Sean Wang, Macpaul Lin, Lee Jones, Jaroslav Kysela,
	Takashi Iwai, Catalin Marinas, Will Deacon
  Cc: kernel, linux-sound, devicetree, linux-kernel, linux-arm-kernel,
	linux-mediatek, linux-pm

Il 02/03/25 17:30, Nícolas F. R. A. Prado ha scritto:
> The button detection functionality depends on a calibration voltage
> value which is currently not updated anywhere in the driver code, and
> hence it doesn't actually do anything. Remove this unused code.
> 
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>




^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH v2 07/20] ASoC: mediatek: mt6359-accdet: Drop dead code for EINT/GPIO IRQ handling
  2025-03-02 16:30 ` [PATCH v2 07/20] ASoC: mediatek: mt6359-accdet: Drop dead code for EINT/GPIO IRQ handling Nícolas F. R. A. Prado
@ 2025-03-03 11:07   ` AngeloGioacchino Del Regno
  0 siblings, 0 replies; 44+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-03-03 11:07 UTC (permalink / raw)
  To: Nícolas F. R. A. Prado, Liam Girdwood, Mark Brown,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
	Sen Chu, Sean Wang, Macpaul Lin, Lee Jones, Jaroslav Kysela,
	Takashi Iwai, Catalin Marinas, Will Deacon
  Cc: kernel, linux-sound, devicetree, linux-kernel, linux-arm-kernel,
	linux-mediatek, linux-pm

Il 02/03/25 17:30, Nícolas F. R. A. Prado ha scritto:
> The ACCDET supports two modes for IRQ generation: PMIC EINT or AP GPIO,
> which in principle could be configured through a DT property. However
> this DT property has no user nor is documented in a binding, and the
> driver only implements the PMIC EINT case, so drop the unused code
> intended to handle both cases.
> 
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>



^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH v2 08/20] ASoC: mediatek: mt6359-accdet: Drop dead code for EINT trigger setting
  2025-03-02 16:30 ` [PATCH v2 08/20] ASoC: mediatek: mt6359-accdet: Drop dead code for EINT trigger setting Nícolas F. R. A. Prado
@ 2025-03-03 11:07   ` AngeloGioacchino Del Regno
  0 siblings, 0 replies; 44+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-03-03 11:07 UTC (permalink / raw)
  To: Nícolas F. R. A. Prado, Liam Girdwood, Mark Brown,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
	Sen Chu, Sean Wang, Macpaul Lin, Lee Jones, Jaroslav Kysela,
	Takashi Iwai, Catalin Marinas, Will Deacon
  Cc: kernel, linux-sound, devicetree, linux-kernel, linux-arm-kernel,
	linux-mediatek, linux-pm

Il 02/03/25 17:30, Nícolas F. R. A. Prado ha scritto:
> None of the EINT trigger options are implemented and the DT property is
> not described in the binding. Remove the unused code.
> 
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>



^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH v2 05/20] ASoC: mediatek: mt6359-accdet: Handle hp-eint-high property
  2025-03-02 16:30 ` [PATCH v2 05/20] ASoC: mediatek: mt6359-accdet: Handle hp-eint-high property Nícolas F. R. A. Prado
@ 2025-03-03 11:07   ` AngeloGioacchino Del Regno
  0 siblings, 0 replies; 44+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-03-03 11:07 UTC (permalink / raw)
  To: Nícolas F. R. A. Prado, Liam Girdwood, Mark Brown,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
	Sen Chu, Sean Wang, Macpaul Lin, Lee Jones, Jaroslav Kysela,
	Takashi Iwai, Catalin Marinas, Will Deacon
  Cc: kernel, linux-sound, devicetree, linux-kernel, linux-arm-kernel,
	linux-mediatek, linux-pm

Il 02/03/25 17:30, Nícolas F. R. A. Prado ha scritto:
> Now that the dt-binding was introduced, the property that governs the
> eint polarity is a boolean called mediatek,hp-eint-high, while the
> current code handles a u32 property called mediatek,eint-level-pol.
> Update the driver handling accordingly.
> 
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>




^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH v2 18/20] ASoC: mediatek: mt6359-accdet: Always use EINT0 IRQ
  2025-03-02 16:30 ` [PATCH v2 18/20] ASoC: mediatek: mt6359-accdet: Always use EINT0 IRQ Nícolas F. R. A. Prado
@ 2025-03-03 11:08   ` AngeloGioacchino Del Regno
  0 siblings, 0 replies; 44+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-03-03 11:08 UTC (permalink / raw)
  To: Nícolas F. R. A. Prado, Liam Girdwood, Mark Brown,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
	Sen Chu, Sean Wang, Macpaul Lin, Lee Jones, Jaroslav Kysela,
	Takashi Iwai, Catalin Marinas, Will Deacon
  Cc: kernel, linux-sound, devicetree, linux-kernel, linux-arm-kernel,
	linux-mediatek, linux-pm

Il 02/03/25 17:30, Nícolas F. R. A. Prado ha scritto:
> The ACCDET block can generate two distinct EINT interrupts: EINT0 and
> EINT1, and which is enabled is currently determined by mediatek,eint-num
> property in DT. However, only EINT0 is used on the boards that are
> known to have working ACCDET. Since there are no current users of the
> property, remove its handling and instead always enable EINT0. The
> property can be properly introduced in the binding in the future if it
> really turns out that other boards require EINT1.
> 
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>




^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH v2 19/20] arm64: dts: mt6359: Add accessory detect node
  2025-03-02 16:30 ` [PATCH v2 19/20] arm64: dts: mt6359: Add accessory detect node Nícolas F. R. A. Prado
  2025-03-03  2:30   ` Macpaul Lin (林智斌)
@ 2025-03-03 11:09   ` AngeloGioacchino Del Regno
  1 sibling, 0 replies; 44+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-03-03 11:09 UTC (permalink / raw)
  To: Nícolas F. R. A. Prado, Liam Girdwood, Mark Brown,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
	Sen Chu, Sean Wang, Macpaul Lin, Lee Jones, Jaroslav Kysela,
	Takashi Iwai, Catalin Marinas, Will Deacon
  Cc: kernel, linux-sound, devicetree, linux-kernel, linux-arm-kernel,
	linux-mediatek, linux-pm, Andrew Perepech

Il 02/03/25 17:30, Nícolas F. R. A. Prado ha scritto:
> Add audio jack detection node. PMIC accessory detect driver will
> create an input device that will send key events on jack
> insertion/removal or accessory device key presses.
> 
> Co-developed-by: Andrew Perepech <andrew.perepech@mediatek.com>
> Signed-off-by: Andrew Perepech <andrew.perepech@mediatek.com>
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>




^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH v2 20/20] arm64: defconfig: Enable MT6359 ACCDET
  2025-03-02 16:30 ` [PATCH v2 20/20] arm64: defconfig: Enable MT6359 ACCDET Nícolas F. R. A. Prado
@ 2025-03-03 11:09   ` AngeloGioacchino Del Regno
  0 siblings, 0 replies; 44+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-03-03 11:09 UTC (permalink / raw)
  To: Nícolas F. R. A. Prado, Liam Girdwood, Mark Brown,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
	Sen Chu, Sean Wang, Macpaul Lin, Lee Jones, Jaroslav Kysela,
	Takashi Iwai, Catalin Marinas, Will Deacon
  Cc: kernel, linux-sound, devicetree, linux-kernel, linux-arm-kernel,
	linux-mediatek, linux-pm

Il 02/03/25 17:30, Nícolas F. R. A. Prado ha scritto:
> Enable support for the ACCDET block in the MT6359 PMIC, which provides
> jack detection capabilities to MediaTek platforms.
> 
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>




^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH v2 03/20] mfd: mt6397-core: Add mfd_cell for mt6359-accdet
  2025-03-02 16:30 ` [PATCH v2 03/20] mfd: mt6397-core: Add mfd_cell for mt6359-accdet Nícolas F. R. A. Prado
@ 2025-03-03 11:13   ` AngeloGioacchino Del Regno
  0 siblings, 0 replies; 44+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-03-03 11:13 UTC (permalink / raw)
  To: Nícolas F. R. A. Prado, Liam Girdwood, Mark Brown,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
	Sen Chu, Sean Wang, Macpaul Lin, Lee Jones, Jaroslav Kysela,
	Takashi Iwai, Catalin Marinas, Will Deacon
  Cc: kernel, linux-sound, devicetree, linux-kernel, linux-arm-kernel,
	linux-mediatek, linux-pm, Andrew Perepech

Il 02/03/25 17:30, Nícolas F. R. A. Prado ha scritto:
> From: Andrew Perepech <andrew.perepech@mediatek.com>
> 
> Add an mfd_cell for mt6359-accdet and describe its IRQ resources to
> allow the mt6359-accdet driver to probe.
> 
> Signed-off-by: Andrew Perepech <andrew.perepech@mediatek.com>
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>




^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH v2 01/20] ASoC: dt-bindings: Add document for mt6359-accdet
  2025-03-02 16:30 ` [PATCH v2 01/20] ASoC: dt-bindings: Add document for mt6359-accdet Nícolas F. R. A. Prado
@ 2025-03-03 11:14   ` AngeloGioacchino Del Regno
  2025-03-03 14:45     ` Nícolas F. R. A. Prado
  2025-03-03 15:11   ` Rob Herring
  1 sibling, 1 reply; 44+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-03-03 11:14 UTC (permalink / raw)
  To: Nícolas F. R. A. Prado, Liam Girdwood, Mark Brown,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
	Sen Chu, Sean Wang, Macpaul Lin, Lee Jones, Jaroslav Kysela,
	Takashi Iwai, Catalin Marinas, Will Deacon
  Cc: kernel, linux-sound, devicetree, linux-kernel, linux-arm-kernel,
	linux-mediatek, linux-pm

Il 02/03/25 17:30, Nícolas F. R. A. Prado ha scritto:
> Add dt-binding for the MT6359 ACCDET hardware block.
> 
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
> ---
>   .../bindings/sound/mediatek,mt6359-accdet.yaml     | 42 ++++++++++++++++++++++
>   1 file changed, 42 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/sound/mediatek,mt6359-accdet.yaml b/Documentation/devicetree/bindings/sound/mediatek,mt6359-accdet.yaml
> new file mode 100644
> index 0000000000000000000000000000000000000000..d08a79301409374714c76135b061e20e8e8acfaf
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/sound/mediatek,mt6359-accdet.yaml
> @@ -0,0 +1,42 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/sound/mediatek,mt6359-accdet.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: MT6359 Accessory Detection
> +
> +maintainers:
> +  - Nícolas F. R. A. Prado <nfraprado@collabora.com>
> +
> +description: |
> +  The MT6359 Accessory Detection block is part of the MT6359 PMIC and allows
> +  detecting audio jack insertion and removal, as well as identifying the type of
> +  events connected to the jack.
> +
> +properties:
> +  compatible:
> +    const: mediatek,mt6359-accdet
> +
> +  mediatek,hp-eint-high:
> +    type: boolean
> +    description:
> +      By default, the HP_EINT pin is assumed to be pulled high and connected to

Just to be clearer about this pin being an internal one and not externally sourced,
so, *not* a SoC GPIO, but somehing that is completely provided and handled by the
accdet IP...

"By default, the accdet IP's internal HP_EINT pin is assumed to be pulled ..."

After which:

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>

> +      a normally open 3.5mm jack. Plug insertion is detected when the pin is
> +      brought low in that case. Add this property if the behavior should be
> +      inverted, for example if a normally closed 3.5mm jack is used, or if the
> +      line is pulled low on open.
> +
> +required:
> +  - compatible
> +
> +additionalProperties: false
> +
> +examples:
> +  - |
> +    #include <dt-bindings/interrupt-controller/irq.h>
> +
> +    accdet: accdet {
> +        compatible = "mediatek,mt6359-accdet";
> +        mediatek,hp-eint-high;
> +    };
> 




^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH v2 06/20] ASoC: mediatek: mt6359-accdet: Implement HP_EINT polarity configuration
  2025-03-02 16:30 ` [PATCH v2 06/20] ASoC: mediatek: mt6359-accdet: Implement HP_EINT polarity configuration Nícolas F. R. A. Prado
@ 2025-03-03 11:15   ` AngeloGioacchino Del Regno
  0 siblings, 0 replies; 44+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-03-03 11:15 UTC (permalink / raw)
  To: Nícolas F. R. A. Prado, Liam Girdwood, Mark Brown,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
	Sen Chu, Sean Wang, Macpaul Lin, Lee Jones, Jaroslav Kysela,
	Takashi Iwai, Catalin Marinas, Will Deacon
  Cc: kernel, linux-sound, devicetree, linux-kernel, linux-arm-kernel,
	linux-mediatek, linux-pm, Andrew Perepech

Il 02/03/25 17:30, Nícolas F. R. A. Prado ha scritto:
> From: Andrew Perepech <andrew.perepech@mediatek.com>
> 
> The driver currently reads the HP_EINT polarity from the Devicetree but
> never actually configures the hardware accordingly.
> 
> Implement the polarity configuration in hardware.
> 
> Signed-off-by: Andrew Perepech <andrew.perepech@mediatek.com>
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>




^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH v2 01/20] ASoC: dt-bindings: Add document for mt6359-accdet
  2025-03-03 11:14   ` AngeloGioacchino Del Regno
@ 2025-03-03 14:45     ` Nícolas F. R. A. Prado
  2025-03-03 15:33       ` AngeloGioacchino Del Regno
  0 siblings, 1 reply; 44+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-03-03 14:45 UTC (permalink / raw)
  To: AngeloGioacchino Del Regno
  Cc: Liam Girdwood, Mark Brown, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Matthias Brugger, Sen Chu, Sean Wang, Macpaul Lin,
	Lee Jones, Jaroslav Kysela, Takashi Iwai, Catalin Marinas,
	Will Deacon, kernel, linux-sound, devicetree, linux-kernel,
	linux-arm-kernel, linux-mediatek, linux-pm

On Mon, Mar 03, 2025 at 12:14:51PM +0100, AngeloGioacchino Del Regno wrote:
> Il 02/03/25 17:30, Nícolas F. R. A. Prado ha scritto:
> > Add dt-binding for the MT6359 ACCDET hardware block.
> > 
> > Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
> > ---
> >   .../bindings/sound/mediatek,mt6359-accdet.yaml     | 42 ++++++++++++++++++++++
> >   1 file changed, 42 insertions(+)
> > 
> > diff --git a/Documentation/devicetree/bindings/sound/mediatek,mt6359-accdet.yaml b/Documentation/devicetree/bindings/sound/mediatek,mt6359-accdet.yaml
> > new file mode 100644
> > index 0000000000000000000000000000000000000000..d08a79301409374714c76135b061e20e8e8acfaf
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/sound/mediatek,mt6359-accdet.yaml
> > @@ -0,0 +1,42 @@
> > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> > +%YAML 1.2
> > +---
> > +$id: http://devicetree.org/schemas/sound/mediatek,mt6359-accdet.yaml#
> > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > +
> > +title: MT6359 Accessory Detection
> > +
> > +maintainers:
> > +  - Nícolas F. R. A. Prado <nfraprado@collabora.com>
> > +
> > +description: |
> > +  The MT6359 Accessory Detection block is part of the MT6359 PMIC and allows
> > +  detecting audio jack insertion and removal, as well as identifying the type of
> > +  events connected to the jack.
> > +
> > +properties:
> > +  compatible:
> > +    const: mediatek,mt6359-accdet
> > +
> > +  mediatek,hp-eint-high:
> > +    type: boolean
> > +    description:
> > +      By default, the HP_EINT pin is assumed to be pulled high and connected to
> 
> Just to be clearer about this pin being an internal one and not externally sourced,
> so, *not* a SoC GPIO, but somehing that is completely provided and handled by the
> accdet IP...
> 
> "By default, the accdet IP's internal HP_EINT pin is assumed to be pulled ..."

The HP_EINT is an external, not internal, pin of the MT6359 PMIC. It is an input
pin of the MT6359 IC that gets wired to the tip (left channel) of a 3.5mm audio
jack to allow for detecting when a plug is connected.

Since this dt-binding is about an IP in the MT6359 PMIC, I think when saying
"HP_EINT pin" it is already clear that the pin is on the MT6359 IC, but if you
think it's necessary I could make it "MT6359's HP_EINT pin".

Thanks,
Nícolas


^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH v2 01/20] ASoC: dt-bindings: Add document for mt6359-accdet
  2025-03-02 16:30 ` [PATCH v2 01/20] ASoC: dt-bindings: Add document for mt6359-accdet Nícolas F. R. A. Prado
  2025-03-03 11:14   ` AngeloGioacchino Del Regno
@ 2025-03-03 15:11   ` Rob Herring
  1 sibling, 0 replies; 44+ messages in thread
From: Rob Herring @ 2025-03-03 15:11 UTC (permalink / raw)
  To: Nícolas F. R. A. Prado
  Cc: Liam Girdwood, Mark Brown, Krzysztof Kozlowski, Conor Dooley,
	Matthias Brugger, AngeloGioacchino Del Regno, Sen Chu, Sean Wang,
	Macpaul Lin, Lee Jones, Jaroslav Kysela, Takashi Iwai,
	Catalin Marinas, Will Deacon, kernel, linux-sound, devicetree,
	linux-kernel, linux-arm-kernel, linux-mediatek, linux-pm

On Sun, Mar 02, 2025 at 01:30:40PM -0300, Nícolas F. R. A. Prado wrote:
> Add dt-binding for the MT6359 ACCDET hardware block.
> 
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
> ---
>  .../bindings/sound/mediatek,mt6359-accdet.yaml     | 42 ++++++++++++++++++++++
>  1 file changed, 42 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/sound/mediatek,mt6359-accdet.yaml b/Documentation/devicetree/bindings/sound/mediatek,mt6359-accdet.yaml
> new file mode 100644
> index 0000000000000000000000000000000000000000..d08a79301409374714c76135b061e20e8e8acfaf
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/sound/mediatek,mt6359-accdet.yaml
> @@ -0,0 +1,42 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/sound/mediatek,mt6359-accdet.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: MT6359 Accessory Detection
> +
> +maintainers:
> +  - Nícolas F. R. A. Prado <nfraprado@collabora.com>
> +
> +description: |

Don't need '|'.

> +  The MT6359 Accessory Detection block is part of the MT6359 PMIC and allows
> +  detecting audio jack insertion and removal, as well as identifying the type of
> +  events connected to the jack.
> +
> +properties:
> +  compatible:
> +    const: mediatek,mt6359-accdet
> +
> +  mediatek,hp-eint-high:
> +    type: boolean
> +    description:
> +      By default, the HP_EINT pin is assumed to be pulled high and connected to
> +      a normally open 3.5mm jack. Plug insertion is detected when the pin is
> +      brought low in that case. Add this property if the behavior should be
> +      inverted, for example if a normally closed 3.5mm jack is used, or if the
> +      line is pulled low on open.
> +
> +required:
> +  - compatible
> +
> +additionalProperties: false
> +
> +examples:
> +  - |
> +    #include <dt-bindings/interrupt-controller/irq.h>
> +
> +    accdet: accdet {
> +        compatible = "mediatek,mt6359-accdet";
> +        mediatek,hp-eint-high;
> +    };
> 
> -- 
> 2.48.1
> 


^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH v2 02/20] dt-bindings: mfd: mediatek: mt6397: Add accdet subnode
  2025-03-02 16:30 ` [PATCH v2 02/20] dt-bindings: mfd: mediatek: mt6397: Add accdet subnode Nícolas F. R. A. Prado
@ 2025-03-03 15:13   ` Rob Herring
  0 siblings, 0 replies; 44+ messages in thread
From: Rob Herring @ 2025-03-03 15:13 UTC (permalink / raw)
  To: Nícolas F. R. A. Prado
  Cc: Liam Girdwood, Mark Brown, Krzysztof Kozlowski, Conor Dooley,
	Matthias Brugger, AngeloGioacchino Del Regno, Sen Chu, Sean Wang,
	Macpaul Lin, Lee Jones, Jaroslav Kysela, Takashi Iwai,
	Catalin Marinas, Will Deacon, kernel, linux-sound, devicetree,
	linux-kernel, linux-arm-kernel, linux-mediatek, linux-pm

On Sun, Mar 02, 2025 at 01:30:41PM -0300, Nícolas F. R. A. Prado wrote:
> Describe the accdet as a possible subnode of the MT6359 PMIC.
> 
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
> ---
>  Documentation/devicetree/bindings/mfd/mediatek,mt6397.yaml | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/mfd/mediatek,mt6397.yaml b/Documentation/devicetree/bindings/mfd/mediatek,mt6397.yaml
> index 6a89b479d10fad3c8b61cab5a3af1453baca4d1a..1a8c5748a28da6ad8aa091f8c0a74bc1dc709644 100644
> --- a/Documentation/devicetree/bindings/mfd/mediatek,mt6397.yaml
> +++ b/Documentation/devicetree/bindings/mfd/mediatek,mt6397.yaml
> @@ -224,6 +224,13 @@ properties:
>      description:
>        Pin controller
>  
> +  accdet:
> +    type: object
> +    $ref: /schemas/sound/mediatek,mt6359-accdet.yaml
> +    unevaluatedProperties: false

Don't need unevaluatedProperties here. The referenced schema already has 
the constraint.

> +    description:
> +      Accessory Detection
> +
>  required:
>    - compatible
>    - regulators
> 
> -- 
> 2.48.1
> 


^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH v2 01/20] ASoC: dt-bindings: Add document for mt6359-accdet
  2025-03-03 14:45     ` Nícolas F. R. A. Prado
@ 2025-03-03 15:33       ` AngeloGioacchino Del Regno
  0 siblings, 0 replies; 44+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-03-03 15:33 UTC (permalink / raw)
  To: Nícolas F. R. A. Prado
  Cc: Liam Girdwood, Mark Brown, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Matthias Brugger, Sen Chu, Sean Wang, Macpaul Lin,
	Lee Jones, Jaroslav Kysela, Takashi Iwai, Catalin Marinas,
	Will Deacon, kernel, linux-sound, devicetree, linux-kernel,
	linux-arm-kernel, linux-mediatek, linux-pm

Il 03/03/25 15:45, Nícolas F. R. A. Prado ha scritto:
> On Mon, Mar 03, 2025 at 12:14:51PM +0100, AngeloGioacchino Del Regno wrote:
>> Il 02/03/25 17:30, Nícolas F. R. A. Prado ha scritto:
>>> Add dt-binding for the MT6359 ACCDET hardware block.
>>>
>>> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
>>> ---
>>>    .../bindings/sound/mediatek,mt6359-accdet.yaml     | 42 ++++++++++++++++++++++
>>>    1 file changed, 42 insertions(+)
>>>
>>> diff --git a/Documentation/devicetree/bindings/sound/mediatek,mt6359-accdet.yaml b/Documentation/devicetree/bindings/sound/mediatek,mt6359-accdet.yaml
>>> new file mode 100644
>>> index 0000000000000000000000000000000000000000..d08a79301409374714c76135b061e20e8e8acfaf
>>> --- /dev/null
>>> +++ b/Documentation/devicetree/bindings/sound/mediatek,mt6359-accdet.yaml
>>> @@ -0,0 +1,42 @@
>>> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
>>> +%YAML 1.2
>>> +---
>>> +$id: http://devicetree.org/schemas/sound/mediatek,mt6359-accdet.yaml#
>>> +$schema: http://devicetree.org/meta-schemas/core.yaml#
>>> +
>>> +title: MT6359 Accessory Detection
>>> +
>>> +maintainers:
>>> +  - Nícolas F. R. A. Prado <nfraprado@collabora.com>
>>> +
>>> +description: |
>>> +  The MT6359 Accessory Detection block is part of the MT6359 PMIC and allows
>>> +  detecting audio jack insertion and removal, as well as identifying the type of
>>> +  events connected to the jack.
>>> +
>>> +properties:
>>> +  compatible:
>>> +    const: mediatek,mt6359-accdet
>>> +
>>> +  mediatek,hp-eint-high:
>>> +    type: boolean
>>> +    description:
>>> +      By default, the HP_EINT pin is assumed to be pulled high and connected to
>>
>> Just to be clearer about this pin being an internal one and not externally sourced,
>> so, *not* a SoC GPIO, but somehing that is completely provided and handled by the
>> accdet IP...
>>
>> "By default, the accdet IP's internal HP_EINT pin is assumed to be pulled ..."
> 
> The HP_EINT is an external, not internal, pin of the MT6359 PMIC. It is an input
> pin of the MT6359 IC that gets wired to the tip (left channel) of a 3.5mm audio
> jack to allow for detecting when a plug is connected.
> 
> Since this dt-binding is about an IP in the MT6359 PMIC, I think when saying
> "HP_EINT pin" it is already clear that the pin is on the MT6359 IC, but if you
> think it's necessary I could make it "MT6359's HP_EINT pin".
> 

Eh I should've better clarified - I was meaning that the pin is managed internally,
so we're not managing an external SoC pin.

"MT6359's HP_EINT pin" looks good to me, btw.

Cheers!
Angelo




^ permalink raw reply	[flat|nested] 44+ messages in thread

end of thread, other threads:[~2025-03-03 16:08 UTC | newest]

Thread overview: 44+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-02 16:30 [PATCH v2 00/20] Get mt6359-accdet ready for usage in Devicetree Nícolas F. R. A. Prado
2025-03-02 16:30 ` [PATCH v2 01/20] ASoC: dt-bindings: Add document for mt6359-accdet Nícolas F. R. A. Prado
2025-03-03 11:14   ` AngeloGioacchino Del Regno
2025-03-03 14:45     ` Nícolas F. R. A. Prado
2025-03-03 15:33       ` AngeloGioacchino Del Regno
2025-03-03 15:11   ` Rob Herring
2025-03-02 16:30 ` [PATCH v2 02/20] dt-bindings: mfd: mediatek: mt6397: Add accdet subnode Nícolas F. R. A. Prado
2025-03-03 15:13   ` Rob Herring
2025-03-02 16:30 ` [PATCH v2 03/20] mfd: mt6397-core: Add mfd_cell for mt6359-accdet Nícolas F. R. A. Prado
2025-03-03 11:13   ` AngeloGioacchino Del Regno
2025-03-02 16:30 ` [PATCH v2 04/20] ASoC: mediatek: mt6359-accdet: Add compatible property Nícolas F. R. A. Prado
2025-03-02 16:30 ` [PATCH v2 05/20] ASoC: mediatek: mt6359-accdet: Handle hp-eint-high property Nícolas F. R. A. Prado
2025-03-03 11:07   ` AngeloGioacchino Del Regno
2025-03-02 16:30 ` [PATCH v2 06/20] ASoC: mediatek: mt6359-accdet: Implement HP_EINT polarity configuration Nícolas F. R. A. Prado
2025-03-03 11:15   ` AngeloGioacchino Del Regno
2025-03-02 16:30 ` [PATCH v2 07/20] ASoC: mediatek: mt6359-accdet: Drop dead code for EINT/GPIO IRQ handling Nícolas F. R. A. Prado
2025-03-03 11:07   ` AngeloGioacchino Del Regno
2025-03-02 16:30 ` [PATCH v2 08/20] ASoC: mediatek: mt6359-accdet: Drop dead code for EINT trigger setting Nícolas F. R. A. Prado
2025-03-03 11:07   ` AngeloGioacchino Del Regno
2025-03-02 16:30 ` [PATCH v2 09/20] ASoC: mediatek: mt6359-accdet: Drop dead code for button detection Nícolas F. R. A. Prado
2025-03-03 11:07   ` AngeloGioacchino Del Regno
2025-03-02 16:30 ` [PATCH v2 10/20] ASoC: mediatek: mt6359-accdet: Drop dead code for plugout-debounce Nícolas F. R. A. Prado
2025-03-03 11:07   ` AngeloGioacchino Del Regno
2025-03-02 16:30 ` [PATCH v2 11/20] ASoC: mediatek: mt6359-accdet: Drop unused moisture variables Nícolas F. R. A. Prado
2025-03-03 11:07   ` AngeloGioacchino Del Regno
2025-03-02 16:30 ` [PATCH v2 12/20] ASoC: mediatek: mt6359-accdet: Always use internal resistor Nícolas F. R. A. Prado
2025-03-03 11:06   ` AngeloGioacchino Del Regno
2025-03-02 16:30 ` [PATCH v2 13/20] ASoC: mediatek: mt6359-accdet: Make PWM debounce settings internal Nícolas F. R. A. Prado
2025-03-03 11:07   ` AngeloGioacchino Del Regno
2025-03-02 16:30 ` [PATCH v2 14/20] ASoC: mediatek: mt6359-accdet: Always use eint detect mode 4 Nícolas F. R. A. Prado
2025-03-03 11:07   ` AngeloGioacchino Del Regno
2025-03-02 16:30 ` [PATCH v2 15/20] ASoC: mediatek: mt6359-accdet: Always set micbias1 to 2.8V Nícolas F. R. A. Prado
2025-03-03 11:06   ` AngeloGioacchino Del Regno
2025-03-02 16:30 ` [PATCH v2 16/20] ASoC: mediatek: mt6359-accdet: Always configure hardware as mic-mode 2 Nícolas F. R. A. Prado
2025-03-03 11:06   ` AngeloGioacchino Del Regno
2025-03-02 16:30 ` [PATCH v2 17/20] ASoC: mediatek: mt6359-accdet: Always set comp-vth to 1.6V Nícolas F. R. A. Prado
2025-03-03 11:06   ` AngeloGioacchino Del Regno
2025-03-02 16:30 ` [PATCH v2 18/20] ASoC: mediatek: mt6359-accdet: Always use EINT0 IRQ Nícolas F. R. A. Prado
2025-03-03 11:08   ` AngeloGioacchino Del Regno
2025-03-02 16:30 ` [PATCH v2 19/20] arm64: dts: mt6359: Add accessory detect node Nícolas F. R. A. Prado
2025-03-03  2:30   ` Macpaul Lin (林智斌)
2025-03-03 11:09   ` AngeloGioacchino Del Regno
2025-03-02 16:30 ` [PATCH v2 20/20] arm64: defconfig: Enable MT6359 ACCDET Nícolas F. R. A. Prado
2025-03-03 11:09   ` AngeloGioacchino Del Regno

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).