linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] extcon: arizona: Add device bindings for the micd configurations
@ 2015-12-10 17:08 Charles Keepax
  2015-12-10 17:08 ` [PATCH 2/2] extcon: arizona: Update device tree binding for mic detect configurations Charles Keepax
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Charles Keepax @ 2015-12-10 17:08 UTC (permalink / raw)
  To: cw00.choi; +Cc: myungjoo.ham, devicetree, linux-kernel, patches

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 <ckeepax@opensource.wolfsonmicro.com>
---
 drivers/extcon/extcon-arizona.c | 53 +++++++++++++++++++++++++++++++++++++++--
 1 file changed, 51 insertions(+), 2 deletions(-)

diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c
index 8647533..edbf2e1 100644
--- a/drivers/extcon/extcon-arizona.c
+++ b/drivers/extcon/extcon-arizona.c
@@ -1201,7 +1201,54 @@ 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;
@@ -1249,6 +1296,8 @@ static int arizona_extcon_device_get_pdata(struct arizona *arizona)
 	pdata->jd_gpio5_nopull = device_property_read_bool(arizona->dev,
 						"wlf,use-jd2-nopull");
 
+	arizona_extcon_get_micd_configs(dev, arizona);
+
 	return 0;
 }
 
@@ -1270,7 +1319,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)) {
-- 
2.1.4


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

* [PATCH 2/2] extcon: arizona: Update device tree binding for mic detect configurations
  2015-12-10 17:08 [PATCH 1/2] extcon: arizona: Add device bindings for the micd configurations Charles Keepax
@ 2015-12-10 17:08 ` Charles Keepax
  2015-12-11  3:44   ` Rob Herring
  2015-12-14  2:03   ` Chanwoo Choi
  2015-12-14  4:11 ` [PATCH 1/2] extcon: arizona: Add device bindings for the micd configurations Chanwoo Choi
  2016-04-24 15:49 ` Pavel Machek
  2 siblings, 2 replies; 7+ messages in thread
From: Charles Keepax @ 2015-12-10 17:08 UTC (permalink / raw)
  To: cw00.choi; +Cc: myungjoo.ham, devicetree, linux-kernel, patches

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 <ckeepax@opensource.wolfsonmicro.com>
---
 Documentation/devicetree/bindings/extcon/extcon-arizona.txt | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/Documentation/devicetree/bindings/extcon/extcon-arizona.txt b/Documentation/devicetree/bindings/extcon/extcon-arizona.txt
index 238e10e..fd9b898 100644
--- a/Documentation/devicetree/bindings/extcon/extcon-arizona.txt
+++ b/Documentation/devicetree/bindings/extcon/extcon-arizona.txt
@@ -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
-- 
2.1.4


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

* Re: [PATCH 2/2] extcon: arizona: Update device tree binding for mic detect configurations
  2015-12-10 17:08 ` [PATCH 2/2] extcon: arizona: Update device tree binding for mic detect configurations Charles Keepax
@ 2015-12-11  3:44   ` Rob Herring
  2015-12-14  2:03   ` Chanwoo Choi
  1 sibling, 0 replies; 7+ messages in thread
From: Rob Herring @ 2015-12-11  3:44 UTC (permalink / raw)
  To: Charles Keepax; +Cc: cw00.choi, myungjoo.ham, devicetree, linux-kernel, patches

On Thu, Dec 10, 2015 at 05:08:19PM +0000, Charles Keepax wrote:
> 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 <ckeepax@opensource.wolfsonmicro.com>

Acked-by: Rob Herring <robh@kernel.org>

> ---
>  Documentation/devicetree/bindings/extcon/extcon-arizona.txt | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/extcon/extcon-arizona.txt b/Documentation/devicetree/bindings/extcon/extcon-arizona.txt
> index 238e10e..fd9b898 100644
> --- a/Documentation/devicetree/bindings/extcon/extcon-arizona.txt
> +++ b/Documentation/devicetree/bindings/extcon/extcon-arizona.txt
> @@ -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
> -- 
> 2.1.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe devicetree" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 2/2] extcon: arizona: Update device tree binding for mic detect configurations
  2015-12-10 17:08 ` [PATCH 2/2] extcon: arizona: Update device tree binding for mic detect configurations Charles Keepax
  2015-12-11  3:44   ` Rob Herring
@ 2015-12-14  2:03   ` Chanwoo Choi
  2015-12-14  9:18     ` Charles Keepax
  1 sibling, 1 reply; 7+ messages in thread
From: Chanwoo Choi @ 2015-12-14  2:03 UTC (permalink / raw)
  To: Charles Keepax; +Cc: myungjoo.ham, devicetree, linux-kernel, patches

Hi Charles,

On 2015년 12월 11일 02:08, Charles Keepax wrote:
> 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 <ckeepax@opensource.wolfsonmicro.com>
> ---
>  Documentation/devicetree/bindings/extcon/extcon-arizona.txt | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/extcon/extcon-arizona.txt b/Documentation/devicetree/bindings/extcon/extcon-arizona.txt
> index 238e10e..fd9b898 100644
> --- a/Documentation/devicetree/bindings/extcon/extcon-arizona.txt
> +++ b/Documentation/devicetree/bindings/extcon/extcon-arizona.txt
> @@ -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.

I think that you better to add the example using the 'wlf,micd-configs'
to improve the understanding of using this property.
because the number of 'wlf,micd-configs' value is not fixed.

Also,
How about do you add the real example for all arizona properties on separate patch?

Thanks,
Chanwoo Choi

>  
>    - wlf,gpsw : Settings for the general purpose switch
> 


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

* Re: [PATCH 1/2] extcon: arizona: Add device bindings for the micd configurations
  2015-12-10 17:08 [PATCH 1/2] extcon: arizona: Add device bindings for the micd configurations Charles Keepax
  2015-12-10 17:08 ` [PATCH 2/2] extcon: arizona: Update device tree binding for mic detect configurations Charles Keepax
@ 2015-12-14  4:11 ` Chanwoo Choi
  2016-04-24 15:49 ` Pavel Machek
  2 siblings, 0 replies; 7+ messages in thread
From: Chanwoo Choi @ 2015-12-14  4:11 UTC (permalink / raw)
  To: Charles Keepax; +Cc: myungjoo.ham, devicetree, linux-kernel, patches

Hi Charles,

On 2015년 12월 11일 02:08, Charles Keepax wrote:
> 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 <ckeepax@opensource.wolfsonmicro.com>
> ---
>  drivers/extcon/extcon-arizona.c | 53 +++++++++++++++++++++++++++++++++++++++--
>  1 file changed, 51 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c
> index 8647533..edbf2e1 100644
> --- a/drivers/extcon/extcon-arizona.c
> +++ b/drivers/extcon/extcon-arizona.c
> @@ -1201,7 +1201,54 @@ 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;
> @@ -1249,6 +1296,8 @@ static int arizona_extcon_device_get_pdata(struct arizona *arizona)
>  	pdata->jd_gpio5_nopull = device_property_read_bool(arizona->dev,
>  						"wlf,use-jd2-nopull");
>  
> +	arizona_extcon_get_micd_configs(dev, arizona);

You need to check out the return value of arizona_extcon_get_micd_configs().
If arizona_extcon_get_micd_configs() returns the error, 
arizona_extcon_device_get_pdata() don't handle the error case.

> +
>  	return 0;
>  }
>  
> @@ -1270,7 +1319,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)) {
> 

Except for above comment, Looks good to me.
Acked-by: Chanwoo Choi <cw00.choi@samsung.com>

Thanks,
Chanwoo Choi


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

* Re: [PATCH 2/2] extcon: arizona: Update device tree binding for mic detect configurations
  2015-12-14  2:03   ` Chanwoo Choi
@ 2015-12-14  9:18     ` Charles Keepax
  0 siblings, 0 replies; 7+ messages in thread
From: Charles Keepax @ 2015-12-14  9:18 UTC (permalink / raw)
  To: Chanwoo Choi; +Cc: myungjoo.ham, devicetree, linux-kernel, patches

On Mon, Dec 14, 2015 at 11:03:58AM +0900, Chanwoo Choi wrote:
> Hi Charles,
> 
> On 2015년 12월 11일 02:08, Charles Keepax wrote:
> > 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 <ckeepax@opensource.wolfsonmicro.com>
> > ---
> >  Documentation/devicetree/bindings/extcon/extcon-arizona.txt | 8 ++++++++
> >  1 file changed, 8 insertions(+)
> > 
> > diff --git a/Documentation/devicetree/bindings/extcon/extcon-arizona.txt b/Documentation/devicetree/bindings/extcon/extcon-arizona.txt
> > index 238e10e..fd9b898 100644
> > --- a/Documentation/devicetree/bindings/extcon/extcon-arizona.txt
> > +++ b/Documentation/devicetree/bindings/extcon/extcon-arizona.txt
> > @@ -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.
> 
> I think that you better to add the example using the 'wlf,micd-configs'
> to improve the understanding of using this property.
> because the number of 'wlf,micd-configs' value is not fixed.
> 
> Also,
> How about do you add the real example for all arizona properties on separate patch?

Yeah that seems sensible I will do a patch to add an example to
this file.

Thanks,
Charles

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

* Re: [PATCH 1/2] extcon: arizona: Add device bindings for the micd configurations
  2015-12-10 17:08 [PATCH 1/2] extcon: arizona: Add device bindings for the micd configurations Charles Keepax
  2015-12-10 17:08 ` [PATCH 2/2] extcon: arizona: Update device tree binding for mic detect configurations Charles Keepax
  2015-12-14  4:11 ` [PATCH 1/2] extcon: arizona: Add device bindings for the micd configurations Chanwoo Choi
@ 2016-04-24 15:49 ` Pavel Machek
  2 siblings, 0 replies; 7+ messages in thread
From: Pavel Machek @ 2016-04-24 15:49 UTC (permalink / raw)
  To: Charles Keepax; +Cc: cw00.choi, myungjoo.ham, devicetree, linux-kernel, patches

On Thu 2015-12-10 17:08:18, Charles Keepax wrote:
> 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 <ckeepax@opensource.wolfsonmicro.com>


Reviewed-by: Pavel Machek <pavel@ucw.cz>

> ---
>  drivers/extcon/extcon-arizona.c | 53 +++++++++++++++++++++++++++++++++++++++--
>  1 file changed, 51 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c
> index 8647533..edbf2e1 100644
> --- a/drivers/extcon/extcon-arizona.c
> +++ b/drivers/extcon/extcon-arizona.c
> @@ -1201,7 +1201,54 @@ 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;
> @@ -1249,6 +1296,8 @@ static int arizona_extcon_device_get_pdata(struct arizona *arizona)
>  	pdata->jd_gpio5_nopull = device_property_read_bool(arizona->dev,
>  						"wlf,use-jd2-nopull");
>  
> +	arizona_extcon_get_micd_configs(dev, arizona);
> +
>  	return 0;
>  }
>  
> @@ -1270,7 +1319,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)) {

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

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

end of thread, other threads:[~2016-04-24 15:49 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-10 17:08 [PATCH 1/2] extcon: arizona: Add device bindings for the micd configurations Charles Keepax
2015-12-10 17:08 ` [PATCH 2/2] extcon: arizona: Update device tree binding for mic detect configurations Charles Keepax
2015-12-11  3:44   ` Rob Herring
2015-12-14  2:03   ` Chanwoo Choi
2015-12-14  9:18     ` Charles Keepax
2015-12-14  4:11 ` [PATCH 1/2] extcon: arizona: Add device bindings for the micd configurations Chanwoo Choi
2016-04-24 15:49 ` Pavel Machek

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).