2015-05-04 04:43:13

by Inha Song

[permalink] [raw]
Subject: [alsa-devel] [PATCH v5 0/2] Add support for select accessory detect mode to HPDETL or HPDETR

This set of patches adds support for select accessory detect mode to HPDETL or HPDETR.

Changes in v5:
- Rebased on extcon-next branch.

Changes in v4:
- Set the hpdet_channel default value to HPDETL in variable declaration.
- Fix the indentation in binding documentation.

Changes in v3:
- Set the hpdet_channel default value to HPDETL If the value is unknown or invalid.

Changes in v2:
- Use the value in pdata instead of hpdet_channel in extcon_info.
- Wrap arizona_extcon_of_get in IS_ENABLED(CONFIG_OF).
- Change hpdet_channel type to unsigned from signed in pdata.
- Move ARIZONA_ACCDET_MODE_* define to dt-binding header and directly set it to pdata.


Inha Song (2):
extcon: arizona: Add support for select accessory detect mode when
headphone detection
mfd: arizona: Update DT binding to support hpdet channel

Documentation/devicetree/bindings/mfd/arizona.txt | 6 ++++
drivers/extcon/extcon-arizona.c | 38 ++++++++++++++++++-----
include/dt-bindings/mfd/arizona.h | 4 +++
include/linux/mfd/arizona/pdata.h | 3 ++
4 files changed, 43 insertions(+), 8 deletions(-)

--
2.0.0.390.gcb682f8


2015-05-04 04:42:57

by Inha Song

[permalink] [raw]
Subject: [alsa-devel] [PATCH v5 1/2] extcon: arizona: Add support for select accessory detect mode when headphone detection

This patch add support for select accessory detect mode to HPDETL or HPDETR.
Arizona provides a headphone detection circuit on the HPDETL and HPDETR pins
to measure the impedance of an external load connected to the headphone.

Depending on board design, headphone detect pins can change to HPDETR or HPDETL.

Signed-off-by: Inha Song <[email protected]>
Acked-by: Lee Jones <[email protected]>
Acked-by: Charles Keepax <[email protected]>
---
drivers/extcon/extcon-arizona.c | 38 ++++++++++++++++++++++++++++++--------
include/dt-bindings/mfd/arizona.h | 4 ++++
include/linux/mfd/arizona/pdata.h | 3 +++
3 files changed, 37 insertions(+), 8 deletions(-)

diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c
index 5e08c35..1ec06b4 100644
--- a/drivers/extcon/extcon-arizona.c
+++ b/drivers/extcon/extcon-arizona.c
@@ -32,13 +32,10 @@
#include <linux/mfd/arizona/core.h>
#include <linux/mfd/arizona/pdata.h>
#include <linux/mfd/arizona/registers.h>
+#include <dt-bindings/mfd/arizona.h>

#define ARIZONA_MAX_MICD_RANGE 8

-#define ARIZONA_ACCDET_MODE_MIC 0
-#define ARIZONA_ACCDET_MODE_HPL 1
-#define ARIZONA_ACCDET_MODE_HPR 2
-
#define ARIZONA_MICD_CLAMP_MODE_JDL 0x4
#define ARIZONA_MICD_CLAMP_MODE_JDH 0x5
#define ARIZONA_MICD_CLAMP_MODE_JDL_GP5H 0x9
@@ -671,9 +668,9 @@ static void arizona_identify_headphone(struct arizona_extcon_info *info)
ret = regmap_update_bits(arizona->regmap,
ARIZONA_ACCESSORY_DETECT_MODE_1,
ARIZONA_ACCDET_MODE_MASK,
- ARIZONA_ACCDET_MODE_HPL);
+ arizona->pdata.hpdet_channel);
if (ret != 0) {
- dev_err(arizona->dev, "Failed to set HPDETL mode: %d\n", ret);
+ dev_err(arizona->dev, "Failed to set HPDET mode: %d\n", ret);
goto err;
}

@@ -723,9 +720,9 @@ static void arizona_start_hpdet_acc_id(struct arizona_extcon_info *info)
ARIZONA_ACCESSORY_DETECT_MODE_1,
ARIZONA_ACCDET_SRC | ARIZONA_ACCDET_MODE_MASK,
info->micd_modes[0].src |
- ARIZONA_ACCDET_MODE_HPL);
+ arizona->pdata.hpdet_channel);
if (ret != 0) {
- dev_err(arizona->dev, "Failed to set HPDETL mode: %d\n", ret);
+ dev_err(arizona->dev, "Failed to set HPDET mode: %d\n", ret);
goto err;
}

@@ -1121,6 +1118,26 @@ static void arizona_micd_set_level(struct arizona *arizona, int index,
regmap_update_bits(arizona->regmap, reg, mask, level);
}

+static int arizona_extcon_of_get_pdata(struct arizona *arizona)
+{
+ struct arizona_pdata *pdata = &arizona->pdata;
+ unsigned int val = ARIZONA_ACCDET_MODE_HPL;
+
+ of_property_read_u32(arizona->dev->of_node, "wlf,hpdet-channel", &val);
+ switch (val) {
+ case ARIZONA_ACCDET_MODE_HPL:
+ case ARIZONA_ACCDET_MODE_HPR:
+ pdata->hpdet_channel = val;
+ break;
+ default:
+ dev_err(arizona->dev,
+ "Wrong wlf,hpdet-channel DT value %d\n", val);
+ pdata->hpdet_channel = ARIZONA_ACCDET_MODE_HPL;
+ }
+
+ return 0;
+}
+
static int arizona_extcon_probe(struct platform_device *pdev)
{
struct arizona *arizona = dev_get_drvdata(pdev->dev.parent);
@@ -1138,6 +1155,11 @@ static int arizona_extcon_probe(struct platform_device *pdev)
if (!info)
return -ENOMEM;

+ if (IS_ENABLED(CONFIG_OF)) {
+ if (!dev_get_platdata(arizona->dev))
+ arizona_extcon_of_get_pdata(arizona);
+ }
+
info->micvdd = devm_regulator_get(&pdev->dev, "MICVDD");
if (IS_ERR(info->micvdd)) {
ret = PTR_ERR(info->micvdd);
diff --git a/include/dt-bindings/mfd/arizona.h b/include/dt-bindings/mfd/arizona.h
index c7af7c7..fee48e6 100644
--- a/include/dt-bindings/mfd/arizona.h
+++ b/include/dt-bindings/mfd/arizona.h
@@ -90,4 +90,8 @@
#define ARIZONA_INMODE_SE 1
#define ARIZONA_INMODE_DMIC 2

+#define ARIZONA_ACCDET_MODE_MIC 0
+#define ARIZONA_ACCDET_MODE_HPL 1
+#define ARIZONA_ACCDET_MODE_HPR 2
+
#endif
diff --git a/include/linux/mfd/arizona/pdata.h b/include/linux/mfd/arizona/pdata.h
index 1789cb0..aa5c48b 100644
--- a/include/linux/mfd/arizona/pdata.h
+++ b/include/linux/mfd/arizona/pdata.h
@@ -121,6 +121,9 @@ struct arizona_pdata {
/** GPIO used for mic isolation with HPDET */
int hpdet_id_gpio;

+ /** Channel to use for headphone detection */
+ unsigned int hpdet_channel;
+
/** Extra debounce timeout used during initial mic detection (ms) */
int micd_detect_debounce;

--
2.0.0.390.gcb682f8

2015-05-04 04:42:29

by Inha Song

[permalink] [raw]
Subject: [alsa-devel] [PATCH v5 2/2] mfd: arizona: Update DT binding to support hpdet channel

This patch add device tree bindings for the pdata needed to configure
the Accessory Detect Mode select when Headphone detection.

Signed-off-by: Inha Song <[email protected]>
Acked-by: Lee Jones <[email protected]>
Acked-by: Charles Keepax <[email protected]>
---
Documentation/devicetree/bindings/mfd/arizona.txt | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/Documentation/devicetree/bindings/mfd/arizona.txt b/Documentation/devicetree/bindings/mfd/arizona.txt
index 7665aa9..32a71b7 100644
--- a/Documentation/devicetree/bindings/mfd/arizona.txt
+++ b/Documentation/devicetree/bindings/mfd/arizona.txt
@@ -62,6 +62,12 @@ Optional properties:
present, the number of values should be less than or equal to the
number of inputs, unspecified inputs will use the chip default.

+ - wlf,hpdet-channel : Headphone detection channel.
+ ARIZONA_ACCDET_MODE_HPL or 1 - Headphone detect mode is set to HPDETL
+ ARIZONA_ACCDET_MODE_HPR or 2 - Headphone detect mode is set to HPDETR
+ If this node is not mentioned or if the value is unknown, then
+ headphone detection mode is set to HPDETL.
+
- DCVDD-supply, MICVDD-supply : Power supplies, only need to be specified if
they are being externally supplied. As covered in
Documentation/devicetree/bindings/regulator/regulator.txt
--
2.0.0.390.gcb682f8

2015-05-04 05:15:12

by Chanwoo Choi

[permalink] [raw]
Subject: Re: [alsa-devel] [PATCH v5 1/2] extcon: arizona: Add support for select accessory detect mode when headphone detection

On 05/04/2015 01:42 PM, Inha Song wrote:
> This patch add support for select accessory detect mode to HPDETL or HPDETR.
> Arizona provides a headphone detection circuit on the HPDETL and HPDETR pins
> to measure the impedance of an external load connected to the headphone.
>
> Depending on board design, headphone detect pins can change to HPDETR or HPDETL.
>
> Signed-off-by: Inha Song <[email protected]>
> Acked-by: Lee Jones <[email protected]>
> Acked-by: Charles Keepax <[email protected]>
> ---
> drivers/extcon/extcon-arizona.c | 38 ++++++++++++++++++++++++++++++--------
> include/dt-bindings/mfd/arizona.h | 4 ++++
> include/linux/mfd/arizona/pdata.h | 3 +++
> 3 files changed, 37 insertions(+), 8 deletions(-)

Appled it on extcon-next branch.

Thanks,
Chanwoo Choi

2015-05-04 05:17:39

by Chanwoo Choi

[permalink] [raw]
Subject: Re: [alsa-devel] [PATCH v5 2/2] mfd: arizona: Update DT binding to support hpdet channel

Dear Lee,

This patch includes the documentation about extcon-arizona.c.
How are we apply this patch to either mfd git or extcon git?

Thanks,
Chanwoo Choi

On 05/04/2015 01:42 PM, Inha Song wrote:
> This patch add device tree bindings for the pdata needed to configure
> the Accessory Detect Mode select when Headphone detection.
>
> Signed-off-by: Inha Song <[email protected]>
> Acked-by: Lee Jones <[email protected]>
> Acked-by: Charles Keepax <[email protected]>
> ---
> Documentation/devicetree/bindings/mfd/arizona.txt | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/mfd/arizona.txt b/Documentation/devicetree/bindings/mfd/arizona.txt
> index 7665aa9..32a71b7 100644
> --- a/Documentation/devicetree/bindings/mfd/arizona.txt
> +++ b/Documentation/devicetree/bindings/mfd/arizona.txt
> @@ -62,6 +62,12 @@ Optional properties:
> present, the number of values should be less than or equal to the
> number of inputs, unspecified inputs will use the chip default.
>
> + - wlf,hpdet-channel : Headphone detection channel.
> + ARIZONA_ACCDET_MODE_HPL or 1 - Headphone detect mode is set to HPDETL
> + ARIZONA_ACCDET_MODE_HPR or 2 - Headphone detect mode is set to HPDETR
> + If this node is not mentioned or if the value is unknown, then
> + headphone detection mode is set to HPDETL.
> +
> - DCVDD-supply, MICVDD-supply : Power supplies, only need to be specified if
> they are being externally supplied. As covered in
> Documentation/devicetree/bindings/regulator/regulator.txt
>