extcon: arizona: Add device bindings for the micd configurations
Subsystems (2)
PATCH v2 1/3 extcon: arizona: Add device bindings for the micd configurations
Add device bindings to support configuring the jack detection configurations. Each configuration needs to specify the connection of the mic det pins, which micbias should be used and the value of the micd polarity GPIO required to activate that configuration.
---
Changes since v1:
- Report error from arizona_extcon_get_micd_configs
Thanks,
Charles
drivers/extcon/extcon-arizona.c | 56 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 2 deletions(-)
drivers/extcon/extcon-arizona.c +54 -2
@@ -1201,10 +1201,58 @@ static void arizona_micd_set_level(struct arizona *arizona, int index,regmap_update_bits (arizona->regmap, reg, mask, level); } -static int arizona_extcon_device_get_pdata (struct arizona *arizona) +static int arizona_extcon_get_micd_configs (struct device *dev, +struct arizona *arizona) +{ +const char *const prop ="wlf,micd-configs" ; +const int entries_per_config =3 ; +struct arizona_micd_config *micd_configs; +int nconfs, ret; +int i, j; +u32 *vals; + + nconfs =device_property_read_u32_array (arizona->dev, prop,NULL ,0 ); +if (nconfs <=0 ) +return 0 ; + + vals =kcalloc (nconfs,sizeof (u32),GFP_KERNEL ); +if (!vals) +return -ENOMEM ; + + ret =device_property_read_u32_array (arizona->dev, prop, vals, nconfs); +if (ret <0 ) + goto out; + + nconfs /= entries_per_config; + + micd_configs =devm_kzalloc (dev, + nconfs *sizeof (struct arizona_micd_range ), +GFP_KERNEL ); +if (!micd_configs) { + ret = -ENOMEM ; + goto out; + } + +for (i =0 , j =0 ; i < nconfs; ++i) { + micd_configs[i].src = vals[j++] ?ARIZONA_ACCDET_SRC :0 ; + micd_configs[i].bias = vals[j++]; + micd_configs[i].gpio = vals[j++]; + } + + arizona->pdata.micd_configs = micd_configs; + arizona->pdata.num_micd_configs = nconfs; + +out: +kfree (vals); +return ret; +} + +static int arizona_extcon_device_get_pdata (struct device *dev, +struct arizona *arizona) {struct arizona_pdata *pdata = &arizona->pdata;unsigned int val =ARIZONA_ACCDET_MODE_HPL ; +int ret;device_property_read_u32 (arizona->dev,"wlf,hpdet-channel" , &val);switch (val) {
@@ -1249,6 +1297,10 @@ static int arizona_extcon_device_get_pdata(struct arizona *arizona) pdata->jd_gpio5_nopull =device_property_read_bool (arizona->dev,"wlf,use-jd2-nopull" ); + ret =arizona_extcon_get_micd_configs (dev, arizona); +if (ret <0 ) +dev_err (arizona->dev,"Failed to read micd configs: %d\n" , ret); +return 0 ; }
@@ -1270,7 +1322,7 @@ static int arizona_extcon_probe(struct platform_device *pdev)return -ENOMEM ;if (!dev_get_platdata (arizona->dev)) -arizona_extcon_device_get_pdata (arizona); +arizona_extcon_device_get_pdata (&pdev->dev, arizona); info->micvdd =devm_regulator_get (&pdev->dev,"MICVDD" );if (IS_ERR (info->micvdd)) {
Signature · 6 lines
2.1.4 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 2/3 extcon: arizona: Update device tree binding for mic detect configurations
Update the device tree binding documentation to include documentation for the wlf,micd-configs property that is used to specify the configurations for headset polarity detection (CTIA / OTMP).
---
No changes since v1.
Thanks,
Charles
Documentation/devicetree/bindings/extcon/extcon-arizona.txt | 8 ++++++++ 1 file changed, 8 insertions(+)
Documentation/devicetree/bindings/extcon/extcon-arizona.txt +8 -0
@@ -37,5 +37,13 @@ Optional properties: milliseconds. - wlf,micd-force-micbias : Force MICBIAS continuously on during microphone detection. + - wlf,micd-configs : Headset polarity configurations (generally used for + detection of CTIA / OMTP headsets), the field can be of variable length + but should always be a multiple of 3 cells long, each three cell group + represents one polarity configuration. + The first cell defines the accessory detection pin, zero will use MICDET1 + and all other values will use MICDET2. + The second cell represents the MICBIAS to be used. + The third cell represents the value of the micd-pol-gpio pin. - wlf,gpsw : Settings for the general purpose switch
Signature · 6 lines
2.1.4 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Chanwoo Choi
maintainerRe: [PATCH v2 2/3] extcon: arizona: Update device tree binding for mic detect configurations
Quoted 25 lines · Charles Keepax
Update the device tree binding documentation to include documentation for the wlf,micd-configs property that is used to specify the configurations for headset polarity detection (CTIA / OTMP).
Signed-off-by Charles Keepax <[email protected]>Acked-by Rob Herring <[email protected]>---
No changes since v1.
Thanks,
CharlesDocumentation/devicetree/bindings/extcon/extcon-arizona.txt | 8 ++++++++ 1 file changed, 8 insertions(+)Documentation/devicetree/bindings/extcon/extcon-arizona.txt +0
-0@@ -37,5 +37,13 @@ Optional properties: milliseconds. - wlf,micd-force-micbias : Force MICBIAS continuously on during microphone detection.
Documentation/devicetree/bindings/extcon/extcon-arizona.txt Optional properties: · line 49
Quoted 10 lines
Documentation/devicetree/bindings/extcon/extcon-arizona.txt +8
-0+ - wlf,micd-configs : Headset polarity configurations (generally used for + detection of CTIA / OMTP headsets), the field can be of variable length + but should always be a multiple of 3 cells long, each three cell group + represents one polarity configuration. + The first cell defines the accessory detection pin, zero will use MICDET1 + and all other values will use MICDET2. + The second cell represents the MICBIAS to be used. + The third cell represents the value of the micd-pol-gpio pin. - wlf,gpsw : Settings for the general purpose switch
Applied it.
Thanks,
Chanwoo Choi
PATCH 3/3 extcon: arizona: Add DT binding examples
In reply to Charles KeepaxAdd an example for all elements of the Arizona extcon device tree binding.
--- .../devicetree/bindings/extcon/extcon-arizona.txt | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+)
Documentation/devicetree/bindings/extcon/extcon-arizona.txt +26 -0
@@ -47,3 +47,29 @@ Optional properties: The third cell represents the value of the micd-pol-gpio pin. - wlf,gpsw : Settings for the general purpose switch + +Example: + +codec: wm8280@0 { + compatible = "wlf,wm8280"; + reg = <0>; + ... + + wlf,use-jd2; + wlf,use-jd2-nopull; + wlf,jd-invert; + + wlf,micd-software-compare; + wlf,micd-detect-debounce = <0>; + wlf,micd-pol-gpio = <&codec 2 0>; + wlf,micd-rate = <ARIZONA_MICD_TIME_8MS>; + wlf,micd-dbtime = <4>; + wlf,micd-timeout-ms = <100>; + wlf,micd-force-micbias; + wlf,micd-configs = < + 0 1 0 /* MICDET1 MICBIAS1 GPIO=low */ + 1 2 1 /* MICDET2 MICBIAS2 GPIO=high */ + >; + + wlf,gpsw = <0>; +};
Signature · 1 line
2.1.4
Chanwoo Choi
maintainerRe: [PATCH 3/3] extcon: arizona: Add DT binding examples
Quoted 33 lines · Charles Keepax
Add an example for all elements of the Arizona extcon device tree binding.
Signed-off-by Charles Keepax <[email protected]>--- .../devicetree/bindings/extcon/extcon-arizona.txt | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+)Documentation/devicetree/bindings/extcon/extcon-arizona.txt +16
-0@@ -47,3 +47,29 @@ Optional properties: The third cell represents the value of the micd-pol-gpio pin. - wlf,gpsw : Settings for the general purpose switch + +Example: + +codec: wm8280@0 { + compatible = "wlf,wm8280"; + reg = <0>; + ... + + wlf,use-jd2; + wlf,use-jd2-nopull; + wlf,jd-invert; + + wlf,micd-software-compare; + wlf,micd-detect-debounce = <0>; + wlf,micd-pol-gpio = <&codec 2 0>; + wlf,micd-rate = <ARIZONA_MICD_TIME_8MS>;
Documentation/devicetree/bindings/extcon/extcon-arizona.txt Optional properties: · line 75
Quoted 10 lines
Documentation/devicetree/bindings/extcon/extcon-arizona.txt +10
-0+ wlf,micd-dbtime = <4>; + wlf,micd-timeout-ms = <100>; + wlf,micd-force-micbias; + wlf,micd-configs = < + 0 1 0 /* MICDET1 MICBIAS1 GPIO=low */ + 1 2 1 /* MICDET2 MICBIAS2 GPIO=high */ + >; + + wlf,gpsw = <0>; +};
Looks good to me. Applied it.
Thanks,
Chanwoo Choi
Chanwoo Choi
maintainerQuoted 9 lines · Charles Keepax
Add device bindings to support configuring the jack detection configurations. Each configuration needs to specify the connection of the mic det pins, which micbias should be used and the value of the micd polarity GPIO required to activate that configuration.
Signed-off-by Charles Keepax <[email protected]>Acked-by Chanwoo Choi <[email protected]>---
Quoted 8 lines
Changes since v1:
- Report error fromarizona_extcon_get_micd_configsThanks,
Charlesdrivers/extcon/extcon-arizona.c | 56 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 2 deletions(-)
Applied it.
Thanks,
Chanwoo Choi