* [PATCH v4 00/19] Get mt6359-accdet ready for usage in Devicetree
@ 2025-03-05 18:58 Nícolas F. R. A. Prado
2025-03-05 18:58 ` [PATCH v4 01/19] dt-bindings: mfd: mediatek: mt6397: Add accdet subnode Nícolas F. R. A. Prado
` (18 more replies)
0 siblings, 19 replies; 26+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-03-05 18:58 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. Patch 1 adds the required DT bindings, patches 2 and 3 get
the mt6359-accdet driver probing, patches 4-17 clean up code related to
DT property parsing, patch 18 adds the node in the Devicetree and patch
19 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 v4:
- Moved DT-binding for accdet from standalone file
(sound/mediatek,mt6359-accdet.yaml) to parent mfd's file
(mfd/mediatek,mt6397.yaml), squashing patches 1 and 2.
- Link to v3: https://lore.kernel.org/r/20250304-mt6359-accdet-dts-v3-0-5b0eafc29f5b@collabora.com
Changes in v3:
- Removed unneeded '|' in mt6359-accdet's dt-binding description
- Removed unneeded unevaluatedProperties for accdet node in mt6397's
dt-binding
- Clarified HP_EINT pin is on the MT6359 PMIC in mediatek,hp-eint-high's
description in the mt6359-accdet dt-binding
- Link to v2: https://lore.kernel.org/r/20250302-mt6359-accdet-dts-v2-0-5bd633ee0d47@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 (17):
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 | 51 ++
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 +-
6 files changed, 198 insertions(+), 524 deletions(-)
---
base-commit: 20d5c66e1810e6e8805ec0d01373afb2dba9f51a
change-id: 20250214-mt6359-accdet-dts-00b189847f3c
Best regards,
--
Nícolas F. R. A. Prado <nfraprado@collabora.com>
^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH v4 01/19] dt-bindings: mfd: mediatek: mt6397: Add accdet subnode
2025-03-05 18:58 [PATCH v4 00/19] Get mt6359-accdet ready for usage in Devicetree Nícolas F. R. A. Prado
@ 2025-03-05 18:58 ` Nícolas F. R. A. Prado
2025-03-06 7:57 ` Krzysztof Kozlowski
2025-03-05 18:58 ` [PATCH v4 02/19] mfd: mt6397-core: Add mfd_cell for mt6359-accdet Nícolas F. R. A. Prado
` (17 subsequent siblings)
18 siblings, 1 reply; 26+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-03-05 18:58 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 accessory detection (accdet) module as a possible subnode
of the MT6359 PMIC.
Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
---
.../devicetree/bindings/mfd/mediatek,mt6397.yaml | 51 ++++++++++++++++++++++
1 file changed, 51 insertions(+)
diff --git a/Documentation/devicetree/bindings/mfd/mediatek,mt6397.yaml b/Documentation/devicetree/bindings/mfd/mediatek,mt6397.yaml
index 6a89b479d10fad3c8b61cab5a3af1453baca4d1a..51012b8bbfaef3df7bdb619a4f8d828d6f9cc15a 100644
--- a/Documentation/devicetree/bindings/mfd/mediatek,mt6397.yaml
+++ b/Documentation/devicetree/bindings/mfd/mediatek,mt6397.yaml
@@ -24,6 +24,7 @@ description: |
- LED
- Keys
- Power controller
+ - Accessory Detection
It is interfaced to host controller using SPI interface by a proprietary hardware
called PMIC wrapper or pwrap. MT6397/MT6323 PMIC is a child device of pwrap.
@@ -224,6 +225,30 @@ properties:
description:
Pin controller
+ accdet:
+ type: object
+ additionalProperties: false
+ description:
+ The Accessory Detection module found on the PMIC 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, MT6359's 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
+
required:
- compatible
- regulators
@@ -598,3 +623,29 @@ examples:
compatible = "mediatek,mt6397-rtc";
};
};
+ - |
+ #include <dt-bindings/input/input.h>
+ #include <dt-bindings/interrupt-controller/arm-gic.h>
+
+ pmic {
+ compatible = "mediatek,mt6359";
+ interrupt-controller;
+ #interrupt-cells = <2>;
+
+ accdet {
+ compatible = "mediatek,mt6359-accdet";
+ mediatek,hp-eint-high;
+ };
+
+ regulators {
+ compatible = "mediatek,mt6359-regulator";
+
+ buck_vs1 {
+ regulator-name = "vs1";
+ regulator-min-microvolt = <800000>;
+ regulator-max-microvolt = <2200000>;
+ regulator-enable-ramp-delay = <0>;
+ regulator-always-on;
+ };
+ };
+ };
--
2.48.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH v4 02/19] mfd: mt6397-core: Add mfd_cell for mt6359-accdet
2025-03-05 18:58 [PATCH v4 00/19] Get mt6359-accdet ready for usage in Devicetree Nícolas F. R. A. Prado
2025-03-05 18:58 ` [PATCH v4 01/19] dt-bindings: mfd: mediatek: mt6397: Add accdet subnode Nícolas F. R. A. Prado
@ 2025-03-05 18:58 ` Nícolas F. R. A. Prado
2025-03-13 17:02 ` (subset) " Lee Jones
2025-03-05 18:58 ` [PATCH v4 03/19] ASoC: mediatek: mt6359-accdet: Add compatible property Nícolas F. R. A. Prado
` (16 subsequent siblings)
18 siblings, 1 reply; 26+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-03-05 18:58 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>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.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] 26+ messages in thread
* [PATCH v4 03/19] ASoC: mediatek: mt6359-accdet: Add compatible property
2025-03-05 18:58 [PATCH v4 00/19] Get mt6359-accdet ready for usage in Devicetree Nícolas F. R. A. Prado
2025-03-05 18:58 ` [PATCH v4 01/19] dt-bindings: mfd: mediatek: mt6397: Add accdet subnode Nícolas F. R. A. Prado
2025-03-05 18:58 ` [PATCH v4 02/19] mfd: mt6397-core: Add mfd_cell for mt6359-accdet Nícolas F. R. A. Prado
@ 2025-03-05 18:58 ` Nícolas F. R. A. Prado
2025-03-05 18:58 ` [PATCH v4 04/19] ASoC: mediatek: mt6359-accdet: Handle hp-eint-high property Nícolas F. R. A. Prado
` (15 subsequent siblings)
18 siblings, 0 replies; 26+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-03-05 18:58 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] 26+ messages in thread
* [PATCH v4 04/19] ASoC: mediatek: mt6359-accdet: Handle hp-eint-high property
2025-03-05 18:58 [PATCH v4 00/19] Get mt6359-accdet ready for usage in Devicetree Nícolas F. R. A. Prado
` (2 preceding siblings ...)
2025-03-05 18:58 ` [PATCH v4 03/19] ASoC: mediatek: mt6359-accdet: Add compatible property Nícolas F. R. A. Prado
@ 2025-03-05 18:58 ` Nícolas F. R. A. Prado
2025-03-05 18:58 ` [PATCH v4 05/19] ASoC: mediatek: mt6359-accdet: Implement HP_EINT polarity configuration Nícolas F. R. A. Prado
` (14 subsequent siblings)
18 siblings, 0 replies; 26+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-03-05 18:58 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.
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 | 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] 26+ messages in thread
* [PATCH v4 05/19] ASoC: mediatek: mt6359-accdet: Implement HP_EINT polarity configuration
2025-03-05 18:58 [PATCH v4 00/19] Get mt6359-accdet ready for usage in Devicetree Nícolas F. R. A. Prado
` (3 preceding siblings ...)
2025-03-05 18:58 ` [PATCH v4 04/19] ASoC: mediatek: mt6359-accdet: Handle hp-eint-high property Nícolas F. R. A. Prado
@ 2025-03-05 18:58 ` Nícolas F. R. A. Prado
2025-03-05 18:58 ` [PATCH v4 06/19] ASoC: mediatek: mt6359-accdet: Drop dead code for EINT/GPIO IRQ handling Nícolas F. R. A. Prado
` (13 subsequent siblings)
18 siblings, 0 replies; 26+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-03-05 18:58 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>
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 | 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] 26+ messages in thread
* [PATCH v4 06/19] ASoC: mediatek: mt6359-accdet: Drop dead code for EINT/GPIO IRQ handling
2025-03-05 18:58 [PATCH v4 00/19] Get mt6359-accdet ready for usage in Devicetree Nícolas F. R. A. Prado
` (4 preceding siblings ...)
2025-03-05 18:58 ` [PATCH v4 05/19] ASoC: mediatek: mt6359-accdet: Implement HP_EINT polarity configuration Nícolas F. R. A. Prado
@ 2025-03-05 18:58 ` Nícolas F. R. A. Prado
2025-03-05 18:58 ` [PATCH v4 07/19] ASoC: mediatek: mt6359-accdet: Drop dead code for EINT trigger setting Nícolas F. R. A. Prado
` (12 subsequent siblings)
18 siblings, 0 replies; 26+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-03-05 18:58 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.
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 | 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] 26+ messages in thread
* [PATCH v4 07/19] ASoC: mediatek: mt6359-accdet: Drop dead code for EINT trigger setting
2025-03-05 18:58 [PATCH v4 00/19] Get mt6359-accdet ready for usage in Devicetree Nícolas F. R. A. Prado
` (5 preceding siblings ...)
2025-03-05 18:58 ` [PATCH v4 06/19] ASoC: mediatek: mt6359-accdet: Drop dead code for EINT/GPIO IRQ handling Nícolas F. R. A. Prado
@ 2025-03-05 18:58 ` Nícolas F. R. A. Prado
2025-03-05 18:58 ` [PATCH v4 08/19] ASoC: mediatek: mt6359-accdet: Drop dead code for button detection Nícolas F. R. A. Prado
` (11 subsequent siblings)
18 siblings, 0 replies; 26+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-03-05 18:58 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.
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 | 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] 26+ messages in thread
* [PATCH v4 08/19] ASoC: mediatek: mt6359-accdet: Drop dead code for button detection
2025-03-05 18:58 [PATCH v4 00/19] Get mt6359-accdet ready for usage in Devicetree Nícolas F. R. A. Prado
` (6 preceding siblings ...)
2025-03-05 18:58 ` [PATCH v4 07/19] ASoC: mediatek: mt6359-accdet: Drop dead code for EINT trigger setting Nícolas F. R. A. Prado
@ 2025-03-05 18:58 ` Nícolas F. R. A. Prado
2025-03-05 18:58 ` [PATCH v4 09/19] ASoC: mediatek: mt6359-accdet: Drop dead code for plugout-debounce Nícolas F. R. A. Prado
` (10 subsequent siblings)
18 siblings, 0 replies; 26+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-03-05 18:58 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.
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 | 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] 26+ messages in thread
* [PATCH v4 09/19] ASoC: mediatek: mt6359-accdet: Drop dead code for plugout-debounce
2025-03-05 18:58 [PATCH v4 00/19] Get mt6359-accdet ready for usage in Devicetree Nícolas F. R. A. Prado
` (7 preceding siblings ...)
2025-03-05 18:58 ` [PATCH v4 08/19] ASoC: mediatek: mt6359-accdet: Drop dead code for button detection Nícolas F. R. A. Prado
@ 2025-03-05 18:58 ` Nícolas F. R. A. Prado
2025-03-05 18:58 ` [PATCH v4 10/19] ASoC: mediatek: mt6359-accdet: Drop unused moisture variables Nícolas F. R. A. Prado
` (9 subsequent siblings)
18 siblings, 0 replies; 26+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-03-05 18:58 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.
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 | 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] 26+ messages in thread
* [PATCH v4 10/19] ASoC: mediatek: mt6359-accdet: Drop unused moisture variables
2025-03-05 18:58 [PATCH v4 00/19] Get mt6359-accdet ready for usage in Devicetree Nícolas F. R. A. Prado
` (8 preceding siblings ...)
2025-03-05 18:58 ` [PATCH v4 09/19] ASoC: mediatek: mt6359-accdet: Drop dead code for plugout-debounce Nícolas F. R. A. Prado
@ 2025-03-05 18:58 ` Nícolas F. R. A. Prado
2025-03-05 18:58 ` [PATCH v4 11/19] ASoC: mediatek: mt6359-accdet: Always use internal resistor Nícolas F. R. A. Prado
` (8 subsequent siblings)
18 siblings, 0 replies; 26+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-03-05 18:58 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.
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.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] 26+ messages in thread
* [PATCH v4 11/19] ASoC: mediatek: mt6359-accdet: Always use internal resistor
2025-03-05 18:58 [PATCH v4 00/19] Get mt6359-accdet ready for usage in Devicetree Nícolas F. R. A. Prado
` (9 preceding siblings ...)
2025-03-05 18:58 ` [PATCH v4 10/19] ASoC: mediatek: mt6359-accdet: Drop unused moisture variables Nícolas F. R. A. Prado
@ 2025-03-05 18:58 ` Nícolas F. R. A. Prado
2025-03-05 18:58 ` [PATCH v4 12/19] ASoC: mediatek: mt6359-accdet: Make PWM debounce settings internal Nícolas F. R. A. Prado
` (7 subsequent siblings)
18 siblings, 0 replies; 26+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-03-05 18:58 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.
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 | 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] 26+ messages in thread
* [PATCH v4 12/19] ASoC: mediatek: mt6359-accdet: Make PWM debounce settings internal
2025-03-05 18:58 [PATCH v4 00/19] Get mt6359-accdet ready for usage in Devicetree Nícolas F. R. A. Prado
` (10 preceding siblings ...)
2025-03-05 18:58 ` [PATCH v4 11/19] ASoC: mediatek: mt6359-accdet: Always use internal resistor Nícolas F. R. A. Prado
@ 2025-03-05 18:58 ` Nícolas F. R. A. Prado
2025-03-05 18:58 ` [PATCH v4 13/19] ASoC: mediatek: mt6359-accdet: Always use eint detect mode 4 Nícolas F. R. A. Prado
` (6 subsequent siblings)
18 siblings, 0 replies; 26+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-03-05 18:58 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.
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 | 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, ®);
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] 26+ messages in thread
* [PATCH v4 13/19] ASoC: mediatek: mt6359-accdet: Always use eint detect mode 4
2025-03-05 18:58 [PATCH v4 00/19] Get mt6359-accdet ready for usage in Devicetree Nícolas F. R. A. Prado
` (11 preceding siblings ...)
2025-03-05 18:58 ` [PATCH v4 12/19] ASoC: mediatek: mt6359-accdet: Make PWM debounce settings internal Nícolas F. R. A. Prado
@ 2025-03-05 18:58 ` Nícolas F. R. A. Prado
2025-03-05 18:58 ` [PATCH v4 14/19] ASoC: mediatek: mt6359-accdet: Always set micbias1 to 2.8V Nícolas F. R. A. Prado
` (5 subsequent siblings)
18 siblings, 0 replies; 26+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-03-05 18:58 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.
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 | 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] 26+ messages in thread
* [PATCH v4 14/19] ASoC: mediatek: mt6359-accdet: Always set micbias1 to 2.8V
2025-03-05 18:58 [PATCH v4 00/19] Get mt6359-accdet ready for usage in Devicetree Nícolas F. R. A. Prado
` (12 preceding siblings ...)
2025-03-05 18:58 ` [PATCH v4 13/19] ASoC: mediatek: mt6359-accdet: Always use eint detect mode 4 Nícolas F. R. A. Prado
@ 2025-03-05 18:58 ` Nícolas F. R. A. Prado
2025-03-05 18:58 ` [PATCH v4 15/19] ASoC: mediatek: mt6359-accdet: Always configure hardware as mic-mode 2 Nícolas F. R. A. Prado
` (4 subsequent siblings)
18 siblings, 0 replies; 26+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-03-05 18:58 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.
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 | 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, ®);
- 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, ®);
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] 26+ messages in thread
* [PATCH v4 15/19] ASoC: mediatek: mt6359-accdet: Always configure hardware as mic-mode 2
2025-03-05 18:58 [PATCH v4 00/19] Get mt6359-accdet ready for usage in Devicetree Nícolas F. R. A. Prado
` (13 preceding siblings ...)
2025-03-05 18:58 ` [PATCH v4 14/19] ASoC: mediatek: mt6359-accdet: Always set micbias1 to 2.8V Nícolas F. R. A. Prado
@ 2025-03-05 18:58 ` Nícolas F. R. A. Prado
2025-03-05 18:58 ` [PATCH v4 16/19] ASoC: mediatek: mt6359-accdet: Always set comp-vth to 1.6V Nícolas F. R. A. Prado
` (3 subsequent siblings)
18 siblings, 0 replies; 26+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-03-05 18:58 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.
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 | 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, ®);
- 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] 26+ messages in thread
* [PATCH v4 16/19] ASoC: mediatek: mt6359-accdet: Always set comp-vth to 1.6V
2025-03-05 18:58 [PATCH v4 00/19] Get mt6359-accdet ready for usage in Devicetree Nícolas F. R. A. Prado
` (14 preceding siblings ...)
2025-03-05 18:58 ` [PATCH v4 15/19] ASoC: mediatek: mt6359-accdet: Always configure hardware as mic-mode 2 Nícolas F. R. A. Prado
@ 2025-03-05 18:58 ` Nícolas F. R. A. Prado
2025-03-05 18:58 ` [PATCH v4 17/19] ASoC: mediatek: mt6359-accdet: Always use EINT0 IRQ Nícolas F. R. A. Prado
` (2 subsequent siblings)
18 siblings, 0 replies; 26+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-03-05 18:58 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.
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 | 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] 26+ messages in thread
* [PATCH v4 17/19] ASoC: mediatek: mt6359-accdet: Always use EINT0 IRQ
2025-03-05 18:58 [PATCH v4 00/19] Get mt6359-accdet ready for usage in Devicetree Nícolas F. R. A. Prado
` (15 preceding siblings ...)
2025-03-05 18:58 ` [PATCH v4 16/19] ASoC: mediatek: mt6359-accdet: Always set comp-vth to 1.6V Nícolas F. R. A. Prado
@ 2025-03-05 18:58 ` Nícolas F. R. A. Prado
2025-03-05 18:58 ` [PATCH v4 18/19] arm64: dts: mt6359: Add accessory detect node Nícolas F. R. A. Prado
2025-03-05 18:58 ` [PATCH v4 19/19] arm64: defconfig: Enable MT6359 ACCDET Nícolas F. R. A. Prado
18 siblings, 0 replies; 26+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-03-05 18:58 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.
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 | 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] 26+ messages in thread
* [PATCH v4 18/19] arm64: dts: mt6359: Add accessory detect node
2025-03-05 18:58 [PATCH v4 00/19] Get mt6359-accdet ready for usage in Devicetree Nícolas F. R. A. Prado
` (16 preceding siblings ...)
2025-03-05 18:58 ` [PATCH v4 17/19] ASoC: mediatek: mt6359-accdet: Always use EINT0 IRQ Nícolas F. R. A. Prado
@ 2025-03-05 18:58 ` Nícolas F. R. A. Prado
2025-03-05 18:58 ` [PATCH v4 19/19] arm64: defconfig: Enable MT6359 ACCDET Nícolas F. R. A. Prado
18 siblings, 0 replies; 26+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-03-05 18:58 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>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: Macpaul Lin <macpaul.lin@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] 26+ messages in thread
* [PATCH v4 19/19] arm64: defconfig: Enable MT6359 ACCDET
2025-03-05 18:58 [PATCH v4 00/19] Get mt6359-accdet ready for usage in Devicetree Nícolas F. R. A. Prado
` (17 preceding siblings ...)
2025-03-05 18:58 ` [PATCH v4 18/19] arm64: dts: mt6359: Add accessory detect node Nícolas F. R. A. Prado
@ 2025-03-05 18:58 ` Nícolas F. R. A. Prado
18 siblings, 0 replies; 26+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-03-05 18:58 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.
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
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 3a3706db29822036d25a7228f8936e2ad613b208..d4a6eeec8ba0db110dd831e146716a0e50cc294f 100644
--- a/arch/arm64/configs/defconfig
+++ b/arch/arm64/configs/defconfig
@@ -1066,6 +1066,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] 26+ messages in thread
* Re: [PATCH v4 01/19] dt-bindings: mfd: mediatek: mt6397: Add accdet subnode
2025-03-05 18:58 ` [PATCH v4 01/19] dt-bindings: mfd: mediatek: mt6397: Add accdet subnode Nícolas F. R. A. Prado
@ 2025-03-06 7:57 ` Krzysztof Kozlowski
2025-03-06 12:19 ` Nícolas F. R. A. Prado
0 siblings, 1 reply; 26+ messages in thread
From: Krzysztof Kozlowski @ 2025-03-06 7:57 UTC (permalink / raw)
To: Nícolas F. R. A. Prado
Cc: 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, kernel, linux-sound,
devicetree, linux-kernel, linux-arm-kernel, linux-mediatek,
linux-pm
On Wed, Mar 05, 2025 at 03:58:16PM -0300, Nícolas F. R. A. Prado wrote:
> Describe the accessory detection (accdet) module as a possible subnode
> of the MT6359 PMIC.
>
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
> ---
> .../devicetree/bindings/mfd/mediatek,mt6397.yaml | 51 ++++++++++++++++++++++
> 1 file changed, 51 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/mfd/mediatek,mt6397.yaml b/Documentation/devicetree/bindings/mfd/mediatek,mt6397.yaml
> index 6a89b479d10fad3c8b61cab5a3af1453baca4d1a..51012b8bbfaef3df7bdb619a4f8d828d6f9cc15a 100644
> --- a/Documentation/devicetree/bindings/mfd/mediatek,mt6397.yaml
> +++ b/Documentation/devicetree/bindings/mfd/mediatek,mt6397.yaml
> @@ -24,6 +24,7 @@ description: |
> - LED
> - Keys
> - Power controller
> + - Accessory Detection
>
> It is interfaced to host controller using SPI interface by a proprietary hardware
> called PMIC wrapper or pwrap. MT6397/MT6323 PMIC is a child device of pwrap.
> @@ -224,6 +225,30 @@ properties:
> description:
> Pin controller
>
> + accdet:
> + type: object
> + additionalProperties: false
> + description:
> + The Accessory Detection module found on the PMIC 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
You just removed the other file, no folding happened here. Drop the
accdet node and fold this into parent.
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v4 01/19] dt-bindings: mfd: mediatek: mt6397: Add accdet subnode
2025-03-06 7:57 ` Krzysztof Kozlowski
@ 2025-03-06 12:19 ` Nícolas F. R. A. Prado
2025-03-07 7:11 ` Krzysztof Kozlowski
0 siblings, 1 reply; 26+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-03-06 12:19 UTC (permalink / raw)
To: Krzysztof Kozlowski
Cc: 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, kernel, linux-sound,
devicetree, linux-kernel, linux-arm-kernel, linux-mediatek,
linux-pm
On Thu, Mar 06, 2025 at 08:57:27AM +0100, Krzysztof Kozlowski wrote:
> On Wed, Mar 05, 2025 at 03:58:16PM -0300, Nícolas F. R. A. Prado wrote:
> > Describe the accessory detection (accdet) module as a possible subnode
> > of the MT6359 PMIC.
> >
> > Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
> > ---
> > .../devicetree/bindings/mfd/mediatek,mt6397.yaml | 51 ++++++++++++++++++++++
> > 1 file changed, 51 insertions(+)
> >
> > diff --git a/Documentation/devicetree/bindings/mfd/mediatek,mt6397.yaml b/Documentation/devicetree/bindings/mfd/mediatek,mt6397.yaml
> > index 6a89b479d10fad3c8b61cab5a3af1453baca4d1a..51012b8bbfaef3df7bdb619a4f8d828d6f9cc15a 100644
> > --- a/Documentation/devicetree/bindings/mfd/mediatek,mt6397.yaml
> > +++ b/Documentation/devicetree/bindings/mfd/mediatek,mt6397.yaml
> > @@ -24,6 +24,7 @@ description: |
> > - LED
> > - Keys
> > - Power controller
> > + - Accessory Detection
> >
> > It is interfaced to host controller using SPI interface by a proprietary hardware
> > called PMIC wrapper or pwrap. MT6397/MT6323 PMIC is a child device of pwrap.
> > @@ -224,6 +225,30 @@ properties:
> > description:
> > Pin controller
> >
> > + accdet:
> > + type: object
> > + additionalProperties: false
> > + description:
> > + The Accessory Detection module found on the PMIC 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
>
> You just removed the other file, no folding happened here. Drop the
> accdet node and fold this into parent.
Sorry, I'm still not sure what you mean by folding here then. Right now the
accdet is a subnode of the PMIC. If you want me to remove the accdet node, where
would its compatible and property go?
pmic {
compatible = "mediatek,mt6359";
interrupt-controller;
#interrupt-cells = <2>;
accdet {
compatible = "mediatek,mt6359-accdet";
mediatek,hp-eint-high;
};
};
Thanks,
Nícolas
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v4 01/19] dt-bindings: mfd: mediatek: mt6397: Add accdet subnode
2025-03-06 12:19 ` Nícolas F. R. A. Prado
@ 2025-03-07 7:11 ` Krzysztof Kozlowski
2025-03-07 13:22 ` Nícolas F. R. A. Prado
0 siblings, 1 reply; 26+ messages in thread
From: Krzysztof Kozlowski @ 2025-03-07 7:11 UTC (permalink / raw)
To: Nícolas F. R. A. Prado
Cc: 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, kernel, linux-sound,
devicetree, linux-kernel, linux-arm-kernel, linux-mediatek,
linux-pm
On 06/03/2025 13:19, Nícolas F. R. A. Prado wrote:
>>> It is interfaced to host controller using SPI interface by a proprietary hardware
>>> called PMIC wrapper or pwrap. MT6397/MT6323 PMIC is a child device of pwrap.
>>> @@ -224,6 +225,30 @@ properties:
>>> description:
>>> Pin controller
>>>
>>> + accdet:
>>> + type: object
>>> + additionalProperties: false
>>> + description:
>>> + The Accessory Detection module found on the PMIC 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
>>
>> You just removed the other file, no folding happened here. Drop the
>> accdet node and fold this into parent.
>
> Sorry, I'm still not sure what you mean by folding here then. Right now the
> accdet is a subnode of the PMIC. If you want me to remove the accdet node, where
Yes
> would its compatible and property go?
compatible: nowhere, because it is close to redundancy.
property: to the parent pmic node.
pmic {
compatible = "mediatek,mt6359";
interrupt-controller;
#interrupt-cells = <2>;
mediatek,hp-eint-high;
};
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v4 01/19] dt-bindings: mfd: mediatek: mt6397: Add accdet subnode
2025-03-07 7:11 ` Krzysztof Kozlowski
@ 2025-03-07 13:22 ` Nícolas F. R. A. Prado
2025-03-09 19:50 ` Krzysztof Kozlowski
0 siblings, 1 reply; 26+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-03-07 13:22 UTC (permalink / raw)
To: Krzysztof Kozlowski
Cc: 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, kernel, linux-sound,
devicetree, linux-kernel, linux-arm-kernel, linux-mediatek,
linux-pm
On Fri, Mar 07, 2025 at 08:11:26AM +0100, Krzysztof Kozlowski wrote:
> On 06/03/2025 13:19, Nícolas F. R. A. Prado wrote:
> >>> It is interfaced to host controller using SPI interface by a proprietary hardware
> >>> called PMIC wrapper or pwrap. MT6397/MT6323 PMIC is a child device of pwrap.
> >>> @@ -224,6 +225,30 @@ properties:
> >>> description:
> >>> Pin controller
> >>>
> >>> + accdet:
> >>> + type: object
> >>> + additionalProperties: false
> >>> + description:
> >>> + The Accessory Detection module found on the PMIC 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
> >>
> >> You just removed the other file, no folding happened here. Drop the
> >> accdet node and fold this into parent.
> >
> > Sorry, I'm still not sure what you mean by folding here then. Right now the
> > accdet is a subnode of the PMIC. If you want me to remove the accdet node, where
>
> Yes
>
> > would its compatible and property go?
>
> compatible: nowhere, because it is close to redundancy.
>
> property: to the parent pmic node.
>
> pmic {
> compatible = "mediatek,mt6359";
> interrupt-controller;
> #interrupt-cells = <2>;
>
> mediatek,hp-eint-high;
> };
I'm not sure that's right. The ACCDET submodule does have some resources, IRQs,
that it registers in its mfd cell, see patch 2 of this series [1]. It also has
its own driver (sound/soc/codecs/mt6359-accdet.c) that probes based on this
compatible and handles those interrupts. Why would it not get its own node like
the other MFD cells?
[1] https://lore.kernel.org/all/20250305-mt6359-accdet-dts-v4-2-e5ffa5ee9991@collabora.com
Thanks,
Nícolas
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v4 01/19] dt-bindings: mfd: mediatek: mt6397: Add accdet subnode
2025-03-07 13:22 ` Nícolas F. R. A. Prado
@ 2025-03-09 19:50 ` Krzysztof Kozlowski
0 siblings, 0 replies; 26+ messages in thread
From: Krzysztof Kozlowski @ 2025-03-09 19:50 UTC (permalink / raw)
To: Nícolas F. R. A. Prado
Cc: 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, kernel, linux-sound,
devicetree, linux-kernel, linux-arm-kernel, linux-mediatek,
linux-pm
On 07/03/2025 14:22, Nícolas F. R. A. Prado wrote:
> On Fri, Mar 07, 2025 at 08:11:26AM +0100, Krzysztof Kozlowski wrote:
>> On 06/03/2025 13:19, Nícolas F. R. A. Prado wrote:
>>>>> It is interfaced to host controller using SPI interface by a proprietary hardware
>>>>> called PMIC wrapper or pwrap. MT6397/MT6323 PMIC is a child device of pwrap.
>>>>> @@ -224,6 +225,30 @@ properties:
>>>>> description:
>>>>> Pin controller
>>>>>
>>>>> + accdet:
>>>>> + type: object
>>>>> + additionalProperties: false
>>>>> + description:
>>>>> + The Accessory Detection module found on the PMIC 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
>>>>
>>>> You just removed the other file, no folding happened here. Drop the
>>>> accdet node and fold this into parent.
>>>
>>> Sorry, I'm still not sure what you mean by folding here then. Right now the
>>> accdet is a subnode of the PMIC. If you want me to remove the accdet node, where
>>
>> Yes
>>
>>> would its compatible and property go?
>>
>> compatible: nowhere, because it is close to redundancy.
>>
>> property: to the parent pmic node.
>>
>> pmic {
>> compatible = "mediatek,mt6359";
>> interrupt-controller;
>> #interrupt-cells = <2>;
>>
>> mediatek,hp-eint-high;
>> };
>
> I'm not sure that's right. The ACCDET submodule does have some resources, IRQs,
> that it registers in its mfd cell, see patch 2 of this series [1]. It also has
Binding is supposed to be complete, so why suddenly we have here some
resources which you did not add?
Post complete binding, so you will get proper review.
> its own driver (sound/soc/codecs/mt6359-accdet.c) that probes based on this
Drivers do not define bindings.
> compatible and handles those interrupts. Why would it not get its own node like
Sorry, cannot go. You cannot document binding post factum and claim "I
have a driver which uses that compatible".
This would be a nice way to bypass review.
> the other MFD cells?
I explained why. I gave you the exact reason.
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: (subset) [PATCH v4 02/19] mfd: mt6397-core: Add mfd_cell for mt6359-accdet
2025-03-05 18:58 ` [PATCH v4 02/19] mfd: mt6397-core: Add mfd_cell for mt6359-accdet Nícolas F. R. A. Prado
@ 2025-03-13 17:02 ` Lee Jones
0 siblings, 0 replies; 26+ messages in thread
From: Lee Jones @ 2025-03-13 17:02 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,
Nícolas F. R. A. Prado
Cc: kernel, linux-sound, devicetree, linux-kernel, linux-arm-kernel,
linux-mediatek, linux-pm, Andrew Perepech
On Wed, 05 Mar 2025 15:58:17 -0300, Nícolas F. R. A. Prado wrote:
> Add an mfd_cell for mt6359-accdet and describe its IRQ resources to
> allow the mt6359-accdet driver to probe.
>
>
Applied, thanks!
[02/19] mfd: mt6397-core: Add mfd_cell for mt6359-accdet
commit: 1b9e922a8df918812aff4090207abf4a8cb5aefa
--
Lee Jones [李琼斯]
^ permalink raw reply [flat|nested] 26+ messages in thread
end of thread, other threads:[~2025-03-13 17:02 UTC | newest]
Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-05 18:58 [PATCH v4 00/19] Get mt6359-accdet ready for usage in Devicetree Nícolas F. R. A. Prado
2025-03-05 18:58 ` [PATCH v4 01/19] dt-bindings: mfd: mediatek: mt6397: Add accdet subnode Nícolas F. R. A. Prado
2025-03-06 7:57 ` Krzysztof Kozlowski
2025-03-06 12:19 ` Nícolas F. R. A. Prado
2025-03-07 7:11 ` Krzysztof Kozlowski
2025-03-07 13:22 ` Nícolas F. R. A. Prado
2025-03-09 19:50 ` Krzysztof Kozlowski
2025-03-05 18:58 ` [PATCH v4 02/19] mfd: mt6397-core: Add mfd_cell for mt6359-accdet Nícolas F. R. A. Prado
2025-03-13 17:02 ` (subset) " Lee Jones
2025-03-05 18:58 ` [PATCH v4 03/19] ASoC: mediatek: mt6359-accdet: Add compatible property Nícolas F. R. A. Prado
2025-03-05 18:58 ` [PATCH v4 04/19] ASoC: mediatek: mt6359-accdet: Handle hp-eint-high property Nícolas F. R. A. Prado
2025-03-05 18:58 ` [PATCH v4 05/19] ASoC: mediatek: mt6359-accdet: Implement HP_EINT polarity configuration Nícolas F. R. A. Prado
2025-03-05 18:58 ` [PATCH v4 06/19] ASoC: mediatek: mt6359-accdet: Drop dead code for EINT/GPIO IRQ handling Nícolas F. R. A. Prado
2025-03-05 18:58 ` [PATCH v4 07/19] ASoC: mediatek: mt6359-accdet: Drop dead code for EINT trigger setting Nícolas F. R. A. Prado
2025-03-05 18:58 ` [PATCH v4 08/19] ASoC: mediatek: mt6359-accdet: Drop dead code for button detection Nícolas F. R. A. Prado
2025-03-05 18:58 ` [PATCH v4 09/19] ASoC: mediatek: mt6359-accdet: Drop dead code for plugout-debounce Nícolas F. R. A. Prado
2025-03-05 18:58 ` [PATCH v4 10/19] ASoC: mediatek: mt6359-accdet: Drop unused moisture variables Nícolas F. R. A. Prado
2025-03-05 18:58 ` [PATCH v4 11/19] ASoC: mediatek: mt6359-accdet: Always use internal resistor Nícolas F. R. A. Prado
2025-03-05 18:58 ` [PATCH v4 12/19] ASoC: mediatek: mt6359-accdet: Make PWM debounce settings internal Nícolas F. R. A. Prado
2025-03-05 18:58 ` [PATCH v4 13/19] ASoC: mediatek: mt6359-accdet: Always use eint detect mode 4 Nícolas F. R. A. Prado
2025-03-05 18:58 ` [PATCH v4 14/19] ASoC: mediatek: mt6359-accdet: Always set micbias1 to 2.8V Nícolas F. R. A. Prado
2025-03-05 18:58 ` [PATCH v4 15/19] ASoC: mediatek: mt6359-accdet: Always configure hardware as mic-mode 2 Nícolas F. R. A. Prado
2025-03-05 18:58 ` [PATCH v4 16/19] ASoC: mediatek: mt6359-accdet: Always set comp-vth to 1.6V Nícolas F. R. A. Prado
2025-03-05 18:58 ` [PATCH v4 17/19] ASoC: mediatek: mt6359-accdet: Always use EINT0 IRQ Nícolas F. R. A. Prado
2025-03-05 18:58 ` [PATCH v4 18/19] arm64: dts: mt6359: Add accessory detect node Nícolas F. R. A. Prado
2025-03-05 18:58 ` [PATCH v4 19/19] arm64: defconfig: Enable MT6359 ACCDET Nícolas F. R. A. Prado
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).